@ecomiq/core 0.1.6 → 0.1.8

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 (65) hide show
  1. package/dist/client.cjs +58 -46
  2. package/dist/client.cjs.map +1 -1
  3. package/dist/client.d.cts +1 -0
  4. package/dist/client.d.ts +1 -0
  5. package/dist/client.js +58 -46
  6. package/dist/client.js.map +1 -1
  7. package/dist/index.cjs +60 -46
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +3 -2
  10. package/dist/index.d.ts +3 -2
  11. package/dist/index.js +59 -47
  12. package/dist/index.js.map +1 -1
  13. package/dist/models/collections.cjs +9 -1
  14. package/dist/models/collections.cjs.map +1 -1
  15. package/dist/models/collections.d.cts +6 -6
  16. package/dist/models/collections.d.ts +6 -6
  17. package/dist/models/collections.js +9 -1
  18. package/dist/models/collections.js.map +1 -1
  19. package/dist/models/geo.cjs +10 -2
  20. package/dist/models/geo.cjs.map +1 -1
  21. package/dist/models/geo.d.cts +14 -14
  22. package/dist/models/geo.d.ts +14 -14
  23. package/dist/models/geo.js +10 -2
  24. package/dist/models/geo.js.map +1 -1
  25. package/dist/models/ids.cjs +17 -0
  26. package/dist/models/ids.cjs.map +1 -0
  27. package/dist/models/ids.d.cts +12 -0
  28. package/dist/models/ids.d.ts +12 -0
  29. package/dist/models/ids.js +13 -0
  30. package/dist/models/ids.js.map +1 -0
  31. package/dist/models/products.cjs +12 -4
  32. package/dist/models/products.cjs.map +1 -1
  33. package/dist/models/products.d.cts +4 -4
  34. package/dist/models/products.d.ts +4 -4
  35. package/dist/models/products.js +12 -4
  36. package/dist/models/products.js.map +1 -1
  37. package/dist/models/search.cjs +11 -5
  38. package/dist/models/search.cjs.map +1 -1
  39. package/dist/models/search.d.cts +1 -1
  40. package/dist/models/search.d.ts +1 -1
  41. package/dist/models/search.js +11 -5
  42. package/dist/models/search.js.map +1 -1
  43. package/dist/models/settings.cjs +12 -9
  44. package/dist/models/settings.cjs.map +1 -1
  45. package/dist/models/settings.d.cts +23 -25
  46. package/dist/models/settings.d.ts +23 -25
  47. package/dist/models/settings.js +12 -10
  48. package/dist/models/settings.js.map +1 -1
  49. package/dist/models/storefront-cart.cjs +23 -15
  50. package/dist/models/storefront-cart.cjs.map +1 -1
  51. package/dist/models/storefront-cart.d.cts +23 -23
  52. package/dist/models/storefront-cart.d.ts +23 -23
  53. package/dist/models/storefront-cart.js +23 -15
  54. package/dist/models/storefront-cart.js.map +1 -1
  55. package/dist/models/storefront-checkout.cjs +46 -29
  56. package/dist/models/storefront-checkout.cjs.map +1 -1
  57. package/dist/models/storefront-checkout.d.cts +555 -2183
  58. package/dist/models/storefront-checkout.d.ts +555 -2183
  59. package/dist/models/storefront-checkout.js +46 -30
  60. package/dist/models/storefront-checkout.js.map +1 -1
  61. package/dist/models/storefront-reviews.cjs +12 -4
  62. package/dist/models/storefront-reviews.cjs.map +1 -1
  63. package/dist/models/storefront-reviews.js +12 -4
  64. package/dist/models/storefront-reviews.js.map +1 -1
  65. package/package.json +6 -1
package/dist/client.cjs CHANGED
@@ -105,8 +105,16 @@ function createApi(options = {}) {
105
105
  postForm: (path, body, schema, opts) => request("POST", path, schema, { ...opts, body })
106
106
  };
107
107
  }
