@asteby/storefront 0.22.1 → 0.24.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/dist/{account-settings-DZGcveuu.d.cts → account-settings-BZKux56f.d.cts} +48 -1
- package/dist/{account-settings-CwEnn5sR.d.ts → account-settings-CrQV1rPU.d.ts} +48 -1
- package/dist/cli.js +17 -1
- package/dist/fiscal-document.d.cts +2 -2
- package/dist/fiscal-document.d.ts +2 -2
- package/dist/index.cjs +16 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -3
- package/dist/index.d.ts +27 -3
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/mock.cjs +12 -0
- package/dist/mock.cjs.map +1 -1
- package/dist/mock.d.cts +7 -1
- package/dist/mock.d.ts +7 -1
- package/dist/mock.js +12 -0
- package/dist/mock.js.map +1 -1
- package/dist/mockup.d.cts +1 -1
- package/dist/mockup.d.ts +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.js +1 -1
- package/package.json +1 -1
package/dist/mock.cjs
CHANGED
|
@@ -2369,6 +2369,18 @@ function createMockStorefront(options = {}) {
|
|
|
2369
2369
|
if (!region) throw new HttpError(404, "not_found", "No region configured");
|
|
2370
2370
|
return { body: region, cache: "public" };
|
|
2371
2371
|
});
|
|
2372
|
+
route("GET", "/address/suggest", "catalog:read", ({ search }) => {
|
|
2373
|
+
const q = (search.get("q") ?? "").trim().replace(/\s+/g, " ");
|
|
2374
|
+
if ([...q].length < 3) throw new HttpError(400, "validation", "q needs at least 3 characters", "q");
|
|
2375
|
+
const pool = options.addressSuggestions;
|
|
2376
|
+
if (!pool) return { body: { suggestions: [], available: false }, cache: "private" };
|
|
2377
|
+
const fold = (v) => v.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
|
|
2378
|
+
const country = search.get("country")?.toUpperCase();
|
|
2379
|
+
const zip = search.get("zip")?.trim();
|
|
2380
|
+
const limit = Math.min(Math.max(Number(search.get("limit")) || 5, 1), 8);
|
|
2381
|
+
const hits = pool.filter((p) => fold(p.label).includes(fold(q)) && (!country || p.country === country) && (!zip || !p.zip || p.zip === zip));
|
|
2382
|
+
return { body: { suggestions: hits.slice(0, limit), available: true }, cache: "private" };
|
|
2383
|
+
});
|
|
2372
2384
|
route("GET", "/products", "catalog:read", ({ search }) => ({ body: listProducts(search), cache: "public" }));
|
|
2373
2385
|
route("GET", "/products/:handle", "catalog:read", ({ params }) => ({
|
|
2374
2386
|
body: requireNode(state.products.find((p) => p.handle === params[0]), `Product ${params[0]}`),
|