@scaleway/sdk-client 1.1.1 → 1.2.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.
@@ -11,3 +11,22 @@ export declare const isJSON: (obj: unknown) => obj is JSON;
11
11
  * @internal
12
12
  */
13
13
  export declare const isJSONObject: (obj: unknown) => obj is JSONObject;
14
+ /**
15
+ * Camelizes a string.
16
+ *
17
+ * @param str - The string to camelize
18
+ * @returns The camelized string
19
+ *
20
+ * @internal
21
+ */
22
+ export declare const camelize: (str: string) => string;
23
+ /**
24
+ * Camelizes keys of an object (deeply).
25
+ *
26
+ * @param obj - The object
27
+ * @param ignoreKeys - The keys to ignore
28
+ * @returns The object with camelized keys
29
+ *
30
+ * @internal
31
+ */
32
+ export declare const camelizeKeys: <T>(obj: object | unknown[] | unknown, ignoreKeys?: string[]) => T;
package/dist/index.cjs CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const index = require("./internal/logger/index.cjs");
4
4
  const client = require("./scw/client.cjs");
5
+ const constants = require("./scw/constants.cjs");
5
6
  const clientIniFactory = require("./scw/client-ini-factory.cjs");
6
7
  const customTypes = require("./scw/custom-types.cjs");
7
8
  const index$1 = require("./scw/errors/standard/index.cjs");
@@ -17,6 +18,8 @@ exports.enableConsoleLogger = index.enableConsoleLogger;
17
18
  exports.setLogger = index.setLogger;
18
19
  exports.createAdvancedClient = client.createAdvancedClient;
19
20
  exports.createClient = client.createClient;
21
+ exports.AUTH_HEADER_KEY = constants.AUTH_HEADER_KEY;
22
+ exports.SESSION_HEADER_KEY = constants.SESSION_HEADER_KEY;
20
23
  exports.withAdditionalInterceptors = clientIniFactory.withAdditionalInterceptors;
21
24
  exports.withDefaultPageSize = clientIniFactory.withDefaultPageSize;
