@scaleway/sdk-client 1.3.2 → 2.1.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.
Files changed (65) hide show
  1. package/dist/helpers/json.js +6 -7
  2. package/dist/helpers/marshalling.d.ts +0 -8
  3. package/dist/helpers/marshalling.js +18 -22
  4. package/dist/internal/async/interval-retrier.js +2 -1
  5. package/dist/internal/interceptors/types.d.ts +7 -0
  6. package/dist/package.json.js +1 -1
  7. package/dist/scw/auth.d.ts +7 -0
  8. package/dist/scw/custom-marshalling.js +5 -7
  9. package/dist/scw/errors/error-parser.js +4 -4
  10. package/dist/scw/errors/non-standard/invalid-request-mapper.d.ts +1 -3
  11. package/dist/scw/errors/non-standard/invalid-request-mapper.js +27 -29
  12. package/dist/scw/errors/non-standard/unknown-resource-mapper.d.ts +1 -3
  13. package/dist/scw/errors/non-standard/unknown-resource-mapper.js +15 -17
  14. package/dist/scw/fetch/build-fetcher.js +2 -1
  15. package/dist/scw/fetch/http-interceptors.d.ts +7 -0
  16. package/dist/vendor/base64/index.js +16 -11
  17. package/package.json +2 -4
  18. package/dist/helpers/is-browser.cjs +0 -4
  19. package/dist/helpers/is-response.cjs +0 -4
  20. package/dist/helpers/json.cjs +0 -47
  21. package/dist/helpers/marshalling.cjs +0 -76
  22. package/dist/index.cjs +0 -58
  23. package/dist/internal/async/interval-retrier.cjs +0 -53
  24. package/dist/internal/async/sleep.cjs +0 -6
  25. package/dist/internal/interceptors/composer.cjs +0 -25
  26. package/dist/internal/interceptors/helpers.cjs +0 -12
  27. package/dist/internal/logger/console-logger.cjs +0 -24
  28. package/dist/internal/logger/index.cjs +0 -12
  29. package/dist/internal/logger/level-resolver.cjs +0 -13
  30. package/dist/internal/validations/string-validation.cjs +0 -30
  31. package/dist/package.json.cjs +0 -8
  32. package/dist/scw/api.cjs +0 -8
  33. package/dist/scw/auth.cjs +0 -25
  34. package/dist/scw/client-ini-factory.cjs +0 -66
  35. package/dist/scw/client-ini-profile.cjs +0 -23
  36. package/dist/scw/client-settings.cjs +0 -51
  37. package/dist/scw/client.cjs +0 -31
  38. package/dist/scw/constants.cjs +0 -11
  39. package/dist/scw/custom-marshalling.cjs +0 -152
  40. package/dist/scw/custom-types.cjs +0 -11
  41. package/dist/scw/errors/error-parser.cjs +0 -76
  42. package/dist/scw/errors/non-standard/invalid-request-mapper.cjs +0 -36
  43. package/dist/scw/errors/non-standard/unknown-resource-mapper.cjs +0 -23
  44. package/dist/scw/errors/scw-error.cjs +0 -43
  45. package/dist/scw/errors/standard/already-exists-error.cjs +0 -31
  46. package/dist/scw/errors/standard/denied-authentication-error.cjs +0 -37
  47. package/dist/scw/errors/standard/index.cjs +0 -28
  48. package/dist/scw/errors/standard/invalid-arguments-error.cjs +0 -54
  49. package/dist/scw/errors/standard/out-of-stock-error.cjs +0 -17
  50. package/dist/scw/errors/standard/permissions-denied-error.cjs +0 -29
  51. package/dist/scw/errors/standard/precondition-failed-error.cjs +0 -32
  52. package/dist/scw/errors/standard/quotas-exceeded-error.cjs +0 -43
  53. package/dist/scw/errors/standard/resource-expired-error.cjs +0 -31
  54. package/dist/scw/errors/standard/resource-locked-error.cjs +0 -20
  55. package/dist/scw/errors/standard/resource-not-found-error.cjs +0 -24
  56. package/dist/scw/errors/standard/too-many-requests-error.cjs +0 -58
  57. package/dist/scw/errors/standard/transient-state-error.cjs +0 -31
  58. package/dist/scw/errors/types.cjs +0 -15
  59. package/dist/scw/fetch/build-fetcher.cjs +0 -60
  60. package/dist/scw/fetch/http-dumper.cjs +0 -20
  61. package/dist/scw/fetch/http-interceptors.cjs +0 -43
  62. package/dist/scw/fetch/resource-paginator.cjs +0 -36
  63. package/dist/scw/fetch/response-parser.cjs +0 -55
  64. package/dist/scw/locality.cjs +0 -16
  65. package/dist/vendor/base64/index.cjs +0 -46
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const isResponse = require("../../helpers/is-response.cjs");
4
- const json = require("../../helpers/json.cjs");
5
- const errorParser = require("../errors/error-parser.cjs");
6
- const scwError = require("../errors/scw-error.cjs");
7
- const X_TOTAL_COUNT_HEADER_KEY = "x-total-count";
8
- const TOTAL_COUNT_RES_KEY = "total_count";
9
- const fixLegacyTotalCount = (obj, headers) => {
10
- const headerVal = headers.get(X_TOTAL_COUNT_HEADER_KEY);
11
- if (!headerVal) {
12
- return obj;
13
- }
14
- const totalCount = parseInt(headerVal, 10);
15
- if (Number.isNaN(totalCount)) {
16
- return obj;
17
- }
18
- if (json.isJSONObject(obj) && !(TOTAL_COUNT_RES_KEY in obj)) {
19
- return Object.assign(obj, { [TOTAL_COUNT_RES_KEY]: totalCount });
20
- }
21
- return obj;
22
- };
23
- const responseParser = (unmarshaller, responseType) => async (response) => {
24
- if (!isResponse.isResponse(response)) {
25
- throw new TypeError("Invalid response object");
26
- }
27
- if (response.ok) {
28
- if (response.status === 204) return unmarshaller(void 0);
29
- const contentType = response.headers.get("Content-Type");
30
- try {
31
- if (responseType === "json" && contentType === "application/json") {
32
- return unmarshaller(
33
- fixLegacyTotalCount(await response.json(), response.headers)
34
- );
35
- }
36
- if (responseType === "blob") {
37
- return unmarshaller(await response.blob());
38
- }
39
- return unmarshaller(await response.text());
40
- } catch (err) {
41
- throw new scwError.ScalewayError(
42
- response.status,
43
- `could not parse '${contentType ?? ""}' response${err instanceof Error ? `: ${err.message}` : ""}`
44
- );
45
- }
46
- }
47
- const error = await response.clone().json().catch(() => response.text());
48
- if (json.isJSONObject(error)) throw errorParser.parseScalewayError(response.status, error);
49
- throw new scwError.ScalewayError(
50
- response.status,
51
- typeof error === "string" ? error : "cannot read error response body"
52
- );
53
- };
54
- exports.fixLegacyTotalCount = fixLegacyTotalCount;
55
- exports.responseParser = responseParser;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- function toApiLocality(legacy) {
4
- if (!legacy) {
5
- return { type: "unspecified" };
6
- }
7
- const { zones, regions } = legacy;
8
- if (zones && zones.length > 0) {
9
- return { type: "zone", zones };
10
- }
11
- if (regions && regions.length > 0) {
12
- return { type: "region", regions };
13
- }
14
- return { type: "global" };
15
- }
16
- exports.toApiLocality = toApiLocality;
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- var lookup = [];
4
- var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
5
- for (var i = 0, len = code.length; i < len; ++i) {
6
- lookup[i] = code[i];
7
- }
8
- function tripletToBase64(num) {
9
- return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
10
- }
11
- function encodeChunk(uint8, start, end) {
12
- var tmp;
13
- var output = [];
14
- for (var i = start; i < end; i += 3) {
15
- tmp = (uint8[i] << 16 & 16711680) + (uint8[i + 1] << 8 & 65280) + (uint8[i + 2] & 255);
16
- output.push(tripletToBase64(tmp));
17
- }
18
- return output.join("");
19
- }
20
- function fromByteArray(uint8) {
21
- var tmp;
22
- var len = uint8.length;
23
- var extraBytes = len % 3;
24
- var parts = [];
25
- var maxChunkLength = 16383;
26
- for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
27
- parts.push(
28
- encodeChunk(
29
- uint8,
30
- i,
31
- i + maxChunkLength > len2 ? len2 : i + maxChunkLength
32
- )
33
- );
34
- }
35
- if (extraBytes === 1) {
36
- tmp = uint8[len - 1];
37
- parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "==");
38
- } else if (extraBytes === 2) {
39
- tmp = (uint8[len - 2] << 8) + uint8[len - 1];
40
- parts.push(
41
- lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "="
42
- );
43
- }
44
- return parts.join("");
45
- }
46
- exports.fromByteArray = fromByteArray;