@scaleway/sdk 3.0.0-alpha.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/dist/index.gen.d.ts +362 -0
  2. package/dist/index.gen.js +323 -0
  3. package/package.json +71 -25
  4. package/README.md +0 -46
  5. package/dist/api/account/index.js +0 -4
  6. package/dist/api/account/v2/api.gen.js +0 -147
  7. package/dist/api/account/v2/index.gen.js +0 -4
  8. package/dist/api/account/v2/marshalling.gen.js +0 -39
  9. package/dist/api/account/v3/api.gen.js +0 -129
  10. package/dist/api/account/v3/index.gen.js +0 -6
  11. package/dist/api/account/v3/marshalling.gen.js +0 -39
  12. package/dist/api/account/v3/validation-rules.gen.js +0 -39
  13. package/dist/api/applesilicon/index.js +0 -2
  14. package/dist/api/applesilicon/v1alpha1/api.gen.js +0 -220
  15. package/dist/api/applesilicon/v1alpha1/content.gen.js +0 -7
  16. package/dist/api/applesilicon/v1alpha1/index.gen.js +0 -5
  17. package/dist/api/applesilicon/v1alpha1/marshalling.gen.js +0 -113
  18. package/dist/api/baremetal/index.js +0 -2
  19. package/dist/api/baremetal/v1/api.gen.js +0 -523
  20. package/dist/api/baremetal/v1/api.utils.js +0 -27
  21. package/dist/api/baremetal/v1/content.gen.js +0 -13
  22. package/dist/api/baremetal/v1/index.js +0 -5
  23. package/dist/api/baremetal/v1/marshalling.gen.js +0 -395
  24. package/dist/api/baremetal/v1/validation-rules.gen.js +0 -109
  25. package/dist/api/billing/index.js +0 -2
  26. package/dist/api/billing/v2alpha1/api.gen.js +0 -80
  27. package/dist/api/billing/v2alpha1/index.gen.js +0 -4
  28. package/dist/api/billing/v2alpha1/marshalling.gen.js +0 -53
  29. package/dist/api/block/index.js +0 -2
  30. package/dist/api/block/v1alpha1/api.gen.js +0 -245
  31. package/dist/api/block/v1alpha1/content.gen.js +0 -13
  32. package/dist/api/block/v1alpha1/index.gen.js +0 -7
  33. package/dist/api/block/v1alpha1/marshalling.gen.js +0 -175
  34. package/dist/api/block/v1alpha1/validation-rules.gen.js +0 -42
  35. package/dist/api/cockpit/index.js +0 -2
  36. package/dist/api/cockpit/v1beta1/api.gen.js +0 -448
  37. package/dist/api/cockpit/v1beta1/content.gen.js +0 -7
  38. package/dist/api/cockpit/v1beta1/index.gen.js +0 -5
  39. package/dist/api/cockpit/v1beta1/marshalling.gen.js +0 -220
  40. package/dist/api/container/index.js +0 -2
  41. package/dist/api/container/v1beta1/api.gen.js +0 -549
  42. package/dist/api/container/v1beta1/content.gen.js +0 -22
  43. package/dist/api/container/v1beta1/index.gen.js +0 -5
  44. package/dist/api/container/v1beta1/marshalling.gen.js +0 -330
  45. package/dist/api/document_db/index.js +0 -2
  46. package/dist/api/document_db/v1beta1/api.gen.js +0 -830
  47. package/dist/api/document_db/v1beta1/content.gen.js +0 -19
  48. package/dist/api/document_db/v1beta1/index.gen.js +0 -7
  49. package/dist/api/document_db/v1beta1/marshalling.gen.js +0 -580
  50. package/dist/api/document_db/v1beta1/validation-rules.gen.js +0 -10
  51. package/dist/api/domain/index.js +0 -2
  52. package/dist/api/domain/v2beta1/api.gen.js +0 -875
  53. package/dist/api/domain/v2beta1/content.gen.js +0 -28
  54. package/dist/api/domain/v2beta1/index.gen.js +0 -7
  55. package/dist/api/domain/v2beta1/marshalling.gen.js +0 -958
  56. package/dist/api/flexibleip/index.js +0 -2
  57. package/dist/api/flexibleip/v1alpha1/api.gen.js +0 -203
  58. package/dist/api/flexibleip/v1alpha1/content.gen.js +0 -10
  59. package/dist/api/flexibleip/v1alpha1/index.gen.js +0 -7
  60. package/dist/api/flexibleip/v1alpha1/marshalling.gen.js +0 -97
  61. package/dist/api/flexibleip/v1alpha1/validation-rules.gen.js +0 -14
  62. package/dist/api/function/index.js +0 -2
  63. package/dist/api/function/v1beta1/api.gen.js +0 -560
  64. package/dist/api/function/v1beta1/content.gen.js +0 -22
  65. package/dist/api/function/v1beta1/index.gen.js +0 -5
  66. package/dist/api/function/v1beta1/marshalling.gen.js +0 -368
  67. package/dist/api/iam/index.js +0 -2
  68. package/dist/api/iam/v1alpha1/api.gen.js +0 -799
  69. package/dist/api/iam/v1alpha1/index.gen.js +0 -6
  70. package/dist/api/iam/v1alpha1/marshalling.gen.js +0 -373
  71. package/dist/api/iam/v1alpha1/validation-rules.gen.js +0 -207
  72. package/dist/api/instance/index.js +0 -2
  73. package/dist/api/instance/v1/api.gen.js +0 -1003
  74. package/dist/api/instance/v1/api.utils.js +0 -369
  75. package/dist/api/instance/v1/content.gen.js +0 -31
  76. package/dist/api/instance/v1/index.js +0 -2
  77. package/dist/api/instance/v1/marshalling.gen.js +0 -1206
  78. package/dist/api/instance/v1/marshalling.utils.js +0 -63
  79. package/dist/api/iot/index.js +0 -2
  80. package/dist/api/iot/v1/api.gen.js +0 -581
  81. package/dist/api/iot/v1/content.gen.js +0 -7
  82. package/dist/api/iot/v1/index.gen.js +0 -5
  83. package/dist/api/iot/v1/marshalling.gen.js +0 -388
  84. package/dist/api/ipfs/index.js +0 -2
  85. package/dist/api/ipfs/v1alpha1/api.gen.js +0 -197
  86. package/dist/api/ipfs/v1alpha1/content.gen.js +0 -7
  87. package/dist/api/ipfs/v1alpha1/index.gen.js +0 -5
  88. package/dist/api/ipfs/v1alpha1/marshalling.gen.js +0 -121
  89. package/dist/api/k8s/index.js +0 -2
  90. package/dist/api/k8s/v1/api.gen.js +0 -454
  91. package/dist/api/k8s/v1/api.utils.js +0 -13
  92. package/dist/api/k8s/v1/content.gen.js +0 -13
  93. package/dist/api/k8s/v1/index.js +0 -4
  94. package/dist/api/k8s/v1/marshalling.gen.js +0 -333
  95. package/dist/api/k8s/v1/validation-rules.gen.js +0 -101
  96. package/dist/api/lb/index.js +0 -2
  97. package/dist/api/lb/v1/api.gen.js +0 -1669
  98. package/dist/api/lb/v1/api.utils.js +0 -81
  99. package/dist/api/lb/v1/content.gen.js +0 -16
  100. package/dist/api/lb/v1/index.js +0 -2
  101. package/dist/api/lb/v1/marshalling.gen.js +0 -923
  102. package/dist/api/marketplace/index.js +0 -4
  103. package/dist/api/marketplace/v1/api.gen.js +0 -60
  104. package/dist/api/marketplace/v1/index.gen.js +0 -4
  105. package/dist/api/marketplace/v1/marshalling.gen.js +0 -92
  106. package/dist/api/marketplace/v2/api.gen.js +0 -162
  107. package/dist/api/marketplace/v2/index.gen.js +0 -4
  108. package/dist/api/marketplace/v2/marshalling.gen.js +0 -94
  109. package/dist/api/mnq/index.js +0 -2
  110. package/dist/api/mnq/v1alpha1/api.gen.js +0 -205
  111. package/dist/api/mnq/v1alpha1/index.gen.js +0 -4
  112. package/dist/api/mnq/v1alpha1/marshalling.gen.js +0 -121
  113. package/dist/api/rdb/index.js +0 -2
  114. package/dist/api/rdb/v1/api.gen.js +0 -972
  115. package/dist/api/rdb/v1/content.gen.js +0 -22
  116. package/dist/api/rdb/v1/index.gen.js +0 -7
  117. package/dist/api/rdb/v1/marshalling.gen.js +0 -636
  118. package/dist/api/rdb/v1/validation-rules.gen.js +0 -10
  119. package/dist/api/redis/index.js +0 -2
  120. package/dist/api/redis/v1/api.gen.js +0 -389
  121. package/dist/api/redis/v1/content.gen.js +0 -7
  122. package/dist/api/redis/v1/index.gen.js +0 -5
  123. package/dist/api/redis/v1/marshalling.gen.js +0 -259
  124. package/dist/api/registry/index.js +0 -2
  125. package/dist/api/registry/v1/api.gen.js +0 -252
  126. package/dist/api/registry/v1/content.gen.js +0 -13
  127. package/dist/api/registry/v1/index.gen.js +0 -5
  128. package/dist/api/registry/v1/marshalling.gen.js +0 -106
  129. package/dist/api/secret/index.js +0 -2
  130. package/dist/api/secret/v1alpha1/api.gen.js +0 -415
  131. package/dist/api/secret/v1alpha1/index.gen.js +0 -4
  132. package/dist/api/secret/v1alpha1/marshalling.gen.js +0 -143
  133. package/dist/api/tem/index.js +0 -2
  134. package/dist/api/tem/v1alpha1/api.gen.js +0 -229
  135. package/dist/api/tem/v1alpha1/content.gen.js +0 -10
  136. package/dist/api/tem/v1alpha1/index.gen.js +0 -5
  137. package/dist/api/tem/v1alpha1/marshalling.gen.js +0 -159
  138. package/dist/api/test/index.js +0 -2
  139. package/dist/api/test/v1/api.gen.js +0 -152
  140. package/dist/api/test/v1/content.gen.js +0 -7
  141. package/dist/api/test/v1/index.gen.js +0 -5
  142. package/dist/api/test/v1/marshalling.gen.js +0 -79
  143. package/dist/api/vpc/index.js +0 -4
  144. package/dist/api/vpc/v1/api.gen.js +0 -110
  145. package/dist/api/vpc/v1/index.gen.js +0 -4
  146. package/dist/api/vpc/v1/marshalling.gen.js +0 -44
  147. package/dist/api/vpc/v2/api.gen.js +0 -276
  148. package/dist/api/vpc/v2/index.gen.js +0 -4
  149. package/dist/api/vpc/v2/marshalling.gen.js +0 -135
  150. package/dist/api/vpcgw/index.js +0 -2
  151. package/dist/api/vpcgw/v1/api.gen.js +0 -669
  152. package/dist/api/vpcgw/v1/content.gen.js +0 -10
  153. package/dist/api/vpcgw/v1/index.gen.js +0 -5
  154. package/dist/api/vpcgw/v1/marshalling.gen.js +0 -336
  155. package/dist/api/webhosting/index.js +0 -2
  156. package/dist/api/webhosting/v1alpha1/api.gen.js +0 -210
  157. package/dist/api/webhosting/v1alpha1/content.gen.js +0 -7
  158. package/dist/api/webhosting/v1alpha1/index.gen.js +0 -7
  159. package/dist/api/webhosting/v1alpha1/marshalling.gen.js +0 -173
  160. package/dist/api/webhosting/v1alpha1/validation-rules.gen.js +0 -23
  161. package/dist/helpers/is-browser.js +0 -5
  162. package/dist/helpers/is-response.js +0 -10
  163. package/dist/helpers/json.js +0 -11
  164. package/dist/helpers/marshalling.js +0 -130
  165. package/dist/index.cjs +0 -24364
  166. package/dist/index.d.ts +0 -27584
  167. package/dist/index.js +0 -69
  168. package/dist/internal/async/interval-retrier.js +0 -105
  169. package/dist/internal/async/sleep.js +0 -13
  170. package/dist/internal/interceptors/composer.js +0 -46
  171. package/dist/internal/interceptors/helpers.js +0 -32
  172. package/dist/internal/logger/console-logger.js +0 -38
  173. package/dist/internal/logger/index.js +0 -41
  174. package/dist/internal/logger/level-resolver.js +0 -13
  175. package/dist/internal/validations/string-validation.js +0 -38
  176. package/dist/node_modules/.pnpm/@scaleway_random-name@4.0.2/node_modules/@scaleway/random-name/dist/index.js +0 -13
  177. package/dist/scw/api.js +0 -12
  178. package/dist/scw/auth.js +0 -68
  179. package/dist/scw/client-ini-factory.js +0 -174
  180. package/dist/scw/client-ini-profile.js +0 -54
  181. package/dist/scw/client-settings.js +0 -78
  182. package/dist/scw/client.js +0 -98
  183. package/dist/scw/constants.js +0 -4
  184. package/dist/scw/custom-marshalling.js +0 -131
  185. package/dist/scw/errors/error-parser.js +0 -107
  186. package/dist/scw/errors/non-standard/invalid-request-mapper.js +0 -36
  187. package/dist/scw/errors/non-standard/unknown-resource-mapper.js +0 -27
  188. package/dist/scw/errors/scw-error.js +0 -66
  189. package/dist/scw/errors/standard/already-exists-error.js +0 -26
  190. package/dist/scw/errors/standard/denied-authentication-error.js +0 -52
  191. package/dist/scw/errors/standard/index.js +0 -13
  192. package/dist/scw/errors/standard/invalid-arguments-error.js +0 -67
  193. package/dist/scw/errors/standard/out-of-stock-error.js +0 -22
  194. package/dist/scw/errors/standard/permissions-denied-error.js +0 -48
  195. package/dist/scw/errors/standard/precondition-failed-error.js +0 -42
  196. package/dist/scw/errors/standard/quotas-exceeded-error.js +0 -68
  197. package/dist/scw/errors/standard/resource-expired-error.js +0 -26
  198. package/dist/scw/errors/standard/resource-locked-error.js +0 -25
  199. package/dist/scw/errors/standard/resource-not-found-error.js +0 -25
  200. package/dist/scw/errors/standard/too-many-requests-error.js +0 -70
  201. package/dist/scw/errors/standard/transient-state-error.js +0 -26
  202. package/dist/scw/errors/types.js +0 -23
  203. package/dist/scw/fetch/build-fetcher.js +0 -72
  204. package/dist/scw/fetch/http-dumper.js +0 -54
  205. package/dist/scw/fetch/http-interceptors.js +0 -99
  206. package/dist/scw/fetch/resource-paginator.js +0 -84
  207. package/dist/scw/fetch/response-parser.js +0 -72
  208. package/node_modules/@scaleway/random-name/.npmignore +0 -4
  209. package/node_modules/@scaleway/random-name/CHANGELOG.md +0 -129
  210. package/node_modules/@scaleway/random-name/LICENSE.md +0 -21
  211. package/node_modules/@scaleway/random-name/README.md +0 -26
  212. package/node_modules/@scaleway/random-name/dist/index.d.ts +0 -3
  213. package/node_modules/@scaleway/random-name/dist/index.js +0 -13
  214. package/node_modules/@scaleway/random-name/package.json +0 -23
