@scaleway/sdk-client 2.2.2 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,4 +29,4 @@ export declare const camelize: (str: string) => string;
29
29
  *
30
30
  * @internal
31
31
  */
32
- export declare const camelizeKeys: <T>(obj: object | unknown[] | unknown, ignoreKeys?: string[]) => T;
32
+ export declare const camelizeKeys: <T>(obj: unknown, ignoreKeys?: string[]) => T;
@@ -30,7 +30,7 @@ export declare const resolveOneOf: <T>(list: {
30
30
  default?: T | undefined;
31
31
  }[], isRequired?: boolean) => Record<string, T>;
32
32
  type URLParameterValue = string | number | boolean | Date | null;
33
- export declare const urlParams: (...paramTuples: Readonly<[string, URLParameterValue | URLParameterValue[] | undefined]>[]) => URLSearchParams;
33
+ export declare const urlParams: (...paramTuples: (readonly [string, URLParameterValue[] | URLParameterValue | undefined])[]) => URLSearchParams;
34
34
  /**
35
35
  * Unmarshals data to Date object.
36
36
  *
@@ -107,5 +107,5 @@ type ResourceFetcher<T, R> = (request: R) => Promise<T>;
107
107
  *
108
108
  * @public
109
109
  */
110
- export declare const waitForResource: <R, T>(stop: WaitForStopCondition<T>, fetcher: ResourceFetcher<T, R>, request: R, options?: WaitForOptions<T>, strategy?: IntervalStrategy) => Promise<Awaited<T>>;
110
+ export declare const waitForResource: <R, T>(stop: WaitForStopCondition<T>, fetcher: ResourceFetcher<T, R>, request: R, options?: WaitForOptions<T> | undefined, strategy?: IntervalStrategy) => Promise<Awaited<T>>;
111
111
  export {};
