@wix/auto_sdk_stores_inventory 1.0.64 → 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.
@@ -2,7 +2,9 @@ import { HttpClient, NonNullablePaths, EventDefinition, MaybeContext, BuildRESTF
2
2
  import { GetInventoryVariantsOptions, GetInventoryVariantsResponse, QueryInventoryOptions, QueryInventoryResponse, UpdateInventoryVariantsInventoryItem, DecrementData, IncrementData, InventoryItemChangedEnvelope, InventoryVariantsChangedEnvelope } from './index.typings.js';
3
3
  export { AccountInfo, BaseEventMetadata, BulkUpdateInventoryItemsRequest, BulkUpdateInventoryItemsResponse, BulkUpdateInventoryVariantsRequest, BulkUpdateInventoryVariantsRequestActionOneOf, BulkUpdateInventoryVariantsResponse, ChangedInventoryVariant, ChangedInventoryVariantData, DecrementDataIdOneOf, DecrementInventoryRequest, DecrementInventoryResponse, GetInventoryItemsRequest, GetInventoryItemsResponse, GetInventoryVariantsOptionsIdOneOf, GetInventoryVariantsRequest, GetInventoryVariantsRequestIdOneOf, IdentificationData, IdentificationDataIdOneOf, IncrementDataIdOneOf, IncrementInventoryRequest, IncrementInventoryResponse, InventoryItemChanged, InventoryItemV2, InventoryVariantV2, InventoryVariantsChanged, MessageEnvelope, Paging, PagingMetadata, PreorderInfo, Query, QueryInventoryRequest, ReasonType, ReasonTypeWithLiterals, UpdateInventoryVariantsRequest, UpdateInventoryVariantsResponse, WebhookIdentityType, WebhookIdentityTypeWithLiterals } from './index.typings.js';
4
4
 
5
- declare function getInventoryVariants$1(httpClient: HttpClient): GetInventoryVariantsSignature;
5
+ declare function getInventoryVariants$1(httpClient: HttpClient, __options?: {
6
+ validateRequestSchema?: boolean;
7
+ }): GetInventoryVariantsSignature;
6
8
  interface GetInventoryVariantsSignature {
7
9
  /**
8
10
  * Gets inventory variant information based on the specified option choices.
@@ -13,14 +15,18 @@ interface GetInventoryVariantsSignature {
13
15
  */
14
16
  (inventoryId: string, options?: GetInventoryVariantsOptions): Promise<NonNullablePaths<GetInventoryVariantsResponse, `inventoryItem.variants` | `inventoryItem.variants.${number}.variantId` | `inventoryItem.variants.${number}.availableForPreorder` | `inventoryItem.numericId` | `inventoryItem.preorderInfo.enabled`, 5>>;
15
17
  }
16
- declare function queryInventory$1(httpClient: HttpClient): QueryInventorySignature;
18
+ declare function queryInventory$1(httpClient: HttpClient, __options?: {
19
+ validateRequestSchema?: boolean;
20
+ }): QueryInventorySignature;
17
21
  interface QueryInventorySignature {
18
22
  /**
19
23
  * Returns a list of inventory items, given the provided paging, sorting and filtering.
20
24
  */
21
25
  (options?: QueryInventoryOptions): Promise<NonNullablePaths<QueryInventoryResponse, `inventoryItems` | `inventoryItems.${number}.numericId` | `inventoryItems.${number}.preorderInfo.enabled` | `metadata.items` | `metadata.offset` | `totalResults`, 5>>;
22
26
  }
23
- declare function updateInventoryVariants$1(httpClient: HttpClient): UpdateInventoryVariantsSignature;
27
+ declare function updateInventoryVariants$1(httpClient: HttpClient, __options?: {
28
+ validateRequestSchema?: boolean;
29
+ }): UpdateInventoryVariantsSignature;
24
30
  interface UpdateInventoryVariantsSignature {
25
31
  /**
26
32
  * Updates product inventory, including total quantity, whether the product is in stock, and whether the product inventory is tracked.
@@ -32,7 +38,9 @@ interface UpdateInventoryVariantsSignature {
32
38
  */
33
39
  (productId: string, inventoryItem: UpdateInventoryVariantsInventoryItem): Promise<void>;
34
40
  }
35
- declare function decrementInventory$1(httpClient: HttpClient): DecrementInventorySignature;
41
+ declare function decrementInventory$1(httpClient: HttpClient, __options?: {
42
+ validateRequestSchema?: boolean;
43
+ }): DecrementInventorySignature;
36
44
  interface DecrementInventorySignature {
37
45
  /**
38
46
  * Subtracts a set number of items from inventory.
@@ -43,7 +51,9 @@ interface DecrementInventorySignature {
43
51
  */
44
52
  (decrementData: DecrementData[]): Promise<void>;
45
53
  }
46
- declare function incrementInventory$1(httpClient: HttpClient): IncrementInventorySignature;
54
+ declare function incrementInventory$1(httpClient: HttpClient, __options?: {
55
+ validateRequestSchema?: boolean;
56
+ }): IncrementInventorySignature;
47
57
  interface IncrementInventorySignature {
48
58
  /**
49
59
  * Adds a set number of items to inventory.
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // index.ts
@@ -317,6 +327,222 @@ function incrementInventory(payload) {
317
327
  return __incrementInventory;
318
328
  }
319
329
 
330
+ // src/stores-v2-inventory-inventory.schemas.ts
331
+ var z = __toESM(require("zod"));
332
+ var GetInventoryVariantsRequest = z.object({
333
+ inventoryId: z.string().describe("Inventory item ID."),
334
+ options: z.intersection(
335
+ z.object({ variantIds: z.array(z.string()).optional() }),
336
+ z.xor([
337
+ z.object({
338
+ inventoryId: z.never().optional(),
339
+ externalId: z.never().optional(),
340
+ productId: z.never().optional()
341
+ }),
342
+ z.object({
343
+ externalId: z.never().optional(),
344
+ productId: z.never().optional(),
345
+ inventoryId: z.string().describe("Inventory item ID.")
346
+ }),
347
+ z.object({
348
+ inventoryId: z.never().optional(),
349
+ productId: z.never().optional(),
350
+ externalId: z.string().describe("Deprecated (use productID instead).")
351
+ }),
352
+ z.object({
353
+ inventoryId: z.never().optional(),
354
+ externalId: z.never().optional(),
355
+ productId: z.string().describe("Product ID.")
356
+ })
357
+ ])
358
+ ).optional()
359
+ });
360
+ var GetInventoryVariantsResponse = z.object({
361
+ inventoryItem: z.object({
362
+ _id: z.string().describe("Inventory item ID.").optional().nullable(),
363
+ externalId: z.string().describe("Deprecated: use productId.").optional().nullable(),
364
+ productId: z.string().describe("Product ID.").optional().nullable(),
365
+ trackQuantity: z.boolean().describe("Whether quantity is being tracked.").optional().nullable(),
366
+ variants: z.array(
367
+ z.object({
368
+ variantId: z.string().describe("Variant ID.").optional(),
369
+ inStock: z.boolean().describe("Whether the product is listed as in stock.").optional().nullable(),
370
+ quantity: z.number().int().describe("Quantity currently left in inventory.").min(0).optional().nullable(),
371
+ availableForPreorder: z.boolean().describe(
372
+ "Whether the variant is available for preorder. When `true`, the variant is out of stock and preorder is enabled on inventory level."
373
+ ).optional()
374
+ })
375
+ ).optional(),
376
+ lastUpdated: z.date().describe("Last updated timestamp.").optional().nullable(),
377
+ numericId: z.string().regex(/^\d+$/, "Must be a valid UInt64 string").describe(
378
+ "Inventory\u2019s unique numeric ID (assigned in ascending order).\nPrimarily for sorting and filtering when crawling all inventories."
379
+ ).optional(),
380
+ preorderInfo: z.object({
381
+ enabled: z.boolean().describe("Whether the item is available for preorder.").optional(),
382
+ message: z.string().describe(
383
+ "A message the buyer will see when the item is out of stock and preorder is enabled."
384
+ ).min(1).max(250).optional().nullable(),
385
+ limit: z.number().int().describe(
386
+ "Number of products that can be preordered after stock reaches zero."
387
+ ).min(0).max(1e5).optional().nullable()
388
+ }).describe("Preorder information.").optional()
389
+ }).describe("Inventory item.").optional()
390
+ });
391
+ var QueryInventoryRequest = z.object({
392
+ options: z.object({
393
+ query: z.object({
394
+ paging: z.object({
395
+ limit: z.number().int().describe("Amount of items to load per page").min(0).max(100).optional().nullable(),
396
+ offset: z.number().int().describe(
397
+ "Number of items to skip in the display (relevant for all pages after the first)"
398
+ ).min(0).optional().nullable()
399
+ }).optional(),
400
+ filter: z.string().describe("Filter string").optional().nullable(),
401
+ sort: z.string().describe("Sort string").optional().nullable()
402
+ }).optional()
403
+ }).optional()
404
+ });
405
+ var QueryInventoryResponse = z.object({
406
+ inventoryItems: z.array(
407
+ z.object({
408
+ _id: z.string().describe("Inventory item ID.").optional().nullable(),
409
+ externalId: z.string().describe("Deprecated: use productId.").optional().nullable(),
410
+ productId: z.string().describe("Product ID.").optional().nullable(),
411
+ trackQuantity: z.boolean().describe("Whether quantity is being tracked.").optional().nullable(),
412
+ variants: z.array(
413
+ z.object({
414
+ variantId: z.string().describe("Variant ID.").optional(),
415
+ inStock: z.boolean().describe("Whether the product is listed as in stock.").optional().nullable(),
416
+ quantity: z.number().int().describe("Quantity currently left in inventory.").min(0).optional().nullable(),
417
+ availableForPreorder: z.boolean().describe(
418
+ "Whether the variant is available for preorder. When `true`, the variant is out of stock and preorder is enabled on inventory level."
419
+ ).optional()
420
+ })
421
+ ).optional(),
422
+ lastUpdated: z.date().describe("Last updated timestamp.").optional().nullable(),
423
+ numericId: z.string().regex(/^\d+$/, "Must be a valid UInt64 string").describe(
424
+ "Inventory\u2019s unique numeric ID (assigned in ascending order).\nPrimarily for sorting and filtering when crawling all inventories."
425
+ ).optional(),
426
+ preorderInfo: z.object({
427
+ enabled: z.boolean().describe("Whether the item is available for preorder.").optional(),
428
+ message: z.string().describe(
429
+ "A message the buyer will see when the item is out of stock and preorder is enabled."
430
+ ).min(1).max(250).optional().nullable(),
431
+ limit: z.number().int().describe(
432
+ "Number of products that can be preordered after stock reaches zero."
433
+ ).min(0).max(1e5).optional().nullable()
434
+ }).describe("Preorder information.").optional()
435
+ })
436
+ ).optional(),
437
+ metadata: z.object({
438
+ items: z.number().int().describe("Amount of items to load per page").optional(),
439
+ offset: z.number().int().describe(
440
+ "Number of items to skip in the display (relevant for all pages after the first)"
441
+ ).optional()
442
+ }).describe("Display metadata.").optional(),
443
+ totalResults: z.number().int().describe("Number of total results.").optional()
444
+ });
445
+ var UpdateInventoryVariantsRequest = z.object({
446
+ productId: z.string().describe("Product ID."),
447
+ inventoryItem: z.object({
448
+ _id: z.string().describe("Inventory item ID.").optional().nullable(),
449
+ externalId: z.string().describe("Deprecated: use productId.").optional().nullable(),
450
+ productId: z.string().describe("Product ID.").optional().nullable(),
451
+ trackQuantity: z.boolean().describe("Whether quantity is being tracked.").optional().nullable(),
452
+ variants: z.array(
453
+ z.object({
454
+ variantId: z.string().describe("Variant ID.").optional(),
455
+ inStock: z.boolean().describe("Whether the product is listed as in stock.").optional().nullable(),
456
+ quantity: z.number().int().describe("Quantity currently left in inventory.").min(0).optional().nullable(),
457
+ availableForPreorder: z.boolean().describe(
458
+ "Whether the variant is available for preorder. When `true`, the variant is out of stock and preorder is enabled on inventory level."
459
+ ).optional()
460
+ })
461
+ ).optional(),
462
+ lastUpdated: z.date().describe("Last updated timestamp.").optional().nullable(),
463
+ numericId: z.string().regex(/^\d+$/, "Must be a valid UInt64 string").describe(
464
+ "Inventory\u2019s unique numeric ID (assigned in ascending order).\nPrimarily for sorting and filtering when crawling all inventories."
465
+ ).optional(),
466
+ preorderInfo: z.object({
467
+ enabled: z.boolean().describe("Whether the item is available for preorder.").optional(),
468
+ message: z.string().describe(
469
+ "A message the buyer will see when the item is out of stock and preorder is enabled."
470
+ ).min(1).max(250).optional().nullable(),
471
+ limit: z.number().int().describe(
472
+ "Number of products that can be preordered after stock reaches zero."
473
+ ).min(0).max(1e5).optional().nullable()
474
+ }).describe("Preorder information.").optional()
475
+ }).describe("Inventory item to update.")
476
+ });
477
+ var UpdateInventoryVariantsResponse = z.object({});
478
+ var DecrementInventoryRequest = z.object({
479
+ decrementData: z.array(
480
+ z.intersection(
481
+ z.object({
482
+ variantId: z.string().describe("Variant ID.").regex(
483
+ /^[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}$/,
484
+ "Must be a valid GUID"
485
+ ).optional(),
486
+ decrementBy: z.number().int().describe("Number to decrement inventory by.").min(1).optional(),
487
+ preorderRequest: z.boolean().describe(
488
+ "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)."
489
+ ).optional()
490
+ }),
491
+ z.xor([
492
+ z.object({
493
+ inventoryId: z.never().optional(),
494
+ externalId: z.never().optional(),
495
+ productId: z.never().optional()
496
+ }),
497
+ z.object({
498
+ externalId: z.never().optional(),
499
+ productId: z.never().optional(),
500
+ inventoryId: z.string().describe("Inventory item ID.").max(36)
501
+ }),
502
+ z.object({
503
+ inventoryId: z.never().optional(),
504
+ productId: z.never().optional(),
505
+ externalId: z.string().describe("Deprecated: use productId.").max(36)
506
+ }),
507
+ z.object({
508
+ inventoryId: z.never().optional(),
509
+ externalId: z.never().optional(),
510
+ productId: z.string().describe("Product ID.").max(36)
511
+ })
512
+ ])
513
+ )
514
+ ).min(1).max(300)
515
+ });
516
+ var DecrementInventoryResponse = z.object({});
517
+ var IncrementInventoryRequest = z.object({
518
+ incrementData: z.array(
519
+ z.intersection(
520
+ z.object({
521
+ variantId: z.string().describe("Variant ID.").regex(
522
+ /^[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}$/,
523
+ "Must be a valid GUID"
524
+ ).optional(),
525
+ incrementBy: z.number().int().describe("Number to increment inventory by.").min(1).optional()
526
+ }),
527
+ z.xor([
528
+ z.object({
529
+ inventoryId: z.never().optional(),
530
+ productId: z.never().optional()
531
+ }),
532
+ z.object({
533
+ productId: z.never().optional(),
534
+ inventoryId: z.string().describe("Inventory item ID.").max(36)
535
+ }),
536
+ z.object({
537
+ inventoryId: z.never().optional(),
538
+ productId: z.string().describe("Product ID.").max(36)
539
+ })
540
+ ])
541
+ )
542
+ ).min(1).max(300)
543
+ });
544
+ var IncrementInventoryResponse = z.object({});
545
+
320
546
  // src/stores-v2-inventory-inventory.universal.ts
321
547
  var ReasonType = /* @__PURE__ */ ((ReasonType2) => {
322
548
  ReasonType2["UNKNOWN"] = "UNKNOWN";
@@ -334,7 +560,10 @@ var WebhookIdentityType = /* @__PURE__ */ ((WebhookIdentityType2) => {
334
560
  return WebhookIdentityType2;
335
561
  })(WebhookIdentityType || {});
336
562
  async function getInventoryVariants2(inventoryId, options) {
337
- const { httpClient, sideEffects } = arguments[2];
563
+ const { httpClient, sideEffects, validateRequestSchema } = arguments[2];
564
+ if (validateRequestSchema) {
565
+ GetInventoryVariantsRequest.parse({ inventoryId, options });
566
+ }
338
567
  const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
339
568
  inventoryId,
340
569
  externalId: options?.externalId,
@@ -367,7 +596,10 @@ async function getInventoryVariants2(inventoryId, options) {
367
596
  }
368
597
  }
369
598
  async function queryInventory2(options) {
370
- const { httpClient, sideEffects } = arguments[1];
599
+ const { httpClient, sideEffects, validateRequestSchema } = arguments[1];
600
+ if (validateRequestSchema) {
601
+ QueryInventoryRequest.parse({ options });
602
+ }
371
603
  const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
372
604
  query: options?.query
373
605
  });
@@ -392,7 +624,10 @@ async function queryInventory2(options) {
392
624
  }
393
625
  }
394
626
  async function updateInventoryVariants2(productId, inventoryItem) {
395
- const { httpClient, sideEffects } = arguments[2];
627
+ const { httpClient, sideEffects, validateRequestSchema } = arguments[2];
628
+ if (validateRequestSchema) {
629
+ UpdateInventoryVariantsRequest.parse({ productId, inventoryItem });
630
+ }
396
631
  const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
397
632
  inventoryItem: { ...inventoryItem, productId }
398
633
  });
@@ -416,7 +651,10 @@ async function updateInventoryVariants2(productId, inventoryItem) {
416
651
  }
417
652
  }
