@wix/auto_sdk_stores_inventory 1.0.63 → 1.0.65

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 (49) hide show
  1. package/build/cjs/index.d.ts +34 -24
  2. package/build/cjs/index.js +417 -176
  3. package/build/cjs/index.js.map +1 -1
  4. package/build/cjs/index.typings.d.ts +197 -197
  5. package/build/cjs/index.typings.js +394 -153
  6. package/build/cjs/index.typings.js.map +1 -1
  7. package/build/cjs/meta.d.ts +178 -178
  8. package/build/cjs/meta.js +140 -140
  9. package/build/cjs/meta.js.map +1 -1
  10. package/build/cjs/schemas.d.ts +63 -63
  11. package/build/cjs/schemas.js +100 -100
  12. package/build/cjs/schemas.js.map +1 -1
  13. package/build/es/index.d.mts +34 -24
  14. package/build/es/index.mjs +407 -176
  15. package/build/es/index.mjs.map +1 -1
  16. package/build/es/index.typings.d.mts +197 -197
  17. package/build/es/index.typings.mjs +384 -153
  18. package/build/es/index.typings.mjs.map +1 -1
  19. package/build/es/meta.d.mts +178 -178
  20. package/build/es/meta.mjs +140 -140
  21. package/build/es/meta.mjs.map +1 -1
  22. package/build/es/schemas.d.mts +63 -63
  23. package/build/es/schemas.mjs +100 -100
  24. package/build/es/schemas.mjs.map +1 -1
  25. package/build/internal/cjs/index.d.ts +34 -24
  26. package/build/internal/cjs/index.js +417 -176
  27. package/build/internal/cjs/index.js.map +1 -1
  28. package/build/internal/cjs/index.typings.d.ts +230 -230
  29. package/build/internal/cjs/index.typings.js +394 -153
  30. package/build/internal/cjs/index.typings.js.map +1 -1
  31. package/build/internal/cjs/meta.d.ts +178 -178
  32. package/build/internal/cjs/meta.js +140 -140
  33. package/build/internal/cjs/meta.js.map +1 -1
  34. package/build/internal/cjs/schemas.d.ts +63 -63
  35. package/build/internal/cjs/schemas.js +100 -100
  36. package/build/internal/cjs/schemas.js.map +1 -1
  37. package/build/internal/es/index.d.mts +34 -24
  38. package/build/internal/es/index.mjs +407 -176
  39. package/build/internal/es/index.mjs.map +1 -1
  40. package/build/internal/es/index.typings.d.mts +230 -230
  41. package/build/internal/es/index.typings.mjs +384 -153
  42. package/build/internal/es/index.typings.mjs.map +1 -1
  43. package/build/internal/es/meta.d.mts +178 -178
  44. package/build/internal/es/meta.mjs +140 -140
  45. package/build/internal/es/meta.mjs.map +1 -1
  46. package/build/internal/es/schemas.d.mts +63 -63
  47. package/build/internal/es/schemas.mjs +100 -100
  48. package/build/internal/es/schemas.mjs.map +1 -1
  49. package/package.json +2 -2
@@ -10,67 +10,6 @@ import { transformSDKTimestampToRESTTimestamp } from "@wix/sdk-runtime/transform
10
10
  import { transformRESTTimestampToSDKTimestamp } from "@wix/sdk-runtime/transformations/timestamp";
11
11
  import { transformPaths } from "@wix/sdk-runtime/transformations/transform-paths";
12
12
  import { resolveUrl } from "@wix/sdk-runtime/rest-modules";
