@ecomiq/core 0.1.8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +39 -2
- package/dist/_virtual/_rolldown/runtime-C6LprzCP.cjs +22 -0
- package/dist/api.cjs +117 -102
- package/dist/api.d.cts +33 -37
- package/dist/api.d.ts +33 -37
- package/dist/api.js +116 -100
- package/dist/client.cjs +499 -1681
- package/dist/client.d.cts +156 -15
- package/dist/client.d.ts +156 -15
- package/dist/client.js +500 -1680
- package/dist/index.cjs +333 -2108
- package/dist/index.d.cts +53 -1117
- package/dist/index.d.ts +53 -1117
- package/dist/index.js +52 -1910
- package/dist/libs/bounded-read-cache-Abmb5VnJ.js +41 -0
- package/dist/libs/bounded-read-cache-D4644LJo.cjs +41 -0
- package/dist/libs/catalog-link-key-B7l5KZsF.js +9 -0
- package/dist/libs/catalog-link-key-CZTHJBGD.cjs +9 -0
- package/dist/libs/catalog-link-key.d.cts +2 -0
- package/dist/libs/catalog-link-key.d.ts +2 -0
- package/dist/libs/graphql-_6Y8lR_Q.js +49 -0
- package/dist/libs/graphql-selection-Cj51WkJn.cjs +21 -0
- package/dist/libs/graphql-selection-H1RMh6VD.js +21 -0
- package/dist/libs/graphql-selection.d.cts +3 -0
- package/dist/libs/graphql-selection.d.ts +3 -0
- package/dist/libs/graphql-wJH7HaQU.cjs +50 -0
- package/dist/libs/graphql.d.cts +24 -0
- package/dist/libs/graphql.d.ts +24 -0
- package/dist/models/amounts-cKBCecl7.js +5 -0
- package/dist/models/amounts-lmg89eJQ.cjs +4 -0
- package/dist/models/articles-C-4JvT2Z.js +27 -0
- package/dist/models/articles-xHCXLKDK.cjs +30 -0
- package/dist/models/articles.d.cts +46 -0
- package/dist/models/articles.d.ts +46 -0
- package/dist/models/catalog-links-BzJeyBy4.js +80 -0
- package/dist/models/catalog-links-c4LADGf_.cjs +88 -0
- package/dist/models/catalog-links.d.cts +39 -0
- package/dist/models/catalog-links.d.ts +39 -0
- package/dist/models/categories-CKkJY8_P.js +42 -0
- package/dist/models/categories-DZ5i5kwi.cjs +45 -0
- package/dist/models/categories.d.cts +54 -0
- package/dist/models/categories.d.ts +54 -0
- package/dist/models/collections.cjs +13 -24
- package/dist/models/collections.d.cts +23 -56
- package/dist/models/collections.d.ts +23 -56
- package/dist/models/collections.js +12 -22
- package/dist/models/complaint-book-D5INpuI2.cjs +64 -0
- package/dist/models/complaint-book-QpQZe7Xl.js +58 -0
- package/dist/models/complaint-book.d.cts +71 -0
- package/dist/models/complaint-book.d.ts +71 -0
- package/dist/models/customer-address.cjs +39 -32
- package/dist/models/customer-address.d.cts +59 -158
- package/dist/models/customer-address.d.ts +59 -158
- package/dist/models/customer-address.js +38 -30
- package/dist/models/customer-order.cjs +181 -136
- package/dist/models/customer-order.d.cts +430 -862
- package/dist/models/customer-order.d.ts +430 -862
- package/dist/models/customer-order.js +178 -135
- package/dist/models/customer-profile.cjs +121 -112
- package/dist/models/customer-profile.d.cts +90 -175
- package/dist/models/customer-profile.d.ts +90 -175
- package/dist/models/customer-profile.js +121 -110
- package/dist/models/customer-registration-C13knqyv.js +28 -0
- package/dist/models/customer-registration-EZ0yZgGr.cjs +31 -0
- package/dist/models/customer-registration.d.cts +66 -0
- package/dist/models/customer-registration.d.ts +66 -0
- package/dist/models/customer-session-BiX0TXhO.js +41 -0
- package/dist/models/customer-session-JeQiC8Yx.cjs +45 -0
- package/dist/models/customer-session.d.cts +61 -0
- package/dist/models/customer-session.d.ts +61 -0
- package/dist/models/geo.cjs +52 -51
- package/dist/models/geo.d.cts +141 -270
- package/dist/models/geo.d.ts +141 -270
- package/dist/models/geo.js +51 -49
- package/dist/models/ids.cjs +9 -13
- package/dist/models/ids.d.cts +9 -12
- package/dist/models/ids.d.ts +9 -12
- package/dist/models/ids.js +8 -12
- package/dist/models/order-draft-CnHJ0btL.js +37 -0
- package/dist/models/order-draft-PFBZfRRR.cjs +39 -0
- package/dist/models/order-draft.d.cts +51 -0
- package/dist/models/order-draft.d.ts +51 -0
- package/dist/models/order-review--xGlZKtS.cjs +18 -0
- package/dist/models/order-review-egGeCaqB.js +17 -0
- package/dist/models/order-review.d.cts +22 -0
- package/dist/models/order-review.d.ts +22 -0
- package/dist/models/order-status-CS_OeSPY.cjs +66 -0
- package/dist/models/order-status-CgaLkU0M.js +60 -0
- package/dist/models/order-status.d.cts +298 -0
- package/dist/models/order-status.d.ts +298 -0
- package/dist/models/payment-methods--VUUZpMz.js +17 -0
- package/dist/models/payment-methods-CmK08zBM.cjs +19 -0
- package/dist/models/payment-methods.d.cts +28 -0
- package/dist/models/payment-methods.d.ts +28 -0
- package/dist/models/products.cjs +214 -200
- package/dist/models/products.d.cts +616 -1359
- package/dist/models/products.d.ts +616 -1359
- package/dist/models/products.js +210 -192
- package/dist/models/search.cjs +15 -202
- package/dist/models/search.d.cts +21 -51
- package/dist/models/search.d.ts +21 -51
- package/dist/models/search.js +14 -200
- package/dist/models/sellers.cjs +44 -0
- package/dist/models/sellers.d.cts +82 -0
- package/dist/models/sellers.d.ts +82 -0
- package/dist/models/sellers.js +38 -0
- package/dist/models/settings.cjs +205 -238
- package/dist/models/settings.d.cts +862 -6949
- package/dist/models/settings.d.ts +862 -6949
- package/dist/models/settings.js +213 -241
- package/dist/models/storefront-cart.cjs +143 -129
- package/dist/models/storefront-cart.d.cts +255 -713
- package/dist/models/storefront-cart.d.ts +255 -713
- package/dist/models/storefront-cart.js +140 -127
- package/dist/models/storefront-checkout.cjs +212 -298
- package/dist/models/storefront-checkout.d.cts +656 -2441
- package/dist/models/storefront-checkout.d.ts +656 -2441
- package/dist/models/storefront-checkout.js +208 -298
- package/dist/models/storefront-reviews.cjs +62 -226
- package/dist/models/storefront-reviews.d.cts +73 -141
- package/dist/models/storefront-reviews.d.ts +73 -141
- package/dist/models/storefront-reviews.js +59 -225
- package/dist/models/tracking-CiIAhQW0.js +33 -0
- package/dist/models/tracking-wNyzQ6Bp.cjs +36 -0
- package/dist/models/tracking.d.cts +26 -0
- package/dist/models/tracking.d.ts +26 -0
- package/dist/models/urls-B0ZODOwH.cjs +35 -0
- package/dist/models/urls-Dt_dTt4Q.js +33 -0
- package/dist/models/urls.d.cts +201 -0
- package/dist/models/urls.d.ts +201 -0
- package/dist/redirects.cjs +113 -0
- package/dist/redirects.d.cts +11 -0
- package/dist/redirects.d.ts +11 -0
- package/dist/redirects.js +108 -0
- package/dist/services/article.service-DBsOvflH.js +10 -0
- package/dist/services/article.service-zmTkbbPV.cjs +11 -0
- package/dist/services/article.service.d.cts +4 -0
- package/dist/services/article.service.d.ts +4 -0
- package/dist/services/cart.service-B0D8s6jI.cjs +37 -0
- package/dist/services/cart.service-yMCz9oQP.js +33 -0
- package/dist/services/cart.service.d.cts +527 -0
- package/dist/services/cart.service.d.ts +527 -0
- package/dist/services/catalog-link.service-BQ2d-EPX.js +8 -0
- package/dist/services/catalog-link.service-DiB-OVjn.cjs +8 -0
- package/dist/services/category.service-8tieYX2r.js +6 -0
- package/dist/services/category.service-BsSJZV2B.cjs +6 -0
- package/dist/services/checkout.service-CC-3tm2y.js +60 -0
- package/dist/services/checkout.service-CG8KrDNY.cjs +69 -0
- package/dist/services/checkout.service.d.cts +439 -0
- package/dist/services/checkout.service.d.ts +439 -0
- package/dist/services/collection.service-C4QETpuI.js +11 -0
- package/dist/services/collection.service-DHGN3rhs.cjs +12 -0
- package/dist/services/complaint-book.service-C7TxltQe.cjs +13 -0
- package/dist/services/complaint-book.service-DXiVyKdD.js +12 -0
- package/dist/services/complaint-book.service.d.cts +4 -0
- package/dist/services/complaint-book.service.d.ts +4 -0
- package/dist/services/customer-address.service-Ca4qla_R.cjs +51 -0
- package/dist/services/customer-address.service-xEThx7cQ.js +47 -0
- package/dist/services/customer-address.service.d.cts +19 -0
- package/dist/services/customer-address.service.d.ts +19 -0
- package/dist/services/customer-order.service-DLGgT0xa.cjs +54 -0
- package/dist/services/customer-order.service-qHoRBuyX.js +51 -0
- package/dist/services/customer-order.service.d.cts +34 -0
- package/dist/services/customer-order.service.d.ts +34 -0
- package/dist/services/customer-registration.service-C3BNyCHP.cjs +10 -0
- package/dist/services/customer-registration.service-CxcWD2hf.js +9 -0
- package/dist/services/customer-registration.service.d.cts +5 -0
- package/dist/services/customer-registration.service.d.ts +5 -0
- package/dist/services/customer-session.service-4YgfbWRB.js +16 -0
- package/dist/services/customer-session.service-Bd8pLC2v.cjs +19 -0
- package/dist/services/customer.service-BM0NrOxP.cjs +26 -0
- package/dist/services/customer.service-BoU6l2-R.js +25 -0
- package/dist/services/customer.service.d.cts +10 -0
- package/dist/services/customer.service.d.ts +10 -0
- package/dist/services/geo.service-C32R7N8W.js +39 -0
- package/dist/services/geo.service-JeTT3Wun.cjs +42 -0
- package/dist/services/geo.service.d.cts +10 -0
- package/dist/services/geo.service.d.ts +10 -0
- package/dist/services/layout.service-BkvLzl1g.cjs +50 -0
- package/dist/services/layout.service-DmbeMOkK.js +50 -0
- package/dist/services/layout.service.d.cts +9 -0
- package/dist/services/layout.service.d.ts +9 -0
- package/dist/services/order-draft.service-D9gy-OPr.cjs +14 -0
- package/dist/services/order-draft.service-DYPR_pcV.js +13 -0
- package/dist/services/order-draft.service.d.cts +4 -0
- package/dist/services/order-draft.service.d.ts +4 -0
- package/dist/services/order-review.service-BEr-FB6_.cjs +11 -0
- package/dist/services/order-review.service-PdBPUsxE.js +11 -0
- package/dist/services/order-review.service.d.cts +7 -0
- package/dist/services/order-review.service.d.ts +7 -0
- package/dist/services/order-status.service-Cn7dsaJo.cjs +26 -0
- package/dist/services/order-status.service-MC9hVpP-.js +23 -0
- package/dist/services/order-status.service.d.cts +16 -0
- package/dist/services/order-status.service.d.ts +16 -0
- package/dist/services/page.service-CWhWCjMQ.js +7 -0
- package/dist/services/page.service-DmCSeMiR.cjs +7 -0
- package/dist/services/page.service.d.cts +4 -0
- package/dist/services/page.service.d.ts +4 -0
- package/dist/services/payment-method.service-CEt_nB4R.cjs +7 -0
- package/dist/services/payment-method.service-CjKbAsOh.js +7 -0
- package/dist/services/payment-method.service.d.cts +4 -0
- package/dist/services/payment-method.service.d.ts +4 -0
- package/dist/services/product.service-B05Qmbuh.js +35 -0
- package/dist/services/product.service-B7OFZWB1.cjs +37 -0
- package/dist/services/product.service.d.cts +231 -0
- package/dist/services/product.service.d.ts +231 -0
- package/dist/services/review.service-CO2icjpu.cjs +46 -0
- package/dist/services/review.service-De1YkhFp.js +43 -0
- package/dist/services/review.service.d.cts +28 -0
- package/dist/services/review.service.d.ts +28 -0
- package/dist/services/search.service-Bx1zbTHJ.cjs +10 -0
- package/dist/services/search.service-DSBMhaSY.js +10 -0
- package/dist/services/search.service.d.cts +9 -0
- package/dist/services/search.service.d.ts +9 -0
- package/dist/services/seller.service-D11WHhbC.cjs +10 -0
- package/dist/services/seller.service-DUptDTv4.js +9 -0
- package/dist/services/seller.service.d.cts +42 -0
- package/dist/services/seller.service.d.ts +42 -0
- package/dist/services/tracking.service-CPK1B69N.js +11 -0
- package/dist/services/tracking.service-DqOoi8qr.cjs +11 -0
- package/dist/services/tracking.service.d.cts +7 -0
- package/dist/services/tracking.service.d.ts +7 -0
- package/dist/services/url.service-B-nC14Ue.cjs +19 -0
- package/dist/services/url.service-CLW0Tc7S.js +18 -0
- package/dist/storefront-cache-revision.cjs +23 -0
- package/dist/storefront-cache-revision.d.cts +16 -0
- package/dist/storefront-cache-revision.d.ts +16 -0
- package/dist/storefront-cache-revision.js +17 -0
- package/dist/storefront-routes.cjs +14 -0
- package/dist/storefront-routes.d.cts +11 -0
- package/dist/storefront-routes.d.ts +11 -0
- package/dist/storefront-routes.js +12 -0
- package/dist/utils-CDEC5xcY.cjs +139 -0
- package/dist/utils-DK7qa54o.js +136 -0
- package/dist/utils.d.cts +3 -0
- package/dist/utils.d.ts +3 -0
- package/dist/video-links-CbRO0m8V.js +47 -0
- package/dist/video-links-ClryQjPH.cjs +47 -0
- package/dist/video-links.d.cts +7 -0
- package/dist/video-links.d.ts +7 -0
- package/package.json +28 -11
- package/dist/api.cjs.map +0 -1
- package/dist/api.js.map +0 -1
- package/dist/client-4ZTG2RZ3.d.ts +0 -195
- package/dist/client-BpX4yR6S.d.cts +0 -195
- package/dist/client.cjs.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/models/collections.cjs.map +0 -1
- package/dist/models/collections.js.map +0 -1
- package/dist/models/customer-address.cjs.map +0 -1
- package/dist/models/customer-address.js.map +0 -1
- package/dist/models/customer-order.cjs.map +0 -1
- package/dist/models/customer-order.js.map +0 -1
- package/dist/models/customer-profile.cjs.map +0 -1
- package/dist/models/customer-profile.js.map +0 -1
- package/dist/models/geo.cjs.map +0 -1
- package/dist/models/geo.js.map +0 -1
- package/dist/models/ids.cjs.map +0 -1
- package/dist/models/ids.js.map +0 -1
- package/dist/models/products.cjs.map +0 -1
- package/dist/models/products.js.map +0 -1
- package/dist/models/search.cjs.map +0 -1
- package/dist/models/search.js.map +0 -1
- package/dist/models/settings.cjs.map +0 -1
- package/dist/models/settings.js.map +0 -1
- package/dist/models/storefront-cart.cjs.map +0 -1
- package/dist/models/storefront-cart.js.map +0 -1
- package/dist/models/storefront-checkout.cjs.map +0 -1
- package/dist/models/storefront-checkout.js.map +0 -1
- package/dist/models/storefront-reviews.cjs.map +0 -1
- package/dist/models/storefront-reviews.js.map +0 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const require_models_customer_order = require("../models/customer-order.cjs");
|
|
2
|
+
let zod = require("zod");
|
|
3
|
+
// src/services/customer-order.service.ts
|
|
4
|
+
const ORDERS_PATH = "customer/orders";
|
|
5
|
+
/** GET /v1/customer/orders → proxy `customer/orders` */
|
|
6
|
+
async function getCustomerOrders(api, options = {}) {
|
|
7
|
+
const query = {};
|
|
8
|
+
if (options.cursor) query.cursor = options.cursor;
|
|
9
|
+
if (options.search) query.search = options.search;
|
|
10
|
+
if (options.status) query.status = options.status;
|
|
11
|
+
if (options.sortDirection) query.sortDirection = options.sortDirection;
|
|
12
|
+
return api.get(ORDERS_PATH, require_models_customer_order.CustomerOrderPageSchema, {
|
|
13
|
+
headers: options.headers,
|
|
14
|
+
signal: options.signal,
|
|
15
|
+
query: Object.keys(query).length > 0 ? query : void 0
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/** GET /v1/customer/orders/{orderId} → proxy `customer/orders/{orderId}` */
|
|
19
|
+
async function getCustomerOrder(api, orderId, options = {}) {
|
|
20
|
+
const id = orderId.trim();
|
|
21
|
+
if (!id) throw new Error("orderId requerido");
|
|
22
|
+
return api.get(`${ORDERS_PATH}/${encodeURIComponent(id)}`, require_models_customer_order.CustomerOrderDetailSchema, {
|
|
23
|
+
headers: options.headers,
|
|
24
|
+
signal: options.signal
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function orderPath(orderId) {
|
|
28
|
+
const id = orderId.trim();
|
|
29
|
+
if (!id) throw new Error("orderId requerido");
|
|
30
|
+
return `${ORDERS_PATH}/${encodeURIComponent(id)}`;
|
|
31
|
+
}
|
|
32
|
+
/** POST /v1/customer/orders/{orderId}/return-request (multipart, hasta 3 fotos) */
|
|
33
|
+
async function requestCustomerOrderReturn(api, orderId, input, options = {}) {
|
|
34
|
+
const form = new FormData();
|
|
35
|
+
form.append("reason", input.reason);
|
|
36
|
+
if (input.comment) form.append("comment", input.comment);
|
|
37
|
+
form.append("items", JSON.stringify(input.items));
|
|
38
|
+
for (const photo of input.photos ?? []) form.append("files", photo, photo instanceof File ? photo.name : "foto");
|
|
39
|
+
await api.postForm(`${orderPath(orderId)}/return-request`, form, zod.z.null(), {
|
|
40
|
+
headers: options.headers,
|
|
41
|
+
signal: options.signal
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/** POST /v1/customer/orders/{orderId}/cancellation-request */
|
|
45
|
+
async function requestCustomerOrderCancellation(api, orderId, input, options = {}) {
|
|
46
|
+
await api.post(`${orderPath(orderId)}/cancellation-request`, input, zod.z.null(), {
|
|
47
|
+
headers: options.headers,
|
|
48
|
+
signal: options.signal
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
exports.getCustomerOrder = getCustomerOrder;
|
|
52
|
+
exports.getCustomerOrders = getCustomerOrders;
|
|
53
|
+
exports.requestCustomerOrderCancellation = requestCustomerOrderCancellation;
|
|
54
|
+
exports.requestCustomerOrderReturn = requestCustomerOrderReturn;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { CustomerOrderDetailSchema, CustomerOrderPageSchema } from "../models/customer-order.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
// src/services/customer-order.service.ts
|
|
4
|
+
const ORDERS_PATH = "customer/orders";
|
|
5
|
+
/** GET /v1/customer/orders → proxy `customer/orders` */
|
|
6
|
+
async function getCustomerOrders(api, options = {}) {
|
|
7
|
+
const query = {};
|
|
8
|
+
if (options.cursor) query.cursor = options.cursor;
|
|
9
|
+
if (options.search) query.search = options.search;
|
|
10
|
+
if (options.status) query.status = options.status;
|
|
11
|
+
if (options.sortDirection) query.sortDirection = options.sortDirection;
|
|
12
|
+
return api.get(ORDERS_PATH, CustomerOrderPageSchema, {
|
|
13
|
+
headers: options.headers,
|
|
14
|
+
signal: options.signal,
|
|
15
|
+
query: Object.keys(query).length > 0 ? query : void 0
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/** GET /v1/customer/orders/{orderId} → proxy `customer/orders/{orderId}` */
|
|
19
|
+
async function getCustomerOrder(api, orderId, options = {}) {
|
|
20
|
+
const id = orderId.trim();
|
|
21
|
+
if (!id) throw new Error("orderId requerido");
|
|
22
|
+
return api.get(`${ORDERS_PATH}/${encodeURIComponent(id)}`, CustomerOrderDetailSchema, {
|
|
23
|
+
headers: options.headers,
|
|
24
|
+
signal: options.signal
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function orderPath(orderId) {
|
|
28
|
+
const id = orderId.trim();
|
|
29
|
+
if (!id) throw new Error("orderId requerido");
|
|
30
|
+
return `${ORDERS_PATH}/${encodeURIComponent(id)}`;
|
|
31
|
+
}
|
|
32
|
+
/** POST /v1/customer/orders/{orderId}/return-request (multipart, hasta 3 fotos) */
|
|
33
|
+
async function requestCustomerOrderReturn(api, orderId, input, options = {}) {
|
|
34
|
+
const form = new FormData();
|
|
35
|
+
form.append("reason", input.reason);
|
|
36
|
+
if (input.comment) form.append("comment", input.comment);
|
|
37
|
+
form.append("items", JSON.stringify(input.items));
|
|
38
|
+
for (const photo of input.photos ?? []) form.append("files", photo, photo instanceof File ? photo.name : "foto");
|
|
39
|
+
await api.postForm(`${orderPath(orderId)}/return-request`, form, z.null(), {
|
|
40
|
+
headers: options.headers,
|
|
41
|
+
signal: options.signal
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/** POST /v1/customer/orders/{orderId}/cancellation-request */
|
|
45
|
+
async function requestCustomerOrderCancellation(api, orderId, input, options = {}) {
|
|
46
|
+
await api.post(`${orderPath(orderId)}/cancellation-request`, input, z.null(), {
|
|
47
|
+
headers: options.headers,
|
|
48
|
+
signal: options.signal
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
export { getCustomerOrder, getCustomerOrders, requestCustomerOrderCancellation, requestCustomerOrderReturn };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Api } from "../api.cjs";
|
|
2
|
+
import { CustomerOrderDetail, CustomerOrderPage } from "../models/customer-order.cjs";
|
|
3
|
+
export type CustomerOrderRequestOptions = {
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
};
|
|
7
|
+
export type CustomerOrderStatusFilter = 'open' | 'delivered' | 'cancelled';
|
|
8
|
+
export type CustomerOrderListOptions = CustomerOrderRequestOptions & {
|
|
9
|
+
cursor?: string;
|
|
10
|
+
search?: string;
|
|
11
|
+
status?: CustomerOrderStatusFilter;
|
|
12
|
+
sortDirection?: 'asc' | 'desc';
|
|
13
|
+
};
|
|
14
|
+
/** GET /v1/customer/orders → proxy `customer/orders` */
|
|
15
|
+
export declare function getCustomerOrders(api: Api, options?: CustomerOrderListOptions): Promise<CustomerOrderPage>;
|
|
16
|
+
/** GET /v1/customer/orders/{orderId} → proxy `customer/orders/{orderId}` */
|
|
17
|
+
export declare function getCustomerOrder(api: Api, orderId: string, options?: CustomerOrderRequestOptions): Promise<CustomerOrderDetail>;
|
|
18
|
+
export type CustomerOrderReturnInput = {
|
|
19
|
+
reason: string;
|
|
20
|
+
comment?: string;
|
|
21
|
+
items: {
|
|
22
|
+
itemId: string;
|
|
23
|
+
quantity: number;
|
|
24
|
+
}[];
|
|
25
|
+
photos?: Blob[];
|
|
26
|
+
};
|
|
27
|
+
export type CustomerOrderCancellationInput = {
|
|
28
|
+
reason: string;
|
|
29
|
+
comment?: string;
|
|
30
|
+
};
|
|
31
|
+
/** POST /v1/customer/orders/{orderId}/return-request (multipart, hasta 3 fotos) */
|
|
32
|
+
export declare function requestCustomerOrderReturn(api: Api, orderId: string, input: CustomerOrderReturnInput, options?: CustomerOrderRequestOptions): Promise<void>;
|
|
33
|
+
/** POST /v1/customer/orders/{orderId}/cancellation-request */
|
|
34
|
+
export declare function requestCustomerOrderCancellation(api: Api, orderId: string, input: CustomerOrderCancellationInput, options?: CustomerOrderRequestOptions): Promise<void>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Api } from "../api.js";
|
|
2
|
+
import { CustomerOrderDetail, CustomerOrderPage } from "../models/customer-order.js";
|
|
3
|
+
export type CustomerOrderRequestOptions = {
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
};
|
|
7
|
+
export type CustomerOrderStatusFilter = 'open' | 'delivered' | 'cancelled';
|
|
8
|
+
export type CustomerOrderListOptions = CustomerOrderRequestOptions & {
|
|
9
|
+
cursor?: string;
|
|
10
|
+
search?: string;
|
|
11
|
+
status?: CustomerOrderStatusFilter;
|
|
12
|
+
sortDirection?: 'asc' | 'desc';
|
|
13
|
+
};
|
|
14
|
+
/** GET /v1/customer/orders → proxy `customer/orders` */
|
|
15
|
+
export declare function getCustomerOrders(api: Api, options?: CustomerOrderListOptions): Promise<CustomerOrderPage>;
|
|
16
|
+
/** GET /v1/customer/orders/{orderId} → proxy `customer/orders/{orderId}` */
|
|
17
|
+
export declare function getCustomerOrder(api: Api, orderId: string, options?: CustomerOrderRequestOptions): Promise<CustomerOrderDetail>;
|
|
18
|
+
export type CustomerOrderReturnInput = {
|
|
19
|
+
reason: string;
|
|
20
|
+
comment?: string;
|
|
21
|
+
items: {
|
|
22
|
+
itemId: string;
|
|
23
|
+
quantity: number;
|
|
24
|
+
}[];
|
|
25
|
+
photos?: Blob[];
|
|
26
|
+
};
|
|
27
|
+
export type CustomerOrderCancellationInput = {
|
|
28
|
+
reason: string;
|
|
29
|
+
comment?: string;
|
|
30
|
+
};
|
|
31
|
+
/** POST /v1/customer/orders/{orderId}/return-request (multipart, hasta 3 fotos) */
|
|
32
|
+
export declare function requestCustomerOrderReturn(api: Api, orderId: string, input: CustomerOrderReturnInput, options?: CustomerOrderRequestOptions): Promise<void>;
|
|
33
|
+
/** POST /v1/customer/orders/{orderId}/cancellation-request */
|
|
34
|
+
export declare function requestCustomerOrderCancellation(api: Api, orderId: string, input: CustomerOrderCancellationInput, options?: CustomerOrderRequestOptions): Promise<void>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const require_customer_registration = require("../models/customer-registration-EZ0yZgGr.cjs");
|
|
2
|
+
// src/services/customer-registration.service.ts
|
|
3
|
+
function getCustomerRegistration(api, options) {
|
|
4
|
+
return api.get("customer/registration", require_customer_registration.CustomerRegistrationSchema, options);
|
|
5
|
+
}
|
|
6
|
+
function completeCustomerRegistration(api, input, options) {
|
|
7
|
+
return api.post("customer/registration", require_customer_registration.CustomerRegistrationInputSchema.parse(input), require_customer_registration.CustomerRegistrationSchema, options);
|
|
8
|
+
}
|
|
9
|
+
exports.completeCustomerRegistration = completeCustomerRegistration;
|
|
10
|
+
exports.getCustomerRegistration = getCustomerRegistration;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CustomerRegistrationInputSchema, CustomerRegistrationSchema } from "../models/customer-registration-C13knqyv.js";
|
|
2
|
+
// src/services/customer-registration.service.ts
|
|
3
|
+
function getCustomerRegistration(api, options) {
|
|
4
|
+
return api.get("customer/registration", CustomerRegistrationSchema, options);
|
|
5
|
+
}
|
|
6
|
+
function completeCustomerRegistration(api, input, options) {
|
|
7
|
+
return api.post("customer/registration", CustomerRegistrationInputSchema.parse(input), CustomerRegistrationSchema, options);
|
|
8
|
+
}
|
|
9
|
+
export { completeCustomerRegistration, getCustomerRegistration };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Api } from "../api.cjs";
|
|
2
|
+
import { CustomerRegistration, CustomerRegistrationInput } from "../models/customer-registration.cjs";
|
|
3
|
+
import { CustomerRequestOptions } from "./customer.service.cjs";
|
|
4
|
+
export declare function getCustomerRegistration(api: Api, options: CustomerRequestOptions): Promise<CustomerRegistration>;
|
|
5
|
+
export declare function completeCustomerRegistration(api: Api, input: CustomerRegistrationInput, options: CustomerRequestOptions): Promise<CustomerRegistration>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Api } from "../api.js";
|
|
2
|
+
import { CustomerRegistration, CustomerRegistrationInput } from "../models/customer-registration.js";
|
|
3
|
+
import { CustomerRequestOptions } from "./customer.service.js";
|
|
4
|
+
export declare function getCustomerRegistration(api: Api, options: CustomerRequestOptions): Promise<CustomerRegistration>;
|
|
5
|
+
export declare function completeCustomerRegistration(api: Api, input: CustomerRegistrationInput, options: CustomerRequestOptions): Promise<CustomerRegistration>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CustomerAuthConfigurationSchema, CustomerSessionCreateSchema, CustomerSessionCreatedSchema, CustomerSessionSchema } from "../models/customer-session-BiX0TXhO.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
// src/services/customer-session.service.ts
|
|
4
|
+
function upsertCustomerAuthConfiguration(api, origin) {
|
|
5
|
+
return api.post("customer/auth/config", void 0, CustomerAuthConfigurationSchema, { query: { origin } });
|
|
6
|
+
}
|
|
7
|
+
function createCustomerSession(api, input) {
|
|
8
|
+
return api.post("customer/sessions", CustomerSessionCreateSchema.parse(input), CustomerSessionCreatedSchema);
|
|
9
|
+
}
|
|
10
|
+
function getCustomerSession(api, options) {
|
|
11
|
+
return api.get("customer/sessions/current", CustomerSessionSchema, options);
|
|
12
|
+
}
|
|
13
|
+
async function deleteCustomerSession(api, options) {
|
|
14
|
+
await api.request("DELETE", "customer/sessions/current", z.null(), options);
|
|
15
|
+
}
|
|
16
|
+
export { createCustomerSession, deleteCustomerSession, getCustomerSession, upsertCustomerAuthConfiguration };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const require_customer_session = require("../models/customer-session-JeQiC8Yx.cjs");
|
|
2
|
+
let zod = require("zod");
|
|
3
|
+
// src/services/customer-session.service.ts
|
|
4
|
+
function upsertCustomerAuthConfiguration(api, origin) {
|
|
5
|
+
return api.post("customer/auth/config", void 0, require_customer_session.CustomerAuthConfigurationSchema, { query: { origin } });
|
|
6
|
+
}
|
|
7
|
+
function createCustomerSession(api, input) {
|
|
8
|
+
return api.post("customer/sessions", require_customer_session.CustomerSessionCreateSchema.parse(input), require_customer_session.CustomerSessionCreatedSchema);
|
|
9
|
+
}
|
|
10
|
+
function getCustomerSession(api, options) {
|
|
11
|
+
return api.get("customer/sessions/current", require_customer_session.CustomerSessionSchema, options);
|
|
12
|
+
}
|
|
13
|
+
async function deleteCustomerSession(api, options) {
|
|
14
|
+
await api.request("DELETE", "customer/sessions/current", zod.z.null(), options);
|
|
15
|
+
}
|
|
16
|
+
exports.createCustomerSession = createCustomerSession;
|
|
17
|
+
exports.deleteCustomerSession = deleteCustomerSession;
|
|
18
|
+
exports.getCustomerSession = getCustomerSession;
|
|
19
|
+
exports.upsertCustomerAuthConfiguration = upsertCustomerAuthConfiguration;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const require_models_customer_profile = require("../models/customer-profile.cjs");
|
|
2
|
+
let zod = require("zod");
|
|
3
|
+
// src/services/customer.service.ts
|
|
4
|
+
/**
|
|
5
|
+
* Perfil customer autenticado.
|
|
6
|
+
* GET `/v1/customer/me` y PATCH `/v1/customer` vía proxy `customer`.
|
|
7
|
+
*/
|
|
8
|
+
const CUSTOMER_PATH = "customer";
|
|
9
|
+
/** GET /v1/customer/me → proxy `customer` */
|
|
10
|
+
async function getCustomerMe(api, options = {}) {
|
|
11
|
+
return api.get(CUSTOMER_PATH, require_models_customer_profile.CustomerMeSchema, {
|
|
12
|
+
headers: options.headers,
|
|
13
|
+
signal: options.signal
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
/** PATCH /v1/customer → proxy `customer` (204). */
|
|
17
|
+
async function patchCustomer(api, data, options = {}) {
|
|
18
|
+
const payload = require_models_customer_profile.CustomerProfilePatchSchema.parse(data);
|
|
19
|
+
await api.request("PATCH", CUSTOMER_PATH, zod.z.null(), {
|
|
20
|
+
body: payload,
|
|
21
|
+
headers: options.headers,
|
|
22
|
+
signal: options.signal
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
exports.getCustomerMe = getCustomerMe;
|
|
26
|
+
exports.patchCustomer = patchCustomer;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CustomerMeSchema, CustomerProfilePatchSchema } from "../models/customer-profile.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
// src/services/customer.service.ts
|
|
4
|
+
/**
|
|
5
|
+
* Perfil customer autenticado.
|
|
6
|
+
* GET `/v1/customer/me` y PATCH `/v1/customer` vía proxy `customer`.
|
|
7
|
+
*/
|
|
8
|
+
const CUSTOMER_PATH = "customer";
|
|
9
|
+
/** GET /v1/customer/me → proxy `customer` */
|
|
10
|
+
async function getCustomerMe(api, options = {}) {
|
|
11
|
+
return api.get(CUSTOMER_PATH, CustomerMeSchema, {
|
|
12
|
+
headers: options.headers,
|
|
13
|
+
signal: options.signal
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
/** PATCH /v1/customer → proxy `customer` (204). */
|
|
17
|
+
async function patchCustomer(api, data, options = {}) {
|
|
18
|
+
const payload = CustomerProfilePatchSchema.parse(data);
|
|
19
|
+
await api.request("PATCH", CUSTOMER_PATH, z.null(), {
|
|
20
|
+
body: payload,
|
|
21
|
+
headers: options.headers,
|
|
22
|
+
signal: options.signal
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export { getCustomerMe, patchCustomer };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Api } from "../api.cjs";
|
|
2
|
+
import { CustomerMe, CustomerProfilePatch } from "../models/customer-profile.cjs";
|
|
3
|
+
export type CustomerRequestOptions = {
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
};
|
|
7
|
+
/** GET /v1/customer/me → proxy `customer` */
|
|
8
|
+
export declare function getCustomerMe(api: Api, options?: CustomerRequestOptions): Promise<CustomerMe>;
|
|
9
|
+
/** PATCH /v1/customer → proxy `customer` (204). */
|
|
10
|
+
export declare function patchCustomer(api: Api, data: CustomerProfilePatch, options?: CustomerRequestOptions): Promise<void>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Api } from "../api.js";
|
|
2
|
+
import { CustomerMe, CustomerProfilePatch } from "../models/customer-profile.js";
|
|
3
|
+
export type CustomerRequestOptions = {
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
};
|
|
7
|
+
/** GET /v1/customer/me → proxy `customer` */
|
|
8
|
+
export declare function getCustomerMe(api: Api, options?: CustomerRequestOptions): Promise<CustomerMe>;
|
|
9
|
+
/** PATCH /v1/customer → proxy `customer` (204). */
|
|
10
|
+
export declare function patchCustomer(api: Api, data: CustomerProfilePatch, options?: CustomerRequestOptions): Promise<void>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CountriesSchema, DepartmentsSchema, DistrictsSchema, GetDepartmentsParamsSchema, GetDistrictsParamsSchema, GetProvincesParamsSchema, ProvincesSchema } from "../models/geo.js";
|
|
2
|
+
// src/services/geo.service.ts
|
|
3
|
+
/** GET /v1/geo/countries */
|
|
4
|
+
async function getCountries(api) {
|
|
5
|
+
return api.get("geo/countries", CountriesSchema);
|
|
6
|
+
}
|
|
7
|
+
/** GET /v1/geo/departments?countryCode=&source=&search=&limit= */
|
|
8
|
+
async function getDepartments(api, params) {
|
|
9
|
+
const input = GetDepartmentsParamsSchema.parse(params);
|
|
10
|
+
return api.get("geo/departments", DepartmentsSchema, { query: {
|
|
11
|
+
countryCode: input.countryCode,
|
|
12
|
+
source: input.source,
|
|
13
|
+
search: input.search,
|
|
14
|
+
limit: input.limit
|
|
15
|
+
} });
|
|
16
|
+
}
|
|
17
|
+
/** GET /v1/geo/provinces?countryCode=&departmentCode=&source=&search=&limit= */
|
|
18
|
+
async function getProvinces(api, params) {
|
|
19
|
+
const input = GetProvincesParamsSchema.parse(params);
|
|
20
|
+
return api.get("geo/provinces", ProvincesSchema, { query: {
|
|
21
|
+
countryCode: input.countryCode,
|
|
22
|
+
departmentCode: input.departmentCode,
|
|
23
|
+
source: input.source,
|
|
24
|
+
search: input.search,
|
|
25
|
+
limit: input.limit
|
|
26
|
+
} });
|
|
27
|
+
}
|
|
28
|
+
/** GET /v1/geo/districts?countryCode=&provinceCode=&source=&search=&limit= */
|
|
29
|
+
async function getDistricts(api, params) {
|
|
30
|
+
const input = GetDistrictsParamsSchema.parse(params);
|
|
31
|
+
return api.get("geo/districts", DistrictsSchema, { query: {
|
|
32
|
+
countryCode: input.countryCode,
|
|
33
|
+
provinceCode: input.provinceCode,
|
|
34
|
+
source: input.source,
|
|
35
|
+
search: input.search,
|
|
36
|
+
limit: input.limit
|
|
37
|
+
} });
|
|
38
|
+
}
|
|
39
|
+
export { getCountries, getDepartments, getDistricts, getProvinces };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const require_models_geo = require("../models/geo.cjs");
|
|
2
|
+
// src/services/geo.service.ts
|
|
3
|
+
/** GET /v1/geo/countries */
|
|
4
|
+
async function getCountries(api) {
|
|
5
|
+
return api.get("geo/countries", require_models_geo.CountriesSchema);
|
|
6
|
+
}
|
|
7
|
+
/** GET /v1/geo/departments?countryCode=&source=&search=&limit= */
|
|
8
|
+
async function getDepartments(api, params) {
|
|
9
|
+
const input = require_models_geo.GetDepartmentsParamsSchema.parse(params);
|
|
10
|
+
return api.get("geo/departments", require_models_geo.DepartmentsSchema, { query: {
|
|
11
|
+
countryCode: input.countryCode,
|
|
12
|
+
source: input.source,
|
|
13
|
+
search: input.search,
|
|
14
|
+
limit: input.limit
|
|
15
|
+
} });
|
|
16
|
+
}
|
|
17
|
+
/** GET /v1/geo/provinces?countryCode=&departmentCode=&source=&search=&limit= */
|
|
18
|
+
async function getProvinces(api, params) {
|
|
19
|
+
const input = require_models_geo.GetProvincesParamsSchema.parse(params);
|
|
20
|
+
return api.get("geo/provinces", require_models_geo.ProvincesSchema, { query: {
|
|
21
|
+
countryCode: input.countryCode,
|
|
22
|
+
departmentCode: input.departmentCode,
|
|
23
|
+
source: input.source,
|
|
24
|
+
search: input.search,
|
|
25
|
+
limit: input.limit
|
|
26
|
+
} });
|
|
27
|
+
}
|
|
28
|
+
/** GET /v1/geo/districts?countryCode=&provinceCode=&source=&search=&limit= */
|
|
29
|
+
async function getDistricts(api, params) {
|
|
30
|
+
const input = require_models_geo.GetDistrictsParamsSchema.parse(params);
|
|
31
|
+
return api.get("geo/districts", require_models_geo.DistrictsSchema, { query: {
|
|
32
|
+
countryCode: input.countryCode,
|
|
33
|
+
provinceCode: input.provinceCode,
|
|
34
|
+
source: input.source,
|
|
35
|
+
search: input.search,
|
|
36
|
+
limit: input.limit
|
|
37
|
+
} });
|
|
38
|
+
}
|
|
39
|
+
exports.getCountries = getCountries;
|
|
40
|
+
exports.getDepartments = getDepartments;
|
|
41
|
+
exports.getDistricts = getDistricts;
|
|
42
|
+
exports.getProvinces = getProvinces;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Api } from "../api.cjs";
|
|
2
|
+
import { Countries, Departments, Districts, GetDepartmentsParams, GetDistrictsParams, GetProvincesParams, Provinces } from "../models/geo.cjs";
|
|
3
|
+
/** GET /v1/geo/countries */
|
|
4
|
+
export declare function getCountries(api: Api): Promise<Countries>;
|
|
5
|
+
/** GET /v1/geo/departments?countryCode=&source=&search=&limit= */
|
|
6
|
+
export declare function getDepartments(api: Api, params: GetDepartmentsParams): Promise<Departments>;
|
|
7
|
+
/** GET /v1/geo/provinces?countryCode=&departmentCode=&source=&search=&limit= */
|
|
8
|
+
export declare function getProvinces(api: Api, params: GetProvincesParams): Promise<Provinces>;
|
|
9
|
+
/** GET /v1/geo/districts?countryCode=&provinceCode=&source=&search=&limit= */
|
|
10
|
+
export declare function getDistricts(api: Api, params: GetDistrictsParams): Promise<Districts>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Api } from "../api.js";
|
|
2
|
+
import { Countries, Departments, Districts, GetDepartmentsParams, GetDistrictsParams, GetProvincesParams, Provinces } from "../models/geo.js";
|
|
3
|
+
/** GET /v1/geo/countries */
|
|
4
|
+
export declare function getCountries(api: Api): Promise<Countries>;
|
|
5
|
+
/** GET /v1/geo/departments?countryCode=&source=&search=&limit= */
|
|
6
|
+
export declare function getDepartments(api: Api, params: GetDepartmentsParams): Promise<Departments>;
|
|
7
|
+
/** GET /v1/geo/provinces?countryCode=&departmentCode=&source=&search=&limit= */
|
|
8
|
+
export declare function getProvinces(api: Api, params: GetProvincesParams): Promise<Provinces>;
|
|
9
|
+
/** GET /v1/geo/districts?countryCode=&provinceCode=&source=&search=&limit= */
|
|
10
|
+
export declare function getDistricts(api: Api, params: GetDistrictsParams): Promise<Districts>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const require_graphql = require("../libs/graphql-wJH7HaQU.cjs");
|
|
2
|
+
const require_graphql_selection = require("../libs/graphql-selection-Cj51WkJn.cjs");
|
|
3
|
+
const require_catalog_links = require("../models/catalog-links-c4LADGf_.cjs");
|
|
4
|
+
const require_catalog_link_key = require("../libs/catalog-link-key-CZTHJBGD.cjs");
|
|
5
|
+
const require_models_collections = require("../models/collections.cjs");
|
|
6
|
+
const require_models_settings = require("../models/settings.cjs");
|
|
7
|
+
let zod = require("zod");
|
|
8
|
+
// src/services/layout.service.ts
|
|
9
|
+
const LayoutSchema = zod.z.object({
|
|
10
|
+
settings: require_models_settings.StorefrontSettingsSchema,
|
|
11
|
+
collections: require_models_collections.CollectionsSchema.nullable(),
|
|
12
|
+
links: zod.z.array(require_catalog_links.CatalogLinkSchema).nullable()
|
|
13
|
+
});
|
|
14
|
+
const LinksSchema = LayoutSchema.pick({ links: true });
|
|
15
|
+
const LINK_FIELDS = require_graphql_selection.graphQLSelection(require_catalog_links.CatalogLinkSchema);
|
|
16
|
+
const LAYOUT = `query StorefrontLayoutV3($links: [StorefrontLinkInput!]!) {
|
|
17
|
+
settings { ${require_graphql_selection.graphQLSelection(require_models_settings.StorefrontSettingsSchema)} }
|
|
18
|
+
collections { ${require_graphql_selection.graphQLSelection(require_models_collections.CollectionSchema)} }
|
|
19
|
+
links(links: $links) { ${LINK_FIELDS} }
|
|
20
|
+
}`;
|
|
21
|
+
const LINKS = `query StorefrontLinks($links: [StorefrontLinkInput!]!) {
|
|
22
|
+
links(links: $links) { ${LINK_FIELDS} }
|
|
23
|
+
}`;
|
|
24
|
+
async function getLayout({ graphql, links }) {
|
|
25
|
+
const input = links.map(require_catalog_links.readCatalogLink);
|
|
26
|
+
const candidates = require_catalog_links.catalogLinkCandidates(input);
|
|
27
|
+
const first = candidates.slice(0, 100);
|
|
28
|
+
const layout = graphql(LAYOUT, LayoutSchema, { links: first }, { allowStale: false }).catch((error) => {
|
|
29
|
+
if (error instanceof require_graphql.GraphQLResponseError && error.errors.every((item) => item.path?.[0] === "collections" || item.path?.[0] === "links")) {
|
|
30
|
+
const partial = LayoutSchema.safeParse(error.data);
|
|
31
|
+
if (partial.success) return partial.data;
|
|
32
|
+
}
|
|
33
|
+
throw error;
|
|
34
|
+
});
|
|
35
|
+
const remaining = [];
|
|
36
|
+
for (let offset = 100; offset < candidates.length; offset += 100) {
|
|
37
|
+
const batch = candidates.slice(offset, offset + 100);
|
|
38
|
+
remaining.push(graphql(LINKS, LinksSchema, { links: batch }, { allowStale: false }).then((result) => batch.map((link, index) => result.links?.[index] ?? link)).catch(() => batch));
|
|
39
|
+
}
|
|
40
|
+
const [result, batches] = await Promise.all([layout, Promise.all(remaining)]);
|
|
41
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
42
|
+
const values = [...first.map((link, index) => result.links?.[index] ?? link), ...batches.flat()];
|
|
43
|
+
candidates.forEach((link, index) => resolved.set(require_catalog_link_key.catalogLinkKey(link), values[index] ?? link));
|
|
44
|
+
return {
|
|
45
|
+
settings: result.settings,
|
|
46
|
+
collections: result.collections ?? [],
|
|
47
|
+
links: input.map((link) => resolved.get(require_catalog_link_key.catalogLinkKey(link)) ?? link)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
exports.getLayout = getLayout;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { GraphQLResponseError } from "../libs/graphql-_6Y8lR_Q.js";
|
|
2
|
+
import { graphQLSelection } from "../libs/graphql-selection-H1RMh6VD.js";
|
|
3
|
+
import { CatalogLinkSchema, catalogLinkCandidates, readCatalogLink } from "../models/catalog-links-BzJeyBy4.js";
|
|
4
|
+
import { catalogLinkKey } from "../libs/catalog-link-key-B7l5KZsF.js";
|
|
5
|
+
import { CollectionSchema, CollectionsSchema } from "../models/collections.js";
|
|
6
|
+
import { StorefrontSettingsSchema } from "../models/settings.js";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
// src/services/layout.service.ts
|
|
9
|
+
const LayoutSchema = z.object({
|
|
10
|
+
settings: StorefrontSettingsSchema,
|
|
11
|
+
collections: CollectionsSchema.nullable(),
|
|
12
|
+
links: z.array(CatalogLinkSchema).nullable()
|
|
13
|
+
});
|
|
14
|
+
const LinksSchema = LayoutSchema.pick({ links: true });
|
|
15
|
+
const LINK_FIELDS = graphQLSelection(CatalogLinkSchema);
|
|
16
|
+
const LAYOUT = `query StorefrontLayoutV3($links: [StorefrontLinkInput!]!) {
|
|
17
|
+
settings { ${graphQLSelection(StorefrontSettingsSchema)} }
|
|
18
|
+
collections { ${graphQLSelection(CollectionSchema)} }
|
|
19
|
+
links(links: $links) { ${LINK_FIELDS} }
|
|
20
|
+
}`;
|
|
21
|
+
const LINKS = `query StorefrontLinks($links: [StorefrontLinkInput!]!) {
|
|
22
|
+
links(links: $links) { ${LINK_FIELDS} }
|
|
23
|
+
}`;
|
|
24
|
+
async function getLayout({ graphql, links }) {
|
|
25
|
+
const input = links.map(readCatalogLink);
|
|
26
|
+
const candidates = catalogLinkCandidates(input);
|
|
27
|
+
const first = candidates.slice(0, 100);
|
|
28
|
+
const layout = graphql(LAYOUT, LayoutSchema, { links: first }, { allowStale: false }).catch((error) => {
|
|
29
|
+
if (error instanceof GraphQLResponseError && error.errors.every((item) => item.path?.[0] === "collections" || item.path?.[0] === "links")) {
|
|
30
|
+
const partial = LayoutSchema.safeParse(error.data);
|
|
31
|
+
if (partial.success) return partial.data;
|
|
32
|
+
}
|
|
33
|
+
throw error;
|
|
34
|
+
});
|
|
35
|
+
const remaining = [];
|
|
36
|
+
for (let offset = 100; offset < candidates.length; offset += 100) {
|
|
37
|
+
const batch = candidates.slice(offset, offset + 100);
|
|
38
|
+
remaining.push(graphql(LINKS, LinksSchema, { links: batch }, { allowStale: false }).then((result) => batch.map((link, index) => result.links?.[index] ?? link)).catch(() => batch));
|
|
39
|
+
}
|
|
40
|
+
const [result, batches] = await Promise.all([layout, Promise.all(remaining)]);
|
|
41
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
42
|
+
const values = [...first.map((link, index) => result.links?.[index] ?? link), ...batches.flat()];
|
|
43
|
+
candidates.forEach((link, index) => resolved.set(catalogLinkKey(link), values[index] ?? link));
|
|
44
|
+
return {
|
|
45
|
+
settings: result.settings,
|
|
46
|
+
collections: result.collections ?? [],
|
|
47
|
+
links: input.map((link) => resolved.get(catalogLinkKey(link)) ?? link)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export { getLayout };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "../client.cjs";
|
|
2
|
+
import { CatalogLink } from "../models/catalog-links.cjs";
|
|
3
|
+
import { Collections } from "../models/collections.cjs";
|
|
4
|
+
import { StorefrontSettings } from "../models/settings.cjs";
|
|
5
|
+
export type StorefrontLayout = {
|
|
6
|
+
settings: StorefrontSettings;
|
|
7
|
+
collections: Collections;
|
|
8
|
+
links: CatalogLink[];
|
|
9
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "../client.js";
|
|
2
|
+
import { CatalogLink } from "../models/catalog-links.js";
|
|
3
|
+
import { Collections } from "../models/collections.js";
|
|
4
|
+
import { StorefrontSettings } from "../models/settings.js";
|
|
5
|
+
export type StorefrontLayout = {
|
|
6
|
+
settings: StorefrontSettings;
|
|
7
|
+
collections: Collections;
|
|
8
|
+
links: CatalogLink[];
|
|
9
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const require_order_draft = require("../models/order-draft-PFBZfRRR.cjs");
|
|
2
|
+
// src/services/order-draft.service.ts
|
|
3
|
+
async function getOrderDraft(api, token) {
|
|
4
|
+
const value = token.trim();
|
|
5
|
+
if (!value) throw new Error("token requerido");
|
|
6
|
+
return api.get(`order-drafts/share/${encodeURIComponent(value)}`, require_order_draft.OrderDraftSchema);
|
|
7
|
+
}
|
|
8
|
+
async function checkoutOrderDraft(api, token) {
|
|
9
|
+
const value = token.trim();
|
|
10
|
+
if (!value) throw new Error("token requerido");
|
|
11
|
+
return api.post(`order-drafts/share/${encodeURIComponent(value)}/checkout`, { invoiceType: "ticket" }, require_order_draft.OrderDraftCheckoutSchema);
|
|
12
|
+
}
|
|
13
|
+
exports.checkoutOrderDraft = checkoutOrderDraft;
|
|
14
|
+
exports.getOrderDraft = getOrderDraft;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OrderDraftCheckoutSchema, OrderDraftSchema } from "../models/order-draft-CnHJ0btL.js";
|
|
2
|
+
// src/services/order-draft.service.ts
|
|
3
|
+
async function getOrderDraft(api, token) {
|
|
4
|
+
const value = token.trim();
|
|
5
|
+
if (!value) throw new Error("token requerido");
|
|
6
|
+
return api.get(`order-drafts/share/${encodeURIComponent(value)}`, OrderDraftSchema);
|
|
7
|
+
}
|
|
8
|
+
async function checkoutOrderDraft(api, token) {
|
|
9
|
+
const value = token.trim();
|
|
10
|
+
if (!value) throw new Error("token requerido");
|
|
11
|
+
return api.post(`order-drafts/share/${encodeURIComponent(value)}/checkout`, { invoiceType: "ticket" }, OrderDraftCheckoutSchema);
|
|
12
|
+
}
|
|
13
|
+
export { checkoutOrderDraft, getOrderDraft };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Api } from "../api.cjs";
|
|
2
|
+
import { OrderDraft, OrderDraftCheckout } from "../models/order-draft.cjs";
|
|
3
|
+
export declare function getOrderDraft(api: Api, token: string): Promise<OrderDraft>;
|
|
4
|
+
export declare function checkoutOrderDraft(api: Api, token: string): Promise<OrderDraftCheckout>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Api } from "../api.js";
|
|
2
|
+
import { OrderDraft, OrderDraftCheckout } from "../models/order-draft.js";
|
|
3
|
+
export declare function getOrderDraft(api: Api, token: string): Promise<OrderDraft>;
|
|
4
|
+
export declare function checkoutOrderDraft(api: Api, token: string): Promise<OrderDraftCheckout>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const require_order_review = require("../models/order-review--xGlZKtS.cjs");
|
|
2
|
+
// src/services/order-review.service.ts
|
|
3
|
+
async function getOrderReviewContext(api, reviewToken, options = {}) {
|
|
4
|
+
const token = reviewToken.trim();
|
|
5
|
+
if (!token) throw new Error("reviewToken requerido");
|
|
6
|
+
return api.get(`orders/review-context/${encodeURIComponent(token)}`, require_order_review.OrderReviewContextSchema, {
|
|
7
|
+
headers: options.headers,
|
|
8
|
+
signal: options.signal
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
exports.getOrderReviewContext = getOrderReviewContext;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OrderReviewContextSchema } from "../models/order-review-egGeCaqB.js";
|
|
2
|
+
// src/services/order-review.service.ts
|
|
3
|
+
async function getOrderReviewContext(api, reviewToken, options = {}) {
|
|
4
|
+
const token = reviewToken.trim();
|
|
5
|
+
if (!token) throw new Error("reviewToken requerido");
|
|
6
|
+
return api.get(`orders/review-context/${encodeURIComponent(token)}`, OrderReviewContextSchema, {
|
|
7
|
+
headers: options.headers,
|
|
8
|
+
signal: options.signal
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export { getOrderReviewContext };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Api } from "../api.cjs";
|
|
2
|
+
import { OrderReviewContext } from "../models/order-review.cjs";
|
|
3
|
+
export type OrderReviewRequestOptions = {
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
};
|
|
7
|
+
export declare function getOrderReviewContext(api: Api, reviewToken: string, options?: OrderReviewRequestOptions): Promise<OrderReviewContext>;
|