@scaleway/sdk 2.0.0-alpha.11 → 2.0.0-alpha.13
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 +2 -2
- package/dist/api/account/index.js +0 -4
- package/dist/api/account/v2/api.gen.js +0 -147
- package/dist/api/account/v2/index.gen.js +0 -4
- package/dist/api/account/v2/marshalling.gen.js +0 -39
- package/dist/api/account/v3/api.gen.js +0 -129
- package/dist/api/account/v3/index.gen.js +0 -6
- package/dist/api/account/v3/marshalling.gen.js +0 -39
- package/dist/api/account/v3/validation-rules.gen.js +0 -39
- package/dist/api/applesilicon/index.js +0 -2
- package/dist/api/applesilicon/v1alpha1/api.gen.js +0 -220
- package/dist/api/applesilicon/v1alpha1/content.gen.js +0 -7
- package/dist/api/applesilicon/v1alpha1/index.gen.js +0 -5
- package/dist/api/applesilicon/v1alpha1/marshalling.gen.js +0 -113
- package/dist/api/baremetal/index.js +0 -2
- package/dist/api/baremetal/v1/api.gen.js +0 -523
- package/dist/api/baremetal/v1/api.utils.js +0 -27
- package/dist/api/baremetal/v1/content.gen.js +0 -13
- package/dist/api/baremetal/v1/index.js +0 -5
- package/dist/api/baremetal/v1/marshalling.gen.js +0 -395
- package/dist/api/baremetal/v1/validation-rules.gen.js +0 -109
- package/dist/api/billing/index.js +0 -2
- package/dist/api/billing/v2alpha1/api.gen.js +0 -80
- package/dist/api/billing/v2alpha1/index.gen.js +0 -4
- package/dist/api/billing/v2alpha1/marshalling.gen.js +0 -53
- package/dist/api/block/index.js +0 -2
- package/dist/api/block/v1alpha1/api.gen.js +0 -245
- package/dist/api/block/v1alpha1/content.gen.js +0 -13
- package/dist/api/block/v1alpha1/index.gen.js +0 -7
- package/dist/api/block/v1alpha1/marshalling.gen.js +0 -175
- package/dist/api/block/v1alpha1/validation-rules.gen.js +0 -42
- package/dist/api/cockpit/index.js +0 -2
- package/dist/api/cockpit/v1beta1/api.gen.js +0 -448
- package/dist/api/cockpit/v1beta1/content.gen.js +0 -7
- package/dist/api/cockpit/v1beta1/index.gen.js +0 -5
- package/dist/api/cockpit/v1beta1/marshalling.gen.js +0 -220
- package/dist/api/container/index.js +0 -2
- package/dist/api/container/v1beta1/api.gen.js +0 -549
- package/dist/api/container/v1beta1/content.gen.js +0 -22
- package/dist/api/container/v1beta1/index.gen.js +0 -5
- package/dist/api/container/v1beta1/marshalling.gen.js +0 -330
- package/dist/api/document_db/index.js +0 -2
- package/dist/api/document_db/v1beta1/api.gen.js +0 -830
- package/dist/api/document_db/v1beta1/content.gen.js +0 -19
- package/dist/api/document_db/v1beta1/index.gen.js +0 -7
- package/dist/api/document_db/v1beta1/marshalling.gen.js +0 -580
- package/dist/api/document_db/v1beta1/validation-rules.gen.js +0 -10
- package/dist/api/domain/index.js +0 -2
- package/dist/api/domain/v2beta1/api.gen.js +0 -875
- package/dist/api/domain/v2beta1/content.gen.js +0 -28
- package/dist/api/domain/v2beta1/index.gen.js +0 -7
- package/dist/api/domain/v2beta1/marshalling.gen.js +0 -958
- package/dist/api/flexibleip/index.js +0 -2
- package/dist/api/flexibleip/v1alpha1/api.gen.js +0 -203
- package/dist/api/flexibleip/v1alpha1/content.gen.js +0 -10
- package/dist/api/flexibleip/v1alpha1/index.gen.js +0 -7
- package/dist/api/flexibleip/v1alpha1/marshalling.gen.js +0 -97
- package/dist/api/flexibleip/v1alpha1/validation-rules.gen.js +0 -14
- package/dist/api/function/index.js +0 -2
- package/dist/api/function/v1beta1/api.gen.js +0 -560
- package/dist/api/function/v1beta1/content.gen.js +0 -22
- package/dist/api/function/v1beta1/index.gen.js +0 -5
- package/dist/api/function/v1beta1/marshalling.gen.js +0 -368
- package/dist/api/iam/index.js +0 -2
- package/dist/api/iam/v1alpha1/api.gen.js +0 -799
- package/dist/api/iam/v1alpha1/index.gen.js +0 -6
- package/dist/api/iam/v1alpha1/marshalling.gen.js +0 -373
- package/dist/api/iam/v1alpha1/validation-rules.gen.js +0 -207
- package/dist/api/instance/index.js +0 -2
- package/dist/api/instance/v1/api.gen.js +0 -1003
- package/dist/api/instance/v1/api.utils.js +0 -369
- package/dist/api/instance/v1/content.gen.js +0 -31
- package/dist/api/instance/v1/index.js +0 -2
- package/dist/api/instance/v1/marshalling.gen.js +0 -1206
- package/dist/api/instance/v1/marshalling.utils.js +0 -63
- package/dist/api/iot/index.js +0 -2
- package/dist/api/iot/v1/api.gen.js +0 -581
- package/dist/api/iot/v1/content.gen.js +0 -7
- package/dist/api/iot/v1/index.gen.js +0 -5
- package/dist/api/iot/v1/marshalling.gen.js +0 -388
- package/dist/api/ipfs/index.js +0 -2
- package/dist/api/ipfs/v1alpha1/api.gen.js +0 -197
- package/dist/api/ipfs/v1alpha1/content.gen.js +0 -7
- package/dist/api/ipfs/v1alpha1/index.gen.js +0 -5
- package/dist/api/ipfs/v1alpha1/marshalling.gen.js +0 -121
- package/dist/api/k8s/index.js +0 -2
- package/dist/api/k8s/v1/api.gen.js +0 -454
- package/dist/api/k8s/v1/api.utils.js +0 -13
- package/dist/api/k8s/v1/content.gen.js +0 -13
- package/dist/api/k8s/v1/index.js +0 -4
- package/dist/api/k8s/v1/marshalling.gen.js +0 -333
- package/dist/api/k8s/v1/validation-rules.gen.js +0 -101
- package/dist/api/lb/index.js +0 -2
- package/dist/api/lb/v1/api.gen.js +0 -1669
- package/dist/api/lb/v1/api.utils.js +0 -81
- package/dist/api/lb/v1/content.gen.js +0 -16
- package/dist/api/lb/v1/index.js +0 -2
- package/dist/api/lb/v1/marshalling.gen.js +0 -923
- package/dist/api/marketplace/index.js +0 -4
- package/dist/api/marketplace/v1/api.gen.js +0 -60
- package/dist/api/marketplace/v1/index.gen.js +0 -4
- package/dist/api/marketplace/v1/marshalling.gen.js +0 -92
- package/dist/api/marketplace/v2/api.gen.js +0 -162
- package/dist/api/marketplace/v2/index.gen.js +0 -4
- package/dist/api/marketplace/v2/marshalling.gen.js +0 -94
- package/dist/api/mnq/index.js +0 -2
- package/dist/api/mnq/v1alpha1/api.gen.js +0 -205
- package/dist/api/mnq/v1alpha1/index.gen.js +0 -4
- package/dist/api/mnq/v1alpha1/marshalling.gen.js +0 -121
- package/dist/api/rdb/index.js +0 -2
- package/dist/api/rdb/v1/api.gen.js +0 -972
- package/dist/api/rdb/v1/content.gen.js +0 -22
- package/dist/api/rdb/v1/index.gen.js +0 -7
- package/dist/api/rdb/v1/marshalling.gen.js +0 -636
- package/dist/api/rdb/v1/validation-rules.gen.js +0 -10
- package/dist/api/redis/index.js +0 -2
- package/dist/api/redis/v1/api.gen.js +0 -389
- package/dist/api/redis/v1/content.gen.js +0 -7
- package/dist/api/redis/v1/index.gen.js +0 -5
- package/dist/api/redis/v1/marshalling.gen.js +0 -259
- package/dist/api/registry/index.js +0 -2
- package/dist/api/registry/v1/api.gen.js +0 -252
- package/dist/api/registry/v1/content.gen.js +0 -13
- package/dist/api/registry/v1/index.gen.js +0 -5
- package/dist/api/registry/v1/marshalling.gen.js +0 -106
- package/dist/api/secret/index.js +0 -2
- package/dist/api/secret/v1alpha1/api.gen.js +0 -415
- package/dist/api/secret/v1alpha1/index.gen.js +0 -4
- package/dist/api/secret/v1alpha1/marshalling.gen.js +0 -143
- package/dist/api/tem/index.js +0 -2
- package/dist/api/tem/v1alpha1/api.gen.js +0 -229
- package/dist/api/tem/v1alpha1/content.gen.js +0 -10
- package/dist/api/tem/v1alpha1/index.gen.js +0 -5
- package/dist/api/tem/v1alpha1/marshalling.gen.js +0 -159
- package/dist/api/test/index.js +0 -2
- package/dist/api/test/v1/api.gen.js +0 -152
- package/dist/api/test/v1/content.gen.js +0 -7
- package/dist/api/test/v1/index.gen.js +0 -5
- package/dist/api/test/v1/marshalling.gen.js +0 -79
- package/dist/api/vpc/index.js +0 -4
- package/dist/api/vpc/v1/api.gen.js +0 -110
- package/dist/api/vpc/v1/index.gen.js +0 -4
- package/dist/api/vpc/v1/marshalling.gen.js +0 -44
- package/dist/api/vpc/v2/api.gen.js +0 -276
- package/dist/api/vpc/v2/index.gen.js +0 -4
- package/dist/api/vpc/v2/marshalling.gen.js +0 -135
- package/dist/api/vpcgw/index.js +0 -2
- package/dist/api/vpcgw/v1/api.gen.js +0 -669
- package/dist/api/vpcgw/v1/content.gen.js +0 -10
- package/dist/api/vpcgw/v1/index.gen.js +0 -5
- package/dist/api/vpcgw/v1/marshalling.gen.js +0 -336
- package/dist/api/webhosting/index.js +0 -2
- package/dist/api/webhosting/v1alpha1/api.gen.js +0 -210
- package/dist/api/webhosting/v1alpha1/content.gen.js +0 -7
- package/dist/api/webhosting/v1alpha1/index.gen.js +0 -7
- package/dist/api/webhosting/v1alpha1/marshalling.gen.js +0 -173
- package/dist/api/webhosting/v1alpha1/validation-rules.gen.js +0 -23
- package/dist/helpers/is-browser.js +0 -5
- package/dist/helpers/is-response.js +0 -10
- package/dist/helpers/json.js +0 -11
- package/dist/helpers/marshalling.js +0 -130
- package/dist/index.cjs +0 -24364
- package/dist/index.d.ts +0 -27584
- package/dist/index.js +0 -69
- package/dist/internal/async/interval-retrier.js +0 -105
- package/dist/internal/async/sleep.js +0 -13
- package/dist/internal/interceptors/composer.js +0 -46
- package/dist/internal/interceptors/helpers.js +0 -32
- package/dist/internal/logger/console-logger.js +0 -38
- package/dist/internal/logger/index.js +0 -41
- package/dist/internal/logger/level-resolver.js +0 -13
- package/dist/internal/validations/string-validation.js +0 -38
- package/dist/node_modules/.pnpm/@scaleway_random-name@4.0.2/node_modules/@scaleway/random-name/dist/index.js +0 -13
- package/dist/scw/api.js +0 -12
- package/dist/scw/auth.js +0 -68
- package/dist/scw/client-ini-factory.js +0 -174
- package/dist/scw/client-ini-profile.js +0 -54
- package/dist/scw/client-settings.js +0 -78
- package/dist/scw/client.js +0 -98
- package/dist/scw/constants.js +0 -4
- package/dist/scw/custom-marshalling.js +0 -131
- package/dist/scw/errors/error-parser.js +0 -107
- package/dist/scw/errors/non-standard/invalid-request-mapper.js +0 -36
- package/dist/scw/errors/non-standard/unknown-resource-mapper.js +0 -27
- package/dist/scw/errors/scw-error.js +0 -66
- package/dist/scw/errors/standard/already-exists-error.js +0 -26
- package/dist/scw/errors/standard/denied-authentication-error.js +0 -52
- package/dist/scw/errors/standard/index.js +0 -13
- package/dist/scw/errors/standard/invalid-arguments-error.js +0 -67
- package/dist/scw/errors/standard/out-of-stock-error.js +0 -22
- package/dist/scw/errors/standard/permissions-denied-error.js +0 -48
- package/dist/scw/errors/standard/precondition-failed-error.js +0 -42
- package/dist/scw/errors/standard/quotas-exceeded-error.js +0 -68
- package/dist/scw/errors/standard/resource-expired-error.js +0 -26
- package/dist/scw/errors/standard/resource-locked-error.js +0 -25
- package/dist/scw/errors/standard/resource-not-found-error.js +0 -25
- package/dist/scw/errors/standard/too-many-requests-error.js +0 -70
- package/dist/scw/errors/standard/transient-state-error.js +0 -26
- package/dist/scw/errors/types.js +0 -23
- package/dist/scw/fetch/build-fetcher.js +0 -72
- package/dist/scw/fetch/http-dumper.js +0 -54
- package/dist/scw/fetch/http-interceptors.js +0 -99
- package/dist/scw/fetch/resource-paginator.js +0 -84
- package/dist/scw/fetch/response-parser.js +0 -72
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
const extract = key => result => result[key];
|
|
2
|
-
function* pages(key, fetcher, request, firstPage) {
|
|
3
|
-
if (!Array.isArray(firstPage[key])) {
|
|
4
|
-
throw new Error(`Property ${key} is not a list in paginated result`);
|
|
5
|
-
}
|
|
6
|
-
const getList = extract(key);
|
|
7
|
-
let page = request.page || 1;
|
|
8
|
-
if (page === 1) {
|
|
9
|
-
yield Promise.resolve(getList(firstPage));
|
|
10
|
-
page += 1;
|
|
11
|
-
}
|
|
12
|
-
const {
|
|
13
|
-
length
|
|
14
|
-
} = firstPage[key];
|
|
15
|
-
if (!length) return;
|
|
16
|
-
const {
|
|
17
|
-
totalCount
|
|
18
|
-
} = firstPage;
|
|
19
|
-
while (page <= Math.floor((totalCount + length - 1) / length)) {
|
|
20
|
-
yield fetcher({
|
|
21
|
-
...request,
|
|
22
|
-
page
|
|
23
|
-
}).then(getList);
|
|
24
|
-
page += 1;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Fetches a paginated resource.
|
|
30
|
-
*
|
|
31
|
-
* @param key - The resource key of values list
|
|
32
|
-
* @param fetcher - The method to retrieve paginated resources
|
|
33
|
-
* @param request - A request with pagination options
|
|
34
|
-
* @param initial - The first page
|
|
35
|
-
* @returns An async generator of resources arrays
|
|
36
|
-
*/
|
|
37
|
-
function fetchPaginated(key, fetcher, request, initial) {
|
|
38
|
-
try {
|
|
39
|
-
if (initial === void 0) {
|
|
40
|
-
initial = fetcher(request);
|
|
41
|
-
}
|
|
42
|
-
return async function* () {
|
|
43
|
-
yield* pages(key, fetcher, request, await initial);
|
|
44
|
-
}();
|
|
45
|
-
} catch (e) {
|
|
46
|
-
return Promise.reject(e);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Fetches all paginated resource.
|
|
52
|
-
*
|
|
53
|
-
* @param key - The resource key of values list
|
|
54
|
-
* @param fetcher - The method to retrieve paginated resources
|
|
55
|
-
* @param request - A request with pagination options
|
|
56
|
-
* @param initial - The first page
|
|
57
|
-
* @returns A resources array Promise
|
|
58
|
-
*/
|
|
59
|
-
const fetchAll = async function (key, fetcher, request, initial) {
|
|
60
|
-
if (initial === void 0) {
|
|
61
|
-
initial = fetcher(request);
|
|
62
|
-
}
|
|
63
|
-
return (await Promise.all(Array.from(pages(key, fetcher, request, await initial)))).flat();
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Enriches a listing method with helpers.
|
|
68
|
-
*
|
|
69
|
-
* @param key - The resource key of values list
|
|
70
|
-
* @param fetcher - The method to retrieve paginated resources
|
|
71
|
-
* @param request - A request with pagination options
|
|
72
|
-
* @returns A resource Promise with the pagination helpers
|
|
73
|
-
*
|
|
74
|
-
* @internal
|
|
75
|
-
*/
|
|
76
|
-
const enrichForPagination = (key, fetcher, request) => {
|
|
77
|
-
const firstPage = fetcher(request);
|
|
78
|
-
return Object.assign(firstPage, {
|
|
79
|
-
all: () => fetchAll(key, fetcher, request, firstPage),
|
|
80
|
-
[Symbol.asyncIterator]: () => fetchPaginated(key, fetcher, request, firstPage)
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export { enrichForPagination, extract, fetchAll, fetchPaginated };
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { isResponse } from '../../helpers/is-response.js';
|
|
2
|
-
import { isJSONObject } from '../../helpers/json.js';
|
|
3
|
-
import { parseScalewayError } from '../errors/error-parser.js';
|
|
4
|
-
import { ScalewayError } from '../errors/scw-error.js';
|
|
5
|
-
|
|
6
|
-
const X_TOTAL_COUNT_HEADER_KEY = 'x-total-count';
|
|
7
|
-
const TOTAL_COUNT_RES_KEY = 'total_count';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Fixes the totalCount property for old APIs.
|
|
11
|
-
*
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
const fixLegacyTotalCount = (obj, headers) => {
|
|
15
|
-
const headerVal = headers.get(X_TOTAL_COUNT_HEADER_KEY);
|
|
16
|
-
if (!headerVal) {
|
|
17
|
-
return obj;
|
|
18
|
-
}
|
|
19
|
-
const totalCount = parseInt(headerVal, 10);
|
|
20
|
-
if (Number.isNaN(totalCount)) {
|
|
21
|
-
return obj;
|
|
22
|
-
}
|
|
23
|
-
if (isJSONObject(obj) && !(TOTAL_COUNT_RES_KEY in obj)) {
|
|
24
|
-
return Object.assign(obj, {
|
|
25
|
-
[TOTAL_COUNT_RES_KEY]: totalCount
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
return obj;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Makes response parser.
|
|
33
|
-
*
|
|
34
|
-
* @param unmarshaller - The response payload unmarshaller
|
|
35
|
-
* @returns An async converter of HTTP Response to desired result
|
|
36
|
-
*
|
|
37
|
-
* @throws {@link ScalewayError}
|
|
38
|
-
* Thrown by the API if the request couldn't be completed.
|
|
39
|
-
*
|
|
40
|
-
* @throws TypeError
|
|
41
|
-
* Thrown if the response parameter isn't of the expected type.
|
|
42
|
-
*
|
|
43
|
-
* @throws Error
|
|
44
|
-
* JSON parsing could trigger an error.
|
|
45
|
-
*
|
|
46
|
-
* @internal
|
|
47
|
-
*/
|
|
48
|
-
const responseParser = (unmarshaller, responseType) => async response => {
|
|
49
|
-
if (!isResponse(response)) {
|
|
50
|
-
throw new TypeError('Invalid response object');
|
|
51
|
-
}
|
|
52
|
-
if (response.ok) {
|
|
53
|
-
if (response.status === 204) return unmarshaller(undefined);
|
|
54
|
-
const contentType = response.headers.get('Content-Type');
|
|
55
|
-
try {
|
|
56
|
-
if (responseType === 'json' && contentType === 'application/json') {
|
|
57
|
-
return unmarshaller(fixLegacyTotalCount(await response.json(), response.headers));
|
|
58
|
-
}
|
|
59
|
-
if (responseType === 'blob') {
|
|
60
|
-
return unmarshaller(await response.blob());
|
|
61
|
-
}
|
|
62
|
-
return unmarshaller(await response.text());
|
|
63
|
-
} catch (err) {
|
|
64
|
-
throw new ScalewayError(response.status, `could not parse '${contentType ?? ''}' response${err instanceof Error ? `: ${err.message}` : ''}`);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
const error = await response.clone().json().catch(() => response.text());
|
|
68
|
-
if (isJSONObject(error)) throw parseScalewayError(response.status, error);
|
|
69
|
-
throw new ScalewayError(response.status, typeof error === 'string' ? error : 'cannot read error response body');
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export { fixLegacyTotalCount, responseParser };
|