@ecomiq/core 0.1.7 → 0.1.9
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.
- package/dist/{client-4ZTG2RZ3.d.ts → client-Ba1r_uiO.d.ts} +4 -4
- package/dist/{client-BpX4yR6S.d.cts → client-Cqcnv2tC.d.cts} +4 -4
- package/dist/client.cjs +94 -89
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +94 -89
- package/dist/client.js.map +1 -1
- package/dist/index.cjs +96 -101
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +65 -55
- package/dist/index.d.ts +65 -55
- package/dist/index.js +95 -100
- package/dist/index.js.map +1 -1
- package/dist/models/collections.cjs +7 -1
- package/dist/models/collections.cjs.map +1 -1
- package/dist/models/collections.d.cts +6 -6
- package/dist/models/collections.d.ts +6 -6
- package/dist/models/collections.js +7 -1
- package/dist/models/collections.js.map +1 -1
- package/dist/models/customer-address.cjs +7 -1
- package/dist/models/customer-address.cjs.map +1 -1
- package/dist/models/customer-address.d.cts +4 -4
- package/dist/models/customer-address.d.ts +4 -4
- package/dist/models/customer-address.js +7 -1
- package/dist/models/customer-address.js.map +1 -1
- package/dist/models/customer-order.cjs +14 -8
- package/dist/models/customer-order.cjs.map +1 -1
- package/dist/models/customer-order.d.cts +1 -5
- package/dist/models/customer-order.d.ts +1 -5
- package/dist/models/customer-order.js +14 -8
- package/dist/models/customer-order.js.map +1 -1
- package/dist/models/customer-profile.cjs +8 -2
- package/dist/models/customer-profile.cjs.map +1 -1
- package/dist/models/customer-profile.d.cts +3 -3
- package/dist/models/customer-profile.d.ts +3 -3
- package/dist/models/customer-profile.js +8 -2
- package/dist/models/customer-profile.js.map +1 -1
- package/dist/models/geo.cjs +2 -4
- package/dist/models/geo.cjs.map +1 -1
- package/dist/models/geo.d.cts +14 -14
- package/dist/models/geo.d.ts +14 -14
- package/dist/models/geo.js +2 -4
- package/dist/models/geo.js.map +1 -1
- package/dist/models/ids.cjs +3 -4
- package/dist/models/ids.cjs.map +1 -1
- package/dist/models/ids.d.cts +8 -8
- package/dist/models/ids.d.ts +8 -8
- package/dist/models/ids.js +3 -5
- package/dist/models/ids.js.map +1 -1
- package/dist/models/products.cjs +12 -19
- package/dist/models/products.cjs.map +1 -1
- package/dist/models/products.d.cts +32 -33
- package/dist/models/products.d.ts +32 -33
- package/dist/models/products.js +13 -19
- package/dist/models/products.js.map +1 -1
- package/dist/models/search.cjs +3 -180
- package/dist/models/search.cjs.map +1 -1
- package/dist/models/search.d.cts +5 -5
- package/dist/models/search.d.ts +5 -5
- package/dist/models/search.js +3 -180
- package/dist/models/search.js.map +1 -1
- package/dist/models/settings.cjs +2 -4
- package/dist/models/settings.cjs.map +1 -1
- package/dist/models/settings.d.cts +63 -63
- package/dist/models/settings.d.ts +63 -63
- package/dist/models/settings.js +2 -4
- package/dist/models/settings.js.map +1 -1
- package/dist/models/storefront-cart.cjs +14 -26
- package/dist/models/storefront-cart.cjs.map +1 -1
- package/dist/models/storefront-cart.d.cts +100 -98
- package/dist/models/storefront-cart.d.ts +100 -98
- package/dist/models/storefront-cart.js +15 -26
- package/dist/models/storefront-cart.js.map +1 -1
- package/dist/models/storefront-checkout.cjs +44 -34
- package/dist/models/storefront-checkout.cjs.map +1 -1
- package/dist/models/storefront-checkout.d.cts +660 -2278
- package/dist/models/storefront-checkout.d.ts +660 -2278
- package/dist/models/storefront-checkout.js +44 -35
- package/dist/models/storefront-checkout.js.map +1 -1
- package/dist/models/storefront-reviews.cjs +8 -187
- package/dist/models/storefront-reviews.cjs.map +1 -1
- package/dist/models/storefront-reviews.d.cts +17 -17
- package/dist/models/storefront-reviews.d.ts +17 -17
- package/dist/models/storefront-reviews.js +8 -187
- package/dist/models/storefront-reviews.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -104,8 +104,14 @@ function createApi(options = {}) {
|
|
|
104
104
|
postForm: (path, body, schema, opts) => request("POST", path, schema, { ...opts, body })
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
|
+
var EntityIdSchema = z.string().min(1, "Expected resource id");
|
|
108
|
+
var CartTokenSchema = z.string().min(1).max(32).regex(/^[A-Za-z0-9_-]+$/, "Expected cart token");
|
|
109
|
+
var NullableEntityIdSchema = EntityIdSchema.nullable();
|
|
110
|
+
var OptionalEntityIdSchema = EntityIdSchema.optional();
|
|
111
|
+
|
|
112
|
+
// src/models/collections.ts
|
|
107
113
|
var CollectionSchema = z.object({
|
|
108
|
-
id:
|
|
114
|
+
id: EntityIdSchema,
|
|
109
115
|
slug: z.string(),
|
|
110
116
|
name: z.string(),
|
|
111
117
|
description: z.string().nullable().optional(),
|
|
@@ -114,20 +120,8 @@ var CollectionSchema = z.object({
|
|
|
114
120
|
productCount: z.number().optional()
|
|
115
121
|
});
|
|
116
122
|
var CollectionsSchema = z.array(CollectionSchema);
|
|
117
|
-
var EntityIdSchema = z.union([
|
|
118
|
-
z.string().uuid(),
|
|
119
|
-
z.string().regex(/^\d+$/, "Expected numeric id")
|
|
120
|
-
]);
|
|
121
|
-
var NullableEntityIdSchema = EntityIdSchema.nullable();
|
|
122
|
-
var OptionalEntityIdSchema = EntityIdSchema.optional();
|
|
123
|
-
|
|
124
|
-
// src/models/products.ts
|
|
125
|
-
var ProductPublicIdSchema = z.union([
|
|
126
|
-
z.string().regex(/^[1-9]\d*$/),
|
|
127
|
-
z.number().int().safe().positive()
|
|
128
|
-
]).transform(String);
|
|
129
123
|
var ProductSummarySchema = z.object({
|
|
130
|
-
id:
|
|
124
|
+
id: EntityIdSchema,
|
|
131
125
|
name: z.string(),
|
|
132
126
|
slug: z.string(),
|
|
133
127
|
productType: z.string(),
|
|
@@ -186,7 +180,7 @@ var ProductsParamsSchema = z.object({
|
|
|
186
180
|
search: z.string().optional(),
|
|
187
181
|
collection: z.string().optional(),
|
|
188
182
|
collections: z.array(z.string()).optional(),
|
|
189
|
-
collectionId:
|
|
183
|
+
collectionId: EntityIdSchema.optional(),
|
|
190
184
|
category: z.string().optional(),
|
|
191
185
|
categories: z.array(z.string()).optional(),
|
|
192
186
|
brand: z.string().optional(),
|
|
@@ -205,7 +199,7 @@ var ProductDetailParamsSchema = z.object({
|
|
|
205
199
|
sellerId: OptionalEntityIdSchema
|
|
206
200
|
});
|
|
207
201
|
var RelatedProductsParamsSchema = z.object({
|
|
208
|
-
productId:
|
|
202
|
+
productId: EntityIdSchema,
|
|
209
203
|
limit: z.number().int().positive().max(12).default(8),
|
|
210
204
|
sellerId: OptionalEntityIdSchema
|
|
211
205
|
});
|
|
@@ -221,7 +215,7 @@ var ProductImageSchema = z.object({
|
|
|
221
215
|
order: z.number().int().nonnegative()
|
|
222
216
|
});
|
|
223
217
|
var VariantItemSchema = z.object({
|
|
224
|
-
id:
|
|
218
|
+
id: EntityIdSchema.nullable(),
|
|
225
219
|
sku: z.string(),
|
|
226
220
|
status: z.string(),
|
|
227
221
|
price: z.number().nonnegative(),
|
|
@@ -232,15 +226,15 @@ var VariantItemSchema = z.object({
|
|
|
232
226
|
});
|
|
233
227
|
var VariantSchema = VariantItemSchema;
|
|
234
228
|
var ProductPriceTierSchema = z.object({
|
|
235
|
-
variantId:
|
|
229
|
+
variantId: EntityIdSchema,
|
|
236
230
|
minQuantity: z.number().int().positive(),
|
|
237
231
|
maxQuantity: z.number().int().positive().nullable(),
|
|
238
232
|
unitPrice: z.number().nonnegative()
|
|
239
233
|
});
|
|
240
234
|
var PriceTierSchema = ProductPriceTierSchema;
|
|
241
235
|
var BundleItemSchema = z.object({
|
|
242
|
-
productId:
|
|
243
|
-
variantId:
|
|
236
|
+
productId: EntityIdSchema,
|
|
237
|
+
variantId: EntityIdSchema,
|
|
244
238
|
productName: z.string(),
|
|
245
239
|
variantName: z.string().nullable(),
|
|
246
240
|
sku: z.string().nullable(),
|
|
@@ -266,7 +260,7 @@ var SizeGuideRowSchema = z.object({
|
|
|
266
260
|
measurements: z.array(SizeGuideMeasurementSchema)
|
|
267
261
|
});
|
|
268
262
|
var SizeGuideSchema = z.object({
|
|
269
|
-
id:
|
|
263
|
+
id: EntityIdSchema,
|
|
270
264
|
name: z.string(),
|
|
271
265
|
slug: z.string(),
|
|
272
266
|
description: z.string().nullable(),
|
|
@@ -278,7 +272,7 @@ var SizeGuideSchema = z.object({
|
|
|
278
272
|
rows: z.array(SizeGuideRowSchema)
|
|
279
273
|
});
|
|
280
274
|
var ProductDetailSchema = z.object({
|
|
281
|
-
id:
|
|
275
|
+
id: EntityIdSchema,
|
|
282
276
|
name: z.string(),
|
|
283
277
|
slug: z.string(),
|
|
284
278
|
description: z.string(),
|
|
@@ -291,7 +285,7 @@ var ProductDetailSchema = z.object({
|
|
|
291
285
|
totalInventory: z.number().int().nonnegative(),
|
|
292
286
|
brand: z.string(),
|
|
293
287
|
category: z.string(),
|
|
294
|
-
categoryId:
|
|
288
|
+
categoryId: EntityIdSchema.nullable(),
|
|
295
289
|
tags: z.array(z.string()),
|
|
296
290
|
specifications: z.array(SpecItemSchema),
|
|
297
291
|
variants: z.array(VariantItemSchema),
|
|
@@ -603,7 +597,7 @@ var ProductAutocompleteParamsSchema = z.object({
|
|
|
603
597
|
sellerId: OptionalEntityIdSchema
|
|
604
598
|
});
|
|
605
599
|
var ProductSuggestionSchema = z.object({
|
|
606
|
-
id:
|
|
600
|
+
id: EntityIdSchema,
|
|
607
601
|
name: z.string(),
|
|
608
602
|
slug: z.string(),
|
|
609
603
|
imageUrl: z.string()
|
|
@@ -622,8 +616,8 @@ async function autocompleteProducts(api, params) {
|
|
|
622
616
|
});
|
|
623
617
|
}
|
|
624
618
|
var StorefrontReviewSchema = z.object({
|
|
625
|
-
id:
|
|
626
|
-
productId:
|
|
619
|
+
id: EntityIdSchema,
|
|
620
|
+
productId: EntityIdSchema,
|
|
627
621
|
isVerifiedPurchase: z.boolean(),
|
|
628
622
|
rating: z.number().int().min(1).max(5),
|
|
629
623
|
title: z.string().nullable(),
|
|
@@ -638,7 +632,7 @@ var StorefrontReviewsSchema = z.object({
|
|
|
638
632
|
totalCount: z.number().int().nonnegative().nullable()
|
|
639
633
|
});
|
|
640
634
|
var ListProductReviewsParamsSchema = z.object({
|
|
641
|
-
productId:
|
|
635
|
+
productId: EntityIdSchema,
|
|
642
636
|
limit: z.number().int().min(1).max(200).optional(),
|
|
643
637
|
cursor: z.string().optional(),
|
|
644
638
|
search: z.string().optional(),
|
|
@@ -647,13 +641,13 @@ var ListProductReviewsParamsSchema = z.object({
|
|
|
647
641
|
rating: z.number().int().min(1).max(5).optional()
|
|
648
642
|
});
|
|
649
643
|
var CreateProductReviewParamsSchema = z.object({
|
|
650
|
-
productId:
|
|
644
|
+
productId: EntityIdSchema,
|
|
651
645
|
rating: z.number().int().min(1).max(5),
|
|
652
646
|
content: z.string().min(1).max(4e3),
|
|
653
647
|
title: z.string().max(200).optional(),
|
|
654
648
|
reviewerName: z.string().min(1).max(200),
|
|
655
649
|
reviewerEmail: z.string().email().max(320),
|
|
656
|
-
orderId:
|
|
650
|
+
orderId: EntityIdSchema.optional()
|
|
657
651
|
});
|
|
658
652
|
|
|
659
653
|
// src/services/review.service.ts
|
|
@@ -689,16 +683,6 @@ async function createProductReview(api, params) {
|
|
|
689
683
|
StorefrontReviewSchema
|
|
690
684
|
);
|
|
691
685
|
}
|
|
692
|
-
function cartVariantIdFromProduct(variantId) {
|
|
693
|
-
if (!/^\d+$/.test(variantId)) {
|
|
694
|
-
throw new RangeError("El variant ID debe ser un integer decimal positivo.");
|
|
695
|
-
}
|
|
696
|
-
const value = BigInt(variantId);
|
|
697
|
-
if (value <= 0n || value > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
698
|
-
throw new RangeError("El variant ID no cabe en un integer seguro de JavaScript.");
|
|
699
|
-
}
|
|
700
|
-
return Number(value);
|
|
701
|
-
}
|
|
702
686
|
var StorefrontAddressSchema = z.object({
|
|
703
687
|
name: z.string().nullable(),
|
|
704
688
|
address1: z.string(),
|
|
@@ -714,8 +698,8 @@ var StorefrontAddressSchema = z.object({
|
|
|
714
698
|
longitude: z.number().nullable()
|
|
715
699
|
});
|
|
716
700
|
var StorefrontCartBundleItemSchema = z.object({
|
|
717
|
-
productId:
|
|
718
|
-
variantId:
|
|
701
|
+
productId: EntityIdSchema,
|
|
702
|
+
variantId: EntityIdSchema,
|
|
719
703
|
productName: z.string(),
|
|
720
704
|
variantName: z.string().nullable(),
|
|
721
705
|
sku: z.string().nullable(),
|
|
@@ -725,13 +709,13 @@ var StorefrontCartBundleItemSchema = z.object({
|
|
|
725
709
|
});
|
|
726
710
|
var StorefrontCartItemSchema = z.object({
|
|
727
711
|
id: EntityIdSchema,
|
|
728
|
-
productId:
|
|
712
|
+
productId: NullableEntityIdSchema,
|
|
729
713
|
title: z.string(),
|
|
730
714
|
variantLabel: z.string().nullable(),
|
|
731
715
|
productHandle: z.string().nullable(),
|
|
732
716
|
thumbnail: z.string().nullable(),
|
|
733
717
|
quantity: z.number().int().positive(),
|
|
734
|
-
variantId:
|
|
718
|
+
variantId: NullableEntityIdSchema,
|
|
735
719
|
variantSku: z.string().nullable(),
|
|
736
720
|
unitPrice: z.number(),
|
|
737
721
|
compareAtUnitPrice: z.number().nullable(),
|
|
@@ -773,6 +757,7 @@ var StorefrontCartStatusSchema = z.enum([
|
|
|
773
757
|
]);
|
|
774
758
|
var StorefrontCartSchema = z.object({
|
|
775
759
|
id: EntityIdSchema,
|
|
760
|
+
token: CartTokenSchema,
|
|
776
761
|
cartNumber: z.string(),
|
|
777
762
|
email: z.string().nullable(),
|
|
778
763
|
phone: z.string().nullable(),
|
|
@@ -794,25 +779,25 @@ var CreateCartParamsSchema = z.object({
|
|
|
794
779
|
email: z.string().email().optional()
|
|
795
780
|
});
|
|
796
781
|
var GetCartParamsSchema = z.object({
|
|
797
|
-
|
|
782
|
+
cartToken: CartTokenSchema
|
|
798
783
|
});
|
|
799
784
|
var CartItemModifierSchema = z.object({
|
|
800
|
-
modifierGroupId:
|
|
801
|
-
optionIds: z.array(
|
|
785
|
+
modifierGroupId: EntityIdSchema,
|
|
786
|
+
optionIds: z.array(EntityIdSchema).min(1)
|
|
802
787
|
});
|
|
803
788
|
var AddCartItemParamsSchema = z.object({
|
|
804
|
-
|
|
805
|
-
variantId:
|
|
789
|
+
cartToken: CartTokenSchema,
|
|
790
|
+
variantId: EntityIdSchema,
|
|
806
791
|
quantity: z.number().int().positive(),
|
|
807
792
|
modifiers: z.array(CartItemModifierSchema).optional()
|
|
808
793
|
});
|
|
809
794
|
var UpdateCartItemQuantityParamsSchema = z.object({
|
|
810
|
-
|
|
795
|
+
cartToken: CartTokenSchema,
|
|
811
796
|
cartItemId: EntityIdSchema,
|
|
812
797
|
quantity: z.number().int().nonnegative()
|
|
813
798
|
});
|
|
814
799
|
var RemoveCartItemParamsSchema = z.object({
|
|
815
|
-
|
|
800
|
+
cartToken: CartTokenSchema,
|
|
816
801
|
cartItemId: EntityIdSchema
|
|
817
802
|
});
|
|
818
803
|
|
|
@@ -832,14 +817,14 @@ async function createCart(api, params) {
|
|
|
832
817
|
async function getCart(api, params) {
|
|
833
818
|
const input = GetCartParamsSchema.parse(params);
|
|
834
819
|
return api.get(
|
|
835
|
-
`carts/${encodeURIComponent(input.
|
|
820
|
+
`carts/${encodeURIComponent(input.cartToken)}`,
|
|
836
821
|
StorefrontCartSchema
|
|
837
822
|
);
|
|
838
823
|
}
|
|
839
824
|
async function addCartItem(api, params) {
|
|
840
825
|
const input = AddCartItemParamsSchema.parse(params);
|
|
841
826
|
return api.post(
|
|
842
|
-
`carts/${encodeURIComponent(input.
|
|
827
|
+
`carts/${encodeURIComponent(input.cartToken)}/items`,
|
|
843
828
|
{
|
|
844
829
|
variantId: input.variantId,
|
|
845
830
|
quantity: input.quantity,
|
|
@@ -852,7 +837,7 @@ async function updateCartItemQuantity(api, params) {
|
|
|
852
837
|
const input = UpdateCartItemQuantityParamsSchema.parse(params);
|
|
853
838
|
return api.request(
|
|
854
839
|
"PATCH",
|
|
855
|
-
`carts/${encodeURIComponent(input.
|
|
840
|
+
`carts/${encodeURIComponent(input.cartToken)}/items/${encodeURIComponent(input.cartItemId)}`,
|
|
856
841
|
StorefrontCartSchema,
|
|
857
842
|
{ body: { quantity: input.quantity } }
|
|
858
843
|
);
|
|
@@ -861,7 +846,7 @@ async function removeCartItem(api, params) {
|
|
|
861
846
|
const input = RemoveCartItemParamsSchema.parse(params);
|
|
862
847
|
return api.request(
|
|
863
848
|
"DELETE",
|
|
864
|
-
`carts/${encodeURIComponent(input.
|
|
849
|
+
`carts/${encodeURIComponent(input.cartToken)}/items/${encodeURIComponent(input.cartItemId)}`,
|
|
865
850
|
StorefrontCartSchema
|
|
866
851
|
);
|
|
867
852
|
}
|
|
@@ -878,8 +863,18 @@ async function getCollectionBySlug(api, collectionSlug) {
|
|
|
878
863
|
async function getPageBySlug(api, pageSlug) {
|
|
879
864
|
return api.get(`pages/${encodeURIComponent(pageSlug)}`, CmsPageDetailsDtoSchema);
|
|
880
865
|
}
|
|
866
|
+
var CheckoutMetadataValueSchema = z.lazy(
|
|
867
|
+
() => z.union([
|
|
868
|
+
z.string(),
|
|
869
|
+
z.number(),
|
|
870
|
+
z.boolean(),
|
|
871
|
+
z.null(),
|
|
872
|
+
z.array(CheckoutMetadataValueSchema),
|
|
873
|
+
z.record(z.string(), CheckoutMetadataValueSchema)
|
|
874
|
+
])
|
|
875
|
+
);
|
|
881
876
|
var CartBuyerParamsSchema = z.object({
|
|
882
|
-
|
|
877
|
+
cartToken: CartTokenSchema,
|
|
883
878
|
email: z.string().email(),
|
|
884
879
|
firstName: z.string().min(1),
|
|
885
880
|
lastName: z.string().min(1),
|
|
@@ -905,7 +900,7 @@ var CartAddressWriteSchema = z.object({
|
|
|
905
900
|
}).nullable().optional()
|
|
906
901
|
});
|
|
907
902
|
var CartAddressesParamsSchema = z.object({
|
|
908
|
-
|
|
903
|
+
cartToken: CartTokenSchema,
|
|
909
904
|
shippingAddress: CartAddressWriteSchema,
|
|
910
905
|
billingAddress: CartAddressWriteSchema
|
|
911
906
|
});
|
|
@@ -924,9 +919,9 @@ var CartPaymentMethodSchema = z.object({
|
|
|
924
919
|
qrImageUrl: z.string().nullable().optional()
|
|
925
920
|
});
|
|
926
921
|
var StorefrontOrderBumpSchema = z.object({
|
|
927
|
-
id:
|
|
928
|
-
|
|
929
|
-
|
|
922
|
+
id: EntityIdSchema,
|
|
923
|
+
productId: EntityIdSchema,
|
|
924
|
+
variantId: EntityIdSchema,
|
|
930
925
|
productName: z.string(),
|
|
931
926
|
variantName: z.string().nullable().optional(),
|
|
932
927
|
imageUrl: z.string().nullable().optional(),
|
|
@@ -938,7 +933,7 @@ var StorefrontOrderBumpSchema = z.object({
|
|
|
938
933
|
description: z.string().nullable().optional()
|
|
939
934
|
});
|
|
940
935
|
var CartCheckoutReadParamsSchema = z.object({
|
|
941
|
-
|
|
936
|
+
cartToken: CartTokenSchema
|
|
942
937
|
});
|
|
943
938
|
var CartCheckoutReadResponseSchema = z.object({
|
|
944
939
|
cart: StorefrontCartSchema,
|
|
@@ -954,13 +949,13 @@ var CartCheckoutPaymentActionSchema = z.object({
|
|
|
954
949
|
phoneNumber: z.string().nullable().optional(),
|
|
955
950
|
accountHolder: z.string().nullable().optional(),
|
|
956
951
|
qrImageUrl: z.string().nullable().optional()
|
|
957
|
-
}).
|
|
952
|
+
}).strip().nullable().optional(),
|
|
958
953
|
url: z.string().nullable().optional(),
|
|
959
954
|
html: z.string().nullable().optional(),
|
|
960
955
|
clientSecret: z.string().nullable().optional(),
|
|
961
956
|
qrCode: z.string().nullable().optional(),
|
|
962
957
|
expiresAt: z.string().nullable().optional()
|
|
963
|
-
}).
|
|
958
|
+
}).strip();
|
|
964
959
|
var CartCheckoutPaymentSchema = z.object({
|
|
965
960
|
transactionId: z.string(),
|
|
966
961
|
paymentMethodCode: z.string(),
|
|
@@ -971,21 +966,21 @@ var CartCheckoutPaymentSchema = z.object({
|
|
|
971
966
|
actionType: z.string(),
|
|
972
967
|
receiptUrl: z.string().nullable().optional(),
|
|
973
968
|
action: CartCheckoutPaymentActionSchema.nullable().optional()
|
|
974
|
-
}).
|
|
969
|
+
}).strip();
|
|
975
970
|
var CartCheckoutResponseSchema = z.object({
|
|
976
971
|
publicKey: z.string().optional(),
|
|
977
972
|
publishableKey: z.string().optional(),
|
|
978
973
|
stripePublicKey: z.string().optional(),
|
|
979
974
|
clientSecret: z.string().optional(),
|
|
980
975
|
intentClientSecret: z.string().optional(),
|
|
981
|
-
orderId:
|
|
976
|
+
orderId: EntityIdSchema.optional(),
|
|
982
977
|
orderGroup: z.string().optional(),
|
|
983
|
-
orderIds: z.array(
|
|
978
|
+
orderIds: z.array(EntityIdSchema).optional(),
|
|
984
979
|
payment: CartCheckoutPaymentSchema.optional(),
|
|
985
980
|
cart: StorefrontCartSchema.optional()
|
|
986
|
-
}).
|
|
981
|
+
}).strip();
|
|
987
982
|
var CartCheckoutParamsSchema = z.object({
|
|
988
|
-
|
|
983
|
+
cartToken: CartTokenSchema,
|
|
989
984
|
paymentMethodCode: z.string().min(1),
|
|
990
985
|
externalRef: z.string().min(1),
|
|
991
986
|
receiptUrl: z.string().min(1).optional()
|
|
@@ -1004,8 +999,8 @@ var ShippingRateSchema = z.object({
|
|
|
1004
999
|
deliveryLocationName: z.string().nullable().optional(),
|
|
1005
1000
|
estimatedDeliveryDays: z.number().nullable().optional(),
|
|
1006
1001
|
serviceCode: z.string().nullable().optional(),
|
|
1007
|
-
metadata: z.record(z.string(),
|
|
1008
|
-
}).
|
|
1002
|
+
metadata: z.record(z.string(), CheckoutMetadataValueSchema).optional()
|
|
1003
|
+
}).strip();
|
|
1009
1004
|
var ShippingOptionGroupSchema = z.object({
|
|
1010
1005
|
sellerId: z.string(),
|
|
1011
1006
|
shippingProfileId: z.string().nullable().optional(),
|
|
@@ -1013,16 +1008,16 @@ var ShippingOptionGroupSchema = z.object({
|
|
|
1013
1008
|
totalWeight: z.number().optional(),
|
|
1014
1009
|
itemIds: z.array(z.string()).optional(),
|
|
1015
1010
|
rates: z.array(ShippingRateSchema)
|
|
1016
|
-
}).
|
|
1011
|
+
}).strip();
|
|
1017
1012
|
var ShippingOptionsResponseSchema = z.object({
|
|
1018
1013
|
groups: z.array(ShippingOptionGroupSchema)
|
|
1019
1014
|
});
|
|
1020
1015
|
var GetShippingOptionsParamsSchema = z.object({
|
|
1021
|
-
|
|
1016
|
+
cartToken: CartTokenSchema,
|
|
1022
1017
|
postalCode: z.string().min(1)
|
|
1023
1018
|
});
|
|
1024
1019
|
var PutShippingMethodParamsSchema = z.object({
|
|
1025
|
-
|
|
1020
|
+
cartToken: CartTokenSchema,
|
|
1026
1021
|
rateId: z.string().min(1),
|
|
1027
1022
|
shippingMethodId: z.string().min(1),
|
|
1028
1023
|
serviceCode: z.string().nullable().optional(),
|
|
@@ -1038,7 +1033,7 @@ var CartPaymentReceiptResponseSchema = z.object({
|
|
|
1038
1033
|
url: z.string()
|
|
1039
1034
|
});
|
|
1040
1035
|
var CartPromotionCodeParamsSchema = z.object({
|
|
1041
|
-
|
|
1036
|
+
cartToken: CartTokenSchema,
|
|
1042
1037
|
code: z.string().min(1)
|
|
1043
1038
|
});
|
|
1044
1039
|
|
|
@@ -1046,59 +1041,59 @@ var CartPromotionCodeParamsSchema = z.object({
|
|
|
1046
1041
|
async function getCartCheckout(api, params) {
|
|
1047
1042
|
const input = CartCheckoutReadParamsSchema.parse(params);
|
|
1048
1043
|
return api.get(
|
|
1049
|
-
`carts/${encodeURIComponent(input.
|
|
1044
|
+
`carts/${encodeURIComponent(input.cartToken)}/checkout`,
|
|
1050
1045
|
CartCheckoutReadResponseSchema
|
|
1051
1046
|
);
|
|
1052
1047
|
}
|
|
1053
1048
|
async function getShippingOptions(api, params) {
|
|
1054
1049
|
const input = GetShippingOptionsParamsSchema.parse(params);
|
|
1055
1050
|
return api.get(
|
|
1056
|
-
`carts/${encodeURIComponent(input.
|
|
1051
|
+
`carts/${encodeURIComponent(input.cartToken)}/shipping-options`,
|
|
1057
1052
|
ShippingOptionsResponseSchema,
|
|
1058
1053
|
{ query: { postalCode: input.postalCode } }
|
|
1059
1054
|
);
|
|
1060
1055
|
}
|
|
1061
1056
|
async function putCartShippingMethod(api, params) {
|
|
1062
1057
|
const input = PutShippingMethodParamsSchema.parse(params);
|
|
1063
|
-
const {
|
|
1058
|
+
const { cartToken, ...body } = input;
|
|
1064
1059
|
return api.request(
|
|
1065
1060
|
"PUT",
|
|
1066
|
-
`carts/${encodeURIComponent(
|
|
1061
|
+
`carts/${encodeURIComponent(cartToken)}/shipping-method`,
|
|
1067
1062
|
StorefrontCartSchema,
|
|
1068
1063
|
{ body }
|
|
1069
1064
|
);
|
|
1070
1065
|
}
|
|
1071
1066
|
async function patchCartBuyer(api, params) {
|
|
1072
1067
|
const input = CartBuyerParamsSchema.parse(params);
|
|
1073
|
-
const {
|
|
1068
|
+
const { cartToken, ...body } = input;
|
|
1074
1069
|
return api.request(
|
|
1075
1070
|
"PATCH",
|
|
1076
|
-
`carts/${encodeURIComponent(
|
|
1071
|
+
`carts/${encodeURIComponent(cartToken)}/buyer`,
|
|
1077
1072
|
StorefrontCartSchema,
|
|
1078
1073
|
{ body }
|
|
1079
1074
|
);
|
|
1080
1075
|
}
|
|
1081
1076
|
async function patchCartAddresses(api, params) {
|
|
1082
1077
|
const input = CartAddressesParamsSchema.parse(params);
|
|
1083
|
-
const {
|
|
1078
|
+
const { cartToken, shippingAddress, billingAddress } = input;
|
|
1084
1079
|
return api.request(
|
|
1085
1080
|
"PATCH",
|
|
1086
|
-
`carts/${encodeURIComponent(
|
|
1081
|
+
`carts/${encodeURIComponent(cartToken)}/addresses`,
|
|
1087
1082
|
StorefrontCartSchema,
|
|
1088
1083
|
{ body: { shippingAddress, billingAddress } }
|
|
1089
1084
|
);
|
|
1090
1085
|
}
|
|
1091
1086
|
async function checkoutCart(api, params) {
|
|
1092
1087
|
const input = CartCheckoutParamsSchema.parse(params);
|
|
1093
|
-
const {
|
|
1088
|
+
const { cartToken, ...body } = input;
|
|
1094
1089
|
return api.post(
|
|
1095
|
-
`carts/${encodeURIComponent(
|
|
1090
|
+
`carts/${encodeURIComponent(cartToken)}/checkout`,
|
|
1096
1091
|
body,
|
|
1097
1092
|
CartCheckoutResponseSchema
|
|
1098
1093
|
);
|
|
1099
1094
|
}
|
|
1100
1095
|
async function uploadPaymentReceipt(api, params) {
|
|
1101
|
-
const
|
|
1096
|
+
const cartToken = CartCheckoutReadParamsSchema.shape.cartToken.parse(params.cartToken);
|
|
1102
1097
|
if (!(params.file instanceof Blob)) {
|
|
1103
1098
|
throw new TypeError("uploadPaymentReceipt requiere un archivo (Blob/File)");
|
|
1104
1099
|
}
|
|
@@ -1106,7 +1101,7 @@ async function uploadPaymentReceipt(api, params) {
|
|
|
1106
1101
|
const name = params.fileName ?? (params.file instanceof File ? params.file.name : "receipt");
|
|
1107
1102
|
form.append("file", params.file, name);
|
|
1108
1103
|
return api.postForm(
|
|
1109
|
-
`carts/${encodeURIComponent(
|
|
1104
|
+
`carts/${encodeURIComponent(cartToken)}/payment-receipt`,
|
|
1110
1105
|
form,
|
|
1111
1106
|
CartPaymentReceiptResponseSchema
|
|
1112
1107
|
);
|
|
@@ -1114,7 +1109,7 @@ async function uploadPaymentReceipt(api, params) {
|
|
|
1114
1109
|
async function addCartPromotionCode(api, params) {
|
|
1115
1110
|
const input = CartPromotionCodeParamsSchema.parse(params);
|
|
1116
1111
|
return api.post(
|
|
1117
|
-
`carts/${encodeURIComponent(input.
|
|
1112
|
+
`carts/${encodeURIComponent(input.cartToken)}/promotion-codes`,
|
|
1118
1113
|
{ code: input.code },
|
|
1119
1114
|
StorefrontCartSchema
|
|
1120
1115
|
);
|
|
@@ -1123,7 +1118,7 @@ async function removeCartPromotionCode(api, params) {
|
|
|
1123
1118
|
const input = CartPromotionCodeParamsSchema.parse(params);
|
|
1124
1119
|
return api.request(
|
|
1125
1120
|
"DELETE",
|
|
1126
|
-
`carts/${encodeURIComponent(input.
|
|
1121
|
+
`carts/${encodeURIComponent(input.cartToken)}/promotion-codes/${encodeURIComponent(input.code)}`,
|
|
1127
1122
|
StorefrontCartSchema
|
|
1128
1123
|
);
|
|
1129
1124
|
}
|
|
@@ -1225,7 +1220,7 @@ var CustomerAddressUpsertInputSchema = z.object({
|
|
|
1225
1220
|
isDefault: z.boolean()
|
|
1226
1221
|
});
|
|
1227
1222
|
var CustomerAddressSchema = CustomerAddressUpsertInputSchema.extend({
|
|
1228
|
-
id:
|
|
1223
|
+
id: EntityIdSchema.optional()
|
|
1229
1224
|
});
|
|
1230
1225
|
var CustomerAddressesSchema = z.array(CustomerAddressSchema);
|
|
1231
1226
|
function toCustomerSavedAddresses(addresses) {
|
|
@@ -1243,7 +1238,7 @@ var ADDRESSES_PATH = "customer/addresses";
|
|
|
1243
1238
|
var CustomerAddressMutationResponseSchema = z.union([
|
|
1244
1239
|
CustomerAddressSchema,
|
|
1245
1240
|
z.object({
|
|
1246
|
-
id:
|
|
1241
|
+
id: EntityIdSchema
|
|
1247
1242
|
}),
|
|
1248
1243
|
z.null()
|
|
1249
1244
|
]);
|
|
@@ -1330,8 +1325,8 @@ var CustomerProfileSchema = z.object({
|
|
|
1330
1325
|
});
|
|
1331
1326
|
var nullableString = z.string().nullable().optional().transform((v) => v ?? null);
|
|
1332
1327
|
var CustomerMeSchema = z.object({
|
|
1333
|
-
id:
|
|
1334
|
-
storeId:
|
|
1328
|
+
id: EntityIdSchema,
|
|
1329
|
+
storeId: EntityIdSchema.optional(),
|
|
1335
1330
|
email: z.string().email(),
|
|
1336
1331
|
firstName: z.string(),
|
|
1337
1332
|
lastName: z.string(),
|
|
@@ -1440,10 +1435,10 @@ var CustomerOrderShippingAddressSchema = z.object({
|
|
|
1440
1435
|
metadata: z.record(z.unknown()).nullable().optional()
|
|
1441
1436
|
}).passthrough();
|
|
1442
1437
|
var CustomerOrderLineItemSchema = z.object({
|
|
1443
|
-
id:
|
|
1444
|
-
orderId:
|
|
1445
|
-
productId:
|
|
1446
|
-
variantId:
|
|
1438
|
+
id: EntityIdSchema,
|
|
1439
|
+
orderId: EntityIdSchema,
|
|
1440
|
+
productId: EntityIdSchema.nullable(),
|
|
1441
|
+
variantId: EntityIdSchema.nullable(),
|
|
1447
1442
|
title: z.string(),
|
|
1448
1443
|
subtitle: z.string().nullable().optional(),
|
|
1449
1444
|
thumbnail: z.string().nullable().optional(),
|
|
@@ -1455,10 +1450,10 @@ var CustomerOrderLineItemSchema = z.object({
|
|
|
1455
1450
|
status: z.string()
|
|
1456
1451
|
});
|
|
1457
1452
|
var CustomerOrderListItemSchema = z.object({
|
|
1458
|
-
orderId:
|
|
1453
|
+
orderId: EntityIdSchema,
|
|
1459
1454
|
orderNumber: z.string(),
|
|
1460
1455
|
orderGroup: z.string(),
|
|
1461
|
-
orderIds: z.array(
|
|
1456
|
+
orderIds: z.array(EntityIdSchema),
|
|
1462
1457
|
status: z.string(),
|
|
1463
1458
|
total: z.number(),
|
|
1464
1459
|
totalPaid: z.number(),
|
|
@@ -1473,7 +1468,7 @@ var CustomerOrderListItemSchema = z.object({
|
|
|
1473
1468
|
});
|
|
1474
1469
|
var CustomerOrderListSchema = z.array(CustomerOrderListItemSchema);
|
|
1475
1470
|
var CustomerOrderPaymentSchema = z.object({
|
|
1476
|
-
id:
|
|
1471
|
+
id: EntityIdSchema,
|
|
1477
1472
|
paymentMethod: z.string(),
|
|
1478
1473
|
paymentCode: z.string(),
|
|
1479
1474
|
amount: z.number(),
|
|
@@ -1490,7 +1485,7 @@ var CustomerOrderStatusTimelineSchema = z.object({
|
|
|
1490
1485
|
source: z.string()
|
|
1491
1486
|
});
|
|
1492
1487
|
var CustomerOrderDetailSchema = z.object({
|
|
1493
|
-
id:
|
|
1488
|
+
id: EntityIdSchema,
|
|
1494
1489
|
orderNumber: z.string(),
|
|
1495
1490
|
orderGroup: z.string(),
|
|
1496
1491
|
status: z.string(),
|
|
@@ -1895,6 +1890,6 @@ function stripHtml(html) {
|
|
|
1895
1890
|
return html.replace(/<br\s*\/?>/gi, " ").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
|
|
1896
1891
|
}
|
|
1897
1892
|
|
|
1898
|
-
export { AddCartItemParamsSchema, ApiError, BundleItemSchema, CartAddressWriteSchema, CartAddressesParamsSchema, CartBuyerParamsSchema, CartCheckoutParamsSchema, CartCheckoutPaymentActionSchema, CartCheckoutPaymentSchema, CartCheckoutReadParamsSchema, CartCheckoutReadResponseSchema, CartCheckoutResponseSchema, CartItemModifierSchema, CartPaymentMethodSchema, CartPaymentReceiptResponseSchema, CartPromotionCodeParamsSchema, CmsBlockDtoSchema, CmsBrandingSettingsDtoSchema, CmsContactSettingsDtoSchema, CmsContentChannelSchema, CmsCustomScriptsDtoSchema, CmsMenuDtoSchema, CmsMenuItemSchema, CmsPageDetailsDtoSchema, CmsPageStatusSchema, CmsSectionDtoSchema, CmsSeoSettingsDtoSchema, CmsSiteSettingsDtoSchema, CmsSnapshotDtoSchema, CmsSocialLinksDtoSchema, CmsTrackingSettingsDtoSchema, CollectionSchema, CollectionsSchema, CountriesSchema, CountrySchema, CreateCartParamsSchema, CreateProductReviewParamsSchema, CustomerAddressMutationResponseSchema, CustomerAddressSchema, CustomerAddressUpsertInputSchema, CustomerAddressesSchema, CustomerMeSchema, CustomerOrderDetailSchema, CustomerOrderLineItemSchema, CustomerOrderListItemSchema, CustomerOrderListSchema, CustomerOrderPaymentSchema, CustomerOrderShippingAddressSchema, CustomerOrderStatusTimelineSchema, CustomerProfilePatchSchema, CustomerProfileSchema, CustomerRegisterRequestSchema, DEFAULT_API_BASE_URL, DEFAULT_API_VERSION, DepartmentSchema, DepartmentsSchema, DistrictSchema, DistrictsSchema, EntityIdSchema, FacetItemSchema, FacetSchema, GeoDivisionSchema, GeoDivisionTypeSchema, GetCartParamsSchema, GetDepartmentsParamsSchema, GetDistrictsParamsSchema, GetProvincesParamsSchema, GetShippingOptionsParamsSchema, JsonElementSchema, ListProductReviewsParamsSchema, NullableEntityIdSchema, OptionalEntityIdSchema, PriceTierSchema, ProductAutocompleteParamsSchema, ProductDetailParamsSchema, ProductDetailSchema, ProductImageSchema, ProductPriceTierSchema,
|
|
1893
|
+
export { AddCartItemParamsSchema, ApiError, BundleItemSchema, CartAddressWriteSchema, CartAddressesParamsSchema, CartBuyerParamsSchema, CartCheckoutParamsSchema, CartCheckoutPaymentActionSchema, CartCheckoutPaymentSchema, CartCheckoutReadParamsSchema, CartCheckoutReadResponseSchema, CartCheckoutResponseSchema, CartItemModifierSchema, CartPaymentMethodSchema, CartPaymentReceiptResponseSchema, CartPromotionCodeParamsSchema, CartTokenSchema, CheckoutMetadataValueSchema, CmsBlockDtoSchema, CmsBrandingSettingsDtoSchema, CmsContactSettingsDtoSchema, CmsContentChannelSchema, CmsCustomScriptsDtoSchema, CmsMenuDtoSchema, CmsMenuItemSchema, CmsPageDetailsDtoSchema, CmsPageStatusSchema, CmsSectionDtoSchema, CmsSeoSettingsDtoSchema, CmsSiteSettingsDtoSchema, CmsSnapshotDtoSchema, CmsSocialLinksDtoSchema, CmsTrackingSettingsDtoSchema, CollectionSchema, CollectionsSchema, CountriesSchema, CountrySchema, CreateCartParamsSchema, CreateProductReviewParamsSchema, CustomerAddressMutationResponseSchema, CustomerAddressSchema, CustomerAddressUpsertInputSchema, CustomerAddressesSchema, CustomerMeSchema, CustomerOrderDetailSchema, CustomerOrderLineItemSchema, CustomerOrderListItemSchema, CustomerOrderListSchema, CustomerOrderPaymentSchema, CustomerOrderShippingAddressSchema, CustomerOrderStatusTimelineSchema, CustomerProfilePatchSchema, CustomerProfileSchema, CustomerRegisterRequestSchema, DEFAULT_API_BASE_URL, DEFAULT_API_VERSION, DepartmentSchema, DepartmentsSchema, DistrictSchema, DistrictsSchema, EntityIdSchema, FacetItemSchema, FacetSchema, GeoDivisionSchema, GeoDivisionTypeSchema, GetCartParamsSchema, GetDepartmentsParamsSchema, GetDistrictsParamsSchema, GetProvincesParamsSchema, GetShippingOptionsParamsSchema, JsonElementSchema, ListProductReviewsParamsSchema, NullableEntityIdSchema, OptionalEntityIdSchema, PriceTierSchema, ProductAutocompleteParamsSchema, ProductDetailParamsSchema, ProductDetailSchema, ProductImageSchema, ProductPriceTierSchema, ProductSchema, ProductSortSchema, ProductSuggestionSchema, ProductSuggestionsSchema, ProductSummariesSchema, ProductSummarySchema, ProductsParamsSchema, ProductsResponseSchema, ProvinceSchema, ProvincesSchema, PutShippingMethodParamsSchema, RelatedProductsParamsSchema, RemoveCartItemParamsSchema, SearchFilterSchema, ShippingOptionGroupSchema, ShippingOptionsResponseSchema, ShippingRateSchema, SizeGuideMeasurementSchema, SizeGuideRowSchema, SizeGuideSchema, SpecItemSchema, StoreCheckoutCartPageSettingsSchema, StoreCheckoutGeneralSettingsSchema, StoreCheckoutOrderBumpSettingsSchema, StoreCheckoutOrdersAndPaymentsSettingsSchema, StoreCheckoutSettingsSchema, StoreCheckoutShippingSettingsSchema, StoreFeatureFlagsSchema, StoreModelSchema, StoreSettingsSnapshotDtoSchema, StoreThemeSettingsSchema, StoreTypeSchema, StoreVisibilitySchema, StorefrontAddressSchema, StorefrontCartBundleItemSchema, StorefrontCartItemSchema, StorefrontCartSchema, StorefrontCartShippingMethodSchema, StorefrontCartStatusSchema, StorefrontCartTotalsSchema, StorefrontCheckoutSettingsSchema, StorefrontCmsBrandingSchema, StorefrontCmsContactSchema, StorefrontCmsCustomScriptsSchema, StorefrontCmsPageSchema, StorefrontCmsSeoSchema, StorefrontCmsSettingsSchema, StorefrontCmsSocialLinksSchema, StorefrontCmsTrackingSchema, StorefrontFeaturesEnabledSchema, StorefrontMenuItemSchema, StorefrontMenuSchema, StorefrontOrderBumpSchema, StorefrontReviewSchema, StorefrontReviewsSchema, StorefrontSettingsSchema, StorefrontStoreSchema, StorefrontStoreTypeSchema, StorefrontThemeConfigSchema, UpdateCartItemQuantityParamsSchema, VariantItemSchema, VariantOptionSchema, VariantSchema, addCartItem, addCartPromotionCode, autocompleteProducts, checkoutCart, createApi, createCart, createClient, createCustomerAddress, createProductReview, createStorefrontClient, customerMeToProfile, customerMeToProfilePatch, customerOrderStatusTone, customerProfileToPatch, deleteCustomerAddress, formatCustomerOrderStatus, formatOrderDate, formatOrderDateTime, getCart, getCartCheckout, getCountries, getCustomerAddresses, getCustomerMe, getCustomerOrder, getCustomerOrders, getDepartments, getDistricts, getMenuItems, getPageBySlug, getProductBySlug, getProducts, getProvinces, getRelatedProducts, getShippingOptions, listProductReviews, patchCartAddresses, patchCartBuyer, patchCustomer, putCartShippingMethod, registerCustomer, removeCartItem, removeCartPromotionCode, resolveApiBaseUrl, sanitizeHtml, stripHtml, toCustomerSavedAddresses, updateCartItemQuantity, updateCustomerAddress, uploadPaymentReceipt };
|
|
1899
1894
|
//# sourceMappingURL=index.js.map
|
|
1900
1895
|
//# sourceMappingURL=index.js.map
|