@scaleway/sdk 2.0.0-alpha.12 → 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.
Files changed (204) hide show
  1. package/package.json +2 -2
  2. package/dist/api/account/index.js +0 -4
  3. package/dist/api/account/v2/api.gen.js +0 -147
  4. package/dist/api/account/v2/index.gen.js +0 -4
  5. package/dist/api/account/v2/marshalling.gen.js +0 -39
  6. package/dist/api/account/v3/api.gen.js +0 -129
  7. package/dist/api/account/v3/index.gen.js +0 -6
  8. package/dist/api/account/v3/marshalling.gen.js +0 -39
  9. package/dist/api/account/v3/validation-rules.gen.js +0 -39
  10. package/dist/api/applesilicon/index.js +0 -2
  11. package/dist/api/applesilicon/v1alpha1/api.gen.js +0 -220
  12. package/dist/api/applesilicon/v1alpha1/content.gen.js +0 -7
  13. package/dist/api/applesilicon/v1alpha1/index.gen.js +0 -5
  14. package/dist/api/applesilicon/v1alpha1/marshalling.gen.js +0 -113
  15. package/dist/api/baremetal/index.js +0 -2
  16. package/dist/api/baremetal/v1/api.gen.js +0 -523
  17. package/dist/api/baremetal/v1/api.utils.js +0 -27
  18. package/dist/api/baremetal/v1/content.gen.js +0 -13
  19. package/dist/api/baremetal/v1/index.js +0 -5
  20. package/dist/api/baremetal/v1/marshalling.gen.js +0 -395
  21. package/dist/api/baremetal/v1/validation-rules.gen.js +0 -109
  22. package/dist/api/billing/index.js +0 -2
  23. package/dist/api/billing/v2alpha1/api.gen.js +0 -80
  24. package/dist/api/billing/v2alpha1/index.gen.js +0 -4
  25. package/dist/api/billing/v2alpha1/marshalling.gen.js +0 -53
  26. package/dist/api/block/index.js +0 -2
  27. package/dist/api/block/v1alpha1/api.gen.js +0 -245
  28. package/dist/api/block/v1alpha1/content.gen.js +0 -13
  29. package/dist/api/block/v1alpha1/index.gen.js +0 -7
  30. package/dist/api/block/v1alpha1/marshalling.gen.js +0 -175
  31. package/dist/api/block/v1alpha1/validation-rules.gen.js +0 -42
  32. package/dist/api/cockpit/index.js +0 -2
  33. package/dist/api/cockpit/v1beta1/api.gen.js +0 -448
  34. package/dist/api/cockpit/v1beta1/content.gen.js +0 -7
  35. package/dist/api/cockpit/v1beta1/index.gen.js +0 -5
  36. package/dist/api/cockpit/v1beta1/marshalling.gen.js +0 -220
  37. package/dist/api/container/index.js +0 -2
  38. package/dist/api/container/v1beta1/api.gen.js +0 -549
  39. package/dist/api/container/v1beta1/content.gen.js +0 -22
  40. package/dist/api/container/v1beta1/index.gen.js +0 -5
  41. package/dist/api/container/v1beta1/marshalling.gen.js +0 -330
  42. package/dist/api/document_db/index.js +0 -2
  43. package/dist/api/document_db/v1beta1/api.gen.js +0 -830
  44. package/dist/api/document_db/v1beta1/content.gen.js +0 -19
  45. package/dist/api/document_db/v1beta1/index.gen.js +0 -7
  46. package/dist/api/document_db/v1beta1/marshalling.gen.js +0 -580
  47. package/dist/api/document_db/v1beta1/validation-rules.gen.js +0 -10
  48. package/dist/api/domain/index.js +0 -2
  49. package/dist/api/domain/v2beta1/api.gen.js +0 -875
  50. package/dist/api/domain/v2beta1/content.gen.js +0 -28
  51. package/dist/api/domain/v2beta1/index.gen.js +0 -7
  52. package/dist/api/domain/v2beta1/marshalling.gen.js +0 -958
  53. package/dist/api/flexibleip/index.js +0 -2
  54. package/dist/api/flexibleip/v1alpha1/api.gen.js +0 -203
  55. package/dist/api/flexibleip/v1alpha1/content.gen.js +0 -10
  56. package/dist/api/flexibleip/v1alpha1/index.gen.js +0 -7
  57. package/dist/api/flexibleip/v1alpha1/marshalling.gen.js +0 -97
  58. package/dist/api/flexibleip/v1alpha1/validation-rules.gen.js +0 -14
  59. package/dist/api/function/index.js +0 -2
  60. package/dist/api/function/v1beta1/api.gen.js +0 -560
  61. package/dist/api/function/v1beta1/content.gen.js +0 -22
  62. package/dist/api/function/v1beta1/index.gen.js +0 -5
  63. package/dist/api/function/v1beta1/marshalling.gen.js +0 -368
  64. package/dist/api/iam/index.js +0 -2
  65. package/dist/api/iam/v1alpha1/api.gen.js +0 -799
  66. package/dist/api/iam/v1alpha1/index.gen.js +0 -6
  67. package/dist/api/iam/v1alpha1/marshalling.gen.js +0 -373
  68. package/dist/api/iam/v1alpha1/validation-rules.gen.js +0 -207
  69. package/dist/api/instance/index.js +0 -2
  70. package/dist/api/instance/v1/api.gen.js +0 -1003
  71. package/dist/api/instance/v1/api.utils.js +0 -369
  72. package/dist/api/instance/v1/content.gen.js +0 -31
  73. package/dist/api/instance/v1/index.js +0 -2
  74. package/dist/api/instance/v1/marshalling.gen.js +0 -1206
  75. package/dist/api/instance/v1/marshalling.utils.js +0 -63
  76. package/dist/api/iot/index.js +0 -2
  77. package/dist/api/iot/v1/api.gen.js +0 -581
  78. package/dist/api/iot/v1/content.gen.js +0 -7
  79. package/dist/api/iot/v1/index.gen.js +0 -5
  80. package/dist/api/iot/v1/marshalling.gen.js +0 -388
  81. package/dist/api/ipfs/index.js +0 -2
  82. package/dist/api/ipfs/v1alpha1/api.gen.js +0 -197
  83. package/dist/api/ipfs/v1alpha1/content.gen.js +0 -7
  84. package/dist/api/ipfs/v1alpha1/index.gen.js +0 -5
  85. package/dist/api/ipfs/v1alpha1/marshalling.gen.js +0 -121
  86. package/dist/api/k8s/index.js +0 -2
  87. package/dist/api/k8s/v1/api.gen.js +0 -454
  88. package/dist/api/k8s/v1/api.utils.js +0 -13
  89. package/dist/api/k8s/v1/content.gen.js +0 -13
  90. package/dist/api/k8s/v1/index.js +0 -4
  91. package/dist/api/k8s/v1/marshalling.gen.js +0 -333
  92. package/dist/api/k8s/v1/validation-rules.gen.js +0 -101
  93. package/dist/api/lb/index.js +0 -2
  94. package/dist/api/lb/v1/api.gen.js +0 -1669
  95. package/dist/api/lb/v1/api.utils.js +0 -81
  96. package/dist/api/lb/v1/content.gen.js +0 -16
  97. package/dist/api/lb/v1/index.js +0 -2
  98. package/dist/api/lb/v1/marshalling.gen.js +0 -923
  99. package/dist/api/marketplace/index.js +0 -4
  100. package/dist/api/marketplace/v1/api.gen.js +0 -60
  101. package/dist/api/marketplace/v1/index.gen.js +0 -4
  102. package/dist/api/marketplace/v1/marshalling.gen.js +0 -92
  103. package/dist/api/marketplace/v2/api.gen.js +0 -162
  104. package/dist/api/marketplace/v2/index.gen.js +0 -4
  105. package/dist/api/marketplace/v2/marshalling.gen.js +0 -94
  106. package/dist/api/mnq/index.js +0 -2
  107. package/dist/api/mnq/v1alpha1/api.gen.js +0 -205
  108. package/dist/api/mnq/v1alpha1/index.gen.js +0 -4
  109. package/dist/api/mnq/v1alpha1/marshalling.gen.js +0 -121
  110. package/dist/api/rdb/index.js +0 -2
  111. package/dist/api/rdb/v1/api.gen.js +0 -972
  112. package/dist/api/rdb/v1/content.gen.js +0 -22
  113. package/dist/api/rdb/v1/index.gen.js +0 -7
  114. package/dist/api/rdb/v1/marshalling.gen.js +0 -636
  115. package/dist/api/rdb/v1/validation-rules.gen.js +0 -10
  116. package/dist/api/redis/index.js +0 -2
  117. package/dist/api/redis/v1/api.gen.js +0 -389
  118. package/dist/api/redis/v1/content.gen.js +0 -7
  119. package/dist/api/redis/v1/index.gen.js +0 -5
  120. package/dist/api/redis/v1/marshalling.gen.js +0 -259
  121. package/dist/api/registry/index.js +0 -2
  122. package/dist/api/registry/v1/api.gen.js +0 -252
  123. package/dist/api/registry/v1/content.gen.js +0 -13
  124. package/dist/api/registry/v1/index.gen.js +0 -5
  125. package/dist/api/registry/v1/marshalling.gen.js +0 -106
  126. package/dist/api/secret/index.js +0 -2
  127. package/dist/api/secret/v1alpha1/api.gen.js +0 -415
  128. package/dist/api/secret/v1alpha1/index.gen.js +0 -4
  129. package/dist/api/secret/v1alpha1/marshalling.gen.js +0 -143
  130. package/dist/api/tem/index.js +0 -2
  131. package/dist/api/tem/v1alpha1/api.gen.js +0 -229
  132. package/dist/api/tem/v1alpha1/content.gen.js +0 -10
  133. package/dist/api/tem/v1alpha1/index.gen.js +0 -5
  134. package/dist/api/tem/v1alpha1/marshalling.gen.js +0 -159
  135. package/dist/api/test/index.js +0 -2
  136. package/dist/api/test/v1/api.gen.js +0 -152
  137. package/dist/api/test/v1/content.gen.js +0 -7
  138. package/dist/api/test/v1/index.gen.js +0 -5
  139. package/dist/api/test/v1/marshalling.gen.js +0 -79
  140. package/dist/api/vpc/index.js +0 -4
  141. package/dist/api/vpc/v1/api.gen.js +0 -110
  142. package/dist/api/vpc/v1/index.gen.js +0 -4
  143. package/dist/api/vpc/v1/marshalling.gen.js +0 -44
  144. package/dist/api/vpc/v2/api.gen.js +0 -276
  145. package/dist/api/vpc/v2/index.gen.js +0 -4
  146. package/dist/api/vpc/v2/marshalling.gen.js +0 -135
  147. package/dist/api/vpcgw/index.js +0 -2
  148. package/dist/api/vpcgw/v1/api.gen.js +0 -669
  149. package/dist/api/vpcgw/v1/content.gen.js +0 -10
  150. package/dist/api/vpcgw/v1/index.gen.js +0 -5
  151. package/dist/api/vpcgw/v1/marshalling.gen.js +0 -336
  152. package/dist/api/webhosting/index.js +0 -2
  153. package/dist/api/webhosting/v1alpha1/api.gen.js +0 -210
  154. package/dist/api/webhosting/v1alpha1/content.gen.js +0 -7
  155. package/dist/api/webhosting/v1alpha1/index.gen.js +0 -7
  156. package/dist/api/webhosting/v1alpha1/marshalling.gen.js +0 -173
  157. package/dist/api/webhosting/v1alpha1/validation-rules.gen.js +0 -23
  158. package/dist/helpers/is-browser.js +0 -5
  159. package/dist/helpers/is-response.js +0 -10
  160. package/dist/helpers/json.js +0 -11
  161. package/dist/helpers/marshalling.js +0 -130
  162. package/dist/index.cjs +0 -24364
  163. package/dist/index.d.ts +0 -27584
  164. package/dist/index.js +0 -69
  165. package/dist/internal/async/interval-retrier.js +0 -105
  166. package/dist/internal/async/sleep.js +0 -13
  167. package/dist/internal/interceptors/composer.js +0 -46
  168. package/dist/internal/interceptors/helpers.js +0 -32
  169. package/dist/internal/logger/console-logger.js +0 -38
  170. package/dist/internal/logger/index.js +0 -41
  171. package/dist/internal/logger/level-resolver.js +0 -13
  172. package/dist/internal/validations/string-validation.js +0 -38
  173. package/dist/node_modules/.pnpm/@scaleway_random-name@4.0.2/node_modules/@scaleway/random-name/dist/index.js +0 -13
  174. package/dist/scw/api.js +0 -12
  175. package/dist/scw/auth.js +0 -68
  176. package/dist/scw/client-ini-factory.js +0 -174
  177. package/dist/scw/client-ini-profile.js +0 -54
  178. package/dist/scw/client-settings.js +0 -78
  179. package/dist/scw/client.js +0 -98
  180. package/dist/scw/constants.js +0 -4
  181. package/dist/scw/custom-marshalling.js +0 -131
  182. package/dist/scw/errors/error-parser.js +0 -107
  183. package/dist/scw/errors/non-standard/invalid-request-mapper.js +0 -36
  184. package/dist/scw/errors/non-standard/unknown-resource-mapper.js +0 -27
  185. package/dist/scw/errors/scw-error.js +0 -66
  186. package/dist/scw/errors/standard/already-exists-error.js +0 -26
  187. package/dist/scw/errors/standard/denied-authentication-error.js +0 -52
  188. package/dist/scw/errors/standard/index.js +0 -13
  189. package/dist/scw/errors/standard/invalid-arguments-error.js +0 -67
  190. package/dist/scw/errors/standard/out-of-stock-error.js +0 -22
  191. package/dist/scw/errors/standard/permissions-denied-error.js +0 -48
  192. package/dist/scw/errors/standard/precondition-failed-error.js +0 -42
  193. package/dist/scw/errors/standard/quotas-exceeded-error.js +0 -68
  194. package/dist/scw/errors/standard/resource-expired-error.js +0 -26
  195. package/dist/scw/errors/standard/resource-locked-error.js +0 -25
  196. package/dist/scw/errors/standard/resource-not-found-error.js +0 -25
  197. package/dist/scw/errors/standard/too-many-requests-error.js +0 -70
  198. package/dist/scw/errors/standard/transient-state-error.js +0 -26
  199. package/dist/scw/errors/types.js +0 -23
  200. package/dist/scw/fetch/build-fetcher.js +0 -72
  201. package/dist/scw/fetch/http-dumper.js +0 -54
  202. package/dist/scw/fetch/http-interceptors.js +0 -99
  203. package/dist/scw/fetch/resource-paginator.js +0 -84
  204. package/dist/scw/fetch/response-parser.js +0 -72