22
25
  exports.withHTTPClient = clientIniFactory.withHTTPClient;
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export type { NetworkInterceptors, RequestInterceptor, ResponseInterceptor, Resp
3
3
  export { enableConsoleLogger, setLogger } from './internal/logger/index.js';
4
4
  export type { Logger } from './internal/logger/logger';
5
5
  export { createClient, createAdvancedClient } from './scw/client.js';
6
+ export { AUTH_HEADER_KEY, SESSION_HEADER_KEY } from './scw/constants.js';
6
7
  export type { Client } from './scw/client.js';
7
8
  export type { Profile } from './scw/client-ini-profile.js';
8
9
  export type { Settings } from './scw/client-settings.js';
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { enableConsoleLogger, setLogger } from "./internal/logger/index.js";
2
2
  import { createAdvancedClient, createClient } from "./scw/client.js";
3
+ import { AUTH_HEADER_KEY, SESSION_HEADER_KEY } from "./scw/constants.js";
3
4
  import { withAdditionalInterceptors, withDefaultPageSize, withHTTPClient, withProfile, withUserAgent, withUserAgentSuffix } from "./scw/client-ini-factory.js";
4
5
  import { Decimal } from "./scw/custom-types.js";
5
6
  import * as index from "./scw/errors/standard/index.js";
@@ -13,8 +14,10 @@ import { resolveOneOf, unmarshalArrayOfObject, unmarshalDate, unmarshalMapOfObje
13
14
  import { enrichForPagination } from "./scw/fetch/resource-paginator.js";
14
15
  export {
15
16
  API,
17
+ AUTH_HEADER_KEY,
16
18
  Decimal,
17
19
  index as Errors,
20
+ SESSION_HEADER_KEY,
18
21
  addAsyncHeaderInterceptor,
19
22
  authenticateWithSessionToken,
20
23
  createAdvancedClient,
@@ -1,67 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const name = "@scaleway/sdk-client";
4
- const version = "1.1.0";
5
- const license = "Apache-2.0";
6
- const description = "Scaleway SDK Client";
7
- const keywords = [
8
- "scaleway",
9
- "cloud",
10
- "sdk",
11
- "client"
12
- ];
13
- const main = "dist/index.cjs";
14
- const module$1 = "dist/index.js";
15
- const types = "dist/index.d.ts";
16
- const scripts = {
17
- typecheck: "tsc --noEmit",
18
- "type:generate": "tsc --declaration -p tsconfig.build.json",
19
- build: "vite build --config ../../vite.config.ts && pnpm run type:generate && tsc-alias -p tsconfig.build.json",
20
- "build:profile": "npx vite-bundle-visualizer -c ../../vite.config.ts"
21
- };
22
- const files = [
23
- "dist"
24
- ];
25
- const publishConfig = {
26
- access: "public"
27
- };
28
- const repository = {
29
- type: "git",
30
- url: "https://github.com/scaleway/scaleway-sdk-js",
31
- directory: "packages/client"
32
- };
33
- const engines = {
34
- node: ">=18.0"
35
- };
36
- const type = "module";
3
+ const version = "1.1.1";
37
4
  const pkg = {
38
- name,
39
- version,
40
- license,
41
- description,
42
- keywords,
43
- main,
44
- module: module$1,
45
- types,
46
- scripts,
47
- files,
48
- publishConfig,
49
- repository,
50
- engines,
51
- type
5
+ version
52
6
  };
53
7
  exports.default = pkg;
54
- exports.description = description;
55
- exports.engines = engines;
56
- exports.files = files;
57
- exports.keywords = keywords;
58
- exports.license = license;
59
- exports.main = main;
60
- exports.module = module$1;
61
- exports.name = name;
62
- exports.publishConfig = publishConfig;
63
- exports.repository = repository;
64
- exports.scripts = scripts;
65
- exports.type = type;
66
- exports.types = types;
67
8
  exports.version = version;
@@ -1,67 +1,8 @@
1
- const name = "@scaleway/sdk-client";
2
- const version = "1.1.0";
3
- const license = "Apache-2.0";
4
- const description = "Scaleway SDK Client";
5
- const keywords = [
6
- "scaleway",
7
- "cloud",
8
- "sdk",
9
- "client"
10
- ];
11
- const main = "dist/index.cjs";
12
- const module = "dist/index.js";
13
- const types = "dist/index.d.ts";
14
- const scripts = {
15
- typecheck: "tsc --noEmit",
16
- "type:generate": "tsc --declaration -p tsconfig.build.json",
17
- build: "vite build --config ../../vite.config.ts && pnpm run type:generate && tsc-alias -p tsconfig.build.json",
18
- "build:profile": "npx vite-bundle-visualizer -c ../../vite.config.ts"
19
- };
20
- const files = [
21
- "dist"
22
- ];
23
- const publishConfig = {
24
- access: "public"
25
- };
26
- const repository = {
27
- type: "git",
28
- url: "https://github.com/scaleway/scaleway-sdk-js",
29
- directory: "packages/client"
30
- };
31
- const engines = {
32
- node: ">=18.0"
33
- };
34
- const type = "module";
1
+ const version = "1.1.1";
35
2
  const pkg = {
36
- name,
37
- version,
38
- license,
39
- description,
40
- keywords,
41
- main,
42
- module,
43
- types,
44
- scripts,
45
- files,
46
- publishConfig,
47
- repository,
48
- engines,
49
- type
3
+ version
50
4
  };
51
5
  export {
52
6
  pkg as default,
53
- description,
54
- engines,
55
- files,
56
- keywords,
57
- license,
58
- main,
59
- module,
60
- name,
61
- publishConfig,
62
- repository,
63
- scripts,
64
- type,
65
- types,
66
7
  version
67
8
  };
package/dist/scw/auth.cjs CHANGED
@@ -2,12 +2,11 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const helpers = require("../internal/interceptors/helpers.cjs");
4
4
  const clientIniProfile = require("./client-ini-profile.cjs");
5
- const SESSION_HEADER_KEY = "x-session-token";
6
- const AUTH_HEADER_KEY = "x-auth-token";
7
- const authenticateWithSessionToken = (getToken) => helpers.addAsyncHeaderInterceptor(SESSION_HEADER_KEY, getToken);
5
+ const constants = require("./constants.cjs");
6
+ const authenticateWithSessionToken = (getToken) => helpers.addAsyncHeaderInterceptor(constants.SESSION_HEADER_KEY, getToken);
8
7
  const authenticateWithSecrets = (secrets) => {
9
8
  clientIniProfile.assertValidAuthenticationSecrets(secrets);
10
- return helpers.addHeaderInterceptor(AUTH_HEADER_KEY, secrets.secretKey);
9
+ return helpers.addHeaderInterceptor(constants.AUTH_HEADER_KEY, secrets.secretKey);
11
10
  };
12
11
  const obfuscateToken = (key) => `${key.substring(0, 5)}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`;
13
12
  const obfuscateUUID = (key) => `${key.substring(0, 8)}-xxxx-xxxx-xxxx-xxxxxxxxxxxx`;
@@ -15,8 +14,8 @@ const obfuscateAuthHeadersEntry = ([
15
14
  name,
16
15
  value
17
16
  ]) => {
18
- if (name === SESSION_HEADER_KEY) return [name, obfuscateToken(value)];
19
- if (name === AUTH_HEADER_KEY) return [name, obfuscateUUID(value)];
17
+ if (name === constants.SESSION_HEADER_KEY) return [name, obfuscateToken(value)];
18
+ if (name === constants.AUTH_HEADER_KEY) return [name, obfuscateUUID(value)];
20
19
  return [name, value];
21
20
  };
22
21
  exports.authenticateWithSecrets = authenticateWithSecrets;
@@ -3,6 +3,19 @@ import type { AuthenticationSecrets } from './client-ini-profile.js';
3
3
  interface TokenAccessor {
4
4
  (): Promise<string | undefined>;
5
5
  }
6
+ interface AddSessionHeader {
7
+ request: Request;
8
+ getAsyncToken: () => Promise<string | undefined>;
9
+ }
10
+ /**
11
+ * Add an JWT Session Header to a request through an interceptor.
12
+ *
13
+ * @param request - The request to modify
14
+ * @param getJwt - The session value
15
+ * @returns The Request interceptor
16
+ *
17
+ */
18
+ export declare const addSessionHeader: ({ request, getAsyncToken, }: AddSessionHeader) => Promise<Request>;
6
19
  /**
7
20
  * Authenticates with a session token.
8
21
  *
package/dist/scw/auth.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { addAsyncHeaderInterceptor, addHeaderInterceptor } from "../internal/interceptors/helpers.js";
2
2
  import { assertValidAuthenticationSecrets } from "./client-ini-profile.js";
3
- const SESSION_HEADER_KEY = "x-session-token";
4
- const AUTH_HEADER_KEY = "x-auth-token";
3
+ import { SESSION_HEADER_KEY, AUTH_HEADER_KEY } from "./constants.js";
5
4
  const authenticateWithSessionToken = (getToken) => addAsyncHeaderInterceptor(SESSION_HEADER_KEY, getToken);
6
5
  const authenticateWithSecrets = (secrets) => {
7
6
  assertValidAuthenticationSecrets(secrets);
@@ -1,7 +1,7 @@
1
1
  import { getLogger } from "../internal/logger/index.js";
2
- import { withLegacyInterceptors, withAdditionalInterceptors, withProfile } from "./client-ini-factory.js";
2
+ import { withAdditionalInterceptors, withProfile, withLegacyInterceptors } from "./client-ini-factory.js";
3
3
  import { assertValidSettings } from "./client-settings.js";
4
- import { version, userAgent } from "./constants.js";
4
+ import { userAgent, version } from "./constants.js";
5
5
  import { buildFetcher } from "./fetch/build-fetcher.js";
6
6
  const DEFAULT_SETTINGS = {
7
7
  apiURL: "https://api.scaleway.com",
@@ -3,5 +3,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const _package = require("../package.json.cjs");
4
4
  const { version } = _package.default;
5
5
  const userAgent = `scaleway-sdk-js/${version}`;
6
+ const SESSION_HEADER_KEY = "x-session-token";
7
+ const AUTH_HEADER_KEY = "x-auth-token";
8
+ exports.AUTH_HEADER_KEY = AUTH_HEADER_KEY;
9
+ exports.SESSION_HEADER_KEY = SESSION_HEADER_KEY;
6
10
  exports.userAgent = userAgent;
7
11
  exports.version = version;
@@ -1,2 +1,4 @@
1
1
  export declare const version: string;
2
2
  export declare const userAgent: string;
3
+ export declare const SESSION_HEADER_KEY = "x-session-token";
4
+ export declare const AUTH_HEADER_KEY = "x-auth-token";
@@ -1,7 +1,11 @@
1
1
  import pkg from "../package.json.js";
2
2
  const { version } = pkg;
3
3
  const userAgent = `scaleway-sdk-js/${version}`;
4
+ const SESSION_HEADER_KEY = "x-session-token";
5
+ const AUTH_HEADER_KEY = "x-auth-token";
4
6
  export {
7
+ AUTH_HEADER_KEY,
8
+ SESSION_HEADER_KEY,
5
9
  userAgent,
6
10
  version
7
11
  };
@@ -78,3 +78,27 @@ export declare const marshalTimeSeries: (obj: TimeSeries) => Record<string, unkn
78
78
  export declare const marshalDecimal: (obj: Decimal) => {
79
79
  value: string;
80
80
  };
81
+ /**
82
+ * Unmarshals record to convert iso dates from string to Dates.
83
+ *
84
+ * @param obj - The input
85
+ * @param keys - The keys requiring a conversion
86
+ * @returns The updated input
87
+ *
88
+ * @internal
89
+ */
90
+ export declare const unmarshalDates: <T>(obj: unknown, keys: string[]) => T;
91
+ /**
92
+ * Unmarshals input to a record with camilized keys and instanciated Date.
93
+ *
94
+ * @param obj - The input
95
+ * @param ignoreKeys - The keys which should be not be transformed
96
+ * @param dateKeys - The keys which should be transformed to Date
97
+ * @returns The record
98
+ *
99
+ * @throws TypeError
100
+ * Thrown if the input isn't {@link JSONObject}.
101
+ *
102
+ * @internal
103
+ */
104
+ export declare const unmarshalAnyRes: <T>(obj: unknown, ignoreKeys?: string[], dateKeys?: string[]) => T;
@@ -1,5 +1,5 @@
1
1
  import { isJSONObject } from "../helpers/json.js";
2
- import { unmarshalDate, unmarshalArrayOfObject } from "../helpers/marshalling.js";
2
+ import { unmarshalArrayOfObject, unmarshalDate } from "../helpers/marshalling.js";
3
3
  import { fromByteArray } from "../vendor/base64/index.js";
4
4
  import { Decimal } from "./custom-types.js";
5
5
  const unmarshalMoney = (data) => {
@@ -1,2 +1,2 @@
1
1
  export type Region = 'fr-par' | 'nl-ams' | 'pl-waw' | (string & {});
2
- export type Zone = 'fr-par-1' | 'fr-par-2' | 'fr-par-3' | 'nl-ams-1' | 'nl-ams-2' | 'nl-ams-3' | 'pl-waw-1' | 'pl-waw-2' | (string & {});
2
+ export type Zone = 'fr-par-1' | 'fr-par-2' | 'fr-par-3' | 'nl-ams-1' | 'nl-ams-2' | 'nl-ams-3' | 'pl-waw-1' | 'pl-waw-2' | 'pl-waw-3' | (string & {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scaleway/sdk-client",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Scaleway SDK Client",
6
6
  "keywords": [
@@ -33,5 +33,5 @@
33
33
  "node": ">=18.0"
34
34
  },
35
35
  "type": "module",
36
- "gitHead": "50cbd0a83df3ed423f7aedae4018e63299e7c945"
36
+ "gitHead": "ec3673d4c0a007ae40b9934f3c3eb770f45cc3bb"
37
37
  }