@scaleway/sdk-std 1.0.1 → 1.0.3
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/package.json +4 -7
- package/node_modules/@scaleway/sdk-client/README.md +0 -36
- package/node_modules/@scaleway/sdk-client/dist/bridge.d.ts +0 -12
- package/node_modules/@scaleway/sdk-client/dist/helpers/is-browser.cjs +0 -4
- package/node_modules/@scaleway/sdk-client/dist/helpers/is-browser.d.ts +0 -1
- package/node_modules/@scaleway/sdk-client/dist/helpers/is-browser.js +0 -4
- package/node_modules/@scaleway/sdk-client/dist/helpers/is-response.cjs +0 -4
- package/node_modules/@scaleway/sdk-client/dist/helpers/is-response.d.ts +0 -8
- package/node_modules/@scaleway/sdk-client/dist/helpers/is-response.js +0 -4
- package/node_modules/@scaleway/sdk-client/dist/helpers/json.cjs +0 -47
- package/node_modules/@scaleway/sdk-client/dist/helpers/json.d.ts +0 -32
- package/node_modules/@scaleway/sdk-client/dist/helpers/json.js +0 -47
- package/node_modules/@scaleway/sdk-client/dist/helpers/marshalling.cjs +0 -76
- package/node_modules/@scaleway/sdk-client/dist/helpers/marshalling.d.ts +0 -60
- package/node_modules/@scaleway/sdk-client/dist/helpers/marshalling.js +0 -76
- package/node_modules/@scaleway/sdk-client/dist/index.cjs +0 -56
- package/node_modules/@scaleway/sdk-client/dist/index.d.ts +0 -16
- package/node_modules/@scaleway/sdk-client/dist/index.js +0 -56
- package/node_modules/@scaleway/sdk-client/dist/internal/async/interval-retrier.cjs +0 -53
- package/node_modules/@scaleway/sdk-client/dist/internal/async/interval-retrier.d.ts +0 -111
- package/node_modules/@scaleway/sdk-client/dist/internal/async/interval-retrier.js +0 -53
- package/node_modules/@scaleway/sdk-client/dist/internal/async/sleep.cjs +0 -6
- package/node_modules/@scaleway/sdk-client/dist/internal/async/sleep.d.ts +0 -9
- package/node_modules/@scaleway/sdk-client/dist/internal/async/sleep.js +0 -6
- package/node_modules/@scaleway/sdk-client/dist/internal/interceptors/composer.cjs +0 -25
- package/node_modules/@scaleway/sdk-client/dist/internal/interceptors/composer.d.ts +0 -25
- package/node_modules/@scaleway/sdk-client/dist/internal/interceptors/composer.js +0 -25
- package/node_modules/@scaleway/sdk-client/dist/internal/interceptors/helpers.cjs +0 -12
- package/node_modules/@scaleway/sdk-client/dist/internal/interceptors/helpers.d.ts +0 -21
- package/node_modules/@scaleway/sdk-client/dist/internal/interceptors/helpers.js +0 -12
- package/node_modules/@scaleway/sdk-client/dist/internal/interceptors/types.d.ts +0 -89
- package/node_modules/@scaleway/sdk-client/dist/internal/logger/console-logger.cjs +0 -24
- package/node_modules/@scaleway/sdk-client/dist/internal/logger/console-logger.d.ts +0 -23
- package/node_modules/@scaleway/sdk-client/dist/internal/logger/console-logger.js +0 -24
- package/node_modules/@scaleway/sdk-client/dist/internal/logger/index.cjs +0 -12
- package/node_modules/@scaleway/sdk-client/dist/internal/logger/index.d.ts +0 -25
- package/node_modules/@scaleway/sdk-client/dist/internal/logger/index.js +0 -12
- package/node_modules/@scaleway/sdk-client/dist/internal/logger/level-resolver.cjs +0 -13
- package/node_modules/@scaleway/sdk-client/dist/internal/logger/level-resolver.d.ts +0 -9
- package/node_modules/@scaleway/sdk-client/dist/internal/logger/level-resolver.js +0 -13
- package/node_modules/@scaleway/sdk-client/dist/internal/logger/logger.d.ts +0 -13
- package/node_modules/@scaleway/sdk-client/dist/internal/validations/string-validation.cjs +0 -30
- package/node_modules/@scaleway/sdk-client/dist/internal/validations/string-validation.d.ts +0 -18
- package/node_modules/@scaleway/sdk-client/dist/internal/validations/string-validation.js +0 -30
- package/node_modules/@scaleway/sdk-client/dist/internals.d.ts +0 -10
- package/node_modules/@scaleway/sdk-client/dist/package.json.cjs +0 -8
- package/node_modules/@scaleway/sdk-client/dist/package.json.js +0 -8
- package/node_modules/@scaleway/sdk-client/dist/scw/api.cjs +0 -8
- package/node_modules/@scaleway/sdk-client/dist/scw/api.d.ts +0 -10
- package/node_modules/@scaleway/sdk-client/dist/scw/api.js +0 -8
- package/node_modules/@scaleway/sdk-client/dist/scw/auth.cjs +0 -25
- package/node_modules/@scaleway/sdk-client/dist/scw/auth.d.ts +0 -70
- package/node_modules/@scaleway/sdk-client/dist/scw/auth.js +0 -25
- package/node_modules/@scaleway/sdk-client/dist/scw/client-ini-factory.cjs +0 -66
- package/node_modules/@scaleway/sdk-client/dist/scw/client-ini-factory.d.ts +0 -111
- package/node_modules/@scaleway/sdk-client/dist/scw/client-ini-factory.js +0 -66
- package/node_modules/@scaleway/sdk-client/dist/scw/client-ini-profile.cjs +0 -23
- package/node_modules/@scaleway/sdk-client/dist/scw/client-ini-profile.d.ts +0 -82
- package/node_modules/@scaleway/sdk-client/dist/scw/client-ini-profile.js +0 -23
- package/node_modules/@scaleway/sdk-client/dist/scw/client-settings.cjs +0 -51
- package/node_modules/@scaleway/sdk-client/dist/scw/client-settings.d.ts +0 -59
- package/node_modules/@scaleway/sdk-client/dist/scw/client-settings.js +0 -51
- package/node_modules/@scaleway/sdk-client/dist/scw/client.cjs +0 -31
- package/node_modules/@scaleway/sdk-client/dist/scw/client.d.ts +0 -71
- package/node_modules/@scaleway/sdk-client/dist/scw/client.js +0 -31
- package/node_modules/@scaleway/sdk-client/dist/scw/constants.cjs +0 -11
- package/node_modules/@scaleway/sdk-client/dist/scw/constants.d.ts +0 -4
- package/node_modules/@scaleway/sdk-client/dist/scw/constants.js +0 -11
- package/node_modules/@scaleway/sdk-client/dist/scw/custom-marshalling.cjs +0 -152
- package/node_modules/@scaleway/sdk-client/dist/scw/custom-marshalling.d.ts +0 -104
- package/node_modules/@scaleway/sdk-client/dist/scw/custom-marshalling.js +0 -152
- package/node_modules/@scaleway/sdk-client/dist/scw/custom-types.cjs +0 -11
- package/node_modules/@scaleway/sdk-client/dist/scw/custom-types.d.ts +0 -74
- package/node_modules/@scaleway/sdk-client/dist/scw/custom-types.js +0 -11
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/error-parser.cjs +0 -76
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/error-parser.d.ts +0 -12
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/error-parser.js +0 -76
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/non-standard/invalid-request-mapper.cjs +0 -36
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/non-standard/invalid-request-mapper.d.ts +0 -12
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/non-standard/invalid-request-mapper.js +0 -36
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/non-standard/unknown-resource-mapper.cjs +0 -23
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/non-standard/unknown-resource-mapper.d.ts +0 -11
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/non-standard/unknown-resource-mapper.js +0 -23
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/scw-error-from-json.d.ts +0 -10
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/scw-error.cjs +0 -43
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/scw-error.d.ts +0 -25
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/scw-error.js +0 -43
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/already-exists-error.cjs +0 -31
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/already-exists-error.d.ts +0 -16
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/already-exists-error.js +0 -31
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/denied-authentication-error.cjs +0 -37
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/denied-authentication-error.d.ts +0 -15
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/denied-authentication-error.js +0 -37
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/index.cjs +0 -28
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/index.d.ts +0 -17
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/index.js +0 -28
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/invalid-arguments-error.cjs +0 -54
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/invalid-arguments-error.d.ts +0 -24
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/invalid-arguments-error.js +0 -54
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/out-of-stock-error.cjs +0 -17
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/out-of-stock-error.d.ts +0 -14
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/out-of-stock-error.js +0 -17
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/permissions-denied-error.cjs +0 -29
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/permissions-denied-error.d.ts +0 -23
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/permissions-denied-error.js +0 -29
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/precondition-failed-error.cjs +0 -32
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/precondition-failed-error.d.ts +0 -15
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/precondition-failed-error.js +0 -32
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/quotas-exceeded-error.cjs +0 -43
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/quotas-exceeded-error.d.ts +0 -34
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/quotas-exceeded-error.js +0 -43
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-expired-error.cjs +0 -31
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-expired-error.d.ts +0 -16
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-expired-error.js +0 -31
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-locked-error.cjs +0 -20
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-locked-error.d.ts +0 -15
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-locked-error.js +0 -20
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-not-found-error.cjs +0 -24
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-not-found-error.d.ts +0 -15
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-not-found-error.js +0 -24
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/too-many-requests-error.cjs +0 -58
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/too-many-requests-error.d.ts +0 -32
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/too-many-requests-error.js +0 -58
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/transient-state-error.cjs +0 -31
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/transient-state-error.d.ts +0 -16
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/transient-state-error.js +0 -31
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/types.cjs +0 -15
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/types.d.ts +0 -9
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/types.js +0 -15
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/build-fetcher.cjs +0 -60
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/build-fetcher.d.ts +0 -23
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/build-fetcher.js +0 -60
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/http-dumper.cjs +0 -20
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/http-dumper.d.ts +0 -18
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/http-dumper.js +0 -20
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/http-interceptors.cjs +0 -43
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/http-interceptors.d.ts +0 -38
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/http-interceptors.js +0 -43
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/resource-paginator.cjs +0 -36
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/resource-paginator.d.ts +0 -47
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/resource-paginator.js +0 -36
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/response-parser.cjs +0 -55
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/response-parser.d.ts +0 -25
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/response-parser.js +0 -55
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/types.d.ts +0 -16
- package/node_modules/@scaleway/sdk-client/dist/scw/locality.d.ts +0 -2
- package/node_modules/@scaleway/sdk-client/dist/vendor/base64/index.cjs +0 -46
- package/node_modules/@scaleway/sdk-client/dist/vendor/base64/index.js +0 -46
- package/node_modules/@scaleway/sdk-client/package.json +0 -36
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { isJSONObject } from './helpers/json.js';
|
|
2
|
-
export { createExponentialBackoffStrategy, tryAtIntervals, waitForResource, } from './internal/async/interval-retrier.js';
|
|
3
|
-
export { addAsyncHeaderInterceptor } from './internal/interceptors/helpers.js';
|
|
4
|
-
export { API } from './scw/api.js';
|
|
5
|
-
export { authenticateWithSessionToken } from './scw/auth.js';
|
|
6
|
-
export type { DefaultValues } from './scw/client-settings.js';
|
|
7
|
-
export { marshalBlobToScwFile, marshalDecimal, marshalMoney, marshalScwFile, marshalTimeSeries, unmarshalAnyRes, unmarshalDecimal, unmarshalMoney, unmarshalScwFile, unmarshalServiceInfo, unmarshalTimeSeries, unmarshalTimeSeriesPoint, } from './scw/custom-marshalling.js';
|
|
8
|
-
export type { ServiceInfo } from './scw/custom-types.js';
|
|
9
|
-
export { resolveOneOf, unmarshalDate, unmarshalArrayOfObject, unmarshalMapOfObject, urlParams, validatePathParam, } from './helpers/marshalling.js';
|
|
10
|
-
export { enrichForPagination } from './scw/fetch/resource-paginator.js';
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const helpers = require("../internal/interceptors/helpers.cjs");
|
|
4
|
-
const clientIniProfile = require("./client-ini-profile.cjs");
|
|
5
|
-
const constants = require("./constants.cjs");
|
|
6
|
-
const authenticateWithSessionToken = (getToken) => helpers.addAsyncHeaderInterceptor(constants.SESSION_HEADER_KEY, getToken);
|
|
7
|
-
const authenticateWithSecrets = (secrets) => {
|
|
8
|
-
clientIniProfile.assertValidAuthenticationSecrets(secrets);
|
|
9
|
-
return helpers.addHeaderInterceptor(constants.AUTH_HEADER_KEY, secrets.secretKey);
|
|
10
|
-
};
|
|
11
|
-
const obfuscateToken = (key) => `${key.substring(0, 5)}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`;
|
|
12
|
-
const obfuscateUUID = (key) => `${key.substring(0, 8)}-xxxx-xxxx-xxxx-xxxxxxxxxxxx`;
|
|
13
|
-
const obfuscateAuthHeadersEntry = ([
|
|
14
|
-
name,
|
|
15
|
-
value
|
|
16
|
-
]) => {
|
|
17
|
-
if (name === constants.SESSION_HEADER_KEY) return [name, obfuscateToken(value)];
|
|
18
|
-
if (name === constants.AUTH_HEADER_KEY) return [name, obfuscateUUID(value)];
|
|
19
|
-
return [name, value];
|
|
20
|
-
};
|
|
21
|
-
exports.authenticateWithSecrets = authenticateWithSecrets;
|
|
22
|
-
exports.authenticateWithSessionToken = authenticateWithSessionToken;
|
|
23
|
-
exports.obfuscateAuthHeadersEntry = obfuscateAuthHeadersEntry;
|
|
24
|
-
exports.obfuscateToken = obfuscateToken;
|
|
25
|
-
exports.obfuscateUUID = obfuscateUUID;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import type { RequestInterceptor } from '../internal/interceptors/types';
|
|
2
|
-
import type { AuthenticationSecrets } from './client-ini-profile.js';
|
|
3
|
-
interface TokenAccessor {
|
|
4
|
-
(): Promise<string | undefined>;
|
|
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>;
|
|
19
|
-
/**
|
|
20
|
-
* Authenticates with a session token.
|
|
21
|
-
*
|
|
22
|
-
* @param getToken - The token accessor
|
|
23
|
-
* @returns The request interceptor
|
|
24
|
-
*
|
|
25
|
-
* @deprecated Please use addAsyncHeaderInterceptor instead.
|
|
26
|
-
*
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
29
|
-
export declare const authenticateWithSessionToken: (getToken: TokenAccessor) => RequestInterceptor;
|
|
30
|
-
/**
|
|
31
|
-
* Authenticates with a secrets.
|
|
32
|
-
*
|
|
33
|
-
* @param getToken - The secrets
|
|
34
|
-
* @returns The request interceptor
|
|
35
|
-
*
|
|
36
|
-
* @throws Error
|
|
37
|
-
* Thrown if the secrets are invalid.
|
|
38
|
-
*
|
|
39
|
-
* @internal
|
|
40
|
-
*/
|
|
41
|
-
export declare const authenticateWithSecrets: (secrets: AuthenticationSecrets) => RequestInterceptor;
|
|
42
|
-
/**
|
|
43
|
-
* Obfuscates a token.
|
|
44
|
-
*
|
|
45
|
-
* @param key - The token
|
|
46
|
-
* @returns The obfuscated token
|
|
47
|
-
*
|
|
48
|
-
* @internal
|
|
49
|
-
*/
|
|
50
|
-
export declare const obfuscateToken: (key: string) => string;
|
|
51
|
-
/**
|
|
52
|
-
* Obfuscates an UUID.
|
|
53
|
-
*
|
|
54
|
-
* @param key - The UUID
|
|
55
|
-
* @returns The obfuscated UUID
|
|
56
|
-
*
|
|
57
|
-
* @internal
|
|
58
|
-
*/
|
|
59
|
-
export declare const obfuscateUUID: (key: string) => string;
|
|
60
|
-
type HeaderEntry = [string, string];
|
|
61
|
-
/**
|
|
62
|
-
* Obfuscates headers entry.
|
|
63
|
-
*
|
|
64
|
-
* @param array - The header entry
|
|
65
|
-
* @returns The obfuscated entry
|
|
66
|
-
*
|
|
67
|
-
* @internal
|
|
68
|
-
*/
|
|
69
|
-
export declare const obfuscateAuthHeadersEntry: ([name, value,]: HeaderEntry) => HeaderEntry;
|
|
70
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { addAsyncHeaderInterceptor, addHeaderInterceptor } from "../internal/interceptors/helpers.js";
|
|
2
|
-
import { assertValidAuthenticationSecrets } from "./client-ini-profile.js";
|
|
3
|
-
import { SESSION_HEADER_KEY, AUTH_HEADER_KEY } from "./constants.js";
|
|
4
|
-
const authenticateWithSessionToken = (getToken) => addAsyncHeaderInterceptor(SESSION_HEADER_KEY, getToken);
|
|
5
|
-
const authenticateWithSecrets = (secrets) => {
|
|
6
|
-
assertValidAuthenticationSecrets(secrets);
|
|
7
|
-
return addHeaderInterceptor(AUTH_HEADER_KEY, secrets.secretKey);
|
|
8
|
-
};
|
|
9
|
-
const obfuscateToken = (key) => `${key.substring(0, 5)}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`;
|
|
10
|
-
const obfuscateUUID = (key) => `${key.substring(0, 8)}-xxxx-xxxx-xxxx-xxxxxxxxxxxx`;
|
|
11
|
-
const obfuscateAuthHeadersEntry = ([
|
|
12
|
-
name,
|
|
13
|
-
value
|
|
14
|
-
]) => {
|
|
15
|
-
if (name === SESSION_HEADER_KEY) return [name, obfuscateToken(value)];
|
|
16
|
-
if (name === AUTH_HEADER_KEY) return [name, obfuscateUUID(value)];
|
|
17
|
-
return [name, value];
|
|
18
|
-
};
|
|
19
|
-
export {
|
|
20
|
-
authenticateWithSecrets,
|
|
21
|
-
authenticateWithSessionToken,
|
|
22
|
-
obfuscateAuthHeadersEntry,
|
|
23
|
-
obfuscateToken,
|
|
24
|
-
obfuscateUUID
|
|
25
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const auth = require("./auth.cjs");
|
|
4
|
-
const clientIniProfile = require("./client-ini-profile.cjs");
|
|
5
|
-
const withProfile = (profile) => (settings) => {
|
|
6
|
-
const newSettings = { ...settings };
|
|
7
|
-
if (profile.apiURL) {
|
|
8
|
-
newSettings.apiURL = profile.apiURL;
|
|
9
|
-
}
|
|
10
|
-
if (profile.defaultOrganizationId) {
|
|
11
|
-
newSettings.defaultOrganizationId = profile.defaultOrganizationId;
|
|
12
|
-
}
|
|
13
|
-
if (profile.defaultProjectId) {
|
|
14
|
-
newSettings.defaultProjectId = profile.defaultProjectId;
|
|
15
|
-
}
|
|
16
|
-
if (profile.defaultRegion) {
|
|
17
|
-
newSettings.defaultRegion = profile.defaultRegion;
|
|
18
|
-
}
|
|
19
|
-
if (profile.defaultZone) {
|
|
20
|
-
newSettings.defaultZone = profile.defaultZone;
|
|
21
|
-
}
|
|
22
|
-
if (clientIniProfile.hasAuthenticationSecrets(profile)) {
|
|
23
|
-
newSettings.interceptors = [
|
|
24
|
-
{
|
|
25
|
-
request: auth.authenticateWithSecrets(profile)
|
|
26
|
-
},
|
|
27
|
-
...newSettings.interceptors
|
|
28
|
-
];
|
|
29
|
-
}
|
|
30
|
-
return newSettings;
|
|
31
|
-
};
|
|
32
|
-
const withHTTPClient = (httpClient) => (settings) => ({ ...settings, httpClient });
|
|
33
|
-
const withDefaultPageSize = (defaultPageSize) => (settings) => ({ ...settings, defaultPageSize });
|
|
34
|
-
const withUserAgent = (userAgent) => (settings) => ({ ...settings, userAgent });
|
|
35
|
-
const withUserAgentSuffix = (userAgent) => (settings) => ({
|
|
36
|
-
...settings,
|
|
37
|
-
userAgent: settings.userAgent ? `${settings.userAgent} ${userAgent}` : userAgent
|
|
38
|
-
});
|
|
39
|
-
const withAdditionalInterceptors = (interceptors) => (settings) => ({
|
|
40
|
-
...settings,
|
|
41
|
-
interceptors: settings.interceptors.concat(interceptors)
|
|
42
|
-
});
|
|
43
|
-
const withLegacyInterceptors = () => (settings) => {
|
|
44
|
-
if (!settings.requestInterceptors && !settings.responseInterceptors) {
|
|
45
|
-
return settings;
|
|
46
|
-
}
|
|
47
|
-
const allInterceptors = settings.interceptors.concat(
|
|
48
|
-
(settings.requestInterceptors ?? []).map((obj) => ({
|
|
49
|
-
request: obj
|
|
50
|
-
})),
|
|
51
|
-
(settings.responseInterceptors ?? []).map((obj) => ({
|
|
52
|
-
response: obj
|
|
53
|
-
}))
|
|
54
|
-
);
|
|
55
|
-
return {
|
|
56
|
-
...settings,
|
|
57
|
-
interceptors: allInterceptors
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
exports.withAdditionalInterceptors = withAdditionalInterceptors;
|
|
61
|
-
exports.withDefaultPageSize = withDefaultPageSize;
|
|
62
|
-
exports.withHTTPClient = withHTTPClient;
|
|
63
|
-
exports.withLegacyInterceptors = withLegacyInterceptors;
|
|
64
|
-
exports.withProfile = withProfile;
|
|
65
|
-
exports.withUserAgent = withUserAgent;
|
|
66
|
-
exports.withUserAgentSuffix = withUserAgentSuffix;
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import type { NetworkInterceptors } from '../index.js';
|
|
2
|
-
import type { Profile } from './client-ini-profile.js';
|
|
3
|
-
import type { Settings } from './client-settings.js';
|
|
4
|
-
/**
|
|
5
|
-
* A factory to build {@link Settings}.
|
|
6
|
-
*
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export type ClientConfig = (obj: Settings) => Settings;
|
|
10
|
-
/**
|
|
11
|
-
* Instantiates the SDK from a configuration {@link Profile}.
|
|
12
|
-
*
|
|
13
|
-
* @param profile - The profile
|
|
14
|
-
* @returns A factory {@link ClientConfig}
|
|
15
|
-
*
|
|
16
|
-
* @remarks This method should be used in conjunction with the initializer `createAdvancedClient`.
|
|
17
|
-
*
|
|
18
|
-
* @public
|
|
19
|
-
*/
|
|
20
|
-
export declare const withProfile: (profile: Readonly<Profile>) => (settings: Readonly<Settings>) => Settings;
|
|
21
|
-
/**
|
|
22
|
-
* Instantiates the SDK with a different HTTP client.
|
|
23
|
-
*
|
|
24
|
-
* @param httpClient - A fetch compatible HTTP client
|
|
25
|
-
* @returns A factory {@link ClientConfig}
|
|
26
|
-
*
|
|
27
|
-
* @remarks This method should be used in conjunction with the initializer `createAdvancedClient`.
|
|
28
|
-
*
|
|
29
|
-
* @public
|
|
30
|
-
*/
|
|
31
|
-
export declare const withHTTPClient: (httpClient: typeof fetch) => (settings: Readonly<Settings>) => Settings;
|
|
32
|
-
/**
|
|
33
|
-
* Instantiates the SDK with a default page size.
|
|
34
|
-
*
|
|
35
|
-
* @param defaultPageSize - The default page size
|
|
36
|
-
* @returns A factory {@link ClientConfig}
|
|
37
|
-
*
|
|
38
|
-
* @remarks This method should be used in conjunction with the initializer `createAdvancedClient`.
|
|
39
|
-
*
|
|
40
|
-
* @public
|
|
41
|
-
*/
|
|
42
|
-
export declare const withDefaultPageSize: (defaultPageSize: number) => ClientConfig;
|
|
43
|
-
/**
|
|
44
|
-
* Instantiates the SDK with a different default user agent.
|
|
45
|
-
*
|
|
46
|
-
* @param userAgent - The default user agent
|
|
47
|
-
* @returns A factory {@link ClientConfig}
|
|
48
|
-
*
|
|
49
|
-
* @remarks This method should be used in conjunction with the initializer `createAdvancedClient`.
|
|
50
|
-
*
|
|
51
|
-
* @public
|
|
52
|
-
*/
|
|
53
|
-
export declare const withUserAgent: (userAgent: string) => (settings: Readonly<Settings>) => Settings;
|
|
54
|
-
/**
|
|
55
|
-
* Instantiates the SDK with an additional user agent.
|
|
56
|
-
*
|
|
57
|
-
* @param userAgent - The suffix to append to default user agent
|
|
58
|
-
* @returns A factory {@link ClientConfig}
|
|
59
|
-
*
|
|
60
|
-
* @remarks This method should be used in conjunction with the initializer `createAdvancedClient`.
|
|
61
|
-
*
|
|
62
|
-
* @public
|
|
63
|
-
*/
|
|
64
|
-
export declare const withUserAgentSuffix: (userAgent: string) => (settings: Readonly<Settings>) => Settings;
|
|
65
|
-
/**
|
|
66
|
-
* Instantiates the SDK with additional interceptors.
|
|
67
|
-
*
|
|
68
|
-
* @param interceptors - The additional {@link NetworkInterceptors} interceptors
|
|
69
|
-
* @returns A factory {@link ClientConfig}
|
|
70
|
-
*
|
|
71
|
-
* @remarks
|
|
72
|
-
* It doesn't override the existing interceptors, but instead push more to the list.
|
|
73
|
-
* This method should be used in conjunction with the initializer `createAdvancedClient`.
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```
|
|
77
|
-
* withAdditionalInterceptors([
|
|
78
|
-
* {
|
|
79
|
-
* request: ({ request }) => {
|
|
80
|
-
* console.log(`Do something with ${JSON.stringify(request)}`)
|
|
81
|
-
* return request
|
|
82
|
-
* },
|
|
83
|
-
* response: ({ response }) => {
|
|
84
|
-
* console.log(`Do something with ${JSON.stringify(response)}`)
|
|
85
|
-
* return response
|
|
86
|
-
* },
|
|
87
|
-
* responseError: async ({
|
|
88
|
-
* request,
|
|
89
|
-
* error,
|
|
90
|
-
* }: {
|
|
91
|
-
* request: Request
|
|
92
|
-
* error: unknown
|
|
93
|
-
* }) => {
|
|
94
|
-
* console.log(
|
|
95
|
-
* `Do something with ${JSON.stringify(request)} and ${JSON.stringify(
|
|
96
|
-
* error,
|
|
97
|
-
* )}`,
|
|
98
|
-
* )
|
|
99
|
-
* throw error // or return Promise.resolve(someData)
|
|
100
|
-
* },
|
|
101
|
-
* },
|
|
102
|
-
* ])
|
|
103
|
-
* ```
|
|
104
|
-
*
|
|
105
|
-
* @public
|
|
106
|
-
*/
|
|
107
|
-
export declare const withAdditionalInterceptors: (interceptors: NetworkInterceptors[]) => (settings: Readonly<Settings>) => Settings;
|
|
108
|
-
/**
|
|
109
|
-
* Instantiates the SDK with legacy interceptors.
|
|
110
|
-
*/
|
|
111
|
-
export declare const withLegacyInterceptors: () => (settings: Readonly<Settings>) => Settings;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { authenticateWithSecrets } from "./auth.js";
|
|
2
|
-
import { hasAuthenticationSecrets } from "./client-ini-profile.js";
|
|
3
|
-
const withProfile = (profile) => (settings) => {
|
|
4
|
-
const newSettings = { ...settings };
|
|
5
|
-
if (profile.apiURL) {
|
|
6
|
-
newSettings.apiURL = profile.apiURL;
|
|
7
|
-
}
|
|
8
|
-
if (profile.defaultOrganizationId) {
|
|
9
|
-
newSettings.defaultOrganizationId = profile.defaultOrganizationId;
|
|
10
|
-
}
|
|
11
|
-
if (profile.defaultProjectId) {
|
|
12
|
-
newSettings.defaultProjectId = profile.defaultProjectId;
|
|
13
|
-
}
|
|
14
|
-
if (profile.defaultRegion) {
|
|
15
|
-
newSettings.defaultRegion = profile.defaultRegion;
|
|
16
|
-
}
|
|
17
|
-
if (profile.defaultZone) {
|
|
18
|
-
newSettings.defaultZone = profile.defaultZone;
|
|
19
|
-
}
|
|
20
|
-
if (hasAuthenticationSecrets(profile)) {
|
|
21
|
-
newSettings.interceptors = [
|
|
22
|
-
{
|
|
23
|
-
request: authenticateWithSecrets(profile)
|
|
24
|
-
},
|
|
25
|
-
...newSettings.interceptors
|
|
26
|
-
];
|
|
27
|
-
}
|
|
28
|
-
return newSettings;
|
|
29
|
-
};
|
|
30
|
-
const withHTTPClient = (httpClient) => (settings) => ({ ...settings, httpClient });
|
|
31
|
-
const withDefaultPageSize = (defaultPageSize) => (settings) => ({ ...settings, defaultPageSize });
|
|
32
|
-
const withUserAgent = (userAgent) => (settings) => ({ ...settings, userAgent });
|
|
33
|
-
const withUserAgentSuffix = (userAgent) => (settings) => ({
|
|
34
|
-
...settings,
|
|
35
|
-
userAgent: settings.userAgent ? `${settings.userAgent} ${userAgent}` : userAgent
|
|
36
|
-
});
|
|
37
|
-
const withAdditionalInterceptors = (interceptors) => (settings) => ({
|
|
38
|
-
...settings,
|
|
39
|
-
interceptors: settings.interceptors.concat(interceptors)
|
|
40
|
-
});
|
|
41
|
-
const withLegacyInterceptors = () => (settings) => {
|
|
42
|
-
if (!settings.requestInterceptors && !settings.responseInterceptors) {
|
|
43
|
-
return settings;
|
|
44
|
-
}
|
|
45
|
-
const allInterceptors = settings.interceptors.concat(
|
|
46
|
-
(settings.requestInterceptors ?? []).map((obj) => ({
|
|
47
|
-
request: obj
|
|
48
|
-
})),
|
|
49
|
-
(settings.responseInterceptors ?? []).map((obj) => ({
|
|
50
|
-
response: obj
|
|
51
|
-
}))
|
|
52
|
-
);
|
|
53
|
-
return {
|
|
54
|
-
...settings,
|
|
55
|
-
interceptors: allInterceptors
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
export {
|
|
59
|
-
withAdditionalInterceptors,
|
|
60
|
-
withDefaultPageSize,
|
|
61
|
-
withHTTPClient,
|
|
62
|
-
withLegacyInterceptors,
|
|
63
|
-
withProfile,
|
|
64
|
-
withUserAgent,
|
|
65
|
-
withUserAgentSuffix
|
|
66
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const stringValidation = require("../internal/validations/string-validation.cjs");
|
|
4
|
-
const hasAuthenticationSecrets = (obj) => typeof obj.accessKey === "string" && obj.accessKey !== "" && typeof obj.secretKey === "string" && obj.secretKey !== "";
|
|
5
|
-
function assertValidAuthenticationSecrets(obj) {
|
|
6
|
-
if (!(obj.accessKey && obj.secretKey)) {
|
|
7
|
-
throw new Error(
|
|
8
|
-
`Invalid secrets, accessKey & secretKey must be defined. See https://www.scaleway.com/en/docs/identity-and-access-management/iam/how-to/create-api-keys/`
|
|
9
|
-
);
|
|
10
|
-
}
|
|
11
|
-
if (!stringValidation.isAccessKey(obj.accessKey)) {
|
|
12
|
-
throw new Error(
|
|
13
|
-
`Invalid access key format '${obj.accessKey}', expected SCWXXXXXXXXXXXXXXXXX format. See https://www.scaleway.com/en/docs/identity-and-access-management/iam/how-to/create-api-keys/`
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
if (!stringValidation.isSecretKey(obj.secretKey)) {
|
|
17
|
-
throw new Error(
|
|
18
|
-
`Invalid secret key format '${obj.secretKey}', expected a UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. See https://www.scaleway.com/en/docs/identity-and-access-management/iam/how-to/create-api-keys/`
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.assertValidAuthenticationSecrets = assertValidAuthenticationSecrets;
|
|
23
|
-
exports.hasAuthenticationSecrets = hasAuthenticationSecrets;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { Region, Zone } from './locality';
|
|
2
|
-
/**
|
|
3
|
-
* Holds access key and secret key.
|
|
4
|
-
*
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
export interface AuthenticationSecrets {
|
|
8
|
-
/**
|
|
9
|
-
* You need an access key and a secret key to connect to Scaleway API.
|
|
10
|
-
* Generate your access key at the following address: {@link https://console.scaleway.com/project/credentials}.
|
|
11
|
-
*/
|
|
12
|
-
accessKey: string;
|
|
13
|
-
/**
|
|
14
|
-
* The secret key is the value that can be used to authenticate against the API (the value used in X-Auth-Token HTTP-header).
|
|
15
|
-
* The secret key MUST remain secret and not given to anyone or published online.
|
|
16
|
-
* Generate your secret key at the following address: {@link https://console.scaleway.com/project/credentials}.
|
|
17
|
-
*/
|
|
18
|
-
secretKey: string;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Holds default values of a Scaleway profile.
|
|
22
|
-
*
|
|
23
|
-
* @public
|
|
24
|
-
*/
|
|
25
|
-
export interface ProfileDefaultValues {
|
|
26
|
-
/**
|
|
27
|
-
* APIURL overrides the API URL of the Scaleway API to the given URL.
|
|
28
|
-
* Change that if you want to direct requests to a different endpoint.
|
|
29
|
-
*
|
|
30
|
-
* @defaultValue `https://api.scaleway.com`
|
|
31
|
-
*/
|
|
32
|
-
apiURL: string;
|
|
33
|
-
/**
|
|
34
|
-
* Your organization ID is the identifier of your account inside Scaleway infrastructure.
|
|
35
|
-
*/
|
|
36
|
-
defaultOrganizationId?: string;
|
|
37
|
-
/**
|
|
38
|
-
* Your project ID is the identifier of the project your resources are attached to.
|
|
39
|
-
*/
|
|
40
|
-
defaultProjectId?: string;
|
|
41
|
-
/**
|
|
42
|
-
* A region is represented as a geographical area such as France (Paris) or the Netherlands (Amsterdam).
|
|
43
|
-
* It can contain multiple availability zones.
|
|
44
|
-
*
|
|
45
|
-
* Examples: fr-par, nl-ams.
|
|
46
|
-
*/
|
|
47
|
-
defaultRegion?: Region;
|
|
48
|
-
/**
|
|
49
|
-
* A region can be split into many availability zones (AZ).
|
|
50
|
-
* Latency between multiple AZ of the same region are low as they have a common network layer.
|
|
51
|
-
*
|
|
52
|
-
* Examples: fr-par-1, nl-ams-1
|
|
53
|
-
*/
|
|
54
|
-
defaultZone?: Zone;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Holds values of a Scaleway profile.
|
|
58
|
-
*
|
|
59
|
-
* @public
|
|
60
|
-
*/
|
|
61
|
-
export type Profile = Partial<ProfileDefaultValues & AuthenticationSecrets>;
|
|
62
|
-
/**
|
|
63
|
-
* Verifies that the payload contains both the accessKey and the secretKey.
|
|
64
|
-
*
|
|
65
|
-
* @param obj - The secrets
|
|
66
|
-
* @returns Whether the secrets are not empty.
|
|
67
|
-
*
|
|
68
|
-
* @internal
|
|
69
|
-
*/
|
|
70
|
-
export declare const hasAuthenticationSecrets: (obj: Partial<AuthenticationSecrets>) => obj is AuthenticationSecrets;
|
|
71
|
-
/**
|
|
72
|
-
* Asserts the format of secrets.
|
|
73
|
-
*
|
|
74
|
-
* @param obj - The secrets
|
|
75
|
-
* @returns Whether the secrets use a valid format
|
|
76
|
-
*
|
|
77
|
-
* @throws Error
|
|
78
|
-
* Thrown if either the accessKey or the secretKey has en invalid format.
|
|
79
|
-
*
|
|
80
|
-
* @internal
|
|
81
|
-
*/
|
|
82
|
-
export declare function assertValidAuthenticationSecrets(obj: Partial<AuthenticationSecrets>): asserts obj is AuthenticationSecrets;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { isAccessKey, isSecretKey } from "../internal/validations/string-validation.js";
|
|
2
|
-
const hasAuthenticationSecrets = (obj) => typeof obj.accessKey === "string" && obj.accessKey !== "" && typeof obj.secretKey === "string" && obj.secretKey !== "";
|
|
3
|
-
function assertValidAuthenticationSecrets(obj) {
|
|
4
|
-
if (!(obj.accessKey && obj.secretKey)) {
|
|
5
|
-
throw new Error(
|
|
6
|
-
`Invalid secrets, accessKey & secretKey must be defined. See https://www.scaleway.com/en/docs/identity-and-access-management/iam/how-to/create-api-keys/`
|
|
7
|
-
);
|
|
8
|
-
}
|
|
9
|
-
if (!isAccessKey(obj.accessKey)) {
|
|
10
|
-
throw new Error(
|
|
11
|
-
`Invalid access key format '${obj.accessKey}', expected SCWXXXXXXXXXXXXXXXXX format. See https://www.scaleway.com/en/docs/identity-and-access-management/iam/how-to/create-api-keys/`
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
if (!isSecretKey(obj.secretKey)) {
|
|
15
|
-
throw new Error(
|
|
16
|
-
`Invalid secret key format '${obj.secretKey}', expected a UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. See https://www.scaleway.com/en/docs/identity-and-access-management/iam/how-to/create-api-keys/`
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
export {
|
|
21
|
-
assertValidAuthenticationSecrets,
|
|
22
|
-
hasAuthenticationSecrets
|
|
23
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const stringValidation = require("../internal/validations/string-validation.cjs");
|
|
4
|
-
const assertValidSettings = (obj) => {
|
|
5
|
-
if (obj.defaultOrganizationId !== void 0) {
|
|
6
|
-
if (typeof obj.defaultOrganizationId !== "string" || obj.defaultOrganizationId.length === 0) {
|
|
7
|
-
throw new Error("Default organization ID cannot be empty");
|
|
8
|
-
}
|
|
9
|
-
if (!stringValidation.isOrganizationId(obj.defaultOrganizationId)) {
|
|
10
|
-
throw new Error(
|
|
11
|
-
`Invalid organization ID format '${obj.defaultOrganizationId}', expected a UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
if (obj.defaultProjectId !== void 0) {
|
|
16
|
-
if (typeof obj.defaultProjectId !== "string" || obj.defaultProjectId.length === 0) {
|
|
17
|
-
throw new Error("Default project ID cannot be empty");
|
|
18
|
-
}
|
|
19
|
-
if (!stringValidation.isProjectId(obj.defaultProjectId)) {
|
|
20
|
-
throw new Error(
|
|
21
|
-
`Invalid project ID format '${obj.defaultProjectId}', expected a UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
if (obj.defaultRegion && !stringValidation.isRegion(obj.defaultRegion)) {
|
|
26
|
-
throw new Error(`Invalid default region format '${obj.defaultRegion}'`);
|
|
27
|
-
}
|
|
28
|
-
if (obj.defaultZone && !stringValidation.isZone(obj.defaultZone)) {
|
|
29
|
-
throw new Error(`Invalid default zone format '${obj.defaultZone}'`);
|
|
30
|
-
}
|
|
31
|
-
if (obj.apiURL && !stringValidation.isURL(obj.apiURL)) {
|
|
32
|
-
throw new Error(`Invalid URL ${obj.apiURL}`);
|
|
33
|
-
}
|
|
34
|
-
if (obj.apiURL?.endsWith("/")) {
|
|
35
|
-
throw new Error(
|
|
36
|
-
`Invalid URL ${obj.apiURL}: it should not have a trailing slash`
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
if (typeof obj.httpClient !== typeof fetch) {
|
|
40
|
-
throw new Error(`Invalid HTTP Client`);
|
|
41
|
-
}
|
|
42
|
-
if (obj.defaultPageSize !== void 0 && (typeof obj.defaultPageSize !== "number" || Number.isNaN(obj.defaultPageSize) || obj.defaultPageSize <= 0)) {
|
|
43
|
-
throw new Error(
|
|
44
|
-
`Invalid defaultPageSize ${obj.defaultPageSize}: it should be a number above 0`
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
if (typeof obj.userAgent !== "string") {
|
|
48
|
-
throw new Error(`Invalid User-Agent`);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
exports.assertValidSettings = assertValidSettings;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { NetworkInterceptors, RequestInterceptor, ResponseInterceptor } from '../internal/interceptors/types';
|
|
2
|
-
import type { Profile } from './client-ini-profile.js';
|
|
3
|
-
/**
|
|
4
|
-
* Holds default values of settings.
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
export type DefaultValues = Profile & {
|
|
9
|
-
/**
|
|
10
|
-
* The default number of results when requesting a paginated resource.
|
|
11
|
-
*/
|
|
12
|
-
defaultPageSize?: number;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Settings hold the values of all client options.
|
|
16
|
-
*
|
|
17
|
-
* @public
|
|
18
|
-
*/
|
|
19
|
-
export interface Settings extends DefaultValues {
|
|
20
|
-
/**
|
|
21
|
-
* The default number of results when requesting a paginated resource.
|
|
22
|
-
*/
|
|
23
|
-
defaultPageSize?: number;
|
|
24
|
-
/**
|
|
25
|
-
* HTTP Client doing the requests.
|
|
26
|
-
*/
|
|
27
|
-
httpClient: typeof fetch;
|
|
28
|
-
/**
|
|
29
|
-
* The Request interceptors.
|
|
30
|
-
*
|
|
31
|
-
* @deprecated Please use `interceptors` instead.
|
|
32
|
-
*/
|
|
33
|
-
requestInterceptors?: RequestInterceptor[];
|
|
34
|
-
/**
|
|
35
|
-
* The Response interceptors.
|
|
36
|
-
*
|
|
37
|
-
* @deprecated Please use `interceptors` instead.
|
|
38
|
-
*/
|
|
39
|
-
responseInterceptors?: ResponseInterceptor[];
|
|
40
|
-
/**
|
|
41
|
-
* The Network interceptors.
|
|
42
|
-
*/
|
|
43
|
-
interceptors: NetworkInterceptors[];
|
|
44
|
-
/**
|
|
45
|
-
* The User-Agent sent with each request.
|
|
46
|
-
*
|
|
47
|
-
* @defaultValue scaleway-sdk-js/version
|
|
48
|
-
*/
|
|
49
|
-
userAgent: string;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Validates the content of a {@link Settings} object.
|
|
53
|
-
*
|
|
54
|
-
* @throws Error
|
|
55
|
-
* Thrown if {@link Settings} aren't valid.
|
|
56
|
-
*
|
|
57
|
-
* @internal
|
|
58
|
-
*/
|
|
59
|
-
export declare const assertValidSettings: (obj: Readonly<Settings>) => void;
|