108
+ var EntityIdSchema = zod.z.union([
109
+ zod.z.string().uuid(),
110
+ zod.z.string().regex(/^\d+$/, "Expected numeric id")
111
+ ]);
112
+ var NullableEntityIdSchema = EntityIdSchema.nullable();
113
+ var OptionalEntityIdSchema = EntityIdSchema.optional();
114
+
115
+ // src/models/collections.ts
108
116
  var CollectionSchema = zod.z.object({
109
- id: zod.z.number(),
117
+ id: EntityIdSchema,
110
118
  slug: zod.z.string(),
111
119
  name: zod.z.string(),
112
120
  description: zod.z.string().nullable().optional(),
@@ -173,7 +181,7 @@ var ProductsParamsSchema = zod.z.object({
173
181
  page: zod.z.number().int().positive().default(1),
174
182
  pageSize: zod.z.number().int().positive().max(100).default(24),
175
183
  sort: ProductSortSchema.optional(),
176
- sellerId: zod.z.string().uuid().optional(),
184
+ sellerId: OptionalEntityIdSchema,
177
185
  search: zod.z.string().optional(),
178
186
  collection: zod.z.string().optional(),
179
187
  collections: zod.z.array(zod.z.string()).optional(),
@@ -187,18 +195,18 @@ var ProductsParamsSchema = zod.z.object({
187
195
  tag: zod.z.string().optional(),
188
196
  tags: zod.z.array(zod.z.string()).optional(),
189
197
  filters: zod.z.array(zod.z.string()).optional(),
190
- locationId: zod.z.string().uuid().optional(),
198
+ locationId: OptionalEntityIdSchema,
191
199
  inStock: zod.z.boolean().optional(),
192
200
  minPrice: zod.z.number().nonnegative().optional(),
193
201
  maxPrice: zod.z.number().nonnegative().optional()
194
202
  });
195
203
  var ProductDetailParamsSchema = zod.z.object({
196
- sellerId: zod.z.string().uuid().optional()
204
+ sellerId: OptionalEntityIdSchema
197
205
  });
198
206
  var RelatedProductsParamsSchema = zod.z.object({
199
207
  productId: ProductPublicIdSchema,
200
208
  limit: zod.z.number().int().positive().max(12).default(8),
201
- sellerId: zod.z.string().uuid().optional()
209
+ sellerId: OptionalEntityIdSchema
202
210
  });
203
211
  var SpecItemSchema = zod.z.object({
204
212
  key: zod.z.string(),
@@ -302,12 +310,6 @@ var JsonElementSchema = zod.z.lazy(
302
310
  );
303
311
  var DateTimeOffsetSchema = zod.z.string().datetime({ offset: true });
304
312
  var NullableDateTimeOffsetSchema = DateTimeOffsetSchema.nullable();
305
- var NullableUuidSchema = zod.z.string().uuid().nullable();
306
- var EntityIdSchema = zod.z.union([
307
- zod.z.string().uuid(),
308
- zod.z.string().regex(/^\d+$/, "Expected numeric id")
309
- ]);
310
- var NullableEntityIdSchema = EntityIdSchema.nullable();
311
313
  var StoreTypeSchema = zod.z.enum([
312
314
  "b2C",
313
315
  "marketplace",
@@ -479,11 +481,11 @@ var CmsPageDetailsDtoSchema = zod.z.object({
479
481
  status: CmsPageStatusSchema,
480
482
  hasPublishedVersion: zod.z.boolean(),
481
483
  publishedOn: NullableDateTimeOffsetSchema,
482
- publishedBy: NullableUuidSchema,
484
+ publishedBy: NullableEntityIdSchema,
483
485
  createdOn: DateTimeOffsetSchema,
484
486
  updatedOn: NullableDateTimeOffsetSchema,
485
- createdBy: NullableUuidSchema,
486
- updatedBy: NullableUuidSchema,
487
+ createdBy: NullableEntityIdSchema,
488
+ updatedBy: NullableEntityIdSchema,
487
489
  lastModifiedBy: zod.z.string().nullable()
488
490
  }).strict();
489
491
  var CmsSnapshotDtoSchema = zod.z.object({
@@ -575,7 +577,7 @@ async function getRelatedProducts(api, params) {
575
577
  var ProductAutocompleteParamsSchema = zod.z.object({
576
578
  search: zod.z.string().min(2).max(80),
577
579
  limit: zod.z.number().int().positive().max(20).default(8),
578
- sellerId: zod.z.string().uuid().optional()
580
+ sellerId: OptionalEntityIdSchema
579
581
  });
580
582
  var ProductSuggestionSchema = zod.z.object({
581
583
  id: ProductPublicIdSchema,
@@ -689,7 +691,7 @@ var StorefrontCartBundleItemSchema = zod.z.object({
689
691
  quantity: zod.z.number().int().positive()
690
692
  });
691
693
  var StorefrontCartItemSchema = zod.z.object({
692
- id: zod.z.string().uuid(),
694
+ id: EntityIdSchema,
693
695
  productId: zod.z.number().int().safe().nonnegative(),
694
696
  title: zod.z.string(),
695
697
  variantLabel: zod.z.string().nullable(),
@@ -703,20 +705,20 @@ var StorefrontCartItemSchema = zod.z.object({
703
705
  bundleItems: zod.z.array(StorefrontCartBundleItemSchema)
704
706
  });
705
707
  var StorefrontCartShippingMethodSchema = zod.z.object({
706
- id: zod.z.string().uuid(),
707
- shippingMethodId: zod.z.string().uuid().nullable(),
708
- rateId: zod.z.string().uuid().nullable(),
708
+ id: EntityIdSchema,
709
+ shippingMethodId: NullableEntityIdSchema,
710
+ rateId: NullableEntityIdSchema,
709
711
  name: zod.z.string(),
710
712
  description: zod.z.string().nullable(),
711
713
  total: zod.z.number(),
712
- locationId: zod.z.string().uuid().nullable(),
714
+ locationId: NullableEntityIdSchema,
713
715
  estimatedDays: zod.z.number().int().nullable(),
714
- pickupPointId: zod.z.string().uuid().nullable(),
716
+ pickupPointId: NullableEntityIdSchema,
715
717
  scheduledDate: zod.z.string().nullable(),
716
718
  scheduledTime: zod.z.string().nullable(),
717
719
  serviceCode: zod.z.string().nullable(),
718
- sellerId: zod.z.string().uuid().nullable(),
719
- shippingProfileId: zod.z.string().uuid().nullable()
720
+ sellerId: NullableEntityIdSchema,
721
+ shippingProfileId: NullableEntityIdSchema
720
722
  });
721
723
  var StorefrontCartTotalsSchema = zod.z.object({
722
724
  subtotal: zod.z.number(),
@@ -737,7 +739,7 @@ var StorefrontCartStatusSchema = zod.z.enum([
737
739
  "failed"
738
740
  ]);
739
741
  var StorefrontCartSchema = zod.z.object({
740
- id: zod.z.string().uuid(),
742
+ id: EntityIdSchema,
741
743
  cartNumber: zod.z.string(),
742
744
  email: zod.z.string().nullable(),
743
745
  phone: zod.z.string().nullable(),
@@ -759,26 +761,26 @@ var CreateCartParamsSchema = zod.z.object({
759
761
  email: zod.z.string().email().optional()
760
762
  });
761
763
  var GetCartParamsSchema = zod.z.object({
762
- cartId: zod.z.string().uuid()
764
+ cartId: EntityIdSchema
763
765
  });
764
766
  var CartItemModifierSchema = zod.z.object({
765
767
  modifierGroupId: zod.z.number().int().safe().positive(),
766
768
  optionIds: zod.z.array(zod.z.number().int().safe().positive()).min(1)
767
769
  });
768
770
  var AddCartItemParamsSchema = zod.z.object({
769
- cartId: zod.z.string().uuid(),
771
+ cartId: EntityIdSchema,
770
772
  variantId: zod.z.number().int().safe().positive(),
771
773
  quantity: zod.z.number().int().positive(),
772
774
  modifiers: zod.z.array(CartItemModifierSchema).optional()
773
775
  });
774
776
  var UpdateCartItemQuantityParamsSchema = zod.z.object({
775
- cartId: zod.z.string().uuid(),
776
- cartItemId: zod.z.string().uuid(),
777
+ cartId: EntityIdSchema,
778
+ cartItemId: EntityIdSchema,
777
779
  quantity: zod.z.number().int().nonnegative()
778
780
  });
779
781
  var RemoveCartItemParamsSchema = zod.z.object({
780
- cartId: zod.z.string().uuid(),
781
- cartItemId: zod.z.string().uuid()
782
+ cartId: EntityIdSchema,
783
+ cartItemId: EntityIdSchema
782
784
  });
783
785
 
784
786
  // src/services/cart.service.ts
@@ -843,8 +845,18 @@ async function getCollectionBySlug(api, collectionSlug) {
843
845
  async function getPageBySlug(api, pageSlug) {
844
846
  return api.get(`pages/${encodeURIComponent(pageSlug)}`, CmsPageDetailsDtoSchema);
845
847
  }
848
+ var CheckoutMetadataValueSchema = zod.z.lazy(
849
+ () => zod.z.union([
850
+ zod.z.string(),
851
+ zod.z.number(),
852
+ zod.z.boolean(),
853
+ zod.z.null(),
854
+ zod.z.array(CheckoutMetadataValueSchema),
855
+ zod.z.record(zod.z.string(), CheckoutMetadataValueSchema)
856
+ ])
857
+ );
846
858
  var CartBuyerParamsSchema = zod.z.object({
847
- cartId: zod.z.string().uuid(),
859
+ cartId: EntityIdSchema,
848
860
  email: zod.z.string().email(),
849
861
  firstName: zod.z.string().min(1),
850
862
  lastName: zod.z.string().min(1),
@@ -870,7 +882,7 @@ var CartAddressWriteSchema = zod.z.object({
870
882
  }).nullable().optional()
871
883
  });
872
884
  var CartAddressesParamsSchema = zod.z.object({
873
- cartId: zod.z.string().uuid(),
885
+ cartId: EntityIdSchema,
874
886
  shippingAddress: CartAddressWriteSchema,
875
887
  billingAddress: CartAddressWriteSchema
876
888
  });
@@ -903,7 +915,7 @@ var StorefrontOrderBumpSchema = zod.z.object({
903
915
  description: zod.z.string().nullable().optional()
904
916
  });
905
917
  var CartCheckoutReadParamsSchema = zod.z.object({
906
- cartId: zod.z.string().uuid()
918
+ cartId: EntityIdSchema
907
919
  });
908
920
  var CartCheckoutReadResponseSchema = zod.z.object({
909
921
  cart: StorefrontCartSchema,
@@ -919,13 +931,13 @@ var CartCheckoutPaymentActionSchema = zod.z.object({
919
931
  phoneNumber: zod.z.string().nullable().optional(),
920
932
  accountHolder: zod.z.string().nullable().optional(),
921
933
  qrImageUrl: zod.z.string().nullable().optional()
922
- }).passthrough().nullable().optional(),
934
+ }).strip().nullable().optional(),
923
935
  url: zod.z.string().nullable().optional(),
924
936
  html: zod.z.string().nullable().optional(),
925
937
  clientSecret: zod.z.string().nullable().optional(),
926
938
  qrCode: zod.z.string().nullable().optional(),
927
939
  expiresAt: zod.z.string().nullable().optional()
928
- }).passthrough();
940
+ }).strip();
929
941
  var CartCheckoutPaymentSchema = zod.z.object({
930
942
  transactionId: zod.z.string(),
931
943
  paymentMethodCode: zod.z.string(),
@@ -936,7 +948,7 @@ var CartCheckoutPaymentSchema = zod.z.object({
936
948
  actionType: zod.z.string(),
937
949
  receiptUrl: zod.z.string().nullable().optional(),
938
950
  action: CartCheckoutPaymentActionSchema.nullable().optional()
939
- }).passthrough();
951
+ }).strip();
940
952
  var CartCheckoutResponseSchema = zod.z.object({
941
953
  publicKey: zod.z.string().optional(),
942
954
  publishableKey: zod.z.string().optional(),
@@ -948,9 +960,9 @@ var CartCheckoutResponseSchema = zod.z.object({
948
960
  orderIds: zod.z.array(zod.z.coerce.string()).optional(),
949
961
  payment: CartCheckoutPaymentSchema.optional(),
950
962
  cart: StorefrontCartSchema.optional()
951
- }).passthrough();
963
+ }).strip();
952
964
  var CartCheckoutParamsSchema = zod.z.object({
953
- cartId: zod.z.string().uuid(),
965
+ cartId: EntityIdSchema,
954
966
  paymentMethodCode: zod.z.string().min(1),
955
967
  externalRef: zod.z.string().min(1),
956
968
  receiptUrl: zod.z.string().min(1).optional()
@@ -969,8 +981,8 @@ var ShippingRateSchema = zod.z.object({
969
981
  deliveryLocationName: zod.z.string().nullable().optional(),
970
982
  estimatedDeliveryDays: zod.z.number().nullable().optional(),
971
983
  serviceCode: zod.z.string().nullable().optional(),
972
- metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
973
- }).passthrough();
984
+ metadata: zod.z.record(zod.z.string(), CheckoutMetadataValueSchema).optional()
985
+ }).strip();
974
986
  var ShippingOptionGroupSchema = zod.z.object({
975
987
  sellerId: zod.z.string(),
976
988
  shippingProfileId: zod.z.string().nullable().optional(),
@@ -978,16 +990,16 @@ var ShippingOptionGroupSchema = zod.z.object({
978
990
  totalWeight: zod.z.number().optional(),
979
991
  itemIds: zod.z.array(zod.z.string()).optional(),
980
992
  rates: zod.z.array(ShippingRateSchema)
981
- }).passthrough();
993
+ }).strip();
982
994
  var ShippingOptionsResponseSchema = zod.z.object({
983
995
  groups: zod.z.array(ShippingOptionGroupSchema)
984
996
  });
985
997
  var GetShippingOptionsParamsSchema = zod.z.object({
986
- cartId: zod.z.string().uuid(),
998
+ cartId: EntityIdSchema,
987
999
  postalCode: zod.z.string().min(1)
988
1000
  });
989
1001
  var PutShippingMethodParamsSchema = zod.z.object({
990
- cartId: zod.z.string().uuid(),
1002
+ cartId: EntityIdSchema,
991
1003
  rateId: zod.z.string().min(1),
992
1004
  shippingMethodId: zod.z.string().min(1),
993
1005
  serviceCode: zod.z.string().nullable().optional(),
@@ -1003,7 +1015,7 @@ var CartPaymentReceiptResponseSchema = zod.z.object({
1003
1015
  url: zod.z.string()
1004
1016
  });
1005
1017
  var CartPromotionCodeParamsSchema = zod.z.object({
1006
- cartId: zod.z.string().uuid(),
1018
+ cartId: EntityIdSchema,
1007
1019
  code: zod.z.string().min(1)
1008
1020
  });
1009
1021
 
@@ -1099,12 +1111,12 @@ var CountrySchema = zod.z.object({
1099
1111
  var CountriesSchema = zod.z.array(CountrySchema);
1100
1112
  var GeoDivisionTypeSchema = zod.z.enum(["level1", "level2", "level3"]);
1101
1113
  var GeoDivisionSchema = zod.z.object({
1102
- id: zod.z.string().uuid(),
1114
+ id: EntityIdSchema,
1103
1115
  countryCode: zod.z.string().length(2),
1104
1116
  type: GeoDivisionTypeSchema,
1105
1117
  code: zod.z.string().min(1),
1106
1118
  name: zod.z.string().min(1),
1107
- parentId: zod.z.string().uuid().nullable(),
1119
+ parentId: NullableEntityIdSchema,
1108
1120
  source: zod.z.string().min(1)
1109
1121
  }).strict();
1110
1122
  var DepartmentSchema = GeoDivisionSchema;