Skip to content

chore: add extension for nodenext #2265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
"generatePackages": "pnpm dlx tsx ./scripts/generatePackages.ts",
"generateGlobalSdkPackage": "pnpm dlx tsx ./scripts/updateGlobalSdkPackage.ts",
"prebuild": "pnpm run generatePackages && pnpm run generateAlias && pnpm format",
"build": "pnpm turbo build",
"build:packages": "pnpm turbo run build",
"fix-import-extensions": "pnpm dlx tsx ./scripts/fix-import-extensions.ts",
"build": "pnpm run build:packages && pnpm run fix-import-extensions",
"typecheck": "pnpm turbo typecheck",
"build:profile": "cross-env PROFILE=true pnpm run build",
"commit": "npx git-cz -a",
Expand Down
22 changes: 11 additions & 11 deletions packages/client/src/bridge.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/** List all helpers required by APIs */
export { isJSONObject } from './helpers/json'
export { waitForResource } from './internal/async/interval-retrier'
export type { WaitForOptions } from './internal/async/interval-retrier'
export { API } from './scw/api'
export type { DefaultValues } from './scw/client-settings'
export { isJSONObject } from './helpers/json.js'
export { waitForResource } from './internal/async/interval-retrier.js'
export type { WaitForOptions } from './internal/async/interval-retrier.js'
export { API } from './scw/api.js'
export type { DefaultValues } from './scw/client-settings.js'
export type {
Money,
ServiceInfo,
ScwFile,
TimeSeries,
} from './scw/custom-types'
export { Decimal } from './scw/custom-types'
} from './scw/custom-types.js'
export { Decimal } from './scw/custom-types.js'
export {
marshalScwFile,
marshalMoney,
Expand All @@ -23,14 +23,14 @@ export {
unmarshalTimeSeries,
unmarshalTimeSeriesPoint,
unmarshalDecimal,
} from './scw/custom-marshalling'
export { enrichForPagination } from './scw/fetch/resource-paginator'
export type { Region, Zone } from './scw/locality'
} from './scw/custom-marshalling.js'
export { enrichForPagination } from './scw/fetch/resource-paginator.js'
export type { Region, Zone } from './scw/locality.js'
export {
resolveOneOf,
unmarshalDate,
unmarshalArrayOfObject,
unmarshalMapOfObject,
urlParams,
validatePathParam,
} from './helpers/marshalling'
} from './helpers/marshalling.js'
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @vitest-environment jsdom
import { describe, expect, it } from 'vitest'
import { isBrowser } from '../is-browser'
import { isBrowser } from '../is-browser.js'