418
653
  async function decrementInventory2(decrementData) {
419
- const { httpClient, sideEffects } = arguments[1];
654
+ const { httpClient, sideEffects, validateRequestSchema } = arguments[1];
655
+ if (validateRequestSchema) {
656
+ DecrementInventoryRequest.parse({ decrementData });
657
+ }
420
658
  const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
421
659
  decrementData
422
660
  });
@@ -440,7 +678,10 @@ async function decrementInventory2(decrementData) {
440
678
  }
441
679
  }
442
680
  async function incrementInventory2(incrementData) {
443
- const { httpClient, sideEffects } = arguments[1];
681
+ const { httpClient, sideEffects, validateRequestSchema } = arguments[1];
682
+ if (validateRequestSchema) {
683
+ IncrementInventoryRequest.parse({ incrementData });
684
+ }
444
685
  const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
445
686
  incrementData
446
687
  });
@@ -465,41 +706,41 @@ async function incrementInventory2(incrementData) {
465
706
  }
466
707
 
467
708
  // src/stores-v2-inventory-inventory.public.ts
468
- function getInventoryVariants3(httpClient) {
709
+ function getInventoryVariants3(httpClient, __options) {
469
710
  return (inventoryId, options) => getInventoryVariants2(
470
711
  inventoryId,
471
712
  options,
472
713
  // @ts-ignore
473
- { httpClient }
714
+ { httpClient, validateRequestSchema: __options?.validateRequestSchema }
474
715
  );
475
716
  }
476
- function queryInventory3(httpClient) {
717
+ function queryInventory3(httpClient, __options) {
477
718
  return (options) => queryInventory2(
478
719
  options,
479
720
  // @ts-ignore
480
- { httpClient }
721
+ { httpClient, validateRequestSchema: __options?.validateRequestSchema }
481
722
  );
482
723
  }
483
- function updateInventoryVariants3(httpClient) {
724
+ function updateInventoryVariants3(httpClient, __options) {
484
725
  return (productId, inventoryItem) => updateInventoryVariants2(
485
726
  productId,
486
727
  inventoryItem,
487
728
  // @ts-ignore
488
- { httpClient }
729
+ { httpClient, validateRequestSchema: __options?.validateRequestSchema }
489
730
  );
490
731
  }
491
- function decrementInventory3(httpClient) {
732
+ function decrementInventory3(httpClient, __options) {
492
733
  return (decrementData) => decrementInventory2(
493
734
  decrementData,
494
735
  // @ts-ignore
495
- { httpClient }
736
+ { httpClient, validateRequestSchema: __options?.validateRequestSchema }
496
737
  );
497
738
  }
498
- function incrementInventory3(httpClient) {
739
+ function incrementInventory3(httpClient, __options) {
499
740
  return (incrementData) => incrementInventory2(
500
741
  incrementData,
501
742
  // @ts-ignore
502
- { httpClient }
743
+ { httpClient, validateRequestSchema: __options?.validateRequestSchema }
503
744
  );
504
745
  }
505
746
  var onInventoryItemChanged = (0, import_sdk_types.EventDefinition)(