@asteby/storefront 0.22.1 → 0.23.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-BdKj3jWb.d.cts} +31 -1
- package/dist/{account-settings-CwEnn5sR.d.ts → account-settings-DHg2RUOH.d.ts} +31 -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.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bU as SubjectKind, ac as IdentityRulesV1, bo as RegionFiscalId, aa as IdentityDocumentSpec, bm as Region, bF as Shop, b7 as Product, B as Collection, bX as Theme, aO as Page, aw as Menu, e as Article, C as Cart, a as Address, am as InvoiceRequest, E as Customer, a5 as FiscalProfile, bO as Subject, aD as Order, aR as PaymentAttemptResult, b4 as PendingPayment, ao as InvoiceStage, F as CustomerCapabilities, be as PromotionAnnouncement, bE as ShippingRate, aY as PaymentMethod, c as AddressSuggestion } from './account-settings-BdKj3jWb.cjs';
|
|
2
2
|
import './geo.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -103,6 +103,12 @@ type MockStorefrontOptions = {
|
|
|
103
103
|
* organization has no region, the route answers `404` and invoice requests are not validated against a region.
|
|
104
104
|
*/
|
|
105
105
|
region?: Region | null;
|
|
106
|
+
/**
|
|
107
|
+
* What `GET /storefront/address/suggest` can answer (matched by `label` containing the typed text). Default: none, so
|
|
108
|
+
* the route answers `{ suggestions: [], available: false }` like a market without a suggestion provider and address
|
|
109
|
+
* forms stay manual.
|
|
110
|
+
*/
|
|
111
|
+
addressSuggestions?: AddressSuggestion[];
|
|
106
112
|
/**
|
|
107
113
|
* The kinds of buyer item («My items») the store declares, served by `GET /subject-kinds` and enforced by
|
|
108
114
|
* `customer.subjects`. Default none: no such section, as in a store that declares nothing (`MOCK_SUBJECT_KINDS` has two).
|
package/dist/mock.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bU as SubjectKind, ac as IdentityRulesV1, bo as RegionFiscalId, aa as IdentityDocumentSpec, bm as Region, bF as Shop, b7 as Product, B as Collection, bX as Theme, aO as Page, aw as Menu, e as Article, C as Cart, a as Address, am as InvoiceRequest, E as Customer, a5 as FiscalProfile, bO as Subject, aD as Order, aR as PaymentAttemptResult, b4 as PendingPayment, ao as InvoiceStage, F as CustomerCapabilities, be as PromotionAnnouncement, bE as ShippingRate, aY as PaymentMethod, c as AddressSuggestion } from './account-settings-DHg2RUOH.js';
|
|
2
2
|
import './geo.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -103,6 +103,12 @@ type MockStorefrontOptions = {
|
|
|
103
103
|
* organization has no region, the route answers `404` and invoice requests are not validated against a region.
|
|
104
104
|
*/
|
|
105
105
|
region?: Region | null;
|
|
106
|
+
/**
|
|
107
|
+
* What `GET /storefront/address/suggest` can answer (matched by `label` containing the typed text). Default: none, so
|
|
108
|
+
* the route answers `{ suggestions: [], available: false }` like a market without a suggestion provider and address
|
|
109
|
+
* forms stay manual.
|
|
110
|
+
*/
|
|
111
|
+
addressSuggestions?: AddressSuggestion[];
|
|
106
112
|
/**
|
|
107
113
|
* The kinds of buyer item («My items») the store declares, served by `GET /subject-kinds` and enforced by
|
|
108
114
|
* `customer.subjects`. Default none: no such section, as in a store that declares nothing (`MOCK_SUBJECT_KINDS` has two).
|
package/dist/mock.js
CHANGED
|
@@ -2092,6 +2092,18 @@ function createMockStorefront(options = {}) {
|
|
|
2092
2092
|
if (!region) throw new HttpError(404, "not_found", "No region configured");
|
|
2093
2093
|
return { body: region, cache: "public" };
|
|
2094
2094
|
});
|
|
2095
|
+
route("GET", "/address/suggest", "catalog:read", ({ search }) => {
|
|
2096
|
+
const q = (search.get("q") ?? "").trim().replace(/\s+/g, " ");
|
|
2097
|
+
if ([...q].length < 3) throw new HttpError(400, "validation", "q needs at least 3 characters", "q");
|
|
2098
|
+
const pool = options.addressSuggestions;
|
|
2099
|
+
if (!pool) return { body: { suggestions: [], available: false }, cache: "private" };
|
|
2100
|
+
const fold = (v) => v.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
|
|
2101
|
+
const country = search.get("country")?.toUpperCase();
|
|
2102
|
+
const zip = search.get("zip")?.trim();
|
|
2103
|
+
const limit = Math.min(Math.max(Number(search.get("limit")) || 5, 1), 8);
|
|
2104
|
+
const hits = pool.filter((p) => fold(p.label).includes(fold(q)) && (!country || p.country === country) && (!zip || !p.zip || p.zip === zip));
|
|
2105
|
+
return { body: { suggestions: hits.slice(0, limit), available: true }, cache: "private" };
|
|
2106
|
+
});
|
|
2095
2107
|
route("GET", "/products", "catalog:read", ({ search }) => ({ body: listProducts(search), cache: "public" }));
|
|
2096
2108
|
route("GET", "/products/:handle", "catalog:read", ({ params }) => ({
|
|
2097
2109
|
body: requireNode(state.products.find((p) => p.handle === params[0]), `Product ${params[0]}`),
|