package/dist/index.js DELETED
@@ -1,69 +0,0 @@
1
- export { enableConsoleLogger, setLogger } from './internal/logger/index.js';
2
- export { createAdvancedClient, createClient } from './scw/client.js';
3
- export { withAdditionalInterceptors, withDefaultPageSize, withHTTPClient, withProfile, withUserAgent, withUserAgentSuffix } from './scw/client-ini-factory.js';
4
- import * as index from './scw/errors/standard/index.js';
5
- export { index as Errors };
6
- export { isJSONObject } from './helpers/json.js';
7
- export { waitForResource } from './internal/async/interval-retrier.js';
8
- export { addAsyncHeaderInterceptor } from './internal/interceptors/helpers.js';
9
- export { API } from './scw/api.js';
10
- export { authenticateWithSessionToken } from './scw/auth.js';
11
- export { marshalMoney, marshalScwFile, marshalTimeSeries, unmarshalMoney, unmarshalScwFile, unmarshalServiceInfo, unmarshalTimeSeries, unmarshalTimeSeriesPoint } from './scw/custom-marshalling.js';
12
- export { resolveOneOf, unmarshalArrayOfObject, unmarshalDate, unmarshalMapOfObject, urlParams, validatePathParam } from './helpers/marshalling.js';
13
- export { enrichForPagination } from './scw/fetch/resource-paginator.js';
14
- import * as index$1 from './api/account/index.js';
15
- export { index$1 as Account };
16
- import * as index$2 from './api/applesilicon/index.js';
17
- export { index$2 as AppleSilicon };
18
- import * as index$3 from './api/baremetal/index.js';
19
- export { index$3 as BareMetal };
20
- import * as index$4 from './api/billing/index.js';
21
- export { index$4 as Billing };
22
- import * as index$5 from './api/block/index.js';
23
- export { index$5 as Block };
24
- import * as index$6 from './api/cockpit/index.js';
25
- export { index$6 as Cockpit };
26
- import * as index$7 from './api/container/index.js';
27
- export { index$7 as Container };
28
- import * as index$8 from './api/document_db/index.js';
29
- export { index$8 as DocumentDB };
30
- import * as index$9 from './api/domain/index.js';
31
- export { index$9 as Domain };
32
- import * as index$a from './api/flexibleip/index.js';
33
- export { index$a as FlexibleIP };
34
- import * as index$b from './api/function/index.js';
35
- export { index$b as Function };
36
- import * as index$c from './api/iam/index.js';
37
- export { index$c as IAM };
38
- import * as index$d from './api/instance/index.js';
39
- export { index$d as Instance };
40
- import * as index$e from './api/iot/index.js';
41
- export { index$e as IOT };
42
- import * as index$f from './api/ipfs/index.js';
43
- export { index$f as IPFS };
44
- import * as index$g from './api/k8s/index.js';
45
- export { index$g as K8S };
46
- import * as index$h from './api/lb/index.js';
47
- export { index$h as LB };
48
- import * as index$i from './api/marketplace/index.js';
49
- export { index$i as Marketplace };
50
- import * as index$j from './api/mnq/index.js';
51
- export { index$j as MNQ };
52
- import * as index$k from './api/rdb/index.js';
53
- export { index$k as RDB };
54
- import * as index$l from './api/redis/index.js';
55
- export { index$l as Redis };
56
- import * as index$m from './api/registry/index.js';
57
- export { index$m as Registry };
58
- import * as index$n from './api/secret/index.js';
59
- export { index$n as Secret };
60
- import * as index$o from './api/test/index.js';
61
- export { index$o as Test };
62
- import * as index$p from './api/tem/index.js';
63
- export { index$p as TransactionalEmail };
64
- import * as index$q from './api/vpc/index.js';
65
- export { index$q as VPC };
66
- import * as index$r from './api/vpcgw/index.js';
67
- export { index$r as VPCGW };
68
- import * as index$s from './api/webhosting/index.js';
69
- export { index$s as Webhosting };
@@ -1,105 +0,0 @@
1
- import { sleep } from './sleep.js';
2
-
3
- const DEFAULT_TIMEOUT_SECONDS = 300;
4
- const DEFAULT_MIN_DELAY_SECONDS = 1;
5
- const DEFAULT_MAX_DELAY_SECONDS = 30;
6
-
7
- /**
8
- * Creates an exponential backoff interval strategy.
9
- *
10
- * @param minDelay - The minimum delay before the next try in seconds
11
- * @param maxDelay - The maximum delay before the next try in seconds
12
- * @returns An exponential backoff generator
13
- *
14
- * @internal
15
- */
16
- function* createExponentialBackoffStrategy(minDelay, maxDelay) {
17
- if (minDelay < 1 || maxDelay < 1 || minDelay > maxDelay) {
18
- throw new Error('Waiter: minDelay must be >= 1 and maxDelay must be >= minDelay');
19
- }
20
- let attempt = 1;
21
- const ceiling = Math.log(maxDelay / minDelay) / Math.log(2) + 1;
22
- const randomInRange = (min, max) => min + Math.random() * (max - min);
23
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
24
- while (true) {
25
- if (attempt > ceiling) {
26
- yield maxDelay;
27
- } else {
28
- yield randomInRange(minDelay, minDelay * 2 ** (attempt - 1));
29
- }
30
- attempt += 1;
31
- }
32
- }
33
-
34
- /**
35
- * Tries a specific logic several times until it succeeds, timeouts, or throws an exception.
36
- *
37
- * @param retry - The function to retry logic between each interval
38
- * @param strategy - A generated interval strategy iterator
39
- * @param timeout - The maximum time elapsed before timeout error
40
- *
41
- * @throws An timeout exception or error thrown by the logic being run
42
- *
43
- * @internal
44
- */
45
- const tryAtIntervals = async function (retry, strategy, timeout) {
46
- if (timeout === void 0) {
47
- timeout = DEFAULT_TIMEOUT_SECONDS;
48
- }
49
- const timeoutTimestamp = Date.now() + timeout * 1000;
50
- let retryCount = 0;
51
- while (Date.now() <= timeoutTimestamp) {
52
- const delay = strategy.next(retryCount += 1).value * 1000;
53
- // Break if timeout has been reached
54
- if (timeoutTimestamp <= Date.now() + delay) break;
55
- // Wait before the next retry
56
- await sleep(delay);
57
- // Retry
58
- const {
59
- value,
60
- done
61
- } = await retry();
62
- if (done) return value;
63
- }
64
- throw new Error(`Timeout after ${timeout}s`);
65
- };
66
-
67
- /**
68
- * Represents the condition to stop waiting for a resource.
69
- *
70
- * @public
71
- */
72
-
73
- /**
74
- * The options to wait until a resource is ready.
75
- *
76
- * @public
77
- */
78
-
79
- /**
80
- * Fetches resource several times until an expected condition is reached, timeouts, or throws an exception.
81
- *
82
- * @param stop - The condition to stop waiting
83
- * @param fetcher - The method to retrieve resource
84
- * @param request - The resource request options
85
- * @param options - The retry strategy options
86
- * @param strategy - An optional custom strategy
87
- *
88
- * @returns A promise of resource
89
- *
90
- * @public
91
- */
92
- const waitForResource = function (stop, fetcher, request, options, strategy) {
93
- if (strategy === void 0) {
94
- strategy = createExponentialBackoffStrategy(options?.minDelay ?? DEFAULT_MIN_DELAY_SECONDS, options?.maxDelay ?? DEFAULT_MAX_DELAY_SECONDS);
95
- }
96
- return tryAtIntervals(async () => {
97
- const value = await fetcher(request);
98
- return {
99
- done: await stop(value),
100
- value
101
- };
102
- }, strategy, options?.timeout);
103
- };
104
-
105
- export { createExponentialBackoffStrategy, tryAtIntervals, waitForResource };
@@ -1,13 +0,0 @@
1
- /**
2
- * Sleep for a specified number of time.
3
- *
4
- * @param ms - The number of milliseconds
5
- * @returns The sleep promise
6
- *
7
- * @internal
8
- */
9
- const sleep = ms => new Promise(resolve => {
10
- setTimeout(resolve, ms);
11
- });
12
-
13
- export { sleep };
@@ -1,46 +0,0 @@
1
- /**
2
- * Composes request interceptors.
3
- *
4
- * @param interceptors - A list of request interceptors
5
- * @returns An async composed interceptor
6
- *
7
- * @internal
8
- */
9
- const composeRequestInterceptors = interceptors => async request => interceptors.reduce(async (asyncResult, interceptor) => interceptor({
10
- request: await asyncResult
11
- }), Promise.resolve(request));
12
-
13
- /**
14
- * Composes response interceptors.
15
- *
16
- * @param interceptors - A list of response interceptors
17
- * @returns An async composed interceptor
18
- *
19
- * @internal
20
- */
21
- const composeResponseInterceptors = interceptors => async response => interceptors.reduce(async (asyncResult, interceptor) => interceptor({
22
- response: await asyncResult
23
- }), Promise.resolve(response));
24
-
25
- /**
26
- * Compose response error interceptors.
27
- *
28
- * @internal
29
- */
30
- const composeResponseErrorInterceptors = interceptors => async (request, error) => {
31
- let prevError = error;
32
- for (const interceptor of interceptors) {
33
- try {
34
- const res = await interceptor({
35
- request,
36
- error: prevError
37
- });
38
- return res;
39
- } catch (err) {
40
- prevError = err;
41
- }
42
- }
43
- throw prevError;
44
- };
45
-
46
- export { composeRequestInterceptors, composeResponseErrorInterceptors, composeResponseInterceptors };
@@ -1,32 +0,0 @@
1
- /**
2
- * Adds an header to a request through an interceptor.
3
- *
4
- * @param key - The header key
5
- * @param value - The header value
6
- * @returns The Request interceptor
7
- *
8
- * @internal
9
- */
10
- const addHeaderInterceptor = (key, value) => _ref => {
11
- let {
12
- request
13
- } = _ref;
14
- const clone = request.clone();
15
- if (value !== undefined) {
16
- clone.headers.append(key, value);
17
- }
18
- return clone;
19
- };
20
-
21
- /**
22
- * Adds asynchronously an header to a request through an interceptor.
23
- *
24
- * @param key - The header key
25
- * @param value - The header value as a Promise
26
- * @returns The Request interceptor
27
- *
28
- * @internal
29
- */
30
- const addAsyncHeaderInterceptor = (key, getter) => async request => addHeaderInterceptor(key, await getter())(request);
31
-
32
- export { addAsyncHeaderInterceptor, addHeaderInterceptor };
@@ -1,38 +0,0 @@
1
- import { LevelResolver, shouldLog } from './level-resolver.js';
2
-
3
- /**
4
- * A Logger using console output.
5
- *
6
- * @param logLevel - The logger level name
7
- * @param prefix - An optional logger message prefix
8
- * @param output - The output to print logs, using by default the global console object
9
- *
10
- * @internal
11
- */
12
- class ConsoleLogger {
13
- constructor(logLevel, prefix, output) {
14
- if (prefix === void 0) {
15
- prefix = '';
16
- }
17
- if (output === void 0) {
18
- output = console;
19
- }
20
- this.logLevel = logLevel;
21
- this.prefix = prefix;
22
- this.output = output;
23
- this.level = LevelResolver[this.logLevel];
24
- }
25
- makeMethod(method) {
26
- return message => {
27
- if (shouldLog(this.level, method)) {
28
- this.output[method](this.prefix ? `${this.prefix} ${message}` : message);
29
- }
30
- };
31
- }
32
- debug = this.makeMethod('debug');
33
- error = this.makeMethod('error');
34
- info = this.makeMethod('info');
35
- warn = this.makeMethod('warn');
36
- }
37
-
38
- export { ConsoleLogger };
@@ -1,41 +0,0 @@
1
- import { ConsoleLogger } from './console-logger.js';
2
-
3
- let sdkLogger = /*#__PURE__*/new ConsoleLogger('silent');
4
-
5
- /**
6
- * Sets a logger to be used within the SDK.
7
- *
8
- * @param logger - The Logger instance
9
- *
10
- * @public
11
- */
12
- const setLogger = logger => {
13
- sdkLogger = logger;
14
- };
15
-
16
- /**
17
- * Sets the logger to console logger with given logLevel (log is disabled by default).
18
- *
19
- * @param logLevel - The Log level (default to 'warn')
20
- * @param prefix - A Log message prefix (default to 'scaleway-sdk-js:')
21
- *
22
- * @public
23
- */
24
- const enableConsoleLogger = function (logLevel, prefix) {
25
- if (logLevel === void 0) {
26
- logLevel = 'warn';
27
- }
28
- if (prefix === void 0) {
29
- prefix = 'scaleway-sdk-js:';
30
- }
31
- return setLogger(new ConsoleLogger(logLevel, prefix));
32
- };
33
-
34
- /**
35
- * Returns the active SDK logger.
36
- *
37
- * @internal
38
- */
39
- const getLogger = () => sdkLogger;
40
-
41
- export { enableConsoleLogger, getLogger, setLogger };
@@ -1,13 +0,0 @@
1
- // eslint-disable-next-line eslint-comments/disable-enable-pair
2
- /* eslint-disable @typescript-eslint/naming-convention */
3
- let LevelResolver = /*#__PURE__*/function (LevelResolver) {
4
- LevelResolver[LevelResolver["silent"] = 0] = "silent";
5
- LevelResolver[LevelResolver["error"] = 1] = "error";
6
- LevelResolver[LevelResolver["warn"] = 2] = "warn";
7
- LevelResolver[LevelResolver["info"] = 3] = "info";
8
- LevelResolver[LevelResolver["debug"] = 4] = "debug";
9
- return LevelResolver;
10
- }({});
11
- const shouldLog = (currentLevel, level) => LevelResolver[level] <= currentLevel;
12
-
13
- export { LevelResolver, shouldLog };
@@ -1,38 +0,0 @@
1
- const isAccessKeyRegex = /^SCW[A-Z0-9]{17}$/i;
2
- const isRegionRegex = /^[a-z]{2}-[a-z]{3}$/i;
3
- const isUUIDRegex = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/i;
4
- const isZoneRegex = /^[a-z]{2}-[a-z]{3}-[1-9]$/i;
5
-
6
- /** Returns true if the given string has a valid UUID format. */
7
- const isUUID = str => isUUIDRegex.test(str);
8
-
9
- /** Returns true if the given string has a valid Scaleway access key format. */
10
- const isAccessKey = str => isAccessKeyRegex.test(str);
11
-
12
- /** Returns true if the given string has a valid Scaleway secret key format. */
13
- const isSecretKey = str => isUUID(str);
14
-
15
- /** Returns true if the given string has a valid Scaleway organization ID format. */
16
- const isOrganizationId = str => isUUID(str);
17
-
18
- /** Returns true if the given string has a valid Scaleway project ID format. */
19
- const isProjectId = str => isUUID(str);
20
-
21
- /** Returns true if the given string has a valid region format. */
22
- const isRegion = str => isRegionRegex.test(str);
23
-
24
- /** Returns true if the given string has a valid zone format. */
25
- const isZone = str => isZoneRegex.test(str);
26
-
27
- /** Returns true if the given string has a valid URL format and starts by `http(s):`. */
28
- const isURL = str => {
29
- let url;
30
- try {
31
- url = new URL(str);
32
- } catch {
33
- return false;
34
- }
35
- return url.protocol === 'http:' || url.protocol === 'https:';
36
- };
37
-
38
- export { isAccessKey, isOrganizationId, isProjectId, isRegion, isSecretKey, isURL, isUUID, isZone };
@@ -1,13 +0,0 @@
1
- const ADJECTIVES = ['admiring', 'adoring', 'affectionate', 'agitated', 'amazing', 'angry', 'awesome', 'beautiful', 'blissful', 'bold', 'boring', 'brave', 'busy', 'charming', 'clever', 'cool', 'compassionate', 'competent', 'condescending', 'confident', 'cranky', 'crazy', 'dazzling', 'determined', 'distracted', 'dreamy', 'eager', 'ecstatic', 'elastic', 'elated', 'elegant', 'eloquent', 'epic', 'exciting', 'fervent', 'festive', 'flamboyant', 'focused', 'friendly', 'frosty', 'funny', 'gallant', 'gifted', 'goofy', 'gracious', 'great', 'happy', 'hardcore', 'heuristic', 'hopeful', 'hungry', 'infallible', 'inspiring', 'interesting', 'intelligent', 'jolly', 'jovial', 'keen', 'kind', 'laughing', 'loving', 'lucid', 'magical', 'mystifying', 'modest', 'musing', 'naughty', 'nervous', 'nice', 'nifty', 'nostalgic', 'objective', 'optimistic', 'peaceful', 'pedantic', 'pensive', 'practical', 'priceless', 'quirky', 'quizzical', 'recursing', 'relaxed', 'reverent', 'romantic', 'sad', 'serene', 'sharp', 'silly', 'sleepy', 'stoic', 'strange', 'stupefied', 'suspicious', 'sweet', 'tender', 'thirsty', 'trusting', 'unruffled', 'upbeat', 'vibrant', 'vigilant', 'vigorous', 'wizardly', 'wonderful', 'xenodochial', 'youthful', 'zealous', 'zen'];
2
- const NAMES = ['albattani', 'allen', 'almeida', 'antonelli', 'agnesi', 'archimedes', 'ardinghelli', 'aryabhata', 'austin', 'babbage', 'banach', 'banzai', 'bardeen', 'bartik', 'bassi', 'beaver', 'bell', 'benz', 'bhabha', 'bhaskara', 'black', 'blackburn', 'blackwell', 'bohr', 'booth', 'borg', 'bose', 'bouman', 'boyd', 'brahmagupta', 'brattain', 'brown', 'buck', 'burnell', 'cannon', 'carson', 'cartwright', 'carver', 'cerf', 'chandrasekhar', 'chaplygin', 'chatelet', 'chatterjee', 'chebyshev', 'cohen', 'chaum', 'clarke', 'colden', 'cori', 'cray', 'curran', 'curie', 'darwin', 'davinci', 'dewdney', 'dhawan', 'diffie', 'dijkstra', 'dirac', 'driscoll', 'dubinsky', 'easley', 'edison', 'einstein', 'elbakyan', 'elgamal', 'elion', 'ellis', 'engelbart', 'euclid', 'euler', 'faraday', 'feistel', 'fermat', 'fermi', 'feynman', 'franklin', 'gagarin', 'galileo', 'galois', 'ganguly', 'gates', 'gauss', 'germain', 'goldberg', 'goldstine', 'goldwasser', 'golick', 'goodall', 'gould', 'greider', 'grothendieck', 'haibt', 'hamilton', 'haslett', 'hawking', 'hellman', 'heisenberg', 'hermann', 'herschel', 'hertz', 'heyrovsky', 'hodgkin', 'hofstadter', 'hoover', 'hopper', 'hugle', 'hypatia', 'ishizaka', 'jackson', 'jang', 'jemison', 'jennings', 'jepsen', 'johnson', 'joliot', 'jones', 'kalam', 'kapitsa', 'kare', 'keldysh', 'keller', 'kepler', 'khayyam', 'khorana', 'kilby', 'kirch', 'knuth', 'kowalevski', 'lalande', 'lamarr', 'lamport', 'leakey', 'leavitt', 'lederberg', 'lehmann', 'lewin', 'lichterman', 'liskov', 'lovelace', 'lumiere', 'mahavira', 'margulis', 'matsumoto', 'maxwell', 'mayer', 'mccarthy', 'mcclintock', 'mclaren', 'mclean', 'mcnulty', 'mendel', 'mendeleev', 'meitner', 'meninsky', 'merkle', 'mestorf', 'mirzakhani', 'montalcini', 'moore', 'morse', 'murdock', 'moser', 'napier', 'nash', 'neumann', 'newton', 'nightingale', 'nobel', 'noether', 'northcutt', 'noyce', 'panini', 'pare', 'pascal', 'pasteur', 'payne', 'perlman', 'pike', 'poincare', 'poitras', 'proskuriakova', 'ptolemy', 'raman', 'ramanujan', 'ride', 'ritchie', 'rhodes', 'robinson', 'roentgen', 'rosalind', 'rubin', 'saha', 'sammet', 'sanderson', 'satoshi', 'shamir', 'shannon', 'shaw', 'shirley', 'shockley', 'shtern', 'sinoussi', 'snyder', 'solomon', 'spence', 'stonebraker', 'sutherland', 'swanson', 'swartz', 'swirles', 'taussig', 'tereshkova', 'tesla', 'tharp', 'thompson', 'torvalds', 'tu', 'turing', 'varahamihira', 'vaughan', 'visvesvaraya', 'volhard', 'villani', 'wescoff', 'wilbur', 'wiles', 'williams', 'williamson', 'wilson', 'wing', 'wozniak', 'wright', 'wu', 'yalow', 'yonath', 'zhukovsky'];
3
- const randomName = function () {
4
- let prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
5
- let separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '-';
6
- const name = `${ADJECTIVES[Math.floor(Math.random() * ADJECTIVES.length)] ?? ''}${separator}${NAMES[Math.floor(Math.random() * NAMES.length)] ?? ''}`;
7
- if (name === `boring${separator}wozniak`) {
8
- return randomName(prefix, separator);
9
- }
10
- return prefix.length > 0 ? `${prefix}${separator}${name}` : name;
11
- };
12
-
13
- export { randomName as default };
package/dist/scw/api.js DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * Abstract class to instantiate API from a {@link Client}.
3
- *
4
- * @internal
5
- */
6
- let API$1 = class API {
7
- constructor(client) {
8
- this.client = client;
9
- }
10
- };
11
-
12
- export { API$1 as API };
package/dist/scw/auth.js DELETED
@@ -1,68 +0,0 @@
1
- import { addAsyncHeaderInterceptor, addHeaderInterceptor } from '../internal/interceptors/helpers.js';
2
- import { assertValidAuthenticationSecrets } from './client-ini-profile.js';
3
-
4
- const SESSION_HEADER_KEY = 'x-session-token';
5
- const AUTH_HEADER_KEY = 'x-auth-token';
6
- /**
7
- * Authenticates with a session token.
8
- *
9
- * @param getToken - The token accessor
10
- * @returns The request interceptor
11
- *
12
- * @deprecated Please use addAsyncHeaderInterceptor instead.
13
- *
14
- * @internal
15
- */
16
- const authenticateWithSessionToken = getToken => addAsyncHeaderInterceptor(SESSION_HEADER_KEY, getToken);
17
-
18
- /**
19
- * Authenticates with a secrets.
20
- *
21
- * @param getToken - The secrets
22
- * @returns The request interceptor
23
- *
24
- * @throws Error
25
- * Thrown if the secrets are invalid.
26
- *
27
- * @internal
28
- */
29
- const authenticateWithSecrets = secrets => {
30
- assertValidAuthenticationSecrets(secrets);
31
- return addHeaderInterceptor(AUTH_HEADER_KEY, secrets.secretKey);
32
- };
33
-
34
- /**
35
- * Obfuscates a token.
36
- *
37
- * @param key - The token
38
- * @returns The obfuscated token
39
- *
40
- * @internal
41
- */
42
- const obfuscateToken = key => `${key.substring(0, 5)}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`;
43
-
44
- /**
45
- * Obfuscates an UUID.
46
- *
47
- * @param key - The UUID
48
- * @returns The obfuscated UUID
49
- *
50
- * @internal
51
- */
52
- const obfuscateUUID = key => `${key.substring(0, 8)}-xxxx-xxxx-xxxx-xxxxxxxxxxxx`;
53
- /**
54
- * Obfuscates headers entry.
55
- *
56
- * @param array - The header entry
57
- * @returns The obfuscated entry
58
- *
59
- * @internal
60
- */
61
- const obfuscateAuthHeadersEntry = _ref => {
62
- let [name, value] = _ref;
63
- if (name === SESSION_HEADER_KEY) return [name, obfuscateToken(value)];
64
- if (name === AUTH_HEADER_KEY) return [name, obfuscateUUID(value)];
65
- return [name, value];
66
- };
67
-
68
- export { authenticateWithSecrets, authenticateWithSessionToken, obfuscateAuthHeadersEntry, obfuscateToken, obfuscateUUID };
@@ -1,174 +0,0 @@
1
- import { authenticateWithSecrets } from './auth.js';
2
- import { hasAuthenticationSecrets } from './client-ini-profile.js';
3
-
4
- /**
5
- * A factory to build {@link Settings}.
6
- *
7
- * @public
8
- */
9
-
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
- const withProfile = profile => settings => {
21
- const newSettings = {
22
- ...settings
23
- };
24
- if (profile.apiURL) {
25
- newSettings.apiURL = profile.apiURL;
26
- }
27
- if (profile.defaultOrganizationId) {
28
- newSettings.defaultOrganizationId = profile.defaultOrganizationId;
29
- }
30
- if (profile.defaultProjectId) {
31
- newSettings.defaultProjectId = profile.defaultProjectId;
32
- }
33
- if (profile.defaultRegion) {
34
- newSettings.defaultRegion = profile.defaultRegion;
35
- }
36
- if (profile.defaultZone) {
37
- newSettings.defaultZone = profile.defaultZone;
38
- }
39
- if (hasAuthenticationSecrets(profile)) {
40
- newSettings.interceptors = [{
41
- request: authenticateWithSecrets(profile)
42
- }, ...newSettings.interceptors];
43
- }
44
- return newSettings;
45
- };
46
-
47
- /**
48
- * Instantiates the SDK with a different HTTP client.
49
- *
50
- * @param httpClient - A fetch compatible HTTP client
51
- * @returns A factory {@link ClientConfig}
52
- *
53
- * @remarks This method should be used in conjunction with the initializer `createAdvancedClient`.
54
- *
55
- * @public
56
- */
57
- const withHTTPClient = httpClient => settings => ({
58
- ...settings,
59
- httpClient
60
- });
61
-
62
- /**
63
- * Instantiates the SDK with a default page size.
64
- *
65
- * @param defaultPageSize - The default page size
66
- * @returns A factory {@link ClientConfig}
67
- *
68
- * @remarks This method should be used in conjunction with the initializer `createAdvancedClient`.
69
- *
70
- * @public
71
- */
72
- const withDefaultPageSize = defaultPageSize => settings => ({
73
- ...settings,
74
- defaultPageSize
75
- });
76
-
77
- /**
78
- * Instantiates the SDK with a different default user agent.
79
- *
80
- * @param userAgent - The default user agent
81
- * @returns A factory {@link ClientConfig}
82
- *
83
- * @remarks This method should be used in conjunction with the initializer `createAdvancedClient`.
84
- *
85
- * @public
86
- */
87
- const withUserAgent = userAgent => settings => ({
88
- ...settings,
89
- userAgent
90
- });
91
-
92
- /**
93
- * Instantiates the SDK with an additional user agent.
94
- *
95
- * @param userAgent - The suffix to append to default user agent
96
- * @returns A factory {@link ClientConfig}
97
- *
98
- * @remarks This method should be used in conjunction with the initializer `createAdvancedClient`.
99
- *
100
- * @public
101
- */
102
- const withUserAgentSuffix = userAgent => settings => ({
103
- ...settings,
104
- userAgent: settings.userAgent ? `${settings.userAgent} ${userAgent}` : userAgent
105
- });
106
-
107
- /**
108
- * Instantiates the SDK with additional interceptors.
109
- *
110
- * @param interceptors - The additional {@link NetworkInterceptors} interceptors
111
- * @returns A factory {@link ClientConfig}
112
- *
113
- * @remarks
114
- * It doesn't override the existing interceptors, but instead push more to the list.
115
- * This method should be used in conjunction with the initializer `createAdvancedClient`.
116
- *
117
- * @example
118
- * ```
119
- * withAdditionalInterceptors([
120
- * {
121
- * request: ({ request }) => {
122
- * console.log(`Do something with ${JSON.stringify(request)}`)
123
- * return request
124
- * },
125
- * response: ({ response }) => {
126
- * console.log(`Do something with ${JSON.stringify(response)}`)
127
- * return response
128
- * },
129
- * responseError: async ({
130
- * request,
131
- * error,
132
- * }: {
133
- * request: Request
134
- * error: unknown
135
- * }) => {
136
- * console.log(
137
- * `Do something with ${JSON.stringify(request)} and ${JSON.stringify(
138
- * error,
139
- * )}`,
140
- * )
141
- * throw error // or return Promise.resolve(someData)
142
- * },
143
- * },
144
- * ])
145
- * ```
146
- *
147
- * @public
148
- */
149
- const withAdditionalInterceptors = interceptors => settings => ({
150
- ...settings,
151
- interceptors: settings.interceptors.concat(interceptors)
152
- });
153
-
154
- /**
155
- * Instantiates the SDK with legacy interceptors.
156
- */
157
- /* eslint-disable deprecation/deprecation */
158
- const withLegacyInterceptors = () => settings => {
159
- if (!settings.requestInterceptors && !settings.responseInterceptors) {
160
- return settings;
161
- }
162
- const allInterceptors = settings.interceptors.concat((settings.requestInterceptors ?? []).map(obj => ({
163
- request: obj
164
- })), (settings.responseInterceptors ?? []).map(obj => ({
165
- response: obj
166
- })));
167
- return {
168
- ...settings,
169
- interceptors: allInterceptors
170
- };
171
- };
172
- /* eslint-enable deprecation/deprecation */
173
-
174
- export { withAdditionalInterceptors, withDefaultPageSize, withHTTPClient, withLegacyInterceptors, withProfile, withUserAgent, withUserAgentSuffix };