@ecomiq/storefront 1.1.5 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/{chunk-QRR7EPCH.js → chunk-AKD5IDEB.js} +4 -3
- package/dist/chunk-AKD5IDEB.js.map +1 -0
- package/dist/{chunk-ZG2XUYGZ.js → chunk-EFEVJJWF.js} +85 -21
- package/dist/chunk-EFEVJJWF.js.map +1 -0
- package/dist/{chunk-3QGB55R6.js → chunk-NAJQB5DN.js} +4 -6
- package/dist/chunk-NAJQB5DN.js.map +1 -0
- package/dist/{chunk-ASFU32ZM.js → chunk-OABDGTBI.js} +25 -8
- package/dist/chunk-OABDGTBI.js.map +1 -0
- package/dist/chunks/client.d.ts +850 -132
- package/dist/chunks/client.js +47 -12
- package/dist/chunks/client.js.map +1 -1
- package/dist/chunks/config.js +1 -1
- package/dist/chunks/core-public.d.ts +2 -2
- package/dist/chunks/core-public.js +2 -2
- package/dist/chunks/server-nextjs.d.ts +3 -3
- package/dist/chunks/server-nextjs.js +17 -5
- package/dist/chunks/server-nextjs.js.map +1 -1
- package/dist/chunks/server-tanstack.d.ts +3 -3
- package/dist/chunks/server-tanstack.js +13 -7
- package/dist/chunks/server-tanstack.js.map +1 -1
- package/dist/{collection-C6bWDLiw.d.ts → collection-DU7gREXS.d.ts} +174 -38
- package/dist/{ecomiq-oauth-password-plugin-J5wDFqzL.d.ts → ecomiq-oauth-password-plugin-B_gMdGuc.d.ts} +32 -30
- package/dist/nextjs/api.js +1 -1
- package/dist/nextjs.server.d.ts +17 -0
- package/dist/tanstack/api.js +2 -2
- package/dist/tanstack.d.ts +0 -1
- package/dist/tanstack.server.d.ts +17 -0
- package/package.json +12 -2
- package/dist/chunk-3QGB55R6.js.map +0 -1
- package/dist/chunk-ASFU32ZM.js.map +0 -1
- package/dist/chunk-QRR7EPCH.js.map +0 -1
- package/dist/chunk-ZG2XUYGZ.js.map +0 -1
package/dist/chunks/client.js
CHANGED
|
@@ -78,7 +78,6 @@ var StoreApiClient = class {
|
|
|
78
78
|
if (!isFormData) {
|
|
79
79
|
headers.set("Content-Type", "application/json");
|
|
80
80
|
}
|
|
81
|
-
headers.set("Accept-Encoding", "identity");
|
|
82
81
|
const explicitStoreId = options?.xStoreId?.trim();
|
|
83
82
|
const runtimeStoreId = explicitStoreId || (typeof window === "undefined" ? serverStoreIdGetter : clientStoreIdGetter);
|
|
84
83
|
if (runtimeStoreId && !headers.has(STOREFRONT_HEADERS.storeIdLower)) {
|
|
@@ -258,7 +257,19 @@ var StorefrontProductSchema = z.object({
|
|
|
258
257
|
});
|
|
259
258
|
var StorefrontFacetSchema = z.object({
|
|
260
259
|
value: z.string(),
|
|
261
|
-
count: z.number().int().nonnegative()
|
|
260
|
+
count: z.number().int().nonnegative(),
|
|
261
|
+
label: z.string().optional().nullable(),
|
|
262
|
+
selected: z.boolean().optional().default(false)
|
|
263
|
+
});
|
|
264
|
+
var StorefrontSearchFilterSchema = z.object({
|
|
265
|
+
id: z.string(),
|
|
266
|
+
label: z.string(),
|
|
267
|
+
type: z.string(),
|
|
268
|
+
values: z.array(StorefrontFacetSchema).optional().default([]),
|
|
269
|
+
min: z.number().nonnegative().optional().nullable(),
|
|
270
|
+
max: z.number().nonnegative().optional().nullable(),
|
|
271
|
+
selectedMin: z.number().nonnegative().optional().nullable(),
|
|
272
|
+
selectedMax: z.number().nonnegative().optional().nullable()
|
|
262
273
|
});
|
|
263
274
|
var StorefrontProductsResponseSchema = z.object({
|
|
264
275
|
pageIndex: z.number().int().positive(),
|
|
@@ -266,10 +277,7 @@ var StorefrontProductsResponseSchema = z.object({
|
|
|
266
277
|
totalCount: z.number().int().nonnegative(),
|
|
267
278
|
totalPages: z.number().int().nonnegative(),
|
|
268
279
|
products: z.array(StorefrontProductSchema),
|
|
269
|
-
|
|
270
|
-
brands: z.array(StorefrontFacetSchema).optional().default([]),
|
|
271
|
-
minPrice: z.number().nonnegative().optional().nullable(),
|
|
272
|
-
maxPrice: z.number().nonnegative().optional().nullable()
|
|
280
|
+
filters: z.array(StorefrontSearchFilterSchema).optional().default([])
|
|
273
281
|
});
|
|
274
282
|
var StorefrontProductsParamsSchema = z.object({
|
|
275
283
|
page: z.number().int().positive().optional().default(1),
|
|
@@ -278,9 +286,17 @@ var StorefrontProductsParamsSchema = z.object({
|
|
|
278
286
|
sellerId: z.string().optional(),
|
|
279
287
|
search: z.string().optional(),
|
|
280
288
|
collection: z.string().optional(),
|
|
289
|
+
collections: z.array(z.string()).optional(),
|
|
281
290
|
category: z.string().optional(),
|
|
291
|
+
categories: z.array(z.string()).optional(),
|
|
282
292
|
brand: z.string().optional(),
|
|
293
|
+
brands: z.array(z.string()).optional(),
|
|
283
294
|
productType: z.string().optional(),
|
|
295
|
+
productTypes: z.array(z.string()).optional(),
|
|
296
|
+
tag: z.string().optional(),
|
|
297
|
+
tags: z.array(z.string()).optional(),
|
|
298
|
+
filters: z.array(z.string()).optional(),
|
|
299
|
+
locationId: z.string().optional(),
|
|
284
300
|
inStock: z.boolean().optional(),
|
|
285
301
|
minPrice: z.number().nonnegative().optional(),
|
|
286
302
|
maxPrice: z.number().nonnegative().optional()
|
|
@@ -359,9 +375,17 @@ async function getStorefrontProducts(params, cacheKey) {
|
|
|
359
375
|
if (parsed.sellerId) searchParams.set("sellerId", parsed.sellerId);
|
|
360
376
|
if (parsed.search) searchParams.set("search", parsed.search);
|
|
361
377
|
if (parsed.collection) searchParams.set("collection", parsed.collection);
|
|
378
|
+
appendValues(searchParams, "collections", parsed.collections);
|
|
362
379
|
if (parsed.category) searchParams.set("category", parsed.category);
|
|
380
|
+
appendValues(searchParams, "categories", parsed.categories);
|
|
363
381
|
if (parsed.brand) searchParams.set("brand", parsed.brand);
|
|
382
|
+
appendValues(searchParams, "brands", parsed.brands);
|
|
364
383
|
if (parsed.productType) searchParams.set("productType", parsed.productType);
|
|
384
|
+
appendValues(searchParams, "productTypes", parsed.productTypes);
|
|
385
|
+
if (parsed.tag) searchParams.set("tag", parsed.tag);
|
|
386
|
+
appendValues(searchParams, "tags", parsed.tags);
|
|
387
|
+
appendValues(searchParams, "filters", parsed.filters);
|
|
388
|
+
if (parsed.locationId) searchParams.set("locationId", parsed.locationId);
|
|
365
389
|
if (parsed.inStock != null) searchParams.set("inStock", String(parsed.inStock));
|
|
366
390
|
if (parsed.minPrice != null) searchParams.set("minPrice", String(parsed.minPrice));
|
|
367
391
|
if (parsed.maxPrice != null) searchParams.set("maxPrice", String(parsed.maxPrice));
|
|
@@ -369,16 +393,24 @@ async function getStorefrontProducts(params, cacheKey) {
|
|
|
369
393
|
const client = await getStoreApiClient();
|
|
370
394
|
const response = await client.get(path, {
|
|
371
395
|
cacheKey,
|
|
372
|
-
noStore:
|
|
396
|
+
noStore: !cacheKey
|
|
373
397
|
});
|
|
374
398
|
return StorefrontProductsResponseSchema.parse(response);
|
|
375
399
|
}
|
|
376
|
-
async function getStorefrontProductBySlug(slug) {
|
|
400
|
+
async function getStorefrontProductBySlug(slug, options) {
|
|
377
401
|
const path = `products/${encodeURIComponent(slug)}`;
|
|
378
402
|
const client = await getStoreApiClient();
|
|
379
|
-
const response = await client.get(path, {
|
|
403
|
+
const response = await client.get(path, {
|
|
404
|
+
cacheKey: options?.cacheKey,
|
|
405
|
+
noStore: !options?.cacheKey
|
|
406
|
+
});
|
|
380
407
|
return StorefrontProductDetailSchema.parse(response);
|
|
381
408
|
}
|
|
409
|
+
function appendValues(searchParams, key, values) {
|
|
410
|
+
for (const value of values ?? []) {
|
|
411
|
+
if (value) searchParams.append(key, value);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
382
414
|
var StorefrontCollectionSchema = z.object({
|
|
383
415
|
id: z.coerce.string(),
|
|
384
416
|
slug: z.string(),
|
|
@@ -1308,7 +1340,8 @@ function useStoreProducts() {
|
|
|
1308
1340
|
return useQuery({
|
|
1309
1341
|
queryKey: ["storefront", "products", params],
|
|
1310
1342
|
queryFn: () => getStorefrontProducts(params),
|
|
1311
|
-
staleTime:
|
|
1343
|
+
staleTime: 6e4,
|
|
1344
|
+
gcTime: 5 * 6e4
|
|
1312
1345
|
});
|
|
1313
1346
|
};
|
|
1314
1347
|
const useStorefrontInfiniteProducts = (params) => {
|
|
@@ -1317,7 +1350,8 @@ function useStoreProducts() {
|
|
|
1317
1350
|
queryFn: ({ pageParam = 1 }) => getStorefrontProducts({ ...params, page: pageParam }),
|
|
1318
1351
|
getNextPageParam: (lastPage) => lastPage.pageIndex < lastPage.totalPages ? lastPage.pageIndex + 1 : void 0,
|
|
1319
1352
|
initialPageParam: 1,
|
|
1320
|
-
staleTime:
|
|
1353
|
+
staleTime: 6e4,
|
|
1354
|
+
gcTime: 5 * 6e4
|
|
1321
1355
|
});
|
|
1322
1356
|
};
|
|
1323
1357
|
const useProductBySlug = (slug) => {
|
|
@@ -1325,7 +1359,8 @@ function useStoreProducts() {
|
|
|
1325
1359
|
queryKey: ["storefront", "product", "slug", slug],
|
|
1326
1360
|
queryFn: () => getStorefrontProductBySlug(slug),
|
|
1327
1361
|
enabled: !!slug,
|
|
1328
|
-
staleTime:
|
|
1362
|
+
staleTime: 5 * 6e4,
|
|
1363
|
+
gcTime: 10 * 6e4
|
|
1329
1364
|
});
|
|
1330
1365
|
};
|
|
1331
1366
|
const useRefreshStorefrontProducts = () => {
|