@moovio/sdk 0.16.5 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +60 -45
  2. package/bin/mcp-server.js +1167 -551
  3. package/bin/mcp-server.js.map +23 -12
  4. package/docs/sdks/images/README.md +190 -0
  5. package/docs/sdks/products/README.md +32 -8
  6. package/examples/package-lock.json +1 -1
  7. package/funcs/imagesUpdate.d.ts +19 -0
  8. package/funcs/imagesUpdate.d.ts.map +1 -0
  9. package/funcs/imagesUpdate.js +170 -0
  10. package/funcs/imagesUpdate.js.map +1 -0
  11. package/funcs/imagesUpload.d.ts +16 -0
  12. package/funcs/imagesUpload.d.ts.map +1 -0
  13. package/funcs/imagesUpload.js +161 -0
  14. package/funcs/imagesUpload.js.map +1 -0
  15. package/jsr.json +1 -1
  16. package/lib/config.d.ts +3 -3
  17. package/lib/config.js +3 -3
  18. package/lib/config.js.map +1 -1
  19. package/mcp-server/mcp-server.js +1 -1
  20. package/mcp-server/server.d.ts.map +1 -1
  21. package/mcp-server/server.js +5 -1
  22. package/mcp-server/server.js.map +1 -1
  23. package/mcp-server/tools/imagesUpdate.d.ts +8 -0
  24. package/mcp-server/tools/imagesUpdate.d.ts.map +1 -0
  25. package/mcp-server/tools/imagesUpdate.js +66 -0
  26. package/mcp-server/tools/imagesUpdate.js.map +1 -0
  27. package/mcp-server/tools/imagesUpload.d.ts +8 -0
  28. package/mcp-server/tools/imagesUpload.d.ts.map +1 -0
  29. package/mcp-server/tools/imagesUpload.js +63 -0
  30. package/mcp-server/tools/imagesUpload.js.map +1 -0
  31. package/models/components/createproductoption.d.ts +3 -2
  32. package/models/components/createproductoption.d.ts.map +1 -1
  33. package/models/components/createproductoption.js +3 -2
  34. package/models/components/createproductoption.js.map +1 -1
  35. package/models/components/imagemetadatarequest.d.ts +35 -0
  36. package/models/components/imagemetadatarequest.d.ts.map +1 -0
  37. package/models/components/imagemetadatarequest.js +69 -0
  38. package/models/components/imagemetadatarequest.js.map +1 -0
  39. package/models/components/imagemetadatavalidationerror.d.ts +29 -0
  40. package/models/components/imagemetadatavalidationerror.d.ts.map +1 -0
  41. package/models/components/imagemetadatavalidationerror.js +69 -0
  42. package/models/components/imagemetadatavalidationerror.js.map +1 -0
  43. package/models/components/imageupdaterequestmultipart.d.ts +103 -0
  44. package/models/components/imageupdaterequestmultipart.d.ts.map +1 -0
  45. package/models/components/imageupdaterequestmultipart.js +139 -0
  46. package/models/components/imageupdaterequestmultipart.js.map +1 -0
  47. package/models/components/imageuploadrequestmultipart.d.ts +65 -0
  48. package/models/components/imageuploadrequestmultipart.d.ts.map +1 -0
  49. package/models/components/imageuploadrequestmultipart.js +113 -0
  50. package/models/components/imageuploadrequestmultipart.js.map +1 -0
  51. package/models/components/index.d.ts +4 -0
  52. package/models/components/index.d.ts.map +1 -1
  53. package/models/components/index.js +4 -0
  54. package/models/components/index.js.map +1 -1
  55. package/models/components/productoption.d.ts +3 -2
  56. package/models/components/productoption.d.ts.map +1 -1
  57. package/models/components/productoption.js +3 -2
  58. package/models/components/productoption.js.map +1 -1
  59. package/models/components/productoptionvalidationerror.d.ts +3 -2
  60. package/models/components/productoptionvalidationerror.d.ts.map +1 -1
  61. package/models/components/productoptionvalidationerror.js +3 -2
  62. package/models/components/productoptionvalidationerror.js.map +1 -1
  63. package/models/errors/imagerequestvalidationerror.d.ts +40 -0
  64. package/models/errors/imagerequestvalidationerror.d.ts.map +1 -0
  65. package/models/errors/imagerequestvalidationerror.js +91 -0
  66. package/models/errors/imagerequestvalidationerror.js.map +1 -0
  67. package/models/errors/index.d.ts +1 -0
  68. package/models/errors/index.d.ts.map +1 -1
  69. package/models/errors/index.js +1 -0
  70. package/models/errors/index.js.map +1 -1
  71. package/models/operations/index.d.ts +2 -0
  72. package/models/operations/index.d.ts.map +1 -1
  73. package/models/operations/index.js +2 -0
  74. package/models/operations/index.js.map +1 -1
  75. package/models/operations/updateimage.d.ts +103 -0
  76. package/models/operations/updateimage.d.ts.map +1 -0
  77. package/models/operations/updateimage.js +157 -0
  78. package/models/operations/updateimage.js.map +1 -0
  79. package/models/operations/uploadimage.d.ts +101 -0
  80. package/models/operations/uploadimage.d.ts.map +1 -0
  81. package/models/operations/uploadimage.js +155 -0
  82. package/models/operations/uploadimage.js.map +1 -0
  83. package/package.json +1 -1
  84. package/sdk/images.d.ts +13 -0
  85. package/sdk/images.d.ts.map +1 -1
  86. package/sdk/images.js +19 -0
  87. package/sdk/images.js.map +1 -1
  88. package/src/funcs/imagesUpdate.ts +258 -0
  89. package/src/funcs/imagesUpload.ts +249 -0
  90. package/src/lib/config.ts +3 -3
  91. package/src/mcp-server/mcp-server.ts +1 -1
  92. package/src/mcp-server/server.ts +5 -1
  93. package/src/mcp-server/tools/imagesUpdate.ts +39 -0
  94. package/src/mcp-server/tools/imagesUpload.ts +36 -0
  95. package/src/models/components/createproductoption.ts +10 -4
  96. package/src/models/components/imagemetadatarequest.ts +72 -0
  97. package/src/models/components/imagemetadatavalidationerror.ts +68 -0
  98. package/src/models/components/imageupdaterequestmultipart.ts +224 -0
  99. package/src/models/components/imageuploadrequestmultipart.ts +150 -0
  100. package/src/models/components/index.ts +4 -0
  101. package/src/models/components/productoption.ts +10 -4
  102. package/src/models/components/productoptionvalidationerror.ts +10 -4
  103. package/src/models/errors/imagerequestvalidationerror.ts +86 -0
  104. package/src/models/errors/index.ts +1 -0
  105. package/src/models/operations/index.ts +2 -0
  106. package/src/models/operations/updateimage.ts +237 -0
  107. package/src/models/operations/uploadimage.ts +233 -0
  108. package/src/sdk/images.ts +35 -0