@@ -1,173 +0,0 @@
1
- import { isJSONObject } from '../../../helpers/json.js';
2
- import { unmarshalMoney } from '../../../scw/custom-marshalling.js';
3
- import { unmarshalDate, unmarshalArrayOfObject } from '../../../helpers/marshalling.js';
4
-
5
- // This file was automatically generated. DO NOT EDIT.
6
- // If you have any remark or suggestion do not hesitate to open an issue.
7
- const unmarshalHostingCpanelUrls = data => {
8
- if (!isJSONObject(data)) {
9
- throw new TypeError(`Unmarshalling the type 'HostingCpanelUrls' failed as data isn't a dictionary.`);
10
- }
11
- return {
12
- dashboard: data.dashboard,
13
- webmail: data.webmail
14
- };
15
- };
16
- const unmarshalHostingOption = data => {
17
- if (!isJSONObject(data)) {
18
- throw new TypeError(`Unmarshalling the type 'HostingOption' failed as data isn't a dictionary.`);
19
- }
20
- return {
21
- id: data.id,
22
- name: data.name
23
- };
24
- };
25
- const unmarshalHosting = data => {
26
- if (!isJSONObject(data)) {
27
- throw new TypeError(`Unmarshalling the type 'Hosting' failed as data isn't a dictionary.`);
28
- }
29
- return {
30
- cpanelUrls: unmarshalHostingCpanelUrls(data.cpanel_urls),
31
- createdAt: unmarshalDate(data.created_at),
32
- dnsStatus: data.dns_status,
33
- domain: data.domain,
34
- id: data.id,
35
- offerEndOfLife: data.offer_end_of_life,
36
- offerId: data.offer_id,
37
- offerName: data.offer_name,
38
- options: unmarshalArrayOfObject(data.options, unmarshalHostingOption),
39
- organizationId: data.organization_id,
40
- platformHostname: data.platform_hostname,
41
- platformNumber: data.platform_number ? data.platform_number : undefined,
42
- projectId: data.project_id,
43
- region: data.region,
44
- status: data.status,
45
- tags: data.tags,
46
- updatedAt: unmarshalDate(data.updated_at),
47
- username: data.username
48
- };
49
- };
50
- const unmarshalNameserver = data => {
51
- if (!isJSONObject(data)) {
52
- throw new TypeError(`Unmarshalling the type 'Nameserver' failed as data isn't a dictionary.`);
53
- }
54
- return {
55
- hostname: data.hostname,
56
- isDefault: data.is_default,
57
- status: data.status
58
- };
59
- };
60
- const unmarshalDnsRecord = data => {
61
- if (!isJSONObject(data)) {
62
- throw new TypeError(`Unmarshalling the type 'DnsRecord' failed as data isn't a dictionary.`);
63
- }
64
- return {
65
- name: data.name,
66
- priority: data.priority ? data.priority : undefined,
67
- status: data.status,
68
- ttl: data.ttl,
69
- type: data.type,
70
- value: data.value
71
- };
72
- };
73
- const unmarshalDnsRecords = data => {
74
- if (!isJSONObject(data)) {
75
- throw new TypeError(`Unmarshalling the type 'DnsRecords' failed as data isn't a dictionary.`);
76
- }
77
- return {
78
- nameServers: unmarshalArrayOfObject(data.name_servers, unmarshalNameserver),
79
- records: unmarshalArrayOfObject(data.records, unmarshalDnsRecord),
80
- status: data.status
81
- };
82
- };
83
- const unmarshalDediboxHosting = data => {
84
- if (!isJSONObject(data)) {
85
- throw new TypeError(`Unmarshalling the type 'DediboxHosting' failed as data isn't a dictionary.`);
86
- }
87
- return {
88
- dediboxId: data.dedibox_id,
89
- domain: data.domain,
90
- offerId: data.offer_id,
91
- type: data.type
92
- };
93
- };
94
- const unmarshalListDediboxHostingsResponse = data => {
95
- if (!isJSONObject(data)) {
96
- throw new TypeError(`Unmarshalling the type 'ListDediboxHostingsResponse' failed as data isn't a dictionary.`);
97
- }
98
- return {
99
- dediboxHostings: unmarshalArrayOfObject(data.dedibox_hostings, unmarshalDediboxHosting),
100
- totalCount: data.total_count
101
- };
102
- };
103
- const unmarshalListHostingsResponse = data => {
104
- if (!isJSONObject(data)) {
105
- throw new TypeError(`Unmarshalling the type 'ListHostingsResponse' failed as data isn't a dictionary.`);
106
- }
107
- return {
108
- hostings: unmarshalArrayOfObject(data.hostings, unmarshalHosting),
109
- totalCount: data.total_count
110
- };
111
- };
112
- const unmarshalOfferProduct = data => {
113
- if (!isJSONObject(data)) {
114
- throw new TypeError(`Unmarshalling the type 'OfferProduct' failed as data isn't a dictionary.`);
115
- }
116
- return {
117
- databasesQuota: data.databases_quota,
118
- emailAccountsQuota: data.email_accounts_quota,
119
- emailStorageQuota: data.email_storage_quota,
120
- hostingStorageQuota: data.hosting_storage_quota,
121
- maxAddonDomains: data.max_addon_domains,
122
- name: data.name,
123
- option: data.option,
124
- ram: data.ram,
125
- supportIncluded: data.support_included,
126
- vCpu: data.v_cpu
127
- };
128
- };
129
- const unmarshalOffer = data => {
130
- if (!isJSONObject(data)) {
131
- throw new TypeError(`Unmarshalling the type 'Offer' failed as data isn't a dictionary.`);
132
- }
133
- return {
134
- available: data.available,
135
- billingOperationPath: data.billing_operation_path,
136
- endOfLife: data.end_of_life,
137
- id: data.id,
138
- price: data.price ? unmarshalMoney(data.price) : undefined,
139
- product: unmarshalOfferProduct(data.product),
140
- quotaWarnings: data.quota_warnings
141
- };
142
- };
143
- const unmarshalListOffersResponse = data => {
144
- if (!isJSONObject(data)) {
145
- throw new TypeError(`Unmarshalling the type 'ListOffersResponse' failed as data isn't a dictionary.`);
146
- }
147
- return {
148
- offers: unmarshalArrayOfObject(data.offers, unmarshalOffer)
149
- };
150
- };
151
- const marshalCreateHostingRequest = (request, defaults) => ({
152
- domain: request.domain,
153
- email: request.email,
154
- offer_id: request.offerId,
155
- option_ids: request.optionIds,
156
- project_id: request.projectId ?? defaults.defaultProjectId,
157
- tags: request.tags
158
- });
159
- const marshalDediboxApiMigrateDediboxHostingRequest = (request, defaults) => ({
160
- domain: request.domain,
161
- email: request.email,
162
- organization_id: request.organizationId ?? defaults.defaultOrganizationId,
163
- project_id: request.projectId ?? defaults.defaultProjectId,
164
- token: request.token
165
- });
166
- const marshalUpdateHostingRequest = (request, defaults) => ({
167
- email: request.email,
168
- offer_id: request.offerId,
169
- option_ids: request.optionIds,
170
- tags: request.tags
171
- });
172
-
173
- export { marshalCreateHostingRequest, marshalDediboxApiMigrateDediboxHostingRequest, marshalUpdateHostingRequest, unmarshalDnsRecords, unmarshalHosting, unmarshalListDediboxHostingsResponse, unmarshalListHostingsResponse, unmarshalListOffersResponse };
@@ -1,23 +0,0 @@
1
- // This file was automatically generated. DO NOT EDIT.
2
- // If you have any remark or suggestion do not hesitate to open an issue.
3
-
4
- const DediboxApiListDediboxHostingsRequest = {
5
- page: {
6
- greaterThan: 0
7
- },
8
- pageSize: {
9
- greaterThan: 0,
10
- lessThanOrEqual: 100
11
- }
12
- };
13
- const ListHostingsRequest = {
14
- page: {
15
- greaterThan: 0
16
- },
17
- pageSize: {
18
- greaterThan: 0,
19
- lessThanOrEqual: 100
20
- }
21
- };
22
-
23
- export { DediboxApiListDediboxHostingsRequest, ListHostingsRequest };
@@ -1,5 +0,0 @@
1
- const isBrowser = () =>
2
- // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
3
- typeof window !== 'undefined' && typeof window.document !== 'undefined';
4
-
5
- export { isBrowser };
@@ -1,10 +0,0 @@
1
- /**
2
- * Validates an object is of type Response without using `instanceof`.
3
- *
4
- * @remarks Check issue #509 for more context.
5
- *
6
- * @internal
7
- */
8
- const isResponse = obj => obj !== null && obj !== undefined && typeof obj === 'object' && 'status' in obj && typeof obj.status === 'number' && 'statusText' in obj && typeof obj.statusText === 'string' && 'headers' in obj && typeof obj.headers === 'object' && 'body' in obj && typeof obj.body !== 'undefined';
9
-
10
- export { isResponse };
@@ -1,11 +0,0 @@
1
- /**
2
- * Validates an unknown object is a JSON Object.
3
- *
4
- * @internal
5
- */
6
- const isJSONObject = obj => {
7
- const objT = typeof obj;
8
- return obj !== undefined && obj !== null && objT !== 'string' && objT !== 'number' && objT !== 'boolean' && !Array.isArray(obj) && objT === 'object';
9
- };
10
-
11
- export { isJSONObject };
@@ -1,130 +0,0 @@
1
- /**
2
- * Returns the parameter if it's valid as path parameter
3
- * (string and not empty, or number), else throws an exception.
4
- *
5
- * @param name - The parameter name
6
- * @param param - The parameter value
7
- * @returns The parameter value
8
- *
9
- * @throws TypeError
10
- * Thrown if the parameter is invalid.
11
- *
12
- * @internal
13
- */
14
- function validatePathParam(name, param) {
15
- if (typeof param === 'string' && param.length > 0) return param;
16
- if (typeof param === 'number') return param.toString();
17
- throw new TypeError(`param ${name} cannot be empty in request`);
18
- }
19
-
20
- /**
21
- * Resolves the ideal parameter and value amongst an optional list.
22
- *
23
- * @param list - The list to be looking into
24
- * @param isRequired - If at least one "one-of" should be found, false by default
25
- * @returns The parameter and value
26
- *
27
- * @throws TypeError
28
- * Thrown if isRequired is true, and no value or default value is specified.
29
- *
30
- * @internal
31
- */
32
- const resolveOneOf = function (list, isRequired) {
33
- if (isRequired === void 0) {
34
- isRequired = false;
35
- }
36
- const elt = list.find(obj => obj.value !== undefined) ?? list.find(obj => obj.default !== undefined);
37
- const value = elt?.value ?? elt?.default;
38
- if (elt && value !== undefined) {
39
- return {
40
- [elt.param]: value
41
- };
42
- }
43
- if (isRequired) {
44
- const keyList = list.map(obj => obj.param).join(' or ');
45
- throw new TypeError(`one of ${keyList} must be indicated in the request`);
46
- }
47
- return {};
48
- };
49
- /**
50
- * Filters defined parameters tuples and converts them to URLSearchParams.
51
- *
52
- * @param paramTuples - The key/value pairs
53
- * @returns URLSearchParams
54
- *
55
- * @internal
56
- */
57
- const urlParams = function () {
58
- const params = new URLSearchParams();
59
- for (var _len = arguments.length, paramTuples = new Array(_len), _key = 0; _key < _len; _key++) {
60
- paramTuples[_key] = arguments[_key];
61
- }
62
- for (const [key, value] of paramTuples) {
63
- if (typeof key === 'string' && value != null) {
64
- if (Array.isArray(value)) {
65
- for (const innerValue of value) {
66
- if (innerValue !== null) {
67
- params.append(key, innerValue instanceof Date ? innerValue.toISOString() : innerValue.toString());
68
- }
69
- }
70
- } else {
71
- params.append(key, value instanceof Date ? value.toISOString() : value.toString());
72
- }
73
- }
74
- }
75
- return params;
76
- };
77
-
78
- /**
79
- * Unmarshals data to Date object.
80
- *
81
- * @internal
82
- */
83
- const unmarshalDate = data => {
84
- if (typeof data !== 'string') {
85
- return undefined;
86
- }
87
- const date = new Date(data);
88
- if (Number.isNaN(date.getTime())) {
89
- return undefined;
90
- }
91
- return date;
92
- };
93
-
94
- /**
95
- * Unmarshals array of object.
96
- *
97
- * @internal
98
- */
99
- const unmarshalArrayOfObject = function (data, unmarshaller, emptyFallback) {
100
- if (emptyFallback === void 0) {
101
- emptyFallback = true;
102
- }
103
- if (!Array.isArray(data)) {
104
- return emptyFallback ? [] : undefined;
105
- }
106
- return data.map(elt => unmarshaller(elt));
107
- };
108
-
109
- /**
110
- * Unmarshals map of object.
111
- *
112
- * @internal
113
- */
114
- const unmarshalMapOfObject = function (data, unmarshaller, emptyFallback) {
115
- if (emptyFallback === void 0) {
116
- emptyFallback = true;
117
- }
118
- if (!data || typeof data !== 'object' || !(data instanceof Object) || Array.isArray(data)) {
119
- return emptyFallback ? {} : undefined;
120
- }
121
- return Object.entries(data).reduce((acc, _ref) => {
122
- let [key, value] = _ref;
123
- return {
124
- ...acc,
125
- [key]: unmarshaller(value)
126
- };
127
- }, {});
128
- };
129
-
130
- export { resolveOneOf, unmarshalArrayOfObject, unmarshalDate, unmarshalMapOfObject, urlParams, validatePathParam };