@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.
Files changed (149) hide show
  1. package/package.json +4 -7
  2. package/node_modules/@scaleway/sdk-client/README.md +0 -36
  3. package/node_modules/@scaleway/sdk-client/dist/bridge.d.ts +0 -12
  4. package/node_modules/@scaleway/sdk-client/dist/helpers/is-browser.cjs +0 -4
  5. package/node_modules/@scaleway/sdk-client/dist/helpers/is-browser.d.ts +0 -1
  6. package/node_modules/@scaleway/sdk-client/dist/helpers/is-browser.js +0 -4
  7. package/node_modules/@scaleway/sdk-client/dist/helpers/is-response.cjs +0 -4
  8. package/node_modules/@scaleway/sdk-client/dist/helpers/is-response.d.ts +0 -8
  9. package/node_modules/@scaleway/sdk-client/dist/helpers/is-response.js +0 -4
  10. package/node_modules/@scaleway/sdk-client/dist/helpers/json.cjs +0 -47
  11. package/node_modules/@scaleway/sdk-client/dist/helpers/json.d.ts +0 -32
  12. package/node_modules/@scaleway/sdk-client/dist/helpers/json.js +0 -47
  13. package/node_modules/@scaleway/sdk-client/dist/helpers/marshalling.cjs +0 -76
  14. package/node_modules/@scaleway/sdk-client/dist/helpers/marshalling.d.ts +0 -60
  15. package/node_modules/@scaleway/sdk-client/dist/helpers/marshalling.js +0 -76
  16. package/node_modules/@scaleway/sdk-client/dist/index.cjs +0 -56
  17. package/node_modules/@scaleway/sdk-client/dist/index.d.ts +0 -16
  18. package/node_modules/@scaleway/sdk-client/dist/index.js +0 -56
  19. package/node_modules/@scaleway/sdk-client/dist/internal/async/interval-retrier.cjs +0 -53
  20. package/node_modules/@scaleway/sdk-client/dist/internal/async/interval-retrier.d.ts +0 -111
  21. package/node_modules/@scaleway/sdk-client/dist/internal/async/interval-retrier.js +0 -53
  22. package/node_modules/@scaleway/sdk-client/dist/internal/async/sleep.cjs +0 -6
  23. package/node_modules/@scaleway/sdk-client/dist/internal/async/sleep.d.ts +0 -9
  24. package/node_modules/@scaleway/sdk-client/dist/internal/async/sleep.js +0 -6
  25. package/node_modules/@scaleway/sdk-client/dist/internal/interceptors/composer.cjs +0 -25
  26. package/node_modules/@scaleway/sdk-client/dist/internal/interceptors/composer.d.ts +0 -25
  27. package/node_modules/@scaleway/sdk-client/dist/internal/interceptors/composer.js +0 -25
  28. package/node_modules/@scaleway/sdk-client/dist/internal/interceptors/helpers.cjs +0 -12
  29. package/node_modules/@scaleway/sdk-client/dist/internal/interceptors/helpers.d.ts +0 -21
  30. package/node_modules/@scaleway/sdk-client/dist/internal/interceptors/helpers.js +0 -12
  31. package/node_modules/@scaleway/sdk-client/dist/internal/interceptors/types.d.ts +0 -89
  32. package/node_modules/@scaleway/sdk-client/dist/internal/logger/console-logger.cjs +0 -24
  33. package/node_modules/@scaleway/sdk-client/dist/internal/logger/console-logger.d.ts +0 -23
  34. package/node_modules/@scaleway/sdk-client/dist/internal/logger/console-logger.js +0 -24
  35. package/node_modules/@scaleway/sdk-client/dist/internal/logger/index.cjs +0 -12
  36. package/node_modules/@scaleway/sdk-client/dist/internal/logger/index.d.ts +0 -25
  37. package/node_modules/@scaleway/sdk-client/dist/internal/logger/index.js +0 -12
  38. package/node_modules/@scaleway/sdk-client/dist/internal/logger/level-resolver.cjs +0 -13
  39. package/node_modules/@scaleway/sdk-client/dist/internal/logger/level-resolver.d.ts +0 -9
  40. package/node_modules/@scaleway/sdk-client/dist/internal/logger/level-resolver.js +0 -13
  41. package/node_modules/@scaleway/sdk-client/dist/internal/logger/logger.d.ts +0 -13
  42. package/node_modules/@scaleway/sdk-client/dist/internal/validations/string-validation.cjs +0 -30
  43. package/node_modules/@scaleway/sdk-client/dist/internal/validations/string-validation.d.ts +0 -18
  44. package/node_modules/@scaleway/sdk-client/dist/internal/validations/string-validation.js +0 -30
  45. package/node_modules/@scaleway/sdk-client/dist/internals.d.ts +0 -10
  46. package/node_modules/@scaleway/sdk-client/dist/package.json.cjs +0 -8
  47. package/node_modules/@scaleway/sdk-client/dist/package.json.js +0 -8
  48. package/node_modules/@scaleway/sdk-client/dist/scw/api.cjs +0 -8
  49. package/node_modules/@scaleway/sdk-client/dist/scw/api.d.ts +0 -10
  50. package/node_modules/@scaleway/sdk-client/dist/scw/api.js +0 -8
  51. package/node_modules/@scaleway/sdk-client/dist/scw/auth.cjs +0 -25
  52. package/node_modules/@scaleway/sdk-client/dist/scw/auth.d.ts +0 -70
  53. package/node_modules/@scaleway/sdk-client/dist/scw/auth.js +0 -25
  54. package/node_modules/@scaleway/sdk-client/dist/scw/client-ini-factory.cjs +0 -66
  55. package/node_modules/@scaleway/sdk-client/dist/scw/client-ini-factory.d.ts +0 -111
  56. package/node_modules/@scaleway/sdk-client/dist/scw/client-ini-factory.js +0 -66
  57. package/node_modules/@scaleway/sdk-client/dist/scw/client-ini-profile.cjs +0 -23
  58. package/node_modules/@scaleway/sdk-client/dist/scw/client-ini-profile.d.ts +0 -82
  59. package/node_modules/@scaleway/sdk-client/dist/scw/client-ini-profile.js +0 -23
  60. package/node_modules/@scaleway/sdk-client/dist/scw/client-settings.cjs +0 -51
  61. package/node_modules/@scaleway/sdk-client/dist/scw/client-settings.d.ts +0 -59
  62. package/node_modules/@scaleway/sdk-client/dist/scw/client-settings.js +0 -51
  63. package/node_modules/@scaleway/sdk-client/dist/scw/client.cjs +0 -31
  64. package/node_modules/@scaleway/sdk-client/dist/scw/client.d.ts +0 -71
  65. package/node_modules/@scaleway/sdk-client/dist/scw/client.js +0 -31
  66. package/node_modules/@scaleway/sdk-client/dist/scw/constants.cjs +0 -11
  67. package/node_modules/@scaleway/sdk-client/dist/scw/constants.d.ts +0 -4
  68. package/node_modules/@scaleway/sdk-client/dist/scw/constants.js +0 -11
  69. package/node_modules/@scaleway/sdk-client/dist/scw/custom-marshalling.cjs +0 -152
  70. package/node_modules/@scaleway/sdk-client/dist/scw/custom-marshalling.d.ts +0 -104
  71. package/node_modules/@scaleway/sdk-client/dist/scw/custom-marshalling.js +0 -152
  72. package/node_modules/@scaleway/sdk-client/dist/scw/custom-types.cjs +0 -11
  73. package/node_modules/@scaleway/sdk-client/dist/scw/custom-types.d.ts +0 -74
  74. package/node_modules/@scaleway/sdk-client/dist/scw/custom-types.js +0 -11
  75. package/node_modules/@scaleway/sdk-client/dist/scw/errors/error-parser.cjs +0 -76
  76. package/node_modules/@scaleway/sdk-client/dist/scw/errors/error-parser.d.ts +0 -12
  77. package/node_modules/@scaleway/sdk-client/dist/scw/errors/error-parser.js +0 -76
  78. package/node_modules/@scaleway/sdk-client/dist/scw/errors/non-standard/invalid-request-mapper.cjs +0 -36
  79. package/node_modules/@scaleway/sdk-client/dist/scw/errors/non-standard/invalid-request-mapper.d.ts +0 -12
  80. package/node_modules/@scaleway/sdk-client/dist/scw/errors/non-standard/invalid-request-mapper.js +0 -36
  81. package/node_modules/@scaleway/sdk-client/dist/scw/errors/non-standard/unknown-resource-mapper.cjs +0 -23
  82. package/node_modules/@scaleway/sdk-client/dist/scw/errors/non-standard/unknown-resource-mapper.d.ts +0 -11
  83. package/node_modules/@scaleway/sdk-client/dist/scw/errors/non-standard/unknown-resource-mapper.js +0 -23
  84. package/node_modules/@scaleway/sdk-client/dist/scw/errors/scw-error-from-json.d.ts +0 -10
  85. package/node_modules/@scaleway/sdk-client/dist/scw/errors/scw-error.cjs +0 -43
  86. package/node_modules/@scaleway/sdk-client/dist/scw/errors/scw-error.d.ts +0 -25
  87. package/node_modules/@scaleway/sdk-client/dist/scw/errors/scw-error.js +0 -43
  88. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/already-exists-error.cjs +0 -31
  89. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/already-exists-error.d.ts +0 -16
  90. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/already-exists-error.js +0 -31
  91. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/denied-authentication-error.cjs +0 -37
  92. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/denied-authentication-error.d.ts +0 -15
  93. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/denied-authentication-error.js +0 -37
  94. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/index.cjs +0 -28
  95. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/index.d.ts +0 -17
  96. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/index.js +0 -28
  97. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/invalid-arguments-error.cjs +0 -54
  98. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/invalid-arguments-error.d.ts +0 -24
  99. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/invalid-arguments-error.js +0 -54
  100. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/out-of-stock-error.cjs +0 -17
  101. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/out-of-stock-error.d.ts +0 -14
  102. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/out-of-stock-error.js +0 -17
  103. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/permissions-denied-error.cjs +0 -29
  104. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/permissions-denied-error.d.ts +0 -23
  105. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/permissions-denied-error.js +0 -29
  106. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/precondition-failed-error.cjs +0 -32
  107. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/precondition-failed-error.d.ts +0 -15
  108. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/precondition-failed-error.js +0 -32
  109. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/quotas-exceeded-error.cjs +0 -43
  110. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/quotas-exceeded-error.d.ts +0 -34
  111. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/quotas-exceeded-error.js +0 -43
  112. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-expired-error.cjs +0 -31
  113. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-expired-error.d.ts +0 -16
  114. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-expired-error.js +0 -31
  115. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-locked-error.cjs +0 -20
  116. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-locked-error.d.ts +0 -15
  117. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-locked-error.js +0 -20
  118. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-not-found-error.cjs +0 -24
  119. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-not-found-error.d.ts +0 -15
  120. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-not-found-error.js +0 -24
  121. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/too-many-requests-error.cjs +0 -58
  122. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/too-many-requests-error.d.ts +0 -32
  123. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/too-many-requests-error.js +0 -58
  124. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/transient-state-error.cjs +0 -31
  125. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/transient-state-error.d.ts +0 -16
  126. package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/transient-state-error.js +0 -31
  127. package/node_modules/@scaleway/sdk-client/dist/scw/errors/types.cjs +0 -15
  128. package/node_modules/@scaleway/sdk-client/dist/scw/errors/types.d.ts +0 -9
  129. package/node_modules/@scaleway/sdk-client/dist/scw/errors/types.js +0 -15
  130. package/node_modules/@scaleway/sdk-client/dist/scw/fetch/build-fetcher.cjs +0 -60
  131. package/node_modules/@scaleway/sdk-client/dist/scw/fetch/build-fetcher.d.ts +0 -23
  132. package/node_modules/@scaleway/sdk-client/dist/scw/fetch/build-fetcher.js +0 -60
  133. package/node_modules/@scaleway/sdk-client/dist/scw/fetch/http-dumper.cjs +0 -20
  134. package/node_modules/@scaleway/sdk-client/dist/scw/fetch/http-dumper.d.ts +0 -18
  135. package/node_modules/@scaleway/sdk-client/dist/scw/fetch/http-dumper.js +0 -20
  136. package/node_modules/@scaleway/sdk-client/dist/scw/fetch/http-interceptors.cjs +0 -43
  137. package/node_modules/@scaleway/sdk-client/dist/scw/fetch/http-interceptors.d.ts +0 -38
  138. package/node_modules/@scaleway/sdk-client/dist/scw/fetch/http-interceptors.js +0 -43
  139. package/node_modules/@scaleway/sdk-client/dist/scw/fetch/resource-paginator.cjs +0 -36
  140. package/node_modules/@scaleway/sdk-client/dist/scw/fetch/resource-paginator.d.ts +0 -47
  141. package/node_modules/@scaleway/sdk-client/dist/scw/fetch/resource-paginator.js +0 -36
  142. package/node_modules/@scaleway/sdk-client/dist/scw/fetch/response-parser.cjs +0 -55
  143. package/node_modules/@scaleway/sdk-client/dist/scw/fetch/response-parser.d.ts +0 -25
  144. package/node_modules/@scaleway/sdk-client/dist/scw/fetch/response-parser.js +0 -55
  145. package/node_modules/@scaleway/sdk-client/dist/scw/fetch/types.d.ts +0 -16
  146. package/node_modules/@scaleway/sdk-client/dist/scw/locality.d.ts +0 -2
  147. package/node_modules/@scaleway/sdk-client/dist/vendor/base64/index.cjs +0 -46
  148. package/node_modules/@scaleway/sdk-client/dist/vendor/base64/index.js +0 -46
  149. package/node_modules/@scaleway/sdk-client/package.json +0 -36