describe('isBrowser', () => {
it('returns true by default', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @vitest-environment node

import { describe, expect, it } from 'vitest'
import { isBrowser } from '../is-browser'
import { isBrowser } from '../is-browser.js'

describe('isBrowser', () => {
it('returns false by default', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/helpers/__tests__/json.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from 'vitest'
import { isJSON, isJSONObject } from '../json'
import { isJSON, isJSONObject } from '../json.js'

describe('isJSON', () => {
test.each(['str', 200, true, null, [true, 'two', 3], { key: 'value' }])(
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/helpers/__tests__/marshalling.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { describe, expect, it } from 'vitest'
import { isJSONObject } from '../json'
import { isJSONObject } from '../json.js'
import {
resolveOneOf,
unmarshalArrayOfObject,
unmarshalDate,
unmarshalMapOfObject,
urlParams,
validatePathParam,
} from '../marshalling'
} from '../marshalling.js'

describe('validatePathParam', () => {
it('returns parameter for a non-empty string', () => {
Expand Down
32 changes: 16 additions & 16 deletions packages/client/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
export type {
WaitForOptions,
WaitForStopCondition,
} from './internal/async/interval-retrier'
} from './internal/async/interval-retrier.js'
export type {
NetworkInterceptors,
RequestInterceptor,
ResponseInterceptor,
ResponseErrorInterceptor,
} from './internal/interceptors/types'
} from './internal/interceptors/types.js'
export { enableConsoleLogger, setLogger } from './internal/logger'
export type { Logger } from './internal/logger/logger'
export { createClient, createAdvancedClient } from './scw/client'
export { AUTH_HEADER_KEY, SESSION_HEADER_KEY } from './scw/constants'
export type { Client } from './scw/client'
export type { Profile } from './scw/client-ini-profile'
export type { Settings } from './scw/client-settings'
export type { Logger } from './internal/logger/logger.js'
export { createClient, createAdvancedClient } from './scw/client.js'
export { AUTH_HEADER_KEY, SESSION_HEADER_KEY } from './scw/constants.js'
export type { Client } from './scw/client.js'
export type { Profile } from './scw/client-ini-profile.js'
export type { Settings } from './scw/client-settings.js'
export {
withAdditionalInterceptors,
withDefaultPageSize,
withHTTPClient,
withProfile,
withUserAgent,
withUserAgentSuffix,
} from './scw/client-ini-factory'
export type { ClientConfig } from './scw/client-ini-factory'
export { Decimal } from './scw/custom-types'
export type { Money, ScwFile, TimeSeries } from './scw/custom-types'
} from './scw/client-ini-factory.js'
export type { ClientConfig } from './scw/client-ini-factory.js'
export { Decimal } from './scw/custom-types.js'
export type { Money, ScwFile, TimeSeries } from './scw/custom-types.js'
export * as Errors from './scw/errors/standard'
export type { Region, Zone } from './scw/locality'
export * from './internals'
export { toApiLocality } from './scw/locality'
export type { ApiLocality } from './scw/locality'
export type { Region, Zone } from './scw/locality.js'
export * from './internals.js'
export { toApiLocality } from './scw/locality.js'
export type { ApiLocality } from './scw/locality.js'
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
createFixedIntervalStrategy,
tryAtIntervals,
waitForResource,
} from '../interval-retrier'
import { sleep } from '../sleep'
} from '../interval-retrier.js'
import { sleep } from '../sleep.js'

describe('createFixedIntervalStrategy', () => {
it('always returns the same interval', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest'
import { sleep } from '../sleep'
import { sleep } from '../sleep.js'

beforeAll(() => {
vi.useFakeTimers()
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/internal/async/interval-retrier.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sleep } from './sleep'
import { sleep } from './sleep.js'

const DEFAULT_TIMEOUT_SECONDS = 300
const DEFAULT_MIN_DELAY_SECONDS = 1
Expand Down Expand Up @@ -115,9 +115,9 @@
// Break if timeout has been reached
if (timeoutTimestamp <= Date.now() + delay) break
// Wait before the next retry
await sleep(delay)

Check warning on line 118 in packages/client/src/internal/async/interval-retrier.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected `await` inside a loop
// Retry
const { value, done } = await retry()

Check warning on line 120 in packages/client/src/internal/async/interval-retrier.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected `await` inside a loop
if (done) return value
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest'
import {
composeRequestInterceptors,
composeResponseErrorInterceptors,
} from '../composer'
} from '../composer.js'

describe('composeRequestInterceptors', () => {
it('modifies the request header', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { addAsyncHeaderInterceptor, addHeaderInterceptor } from '../helpers'
import { addAsyncHeaderInterceptor, addHeaderInterceptor } from '../helpers.js'

describe('addHeaderInterceptor', () => {
it('insertsnothing if value is undefined', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/internal/interceptors/composer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
RequestInterceptor,
ResponseErrorInterceptor,
ResponseInterceptor,
} from './types'
} from './types.js'

/**
* Composes request interceptors.
Expand Down Expand Up @@ -49,7 +49,7 @@
let prevError = error
for (const interceptor of interceptors) {
try {
const res = await interceptor({ request, error: prevError })

Check warning on line 52 in packages/client/src/internal/interceptors/composer.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected `await` inside a loop

return res
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/internal/interceptors/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RequestInterceptor } from './types'
import type { RequestInterceptor } from './types.js'

/**
* Adds an header to a request through an interceptor.
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/internal/logger/__tests__/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, it, vi } from 'vitest'
import { enableConsoleLogger, getLogger, setLogger } from '..'
import { ConsoleLogger } from '../console-logger'
import type { LogLevel } from '../level-resolver'
import { ConsoleLogger } from '../console-logger.js'
import type { LogLevel } from '../level-resolver.js'

const makeCallbackConsole = (
onMessage: (str: string) => void,
Expand Down
6 changes: 3 additions & 3 deletions packages/client/src/internal/logger/console-logger.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LevelResolver, shouldLog } from './level-resolver'
import type { LogLevel } from './level-resolver'
import type { Logger } from './logger'
import { LevelResolver, shouldLog } from './level-resolver.js'
import type { LogLevel } from './level-resolver.js'
import type { Logger } from './logger.js'

/**
* A Logger using console output.
Expand Down
6 changes: 3 additions & 3 deletions packages/client/src/internal/logger/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ConsoleLogger } from './console-logger'
import type { LogLevel } from './level-resolver'
import type { Logger } from './logger'
import { ConsoleLogger } from './console-logger.js'
import type { LogLevel } from './level-resolver.js'
import type { Logger } from './logger.js'

let sdkLogger: Logger = new ConsoleLogger('silent')

Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/internal/logger/logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { LogLevel } from './level-resolver'
import type { LogLevel } from './level-resolver.js'

/**
* Logger.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
isURL,
isUUID,
isZone,
} from '../string-validation'
} from '../string-validation.js'

const validUUIDs = [
'00000000-0000-0000-0000-000000000000',
Expand Down
20 changes: 10 additions & 10 deletions packages/client/src/internals.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
export { isJSONObject } from './helpers/json'
export { isJSONObject } from './helpers/json.js'
export {
createExponentialBackoffStrategy,
tryAtIntervals,
waitForResource,
} from './internal/async/interval-retrier'
export { addAsyncHeaderInterceptor } from './internal/interceptors/helpers'
export { API } from './scw/api'
} from './internal/async/interval-retrier.js'
export { addAsyncHeaderInterceptor } from './internal/interceptors/helpers.js'
export { API } from './scw/api.js'

export { authenticateWithSessionToken } from './scw/auth'
export { authenticateWithSessionToken } from './scw/auth.js'

export type { DefaultValues } from './scw/client-settings'
export type { DefaultValues } from './scw/client-settings.js'
export {
marshalBlobToScwFile,
marshalDecimal,
Expand All @@ -23,14 +23,14 @@ export {
unmarshalServiceInfo,
unmarshalTimeSeries,
unmarshalTimeSeriesPoint,
} from './scw/custom-marshalling'
export type { ServiceInfo } from './scw/custom-types'
} from './scw/custom-marshalling.js'
export type { ServiceInfo } from './scw/custom-types.js'
export {
resolveOneOf,
unmarshalDate,
unmarshalArrayOfObject,
unmarshalMapOfObject,
urlParams,
validatePathParam,
} from './helpers/marshalling'
export { enrichForPagination } from './scw/fetch/resource-paginator'
} from './helpers/marshalling.js'
export { enrichForPagination } from './scw/fetch/resource-paginator.js'
4 changes: 2 additions & 2 deletions packages/client/src/scw/__tests__/api.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'
import { API } from '../api'
import { createClient } from '../client'
import { API } from '../api.js'
import { createClient } from '../client.js'

class CustomAPI extends API {
getBaseURL = (): string => {
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/scw/__tests__/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
obfuscateAuthHeadersEntry,
obfuscateToken,
obfuscateUUID,
} from '../auth'
import type { AuthenticationSecrets } from '../client-ini-profile'
} from '../auth.js'
import type { AuthenticationSecrets } from '../client-ini-profile.js'

describe('obfuscateToken', () => {
it('hides anything after 5 characters', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import type { ClientConfig } from '../client-ini-factory'
import type { ClientConfig } from '../client-ini-factory.js'
import {
withAdditionalInterceptors,
withDefaultPageSize,
Expand All @@ -8,9 +8,9 @@ import {
withProfile,
withUserAgent,
withUserAgentSuffix,
} from '../client-ini-factory'
import type { Profile } from '../client-ini-profile'
import type { Settings } from '../client-settings'
} from '../client-ini-factory.js'
import type { Profile } from '../client-ini-profile.js'
import type { Settings } from '../client-settings.js'

const EMPTY_PROFILE: Profile = {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, expect, it, test } from 'vitest'
import {
assertValidAuthenticationSecrets,
hasAuthenticationSecrets,
} from '../client-ini-profile'
} from '../client-ini-profile.js'

describe('hasAuthenticationSecrets', () => {
it('confirms a non-empty payload', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/scw/__tests__/client-settings.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'
import type { Settings } from '../client-settings'
import { assertValidSettings } from '../client-settings'
import type { Settings } from '../client-settings.js'
import { assertValidSettings } from '../client-settings.js'

const VALID_SETTINGS: Settings = {
apiURL: 'https://api.scaleway.com',
Expand Down
8 changes: 4 additions & 4 deletions packages/client/src/scw/__tests__/client.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { describe, expect, it } from 'vitest'
import { createAdvancedClient, createClient } from '../client'
import { withProfile } from '../client-ini-factory'
import type { ClientConfig } from '../client-ini-factory'
import type { Settings } from '../client-settings'
import { withProfile } from '../client-ini-factory.js'
import type { ClientConfig } from '../client-ini-factory.js'
import type { Settings } from '../client-settings.js'
import { createAdvancedClient, createClient } from '../client.js'

const withApiURL =
(apiURL: string): ClientConfig =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
unmarshalServiceInfo,
unmarshalTimeSeries,
unmarshalTimeSeriesPoint,
} from '../custom-marshalling'
import { Decimal } from '../custom-types'
} from '../custom-marshalling.js'
import { Decimal } from '../custom-types.js'

describe('unmarshalMoney', () => {
it('returns the proper object', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/scw/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Client } from './client'
import type { Client } from './client.js'

/**
* Abstract class to instantiate API from a {@link Client}.
Expand Down
10 changes: 5 additions & 5 deletions packages/client/src/scw/auth.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
addAsyncHeaderInterceptor,
addHeaderInterceptor,
} from '../internal/interceptors/helpers'
import type { RequestInterceptor } from '../internal/interceptors/types'
import { assertValidAuthenticationSecrets } from './client-ini-profile'
import type { AuthenticationSecrets } from './client-ini-profile'
import { AUTH_HEADER_KEY, SESSION_HEADER_KEY } from './constants'
} from '../internal/interceptors/helpers.js'
import type { RequestInterceptor } from '../internal/interceptors/types.js'
import { assertValidAuthenticationSecrets } from './client-ini-profile.js'
import type { AuthenticationSecrets } from './client-ini-profile.js'
import { AUTH_HEADER_KEY, SESSION_HEADER_KEY } from './constants.js'

interface TokenAccessor {
(): Promise<string | undefined>
Expand Down
Loading
Loading