@scaleway/sdk-client 1.1.1 → 1.2.1
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.
- package/dist/helpers/json.cjs +40 -0
- package/dist/helpers/json.d.ts +19 -0
- package/dist/helpers/json.js +40 -0
- package/dist/index.cjs +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -1
- package/dist/internals.d.ts +1 -1
- package/dist/package.json.cjs +2 -61
- package/dist/package.json.js +2 -61
- package/dist/scw/auth.cjs +5 -6
- package/dist/scw/auth.d.ts +13 -0
- package/dist/scw/auth.js +1 -2
- package/dist/scw/client.js +2 -2
- package/dist/scw/constants.cjs +4 -0
- package/dist/scw/constants.d.ts +2 -0
- package/dist/scw/constants.js +4 -0
- package/dist/scw/custom-marshalling.cjs +26 -0
- package/dist/scw/custom-marshalling.d.ts +24 -0
- package/dist/scw/custom-marshalling.js +28 -2
- package/dist/scw/locality.d.ts +1 -1
- package/package.json +2 -2
package/dist/helpers/json.cjs
CHANGED
|
@@ -4,4 +4,44 @@ const isJSONObject = (obj) => {
|
|
|
4
4
|
const objT = typeof obj;
|
|
5
5
|
return obj !== void 0 && obj !== null && objT !== "string" && objT !== "number" && objT !== "boolean" && !Array.isArray(obj) && objT === "object";
|
|
6
6
|
};
|
|
7
|
+
const camelize = (str) => {
|
|
8
|
+
const strLength = str.length;
|
|
9
|
+
if (strLength <= 0) {
|
|
10
|
+
return str;
|
|
11
|
+
}
|
|
12
|
+
let out = "";
|
|
13
|
+
for (let capNext = false, index = 0; index < strLength; index += 1) {
|
|
14
|
+
const char = str.charAt(index);
|
|
15
|
+
if (char >= "a" && char <= "z") {
|
|
16
|
+
if (capNext) {
|
|
17
|
+
out += char.toUpperCase();
|
|
18
|
+
} else {
|
|
19
|
+
out += char;
|
|
20
|
+
}
|
|
21
|
+
} else if (char >= "A" && char <= "Z") {
|
|
22
|
+
out += char;
|
|
23
|
+
} else if (char >= "0" && char <= "9") {
|
|
24
|
+
out += char;
|
|
25
|
+
}
|
|
26
|
+
capNext = char === "_" || char === " " || char === "-" || char === ".";
|
|
27
|
+
}
|
|
28
|
+
return out.charAt(0).toLowerCase() + out.substring(1);
|
|
29
|
+
};
|
|
30
|
+
const camelizeKeys = (obj, ignoreKeys = []) => {
|
|
31
|
+
if (Array.isArray(obj)) {
|
|
32
|
+
return obj.map((v) => camelizeKeys(v, ignoreKeys));
|
|
33
|
+
}
|
|
34
|
+
if (obj && typeof obj === "object" && !(obj instanceof Date)) {
|
|
35
|
+
return Object.entries(obj).reduce(
|
|
36
|
+
(acc, [key, value]) => ({
|
|
37
|
+
...acc,
|
|
38
|
+
[camelize(key)]: ignoreKeys.includes(key) ? value : camelizeKeys(value, ignoreKeys)
|
|
39
|
+
}),
|
|
40
|
+
{}
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
return obj;
|
|
44
|
+
};
|
|
45
|
+
exports.camelize = camelize;
|
|
46
|
+
exports.camelizeKeys = camelizeKeys;
|
|
7
47
|
exports.isJSONObject = isJSONObject;
|
package/dist/helpers/json.d.ts
CHANGED
|
@@ -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/helpers/json.js
CHANGED
|
@@ -2,6 +2,46 @@ const isJSONObject = (obj) => {
|
|
|
2
2
|
const objT = typeof obj;
|
|
3
3
|
return obj !== void 0 && obj !== null && objT !== "string" && objT !== "number" && objT !== "boolean" && !Array.isArray(obj) && objT === "object";
|
|
4
4
|
};
|
|
5
|
+
const camelize = (str) => {
|
|
6
|
+
const strLength = str.length;
|
|
7
|
+
if (strLength <= 0) {
|
|
8
|
+
return str;
|
|
9
|
+
}
|
|
10
|
+
let out = "";
|
|
11
|
+
for (let capNext = false, index = 0; index < strLength; index += 1) {
|
|
12
|
+
const char = str.charAt(index);
|
|
13
|
+
if (char >= "a" && char <= "z") {
|
|
14
|
+
if (capNext) {
|
|
15
|
+
out += char.toUpperCase();
|
|
16
|
+
} else {
|
|
17
|
+
out += char;
|
|
18
|
+
}
|
|
19
|
+
} else if (char >= "A" && char <= "Z") {
|
|
20
|
+
out += char;
|
|
21
|
+
} else if (char >= "0" && char <= "9") {
|
|
22
|
+
out += char;
|
|
23
|
+
}
|
|
24
|
+
capNext = char === "_" || char === " " || char === "-" || char === ".";
|
|
25
|
+
}
|
|
26
|
+
return out.charAt(0).toLowerCase() + out.substring(1);
|
|
27
|
+
};
|
|
28
|
+
const camelizeKeys = (obj, ignoreKeys = []) => {
|
|
29
|
+
if (Array.isArray(obj)) {
|
|
30
|
+
return obj.map((v) => camelizeKeys(v, ignoreKeys));
|
|
31
|
+
}
|
|
32
|
+
if (obj && typeof obj === "object" && !(obj instanceof Date)) {
|
|
33
|
+
return Object.entries(obj).reduce(
|
|
34
|
+
(acc, [key, value]) => ({
|
|
35
|
+
...acc,
|
|
36
|
+
[camelize(key)]: ignoreKeys.includes(key) ? value : camelizeKeys(value, ignoreKeys)
|
|
37
|
+
}),
|
|
38
|
+
{}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
return obj;
|
|
42
|
+
};
|
|
5
43
|
export {
|
|
44
|
+
camelize,
|
|
45
|
+
camelizeKeys,
|
|
6
46
|
isJSONObject
|
|
7
47
|
};
|
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;
|
|
@@ -37,6 +40,7 @@ exports.marshalDecimal = customMarshalling.marshalDecimal;
|
|
|
37
40
|
exports.marshalMoney = customMarshalling.marshalMoney;
|
|
38
41
|
exports.marshalScwFile = customMarshalling.marshalScwFile;
|
|
39
42
|
exports.marshalTimeSeries = customMarshalling.marshalTimeSeries;
|
|
43
|
+
exports.unmarshalAnyRes = customMarshalling.unmarshalAnyRes;
|
|
40
44
|
exports.unmarshalDecimal = customMarshalling.unmarshalDecimal;
|
|
41
45
|
exports.unmarshalMoney = customMarshalling.unmarshalMoney;
|
|
42
46
|
exports.unmarshalScwFile = customMarshalling.unmarshalScwFile;
|
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";
|
|
@@ -8,13 +9,15 @@ import { createExponentialBackoffStrategy, tryAtIntervals, waitForResource } fro
|
|
|
8
9
|
import { addAsyncHeaderInterceptor } from "./internal/interceptors/helpers.js";
|
|
9
10
|
import { API } from "./scw/api.js";
|
|
10
11
|
import { authenticateWithSessionToken } from "./scw/auth.js";
|
|
11
|
-
import { marshalBlobToScwFile, marshalDecimal, marshalMoney, marshalScwFile, marshalTimeSeries, unmarshalDecimal, unmarshalMoney, unmarshalScwFile, unmarshalServiceInfo, unmarshalTimeSeries, unmarshalTimeSeriesPoint } from "./scw/custom-marshalling.js";
|
|
12
|
+
import { marshalBlobToScwFile, marshalDecimal, marshalMoney, marshalScwFile, marshalTimeSeries, unmarshalAnyRes, unmarshalDecimal, unmarshalMoney, unmarshalScwFile, unmarshalServiceInfo, unmarshalTimeSeries, unmarshalTimeSeriesPoint } from "./scw/custom-marshalling.js";
|
|
12
13
|
import { resolveOneOf, unmarshalArrayOfObject, unmarshalDate, unmarshalMapOfObject, urlParams, validatePathParam } from "./helpers/marshalling.js";
|
|
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,
|
|
@@ -31,6 +34,7 @@ export {
|
|
|
31
34
|
resolveOneOf,
|
|
32
35
|
setLogger,
|
|
33
36
|
tryAtIntervals,
|
|
37
|
+
unmarshalAnyRes,
|
|
34
38
|
unmarshalArrayOfObject,
|
|
35
39
|
unmarshalDate,
|
|
36
40
|
unmarshalDecimal,
|
package/dist/internals.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { addAsyncHeaderInterceptor } from './internal/interceptors/helpers.js';
|
|
|
4
4
|
export { API } from './scw/api.js';
|
|
5
5
|
export { authenticateWithSessionToken } from './scw/auth.js';
|
|
6
6
|
export type { DefaultValues } from './scw/client-settings.js';
|
|
7
|
-
export {
|
|
7
|
+
export { marshalBlobToScwFile, marshalDecimal, marshalMoney, marshalScwFile, marshalTimeSeries, unmarshalAnyRes, unmarshalDecimal, unmarshalMoney, unmarshalScwFile, unmarshalServiceInfo, unmarshalTimeSeries, unmarshalTimeSeriesPoint, } from './scw/custom-marshalling.js';
|
|
8
8
|
export type { ServiceInfo } from './scw/custom-types.js';
|
|
9
9
|
export { resolveOneOf, unmarshalDate, unmarshalArrayOfObject, unmarshalMapOfObject, urlParams, validatePathParam, } from './helpers/marshalling.js';
|
|
10
10
|
export { enrichForPagination } from './scw/fetch/resource-paginator.js';
|
package/dist/package.json.cjs
CHANGED
|
@@ -1,67 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const
|
|
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.2.0";
|
|
37
4
|
const pkg = {
|
|
38
|
-
|
|
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;
|
package/dist/package.json.js
CHANGED
|
@@ -1,67 +1,8 @@
|
|
|
1
|
-
const
|
|
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.2.0";
|
|
35
2
|
const pkg = {
|
|
36
|
-
|
|
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
|
|
6
|
-
const
|
|
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;
|
package/dist/scw/auth.d.ts
CHANGED
|
@@ -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
|
-
|
|
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);
|
package/dist/scw/client.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getLogger } from "../internal/logger/index.js";
|
|
2
|
-
import {
|
|
2
|
+
import { withAdditionalInterceptors, withProfile, withLegacyInterceptors } from "./client-ini-factory.js";
|
|
3
3
|
import { assertValidSettings } from "./client-settings.js";
|
|
4
|
-
import {
|
|
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",
|
package/dist/scw/constants.cjs
CHANGED
|
@@ -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;
|
package/dist/scw/constants.d.ts
CHANGED
package/dist/scw/constants.js
CHANGED
|
@@ -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
|
};
|
|
@@ -112,12 +112,38 @@ const marshalTimeSeries = (obj) => ({
|
|
|
112
112
|
const marshalDecimal = (obj) => ({
|
|
113
113
|
value: obj.toString()
|
|
114
114
|
});
|
|
115
|
+
const unmarshalDates = (obj, keys) => {
|
|
116
|
+
if (Array.isArray(obj)) {
|
|
117
|
+
return obj.map((v) => unmarshalDates(v, keys));
|
|
118
|
+
}
|
|
119
|
+
if (obj && typeof obj === "object") {
|
|
120
|
+
return Object.entries(obj).reduce(
|
|
121
|
+
(acc, [key, value]) => ({
|
|
122
|
+
...acc,
|
|
123
|
+
[key]: typeof value === "string" && keys.includes(key) ? new Date(value) : unmarshalDates(value, keys)
|
|
124
|
+
}),
|
|
125
|
+
{}
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
return obj;
|
|
129
|
+
};
|
|
130
|
+
const unmarshalAnyRes = (obj, ignoreKeys = [], dateKeys) => {
|
|
131
|
+
if (!json.isJSONObject(obj)) {
|
|
132
|
+
throw new TypeError(`Data isn't a dictionary.`);
|
|
133
|
+
}
|
|
134
|
+
return json.camelizeKeys(
|
|
135
|
+
dateKeys && dateKeys.length > 0 ? unmarshalDates(obj, dateKeys) : obj,
|
|
136
|
+
ignoreKeys
|
|
137
|
+
);
|
|
138
|
+
};
|
|
115
139
|
exports.marshalBlobToScwFile = marshalBlobToScwFile;
|
|
116
140
|
exports.marshalDecimal = marshalDecimal;
|
|
117
141
|
exports.marshalMoney = marshalMoney;
|
|
118
142
|
exports.marshalScwFile = marshalScwFile;
|
|
119
143
|
exports.marshalTimeSeries = marshalTimeSeries;
|
|
120
144
|
exports.marshalTimeSeriesPoint = marshalTimeSeriesPoint;
|
|
145
|
+
exports.unmarshalAnyRes = unmarshalAnyRes;
|
|
146
|
+
exports.unmarshalDates = unmarshalDates;
|
|
121
147
|
exports.unmarshalDecimal = unmarshalDecimal;
|
|
122
148
|
exports.unmarshalMoney = unmarshalMoney;
|
|
123
149
|
exports.unmarshalScwFile = unmarshalScwFile;
|
|
@@ -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
|
-
import { isJSONObject } from "../helpers/json.js";
|
|
2
|
-
import {
|
|
1
|
+
import { isJSONObject, camelizeKeys } from "../helpers/json.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) => {
|
|
@@ -110,6 +110,30 @@ const marshalTimeSeries = (obj) => ({
|
|
|
110
110
|
const marshalDecimal = (obj) => ({
|
|
111
111
|
value: obj.toString()
|
|
112
112
|
});
|
|
113
|
+
const unmarshalDates = (obj, keys) => {
|
|
114
|
+
if (Array.isArray(obj)) {
|
|
115
|
+
return obj.map((v) => unmarshalDates(v, keys));
|
|
116
|
+
}
|
|
117
|
+
if (obj && typeof obj === "object") {
|
|
118
|
+
return Object.entries(obj).reduce(
|
|
119
|
+
(acc, [key, value]) => ({
|
|
120
|
+
...acc,
|
|
121
|
+
[key]: typeof value === "string" && keys.includes(key) ? new Date(value) : unmarshalDates(value, keys)
|
|
122
|
+
}),
|
|
123
|
+
{}
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
return obj;
|
|
127
|
+
};
|
|
128
|
+
const unmarshalAnyRes = (obj, ignoreKeys = [], dateKeys) => {
|
|
129
|
+
if (!isJSONObject(obj)) {
|
|
130
|
+
throw new TypeError(`Data isn't a dictionary.`);
|
|
131
|
+
}
|
|
132
|
+
return camelizeKeys(
|
|
133
|
+
dateKeys && dateKeys.length > 0 ? unmarshalDates(obj, dateKeys) : obj,
|
|
134
|
+
ignoreKeys
|
|
135
|
+
);
|
|
136
|
+
};
|
|
113
137
|
export {
|
|
114
138
|
marshalBlobToScwFile,
|
|
115
139
|
marshalDecimal,
|
|
@@ -117,6 +141,8 @@ export {
|
|
|
117
141
|
marshalScwFile,
|
|
118
142
|
marshalTimeSeries,
|
|
119
143
|
marshalTimeSeriesPoint,
|
|
144
|
+
unmarshalAnyRes,
|
|
145
|
+
unmarshalDates,
|
|
120
146
|
unmarshalDecimal,
|
|
121
147
|
unmarshalMoney,
|
|
122
148
|
unmarshalScwFile,
|
package/dist/scw/locality.d.ts
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "1.2.1",
|
|
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": "
|
|
36
|
+
"gitHead": "a3b0b412eb0b067b8f2ea61360a023f38d17f5a0"
|
|
37
37
|
}
|