@ecomiq/storefront 0.1.2 → 1.0.1
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/README.md +211 -59
- package/dist/chunk-PCTSWSTB.js +346 -0
- package/dist/chunk-PCTSWSTB.js.map +1 -0
- package/dist/chunk-PDK2VYWD.js +1598 -0
- package/dist/chunk-PDK2VYWD.js.map +1 -0
- package/dist/chunk-Q762YXCQ.js +175 -0
- package/dist/chunk-Q762YXCQ.js.map +1 -0
- package/dist/chunks/client.d.ts +8563 -0
- package/dist/chunks/client.js +2046 -0
- package/dist/chunks/client.js.map +1 -0
- package/dist/chunks/config.js +3 -0
- package/dist/chunks/config.js.map +1 -0
- package/dist/chunks/server-nextjs.d.ts +33 -0
- package/dist/chunks/server-nextjs.js +30 -0
- package/dist/chunks/server-nextjs.js.map +1 -0
- package/dist/chunks/server-tanstack.d.ts +22 -0
- package/dist/chunks/server-tanstack.js +30 -0
- package/dist/chunks/server-tanstack.js.map +1 -0
- package/dist/ecomiq-shell-ui-SWIFLQVM.js +8 -0
- package/dist/ecomiq-shell-ui-SWIFLQVM.js.map +1 -0
- package/dist/format-currency-oJD9jGYW.d.ts +6751 -0
- package/dist/index.d.ts +20 -30
- package/dist/index.js +11 -103
- package/dist/index.js.map +1 -1
- package/dist/index.server.d.ts +8 -0
- package/dist/index.server.js +7 -0
- package/dist/index.server.js.map +1 -0
- package/dist/nextjs/api.d.ts +10 -14
- package/dist/nextjs/api.js +8 -148
- package/dist/nextjs/api.js.map +1 -1
- package/dist/nextjs.d.ts +13 -3213
- package/dist/nextjs.js +11 -1793
- package/dist/nextjs.js.map +1 -1
- package/dist/nextjs.server.d.ts +1 -0
- package/dist/nextjs.server.js +1 -0
- package/dist/nextjs.server.js.map +1 -0
- package/dist/store-proxy-handler-CNzKlTFA.d.ts +10 -0
- package/dist/tanstack/api.d.ts +41 -0
- package/dist/tanstack/api.js +28 -0
- package/dist/tanstack/api.js.map +1 -0
- package/dist/tanstack.d.ts +13 -0
- package/dist/tanstack.js +11 -0
- package/dist/tanstack.js.map +1 -0
- package/dist/tanstack.server.d.ts +1 -0
- package/dist/tanstack.server.js +1 -0
- package/dist/tanstack.server.js.map +1 -0
- package/package.json +33 -13
- package/dist/collection-anMkdWa7.d.ts +0 -4333
- package/dist/core.d.ts +0 -3396
- package/dist/core.js +0 -1239
- package/dist/core.js.map +0 -1
- package/dist/find-storefront-cms-page-DNwLo1iV.d.ts +0 -178
- package/dist/react.d.ts +0 -964
- package/dist/react.js +0 -2670
- package/dist/react.js.map +0 -1
- /package/dist/{..d.ts → chunks/config.d.ts} +0 -0
|
@@ -0,0 +1,1598 @@
|
|
|
1
|
+
import { StorefrontSettingsSchema, resolvePublicStoreKey, getStorefrontSettingsFromKvByStoreKey } from './chunk-PCTSWSTB.js';
|
|
2
|
+
import { STOREFRONT_ECOMIQ_OAUTH_COOKIE_NAME, STOREFRONT_ECOMIQ_OAUTH_COOKIE_PATH } from './chunk-Q762YXCQ.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { createAuthMiddleware, createAuthEndpoint, formCsrfMiddleware } from 'better-auth/api';
|
|
5
|
+
import { APIError } from 'better-auth';
|
|
6
|
+
import { setSessionCookie } from 'better-auth/cookies';
|
|
7
|
+
import { parseUserOutput } from 'better-auth/db';
|
|
8
|
+
import axios from 'axios';
|
|
9
|
+
|
|
10
|
+
// src/core/client/store-api-client.ts
|
|
11
|
+
var STORE_API_PATH = "/api/store";
|
|
12
|
+
var serverRequestOriginGetter = null;
|
|
13
|
+
var serverStoreIdGetter = null;
|
|
14
|
+
var clientStoreIdGetter = null;
|
|
15
|
+
function setServerRequestOrigin(getter) {
|
|
16
|
+
serverRequestOriginGetter = getter;
|
|
17
|
+
}
|
|
18
|
+
function setServerStoreId(storeId) {
|
|
19
|
+
serverStoreIdGetter = storeId?.trim() || null;
|
|
20
|
+
}
|
|
21
|
+
function setClientStoreId(storeId) {
|
|
22
|
+
if (typeof window === "undefined") return;
|
|
23
|
+
clientStoreIdGetter = storeId?.trim() || null;
|
|
24
|
+
}
|
|
25
|
+
async function getStoreApiBaseUrl() {
|
|
26
|
+
if (typeof window !== "undefined") {
|
|
27
|
+
return STORE_API_PATH;
|
|
28
|
+
}
|
|
29
|
+
if (serverRequestOriginGetter) {
|
|
30
|
+
return `${serverRequestOriginGetter.replace(/\/$/, "")}/${STORE_API_PATH.replace(/^\//, "")}`;
|
|
31
|
+
}
|
|
32
|
+
return STORE_API_PATH;
|
|
33
|
+
}
|
|
34
|
+
function createStoreApiClient(baseUrl) {
|
|
35
|
+
return new StoreApiClient(baseUrl);
|
|
36
|
+
}
|
|
37
|
+
async function getStoreApiClient() {
|
|
38
|
+
const baseUrl = await getStoreApiBaseUrl();
|
|
39
|
+
return new StoreApiClient(baseUrl);
|
|
40
|
+
}
|
|
41
|
+
var StoreApiClient = class {
|
|
42
|
+
baseUrl;
|
|
43
|
+
constructor(baseUrl = STORE_API_PATH) {
|
|
44
|
+
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
45
|
+
}
|
|
46
|
+
async request(path, init, options) {
|
|
47
|
+
const pathNorm = path.replace(/^\/+/, "");
|
|
48
|
+
const url = path.startsWith("http") ? path : `${this.baseUrl}/${pathNorm}`;
|
|
49
|
+
const headers = new Headers(init.headers ?? {});
|
|
50
|
+
headers.set("Content-Type", "application/json");
|
|
51
|
+
headers.set("Accept-Encoding", "identity");
|
|
52
|
+
const explicitStoreId = options?.xStoreId?.trim();
|
|
53
|
+
const runtimeStoreId = explicitStoreId || (typeof window === "undefined" ? serverStoreIdGetter : clientStoreIdGetter);
|
|
54
|
+
if (runtimeStoreId && !headers.has("x-store-id")) {
|
|
55
|
+
headers.set("X-Store-Id", runtimeStoreId);
|
|
56
|
+
}
|
|
57
|
+
if (options?.xStoreDomain) {
|
|
58
|
+
headers.set("X-Store-Domain", options.xStoreDomain);
|
|
59
|
+
}
|
|
60
|
+
if (options?.xCartId) {
|
|
61
|
+
headers.set("X-Cart-Token", options.xCartId);
|
|
62
|
+
}
|
|
63
|
+
const bearer = typeof options?.bearerToken === "string" && options.bearerToken.trim().length > 0 ? options.bearerToken.trim() : void 0;
|
|
64
|
+
if (bearer) {
|
|
65
|
+
headers.set(
|
|
66
|
+
"Authorization",
|
|
67
|
+
bearer.toLowerCase().startsWith("bearer ") ? bearer : `Bearer ${bearer}`
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
const isServer = typeof window === "undefined";
|
|
71
|
+
const res = await fetch(url, {
|
|
72
|
+
...init,
|
|
73
|
+
headers,
|
|
74
|
+
credentials: isServer ? "same-origin" : "include",
|
|
75
|
+
...options?.noStore ? { cache: "no-store" } : {},
|
|
76
|
+
...options?.cacheKey && isServer && !options?.noStore ? {
|
|
77
|
+
next: {
|
|
78
|
+
revalidate: 60,
|
|
79
|
+
tags: [options.cacheKey]
|
|
80
|
+
}
|
|
81
|
+
} : {}
|
|
82
|
+
});
|
|
83
|
+
if (!res.ok) {
|
|
84
|
+
let body;
|
|
85
|
+
try {
|
|
86
|
+
const errorText = await res.text();
|
|
87
|
+
body = errorText ? JSON.parse(errorText) : void 0;
|
|
88
|
+
} catch {
|
|
89
|
+
body = void 0;
|
|
90
|
+
}
|
|
91
|
+
const msg = typeof body === "object" && body !== null && "title" in body && typeof body.title === "string" ? body.title : res.statusText || "Store API error";
|
|
92
|
+
const err = new Error(msg);
|
|
93
|
+
err.status = res.status;
|
|
94
|
+
err.body = body;
|
|
95
|
+
throw err;
|
|
96
|
+
}
|
|
97
|
+
const text = await res.text();
|
|
98
|
+
if (!text) return void 0;
|
|
99
|
+
return JSON.parse(text);
|
|
100
|
+
}
|
|
101
|
+
get(path, options) {
|
|
102
|
+
return this.request(path, { method: "GET" }, options);
|
|
103
|
+
}
|
|
104
|
+
post(path, data, options) {
|
|
105
|
+
return this.request(
|
|
106
|
+
path,
|
|
107
|
+
{
|
|
108
|
+
method: "POST",
|
|
109
|
+
body: data != null ? JSON.stringify(data) : void 0
|
|
110
|
+
},
|
|
111
|
+
options
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
patch(path, data, options) {
|
|
115
|
+
return this.request(path, {
|
|
116
|
+
method: "PATCH",
|
|
117
|
+
body: data != null ? JSON.stringify(data) : void 0
|
|
118
|
+
}, options);
|
|
119
|
+
}
|
|
120
|
+
put(path, data, options) {
|
|
121
|
+
return this.request(
|
|
122
|
+
path,
|
|
123
|
+
{
|
|
124
|
+
method: "PUT",
|
|
125
|
+
body: data != null ? JSON.stringify(data) : void 0
|
|
126
|
+
},
|
|
127
|
+
options
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
delete(path, options) {
|
|
131
|
+
return this.request(path, { method: "DELETE" }, options);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
var storeApiClient = new StoreApiClient(STORE_API_PATH);
|
|
135
|
+
|
|
136
|
+
// src/core/server/request-origin.ts
|
|
137
|
+
function applyServerRequestOriginFromHeaders(headerList) {
|
|
138
|
+
const host = headerList.get("host")?.trim();
|
|
139
|
+
if (!host) return;
|
|
140
|
+
const proto = headerList.get("x-forwarded-proto") ?? headerList.get("x-forwarded-ssl") ?? "http";
|
|
141
|
+
const secure = proto === "https" || (headerList.get("x-forwarded-ssl") ?? "") === "on";
|
|
142
|
+
setServerRequestOrigin(`${secure ? "https" : "http"}://${host}`);
|
|
143
|
+
}
|
|
144
|
+
function normalizeRequestHostname(headerList) {
|
|
145
|
+
const host = headerList.get("host");
|
|
146
|
+
return host?.replace(/^www\./, "") ?? null;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// src/core/client/store-api-store.service.ts
|
|
150
|
+
async function getStorefrontSettings(subdomain, cacheKey) {
|
|
151
|
+
const client = await getStoreApiClient();
|
|
152
|
+
const response = await client.get("settings", {
|
|
153
|
+
xStoreDomain: subdomain?.trim() || void 0,
|
|
154
|
+
cacheKey,
|
|
155
|
+
noStore: true
|
|
156
|
+
});
|
|
157
|
+
return StorefrontSettingsSchema.parse(response);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// src/react/shell/lib/public-store-settings-source.ts
|
|
161
|
+
var ENV_PUBLIC_STORE_SETTINGS_SOURCE = "PUBLIC_STORE_SETTINGS_SOURCE";
|
|
162
|
+
function resolvePublicStoreSettingsSource(envValue = process.env[ENV_PUBLIC_STORE_SETTINGS_SOURCE]) {
|
|
163
|
+
const v = (envValue ?? "api").trim().toLowerCase();
|
|
164
|
+
return v === "kv" ? "kv" : "api";
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// src/core/server/fetch-public-store.ts
|
|
168
|
+
async function fetchPublicStoreSettings(options) {
|
|
169
|
+
let storeKey;
|
|
170
|
+
try {
|
|
171
|
+
storeKey = resolvePublicStoreKey(options.host);
|
|
172
|
+
} catch (error) {
|
|
173
|
+
const err = error;
|
|
174
|
+
return {
|
|
175
|
+
data: null,
|
|
176
|
+
error: {
|
|
177
|
+
message: err.message ?? "Host is required",
|
|
178
|
+
statusCode: err.status ?? 400,
|
|
179
|
+
isNotFound: true,
|
|
180
|
+
subdomain: void 0
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
const source = options.source ?? resolvePublicStoreSettingsSource();
|
|
185
|
+
try {
|
|
186
|
+
setServerStoreId(null);
|
|
187
|
+
const data = source === "kv" ? await getStorefrontSettingsFromKvByStoreKey(storeKey) : await getStorefrontSettings(
|
|
188
|
+
storeKey,
|
|
189
|
+
`storefront-settings-${storeKey}`
|
|
190
|
+
);
|
|
191
|
+
setServerStoreId(data.store.id);
|
|
192
|
+
return { data, error: null };
|
|
193
|
+
} catch (error) {
|
|
194
|
+
const err = error;
|
|
195
|
+
const statusCode = err.status ?? 500;
|
|
196
|
+
return {
|
|
197
|
+
data: null,
|
|
198
|
+
error: {
|
|
199
|
+
message: err.message ?? "Error fetching store settings",
|
|
200
|
+
statusCode,
|
|
201
|
+
isNotFound: statusCode === 404,
|
|
202
|
+
subdomain: storeKey
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// src/core/client/store-api-errors.ts
|
|
209
|
+
function isCartNotActiveApiError(error) {
|
|
210
|
+
if (!error || typeof error !== "object") return false;
|
|
211
|
+
const e = error;
|
|
212
|
+
if (e.status !== 400) return false;
|
|
213
|
+
const body = e.body;
|
|
214
|
+
const keys = body?.errors ? Object.keys(body.errors) : [];
|
|
215
|
+
return keys.includes("Carts.NotActive");
|
|
216
|
+
}
|
|
217
|
+
var ProductVariantSchema = z.object({
|
|
218
|
+
id: z.coerce.string(),
|
|
219
|
+
name: z.string(),
|
|
220
|
+
storeId: z.string(),
|
|
221
|
+
productId: z.coerce.string(),
|
|
222
|
+
basePrice: z.number().positive().optional().nullable(),
|
|
223
|
+
comparePrice: z.number().positive().optional().nullable(),
|
|
224
|
+
//TODO: remove this field
|
|
225
|
+
originalPrice: z.number().positive().optional().nullable(),
|
|
226
|
+
costPrice: z.number().positive().optional().nullable(),
|
|
227
|
+
isDefault: z.boolean().optional().nullable(),
|
|
228
|
+
reserveStock: z.number().nonnegative().optional().nullable(),
|
|
229
|
+
weight: z.number().nonnegative().optional().nullable().default(0),
|
|
230
|
+
width: z.number().nonnegative().optional().nullable(),
|
|
231
|
+
height: z.number().nonnegative().optional().nullable(),
|
|
232
|
+
unitOfMeasure: z.string().optional().nullable(),
|
|
233
|
+
order: z.number().nonnegative().optional().nullable().default(0),
|
|
234
|
+
sku: z.string().optional().nullable(),
|
|
235
|
+
stock: z.number().nonnegative().optional().nullable(),
|
|
236
|
+
leadTime: z.string().optional().nullable(),
|
|
237
|
+
barCode: z.string().optional().nullable(),
|
|
238
|
+
shippingWeight: z.number().nonnegative().optional().nullable(),
|
|
239
|
+
images: z.array(z.string()).optional().nullable(),
|
|
240
|
+
attributes: z.array(z.string()).optional().nullable(),
|
|
241
|
+
variantStatus: z.string().optional().nullable(),
|
|
242
|
+
status: z.string().optional().nullable(),
|
|
243
|
+
createdOn: z.string().optional().nullable(),
|
|
244
|
+
updatedOn: z.string().optional().nullable(),
|
|
245
|
+
deletedOn: z.string().optional().nullable()
|
|
246
|
+
});
|
|
247
|
+
var ProductSchema = z.object({
|
|
248
|
+
id: z.coerce.string(),
|
|
249
|
+
name: z.string(),
|
|
250
|
+
images: z.array(z.object({
|
|
251
|
+
url: z.string().url(),
|
|
252
|
+
name: z.string().optional(),
|
|
253
|
+
isPrimary: z.boolean().optional()
|
|
254
|
+
})),
|
|
255
|
+
basePrice: z.number().positive().optional(),
|
|
256
|
+
salePrice: z.number().positive().optional(),
|
|
257
|
+
slug: z.string(),
|
|
258
|
+
description: z.string().optional(),
|
|
259
|
+
categories: z.array(z.object({
|
|
260
|
+
id: z.coerce.string(),
|
|
261
|
+
name: z.string(),
|
|
262
|
+
slug: z.string(),
|
|
263
|
+
logo: z.string().optional(),
|
|
264
|
+
icon: z.string().optional()
|
|
265
|
+
})).optional(),
|
|
266
|
+
tags: z.array(z.string()).optional(),
|
|
267
|
+
inStock: z.boolean().optional(),
|
|
268
|
+
variants: z.array(ProductVariantSchema).optional()
|
|
269
|
+
});
|
|
270
|
+
z.object({
|
|
271
|
+
items: z.array(ProductSchema),
|
|
272
|
+
meta: z.object({
|
|
273
|
+
total: z.number().int().positive(),
|
|
274
|
+
page: z.number().int().positive(),
|
|
275
|
+
pageSize: z.number().int().positive(),
|
|
276
|
+
hasNextPage: z.boolean()
|
|
277
|
+
})
|
|
278
|
+
});
|
|
279
|
+
z.object({
|
|
280
|
+
category: z.string().optional(),
|
|
281
|
+
search: z.string().optional(),
|
|
282
|
+
minPrice: z.number().positive().optional(),
|
|
283
|
+
maxPrice: z.number().positive().optional(),
|
|
284
|
+
inStock: z.boolean().optional(),
|
|
285
|
+
sortBy: z.enum(["name", "price", "createdAt"]).optional(),
|
|
286
|
+
sortOrder: z.enum(["asc", "desc"]).optional(),
|
|
287
|
+
page: z.number().int().positive().optional(),
|
|
288
|
+
limit: z.number().int().positive().optional()
|
|
289
|
+
});
|
|
290
|
+
var StorefrontProductSchema = z.object({
|
|
291
|
+
id: z.coerce.string(),
|
|
292
|
+
name: z.string(),
|
|
293
|
+
slug: z.string(),
|
|
294
|
+
productType: z.string().optional().nullable(),
|
|
295
|
+
imageUrl: z.string().optional().nullable(),
|
|
296
|
+
price: z.number().nonnegative(),
|
|
297
|
+
compareAtPrice: z.number().nonnegative().optional().nullable(),
|
|
298
|
+
variantCount: z.number().int().nonnegative().optional().default(0),
|
|
299
|
+
isAvailable: z.boolean(),
|
|
300
|
+
totalInventory: z.number().int().nonnegative(),
|
|
301
|
+
bundleItemsCount: z.number().int().nonnegative().optional().default(0),
|
|
302
|
+
brand: z.string().optional().nullable(),
|
|
303
|
+
category: z.string().optional().nullable(),
|
|
304
|
+
status: z.string().optional().nullable(),
|
|
305
|
+
tags: z.array(z.string()).optional().nullable()
|
|
306
|
+
});
|
|
307
|
+
var StorefrontFacetSchema = z.object({
|
|
308
|
+
value: z.string(),
|
|
309
|
+
count: z.number().int().nonnegative()
|
|
310
|
+
});
|
|
311
|
+
var StorefrontProductsResponseSchema = z.object({
|
|
312
|
+
pageIndex: z.number().int().positive(),
|
|
313
|
+
pageSize: z.number().int().positive(),
|
|
314
|
+
totalCount: z.number().int().nonnegative(),
|
|
315
|
+
totalPages: z.number().int().nonnegative(),
|
|
316
|
+
products: z.array(StorefrontProductSchema),
|
|
317
|
+
categories: z.array(StorefrontFacetSchema).optional().default([]),
|
|
318
|
+
brands: z.array(StorefrontFacetSchema).optional().default([]),
|
|
319
|
+
minPrice: z.number().nonnegative().optional().nullable(),
|
|
320
|
+
maxPrice: z.number().nonnegative().optional().nullable()
|
|
321
|
+
});
|
|
322
|
+
var StorefrontProductsParamsSchema = z.object({
|
|
323
|
+
page: z.number().int().positive().optional().default(1),
|
|
324
|
+
pageSize: z.number().int().positive().optional().default(20),
|
|
325
|
+
sort: z.enum(["price_asc", "price_desc", "name_asc", "name_desc", "newest"]).optional().default("price_asc"),
|
|
326
|
+
sellerId: z.string().optional(),
|
|
327
|
+
search: z.string().optional(),
|
|
328
|
+
collection: z.string().optional(),
|
|
329
|
+
category: z.string().optional(),
|
|
330
|
+
brand: z.string().optional(),
|
|
331
|
+
productType: z.string().optional(),
|
|
332
|
+
inStock: z.boolean().optional(),
|
|
333
|
+
minPrice: z.number().nonnegative().optional(),
|
|
334
|
+
maxPrice: z.number().nonnegative().optional()
|
|
335
|
+
});
|
|
336
|
+
var StorefrontVariantOptionSchema = z.object({
|
|
337
|
+
key: z.string(),
|
|
338
|
+
name: z.string(),
|
|
339
|
+
value: z.string()
|
|
340
|
+
});
|
|
341
|
+
var StorefrontProductImageSchema = z.object({
|
|
342
|
+
url: z.string(),
|
|
343
|
+
name: z.string().optional().nullable(),
|
|
344
|
+
order: z.number().int().nonnegative().optional()
|
|
345
|
+
});
|
|
346
|
+
var StorefrontVariantSchema = z.object({
|
|
347
|
+
id: z.coerce.string().optional().default(""),
|
|
348
|
+
sku: z.string(),
|
|
349
|
+
status: z.string().optional().nullable(),
|
|
350
|
+
price: z.number().nonnegative(),
|
|
351
|
+
compareAtPrice: z.number().nonnegative().optional().nullable(),
|
|
352
|
+
quantity: z.number().int().nonnegative(),
|
|
353
|
+
options: z.array(StorefrontVariantOptionSchema).optional().default([]),
|
|
354
|
+
images: z.array(StorefrontProductImageSchema).optional().default([])
|
|
355
|
+
});
|
|
356
|
+
var StorefrontPriceTierSchema = z.object({
|
|
357
|
+
variantId: z.coerce.string(),
|
|
358
|
+
minQuantity: z.number().int().positive(),
|
|
359
|
+
maxQuantity: z.number().int().positive().optional().nullable(),
|
|
360
|
+
unitPrice: z.number().nonnegative()
|
|
361
|
+
});
|
|
362
|
+
var StorefrontBundleItemSchema = z.object({
|
|
363
|
+
productId: z.coerce.string(),
|
|
364
|
+
variantId: z.coerce.string(),
|
|
365
|
+
productName: z.string(),
|
|
366
|
+
variantName: z.string().optional().nullable(),
|
|
367
|
+
sku: z.string().optional().nullable(),
|
|
368
|
+
brand: z.string().optional().nullable(),
|
|
369
|
+
imageUrl: z.string().optional().nullable(),
|
|
370
|
+
quantity: z.number().int(),
|
|
371
|
+
availableStock: z.number().int().optional().default(0),
|
|
372
|
+
allowBackorders: z.boolean().optional().default(false),
|
|
373
|
+
requiresShipping: z.boolean().optional().default(true)
|
|
374
|
+
});
|
|
375
|
+
var StorefrontProductDetailSchema = z.object({
|
|
376
|
+
id: z.coerce.string(),
|
|
377
|
+
name: z.string(),
|
|
378
|
+
slug: z.string(),
|
|
379
|
+
description: z.string().optional().nullable(),
|
|
380
|
+
productType: z.string().optional().nullable(),
|
|
381
|
+
status: z.string().optional().nullable(),
|
|
382
|
+
imageUrl: z.string().optional().nullable(),
|
|
383
|
+
price: z.number().nonnegative(),
|
|
384
|
+
compareAtPrice: z.number().nonnegative().optional().nullable(),
|
|
385
|
+
isAvailable: z.boolean(),
|
|
386
|
+
totalInventory: z.number().int().nonnegative(),
|
|
387
|
+
brand: z.string().optional().nullable(),
|
|
388
|
+
category: z.string().optional().nullable(),
|
|
389
|
+
categoryId: z.coerce.string().optional().nullable(),
|
|
390
|
+
tags: z.array(z.string()).optional().nullable(),
|
|
391
|
+
specifications: z.array(z.record(z.string(), z.unknown())).optional().default([]),
|
|
392
|
+
variants: z.array(StorefrontVariantSchema).optional().default([]),
|
|
393
|
+
images: z.array(StorefrontProductImageSchema).optional().default([]),
|
|
394
|
+
bundleItems: z.array(StorefrontBundleItemSchema).optional().default([]),
|
|
395
|
+
priceTiers: z.array(StorefrontPriceTierSchema).optional().default([]),
|
|
396
|
+
createdAt: z.string().optional().nullable(),
|
|
397
|
+
updatedAt: z.string().optional().nullable()
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
// src/core/client/store-api-product.service.ts
|
|
401
|
+
async function getStorefrontProducts(params, cacheKey) {
|
|
402
|
+
const parsed = StorefrontProductsParamsSchema.parse(params ?? {});
|
|
403
|
+
const searchParams = new URLSearchParams();
|
|
404
|
+
searchParams.set("page", String(parsed.page));
|
|
405
|
+
searchParams.set("pageSize", String(parsed.pageSize));
|
|
406
|
+
if (parsed.sort) searchParams.set("sort", parsed.sort);
|
|
407
|
+
if (parsed.sellerId) searchParams.set("sellerId", parsed.sellerId);
|
|
408
|
+
if (parsed.search) searchParams.set("search", parsed.search);
|
|
409
|
+
if (parsed.collection) searchParams.set("collection", parsed.collection);
|
|
410
|
+
if (parsed.category) searchParams.set("category", parsed.category);
|
|
411
|
+
if (parsed.brand) searchParams.set("brand", parsed.brand);
|
|
412
|
+
if (parsed.productType) searchParams.set("productType", parsed.productType);
|
|
413
|
+
if (parsed.inStock != null) searchParams.set("inStock", String(parsed.inStock));
|
|
414
|
+
if (parsed.minPrice != null) searchParams.set("minPrice", String(parsed.minPrice));
|
|
415
|
+
if (parsed.maxPrice != null) searchParams.set("maxPrice", String(parsed.maxPrice));
|
|
416
|
+
const path = `products?${searchParams.toString()}`;
|
|
417
|
+
const client = await getStoreApiClient();
|
|
418
|
+
const response = await client.get(path, {
|
|
419
|
+
cacheKey
|
|
420
|
+
});
|
|
421
|
+
return StorefrontProductsResponseSchema.parse(response);
|
|
422
|
+
}
|
|
423
|
+
async function getStorefrontProductBySlug(slug) {
|
|
424
|
+
const path = `products/${encodeURIComponent(slug)}`;
|
|
425
|
+
const client = await getStoreApiClient();
|
|
426
|
+
const response = await client.get(path);
|
|
427
|
+
return StorefrontProductDetailSchema.parse(response);
|
|
428
|
+
}
|
|
429
|
+
var StorefrontCollectionSchema = z.object({
|
|
430
|
+
id: z.coerce.string(),
|
|
431
|
+
slug: z.string(),
|
|
432
|
+
name: z.string(),
|
|
433
|
+
description: z.string().nullable().optional(),
|
|
434
|
+
imageUrl: z.string().nullable().optional(),
|
|
435
|
+
type: z.string(),
|
|
436
|
+
productCount: z.number().int().nonnegative()
|
|
437
|
+
});
|
|
438
|
+
var StorefrontCollectionsResponseSchema = z.array(StorefrontCollectionSchema);
|
|
439
|
+
var StorefrontCollectionDetailSchema = StorefrontCollectionSchema;
|
|
440
|
+
|
|
441
|
+
// src/core/client/store-api-collection.service.ts
|
|
442
|
+
async function getStorefrontCollections() {
|
|
443
|
+
const client = await getStoreApiClient();
|
|
444
|
+
const response = await client.get("collections");
|
|
445
|
+
return StorefrontCollectionsResponseSchema.parse(response);
|
|
446
|
+
}
|
|
447
|
+
async function getStorefrontCollectionBySlug(slug) {
|
|
448
|
+
const client = await getStoreApiClient();
|
|
449
|
+
const response = await client.get(
|
|
450
|
+
`collections/by-slug/${encodeURIComponent(slug)}`
|
|
451
|
+
);
|
|
452
|
+
return StorefrontCollectionDetailSchema.parse(response);
|
|
453
|
+
}
|
|
454
|
+
var StorefrontPageListItemSchema = z.object({
|
|
455
|
+
id: z.string(),
|
|
456
|
+
name: z.string(),
|
|
457
|
+
slug: z.string(),
|
|
458
|
+
layout: z.string()
|
|
459
|
+
});
|
|
460
|
+
var StorefrontPageSeoSchema = z.object({
|
|
461
|
+
title: z.string().optional(),
|
|
462
|
+
description: z.string().optional()
|
|
463
|
+
}).optional();
|
|
464
|
+
var StorefrontPageSettingsSchema = z.object({
|
|
465
|
+
seo: StorefrontPageSeoSchema,
|
|
466
|
+
html: z.string().optional(),
|
|
467
|
+
title: z.string().optional()
|
|
468
|
+
}).catchall(z.unknown());
|
|
469
|
+
var StorefrontPageBlockSchema = z.object({
|
|
470
|
+
id: z.string(),
|
|
471
|
+
type: z.string(),
|
|
472
|
+
order: z.number(),
|
|
473
|
+
settings: z.record(z.unknown()).optional()
|
|
474
|
+
});
|
|
475
|
+
var StorefrontPageSectionSchema = z.object({
|
|
476
|
+
id: z.string(),
|
|
477
|
+
type: z.string(),
|
|
478
|
+
order: z.number(),
|
|
479
|
+
settings: z.record(z.unknown()).optional(),
|
|
480
|
+
blocks: z.array(StorefrontPageBlockSchema).optional().default([])
|
|
481
|
+
});
|
|
482
|
+
var StorefrontPageDetailSchema = z.object({
|
|
483
|
+
id: z.string(),
|
|
484
|
+
name: z.string(),
|
|
485
|
+
slug: z.string(),
|
|
486
|
+
layout: z.string(),
|
|
487
|
+
settings: StorefrontPageSettingsSchema.optional(),
|
|
488
|
+
sections: z.array(StorefrontPageSectionSchema).optional()
|
|
489
|
+
});
|
|
490
|
+
async function getStorefrontPages() {
|
|
491
|
+
const client = await getStoreApiClient();
|
|
492
|
+
const response = await client.get("pages");
|
|
493
|
+
return z.array(StorefrontPageListItemSchema).parse(response);
|
|
494
|
+
}
|
|
495
|
+
async function getStorefrontPageBySlug(slug) {
|
|
496
|
+
const path = `pages/${encodeURIComponent(slug)}`;
|
|
497
|
+
const client = await getStoreApiClient();
|
|
498
|
+
const response = await client.get(path);
|
|
499
|
+
return StorefrontPageDetailSchema.parse(response);
|
|
500
|
+
}
|
|
501
|
+
async function getStorefrontPagePreview(slug, token) {
|
|
502
|
+
const path = `pages/${encodeURIComponent(slug)}/preview?token=${encodeURIComponent(token)}`;
|
|
503
|
+
const client = await getStoreApiClient();
|
|
504
|
+
const response = await client.get(path);
|
|
505
|
+
return StorefrontPageDetailSchema.parse(response);
|
|
506
|
+
}
|
|
507
|
+
var CartBuyerRequestSchema = z.object({
|
|
508
|
+
email: z.string().email(),
|
|
509
|
+
firstName: z.string().min(1),
|
|
510
|
+
lastName: z.string().min(1),
|
|
511
|
+
phone: z.string().min(1)
|
|
512
|
+
});
|
|
513
|
+
var CartCreateRequestSchema = z.object({
|
|
514
|
+
currencyCode: z.string(),
|
|
515
|
+
salesChannelId: z.string(),
|
|
516
|
+
email: z.string().email()
|
|
517
|
+
});
|
|
518
|
+
var CartAddressSchema = z.object({
|
|
519
|
+
name: z.string().min(1),
|
|
520
|
+
address1: z.string().min(1),
|
|
521
|
+
city: z.string().min(1),
|
|
522
|
+
countryCode: z.string().min(2),
|
|
523
|
+
company: z.string().nullable().optional(),
|
|
524
|
+
address2: z.string().nullable().optional(),
|
|
525
|
+
province: z.string().nullable().optional(),
|
|
526
|
+
postalCode: z.string().nullable().optional(),
|
|
527
|
+
district: z.string().nullable().optional(),
|
|
528
|
+
phone: z.string().nullable().optional(),
|
|
529
|
+
latitude: z.number().nullable().optional(),
|
|
530
|
+
longitude: z.number().nullable().optional(),
|
|
531
|
+
geo: z.object({
|
|
532
|
+
departmentCode: z.string().nullable().optional(),
|
|
533
|
+
provinceCode: z.string().nullable().optional(),
|
|
534
|
+
districtCode: z.string().nullable().optional()
|
|
535
|
+
}).nullable().optional()
|
|
536
|
+
});
|
|
537
|
+
var CartAddressesRequestSchema = z.object({
|
|
538
|
+
shippingAddress: CartAddressSchema,
|
|
539
|
+
billingAddress: CartAddressSchema
|
|
540
|
+
});
|
|
541
|
+
var CartItemModifierRequestSchema = z.object({
|
|
542
|
+
modifierGroupId: z.coerce.string().min(1),
|
|
543
|
+
optionIds: z.array(z.coerce.string().min(1)).optional().default([])
|
|
544
|
+
});
|
|
545
|
+
z.object({
|
|
546
|
+
variantId: z.coerce.string().min(1),
|
|
547
|
+
quantity: z.number().int().positive(),
|
|
548
|
+
modifiers: z.array(CartItemModifierRequestSchema).optional()
|
|
549
|
+
});
|
|
550
|
+
var CartCouponRequestSchema = z.object({
|
|
551
|
+
code: z.string().min(1)
|
|
552
|
+
});
|
|
553
|
+
z.object({
|
|
554
|
+
subtotal: z.number(),
|
|
555
|
+
discount: z.number(),
|
|
556
|
+
tax: z.number(),
|
|
557
|
+
warranty: z.number().optional().default(0),
|
|
558
|
+
total: z.number()
|
|
559
|
+
});
|
|
560
|
+
z.object({
|
|
561
|
+
name: z.string().nullable().optional(),
|
|
562
|
+
address1: z.string(),
|
|
563
|
+
city: z.string(),
|
|
564
|
+
countryCode: z.string(),
|
|
565
|
+
company: z.string().nullable().optional(),
|
|
566
|
+
address2: z.string().nullable().optional(),
|
|
567
|
+
province: z.string().nullable().optional(),
|
|
568
|
+
postalCode: z.string().nullable().optional(),
|
|
569
|
+
district: z.string().nullable().optional(),
|
|
570
|
+
phone: z.string().nullable().optional(),
|
|
571
|
+
latitude: z.number().nullable().optional(),
|
|
572
|
+
longitude: z.number().nullable().optional(),
|
|
573
|
+
geo: z.object({
|
|
574
|
+
departmentCode: z.string().nullable().optional(),
|
|
575
|
+
provinceCode: z.string().nullable().optional(),
|
|
576
|
+
districtCode: z.string().nullable().optional()
|
|
577
|
+
}).nullable().optional()
|
|
578
|
+
});
|
|
579
|
+
var CartResponseBundleItemSchema = z.object({
|
|
580
|
+
productId: z.coerce.string(),
|
|
581
|
+
variantId: z.coerce.string(),
|
|
582
|
+
productName: z.string(),
|
|
583
|
+
variantName: z.string().nullable().optional(),
|
|
584
|
+
sku: z.string().nullable().optional(),
|
|
585
|
+
brand: z.string().nullable().optional(),
|
|
586
|
+
imageUrl: z.string().nullable().optional(),
|
|
587
|
+
quantity: z.number().int()
|
|
588
|
+
});
|
|
589
|
+
var CartResponseItemSchema = z.object({
|
|
590
|
+
id: z.string(),
|
|
591
|
+
title: z.string(),
|
|
592
|
+
variantLabel: z.string().nullable().optional(),
|
|
593
|
+
thumbnail: z.string().nullable().optional(),
|
|
594
|
+
quantity: z.number().int(),
|
|
595
|
+
variantId: z.coerce.string(),
|
|
596
|
+
variantSku: z.string().nullable().optional(),
|
|
597
|
+
unitPrice: z.number(),
|
|
598
|
+
bundleItems: z.array(CartResponseBundleItemSchema).optional().default([])
|
|
599
|
+
});
|
|
600
|
+
z.object({
|
|
601
|
+
id: z.string(),
|
|
602
|
+
name: z.string(),
|
|
603
|
+
description: z.string().nullable().optional(),
|
|
604
|
+
total: z.number(),
|
|
605
|
+
estimatedDays: z.number().int().nullable().optional(),
|
|
606
|
+
pickupPointId: z.string().nullable().optional(),
|
|
607
|
+
scheduledDate: z.string().nullable().optional(),
|
|
608
|
+
scheduledTime: z.string().nullable().optional()
|
|
609
|
+
});
|
|
610
|
+
var CartResponseSchema = z.object({
|
|
611
|
+
id: z.string(),
|
|
612
|
+
regionId: z.string().nullable().optional(),
|
|
613
|
+
salesChannelId: z.string().nullable().optional(),
|
|
614
|
+
email: z.string().email().nullable().optional(),
|
|
615
|
+
phone: z.string().nullable().optional(),
|
|
616
|
+
firstName: z.string().nullable().optional(),
|
|
617
|
+
lastName: z.string().nullable().optional(),
|
|
618
|
+
currencyCode: z.string(),
|
|
619
|
+
completedAt: z.string().nullable().optional(),
|
|
620
|
+
shippingAddress: z.unknown().nullable().optional(),
|
|
621
|
+
billingAddress: z.unknown().nullable().optional(),
|
|
622
|
+
metadata: z.record(z.string(), z.unknown()).optional().default({}),
|
|
623
|
+
promotionCodes: z.array(z.string()).optional().default([]),
|
|
624
|
+
items: z.array(CartResponseItemSchema).optional().default([]),
|
|
625
|
+
shippingMethods: z.array(z.unknown()).optional().default([]),
|
|
626
|
+
totals: z.object({
|
|
627
|
+
discountTotal: z.number(),
|
|
628
|
+
shippingTotal: z.number(),
|
|
629
|
+
subtotal: z.number(),
|
|
630
|
+
taxTotal: z.number(),
|
|
631
|
+
total: z.number(),
|
|
632
|
+
warrantyTotal: z.number()
|
|
633
|
+
})
|
|
634
|
+
});
|
|
635
|
+
var CartCheckoutRequestSchema = z.object({
|
|
636
|
+
paymentMethodCode: z.string().min(1),
|
|
637
|
+
externalRef: z.string().min(1),
|
|
638
|
+
receiptUrl: z.string().min(1).optional()
|
|
639
|
+
});
|
|
640
|
+
var CartCheckoutPaymentActionSchema = z.object({
|
|
641
|
+
publicConfiguration: z.object({
|
|
642
|
+
publishableKey: z.string().nullable().optional(),
|
|
643
|
+
checkoutMode: z.string().nullable().optional(),
|
|
644
|
+
phoneNumber: z.string().nullable().optional(),
|
|
645
|
+
accountHolder: z.string().nullable().optional(),
|
|
646
|
+
qrImageUrl: z.string().nullable().optional()
|
|
647
|
+
}).passthrough().nullable().optional(),
|
|
648
|
+
url: z.string().nullable().optional(),
|
|
649
|
+
html: z.string().nullable().optional(),
|
|
650
|
+
clientSecret: z.string().nullable().optional(),
|
|
651
|
+
qrCode: z.string().nullable().optional(),
|
|
652
|
+
expiresAt: z.string().nullable().optional()
|
|
653
|
+
}).passthrough();
|
|
654
|
+
var CartCheckoutPaymentSchema = z.object({
|
|
655
|
+
transactionId: z.string(),
|
|
656
|
+
paymentMethodCode: z.string(),
|
|
657
|
+
providerId: z.string().nullable().optional(),
|
|
658
|
+
status: z.string(),
|
|
659
|
+
amount: z.number(),
|
|
660
|
+
reference: z.string(),
|
|
661
|
+
actionType: z.string(),
|
|
662
|
+
receiptUrl: z.string().nullable().optional(),
|
|
663
|
+
action: CartCheckoutPaymentActionSchema.nullable().optional()
|
|
664
|
+
}).passthrough();
|
|
665
|
+
var CartCheckoutResponseSchema = z.object({
|
|
666
|
+
publicKey: z.string().optional(),
|
|
667
|
+
publishableKey: z.string().optional(),
|
|
668
|
+
stripePublicKey: z.string().optional(),
|
|
669
|
+
clientSecret: z.string().optional(),
|
|
670
|
+
intentClientSecret: z.string().optional(),
|
|
671
|
+
orderId: z.coerce.string().optional(),
|
|
672
|
+
orderGroup: z.string().optional(),
|
|
673
|
+
orderIds: z.array(z.coerce.string()).optional(),
|
|
674
|
+
/** Payload de pago (embedded, redirect, etc.) */
|
|
675
|
+
payment: CartCheckoutPaymentSchema.optional(),
|
|
676
|
+
cart: z.unknown().optional()
|
|
677
|
+
}).passthrough();
|
|
678
|
+
var CartPaymentReceiptResponseSchema = z.object({
|
|
679
|
+
id: z.string(),
|
|
680
|
+
url: z.string()
|
|
681
|
+
});
|
|
682
|
+
var CartPaymentMethodSchema = z.object({
|
|
683
|
+
code: z.string(),
|
|
684
|
+
name: z.string(),
|
|
685
|
+
description: z.string().nullable().optional(),
|
|
686
|
+
kind: z.string(),
|
|
687
|
+
isActive: z.boolean(),
|
|
688
|
+
isDefault: z.boolean(),
|
|
689
|
+
isManual: z.boolean(),
|
|
690
|
+
sortOrder: z.number(),
|
|
691
|
+
phoneNumber: z.string().nullable().optional(),
|
|
692
|
+
accountHolder: z.string().nullable().optional(),
|
|
693
|
+
qrImageUrl: z.string().nullable().optional()
|
|
694
|
+
});
|
|
695
|
+
var CartPaymentMethodsResponseSchema = z.object({
|
|
696
|
+
methods: z.array(CartPaymentMethodSchema)
|
|
697
|
+
});
|
|
698
|
+
var CartCheckoutReadResponseSchema = z.object({
|
|
699
|
+
cart: CartResponseSchema,
|
|
700
|
+
paymentMethods: CartPaymentMethodsResponseSchema
|
|
701
|
+
});
|
|
702
|
+
var ShippingRateSchema = z.object({
|
|
703
|
+
shippingMethodId: z.string(),
|
|
704
|
+
name: z.string(),
|
|
705
|
+
displayName: z.string().optional(),
|
|
706
|
+
type: z.string().optional(),
|
|
707
|
+
price: z.number(),
|
|
708
|
+
currency: z.string().optional(),
|
|
709
|
+
sortOrder: z.number().optional(),
|
|
710
|
+
rateId: z.string(),
|
|
711
|
+
description: z.string().nullable().optional(),
|
|
712
|
+
deliveryLocationId: z.string().nullable().optional(),
|
|
713
|
+
deliveryLocationName: z.string().nullable().optional(),
|
|
714
|
+
estimatedDeliveryDays: z.number().nullable().optional(),
|
|
715
|
+
serviceCode: z.string().nullable().optional(),
|
|
716
|
+
metadata: z.record(z.string(), z.unknown()).optional()
|
|
717
|
+
}).passthrough();
|
|
718
|
+
var ShippingOptionGroupSchema = z.object({
|
|
719
|
+
sellerId: z.string(),
|
|
720
|
+
shippingProfileId: z.string().nullable().optional(),
|
|
721
|
+
orderAmount: z.number().optional(),
|
|
722
|
+
totalWeight: z.number().optional(),
|
|
723
|
+
itemIds: z.array(z.string()).optional(),
|
|
724
|
+
rates: z.array(ShippingRateSchema)
|
|
725
|
+
}).passthrough();
|
|
726
|
+
var ShippingOptionsResponseSchema = z.object({
|
|
727
|
+
groups: z.array(ShippingOptionGroupSchema)
|
|
728
|
+
});
|
|
729
|
+
var CartShippingMethodPutRequestSchema = z.object({
|
|
730
|
+
rateId: z.string().min(1),
|
|
731
|
+
shippingMethodId: z.string().min(1),
|
|
732
|
+
serviceCode: z.string().nullable().optional(),
|
|
733
|
+
sellerId: z.string().nullable().optional(),
|
|
734
|
+
shippingProfileId: z.string().nullable().optional(),
|
|
735
|
+
locationId: z.string().nullable().optional(),
|
|
736
|
+
pickupPointId: z.string().nullable().optional(),
|
|
737
|
+
scheduledDate: z.string().nullable().optional(),
|
|
738
|
+
scheduledTime: z.string().nullable().optional()
|
|
739
|
+
});
|
|
740
|
+
|
|
741
|
+
// src/core/client/store-api-cart.service.ts
|
|
742
|
+
async function createCart(data) {
|
|
743
|
+
const payload = CartCreateRequestSchema.parse(data);
|
|
744
|
+
const client = await getStoreApiClient();
|
|
745
|
+
const response = await client.post("carts", payload);
|
|
746
|
+
return CartResponseSchema.parse(response);
|
|
747
|
+
}
|
|
748
|
+
async function getCart(cartId) {
|
|
749
|
+
if (!cartId) throw new Error("cartId is required");
|
|
750
|
+
const client = await getStoreApiClient();
|
|
751
|
+
const response = await client.get(`carts/${cartId}`);
|
|
752
|
+
return CartResponseSchema.parse(response);
|
|
753
|
+
}
|
|
754
|
+
async function patchCartBuyer(data, cartId) {
|
|
755
|
+
if (!cartId) throw new Error("cartId is required");
|
|
756
|
+
const payload = CartBuyerRequestSchema.parse(data);
|
|
757
|
+
const client = await getStoreApiClient();
|
|
758
|
+
const response = await client.patch(
|
|
759
|
+
`carts/${cartId}/buyer`,
|
|
760
|
+
payload
|
|
761
|
+
);
|
|
762
|
+
return CartResponseSchema.parse(response);
|
|
763
|
+
}
|
|
764
|
+
async function patchCartAddresses(data, cartId) {
|
|
765
|
+
if (!cartId) throw new Error("cartId is required");
|
|
766
|
+
const payload = CartAddressesRequestSchema.parse(data);
|
|
767
|
+
const client = await getStoreApiClient();
|
|
768
|
+
const response = await client.patch(
|
|
769
|
+
`carts/${cartId}/addresses`,
|
|
770
|
+
payload
|
|
771
|
+
);
|
|
772
|
+
return CartResponseSchema.parse(response);
|
|
773
|
+
}
|
|
774
|
+
async function addCartCoupon(cartId, data) {
|
|
775
|
+
if (!cartId) throw new Error("cartId is required");
|
|
776
|
+
const payload = CartCouponRequestSchema.parse(data);
|
|
777
|
+
const client = await getStoreApiClient();
|
|
778
|
+
const response = await client.post(
|
|
779
|
+
`carts/${cartId}/promotion-codes`,
|
|
780
|
+
payload
|
|
781
|
+
);
|
|
782
|
+
return CartResponseSchema.parse(response);
|
|
783
|
+
}
|
|
784
|
+
async function removeCartCoupon(cartId, code) {
|
|
785
|
+
if (!cartId) throw new Error("cartId is required");
|
|
786
|
+
if (!code.trim()) throw new Error("code is required");
|
|
787
|
+
const client = await getStoreApiClient();
|
|
788
|
+
const response = await client.delete(
|
|
789
|
+
`carts/${cartId}/promotion-codes/${encodeURIComponent(code.trim())}`
|
|
790
|
+
);
|
|
791
|
+
return CartResponseSchema.parse(response);
|
|
792
|
+
}
|
|
793
|
+
async function checkoutCart(data, cartId) {
|
|
794
|
+
if (!cartId) throw new Error("cartId is required");
|
|
795
|
+
const payload = CartCheckoutRequestSchema.parse(data);
|
|
796
|
+
const client = await getStoreApiClient();
|
|
797
|
+
const response = await client.post(
|
|
798
|
+
`carts/${cartId}/checkout`,
|
|
799
|
+
payload
|
|
800
|
+
);
|
|
801
|
+
return CartCheckoutResponseSchema.parse(response);
|
|
802
|
+
}
|
|
803
|
+
async function uploadPaymentReceipt(cartId, file) {
|
|
804
|
+
if (!cartId) throw new Error("cartId is required");
|
|
805
|
+
const baseUrl = await getStoreApiBaseUrl();
|
|
806
|
+
const form = new FormData();
|
|
807
|
+
form.set("file", file);
|
|
808
|
+
const response = await fetch(
|
|
809
|
+
`${baseUrl.replace(/\/$/, "")}/carts/${encodeURIComponent(cartId)}/payment-receipt`,
|
|
810
|
+
{
|
|
811
|
+
method: "POST",
|
|
812
|
+
body: form,
|
|
813
|
+
...typeof window === "undefined" && { cache: "no-store" }
|
|
814
|
+
}
|
|
815
|
+
);
|
|
816
|
+
if (!response.ok) {
|
|
817
|
+
let body;
|
|
818
|
+
try {
|
|
819
|
+
const errorText = await response.text();
|
|
820
|
+
body = errorText ? JSON.parse(errorText) : void 0;
|
|
821
|
+
} catch {
|
|
822
|
+
body = void 0;
|
|
823
|
+
}
|
|
824
|
+
const message = typeof body === "object" && body !== null && "title" in body && typeof body.title === "string" ? body.title : response.statusText || "Store API error";
|
|
825
|
+
const error = new Error(message);
|
|
826
|
+
error.status = response.status;
|
|
827
|
+
error.body = body;
|
|
828
|
+
throw error;
|
|
829
|
+
}
|
|
830
|
+
return CartPaymentReceiptResponseSchema.parse(await response.json());
|
|
831
|
+
}
|
|
832
|
+
async function getCartCheckout(cartId) {
|
|
833
|
+
if (!cartId) throw new Error("cartId is required");
|
|
834
|
+
const client = await getStoreApiClient();
|
|
835
|
+
const response = await client.get(`carts/${cartId}/checkout`);
|
|
836
|
+
return CartCheckoutReadResponseSchema.parse(response);
|
|
837
|
+
}
|
|
838
|
+
async function getShippingOptions(cartId, postalCode) {
|
|
839
|
+
if (!cartId) throw new Error("cartId is required");
|
|
840
|
+
if (!postalCode?.trim()) throw new Error("postalCode is required");
|
|
841
|
+
const client = await getStoreApiClient();
|
|
842
|
+
const q = new URLSearchParams({ postalCode: postalCode.trim() });
|
|
843
|
+
const response = await client.get(
|
|
844
|
+
`carts/${cartId}/shipping-options?${q.toString()}`
|
|
845
|
+
);
|
|
846
|
+
return ShippingOptionsResponseSchema.parse(response);
|
|
847
|
+
}
|
|
848
|
+
async function putCartShippingMethod(cartId, data) {
|
|
849
|
+
if (!cartId) throw new Error("cartId is required");
|
|
850
|
+
const payload = CartShippingMethodPutRequestSchema.parse(data);
|
|
851
|
+
const client = await getStoreApiClient();
|
|
852
|
+
const response = await client.put(
|
|
853
|
+
`carts/${cartId}/shipping-method`,
|
|
854
|
+
payload
|
|
855
|
+
);
|
|
856
|
+
return CartResponseSchema.parse(response);
|
|
857
|
+
}
|
|
858
|
+
async function getCartPaymentMethods(cartId) {
|
|
859
|
+
if (!cartId) throw new Error("cartId is required");
|
|
860
|
+
const { paymentMethods } = await getCartCheckout(cartId);
|
|
861
|
+
return paymentMethods;
|
|
862
|
+
}
|
|
863
|
+
var CustomerRegisterRequestSchema = z.object({
|
|
864
|
+
email: z.string().email(),
|
|
865
|
+
firstName: z.string().trim().min(1),
|
|
866
|
+
lastName: z.string().trim().min(1),
|
|
867
|
+
countryIsoCode: z.string().trim().length(2),
|
|
868
|
+
password: z.string(),
|
|
869
|
+
phone: z.string().trim().optional()
|
|
870
|
+
});
|
|
871
|
+
var CustomerAddressSchema = z.object({
|
|
872
|
+
/** Presente en listados cuando el upstream expone el id para PUT/DELETE. */
|
|
873
|
+
id: z.string().optional(),
|
|
874
|
+
addressKey: z.string(),
|
|
875
|
+
countryIsoCode: z.string(),
|
|
876
|
+
addressLine: z.string(),
|
|
877
|
+
addressNumber: z.string(),
|
|
878
|
+
department: z.string(),
|
|
879
|
+
province: z.string(),
|
|
880
|
+
district: z.string(),
|
|
881
|
+
phone: z.string(),
|
|
882
|
+
cellPhone: z.string(),
|
|
883
|
+
postalCode: z.string(),
|
|
884
|
+
reference: z.string(),
|
|
885
|
+
latitude: z.number().nullable(),
|
|
886
|
+
longitude: z.number().nullable(),
|
|
887
|
+
isDefault: z.boolean()
|
|
888
|
+
});
|
|
889
|
+
var CustomerAddressUpsertSchema = CustomerAddressSchema.omit({ id: true });
|
|
890
|
+
var CustomerMeSchema = z.object({
|
|
891
|
+
id: z.string(),
|
|
892
|
+
storeId: z.string(),
|
|
893
|
+
email: z.string().email(),
|
|
894
|
+
firstName: z.string(),
|
|
895
|
+
lastName: z.string(),
|
|
896
|
+
phone: z.string(),
|
|
897
|
+
identificationNumber: z.string().nullable(),
|
|
898
|
+
identificationType: z.string().nullable(),
|
|
899
|
+
entityName: z.string().nullable(),
|
|
900
|
+
dateOfBirth: z.string().nullable(),
|
|
901
|
+
gender: z.string().nullable(),
|
|
902
|
+
countryIsoCode: z.string(),
|
|
903
|
+
role: z.string().nullable(),
|
|
904
|
+
companyName: z.string().nullable(),
|
|
905
|
+
consent: z.boolean(),
|
|
906
|
+
userId: z.string(),
|
|
907
|
+
customerType: z.string(),
|
|
908
|
+
status: z.string(),
|
|
909
|
+
entityIdentificationNumber: z.string().nullable(),
|
|
910
|
+
defaultAddressId: z.string().nullable(),
|
|
911
|
+
metadata: z.unknown().nullable(),
|
|
912
|
+
totalOrders: z.number(),
|
|
913
|
+
avgOrders: z.number(),
|
|
914
|
+
lastOrderId: z.string().nullable(),
|
|
915
|
+
lastOrderDate: z.string().nullable(),
|
|
916
|
+
loyaltyPoints: z.number(),
|
|
917
|
+
addresses: z.array(CustomerAddressSchema),
|
|
918
|
+
createdOn: z.string(),
|
|
919
|
+
updatedOn: z.string().nullable()
|
|
920
|
+
});
|
|
921
|
+
var CustomerProfilePatchSchema = z.object({
|
|
922
|
+
firstName: z.string().trim().min(1),
|
|
923
|
+
lastName: z.string().trim().min(1),
|
|
924
|
+
phone: z.string().trim(),
|
|
925
|
+
identificationNumber: z.string().nullable(),
|
|
926
|
+
identificationType: z.string().nullable(),
|
|
927
|
+
entityName: z.string().nullable(),
|
|
928
|
+
entityIdentificationNumber: z.string().nullable(),
|
|
929
|
+
gender: z.string().nullable(),
|
|
930
|
+
role: z.string().nullable(),
|
|
931
|
+
companyName: z.string().nullable(),
|
|
932
|
+
dateOfBirth: z.string().nullable(),
|
|
933
|
+
consent: z.boolean(),
|
|
934
|
+
countryIsoCode: z.string().trim().length(2)
|
|
935
|
+
});
|
|
936
|
+
function customerMeToProfilePatch(me) {
|
|
937
|
+
return {
|
|
938
|
+
firstName: me.firstName,
|
|
939
|
+
lastName: me.lastName,
|
|
940
|
+
phone: me.phone ?? "",
|
|
941
|
+
identificationNumber: me.identificationNumber,
|
|
942
|
+
identificationType: me.identificationType,
|
|
943
|
+
entityName: me.entityName,
|
|
944
|
+
entityIdentificationNumber: me.entityIdentificationNumber,
|
|
945
|
+
gender: me.gender,
|
|
946
|
+
role: me.role,
|
|
947
|
+
companyName: me.companyName,
|
|
948
|
+
dateOfBirth: me.dateOfBirth,
|
|
949
|
+
consent: me.consent,
|
|
950
|
+
countryIsoCode: me.countryIsoCode || "PE"
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
function customerAuthOptions(accessToken) {
|
|
954
|
+
const token = typeof accessToken === "string" && accessToken.trim().length > 0 ? accessToken.trim() : void 0;
|
|
955
|
+
return token ? { bearerToken: token } : {};
|
|
956
|
+
}
|
|
957
|
+
async function registerCustomer(data) {
|
|
958
|
+
const payload = CustomerRegisterRequestSchema.parse(data);
|
|
959
|
+
const client = await getStoreApiClient();
|
|
960
|
+
return client.post("customer/register", payload);
|
|
961
|
+
}
|
|
962
|
+
async function getCustomerAddresses(accessToken) {
|
|
963
|
+
const client = await getStoreApiClient();
|
|
964
|
+
const token = typeof accessToken === "string" && accessToken.trim().length > 0 ? accessToken.trim() : void 0;
|
|
965
|
+
const response = await client.get("customer/addresses", {
|
|
966
|
+
...token ? { bearerToken: token } : {}
|
|
967
|
+
});
|
|
968
|
+
return z.array(CustomerAddressSchema).parse(response);
|
|
969
|
+
}
|
|
970
|
+
async function createCustomerAddress(data, accessToken) {
|
|
971
|
+
const client = await getStoreApiClient();
|
|
972
|
+
const token = typeof accessToken === "string" && accessToken.trim().length > 0 ? accessToken.trim() : void 0;
|
|
973
|
+
const payload = CustomerAddressUpsertSchema.parse(data);
|
|
974
|
+
return client.post("customer/addresses", payload, {
|
|
975
|
+
...token ? { bearerToken: token } : {}
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
async function updateCustomerAddress(addressId, data, accessToken) {
|
|
979
|
+
const client = await getStoreApiClient();
|
|
980
|
+
const token = typeof accessToken === "string" && accessToken.trim().length > 0 ? accessToken.trim() : void 0;
|
|
981
|
+
const payload = CustomerAddressUpsertSchema.parse(data);
|
|
982
|
+
const id = addressId.trim();
|
|
983
|
+
if (!id) throw new Error("addressId requerido");
|
|
984
|
+
return client.put(`customer/addresses/${encodeURIComponent(id)}`, payload, {
|
|
985
|
+
...token ? { bearerToken: token } : {}
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
async function deleteCustomerAddress(addressId, accessToken) {
|
|
989
|
+
const client = await getStoreApiClient();
|
|
990
|
+
const token = typeof accessToken === "string" && accessToken.trim().length > 0 ? accessToken.trim() : void 0;
|
|
991
|
+
const id = addressId.trim();
|
|
992
|
+
if (!id) throw new Error("addressId requerido");
|
|
993
|
+
return client.delete(`customer/addresses/${encodeURIComponent(id)}`, {
|
|
994
|
+
...token ? { bearerToken: token } : {}
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
async function getCustomerMe(accessToken) {
|
|
998
|
+
const client = await getStoreApiClient();
|
|
999
|
+
const response = await client.get("customer", customerAuthOptions(accessToken));
|
|
1000
|
+
return CustomerMeSchema.parse(response);
|
|
1001
|
+
}
|
|
1002
|
+
async function patchCustomer(data, accessToken) {
|
|
1003
|
+
const client = await getStoreApiClient();
|
|
1004
|
+
const payload = CustomerProfilePatchSchema.parse(data);
|
|
1005
|
+
await client.patch("customer", payload, customerAuthOptions(accessToken));
|
|
1006
|
+
}
|
|
1007
|
+
var CustomerOrderShippingAddressSchema = z.object({
|
|
1008
|
+
name: z.string().nullable().optional(),
|
|
1009
|
+
company: z.string().nullable().optional(),
|
|
1010
|
+
address1: z.string(),
|
|
1011
|
+
address2: z.string().nullable().optional(),
|
|
1012
|
+
city: z.string().nullable().optional(),
|
|
1013
|
+
countryCode: z.string(),
|
|
1014
|
+
province: z.string().nullable().optional(),
|
|
1015
|
+
postalCode: z.string().nullable().optional(),
|
|
1016
|
+
district: z.string().nullable().optional(),
|
|
1017
|
+
phone: z.string().nullable().optional(),
|
|
1018
|
+
latitude: z.number().nullable().optional(),
|
|
1019
|
+
longitude: z.number().nullable().optional(),
|
|
1020
|
+
metadata: z.record(z.unknown()).nullable().optional()
|
|
1021
|
+
}).passthrough();
|
|
1022
|
+
var CustomerOrderLineItemSchema = z.object({
|
|
1023
|
+
id: z.string(),
|
|
1024
|
+
orderId: z.coerce.string(),
|
|
1025
|
+
productId: z.coerce.string().nullable(),
|
|
1026
|
+
variantId: z.coerce.string().nullable(),
|
|
1027
|
+
title: z.string(),
|
|
1028
|
+
subtitle: z.string().nullable().optional(),
|
|
1029
|
+
thumbnail: z.string().nullable().optional(),
|
|
1030
|
+
variantTitle: z.string().nullable().optional(),
|
|
1031
|
+
productHandle: z.string().nullable().optional(),
|
|
1032
|
+
quantity: z.number(),
|
|
1033
|
+
unitPrice: z.number(),
|
|
1034
|
+
total: z.number(),
|
|
1035
|
+
status: z.string()
|
|
1036
|
+
});
|
|
1037
|
+
var CustomerOrderListItemSchema = z.object({
|
|
1038
|
+
orderId: z.coerce.string(),
|
|
1039
|
+
orderNumber: z.string(),
|
|
1040
|
+
orderGroup: z.string(),
|
|
1041
|
+
orderIds: z.array(z.coerce.string()),
|
|
1042
|
+
status: z.string(),
|
|
1043
|
+
total: z.number(),
|
|
1044
|
+
totalPaid: z.number(),
|
|
1045
|
+
currencyCode: z.string(),
|
|
1046
|
+
orderDate: z.string(),
|
|
1047
|
+
createdOn: z.string(),
|
|
1048
|
+
updatedOn: z.string().nullable().optional(),
|
|
1049
|
+
paymentAt: z.string().nullable().optional(),
|
|
1050
|
+
shippingAddress: CustomerOrderShippingAddressSchema.nullable().optional(),
|
|
1051
|
+
shippingAddressSummary: z.string().nullable().optional(),
|
|
1052
|
+
items: z.array(CustomerOrderLineItemSchema)
|
|
1053
|
+
});
|
|
1054
|
+
var CustomerOrderPaymentSchema = z.object({
|
|
1055
|
+
id: z.string(),
|
|
1056
|
+
paymentMethod: z.string(),
|
|
1057
|
+
paymentCode: z.string(),
|
|
1058
|
+
amount: z.number(),
|
|
1059
|
+
paymentStatus: z.string(),
|
|
1060
|
+
receiptUrl: z.string().nullable().optional(),
|
|
1061
|
+
createdOn: z.string()
|
|
1062
|
+
});
|
|
1063
|
+
var CustomerOrderStatusTimelineSchema = z.object({
|
|
1064
|
+
key: z.string(),
|
|
1065
|
+
label: z.string(),
|
|
1066
|
+
occurredAt: z.string(),
|
|
1067
|
+
description: z.string().nullable().optional(),
|
|
1068
|
+
status: z.string(),
|
|
1069
|
+
source: z.string()
|
|
1070
|
+
});
|
|
1071
|
+
var CustomerOrderDetailSchema = z.object({
|
|
1072
|
+
id: z.coerce.string(),
|
|
1073
|
+
orderNumber: z.string(),
|
|
1074
|
+
orderGroup: z.string(),
|
|
1075
|
+
status: z.string(),
|
|
1076
|
+
total: z.number(),
|
|
1077
|
+
totalPaid: z.number(),
|
|
1078
|
+
currencyCode: z.string(),
|
|
1079
|
+
orderDate: z.string(),
|
|
1080
|
+
createdOn: z.string(),
|
|
1081
|
+
updatedOn: z.string().nullable().optional(),
|
|
1082
|
+
paymentAt: z.string().nullable().optional(),
|
|
1083
|
+
subTotal: z.number(),
|
|
1084
|
+
discount: z.number(),
|
|
1085
|
+
shipping: z.number(),
|
|
1086
|
+
tax: z.number(),
|
|
1087
|
+
email: z.string(),
|
|
1088
|
+
phone: z.string(),
|
|
1089
|
+
firstName: z.string(),
|
|
1090
|
+
lastName: z.string(),
|
|
1091
|
+
shippingAddress: CustomerOrderShippingAddressSchema.nullable().optional(),
|
|
1092
|
+
shippingAddressSummary: z.string().nullable().optional(),
|
|
1093
|
+
billingAddress: CustomerOrderShippingAddressSchema.nullable().optional(),
|
|
1094
|
+
items: z.array(CustomerOrderLineItemSchema),
|
|
1095
|
+
payments: z.array(CustomerOrderPaymentSchema),
|
|
1096
|
+
statusTimeline: z.array(CustomerOrderStatusTimelineSchema)
|
|
1097
|
+
});
|
|
1098
|
+
function authOptions(accessToken) {
|
|
1099
|
+
const token = typeof accessToken === "string" && accessToken.trim().length > 0 ? accessToken.trim() : void 0;
|
|
1100
|
+
return token ? { bearerToken: token } : {};
|
|
1101
|
+
}
|
|
1102
|
+
async function getCustomerOrders(accessToken) {
|
|
1103
|
+
const client = await getStoreApiClient();
|
|
1104
|
+
const response = await client.get("customer/orders", authOptions(accessToken));
|
|
1105
|
+
return z.array(CustomerOrderListItemSchema).parse(response);
|
|
1106
|
+
}
|
|
1107
|
+
async function getCustomerOrder(orderId, accessToken) {
|
|
1108
|
+
const client = await getStoreApiClient();
|
|
1109
|
+
const id = orderId.trim();
|
|
1110
|
+
if (!id) throw new Error("orderId requerido");
|
|
1111
|
+
const response = await client.get(
|
|
1112
|
+
`customer/orders/${encodeURIComponent(id)}`,
|
|
1113
|
+
authOptions(accessToken)
|
|
1114
|
+
);
|
|
1115
|
+
return CustomerOrderDetailSchema.parse(response);
|
|
1116
|
+
}
|
|
1117
|
+
var StorefrontOrderAddressSchema = z.object({
|
|
1118
|
+
address1: z.string().optional(),
|
|
1119
|
+
address2: z.string().optional(),
|
|
1120
|
+
city: z.string().optional(),
|
|
1121
|
+
province: z.string().optional(),
|
|
1122
|
+
country: z.string().optional(),
|
|
1123
|
+
zip: z.string().optional(),
|
|
1124
|
+
phone: z.string().optional(),
|
|
1125
|
+
firstName: z.string().optional(),
|
|
1126
|
+
lastName: z.string().optional()
|
|
1127
|
+
}).passthrough();
|
|
1128
|
+
var OrderDraftItemSchema = z.object({
|
|
1129
|
+
id: z.string(),
|
|
1130
|
+
productId: z.coerce.string().nullable().optional(),
|
|
1131
|
+
sellerId: z.string().nullable().optional(),
|
|
1132
|
+
shippingProfileId: z.string().nullable().optional(),
|
|
1133
|
+
variantId: z.coerce.string().nullable().optional(),
|
|
1134
|
+
title: z.string(),
|
|
1135
|
+
subtitle: z.string().nullable().optional(),
|
|
1136
|
+
thumbnail: z.string().nullable().optional(),
|
|
1137
|
+
quantity: z.number().optional().default(1),
|
|
1138
|
+
unitPrice: z.number().optional().default(0),
|
|
1139
|
+
subTotal: z.number().optional().default(0),
|
|
1140
|
+
discount: z.number().optional().default(0),
|
|
1141
|
+
shipping: z.number().optional().default(0),
|
|
1142
|
+
tax: z.number().optional().default(0),
|
|
1143
|
+
warranty: z.number().optional().default(0),
|
|
1144
|
+
total: z.number().optional().default(0),
|
|
1145
|
+
requiresShipping: z.boolean().optional().default(true),
|
|
1146
|
+
isTaxInclusive: z.boolean().optional().default(true),
|
|
1147
|
+
metadata: z.record(z.unknown()).optional().default({})
|
|
1148
|
+
});
|
|
1149
|
+
var OrderDraftShippingMethodSchema = z.object({
|
|
1150
|
+
id: z.string(),
|
|
1151
|
+
name: z.string().optional().default(""),
|
|
1152
|
+
description: z.string().nullable().optional(),
|
|
1153
|
+
subtotal: z.number().optional().default(0),
|
|
1154
|
+
discountTotal: z.number().optional().default(0),
|
|
1155
|
+
taxTotal: z.number().optional().default(0),
|
|
1156
|
+
total: z.number().optional().default(0),
|
|
1157
|
+
isTaxInclusive: z.boolean().optional().default(true),
|
|
1158
|
+
sellerId: z.string().nullable().optional(),
|
|
1159
|
+
shippingProfileId: z.string().nullable().optional(),
|
|
1160
|
+
shippingMethodId: z.string().nullable().optional(),
|
|
1161
|
+
connectionId: z.string().nullable().optional(),
|
|
1162
|
+
providerName: z.string().nullable().optional(),
|
|
1163
|
+
trackingCode: z.string().nullable().optional(),
|
|
1164
|
+
estimatedDays: z.number().nullable().optional(),
|
|
1165
|
+
zoneCode: z.string().nullable().optional(),
|
|
1166
|
+
locationId: z.string().nullable().optional(),
|
|
1167
|
+
pickupPointId: z.string().nullable().optional(),
|
|
1168
|
+
scheduledDate: z.string().nullable().optional(),
|
|
1169
|
+
scheduledTime: z.string().nullable().optional(),
|
|
1170
|
+
data: z.record(z.unknown()).optional().default({})
|
|
1171
|
+
});
|
|
1172
|
+
var OrderDraftSchema = z.object({
|
|
1173
|
+
id: z.string(),
|
|
1174
|
+
storeId: z.string().optional(),
|
|
1175
|
+
customerId: z.coerce.string().nullable().optional(),
|
|
1176
|
+
cartId: z.string().nullable().optional(),
|
|
1177
|
+
draftNumber: z.string(),
|
|
1178
|
+
currencyCode: z.string().optional().default("PEN"),
|
|
1179
|
+
source: z.string().nullable().optional(),
|
|
1180
|
+
notes: z.string().nullable().optional(),
|
|
1181
|
+
email: z.string().nullable().optional(),
|
|
1182
|
+
phone: z.string().nullable().optional(),
|
|
1183
|
+
firstName: z.string().nullable().optional(),
|
|
1184
|
+
lastName: z.string().nullable().optional(),
|
|
1185
|
+
identificationType: z.string().nullable().optional(),
|
|
1186
|
+
identificationNumber: z.string().nullable().optional(),
|
|
1187
|
+
entityTaxId: z.string().nullable().optional(),
|
|
1188
|
+
entityName: z.string().nullable().optional(),
|
|
1189
|
+
status: z.string(),
|
|
1190
|
+
draftDate: z.string().nullable().optional(),
|
|
1191
|
+
sentAt: z.string().nullable().optional(),
|
|
1192
|
+
viewedAt: z.string().nullable().optional(),
|
|
1193
|
+
acceptedAt: z.string().nullable().optional(),
|
|
1194
|
+
rejectedAt: z.string().nullable().optional(),
|
|
1195
|
+
expiredAt: z.string().nullable().optional(),
|
|
1196
|
+
cancelledAt: z.string().nullable().optional(),
|
|
1197
|
+
convertedAt: z.string().nullable().optional(),
|
|
1198
|
+
shareToken: z.string().nullable().optional(),
|
|
1199
|
+
shareExpiresAt: z.string().nullable().optional(),
|
|
1200
|
+
allowAnonymousShareAccess: z.boolean().optional().default(false),
|
|
1201
|
+
sharedAt: z.string().nullable().optional(),
|
|
1202
|
+
billingAddress: StorefrontOrderAddressSchema.optional().nullable(),
|
|
1203
|
+
shippingAddress: StorefrontOrderAddressSchema.optional().nullable(),
|
|
1204
|
+
metadata: z.record(z.unknown()).optional().default({}),
|
|
1205
|
+
subTotal: z.number().optional().default(0),
|
|
1206
|
+
discount: z.number().optional().default(0),
|
|
1207
|
+
shipping: z.number().optional().default(0),
|
|
1208
|
+
tax: z.number().optional().default(0),
|
|
1209
|
+
warranty: z.number().optional().default(0),
|
|
1210
|
+
total: z.number().optional().default(0),
|
|
1211
|
+
paymentMethod: z.string().optional().default(""),
|
|
1212
|
+
paymentCode: z.string().optional().default(""),
|
|
1213
|
+
items: z.array(OrderDraftItemSchema).optional().default([]),
|
|
1214
|
+
shippingMethods: z.array(OrderDraftShippingMethodSchema).optional().default([]),
|
|
1215
|
+
createdOn: z.string().optional(),
|
|
1216
|
+
updatedOn: z.string().nullable().optional()
|
|
1217
|
+
});
|
|
1218
|
+
|
|
1219
|
+
// src/core/client/store-api-order-draft.service.ts
|
|
1220
|
+
async function getSharedOrderDraft(shareToken) {
|
|
1221
|
+
const client = await getStoreApiClient();
|
|
1222
|
+
const response = await client.get(
|
|
1223
|
+
`order-drafts/share/${encodeURIComponent(shareToken)}`,
|
|
1224
|
+
{ noStore: true }
|
|
1225
|
+
);
|
|
1226
|
+
return OrderDraftSchema.parse(response);
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
// src/react/auth/ecomiq-oauth-password-constants.ts
|
|
1230
|
+
var PLUGIN_ID = "ecomiq-oauth-password";
|
|
1231
|
+
var ECOMIQ_OAUTH_TOKEN_URL = "https://auth.ecomiq.pe/connect/token";
|
|
1232
|
+
var ECOMIQ_OAUTH_USERINFO_URL = "https://auth.ecomiq.pe/connect/userinfo";
|
|
1233
|
+
var tokenResponseSchema = z.object({
|
|
1234
|
+
access_token: z.string().min(1),
|
|
1235
|
+
token_type: z.string().optional(),
|
|
1236
|
+
/** Segundos hasta expiración (Ecomiq envía ej. `86399`). Sincroniza la sesión Better Auth con el bearer. */
|
|
1237
|
+
expires_in: z.coerce.number().int().positive().optional()
|
|
1238
|
+
});
|
|
1239
|
+
var userInfoSchema = z.object({
|
|
1240
|
+
sub: z.string(),
|
|
1241
|
+
email: z.string().email().optional(),
|
|
1242
|
+
family_name: z.string().optional(),
|
|
1243
|
+
given_name: z.string().optional(),
|
|
1244
|
+
iss: z.string().optional(),
|
|
1245
|
+
aud: z.union([z.string(), z.array(z.string())]).optional()
|
|
1246
|
+
});
|
|
1247
|
+
var signInBody = z.object({
|
|
1248
|
+
email: z.string().email(),
|
|
1249
|
+
password: z.string().min(1),
|
|
1250
|
+
callbackURL: z.string().optional(),
|
|
1251
|
+
rememberMe: z.boolean().optional().default(true)
|
|
1252
|
+
});
|
|
1253
|
+
|
|
1254
|
+
// src/react/auth/ecomiq-oauth-password-plugin.ts
|
|
1255
|
+
function ecomiqOAuthPassword() {
|
|
1256
|
+
const secureCookie = true;
|
|
1257
|
+
const clearStorefrontOAuthCookieMiddleware = createAuthMiddleware(async (ctx) => {
|
|
1258
|
+
ctx.setCookie(STOREFRONT_ECOMIQ_OAUTH_COOKIE_NAME, "", {
|
|
1259
|
+
path: STOREFRONT_ECOMIQ_OAUTH_COOKIE_PATH,
|
|
1260
|
+
httpOnly: true,
|
|
1261
|
+
sameSite: "lax",
|
|
1262
|
+
secure: secureCookie,
|
|
1263
|
+
maxAge: 0
|
|
1264
|
+
});
|
|
1265
|
+
});
|
|
1266
|
+
return {
|
|
1267
|
+
id: PLUGIN_ID,
|
|
1268
|
+
schema: {
|
|
1269
|
+
user: {
|
|
1270
|
+
fields: {
|
|
1271
|
+
firstName: { type: "string", required: false },
|
|
1272
|
+
lastName: { type: "string", required: false },
|
|
1273
|
+
phone: { type: "string", required: false }
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
},
|
|
1277
|
+
hooks: {
|
|
1278
|
+
after: [
|
|
1279
|
+
{
|
|
1280
|
+
matcher: (hookCtx) => hookCtx.path === "/sign-out",
|
|
1281
|
+
handler: clearStorefrontOAuthCookieMiddleware
|
|
1282
|
+
}
|
|
1283
|
+
]
|
|
1284
|
+
},
|
|
1285
|
+
endpoints: {
|
|
1286
|
+
signIn: createAuthEndpoint(
|
|
1287
|
+
"/ecomiq-oauth/sign-in",
|
|
1288
|
+
{
|
|
1289
|
+
method: "POST",
|
|
1290
|
+
use: [formCsrfMiddleware],
|
|
1291
|
+
body: signInBody
|
|
1292
|
+
},
|
|
1293
|
+
async (ctx) => {
|
|
1294
|
+
const { email: loginEmail, password, callbackURL, rememberMe } = ctx.body;
|
|
1295
|
+
const tokens = await exchangePasswordGrant(loginEmail, password, {
|
|
1296
|
+
identityScope: ctx.getHeader("x-Identity-Scope"),
|
|
1297
|
+
tenantId: ctx.getHeader("x-Tenant-Id"),
|
|
1298
|
+
storeId: ctx.getHeader("x-Store-Id")
|
|
1299
|
+
});
|
|
1300
|
+
const profile = await fetchUserInfo(tokens.access_token);
|
|
1301
|
+
const profileEmail = profile.email?.toLowerCase().trim();
|
|
1302
|
+
const canonicalEmail = profileEmail ?? loginEmail.toLowerCase().trim();
|
|
1303
|
+
if (profileEmail && profileEmail !== loginEmail.toLowerCase().trim()) {
|
|
1304
|
+
throw APIError.from("UNAUTHORIZED", {
|
|
1305
|
+
code: "ECOMIQ_EMAIL_MISMATCH",
|
|
1306
|
+
message: "El correo del perfil OAuth no coincide con el inicio de sesi\xF3n"
|
|
1307
|
+
});
|
|
1308
|
+
}
|
|
1309
|
+
const displayName = displayNameFromUserInfo(profile, canonicalEmail);
|
|
1310
|
+
const existing = await ctx.context.internalAdapter.findUserByEmail(canonicalEmail);
|
|
1311
|
+
let user = existing?.user;
|
|
1312
|
+
if (!user) {
|
|
1313
|
+
user = await ctx.context.internalAdapter.createUser({
|
|
1314
|
+
email: canonicalEmail,
|
|
1315
|
+
name: displayName,
|
|
1316
|
+
emailVerified: true
|
|
1317
|
+
});
|
|
1318
|
+
} else if (user.name !== displayName) {
|
|
1319
|
+
await ctx.context.internalAdapter.updateUser(user.id, { name: displayName });
|
|
1320
|
+
user = { ...user, name: displayName };
|
|
1321
|
+
}
|
|
1322
|
+
const oauthSessionExpires = tokens.expires_in !== void 0 && tokens.expires_in > 0 ? new Date(Date.now() + tokens.expires_in * 1e3) : void 0;
|
|
1323
|
+
const session = await ctx.context.internalAdapter.createSession(
|
|
1324
|
+
user.id,
|
|
1325
|
+
rememberMe === false,
|
|
1326
|
+
oauthSessionExpires ? { expiresAt: oauthSessionExpires } : {},
|
|
1327
|
+
Boolean(oauthSessionExpires)
|
|
1328
|
+
);
|
|
1329
|
+
if (!session) {
|
|
1330
|
+
throw APIError.from("INTERNAL_SERVER_ERROR", {
|
|
1331
|
+
code: "ECOMIQ_SESSION_FAILED",
|
|
1332
|
+
message: "No se pudo crear la sesi\xF3n"
|
|
1333
|
+
});
|
|
1334
|
+
}
|
|
1335
|
+
await setSessionCookie(ctx, { session, user }, rememberMe === false);
|
|
1336
|
+
const oauthMaxAgeSec = oauthSessionExpires !== void 0 ? Math.max(60, Math.ceil((oauthSessionExpires.getTime() - Date.now()) / 1e3)) : tokens.expires_in !== void 0 && tokens.expires_in > 0 ? tokens.expires_in : 60 * 60 * 24;
|
|
1337
|
+
await ctx.setCookie(STOREFRONT_ECOMIQ_OAUTH_COOKIE_NAME, tokens.access_token, {
|
|
1338
|
+
path: STOREFRONT_ECOMIQ_OAUTH_COOKIE_PATH,
|
|
1339
|
+
httpOnly: true,
|
|
1340
|
+
sameSite: "lax",
|
|
1341
|
+
secure: secureCookie,
|
|
1342
|
+
maxAge: oauthMaxAgeSec
|
|
1343
|
+
});
|
|
1344
|
+
if (callbackURL) ctx.setHeader("Location", callbackURL);
|
|
1345
|
+
return ctx.json({
|
|
1346
|
+
redirect: !!callbackURL,
|
|
1347
|
+
token: session.token,
|
|
1348
|
+
url: callbackURL,
|
|
1349
|
+
user: parseUserOutput(ctx.context.options, user)
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1352
|
+
)
|
|
1353
|
+
}
|
|
1354
|
+
};
|
|
1355
|
+
}
|
|
1356
|
+
function displayNameFromUserInfo(profile, fallbackEmail) {
|
|
1357
|
+
const parts = [profile.given_name?.trim(), profile.family_name?.trim()].filter(Boolean);
|
|
1358
|
+
const joined = parts.join(" ").trim();
|
|
1359
|
+
if (joined) return joined;
|
|
1360
|
+
return fallbackEmail.split("@")[0] || "Cliente";
|
|
1361
|
+
}
|
|
1362
|
+
async function fetchUserInfo(accessToken) {
|
|
1363
|
+
const res = await fetch(ECOMIQ_OAUTH_USERINFO_URL, {
|
|
1364
|
+
method: "GET",
|
|
1365
|
+
headers: {
|
|
1366
|
+
Authorization: `Bearer ${accessToken}`,
|
|
1367
|
+
accept: "application/json"
|
|
1368
|
+
}
|
|
1369
|
+
});
|
|
1370
|
+
const text = await res.text();
|
|
1371
|
+
let json;
|
|
1372
|
+
try {
|
|
1373
|
+
json = text ? JSON.parse(text) : {};
|
|
1374
|
+
} catch {
|
|
1375
|
+
throw APIError.from("UNAUTHORIZED", {
|
|
1376
|
+
code: "ECOMIQ_USERINFO_INVALID_BODY",
|
|
1377
|
+
message: "Respuesta inv\xE1lida del endpoint userinfo"
|
|
1378
|
+
});
|
|
1379
|
+
}
|
|
1380
|
+
if (!res.ok) {
|
|
1381
|
+
const err = json;
|
|
1382
|
+
throw APIError.from("UNAUTHORIZED", {
|
|
1383
|
+
code: "ECOMIQ_USERINFO_REJECTED",
|
|
1384
|
+
message: err.error_description ?? err.error ?? "No se pudo obtener el perfil del usuario"
|
|
1385
|
+
});
|
|
1386
|
+
}
|
|
1387
|
+
const parsed = userInfoSchema.safeParse(json);
|
|
1388
|
+
if (!parsed.success) {
|
|
1389
|
+
throw APIError.from("UNAUTHORIZED", {
|
|
1390
|
+
code: "ECOMIQ_USERINFO_SHAPE",
|
|
1391
|
+
message: "Perfil OAuth con formato inv\xE1lido"
|
|
1392
|
+
});
|
|
1393
|
+
}
|
|
1394
|
+
return parsed.data;
|
|
1395
|
+
}
|
|
1396
|
+
async function exchangePasswordGrant(username, password, context) {
|
|
1397
|
+
const clientId = process.env.ECOMIQ_AUTH_CLIENT_ID ?? "";
|
|
1398
|
+
const clientSecret = process.env.ECOMIQ_AUTH_CLIENT_SECRET ?? "";
|
|
1399
|
+
const scope = process.env.ECOMIQ_AUTH_SCOPE ?? "";
|
|
1400
|
+
if (!clientId || !clientSecret) {
|
|
1401
|
+
throw APIError.from("INTERNAL_SERVER_ERROR", {
|
|
1402
|
+
code: "ECOMIQ_AUTH_NOT_CONFIGURED",
|
|
1403
|
+
message: "OAuth Ecomiq no configurado: ECOMIQ_AUTH_CLIENT_ID y ECOMIQ_AUTH_CLIENT_SECRET."
|
|
1404
|
+
});
|
|
1405
|
+
}
|
|
1406
|
+
const body = new URLSearchParams({
|
|
1407
|
+
grant_type: "password",
|
|
1408
|
+
username,
|
|
1409
|
+
password,
|
|
1410
|
+
scope,
|
|
1411
|
+
client_id: clientId,
|
|
1412
|
+
client_secret: clientSecret
|
|
1413
|
+
});
|
|
1414
|
+
const identityScope = context.identityScope;
|
|
1415
|
+
const tenantId = context.tenantId;
|
|
1416
|
+
const storeId = context.storeId;
|
|
1417
|
+
const headers = new Headers({
|
|
1418
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
1419
|
+
accept: "application/json"
|
|
1420
|
+
});
|
|
1421
|
+
if (identityScope?.trim()) {
|
|
1422
|
+
headers.set("x-Identity-Scope", identityScope.trim());
|
|
1423
|
+
}
|
|
1424
|
+
if (tenantId?.trim()) {
|
|
1425
|
+
headers.set("x-Tenant-Id", tenantId.trim());
|
|
1426
|
+
}
|
|
1427
|
+
if (storeId?.trim()) {
|
|
1428
|
+
headers.set("x-Store-Id", storeId.trim());
|
|
1429
|
+
}
|
|
1430
|
+
let res;
|
|
1431
|
+
let text;
|
|
1432
|
+
try {
|
|
1433
|
+
res = await fetch(ECOMIQ_OAUTH_TOKEN_URL, {
|
|
1434
|
+
method: "POST",
|
|
1435
|
+
headers,
|
|
1436
|
+
body
|
|
1437
|
+
});
|
|
1438
|
+
text = await res.text();
|
|
1439
|
+
} catch (e) {
|
|
1440
|
+
throw mapTokenEndpointFetchFailure(e);
|
|
1441
|
+
}
|
|
1442
|
+
const json = safeParseJson(text);
|
|
1443
|
+
if (!res.ok) {
|
|
1444
|
+
throwBadRequestFromOAuth(json, res.statusText || text || `HTTP ${res.status}`);
|
|
1445
|
+
}
|
|
1446
|
+
const parsed = tokenResponseSchema.safeParse(json);
|
|
1447
|
+
if (!parsed.success) {
|
|
1448
|
+
throwBadRequestFromOAuth(json, "Token de acceso no recibido");
|
|
1449
|
+
}
|
|
1450
|
+
return parsed.data;
|
|
1451
|
+
}
|
|
1452
|
+
function safeParseJson(text) {
|
|
1453
|
+
try {
|
|
1454
|
+
return text ? JSON.parse(text) : {};
|
|
1455
|
+
} catch {
|
|
1456
|
+
return {};
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
function throwBadRequestFromOAuth(payload, fallbackMessage) {
|
|
1460
|
+
const err = payload;
|
|
1461
|
+
const errorCode = typeof err.error === "string" && err.error.trim() ? err.error.trim() : "invalid_grant";
|
|
1462
|
+
const errorMessage = typeof err.error_description === "string" && err.error_description.trim() ? err.error_description.trim() : typeof err.error === "string" && err.error.trim() ? err.error.trim() : fallbackMessage.trim() || "Credenciales invalidas.";
|
|
1463
|
+
throw APIError.from("BAD_REQUEST", {
|
|
1464
|
+
code: errorCode,
|
|
1465
|
+
message: errorMessage.slice(0, 500)
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
function mapTokenEndpointFetchFailure(e) {
|
|
1469
|
+
const codes = collectNetworkErrorCodes(e);
|
|
1470
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
1471
|
+
const isDnsError = codes.some((c) => c === "ENOTFOUND" || c === "EAI_AGAIN");
|
|
1472
|
+
if (isDnsError) {
|
|
1473
|
+
throw APIError.from("BAD_GATEWAY", {
|
|
1474
|
+
code: "ECOMIQ_AUTH_DNS",
|
|
1475
|
+
message: "No se pudo resolver el servidor de autenticacion."
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
const isConnectionRefused = codes.includes("ECONNREFUSED");
|
|
1479
|
+
if (isConnectionRefused) {
|
|
1480
|
+
throw APIError.from("BAD_GATEWAY", {
|
|
1481
|
+
code: "ECOMIQ_AUTH_REFUSED",
|
|
1482
|
+
message: "Conexion rechazada al servidor de autenticacion."
|
|
1483
|
+
});
|
|
1484
|
+
}
|
|
1485
|
+
const looksLikeAbortOrSocketClose = codes.some(
|
|
1486
|
+
(c) => ["UND_ERR_SOCKET", "ECONNRESET", "EPIPE", "ECONNABORTED"].includes(c)
|
|
1487
|
+
) || /terminated|abort|closed|FIN|socket/i.test(msg);
|
|
1488
|
+
if (looksLikeAbortOrSocketClose) {
|
|
1489
|
+
throwBadRequestFromOAuth({}, "Credenciales invalidas o conexion cerrada por el servidor.");
|
|
1490
|
+
}
|
|
1491
|
+
throw APIError.from("INTERNAL_SERVER_ERROR", {
|
|
1492
|
+
code: "ECOMIQ_AUTH_REQUEST_FAILED",
|
|
1493
|
+
message: msg.slice(0, 280) || "Error al contactar el servidor de autenticacion."
|
|
1494
|
+
});
|
|
1495
|
+
}
|
|
1496
|
+
function collectNetworkErrorCodes(e) {
|
|
1497
|
+
const out = [];
|
|
1498
|
+
const visit = (x) => {
|
|
1499
|
+
if (!x || typeof x !== "object") return;
|
|
1500
|
+
const code = "code" in x && typeof x.code === "string" ? x.code : void 0;
|
|
1501
|
+
if (code) out.push(code);
|
|
1502
|
+
if ("cause" in x && x.cause) {
|
|
1503
|
+
visit(x.cause);
|
|
1504
|
+
}
|
|
1505
|
+
};
|
|
1506
|
+
visit(e);
|
|
1507
|
+
return out;
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
// src/react/shell/lib/find-storefront-cms-page.ts
|
|
1511
|
+
function isRenderableCmsPage(p) {
|
|
1512
|
+
if (!p.status) return true;
|
|
1513
|
+
return p.status === "published";
|
|
1514
|
+
}
|
|
1515
|
+
function findStorefrontCmsPageBySlug(settings, slug) {
|
|
1516
|
+
const pages = settings?.cms?.pages;
|
|
1517
|
+
if (!pages?.length) return null;
|
|
1518
|
+
const raw = pages.find(
|
|
1519
|
+
(p) => p.slug === slug && isRenderableCmsPage(p)
|
|
1520
|
+
);
|
|
1521
|
+
if (!raw) return null;
|
|
1522
|
+
const parsed = StorefrontPageDetailSchema.safeParse(raw);
|
|
1523
|
+
return parsed.success ? parsed.data : null;
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
// src/core/constants/currency.ts
|
|
1527
|
+
var countryCurrency = {
|
|
1528
|
+
"PEN": "es-PE",
|
|
1529
|
+
"USD": "en-US",
|
|
1530
|
+
"COP": "es-CO",
|
|
1531
|
+
"MXN": "es-MX"
|
|
1532
|
+
};
|
|
1533
|
+
|
|
1534
|
+
// src/core/utils/format-currency.ts
|
|
1535
|
+
function formatCurrency(amount, currency = "USD") {
|
|
1536
|
+
const locale = countryCurrency[currency] ?? "en-US";
|
|
1537
|
+
return new Intl.NumberFormat(locale, {
|
|
1538
|
+
style: "currency",
|
|
1539
|
+
currency
|
|
1540
|
+
}).format(amount);
|
|
1541
|
+
}
|
|
1542
|
+
var ApiClient = class {
|
|
1543
|
+
client;
|
|
1544
|
+
storeId;
|
|
1545
|
+
storeDomain;
|
|
1546
|
+
constructor(baseURL = "https://storefront.ecomiq.pe") {
|
|
1547
|
+
this.client = axios.create({
|
|
1548
|
+
baseURL,
|
|
1549
|
+
timeout: 1e4,
|
|
1550
|
+
headers: {
|
|
1551
|
+
"Content-Type": "application/json"
|
|
1552
|
+
}
|
|
1553
|
+
});
|
|
1554
|
+
this.client.interceptors.request.use(
|
|
1555
|
+
(config) => {
|
|
1556
|
+
if (config.headers) {
|
|
1557
|
+
if (this.storeId) config.headers["X-Store-Id"] = this.storeId;
|
|
1558
|
+
if (this.storeDomain) config.headers["X-Store-Domain"] = this.storeDomain;
|
|
1559
|
+
}
|
|
1560
|
+
return config;
|
|
1561
|
+
}
|
|
1562
|
+
);
|
|
1563
|
+
this.client.interceptors.response.use(
|
|
1564
|
+
(response) => response,
|
|
1565
|
+
(error) => {
|
|
1566
|
+
console.error("API Error:", error);
|
|
1567
|
+
return Promise.reject(error);
|
|
1568
|
+
}
|
|
1569
|
+
);
|
|
1570
|
+
}
|
|
1571
|
+
setStoreId(storeId) {
|
|
1572
|
+
this.storeId = storeId;
|
|
1573
|
+
}
|
|
1574
|
+
/** Subdominio para endpoints que usan X-Store-Domain (ej. GET /v1/storefront/settings) */
|
|
1575
|
+
setStoreDomain(domain) {
|
|
1576
|
+
this.storeDomain = domain;
|
|
1577
|
+
}
|
|
1578
|
+
get(url, config) {
|
|
1579
|
+
return this.client.get(url, config).then((response) => response.data);
|
|
1580
|
+
}
|
|
1581
|
+
post(url, data, config) {
|
|
1582
|
+
return this.client.post(url, data, config).then((response) => response.data);
|
|
1583
|
+
}
|
|
1584
|
+
put(url, data, config) {
|
|
1585
|
+
return this.client.put(url, data, config).then((response) => response.data);
|
|
1586
|
+
}
|
|
1587
|
+
patch(url, data, config) {
|
|
1588
|
+
return this.client.patch(url, data, config).then((response) => response.data);
|
|
1589
|
+
}
|
|
1590
|
+
delete(url, config) {
|
|
1591
|
+
return this.client.delete(url, config).then((response) => response.data);
|
|
1592
|
+
}
|
|
1593
|
+
};
|
|
1594
|
+
new ApiClient();
|
|
1595
|
+
|
|
1596
|
+
export { CustomerAddressSchema, CustomerAddressUpsertSchema, CustomerMeSchema, CustomerOrderDetailSchema, CustomerOrderListItemSchema, CustomerProfilePatchSchema, CustomerRegisterRequestSchema, StoreApiClient, StorefrontProductSchema, StorefrontProductsResponseSchema, addCartCoupon, applyServerRequestOriginFromHeaders, checkoutCart, createCart, createCustomerAddress, createStoreApiClient, customerMeToProfilePatch, deleteCustomerAddress, ecomiqOAuthPassword, fetchPublicStoreSettings, findStorefrontCmsPageBySlug, formatCurrency, getCart, getCartCheckout, getCartPaymentMethods, getCustomerAddresses, getCustomerMe, getCustomerOrder, getCustomerOrders, getSharedOrderDraft, getShippingOptions, getStoreApiBaseUrl, getStoreApiClient, getStorefrontCollectionBySlug, getStorefrontCollections, getStorefrontPageBySlug, getStorefrontPagePreview, getStorefrontPages, getStorefrontProductBySlug, getStorefrontProducts, getStorefrontSettings, isCartNotActiveApiError, normalizeRequestHostname, patchCartAddresses, patchCartBuyer, patchCustomer, putCartShippingMethod, registerCustomer, removeCartCoupon, resolvePublicStoreSettingsSource, setClientStoreId, setServerRequestOrigin, setServerStoreId, storeApiClient, updateCustomerAddress, uploadPaymentReceipt };
|
|
1597
|
+
//# sourceMappingURL=chunk-PDK2VYWD.js.map
|
|
1598
|
+
//# sourceMappingURL=chunk-PDK2VYWD.js.map
|