@@ -6,7 +6,14 @@
6
6
  ### Available Operations
7
7
 
8
8
  * [list](#list) - List metadata for all images in the specified account.
9
+ * [upload](#upload) - Upload a new PNG, JPEG, or WebP image with optional metadata.
10
+ Duplicate images, and requests larger than 16MB will be rejected.
9
11
  * [getMetadata](#getmetadata) - Retrieve metadata for a specific image by its ID.
12
+ * [update](#update) - Update an existing image and/or its metadata.
13
+
14
+ Duplicate images, and requests larger than 16MB will be rejected. Omit any
15
+ form parts you do not wish to update. Existing metadata can be cleared by
16
+ sending `null` for the `metadata` form part.
10
17
  * [delete](#delete) - Permanently delete an image by its ID.
11
18
  * [getPublic](#getpublic) - Get an image by its public ID.
12
19
 
@@ -91,6 +98,98 @@ run();
91
98
  | --------------- | --------------- | --------------- |
92
99
  | errors.APIError | 4XX, 5XX | \*/\* |
93
100
 
101
+ ## upload
102
+
103
+ Upload a new PNG, JPEG, or WebP image with optional metadata.
104
+ Duplicate images, and requests larger than 16MB will be rejected.
105
+
106
+ ### Example Usage
107
+
108
+ <!-- UsageSnippet language="typescript" operationID="uploadImage" method="post" path="/accounts/{accountID}/images" -->
109
+ ```typescript
110
+ import { Moov } from "@moovio/sdk";
111
+ import { openAsBlob } from "node:fs";
112
+
113
+ const moov = new Moov({
114
+ xMoovVersion: "v2024.01.00",
115
+ security: {
116
+ username: "",
117
+ password: "",
118
+ },
119
+ });
120
+
121
+ async function run() {
122
+ const result = await moov.images.upload({
123
+ accountID: "c0971a52-1f1c-4511-876a-f45c4cfd6154",
124
+ imageUploadRequestMultiPart: {
125
+ image: await openAsBlob("example.file"),
126
+ },
127
+ });
128
+
129
+ console.log(result);
130
+ }
131
+
132
+ run();
133
+ ```
134
+
135
+ ### Standalone function
136
+
137
+ The standalone function version of this method:
138
+
139
+ ```typescript
140
+ import { MoovCore } from "@moovio/sdk/core.js";
141
+ import { imagesUpload } from "@moovio/sdk/funcs/imagesUpload.js";
142
+ import { openAsBlob } from "node:fs";
143
+
144
+ // Use `MoovCore` for best tree-shaking performance.
145
+ // You can create one instance of it to use across an application.
146
+ const moov = new MoovCore({
147
+ xMoovVersion: "v2024.01.00",
148
+ security: {
149
+ username: "",
150
+ password: "",
151
+ },
152
+ });
153
+
154
+ async function run() {
155
+ const res = await imagesUpload(moov, {
156
+ accountID: "c0971a52-1f1c-4511-876a-f45c4cfd6154",
157
+ imageUploadRequestMultiPart: {
158
+ image: await openAsBlob("example.file"),
159
+ },
160
+ });
161
+ if (res.ok) {
162
+ const { value: result } = res;
163
+ console.log(result);
164
+ } else {
165
+ console.log("imagesUpload failed:", res.error);
166
+ }
167
+ }
168
+
169
+ run();
170
+ ```
171
+
172
+ ### Parameters
173
+
174
+ | Parameter | Type | Required | Description |
175
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
176
+ | `request` | [operations.UploadImageRequest](../../models/operations/uploadimagerequest.md) | :heavy_check_mark: | The request object to use for the request. |
177
+ | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
178
+ | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
179
+ | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
180
+
181
+ ### Response
182
+
183
+ **Promise\<[operations.UploadImageResponse](../../models/operations/uploadimageresponse.md)\>**
184
+
185
+ ### Errors
186
+
187
+ | Error Type | Status Code | Content Type |
188
+ | ---------------------------------- | ---------------------------------- | ---------------------------------- |
189
+ | errors.GenericError | 400, 409 | application/json |
190
+ | errors.ImageRequestValidationError | 422 | application/json |
191
+ | errors.APIError | 4XX, 5XX | \*/\* |
192
+
94
193
  ## getMetadata
95
194
 
96
195
  Retrieve metadata for a specific image by its ID.
@@ -174,6 +273,97 @@ run();
174
273
  | --------------- | --------------- | --------------- |
175
274
  | errors.APIError | 4XX, 5XX | \*/\* |
176
275
 
276
+ ## update
277
+
278
+ Update an existing image and/or its metadata.
279
+
280
+ Duplicate images, and requests larger than 16MB will be rejected. Omit any
281
+ form parts you do not wish to update. Existing metadata can be cleared by
282
+ sending `null` for the `metadata` form part.
283
+
284
+ ### Example Usage
285
+
286
+ <!-- UsageSnippet language="typescript" operationID="updateImage" method="patch" path="/accounts/{accountID}/images/{imageID}" -->
287
+ ```typescript
288
+ import { Moov } from "@moovio/sdk";
289
+
290
+ const moov = new Moov({
291
+ xMoovVersion: "v2024.01.00",
292
+ security: {
293
+ username: "",
294
+ password: "",
295
+ },
296
+ });
297
+
298
+ async function run() {
299
+ const result = await moov.images.update({
300
+ accountID: "310f4f19-45cf-4429-9aae-8e93827ecb0d",
301
+ imageID: "8ef109f8-5a61-4355-b2e4-b8ac2f6f6f47",
302
+ imageUpdateRequestMultiPart: {},
303
+ });
304
+
305
+ console.log(result);
306
+ }
307
+
308
+ run();
309
+ ```
310
+
311
+ ### Standalone function
312
+
313
+ The standalone function version of this method:
314
+
315
+ ```typescript
316
+ import { MoovCore } from "@moovio/sdk/core.js";
317
+ import { imagesUpdate } from "@moovio/sdk/funcs/imagesUpdate.js";
318
+
319
+ // Use `MoovCore` for best tree-shaking performance.
320
+ // You can create one instance of it to use across an application.
321
+ const moov = new MoovCore({
322
+ xMoovVersion: "v2024.01.00",
323
+ security: {
324
+ username: "",
325
+ password: "",
326
+ },
327
+ });
328
+
329
+ async function run() {
330
+ const res = await imagesUpdate(moov, {
331
+ accountID: "310f4f19-45cf-4429-9aae-8e93827ecb0d",
332
+ imageID: "8ef109f8-5a61-4355-b2e4-b8ac2f6f6f47",
333
+ imageUpdateRequestMultiPart: {},
334
+ });
335
+ if (res.ok) {
336
+ const { value: result } = res;
337
+ console.log(result);
338
+ } else {
339
+ console.log("imagesUpdate failed:", res.error);
340
+ }
341
+ }
342
+
343
+ run();
344
+ ```
345
+
346
+ ### Parameters
347
+
348
+ | Parameter | Type | Required | Description |
349
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
350
+ | `request` | [operations.UpdateImageRequest](../../models/operations/updateimagerequest.md) | :heavy_check_mark: | The request object to use for the request. |
351
+ | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
352
+ | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
353
+ | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
354
+
355
+ ### Response
356
+
357
+ **Promise\<[operations.UpdateImageResponse](../../models/operations/updateimageresponse.md)\>**
358
+
359
+ ### Errors
360
+
361
+ | Error Type | Status Code | Content Type |
362
+ | ---------------------------------- | ---------------------------------- | ---------------------------------- |
363
+ | errors.GenericError | 400, 409 | application/json |
364
+ | errors.ImageRequestValidationError | 422 | application/json |
365
+ | errors.APIError | 4XX, 5XX | \*/\* |
366
+
177
367
  ## delete
178
368
 
179
369
  Permanently delete an image by its ID.
@@ -144,7 +144,10 @@ async function run() {
144
144
  {
145
145
  name: "Strawberry puree",
146
146
  description: "Fresh and fruity.",
147
- priceModifier: "0.99",
147
+ priceModifier: {
148
+ currency: "USD",
149
+ valueDecimal: "0.99",
150
+ },
148
151
  images: [
149
152
  {
150
153
  imageID: "d359808d-9896-4414-8d17-dac43f35842d",
@@ -153,11 +156,17 @@ async function run() {
153
156
  },
154
157
  {
155
158
  name: "Passionfruit syrup",
156
- priceModifier: "0.49",
159
+ priceModifier: {
160
+ currency: "USD",
161
+ valueDecimal: "0.49",
162
+ },
157
163
  },
158
164
  {
159
165
  name: "Cherry syrup",
160
- priceModifier: "0.49",
166
+ priceModifier: {
167
+ currency: "USD",
168
+ valueDecimal: "0.49",
169
+ },
161
170
  },
162
171
  ],
163
172
  },
@@ -172,7 +181,10 @@ async function run() {
172
181
  },
173
182
  {
174
183
  name: "Honey",
175
- priceModifier: "0.99",
184
+ priceModifier: {
185
+ currency: "USD",
186
+ valueDecimal: "0.99",
187
+ },
176
188
  },
177
189
  {
178
190
  name: "Stevia",
@@ -236,7 +248,10 @@ async function run() {
236
248
  {
237
249
  name: "Strawberry puree",
238
250
  description: "Fresh and fruity.",
239
- priceModifier: "0.99",
251
+ priceModifier: {
252
+ currency: "USD",
253
+ valueDecimal: "0.99",
254
+ },
240
255
  images: [
241
256
  {
242
257
  imageID: "d359808d-9896-4414-8d17-dac43f35842d",
@@ -245,11 +260,17 @@ async function run() {
245
260
  },
246
261
  {
247
262
  name: "Passionfruit syrup",
248
- priceModifier: "0.49",
263
+ priceModifier: {
264
+ currency: "USD",
265
+ valueDecimal: "0.49",
266
+ },
249
267
  },
250
268
  {
251
269
  name: "Cherry syrup",
252
- priceModifier: "0.49",
270
+ priceModifier: {
271
+ currency: "USD",
272
+ valueDecimal: "0.49",
273
+ },
253
274
  },
254
275
  ],
255
276
  },
@@ -264,7 +285,10 @@ async function run() {
264
285
  },
265
286
  {
266
287
  name: "Honey",
267
- priceModifier: "0.99",
288
+ priceModifier: {
289
+ currency: "USD",
290
+ valueDecimal: "0.99",
291
+ },
268
292
  },
269
293
  {
270
294
  name: "Stevia",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "..": {
20
20
  "name": "@moovio/sdk",
21
- "version": "0.16.5",
21
+ "version": "0.17.0",
22
22
  "dependencies": {
23
23
  "decimal.js": "^10.4.3",
24
24
  "zod": "^3.20.0"
@@ -0,0 +1,19 @@
1
+ import { MoovCore } from "../core.js";
2
+ import { RequestOptions } from "../lib/sdks.js";
3
+ import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/httpclienterrors.js";
4
+ import * as errors from "../models/errors/index.js";
5
+ import { MoovError } from "../models/errors/mooverror.js";
6
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
7
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
8
+ import * as operations from "../models/operations/index.js";
9
+ import { APIPromise } from "../types/async.js";
10
+ import { Result } from "../types/fp.js";
11
+ /**
12
+ * Update an existing image and/or its metadata.
13
+ *
14
+ * Duplicate images, and requests larger than 16MB will be rejected. Omit any
15
+ * form parts you do not wish to update. Existing metadata can be cleared by
16
+ * sending `null` for the `metadata` form part.
17
+ */
18
+ export declare function imagesUpdate(client: MoovCore, request: operations.UpdateImageRequest, options?: RequestOptions): APIPromise<Result<operations.UpdateImageResponse, errors.GenericError | errors.ImageRequestValidationError | MoovError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
19
+ //# sourceMappingURL=imagesUpdate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imagesUpdate.d.ts","sourceRoot":"","sources":["../src/funcs/imagesUpdate.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAStC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,KAAK,UAAU,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAW,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,QAAQ,EAChB,OAAO,EAAE,UAAU,CAAC,kBAAkB,EACtC,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CACX,MAAM,CACJ,UAAU,CAAC,mBAAmB,EAC5B,MAAM,CAAC,YAAY,GACnB,MAAM,CAAC,2BAA2B,GAClC,SAAS,GACT,uBAAuB,GACvB,eAAe,GACf,mBAAmB,GACnB,mBAAmB,GACnB,mBAAmB,GACnB,qBAAqB,GACrB,kBAAkB,CACrB,CACF,CAMA"}
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ /*
3
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.imagesUpdate = imagesUpdate;
40
+ const encodings_js_1 = require("../lib/encodings.js");
41
+ const files_js_1 = require("../lib/files.js");
42
+ const M = __importStar(require("../lib/matchers.js"));
43
+ const primitives_js_1 = require("../lib/primitives.js");
44
+ const schemas_js_1 = require("../lib/schemas.js");
45
+ const security_js_1 = require("../lib/security.js");
46
+ const url_js_1 = require("../lib/url.js");
47
+ const errors = __importStar(require("../models/errors/index.js"));
48
+ const operations = __importStar(require("../models/operations/index.js"));
49
+ const async_js_1 = require("../types/async.js");
50
+ const blobs_js_1 = require("../types/blobs.js");
51
+ const streams_js_1 = require("../types/streams.js");
52
+ /**
53
+ * Update an existing image and/or its metadata.
54
+ *
55
+ * Duplicate images, and requests larger than 16MB will be rejected. Omit any
56
+ * form parts you do not wish to update. Existing metadata can be cleared by
57
+ * sending `null` for the `metadata` form part.
58
+ */
59
+ function imagesUpdate(client, request, options) {
60
+ return new async_js_1.APIPromise($do(client, request, options));
61
+ }
62
+ async function $do(client, request, options) {
63
+ const parsed = (0, schemas_js_1.safeParse)(request, (value) => operations.UpdateImageRequest$outboundSchema.parse(value), "Input validation failed");
64
+ if (!parsed.ok) {
65
+ return [parsed, { status: "invalid" }];
66
+ }
67
+ const payload = parsed.value;
68
+ const body = new FormData();
69
+ if (payload.ImageUpdateRequestMultiPart.image !== undefined) {
70
+ if ((0, blobs_js_1.isBlobLike)(payload.ImageUpdateRequestMultiPart.image)) {
71
+ (0, encodings_js_1.appendForm)(body, "image", payload.ImageUpdateRequestMultiPart.image);
72
+ }
73
+ else if ((0, streams_js_1.isReadableStream)(payload.ImageUpdateRequestMultiPart.image.content)) {
74
+ const buffer = await (0, files_js_1.readableStreamToArrayBuffer)(payload.ImageUpdateRequestMultiPart.image.content);
75
+ const contentType = (0, files_js_1.getContentTypeFromFileName)(payload.ImageUpdateRequestMultiPart.image.fileName) || "application/octet-stream";
76
+ const blob = new Blob([buffer], { type: contentType });
77
+ (0, encodings_js_1.appendForm)(body, "image", blob, payload.ImageUpdateRequestMultiPart.image.fileName);
78
+ }
79
+ else {
80
+ const contentType = (0, files_js_1.getContentTypeFromFileName)(payload.ImageUpdateRequestMultiPart.image.fileName) || "application/octet-stream";
81
+ (0, encodings_js_1.appendForm)(body, "image", new Blob([payload.ImageUpdateRequestMultiPart.image.content], {
82
+ type: contentType,
83
+ }), payload.ImageUpdateRequestMultiPart.image.fileName);
84
+ }
85
+ }
86
+ if (payload.ImageUpdateRequestMultiPart.metadata !== undefined) {
87
+ (0, encodings_js_1.appendForm)(body, "metadata", (0, encodings_js_1.encodeJSON)("metadata", payload.ImageUpdateRequestMultiPart.metadata, {
88
+ explode: true,
89
+ }));
90
+ }
91
+ const pathParams = {
92
+ accountID: (0, encodings_js_1.encodeSimple)("accountID", payload.accountID, {
93
+ explode: false,
94
+ charEncoding: "percent",
95
+ }),
96
+ imageID: (0, encodings_js_1.encodeSimple)("imageID", payload.imageID, {
97
+ explode: false,
98
+ charEncoding: "percent",
99
+ }),
100
+ };
101
+ const path = (0, url_js_1.pathToFunc)("/accounts/{accountID}/images/{imageID}")(pathParams);
102
+ const headers = new Headers((0, primitives_js_1.compactMap)({
103
+ Accept: "application/json",
104
+ "x-moov-version": (0, encodings_js_1.encodeSimple)("x-moov-version", client._options.xMoovVersion, { explode: false, charEncoding: "none" }),
105
+ }));
106
+ const securityInput = await (0, security_js_1.extractSecurity)(client._options.security);
107
+ const requestSecurity = (0, security_js_1.resolveGlobalSecurity)(securityInput);
108
+ const context = {
109
+ options: client._options,
110
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
111
+ operationID: "updateImage",
112
+ oAuth2Scopes: null,
113
+ resolvedSecurity: requestSecurity,
114
+ securitySource: client._options.security,
115
+ retryConfig: options?.retries
116
+ || client._options.retryConfig
117
+ || { strategy: "none" },
118
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
119
+ };
120
+ const requestRes = client._createRequest(context, {
121
+ security: requestSecurity,
122
+ method: "PATCH",
123
+ baseURL: options?.serverURL,
124
+ path: path,
125
+ headers: headers,
126
+ body: body,
127
+ userAgent: client._options.userAgent,
128
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
129
+ }, options);
130
+ if (!requestRes.ok) {
131
+ return [requestRes, { status: "invalid" }];
132
+ }
133
+ const req = requestRes.value;
134
+ const doResult = await client._do(req, {
135
+ context,
136
+ errorCodes: [
137
+ "400",
138
+ "401",
139
+ "403",
140
+ "404",
141
+ "409",
142
+ "422",
143
+ "429",
144
+ "4XX",
145
+ "500",
146
+ "504",
147
+ "5XX",
148
+ ],
149
+ retryConfig: context.retryConfig,
150
+ retryCodes: context.retryCodes,
151
+ });
152
+ if (!doResult.ok) {
153
+ return [doResult, { status: "request-error", request: req }];
154
+ }
155
+ const response = doResult.value;
156
+ const responseFields = {
157
+ HttpMeta: { Response: response, Request: req },
158
+ };
159
+ const [result] = await M.match(M.json(200, operations.UpdateImageResponse$inboundSchema, {
160
+ hdrs: true,
161
+ key: "Result",
162
+ }), M.jsonErr([400, 409], errors.GenericError$inboundSchema, { hdrs: true }), M.jsonErr(422, errors.ImageRequestValidationError$inboundSchema, {
163
+ hdrs: true,
164
+ }), M.fail([401, 403, 404, 429]), M.fail([500, 504]), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
165
+ if (!result.ok) {
166
+ return [result, { status: "complete", request: req, response }];
167
+ }
168
+ return [result, { status: "complete", request: req, response }];
169
+ }
170
+ //# sourceMappingURL=imagesUpdate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imagesUpdate.js","sourceRoot":"","sources":["../src/funcs/imagesUpdate.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCH,oCAwBC;AA3DD,sDAA2E;AAC3E,8CAGyB;AACzB,sDAAwC;AACxC,wDAAkD;AAClD,kDAA8C;AAE9C,oDAA4E;AAC5E,0CAA2C;AAQ3C,kEAAoD;AAIpD,0EAA4D;AAC5D,gDAAwD;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AAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,yCAAyC,EAAE;QAC/D,IAAI,EAAE,IAAI;KACX,CAAC,EACF,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,EAC5B,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,EAClB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EACb,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CACd,CAAC,QAAQ,EAAE,GAAG,EAAE,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC,CAAC;IAClD,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,OAAO,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,OAAO,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;AAClE,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { MoovCore } from "../core.js";
2
+ import { RequestOptions } from "../lib/sdks.js";
3
+ import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/httpclienterrors.js";
4
+ import * as errors from "../models/errors/index.js";
5
+ import { MoovError } from "../models/errors/mooverror.js";
6
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
7
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
8
+ import * as operations from "../models/operations/index.js";
9
+ import { APIPromise } from "../types/async.js";
10
+ import { Result } from "../types/fp.js";
11
+ /**
12
+ * Upload a new PNG, JPEG, or WebP image with optional metadata.
13
+ * Duplicate images, and requests larger than 16MB will be rejected.
14
+ */
15
+ export declare function imagesUpload(client: MoovCore, request: operations.UploadImageRequest, options?: RequestOptions): APIPromise<Result<operations.UploadImageResponse, errors.GenericError | errors.ImageRequestValidationError | MoovError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
16
+ //# sourceMappingURL=imagesUpload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imagesUpload.d.ts","sourceRoot":"","sources":["../src/funcs/imagesUpload.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAStC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,KAAK,UAAU,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAW,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,QAAQ,EAChB,OAAO,EAAE,UAAU,CAAC,kBAAkB,EACtC,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CACX,MAAM,CACJ,UAAU,CAAC,mBAAmB,EAC5B,MAAM,CAAC,YAAY,GACnB,MAAM,CAAC,2BAA2B,GAClC,SAAS,GACT,uBAAuB,GACvB,eAAe,GACf,mBAAmB,GACnB,mBAAmB,GACnB,mBAAmB,GACnB,qBAAqB,GACrB,kBAAkB,CACrB,CACF,CAMA"}