@@ -1,74 +0,0 @@
1
- /**
2
- * Represents API metadata.
3
- *
4
- * @remarks These metadata are only here for debugging. Do not rely on these values.
5
- *
6
- * @internal
7
- */
8
- export interface ServiceInfo {
9
- /** Name of the API */
10
- name: string;
11
- /** Human readable description for the API. */
12
- description: string;
13
- /** Version of the API. */
14
- version: string;
15
- /** Web url where the documentation of the API can be found. */
16
- documentationUrl?: string;
17
- }
18
- /**
19
- * Represents an amount of money with its currency type.
20
- */
21
- export interface Money {
22
- /** 3-letter currency code defined in ISO 4217. */
23
- currencyCode: string;
24
- /**
25
- * Whole units of the amount.
26
- *
27
- * For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
28
- */
29
- units: number;
30
- /**
31
- * Number of nano (10^-9) units of the amount.
32
- *
33
- * The value must be between -999,999,999 and +999,999,999 inclusive.
34
- * If `units` is positive, `nanos` must be positive or zero.
35
- * If `units` is zero, `nanos` can be positive, zero, or negative.
36
- * If `units` is negative, `nanos` must be negative or zero.
37
- * For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
38
- */
39
- nanos: number;
40
- }
41
- /** Represents a point in a TimeSeries. */
42
- export interface TimeSeriesPoint {
43
- /** Date of the point. */
44
- timestamp?: Date;
45
- /** Value of the point. */
46
- value: number;
47
- }
48
- /** Represents a time series that could be used for graph purposes. */
49
- export interface TimeSeries {
50
- /** Name of the metric. */
51
- name: string;
52
- /** Points contains all the points that composed the series. */
53
- points: TimeSeriesPoint[];
54
- /** Metadata contains some string metadata related to a metric. */
55
- metadata: Record<string, string>;
56
- }
57
- /** Represents a Scaleway file. */
58
- export interface ScwFile {
59
- /** Name of the file. */
60
- name: string;
61
- /** Content-type of the file. */
62
- contentType: string;
63
- /** Content of the file in base64. */
64
- content: string;
65
- }
66
- /** A representation of a decimal value, such as 2.5.
67
- * Comparable to language-native decimal formats, such as Java's BigDecimal or Python's decimal.Decimal.
68
- * Lookup protobuf google.type.Decimal for details */
69
- export declare class Decimal {
70
- private readonly str;
71
- constructor(v: string);
72
- toString: () => string;
73
- marshal: () => object;
74
- }
@@ -1,11 +0,0 @@
1
- class Decimal {
2
- str;
3
- constructor(v) {
4
- this.str = v;
5
- }
6
- toString = () => this.str;
7
- marshal = () => ({ value: this.str });
8
- }
9
- export {
10
- Decimal
11
- };
@@ -1,76 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const invalidRequestMapper = require("./non-standard/invalid-request-mapper.cjs");
4
- const unknownResourceMapper = require("./non-standard/unknown-resource-mapper.cjs");
5
- const scwError = require("./scw-error.cjs");
6
- const alreadyExistsError = require("./standard/already-exists-error.cjs");
7
- const deniedAuthenticationError = require("./standard/denied-authentication-error.cjs");
8
- const invalidArgumentsError = require("./standard/invalid-arguments-error.cjs");
9
- const outOfStockError = require("./standard/out-of-stock-error.cjs");
10
- const permissionsDeniedError = require("./standard/permissions-denied-error.cjs");
11
- const preconditionFailedError = require("./standard/precondition-failed-error.cjs");
12
- const quotasExceededError = require("./standard/quotas-exceeded-error.cjs");
13
- const resourceExpiredError = require("./standard/resource-expired-error.cjs");
14
- const resourceLockedError = require("./standard/resource-locked-error.cjs");
15
- const resourceNotFoundError = require("./standard/resource-not-found-error.cjs");
16
- const tooManyRequestsError = require("./standard/too-many-requests-error.cjs");
17
- const transientStateError = require("./standard/transient-state-error.cjs");
18
- const unmarshalStandardError = (type, status, body) => {
19
- let error;
20
- switch (type) {
21
- case "denied_authentication":
22
- error = deniedAuthenticationError.DeniedAuthenticationError;
23
- break;
24
- case "invalid_arguments":
25
- error = invalidArgumentsError.InvalidArgumentsError;
26
- break;
27
- case "out_of_stock":
28
- error = outOfStockError.OutOfStockError;
29
- break;
30
- case "permissions_denied":
31
- error = permissionsDeniedError.PermissionsDeniedError;
32
- break;
33
- case "precondition_failed":
34
- error = preconditionFailedError.PreconditionFailedError;
35
- break;
36
- case "quotas_exceeded":
37
- error = quotasExceededError.QuotasExceededError;
38
- break;
39
- case "expired":
40
- error = resourceExpiredError.ResourceExpiredError;
41
- break;
42
- case "not_found":
43
- error = resourceNotFoundError.ResourceNotFoundError;
44
- break;
45
- case "locked":
46
- error = resourceLockedError.ResourceLockedError;
47
- break;
48
- case "transient_state":
49
- error = transientStateError.TransientStateError;
50
- break;
51
- case "already_exists":
52
- error = alreadyExistsError.AlreadyExistsError;
53
- break;
54
- case "too_many_requests":
55
- error = tooManyRequestsError.TooManyRequestsError;
56
- break;
57
- default:
58
- return null;
59
- }
60
- return error.fromJSON(status, body);
61
- };
62
- const unmarshalNonStandardError = (type, status, body) => {
63
- switch (type) {
64
- case "unknown_resource":
65
- return unknownResourceMapper.UnknownResourceMapper.fromJSON(status, body);
66
- case "invalid_request_error":
67
- return invalidRequestMapper.InvalidRequestMapper.fromJSON(status, body);
68
- default:
69
- return null;
70
- }
71
- };
72
- const parseScalewayError = (status, body) => {
73
- const parsableError = typeof body.type === "string" && (unmarshalStandardError(body.type, status, body) ?? unmarshalNonStandardError(body.type, status, body));
74
- return parsableError || new scwError.ScalewayError(status, body);
75
- };
76
- exports.parseScalewayError = parseScalewayError;
@@ -1,12 +0,0 @@
1
- import type { JSONObject } from '../../helpers/json.js';
2
- import { ScalewayError } from './scw-error.js';
3
- /**
4
- * Parses Scaleway error from raw body.
5
- *
6
- * @param status - The status code
7
- * @param body - The error response
8
- * @returns The resolved error
9
- *
10
- * @internal
11
- */
12
- export declare const parseScalewayError: (status: number, body: Readonly<JSONObject>) => ScalewayError;
@@ -1,76 +0,0 @@
1
- import { InvalidRequestMapper } from "./non-standard/invalid-request-mapper.js";
2
- import { UnknownResourceMapper } from "./non-standard/unknown-resource-mapper.js";
3
- import { ScalewayError } from "./scw-error.js";
4
- import { AlreadyExistsError } from "./standard/already-exists-error.js";
5
- import { DeniedAuthenticationError } from "./standard/denied-authentication-error.js";
6
- import { InvalidArgumentsError } from "./standard/invalid-arguments-error.js";
7
- import { OutOfStockError } from "./standard/out-of-stock-error.js";
8
- import { PermissionsDeniedError } from "./standard/permissions-denied-error.js";
9
- import { PreconditionFailedError } from "./standard/precondition-failed-error.js";
10
- import { QuotasExceededError } from "./standard/quotas-exceeded-error.js";
11
- import { ResourceExpiredError } from "./standard/resource-expired-error.js";
12
- import { ResourceLockedError } from "./standard/resource-locked-error.js";
13
- import { ResourceNotFoundError } from "./standard/resource-not-found-error.js";
14
- import { TooManyRequestsError } from "./standard/too-many-requests-error.js";
15
- import { TransientStateError } from "./standard/transient-state-error.js";
16
- const unmarshalStandardError = (type, status, body) => {
17
- let error;
18
- switch (type) {
19
- case "denied_authentication":
20
- error = DeniedAuthenticationError;
21
- break;
22
- case "invalid_arguments":
23
- error = InvalidArgumentsError;
24
- break;
25
- case "out_of_stock":
26
- error = OutOfStockError;
27
- break;
28
- case "permissions_denied":
29
- error = PermissionsDeniedError;
30
- break;
31
- case "precondition_failed":
32
- error = PreconditionFailedError;
33
- break;
34
- case "quotas_exceeded":
35
- error = QuotasExceededError;
36
- break;
37
- case "expired":
38
- error = ResourceExpiredError;
39
- break;
40
- case "not_found":
41
- error = ResourceNotFoundError;
42
- break;
43
- case "locked":
44
- error = ResourceLockedError;
45
- break;
46
- case "transient_state":
47
- error = TransientStateError;
48
- break;
49
- case "already_exists":
50
- error = AlreadyExistsError;
51
- break;
52
- case "too_many_requests":
53
- error = TooManyRequestsError;
54
- break;
55
- default:
56
- return null;
57
- }
58
- return error.fromJSON(status, body);
59
- };
60
- const unmarshalNonStandardError = (type, status, body) => {
61
- switch (type) {
62
- case "unknown_resource":
63
- return UnknownResourceMapper.fromJSON(status, body);
64
- case "invalid_request_error":
65
- return InvalidRequestMapper.fromJSON(status, body);
66
- default:
67
- return null;
68
- }
69
- };
70
- const parseScalewayError = (status, body) => {
71
- const parsableError = typeof body.type === "string" && (unmarshalStandardError(body.type, status, body) ?? unmarshalNonStandardError(body.type, status, body));
72
- return parsableError || new ScalewayError(status, body);
73
- };
74
- export {
75
- parseScalewayError
76
- };
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const scwError = require("../scw-error.cjs");
4
- const invalidArgumentsError = require("../standard/invalid-arguments-error.cjs");
5
- const quotasExceededError = require("../standard/quotas-exceeded-error.cjs");
6
- const types = require("../types.cjs");
7
- class InvalidRequestMapper {
8
- static fromJSON(status, obj) {
9
- if (typeof obj.message === "string" && obj.message.toLowerCase().includes("quota exceeded for this resource")) {
10
- return new quotasExceededError.QuotasExceededError(status, obj, [
11
- {
12
- current: 0,
13
- quota: 0,
14
- resource: typeof obj.resource === "string" ? obj.resource : ""
15
- }
16
- ]);
17
- }
18
- const fields = obj.fields && types.isRecordOfStringArray(obj.fields) ? obj.fields : {};
19
- const fieldsMessages = Object.entries(fields);
20
- if (fieldsMessages.length) {
21
- return new invalidArgumentsError.InvalidArgumentsError(
22
- status,
23
- obj,
24
- fieldsMessages.map(
25
- ([argumentName, messages]) => messages.map((helpMessage) => ({
26
- argumentName,
27
- helpMessage,
28
- reason: "constraint"
29
- }))
30
- ).flat()
31
- );
32
- }
33
- return new scwError.ScalewayError(status, obj);
34
- }
35
- }
36
- exports.InvalidRequestMapper = InvalidRequestMapper;
@@ -1,12 +0,0 @@
1
- import type { JSONObject } from '../../../helpers/json.js';
2
- import { ScalewayError } from '../scw-error.js';
3
- import { InvalidArgumentsError } from '../standard/invalid-arguments-error.js';
4
- import { QuotasExceededError } from '../standard/quotas-exceeded-error.js';
5
- /**
6
- * InvalidRequest error is only returned by the instance API.
7
- *
8
- * @public
9
- */
10
- export declare class InvalidRequestMapper {
11
- static fromJSON(status: number, obj: Readonly<JSONObject>): QuotasExceededError | InvalidArgumentsError | ScalewayError;
12
- }
@@ -1,36 +0,0 @@
1
- import { ScalewayError } from "../scw-error.js";
2
- import { InvalidArgumentsError } from "../standard/invalid-arguments-error.js";
3
- import { QuotasExceededError } from "../standard/quotas-exceeded-error.js";
4
- import { isRecordOfStringArray } from "../types.js";
5
- class InvalidRequestMapper {
6
- static fromJSON(status, obj) {
7
- if (typeof obj.message === "string" && obj.message.toLowerCase().includes("quota exceeded for this resource")) {
8
- return new QuotasExceededError(status, obj, [
9
- {
10
- current: 0,
11
- quota: 0,
12
- resource: typeof obj.resource === "string" ? obj.resource : ""
13
- }
14
- ]);
15
- }
16
- const fields = obj.fields && isRecordOfStringArray(obj.fields) ? obj.fields : {};
17
- const fieldsMessages = Object.entries(fields);
18
- if (fieldsMessages.length) {
19
- return new InvalidArgumentsError(
20
- status,
21
- obj,
22
- fieldsMessages.map(
23
- ([argumentName, messages]) => messages.map((helpMessage) => ({
24
- argumentName,
25
- helpMessage,
26
- reason: "constraint"
27
- }))
28
- ).flat()
29
- );
30
- }
31
- return new ScalewayError(status, obj);
32
- }
33
- }
34
- export {
35
- InvalidRequestMapper
36
- };
@@ -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 scwError = require("../scw-error.cjs");
5
- const resourceNotFoundError = require("../standard/resource-not-found-error.cjs");
6
- class UnknownResourceMapper {
7
- static fromJSON(status, obj) {
8
- const messageParts = typeof obj.message === "string" ? obj.message.split(/"|'/) : [];
9
- if (messageParts.length === 3 && stringValidation.isUUID(messageParts[1])) {
10
- return new resourceNotFoundError.ResourceNotFoundError(
11
- status,
12
- obj,
13
- // transform `Security group ` to `security_group`
14
- // `.replaceAll()` may be too recent to use yet.
15
- // that's why we're using `.split(' ').join('_')` for now.
16
- messageParts[0].trim().toLowerCase().split(" ").join("_"),
17
- messageParts[1]
18
- );
19
- }
20
- return new scwError.ScalewayError(status, obj);
21
- }
22
- }
23
- exports.UnknownResourceMapper = UnknownResourceMapper;
@@ -1,11 +0,0 @@
1
- import type { JSONObject } from '../../../helpers/json.js';
2
- import { ScalewayError } from '../scw-error.js';
3
- import { ResourceNotFoundError } from '../standard/resource-not-found-error.js';
4
- /**
5
- * UnknownResource error is only returned by the instance API.
6
- *
7
- * @public
8
- */
9
- export declare class UnknownResourceMapper {
10
- static fromJSON(status: number, obj: Readonly<JSONObject>): ResourceNotFoundError | ScalewayError;
11
- }
@@ -1,23 +0,0 @@
1
- import { isUUID } from "../../../internal/validations/string-validation.js";
2
- import { ScalewayError } from "../scw-error.js";
3
- import { ResourceNotFoundError } from "../standard/resource-not-found-error.js";
4
- class UnknownResourceMapper {
5
- static fromJSON(status, obj) {
6
- const messageParts = typeof obj.message === "string" ? obj.message.split(/"|'/) : [];
7
- if (messageParts.length === 3 && isUUID(messageParts[1])) {
8
- return new ResourceNotFoundError(
9
- status,
10
- obj,
11
- // transform `Security group ` to `security_group`
12
- // `.replaceAll()` may be too recent to use yet.
13
- // that's why we're using `.split(' ').join('_')` for now.
14
- messageParts[0].trim().toLowerCase().split(" ").join("_"),
15
- messageParts[1]
16
- );
17
- }
18
- return new ScalewayError(status, obj);
19
- }
20
- }
21
- export {
22
- UnknownResourceMapper
23
- };
@@ -1,10 +0,0 @@
1
- import type { JSONObject } from '../../helpers/json.js';
2
- import type { ScalewayError } from './scw-error.js';
3
- /**
4
- * Interface with static method that initialize {@link ScalewayError} from JSON.
5
- *
6
- * @internal
7
- */
8
- export interface ScalewayErrorFromJSONInitializer {
9
- fromJSON(status: number, obj: Readonly<JSONObject>): ScalewayError | null;
10
- }
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const json = require("../../helpers/json.cjs");
4
- const types = require("./types.cjs");
5
- const buildDefaultMessage = (status, body) => {
6
- const message = [`http error ${status}`];
7
- if (typeof body === "string") {
8
- message.push(body);
9
- } else if (json.isJSONObject(body)) {
10
- if (typeof body.resource === "string") {
11
- message.push(`resource ${body.resource}`);
12
- }
13
- if (typeof body.message === "string") {
14
- message.push(body.message);
15
- }
16
- if (body.fields && types.isRecordOfStringArray(body.fields)) {
17
- message.push(
18
- Object.entries(body.fields).map(([name, list]) => `${name} (${list.join(", ")})`).join(", ")
19
- );
20
- }
21
- }
22
- return message.join(": ");
23
- };
24
- class ScalewayError extends Error {
25
- constructor(status, body, message = buildDefaultMessage(status, body)) {
26
- super(message);
27
- this.status = status;
28
- this.body = body;
29
- this.message = message;
30
- this.name = "ScalewayError";
31
- this.rawMessage = typeof body === "object" && typeof body.message === "string" ? body.message : void 0;
32
- Object.setPrototypeOf(this, new.target.prototype);
33
- }
34
- /** The message originating from the payload. */
35
- rawMessage;
36
- static fromJSON(status, obj) {
37
- return new ScalewayError(status, obj);
38
- }
39
- toString() {
40
- return `${this.name}: ${this.message}`;
41
- }
42
- }
43
- exports.ScalewayError = ScalewayError;
@@ -1,25 +0,0 @@
1
- import type { JSONObject } from '../../helpers/json.js';
2
- /**
3
- * Scaleway error.
4
- *
5
- * @public
6
- */
7
- export declare class ScalewayError extends Error {
8
- /** The response status. */
9
- readonly status: number;
10
- /** The response payload. */
11
- readonly body: JSONObject | string;
12
- /** The augmented message. */
13
- readonly message: string;
14
- /** The message originating from the payload. */
15
- rawMessage: string | undefined;
16
- constructor(
17
- /** The response status. */
18
- status: number,
19
- /** The response payload. */
20
- body: JSONObject | string,
21
- /** The augmented message. */
22
- message?: string);
23
- static fromJSON(status: number, obj: Readonly<JSONObject>): ScalewayError | null;
24
- toString(): string;
25
- }
@@ -1,43 +0,0 @@
1
- import { isJSONObject } from "../../helpers/json.js";
2
- import { isRecordOfStringArray } from "./types.js";
3
- const buildDefaultMessage = (status, body) => {
4
- const message = [`http error ${status}`];
5
- if (typeof body === "string") {
6
- message.push(body);
7
- } else if (isJSONObject(body)) {
8
- if (typeof body.resource === "string") {
9
- message.push(`resource ${body.resource}`);
10
- }
11
- if (typeof body.message === "string") {
12
- message.push(body.message);
13
- }
14
- if (body.fields && isRecordOfStringArray(body.fields)) {
15
- message.push(
16
- Object.entries(body.fields).map(([name, list]) => `${name} (${list.join(", ")})`).join(", ")
17
- );
18
- }
19
- }
20
- return message.join(": ");
21
- };
22
- class ScalewayError extends Error {
23
- constructor(status, body, message = buildDefaultMessage(status, body)) {
24
- super(message);
25
- this.status = status;
26
- this.body = body;
27
- this.message = message;
28
- this.name = "ScalewayError";
29
- this.rawMessage = typeof body === "object" && typeof body.message === "string" ? body.message : void 0;
30
- Object.setPrototypeOf(this, new.target.prototype);
31
- }
32
- /** The message originating from the payload. */
33
- rawMessage;
34
- static fromJSON(status, obj) {
35
- return new ScalewayError(status, obj);
36
- }
37
- toString() {
38
- return `${this.name}: ${this.message}`;
39
- }
40
- }
41
- export {
42
- ScalewayError
43
- };
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const scwError = require("../scw-error.cjs");
4
- class AlreadyExistsError extends scwError.ScalewayError {
5
- constructor(status, body, resource, resourceId, helpMessage) {
6
- super(
7
- status,
8
- body,
9
- `resource ${resource} with ID ${resourceId} already exists: ${helpMessage}`
10
- );
11
- this.status = status;
12
- this.body = body;
13
- this.resource = resource;
14
- this.resourceId = resourceId;
15
- this.helpMessage = helpMessage;
16
- this.name = "AlreadyExistsError";
17
- }
18
- static fromJSON(status, obj) {
19
- if (typeof obj.resource !== "string" || typeof obj.resource_id !== "string" || typeof obj.help_message !== "string") {
20
- return null;
21
- }
22
- return new AlreadyExistsError(
23
- status,
24
- obj,
25
- obj.resource,
26
- obj.resource_id,
27
- obj.help_message
28
- );
29
- }
30
- }
31
- exports.AlreadyExistsError = AlreadyExistsError;
@@ -1,16 +0,0 @@
1
- import type { JSONObject } from '../../../helpers/json.js';
2
- import { ScalewayError } from '../scw-error.js';
3
- /**
4
- * AlreadyExists error is used when a resource already exists.
5
- *
6
- * @public
7
- */
8
- export declare class AlreadyExistsError extends ScalewayError {
9
- readonly status: number;
10
- readonly body: JSONObject;
11
- readonly resource: string;
12
- readonly resourceId: string;
13
- readonly helpMessage: string;
14
- constructor(status: number, body: JSONObject, resource: string, resourceId: string, helpMessage: string);
15
- static fromJSON(status: number, obj: Readonly<JSONObject>): AlreadyExistsError | null;
16
- }
@@ -1,31 +0,0 @@
1
- import { ScalewayError } from "../scw-error.js";
2
- class AlreadyExistsError extends ScalewayError {
3
- constructor(status, body, resource, resourceId, helpMessage) {
4
- super(
5
- status,
6
- body,
7
- `resource ${resource} with ID ${resourceId} already exists: ${helpMessage}`
8
- );
9
- this.status = status;
10
- this.body = body;
11
- this.resource = resource;
12
- this.resourceId = resourceId;
13
- this.helpMessage = helpMessage;
14
- this.name = "AlreadyExistsError";
15
- }
16
- static fromJSON(status, obj) {
17
- if (typeof obj.resource !== "string" || typeof obj.resource_id !== "string" || typeof obj.help_message !== "string") {
18
- return null;
19
- }
20
- return new AlreadyExistsError(
21
- status,
22
- obj,
23
- obj.resource,
24
- obj.resource_id,
25
- obj.help_message
26
- );
27
- }
28
- }
29
- export {
30
- AlreadyExistsError
31
- };
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const scwError = require("../scw-error.cjs");
4
- const buildMessage = (method, reason) => {
5
- let reasonDesc;
6
- switch (reason) {
7
- case "invalid_argument":
8
- reasonDesc = `invalid ${method} format or empty value`;
9
- break;
10
- case "not_found":
11
- reasonDesc = `${method} does not exist`;
12
- break;
13
- case "expired":
14
- reasonDesc = `${method} is expired`;
15
- break;
16
- default:
17
- reasonDesc = `unknown reason for ${method}`;
18
- }
19
- return `denied authentication: ${reasonDesc}`;
20
- };
21
- class DeniedAuthenticationError extends scwError.ScalewayError {
22
- constructor(status, body, method, reason) {
23
- super(status, body, buildMessage(method, reason));
24
- this.status = status;
25
- this.body = body;
26
- this.method = method;
27
- this.reason = reason;
28
- this.name = "DeniedAuthenticationError";
29
- }
30
- static fromJSON(status, obj) {
31
- if (typeof obj.method !== "string" || typeof obj.reason !== "string") {
32
- return null;
33
- }
34
- return new DeniedAuthenticationError(status, obj, obj.method, obj.reason);
35
- }
36
- }
37
- exports.DeniedAuthenticationError = DeniedAuthenticationError;
@@ -1,15 +0,0 @@
1
- import type { JSONObject } from '../../../helpers/json.js';
2
- import { ScalewayError } from '../scw-error.js';
3
- /**
4
- * DeniedAuthentication error is used by the API Gateway auth service to deny a request.
5
- *
6
- * @public
7
- */
8
- export declare class DeniedAuthenticationError extends ScalewayError {
9
- readonly status: number;
10
- readonly body: JSONObject;
11
- readonly method: string;
12
- readonly reason: string;
13
- constructor(status: number, body: JSONObject, method: string, reason: string);
14
- static fromJSON(status: number, obj: Readonly<JSONObject>): DeniedAuthenticationError | null;
15
- }