13
- function resolveWixInventoryApiV1InventoryReadApiUrl(opts) {
14
- const domainToMappings = {
15
- "api._api_base_domain_": [
16
- {
17
- srcPath: "/wix-ecommerce-catalog-reader-web",
18
- destPath: ""
19
- }
20
- ],
21
- "manage._base_domain_": [
22
- {
23
- srcPath: "/wix-ecommerce-catalog-reader-web",
24
- destPath: ""
25
- }
26
- ],
27
- "www.wixapis.com": [
28
- {
29
- srcPath: "/stores-reader/v2/collections",
30
- destPath: "/v2/collections"
31
- },
32
- {
33
- srcPath: "/stores-reader/v2/inventoryItems",
34
- destPath: "/v2/inventoryItems"
35
- }
36
- ],
37
- "www._base_domain_": [
38
- {
39
- srcPath: "/wix-ecommerce-catalog-reader-web",
40
- destPath: ""
41
- }
42
- ],
43
- "editor._base_domain_": [
44
- {
45
- srcPath: "/_api/wix-ecommerce-catalog-reader-web",
46
- destPath: ""
47
- }
48
- ],
49
- "blocks._base_domain_": [
50
- {
51
- srcPath: "/_api/wix-ecommerce-catalog-reader-web",
52
- destPath: ""
53
- }
54
- ],
55
- "create.editorx": [
56
- {
57
- srcPath: "/_api/wix-ecommerce-catalog-reader-web",
58
- destPath: ""
59
- }
60
- ],
61
- _: [
62
- {
63
- srcPath: "/stores-reader/v2/inventoryItems",
64
- destPath: "/v2/inventoryItems"
65
- },
66
- {
67
- srcPath: "/stores-reader/v2/collections",
68
- destPath: "/v2/collections"
69
- }
70
- ]
71
- };
72
- return resolveUrl(Object.assign(opts, { domainToMappings }));
73
- }
74
13
  function resolveWixInventoryApiV1InventoryWriteApiUrl(opts) {
75
14
  const domainToMappings = {
76
15
  "api._api_base_domain_": [
@@ -154,7 +93,122 @@ function resolveWixInventoryApiV1InventoryWriteApiUrl(opts) {
154
93
  };
155
94
  return resolveUrl(Object.assign(opts, { domainToMappings }));
156
95
  }
96
+ function resolveWixInventoryApiV1InventoryReadApiUrl(opts) {
97
+ const domainToMappings = {
98
+ "api._api_base_domain_": [
99
+ {
100
+ srcPath: "/wix-ecommerce-catalog-reader-web",
101
+ destPath: ""
102
+ }
103
+ ],
104
+ "manage._base_domain_": [
105
+ {
106
+ srcPath: "/wix-ecommerce-catalog-reader-web",
107
+ destPath: ""
108
+ }
109
+ ],
110
+ "www.wixapis.com": [
111
+ {
112
+ srcPath: "/stores-reader/v2/collections",
113
+ destPath: "/v2/collections"
114
+ },
115
+ {
116
+ srcPath: "/stores-reader/v2/inventoryItems",
117
+ destPath: "/v2/inventoryItems"
118
+ }
119
+ ],
120
+ "www._base_domain_": [
121
+ {
122
+ srcPath: "/wix-ecommerce-catalog-reader-web",
123
+ destPath: ""
124
+ }
125
+ ],
126
+ "editor._base_domain_": [
127
+ {
128
+ srcPath: "/_api/wix-ecommerce-catalog-reader-web",
129
+ destPath: ""
130
+ }
131
+ ],
132
+ "blocks._base_domain_": [
133
+ {
134
+ srcPath: "/_api/wix-ecommerce-catalog-reader-web",
135
+ destPath: ""
136
+ }
137
+ ],
138
+ "create.editorx": [
139
+ {
140
+ srcPath: "/_api/wix-ecommerce-catalog-reader-web",
141
+ destPath: ""
142
+ }
143
+ ],
144
+ _: [
145
+ {
146
+ srcPath: "/stores-reader/v2/inventoryItems",
147
+ destPath: "/v2/inventoryItems"
148
+ },
149
+ {
150
+ srcPath: "/stores-reader/v2/collections",
151
+ destPath: "/v2/collections"
152
+ }
153
+ ]
154
+ };
155
+ return resolveUrl(Object.assign(opts, { domainToMappings }));
156
+ }
157
157
  var PACKAGE_NAME = "@wix/auto_sdk_stores_inventory";
158
+ function getInventoryVariants(payload) {
159
+ function __getInventoryVariants({ host }) {
160
+ const metadata = {
161
+ entityFqdn: "wix.stores.v2.inventory",
162
+ method: "POST",
163
+ methodFqn: "wix.inventory.api.v1.InventoryReadApi.GetInventoryVariants",
164
+ packageName: PACKAGE_NAME,
165
+ migrationOptions: {
166
+ optInTransformResponse: true
167
+ },
168
+ url: resolveWixInventoryApiV1InventoryReadApiUrl({
169
+ protoPath: "/v2/inventoryItems/{inventoryId}/getVariants",
170
+ data: payload,
171
+ host
172
+ }),
173
+ data: payload,
174
+ transformResponse: (payload2) => transformPaths(payload2, [
175
+ {
176
+ transformFn: transformRESTTimestampToSDKTimestamp,
177
+ paths: [{ path: "inventoryItem.lastUpdated" }]
178
+ }
179
+ ])
180
+ };
181
+ return metadata;
182
+ }
183
+ return __getInventoryVariants;
184
+ }
185
+ function queryInventory(payload) {
186
+ function __queryInventory({ host }) {
187
+ const metadata = {
188
+ entityFqdn: "wix.stores.v2.inventory",
189
+ method: "POST",
190
+ methodFqn: "wix.inventory.api.v1.InventoryReadApi.QueryInventory",
191
+ packageName: PACKAGE_NAME,
192
+ migrationOptions: {
193
+ optInTransformResponse: true
194
+ },
195
+ url: resolveWixInventoryApiV1InventoryReadApiUrl({
196
+ protoPath: "/v2/inventoryItems/query",
197
+ data: payload,
198
+ host
199
+ }),
200
+ data: payload,
201
+ transformResponse: (payload2) => transformPaths(payload2, [
202
+ {
203
+ transformFn: transformRESTTimestampToSDKTimestamp,
204
+ paths: [{ path: "inventoryItems.lastUpdated" }]
205
+ }
206
+ ])
207
+ };
208
+ return metadata;
209
+ }
210
+ return __queryInventory;
211
+ }
158
212
  function updateInventoryVariants(payload) {
159
213
  function __updateInventoryVariants({ host }) {
160
214
  const serializedData = transformPaths(payload, [
@@ -224,60 +278,222 @@ function incrementInventory(payload) {
224
278
  }
225
279
  return __incrementInventory;
226
280
  }
227
- function getInventoryVariants(payload) {
228
- function __getInventoryVariants({ host }) {
229
- const metadata = {
230
- entityFqdn: "wix.stores.v2.inventory",
231
- method: "POST",
232
- methodFqn: "wix.inventory.api.v1.InventoryReadApi.GetInventoryVariants",
233
- packageName: PACKAGE_NAME,
234
- migrationOptions: {
235
- optInTransformResponse: true
236
- },
237
- url: resolveWixInventoryApiV1InventoryReadApiUrl({
238
- protoPath: "/v2/inventoryItems/{inventoryId}/getVariants",
239
- data: payload,
240
- host
281
+
282
+ // src/stores-v2-inventory-inventory.schemas.ts
283
+ import * as z from "zod";
284
+ var GetInventoryVariantsRequest = z.object({
285
+ inventoryId: z.string().describe("Inventory item ID."),
286
+ options: z.intersection(
287
+ z.object({ variantIds: z.array(z.string()).optional() }),
288
+ z.xor([
289
+ z.object({
290
+ inventoryId: z.never().optional(),
291
+ externalId: z.never().optional(),
292
+ productId: z.never().optional()
241
293
  }),
242
- data: payload,
243
- transformResponse: (payload2) => transformPaths(payload2, [
244
- {
245
- transformFn: transformRESTTimestampToSDKTimestamp,
246
- paths: [{ path: "inventoryItem.lastUpdated" }]
247
- }
294
+ z.object({
295
+ externalId: z.never().optional(),
296
+ productId: z.never().optional(),
297
+ inventoryId: z.string().describe("Inventory item ID.")
298
+ }),
299
+ z.object({
300
+ inventoryId: z.never().optional(),
301
+ productId: z.never().optional(),
302
+ externalId: z.string().describe("Deprecated (use productID instead).")
303
+ }),
304
+ z.object({
305
+ inventoryId: z.never().optional(),
306
+ externalId: z.never().optional(),
307
+ productId: z.string().describe("Product ID.")
308
+ })
309
+ ])
310
+ ).optional()
311
+ });
312
+ var GetInventoryVariantsResponse = z.object({
313
+ inventoryItem: z.object({
314
+ _id: z.string().describe("Inventory item ID.").optional().nullable(),
315
+ externalId: z.string().describe("Deprecated: use productId.").optional().nullable(),
316
+ productId: z.string().describe("Product ID.").optional().nullable(),
317
+ trackQuantity: z.boolean().describe("Whether quantity is being tracked.").optional().nullable(),
318
+ variants: z.array(
319
+ z.object({
320
+ variantId: z.string().describe("Variant ID.").optional(),
321
+ inStock: z.boolean().describe("Whether the product is listed as in stock.").optional().nullable(),
322
+ quantity: z.number().int().describe("Quantity currently left in inventory.").min(0).optional().nullable(),
323
+ availableForPreorder: z.boolean().describe(
324
+ "Whether the variant is available for preorder. When `true`, the variant is out of stock and preorder is enabled on inventory level."
325
+ ).optional()
326
+ })
327
+ ).optional(),
328
+ lastUpdated: z.date().describe("Last updated timestamp.").optional().nullable(),
329
+ numericId: z.string().regex(/^\d+$/, "Must be a valid UInt64 string").describe(
330
+ "Inventory\u2019s unique numeric ID (assigned in ascending order).\nPrimarily for sorting and filtering when crawling all inventories."
331
+ ).optional(),
332
+ preorderInfo: z.object({
333
+ enabled: z.boolean().describe("Whether the item is available for preorder.").optional(),
334
+ message: z.string().describe(
335
+ "A message the buyer will see when the item is out of stock and preorder is enabled."
336
+ ).min(1).max(250).optional().nullable(),
337
+ limit: z.number().int().describe(
338
+ "Number of products that can be preordered after stock reaches zero."
339
+ ).min(0).max(1e5).optional().nullable()
340
+ }).describe("Preorder information.").optional()
341
+ }).describe("Inventory item.").optional()
342
+ });
343
+ var QueryInventoryRequest = z.object({
344
+ options: z.object({
345
+ query: z.object({
346
+ paging: z.object({
347
+ limit: z.number().int().describe("Amount of items to load per page").min(0).max(100).optional().nullable(),
348
+ offset: z.number().int().describe(
349
+ "Number of items to skip in the display (relevant for all pages after the first)"
350
+ ).min(0).optional().nullable()
351
+ }).optional(),
352
+ filter: z.string().describe("Filter string").optional().nullable(),
353
+ sort: z.string().describe("Sort string").optional().nullable()
354
+ }).optional()
355
+ }).optional()
356
+ });
357
+ var QueryInventoryResponse = z.object({
358
+ inventoryItems: z.array(
359
+ z.object({
360
+ _id: z.string().describe("Inventory item ID.").optional().nullable(),
361
+ externalId: z.string().describe("Deprecated: use productId.").optional().nullable(),
362
+ productId: z.string().describe("Product ID.").optional().nullable(),
363
+ trackQuantity: z.boolean().describe("Whether quantity is being tracked.").optional().nullable(),
364
+ variants: z.array(
365
+ z.object({
366
+ variantId: z.string().describe("Variant ID.").optional(),
367
+ inStock: z.boolean().describe("Whether the product is listed as in stock.").optional().nullable(),
368
+ quantity: z.number().int().describe("Quantity currently left in inventory.").min(0).optional().nullable(),
369
+ availableForPreorder: z.boolean().describe(
370
+ "Whether the variant is available for preorder. When `true`, the variant is out of stock and preorder is enabled on inventory level."
371
+ ).optional()
372
+ })
373
+ ).optional(),
374
+ lastUpdated: z.date().describe("Last updated timestamp.").optional().nullable(),
375
+ numericId: z.string().regex(/^\d+$/, "Must be a valid UInt64 string").describe(
376
+ "Inventory\u2019s unique numeric ID (assigned in ascending order).\nPrimarily for sorting and filtering when crawling all inventories."
377
+ ).optional(),
378
+ preorderInfo: z.object({
379
+ enabled: z.boolean().describe("Whether the item is available for preorder.").optional(),
380
+ message: z.string().describe(
381
+ "A message the buyer will see when the item is out of stock and preorder is enabled."
382
+ ).min(1).max(250).optional().nullable(),
383
+ limit: z.number().int().describe(
384
+ "Number of products that can be preordered after stock reaches zero."
385
+ ).min(0).max(1e5).optional().nullable()
386
+ }).describe("Preorder information.").optional()
387
+ })
388
+ ).optional(),
389
+ metadata: z.object({
390
+ items: z.number().int().describe("Amount of items to load per page").optional(),
391
+ offset: z.number().int().describe(
392
+ "Number of items to skip in the display (relevant for all pages after the first)"
393
+ ).optional()
394
+ }).describe("Display metadata.").optional(),
395
+ totalResults: z.number().int().describe("Number of total results.").optional()
396
+ });
397
+ var UpdateInventoryVariantsRequest = z.object({
398
+ productId: z.string().describe("Product ID."),
399
+ inventoryItem: z.object({
400
+ _id: z.string().describe("Inventory item ID.").optional().nullable(),
401
+ externalId: z.string().describe("Deprecated: use productId.").optional().nullable(),
402
+ productId: z.string().describe("Product ID.").optional().nullable(),
403
+ trackQuantity: z.boolean().describe("Whether quantity is being tracked.").optional().nullable(),
404
+ variants: z.array(
405
+ z.object({
406
+ variantId: z.string().describe("Variant ID.").optional(),
407
+ inStock: z.boolean().describe("Whether the product is listed as in stock.").optional().nullable(),
408
+ quantity: z.number().int().describe("Quantity currently left in inventory.").min(0).optional().nullable(),
409
+ availableForPreorder: z.boolean().describe(
410
+ "Whether the variant is available for preorder. When `true`, the variant is out of stock and preorder is enabled on inventory level."
411
+ ).optional()
412
+ })
413
+ ).optional(),
414
+ lastUpdated: z.date().describe("Last updated timestamp.").optional().nullable(),
415
+ numericId: z.string().regex(/^\d+$/, "Must be a valid UInt64 string").describe(
416
+ "Inventory\u2019s unique numeric ID (assigned in ascending order).\nPrimarily for sorting and filtering when crawling all inventories."
417
+ ).optional(),
418
+ preorderInfo: z.object({
419
+ enabled: z.boolean().describe("Whether the item is available for preorder.").optional(),
420
+ message: z.string().describe(
421
+ "A message the buyer will see when the item is out of stock and preorder is enabled."
422
+ ).min(1).max(250).optional().nullable(),
423
+ limit: z.number().int().describe(
424
+ "Number of products that can be preordered after stock reaches zero."
425
+ ).min(0).max(1e5).optional().nullable()
426
+ }).describe("Preorder information.").optional()
427
+ }).describe("Inventory item to update.")
428
+ });
429
+ var UpdateInventoryVariantsResponse = z.object({});
430
+ var DecrementInventoryRequest = z.object({
431
+ decrementData: z.array(
432
+ z.intersection(
433
+ z.object({
434
+ variantId: z.string().describe("Variant ID.").regex(
435
+ /^[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}$/,
436
+ "Must be a valid GUID"
437
+ ).optional(),
438
+ decrementBy: z.number().int().describe("Number to decrement inventory by.").min(1).optional(),
439
+ preorderRequest: z.boolean().describe(
440
+ "Whether the request to decrement the item's inventory was made as part of a purchase that includes preorder items.\nIf true and the item is available for preorder, we allow negative inventory.\nIf false and the item is not available for preorder, we allow regular buy flow (no negative inventory)."
441
+ ).optional()
442
+ }),
443
+ z.xor([
444
+ z.object({
445
+ inventoryId: z.never().optional(),
446
+ externalId: z.never().optional(),
447
+ productId: z.never().optional()
448
+ }),
449
+ z.object({
450
+ externalId: z.never().optional(),
451
+ productId: z.never().optional(),
452
+ inventoryId: z.string().describe("Inventory item ID.").max(36)
453
+ }),
454
+ z.object({
455
+ inventoryId: z.never().optional(),
456
+ productId: z.never().optional(),
457
+ externalId: z.string().describe("Deprecated: use productId.").max(36)
458
+ }),
459
+ z.object({
460
+ inventoryId: z.never().optional(),
461
+ externalId: z.never().optional(),
462
+ productId: z.string().describe("Product ID.").max(36)
463
+ })
248
464
  ])
249
- };
250
- return metadata;
251
- }
252
- return __getInventoryVariants;
253
- }
254
- function queryInventory(payload) {
255
- function __queryInventory({ host }) {
256
- const metadata = {
257
- entityFqdn: "wix.stores.v2.inventory",
258
- method: "POST",
259
- methodFqn: "wix.inventory.api.v1.InventoryReadApi.QueryInventory",
260
- packageName: PACKAGE_NAME,
261
- migrationOptions: {
262
- optInTransformResponse: true
263
- },
264
- url: resolveWixInventoryApiV1InventoryReadApiUrl({
265
- protoPath: "/v2/inventoryItems/query",
266
- data: payload,
267
- host
465
+ )
466
+ ).min(1).max(300)
467
+ });
468
+ var DecrementInventoryResponse = z.object({});
469
+ var IncrementInventoryRequest = z.object({
470
+ incrementData: z.array(
471
+ z.intersection(
472
+ z.object({
473
+ variantId: z.string().describe("Variant ID.").regex(
474
+ /^[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}$/,
475
+ "Must be a valid GUID"
476
+ ).optional(),
477
+ incrementBy: z.number().int().describe("Number to increment inventory by.").min(1).optional()
268
478
  }),
269
- data: payload,
270
- transformResponse: (payload2) => transformPaths(payload2, [
271
- {
272
- transformFn: transformRESTTimestampToSDKTimestamp,
273
- paths: [{ path: "inventoryItems.lastUpdated" }]
274
- }
479
+ z.xor([
480
+ z.object({
481
+ inventoryId: z.never().optional(),
482
+ productId: z.never().optional()
483
+ }),
484
+ z.object({
485
+ productId: z.never().optional(),
486
+ inventoryId: z.string().describe("Inventory item ID.").max(36)
487
+ }),
488
+ z.object({
489
+ inventoryId: z.never().optional(),
490
+ productId: z.string().describe("Product ID.").max(36)
491
+ })
275
492
  ])
276
- };
277
- return metadata;
278
- }
279
- return __queryInventory;
280
- }
493
+ )
494
+ ).min(1).max(300)
495
+ });
496
+ var IncrementInventoryResponse = z.object({});
281
497
 
282
498
  // src/stores-v2-inventory-inventory.universal.ts
283
499
  var ReasonType = /* @__PURE__ */ ((ReasonType2) => {
@@ -295,60 +511,79 @@ var WebhookIdentityType = /* @__PURE__ */ ((WebhookIdentityType2) => {
295
511
  WebhookIdentityType2["APP"] = "APP";
296
512
  return WebhookIdentityType2;
297
513
  })(WebhookIdentityType || {});
298
- async function updateInventoryVariants2(productId, inventoryItem) {
299
- const { httpClient, sideEffects } = arguments[2];
514
+ async function getInventoryVariants2(inventoryId, options) {
515
+ const { httpClient, sideEffects, validateRequestSchema } = arguments[2];
516
+ if (validateRequestSchema) {
517
+ GetInventoryVariantsRequest.parse({ inventoryId, options });
518
+ }
300
519
  const payload = renameKeysFromSDKRequestToRESTRequest({
301
- inventoryItem: { ...inventoryItem, productId }
520
+ inventoryId,
521
+ externalId: options?.externalId,
522
+ productId: options?.productId,
523
+ variantIds: options?.variantIds
302
524
  });
303
- const reqOpts = updateInventoryVariants(payload);
525
+ const reqOpts = getInventoryVariants(payload);
304
526
  sideEffects?.onSiteCall?.();
305
527
  try {
306
528
  const result = await httpClient.request(reqOpts);
307
529
  sideEffects?.onSuccess?.(result);
530
+ return renameKeysFromRESTResponseToSDKResponse(result.data);
308
531
  } catch (err) {
309
532
  const transformedError = sdkTransformError(
310
533
  err,
311
534
  {
312
- spreadPathsToArguments: { inventoryItem: "$[1]" },
313
- explicitPathsToArguments: { "inventoryItem.productId": "$[0]" },
535
+ spreadPathsToArguments: {},
536
+ explicitPathsToArguments: {
537
+ inventoryId: "$[0]",
538
+ externalId: "$[1].externalId",
539
+ productId: "$[1].productId",
540
+ variantIds: "$[1].variantIds"
541
+ },
314
542
  singleArgumentUnchanged: false
315
543
  },
316
- ["productId", "inventoryItem"]
544
+ ["inventoryId", "options"]
317
545
  );
318
546
  sideEffects?.onError?.(err);
319
547
  throw transformedError;
320
548
  }
321
549
  }
322
- async function decrementInventory2(decrementData) {
323
- const { httpClient, sideEffects } = arguments[1];
550
+ async function queryInventory2(options) {
551
+ const { httpClient, sideEffects, validateRequestSchema } = arguments[1];
552
+ if (validateRequestSchema) {
553
+ QueryInventoryRequest.parse({ options });
554
+ }
324
555
  const payload = renameKeysFromSDKRequestToRESTRequest({
325
- decrementData
556
+ query: options?.query
326
557
  });
327
- const reqOpts = decrementInventory(payload);
558
+ const reqOpts = queryInventory(payload);
328
559
  sideEffects?.onSiteCall?.();
329
560
  try {
330
561
  const result = await httpClient.request(reqOpts);
331
562
  sideEffects?.onSuccess?.(result);
563
+ return renameKeysFromRESTResponseToSDKResponse(result.data);
332
564
  } catch (err) {
333
565
  const transformedError = sdkTransformError(
334
566
  err,
335
567
  {
336
568
  spreadPathsToArguments: {},
337
- explicitPathsToArguments: { decrementData: "$[0]" },
569
+ explicitPathsToArguments: { query: "$[0].query" },
338
570
  singleArgumentUnchanged: false
339
571
  },
340
- ["decrementData"]
572
+ ["options"]
341
573
  );
342
574
  sideEffects?.onError?.(err);
343
575
  throw transformedError;
344
576
  }
345
577
  }
346
- async function incrementInventory2(incrementData) {
347
- const { httpClient, sideEffects } = arguments[1];
578
+ async function updateInventoryVariants2(productId, inventoryItem) {
579
+ const { httpClient, sideEffects, validateRequestSchema } = arguments[2];
580
+ if (validateRequestSchema) {
581
+ UpdateInventoryVariantsRequest.parse({ productId, inventoryItem });
582
+ }
348
583
  const payload = renameKeysFromSDKRequestToRESTRequest({
349
- incrementData
584
+ inventoryItem: { ...inventoryItem, productId }
350
585
  });
351
- const reqOpts = incrementInventory(payload);
586
+ const reqOpts = updateInventoryVariants(payload);
352
587
  sideEffects?.onSiteCall?.();
353
588
  try {
354
589
  const result = await httpClient.request(reqOpts);
@@ -357,69 +592,65 @@ async function incrementInventory2(incrementData) {
357
592
  const transformedError = sdkTransformError(
358
593
  err,
359
594
  {
360
- spreadPathsToArguments: {},
361
- explicitPathsToArguments: { incrementData: "$[0]" },
595
+ spreadPathsToArguments: { inventoryItem: "$[1]" },
596
+ explicitPathsToArguments: { "inventoryItem.productId": "$[0]" },
362
597
  singleArgumentUnchanged: false
363
598
  },
364
- ["incrementData"]
599
+ ["productId", "inventoryItem"]
365
600
  );
366
601
  sideEffects?.onError?.(err);
367
602
  throw transformedError;
368
603
  }
369
604
  }
370
- async function getInventoryVariants2(inventoryId, options) {
371
- const { httpClient, sideEffects } = arguments[2];
605
+ async function decrementInventory2(decrementData) {
606
+ const { httpClient, sideEffects, validateRequestSchema } = arguments[1];
607
+ if (validateRequestSchema) {
608
+ DecrementInventoryRequest.parse({ decrementData });
609
+ }
372
610
  const payload = renameKeysFromSDKRequestToRESTRequest({
373
- inventoryId,
374
- externalId: options?.externalId,
375
- productId: options?.productId,
376
- variantIds: options?.variantIds
611
+ decrementData
377
612
  });
378
- const reqOpts = getInventoryVariants(payload);
613
+ const reqOpts = decrementInventory(payload);
379
614
  sideEffects?.onSiteCall?.();
380
615
  try {
381
616
  const result = await httpClient.request(reqOpts);
382
617
  sideEffects?.onSuccess?.(result);
383
- return renameKeysFromRESTResponseToSDKResponse(result.data);
384
618
  } catch (err) {
385
619
  const transformedError = sdkTransformError(
386
620
  err,
387
621
  {
388
622
  spreadPathsToArguments: {},
389
- explicitPathsToArguments: {
390
- inventoryId: "$[0]",
391
- externalId: "$[1].externalId",
392
- productId: "$[1].productId",
393
- variantIds: "$[1].variantIds"
394
- },
623
+ explicitPathsToArguments: { decrementData: "$[0]" },
395
624
  singleArgumentUnchanged: false
396
625
  },
397
- ["inventoryId", "options"]
626
+ ["decrementData"]
398
627
  );
399
628
  sideEffects?.onError?.(err);
400
629
  throw transformedError;
401
630
  }
402
631
  }
403
- async function queryInventory2(options) {
404
- const { httpClient, sideEffects } = arguments[1];
632
+ async function incrementInventory2(incrementData) {
633
+ const { httpClient, sideEffects, validateRequestSchema } = arguments[1];
634
+ if (validateRequestSchema) {
635
+ IncrementInventoryRequest.parse({ incrementData });
636
+ }
405
637
  const payload = renameKeysFromSDKRequestToRESTRequest({
406
- query: options?.query
638
+ incrementData
407
639
  });
408
- const reqOpts = queryInventory(payload);
640
+ const reqOpts = incrementInventory(payload);
409
641
  sideEffects?.onSiteCall?.();
410
642
  try {
411
643
  const result = await httpClient.request(reqOpts);
412
644
  sideEffects?.onSuccess?.(result);
413
- return renameKeysFromRESTResponseToSDKResponse(result.data);
414
645
  } catch (err) {
415
646
  const transformedError = sdkTransformError(
416
647
  err,
417
648
  {
418
649
  spreadPathsToArguments: {},
419
- explicitPathsToArguments: { query: "$[0].query" },
650
+ explicitPathsToArguments: { incrementData: "$[0]" },
420
651
  singleArgumentUnchanged: false
421
652
  },
422
- ["options"]
653
+ ["incrementData"]
423
654
  );
424
655
  sideEffects?.onError?.(err);
425
656
  throw transformedError;