@@ -13,7 +13,6 @@ describe("composeRequestInterceptors", () => {
13
13
  describe("composeResponseErrorInterceptors", () => {
14
14
  it("passes the error to all interceptors if they all throw", () => {
15
15
  class NumberError extends Error {
16
- counter;
17
16
  constructor(obj) {
18
17
  super();
19
18
  this.counter = obj;
@@ -8,7 +8,7 @@ import type { RequestInterceptor } from './types.js';
8
8
  *
9
9
  * @internal
10
10
  */
11
- export declare const addHeaderInterceptor: (key: string, value?: string) => RequestInterceptor;
11
+ export declare const addHeaderInterceptor: (key: string, value?: string | undefined) => RequestInterceptor;
12
12
  /**
13
13
  * Adds asynchronously an header to a request through an interceptor.
14
14
  *
@@ -10,11 +10,14 @@ import { LevelResolver, shouldLog } from "./level-resolver.js";
10
10
  * @internal
11
11
  */
12
12
  var ConsoleLogger = class {
13
- level;
14
13
  constructor(logLevel, prefix = "", output = console) {
15
14
  this.logLevel = logLevel;
16
15
  this.prefix = prefix;
17
16
  this.output = output;
17
+ this.debug = this.makeMethod("debug");
18
+ this.error = this.makeMethod("error");
19
+ this.info = this.makeMethod("info");
20
+ this.warn = this.makeMethod("warn");
18
21
  this.level = LevelResolver[this.logLevel];
19
22
  }
20
23
  makeMethod(method) {
@@ -22,10 +25,6 @@ var ConsoleLogger = class {
22
25
  if (shouldLog(this.level, method)) this.output[method](this.prefix ? `${this.prefix} ${message}` : message);
23
26
  };
24
27
  }
25
- debug = this.makeMethod("debug");
26
- error = this.makeMethod("error");
27
- info = this.makeMethod("info");
28
- warn = this.makeMethod("warn");
29
28
  };
30
29
  //#endregion
31
30
  export { ConsoleLogger };
@@ -1,4 +1,3 @@
1
- import type { LogLevel } from './level-resolver.js';
2
1
  import type { Logger } from './logger.js';
3
2
  /**
4
3
  * Sets a logger to be used within the SDK.
@@ -16,7 +15,7 @@ export declare const setLogger: (logger: Readonly<Logger>) => void;
16
15
  *
17
16
  * @public
18
17
  */
19
- export declare const enableConsoleLogger: (logLevel?: LogLevel, prefix?: string) => void;
18
+ export declare const enableConsoleLogger: (logLevel?: "debug" | "error" | "info" | "silent" | "warn", prefix?: string) => void;
20
19
  /**
21
20
  * Returns the active SDK logger.
22
21
  *
@@ -6,4 +6,4 @@ export declare enum LevelResolver {
6
6
  debug = 4
7
7
  }
8
8
  export type LogLevel = keyof typeof LevelResolver;
9
- export declare const shouldLog: (currentLevel: LevelResolver, level: LogLevel) => boolean;
9
+ export declare const shouldLog: (currentLevel: LevelResolver, level: "debug" | "error" | "info" | "silent" | "warn") => boolean;
package/dist/package.js CHANGED
@@ -1,6 +1,6 @@
1
1
  var package_default = {
2
2
  name: "@scaleway/sdk-client",
3
- version: "2.2.2",
3
+ version: "2.3.0",
4
4
  license: "Apache-2.0",
5
5
  description: "Scaleway SDK Client",
6
6
  keywords: [
@@ -10,8 +10,8 @@ var package_default = {
10
10
  "client"
11
11
  ],
12
12
  scripts: {
13
- "typecheck": "tsc --noEmit",
14
- "type:generate": "tsc --declaration -p tsconfig.build.json",
13
+ "typecheck": "tsgo --noEmit",
14
+ "type:generate": "tsgo --declaration -p tsconfig.build.json",
15
15
  "build": "vite build --config ../../vite.config.ts && pnpm run type:generate && tsc-alias -p tsconfig.build.json",
16
16
  "build:profile": "npx vite-bundle-visualizer -c ../../vite.config.ts"
17
17
  },
@@ -27,7 +27,8 @@ var package_default = {
27
27
  exports: { ".": {
28
28
  "types": "./dist/index.d.ts",
29
29
  "default": "./dist/index.js"
30
- } }
30
+ } },
31
+ devDependencies: { "@repo/configs": "workspace:^" }
31
32
  };
32
33
  //#endregion
33
34
  export { package_default as default };
@@ -3,10 +3,13 @@ import { createClient } from "../client.js";
3
3
  import { describe, expect, it } from "vitest";
4
4
  //#region src/scw/__tests__/api.test.ts
5
5
  var CustomAPI = class extends API {
6
- getBaseURL = () => {
7
- if (!this.client.settings.apiURL) throw new Error("API URL is missing");
8
- return this.client.settings.apiURL;
9
- };
6
+ constructor(..._args) {
7
+ super(..._args);
8
+ this.getBaseURL = () => {
9
+ if (!this.client.settings.apiURL) throw new Error("API URL is missing");
10
+ return this.client.settings.apiURL;
11
+ };
12
+ }
10
13
  };
11
14
  describe("API", () => {
12
15
  it("binds methods properly", () => {
@@ -1,5 +1,4 @@
1
1
  import type { NetworkInterceptors } from '../index.js';
2
- import type { Profile } from './client-ini-profile.js';
3
2
  import type { Settings } from './client-settings.js';
4
3
  /**
5
4
  * A factory to build {@link Settings}.
@@ -17,7 +16,7 @@ export type ClientConfig = (obj: Settings) => Settings;
17
16
  *
18
17
  * @public
19
18
  */
20
- export declare const withProfile: (profile: Readonly<Profile>) => (settings: Readonly<Settings>) => Settings;
19
+ export declare const withProfile: (profile: Readonly<Partial<import("./client-ini-profile.js").ProfileDefaultValues & import("./client-ini-profile.js").AuthenticationSecrets>>) => (settings: Readonly<Settings>) => Settings;
21
20
  /**
22
21
  * Instantiates the SDK with a different HTTP client.
23
22
  *
@@ -101,4 +101,4 @@ export declare const unmarshalDates: <T>(obj: unknown, keys: string[]) => T;
101
101
  *
102
102
  * @internal
103
103
  */
104
- export declare const unmarshalAnyRes: <T>(obj: unknown, ignoreKeys?: string[], dateKeys?: string[]) => T;
104
+ export declare const unmarshalAnyRes: <T>(obj: unknown, ignoreKeys?: string[], dateKeys?: string[] | undefined) => T;
@@ -3,12 +3,11 @@
3
3
  * Comparable to language-native decimal formats, such as Java's BigDecimal or Python's decimal.Decimal.
4
4
  * Lookup protobuf google.type.Decimal for details */
5
5
  var Decimal = class {
6
- str;
7
6
  constructor(v) {
7
+ this.toString = () => this.str;
8
+ this.marshal = () => ({ value: this.str });
8
9
  this.str = v;
9
10
  }
10
- toString = () => this.str;
11
- marshal = () => ({ value: this.str });
12
11
  };
13
12
  //#endregion
14
13
  export { Decimal };
@@ -7,4 +7,4 @@ import { QuotasExceededError } from '../standard/quotas-exceeded-error.js';
7
7
  *
8
8
  * @public
9
9
  */
10
- export declare const mapInvalidRequestFromJSON: (status: number, obj: Readonly<JSONObject>) => QuotasExceededError | InvalidArgumentsError | ScalewayError;
10
+ export declare const mapInvalidRequestFromJSON: (status: number, obj: Readonly<JSONObject>) => InvalidArgumentsError | QuotasExceededError | ScalewayError;
@@ -26,8 +26,6 @@ var buildDefaultMessage = (status, body) => {
26
26
  * @public
27
27
  */
28
28
  var ScalewayError = class ScalewayError extends Error {
29
- /** The message originating from the payload. */
30
- rawMessage;
31
29
  constructor(status, body, message = buildDefaultMessage(status, body)) {
32
30
  super(message);
33
31
  this.status = status;
@@ -9,7 +9,7 @@ export type PaginatedFetcher<T, R extends PaginationOptions = PaginationOptions>
9
9
  export type PaginatedContent<K extends string, T = unknown> = PaginatedResponse & {
10
10
  [key in K]: T[];
11
11
  };
12
- export declare const extract: <K extends string>(key: K) => <T extends PaginatedContent<K>>(result: T) => T[K];
12
+ export declare const extract: <K extends string>(key: K) => <T extends PaginatedContent<K, unknown>>(result: T) => T[K];
13
13
  /**
14
14
  * Fetches a paginated resource.
15
15
  *
@@ -29,7 +29,7 @@ export declare function fetchPaginated<K extends string, T extends PaginatedCont
29
29
  * @param initial - The first page
30
30
  * @returns A resources array Promise
31
31
  */
32
- export declare const fetchAll: <K extends string, T extends PaginatedContent<K>, R extends PaginationOptions>(key: K, fetcher: PaginatedFetcher<T, R>, request: R, initial?: Promise<T>) => Promise<(Awaited<T[K]> extends infer T_1 ? T_1 extends Awaited<T[K]> ? T_1 extends readonly (infer InnerArr)[] ? InnerArr : T_1 : never : never)[]>;
32
+ export declare const fetchAll: <K extends string, T extends PaginatedContent<K, unknown>, R extends PaginationOptions>(key: K, fetcher: PaginatedFetcher<T, R>, request: R, initial?: Promise<T>) => Promise<(Awaited<T[K]> extends infer T_1 ? T_1 extends Awaited<T[K]> ? T_1 extends readonly (infer InnerArr)[] ? InnerArr : T_1 : never : never)[]>;
33
33
  /**
34
34
  * Enriches a listing method with helpers.
35
35
  *
@@ -40,7 +40,7 @@ export declare const fetchAll: <K extends string, T extends PaginatedContent<K>,
40
40
  *
41
41
  * @internal
42
42
  */
43
- export declare const enrichForPagination: <K extends string, T extends PaginatedContent<K>, R extends PaginationOptions>(key: K, fetcher: PaginatedFetcher<T, R>, request: R) => Promise<T> & {
43
+ export declare const enrichForPagination: <K extends string, T extends PaginatedContent<K, unknown>, R extends PaginationOptions>(key: K, fetcher: PaginatedFetcher<T, R>, request: R) => Promise<T> & {
44
44
  all: () => Promise<(Awaited<T[K]> extends infer T_1 ? T_1 extends Awaited<T[K]> ? T_1 extends readonly (infer InnerArr)[] ? InnerArr : T_1 : never : never)[]>;
45
45
  [Symbol.asyncIterator]: () => AsyncGenerator<T[K], void, void>;
46
46
  };
@@ -22,4 +22,4 @@ export declare const fixLegacyTotalCount: <T>(obj: T, headers: Headers) => T;
22
22
  *
23
23
  * @internal
24
24
  */
25
- export declare const responseParser: <T>(unmarshaller: ResponseUnmarshaller<T>, responseType: "json" | "text" | "blob") => (response: Response) => Promise<T>;
25
+ export declare const responseParser: <T>(unmarshaller: ResponseUnmarshaller<T>, responseType: "blob" | "json" | "text") => (response: Response) => Promise<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scaleway/sdk-client",
3
- "version": "2.2.2",
3
+ "version": "2.3.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Scaleway SDK Client",
6
6
  "keywords": [
@@ -30,9 +30,12 @@
30
30
  "default": "./dist/index.js"
31
31
  }
32
32
  },
33
+ "devDependencies": {
34
+ "@repo/configs": "^0.1.1"
35
+ },
33
36
  "scripts": {
34
- "typecheck": "tsc --noEmit",
35
- "type:generate": "tsc --declaration -p tsconfig.build.json",
37
+ "typecheck": "tsgo --noEmit",
38
+ "type:generate": "tsgo --declaration -p tsconfig.build.json",
36
39
  "build": "vite build --config ../../vite.config.ts && pnpm run type:generate && tsc-alias -p tsconfig.build.json",
37
40
  "build:profile": "npx vite-bundle-visualizer -c ../../vite.config.ts"
38
41
  }