@sixtyninecommerce/client 0.24.0 → 0.25.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/README.md +21 -0
- package/dist/admin/forms.js +19 -0
- package/dist/admin/forms.js.map +1 -1
- package/dist/admin/http.d.ts +9 -0
- package/dist/admin/http.d.ts.map +1 -1
- package/dist/admin/http.js +3 -0
- package/dist/admin/http.js.map +1 -1
- package/dist/admin/index.d.ts +63 -0
- package/dist/admin/index.d.ts.map +1 -1
- package/dist/admin/index.js +67 -0
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/redirects.d.ts +6 -0
- package/dist/admin/redirects.d.ts.map +1 -1
- package/dist/admin/redirects.js +12 -0
- package/dist/admin/redirects.js.map +1 -1
- package/dist/admin/types.d.ts +63 -0
- package/dist/admin/types.d.ts.map +1 -1
- package/dist/cache-tags.d.ts +19 -0
- package/dist/cache-tags.d.ts.map +1 -1
- package/dist/cache-tags.js +19 -0
- package/dist/cache-tags.js.map +1 -1
- package/dist/client.d.ts +17 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +17 -0
- package/dist/client.js.map +1 -1
- package/dist/commerce/age-verification.js +3 -3
- package/dist/commerce/age-verification.js.map +1 -1
- package/dist/commerce/branding.js +7 -0
- package/dist/commerce/branding.js.map +1 -1
- package/dist/commerce/cart.js +25 -0
- package/dist/commerce/cart.js.map +1 -1
- package/dist/commerce/checkout.d.ts +68 -0
- package/dist/commerce/checkout.d.ts.map +1 -1
- package/dist/commerce/checkout.js +83 -0
- package/dist/commerce/checkout.js.map +1 -1
- package/dist/commerce/customer.d.ts +58 -0
- package/dist/commerce/customer.d.ts.map +1 -1
- package/dist/commerce/customer.js +65 -0
- package/dist/commerce/customer.js.map +1 -1
- package/dist/commerce/pickup-location-parser.d.ts +18 -0
- package/dist/commerce/pickup-location-parser.d.ts.map +1 -1
- package/dist/commerce/pickup-location-parser.js +28 -0
- package/dist/commerce/pickup-location-parser.js.map +1 -1
- package/dist/commerce/placement-error.d.ts +52 -0
- package/dist/commerce/placement-error.d.ts.map +1 -1
- package/dist/commerce/placement-error.js +87 -0
- package/dist/commerce/placement-error.js.map +1 -1
- package/dist/commerce/products.d.ts +48 -0
- package/dist/commerce/products.d.ts.map +1 -1
- package/dist/commerce/products.js +92 -0
- package/dist/commerce/products.js.map +1 -1
- package/dist/commerce/queries.d.ts +113 -27
- package/dist/commerce/queries.d.ts.map +1 -1
- package/dist/commerce/queries.js +188 -2
- package/dist/commerce/queries.js.map +1 -1
- package/dist/commerce/quotes.js +33 -0
- package/dist/commerce/quotes.js.map +1 -1
- package/dist/commerce/saved-lists.d.ts +7 -7
- package/dist/commerce/saved-lists.d.ts.map +1 -1
- package/dist/commerce/saved-lists.js +1 -1
- package/dist/commerce/search.js +3 -0
- package/dist/commerce/search.js.map +1 -1
- package/dist/commerce/shipping.js +3 -3
- package/dist/commerce/shipping.js.map +1 -1
- package/dist/commerce/stock-notifications.d.ts +11 -0
- package/dist/commerce/stock-notifications.d.ts.map +1 -1
- package/dist/commerce/stock-notifications.js +11 -0
- package/dist/commerce/stock-notifications.js.map +1 -1
- package/dist/commerce/vat-validation.js +4 -4
- package/dist/commerce/vat-validation.js.map +1 -1
- package/dist/constants.d.ts +31 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +32 -0
- package/dist/constants.js.map +1 -1
- package/dist/content/asset-urls.d.ts +50 -0
- package/dist/content/asset-urls.d.ts.map +1 -1
- package/dist/content/asset-urls.js +92 -0
- package/dist/content/asset-urls.js.map +1 -1
- package/dist/content/assets.d.ts +15 -0
- package/dist/content/assets.d.ts.map +1 -1
- package/dist/content/assets.js +15 -0
- package/dist/content/assets.js.map +1 -1
- package/dist/content/collection-pages.d.ts +5 -0
- package/dist/content/collection-pages.d.ts.map +1 -1
- package/dist/content/collection-pages.js +8 -0
- package/dist/content/collection-pages.js.map +1 -1
- package/dist/content/collections.d.ts +14 -0
- package/dist/content/collections.d.ts.map +1 -1
- package/dist/content/collections.js +16 -0
- package/dist/content/collections.js.map +1 -1
- package/dist/content/filtered-products.d.ts +18 -0
- package/dist/content/filtered-products.d.ts.map +1 -1
- package/dist/content/filtered-products.js +16 -0
- package/dist/content/filtered-products.js.map +1 -1
- package/dist/content/form-field-types.d.ts +6 -0
- package/dist/content/form-field-types.d.ts.map +1 -1
- package/dist/content/form-field-types.js +12 -0
- package/dist/content/form-field-types.js.map +1 -1
- package/dist/content/forms.d.ts +16 -0
- package/dist/content/forms.d.ts.map +1 -1
- package/dist/content/forms.js +23 -0
- package/dist/content/forms.js.map +1 -1
- package/dist/content/items.d.ts +26 -0
- package/dist/content/items.d.ts.map +1 -1
- package/dist/content/items.js +33 -0
- package/dist/content/items.js.map +1 -1
- package/dist/content/resolve.js +6 -0
- package/dist/content/resolve.js.map +1 -1
- package/dist/content/sitemap.d.ts +5 -0
- package/dist/content/sitemap.d.ts.map +1 -1
- package/dist/content/sitemap.js +5 -0
- package/dist/content/sitemap.js.map +1 -1
- package/dist/core/context.js +6 -0
- package/dist/core/context.js.map +1 -1
- package/dist/core/headers.js +2 -0
- package/dist/core/headers.js.map +1 -1
- package/dist/core/http.d.ts +8 -0
- package/dist/core/http.d.ts.map +1 -1
- package/dist/core/http.js +89 -1
- package/dist/core/http.js.map +1 -1
- package/dist/credit/credit-status.js +2 -2
- package/dist/credit/credit-status.js.map +1 -1
- package/dist/credit/payment-terms.js +2 -2
- package/dist/credit/payment-terms.js.map +1 -1
- package/dist/currency/exchange.d.ts +11 -0
- package/dist/currency/exchange.d.ts.map +1 -1
- package/dist/currency/exchange.js +11 -0
- package/dist/currency/exchange.js.map +1 -1
- package/dist/errors.d.ts +50 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +48 -2
- package/dist/errors.js.map +1 -1
- package/dist/events/envelope.d.ts +36 -0
- package/dist/events/envelope.d.ts.map +1 -1
- package/dist/events/envelope.js +12 -0
- package/dist/events/envelope.js.map +1 -1
- package/dist/events/index.d.ts +13 -0
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +13 -0
- package/dist/events/index.js.map +1 -1
- package/dist/events/payloads.d.ts +19 -0
- package/dist/events/payloads.d.ts.map +1 -1
- package/dist/events/payloads.js +12 -0
- package/dist/events/payloads.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/media/index.js +2 -0
- package/dist/media/index.js.map +1 -1
- package/dist/media/urls.d.ts +52 -0
- package/dist/media/urls.d.ts.map +1 -1
- package/dist/media/urls.js +38 -0
- package/dist/media/urls.js.map +1 -1
- package/dist/media/video.d.ts +16 -0
- package/dist/media/video.d.ts.map +1 -1
- package/dist/media/video.js +16 -0
- package/dist/media/video.js.map +1 -1
- package/dist/next/artifact-handler.d.ts +22 -0
- package/dist/next/artifact-handler.d.ts.map +1 -1
- package/dist/next/artifact-handler.js +22 -0
- package/dist/next/artifact-handler.js.map +1 -1
- package/dist/next/event-revalidate-handler.d.ts +67 -0
- package/dist/next/event-revalidate-handler.d.ts.map +1 -1
- package/dist/next/event-revalidate-handler.js +48 -0
- package/dist/next/event-revalidate-handler.js.map +1 -1
- package/dist/next/index.d.ts +6 -0
- package/dist/next/index.d.ts.map +1 -1
- package/dist/next/index.js +6 -0
- package/dist/next/index.js.map +1 -1
- package/dist/next/json-ld.d.ts +9 -0
- package/dist/next/json-ld.d.ts.map +1 -1
- package/dist/next/json-ld.js +9 -0
- package/dist/next/json-ld.js.map +1 -1
- package/dist/next/metadata.d.ts +18 -0
- package/dist/next/metadata.d.ts.map +1 -1
- package/dist/next/metadata.js +21 -0
- package/dist/next/metadata.js.map +1 -1
- package/dist/next/redirect-middleware.d.ts +39 -0
- package/dist/next/redirect-middleware.d.ts.map +1 -1
- package/dist/next/redirect-middleware.js +32 -0
- package/dist/next/redirect-middleware.js.map +1 -1
- package/dist/next/revalidate-handler.d.ts +30 -0
- package/dist/next/revalidate-handler.d.ts.map +1 -1
- package/dist/next/revalidate-handler.js +22 -0
- package/dist/next/revalidate-handler.js.map +1 -1
- package/dist/order-scope.d.ts +27 -0
- package/dist/order-scope.d.ts.map +1 -1
- package/dist/order-scope.js +29 -0
- package/dist/order-scope.js.map +1 -1
- package/dist/pricing/format.d.ts +17 -0
- package/dist/pricing/format.d.ts.map +1 -1
- package/dist/pricing/format.js +19 -0
- package/dist/pricing/format.js.map +1 -1
- package/dist/pricing/index.d.ts +8 -1
- package/dist/pricing/index.d.ts.map +1 -1
- package/dist/pricing/index.js +18 -2
- package/dist/pricing/index.js.map +1 -1
- package/dist/pricing/tax-display.d.ts +77 -0
- package/dist/pricing/tax-display.d.ts.map +1 -1
- package/dist/pricing/tax-display.js +85 -0
- package/dist/pricing/tax-display.js.map +1 -1
- package/dist/pricing/tiers.d.ts +9 -0
- package/dist/pricing/tiers.d.ts.map +1 -1
- package/dist/pricing/tiers.js +9 -0
- package/dist/pricing/tiers.js.map +1 -1
- package/dist/pricing/validation.d.ts +56 -1
- package/dist/pricing/validation.d.ts.map +1 -1
- package/dist/pricing/validation.js +61 -0
- package/dist/pricing/validation.js.map +1 -1
- package/dist/redirects/index.d.ts +1 -0
- package/dist/redirects/index.d.ts.map +1 -1
- package/dist/redirects/index.js +1 -0
- package/dist/redirects/index.js.map +1 -1
- package/dist/redirects/store.d.ts +20 -0
- package/dist/redirects/store.d.ts.map +1 -1
- package/dist/redirects/store.js +57 -0
- package/dist/redirects/store.js.map +1 -1
- package/dist/redirects/types.d.ts +24 -0
- package/dist/redirects/types.d.ts.map +1 -1
- package/dist/redirects/types.js +1 -0
- package/dist/redirects/types.js.map +1 -1
- package/dist/revalidation/event-plan.d.ts +48 -0
- package/dist/revalidation/event-plan.d.ts.map +1 -1
- package/dist/revalidation/event-plan.js +61 -0
- package/dist/revalidation/event-plan.js.map +1 -1
- package/dist/revalidation/event-verify.d.ts +25 -0
- package/dist/revalidation/event-verify.d.ts.map +1 -1
- package/dist/revalidation/event-verify.js +27 -0
- package/dist/revalidation/event-verify.js.map +1 -1
- package/dist/revalidation/types.d.ts +20 -0
- package/dist/revalidation/types.d.ts.map +1 -1
- package/dist/revalidation/types.js +10 -0
- package/dist/revalidation/types.js.map +1 -1
- package/dist/revalidation/url-context.d.ts +25 -0
- package/dist/revalidation/url-context.d.ts.map +1 -1
- package/dist/revalidation/url-context.js +17 -0
- package/dist/revalidation/url-context.js.map +1 -1
- package/dist/revalidation/verify.d.ts +8 -0
- package/dist/revalidation/verify.d.ts.map +1 -1
- package/dist/revalidation/verify.js +8 -0
- package/dist/revalidation/verify.js.map +1 -1
- package/dist/seo/ai.d.ts +17 -0
- package/dist/seo/ai.d.ts.map +1 -1
- package/dist/seo/ai.js +12 -0
- package/dist/seo/ai.js.map +1 -1
- package/dist/seo/alternates.js +13 -0
- package/dist/seo/alternates.js.map +1 -1
- package/dist/seo/artifacts.d.ts +13 -0
- package/dist/seo/artifacts.d.ts.map +1 -1
- package/dist/seo/artifacts.js +19 -0
- package/dist/seo/artifacts.js.map +1 -1
- package/dist/seo/canonical.d.ts +15 -0
- package/dist/seo/canonical.d.ts.map +1 -1
- package/dist/seo/canonical.js +24 -0
- package/dist/seo/canonical.js.map +1 -1
- package/dist/seo/index.js +6 -0
- package/dist/seo/index.js.map +1 -1
- package/dist/seo/json-ld.d.ts +13 -0
- package/dist/seo/json-ld.d.ts.map +1 -1
- package/dist/seo/json-ld.js +32 -0
- package/dist/seo/json-ld.js.map +1 -1
- package/dist/seo/locale-tag.d.ts +31 -0
- package/dist/seo/locale-tag.d.ts.map +1 -1
- package/dist/seo/locale-tag.js +31 -0
- package/dist/seo/locale-tag.js.map +1 -1
- package/dist/seo/meta-tags.d.ts +29 -0
- package/dist/seo/meta-tags.d.ts.map +1 -1
- package/dist/seo/meta-tags.js +28 -0
- package/dist/seo/meta-tags.js.map +1 -1
- package/dist/seo/metadata-parser.d.ts +24 -0
- package/dist/seo/metadata-parser.d.ts.map +1 -1
- package/dist/seo/metadata-parser.js +38 -0
- package/dist/seo/metadata-parser.js.map +1 -1
- package/dist/seo/metadata-types.d.ts +16 -0
- package/dist/seo/metadata-types.d.ts.map +1 -1
- package/dist/seo/product-path.d.ts +96 -0
- package/dist/seo/product-path.d.ts.map +1 -1
- package/dist/seo/product-path.js +96 -0
- package/dist/seo/product-path.js.map +1 -1
- package/dist/seo/robots.d.ts +17 -0
- package/dist/seo/robots.d.ts.map +1 -1
- package/dist/seo/robots.js +12 -0
- package/dist/seo/robots.js.map +1 -1
- package/dist/seo/types.d.ts +39 -0
- package/dist/seo/types.d.ts.map +1 -1
- package/dist/seo/url-builder.d.ts +31 -0
- package/dist/seo/url-builder.d.ts.map +1 -1
- package/dist/seo/url-builder.js +36 -0
- package/dist/seo/url-builder.js.map +1 -1
- package/dist/types.d.ts +1163 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,14 +1,69 @@
|
|
|
1
|
-
import type { OrderValidationResult } from '../types.js';
|
|
1
|
+
import type { OrderableStockInput, OrderValidationResult } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validate an order against the channel's order minimums.
|
|
4
|
+
* Call before `transitionToArrangingPayment()` to provide early feedback.
|
|
5
|
+
*
|
|
6
|
+
* Pass the object from `getOrderConstraints()` straight through — its
|
|
7
|
+
* `minOrderAmountGross` / `minOrderQuantity` fields are read directly:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* const constraints = await client.checkout.getOrderConstraints();
|
|
11
|
+
* const result = client.pricing.validateOrderMinimums(order, constraints);
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* The server enforces both minimums at the transition regardless, and its
|
|
15
|
+
* message may name the price list that binds ("Minimum order for Wholesale
|
|
16
|
+
* is …"), which the client cannot know. Display the server's message as-is on
|
|
17
|
+
* failure; these messages are for the pre-checkout shortfall hint.
|
|
18
|
+
*/
|
|
2
19
|
export declare function validateOrderMinimums(order: {
|
|
3
20
|
totalWithTax: number;
|
|
4
21
|
currencyCode: string;
|
|
5
22
|
totalQuantity?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Net (tax-exclusive) total, minor units. Only needed when the channel
|
|
25
|
+
* returns `minOrderAmountNet`; `subTotal` is preferred over `total` because
|
|
26
|
+
* the server compares line totals, which exclude shipping.
|
|
27
|
+
*/
|
|
6
28
|
subTotal?: number;
|
|
7
29
|
total?: number;
|
|
8
30
|
}, constraints: {
|
|
31
|
+
/** Minimum vs the GROSS order total, minor units. As returned by `getOrderConstraints()`. */
|
|
9
32
|
minOrderAmountGross?: number | null;
|
|
33
|
+
/**
|
|
34
|
+
* Minimum vs the NET order total, minor units. Independent of the gross
|
|
35
|
+
* minimum — both bind. As returned by `getOrderConstraints()`.
|
|
36
|
+
*/
|
|
10
37
|
minOrderAmountNet?: number | null;
|
|
38
|
+
/** Minimum total item count. As returned by `getOrderConstraints()`. */
|
|
11
39
|
minOrderQuantity?: number | null;
|
|
40
|
+
/** @deprecated Use `minOrderAmountGross` — the field `getOrderConstraints()` actually returns. */
|
|
12
41
|
minOrderAmount?: number | null;
|
|
13
42
|
}): OrderValidationResult;
|
|
43
|
+
export type { OrderableStockInput };
|
|
44
|
+
/**
|
|
45
|
+
* How many units of a variant the current shopper may put in the cart:
|
|
46
|
+
* `max(0, saleable) + backorderAllowance`.
|
|
47
|
+
*
|
|
48
|
+
* Returns `null` when the channel does not expose stock (`saleable == null`) —
|
|
49
|
+
* the storefront cannot know a ceiling then and should let the server decide,
|
|
50
|
+
* exactly as before backorders existed. A `null` allowance counts as 0, so a
|
|
51
|
+
* shopper the policy does not admit gets plain `saleable`.
|
|
52
|
+
*/
|
|
53
|
+
export declare function maxOrderableQuantity(variant: OrderableStockInput): number | null;
|
|
54
|
+
/**
|
|
55
|
+
* Whether a variant is orderable only on backorder: nothing saleable, but an
|
|
56
|
+
* allowance. The signal to label "Backorder" instead of "Out of stock".
|
|
57
|
+
*/
|
|
58
|
+
export declare function isBackorderOnly(variant: OrderableStockInput): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Units of a cart line physical stock will not cover — the "N on backorder"
|
|
61
|
+
* hint BEFORE placement, when `backorderedQuantity` is still 0 — computed the
|
|
62
|
+
* way the server stamps it at placement: `max(0, quantity − max(0, saleable))`.
|
|
63
|
+
*
|
|
64
|
+
* `null` when there is nothing to say: the channel hides stock
|
|
65
|
+
* (`saleable == null` — never read that as 0, or every in-stock line would
|
|
66
|
+
* be "on backorder"), or stock covers the line. Pass the line's variant.
|
|
67
|
+
*/
|
|
68
|
+
export declare function backorderedQuantityForCart(variant: Pick<OrderableStockInput, 'saleable'>, quantity: number): number | null;
|
|
14
69
|
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/pricing/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAwB,qBAAqB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/pricing/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAwB,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGpG;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE;IACL,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EACD,WAAW,EAAE;IACX,6FAA6F;IAC7F,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,wEAAwE;IACxE,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,kGAAkG;IAClG,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,GACA,qBAAqB,CAgDvB;AAED,YAAY,EAAE,mBAAmB,EAAE,CAAC;AAEpC;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,GAAG,IAAI,CAGhF;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAErE;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAC9C,QAAQ,EAAE,MAAM,GACf,MAAM,GAAG,IAAI,CAIf"}
|
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
import { formatPrice } from './format.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validate an order against the channel's order minimums.
|
|
4
|
+
* Call before `transitionToArrangingPayment()` to provide early feedback.
|
|
5
|
+
*
|
|
6
|
+
* Pass the object from `getOrderConstraints()` straight through — its
|
|
7
|
+
* `minOrderAmountGross` / `minOrderQuantity` fields are read directly:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* const constraints = await client.checkout.getOrderConstraints();
|
|
11
|
+
* const result = client.pricing.validateOrderMinimums(order, constraints);
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* The server enforces both minimums at the transition regardless, and its
|
|
15
|
+
* message may name the price list that binds ("Minimum order for Wholesale
|
|
16
|
+
* is …"), which the client cannot know. Display the server's message as-is on
|
|
17
|
+
* failure; these messages are for the pre-checkout shortfall hint.
|
|
18
|
+
*/
|
|
2
19
|
export function validateOrderMinimums(order, constraints) {
|
|
3
20
|
const errors = [];
|
|
4
21
|
const minAmount = constraints.minOrderAmountGross ?? constraints.minOrderAmount;
|
|
@@ -10,17 +27,25 @@ export function validateOrderMinimums(order, constraints) {
|
|
|
10
27
|
actual: order.totalWithTax,
|
|
11
28
|
});
|
|
12
29
|
}
|
|
30
|
+
// A net minimum is checked separately, never folded into the gross one: the
|
|
31
|
+
// two are different bases and converting between them needs a tax rate the
|
|
32
|
+
// client does not have. Both can fail on the same cart.
|
|
13
33
|
const minAmountNet = constraints.minOrderAmountNet;
|
|
14
34
|
const netTotal = order.subTotal ?? order.total;
|
|
15
35
|
if (minAmountNet != null && minAmountNet > 0 && netTotal != null && netTotal < minAmountNet) {
|
|
16
36
|
errors.push({
|
|
17
37
|
type: 'min_amount',
|
|
38
|
+
// Says "excl. tax" so the figure is not read against the gross total the
|
|
39
|
+
// buyer sees on screen, where it would look wrong.
|
|
18
40
|
message: `Minimum order amount is ${formatPrice(minAmountNet, order.currencyCode)} excl. tax`,
|
|
19
41
|
required: minAmountNet,
|
|
20
42
|
actual: netTotal,
|
|
21
43
|
});
|
|
22
44
|
}
|
|
23
45
|
const minQuantity = constraints.minOrderQuantity;
|
|
46
|
+
// `totalQuantity` is optional so a caller passing only totals still validates
|
|
47
|
+
// the amount. Skipping the quantity check when it is absent is correct;
|
|
48
|
+
// silently failing it against `undefined` would not be.
|
|
24
49
|
if (minQuantity != null &&
|
|
25
50
|
minQuantity > 0 &&
|
|
26
51
|
order.totalQuantity != null &&
|
|
@@ -34,4 +59,40 @@ export function validateOrderMinimums(order, constraints) {
|
|
|
34
59
|
}
|
|
35
60
|
return { valid: errors.length === 0, errors };
|
|
36
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* How many units of a variant the current shopper may put in the cart:
|
|
64
|
+
* `max(0, saleable) + backorderAllowance`.
|
|
65
|
+
*
|
|
66
|
+
* Returns `null` when the channel does not expose stock (`saleable == null`) —
|
|
67
|
+
* the storefront cannot know a ceiling then and should let the server decide,
|
|
68
|
+
* exactly as before backorders existed. A `null` allowance counts as 0, so a
|
|
69
|
+
* shopper the policy does not admit gets plain `saleable`.
|
|
70
|
+
*/
|
|
71
|
+
export function maxOrderableQuantity(variant) {
|
|
72
|
+
if (variant.saleable == null)
|
|
73
|
+
return null;
|
|
74
|
+
return Math.max(0, variant.saleable) + Math.max(0, variant.backorderAllowance ?? 0);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Whether a variant is orderable only on backorder: nothing saleable, but an
|
|
78
|
+
* allowance. The signal to label "Backorder" instead of "Out of stock".
|
|
79
|
+
*/
|
|
80
|
+
export function isBackorderOnly(variant) {
|
|
81
|
+
return (variant.saleable ?? 0) <= 0 && (variant.backorderAllowance ?? 0) > 0;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Units of a cart line physical stock will not cover — the "N on backorder"
|
|
85
|
+
* hint BEFORE placement, when `backorderedQuantity` is still 0 — computed the
|
|
86
|
+
* way the server stamps it at placement: `max(0, quantity − max(0, saleable))`.
|
|
87
|
+
*
|
|
88
|
+
* `null` when there is nothing to say: the channel hides stock
|
|
89
|
+
* (`saleable == null` — never read that as 0, or every in-stock line would
|
|
90
|
+
* be "on backorder"), or stock covers the line. Pass the line's variant.
|
|
91
|
+
*/
|
|
92
|
+
export function backorderedQuantityForCart(variant, quantity) {
|
|
93
|
+
if (variant.saleable == null)
|
|
94
|
+
return null;
|
|
95
|
+
const units = Math.max(0, quantity - Math.max(0, variant.saleable));
|
|
96
|
+
return units > 0 ? units : null;
|
|
97
|
+
}
|
|
37
98
|
//# sourceMappingURL=validation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/pricing/validation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/pricing/validation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAWC,EACD,WAYC;IAED,MAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,MAAM,SAAS,GAAG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;YACzD,QAAQ,EAAE,WAAW;YACrB,MAAM,EAAE,KAAK,CAAC,aAAa;SAC5B,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;AAChD,CAAC;AAID;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAA4B;IAC/D,IAAI,OAAO,CAAC,QAAQ,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IAC1C,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,kBAAkB,IAAI,CAAC,CAAC,CAAC;AACtF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,OAA4B;IAC1D,OAAO,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;AAC/E,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAA8C,EAC9C,QAAgB;IAEhB,IAAI,OAAO,CAAC,QAAQ,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IACpE,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAClC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { StoreContext } from '../types.js';
|
|
2
2
|
import type { RedirectStore, RedirectStoreConfig } from './types.js';
|
|
3
|
+
/** Wire a redirect store from an initialized client's context. */
|
|
3
4
|
export declare function createRedirectsModule(ctx: StoreContext, options?: Pick<RedirectStoreConfig, 'ttlMs' | 'timeoutMs' | 'onError'>): RedirectStore;
|
|
4
5
|
export { createRedirectStore, normalizeLookupPath } from './store.js';
|
|
5
6
|
export { REDIRECT_STATUS_CODES, type RedirectMatch, type RedirectRule, type RedirectSnapshot, type RedirectStatusCode, type RedirectStore, type RedirectStoreConfig, } from './types.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/redirects/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/redirects/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAErE,kEAAkE;AAClE,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,YAAY,EACjB,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,OAAO,GAAG,WAAW,GAAG,SAAS,CAAC,GACrE,aAAa,CAOf;AAED,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EACL,qBAAqB,EACrB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,mBAAmB,GACzB,MAAM,YAAY,CAAC"}
|
package/dist/redirects/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/redirects/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/redirects/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGjD,kEAAkE;AAClE,MAAM,UAAU,qBAAqB,CACnC,GAAiB,EACjB,OAAsE;IAEtE,OAAO,mBAAmB,CAAC;QACzB,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI;QAC3B,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC;AAED,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EACL,qBAAqB,GAOtB,MAAM,YAAY,CAAC"}
|
|
@@ -1,4 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-process redirect map for a storefront.
|
|
3
|
+
*
|
|
4
|
+
* Fetches the platform's public per-channel snapshot once per TTL and matches
|
|
5
|
+
* pathnames against it in memory, so a middleware costs a Map lookup rather
|
|
6
|
+
* than a network hop. Revalidation is ETag-conditional: an unchanged map comes
|
|
7
|
+
* back as a 304 with no body.
|
|
8
|
+
*
|
|
9
|
+
* Deliberately fail-open — a refresh failure keeps the last good map in service
|
|
10
|
+
* and reports through `onError` rather than throwing. A platform blip must not
|
|
11
|
+
* turn a tenant's working redirects into 404s.
|
|
12
|
+
*
|
|
13
|
+
* Only the FIRST load is awaited. Once a map exists, revalidation happens in the
|
|
14
|
+
* background and callers are served the current one: this runs in middleware
|
|
15
|
+
* ahead of every page render, so a slow platform must never become a slow store.
|
|
16
|
+
*/
|
|
1
17
|
import { type RedirectStore, type RedirectStoreConfig } from './types.js';
|
|
18
|
+
/**
|
|
19
|
+
* Match the platform's own source normalization: trailing slashes are stripped
|
|
20
|
+
* so `/a` and `/a/` are the same rule. The root path keeps its slash.
|
|
21
|
+
*/
|
|
2
22
|
export declare function normalizeLookupPath(pathname: string): string;
|
|
3
23
|
export declare function createRedirectStore(config: RedirectStoreConfig): RedirectStore;
|
|
4
24
|
//# sourceMappingURL=store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/redirects/store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/redirects/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAML,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACzB,MAAM,YAAY,CAAC;AAuBpB;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAe5D;AAsCD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa,CA+J9E"}
|
package/dist/redirects/store.js
CHANGED
|
@@ -1,25 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-process redirect map for a storefront.
|
|
3
|
+
*
|
|
4
|
+
* Fetches the platform's public per-channel snapshot once per TTL and matches
|
|
5
|
+
* pathnames against it in memory, so a middleware costs a Map lookup rather
|
|
6
|
+
* than a network hop. Revalidation is ETag-conditional: an unchanged map comes
|
|
7
|
+
* back as a 304 with no body.
|
|
8
|
+
*
|
|
9
|
+
* Deliberately fail-open — a refresh failure keeps the last good map in service
|
|
10
|
+
* and reports through `onError` rather than throwing. A platform blip must not
|
|
11
|
+
* turn a tenant's working redirects into 404s.
|
|
12
|
+
*
|
|
13
|
+
* Only the FIRST load is awaited. Once a map exists, revalidation happens in the
|
|
14
|
+
* background and callers are served the current one: this runs in middleware
|
|
15
|
+
* ahead of every page render, so a slow platform must never become a slow store.
|
|
16
|
+
*/
|
|
1
17
|
import { DEFAULT_PLUGINS_URL } from '../constants.js';
|
|
2
18
|
import { REDIRECT_STATUS_CODES, } from './types.js';
|
|
3
19
|
const DEFAULT_TTL_MS = 60_000;
|
|
4
20
|
const DEFAULT_TIMEOUT_MS = 5_000;
|
|
21
|
+
/**
|
|
22
|
+
* How long a FAILED load is remembered before the next attempt. Deliberately
|
|
23
|
+
* well above `DEFAULT_TIMEOUT_MS`: if the two were equal, an outage would spend
|
|
24
|
+
* half of every cycle inside a fetch that callers are waiting on.
|
|
25
|
+
*/
|
|
5
26
|
const FAILURE_BACKOFF_MS = 30_000;
|
|
27
|
+
/** Base for lookup-path canonicalization only — never requested. */
|
|
6
28
|
const CANONICAL_BASE = 'https://redirect.invalid';
|
|
29
|
+
/**
|
|
30
|
+
* Match the platform's own source normalization: trailing slashes are stripped
|
|
31
|
+
* so `/a` and `/a/` are the same rule. The root path keeps its slash.
|
|
32
|
+
*/
|
|
7
33
|
export function normalizeLookupPath(pathname) {
|
|
8
34
|
const trimmed = pathname.trim();
|
|
9
35
|
if (trimmed === '' || trimmed === '/')
|
|
10
36
|
return '/';
|
|
11
37
|
const withLeadingSlash = trimmed.startsWith('/') ? trimmed : `/${trimmed}`;
|
|
38
|
+
// The platform stores the canonical percent-encoded form, which is also what
|
|
39
|
+
// a browser sends. Re-encoding here is idempotent and lets a caller pass the
|
|
40
|
+
// human-readable `/café` and still hit the `/caf%C3%A9` rule.
|
|
12
41
|
let canonical = withLeadingSlash;
|
|
13
42
|
try {
|
|
14
43
|
canonical = new URL(withLeadingSlash, CANONICAL_BASE).pathname;
|
|
15
44
|
}
|
|
16
45
|
catch {
|
|
46
|
+
// Not URL-shaped — fall through with the raw value rather than throwing
|
|
47
|
+
// out of a middleware's hot path.
|
|
17
48
|
}
|
|
18
49
|
return canonical.replace(/\/+$/, '') || '/';
|
|
19
50
|
}
|
|
20
51
|
function isRedirectStatusCode(value) {
|
|
21
52
|
return typeof value === 'number' && REDIRECT_STATUS_CODES.includes(value);
|
|
22
53
|
}
|
|
54
|
+
/** Parse the wire payload defensively — the platform is an external boundary. */
|
|
23
55
|
function parseSnapshot(raw) {
|
|
24
56
|
if (typeof raw !== 'object' || raw === null) {
|
|
25
57
|
throw new Error('Redirect snapshot is not an object');
|
|
@@ -63,6 +95,7 @@ export function createRedirectStore(config) {
|
|
|
63
95
|
let etag = null;
|
|
64
96
|
let freshUntil = 0;
|
|
65
97
|
let inFlight = null;
|
|
98
|
+
/** Set once a load has failed; cleared by the next success. */
|
|
66
99
|
let lastLoadFailed = false;
|
|
67
100
|
function indexOf(snapshot) {
|
|
68
101
|
const map = new Map();
|
|
@@ -100,12 +133,19 @@ export function createRedirectStore(config) {
|
|
|
100
133
|
clearTimeout(timeoutId);
|
|
101
134
|
}
|
|
102
135
|
}
|
|
136
|
+
/** One refresh at a time; concurrent callers share the in-flight request. */
|
|
103
137
|
function loadOnce() {
|
|
104
138
|
inFlight ??= load().finally(() => {
|
|
105
139
|
inFlight = null;
|
|
106
140
|
});
|
|
107
141
|
return inFlight;
|
|
108
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Load that is guaranteed to observe state as of NOW. An in-flight request
|
|
145
|
+
* may have been issued before the change we are being told about, so joining
|
|
146
|
+
* it would report success while leaving the stale map in place — chain a new
|
|
147
|
+
* load after it instead.
|
|
148
|
+
*/
|
|
109
149
|
function loadAfterInFlight() {
|
|
110
150
|
const pending = inFlight;
|
|
111
151
|
if (!pending)
|
|
@@ -115,8 +155,12 @@ export function createRedirectStore(config) {
|
|
|
115
155
|
function reportFailure(error) {
|
|
116
156
|
lastLoadFailed = true;
|
|
117
157
|
config.onError?.(error instanceof Error ? error : new Error(String(error)));
|
|
158
|
+
// Back off whether or not there is a map to fall back on. With a warm cache
|
|
159
|
+
// that means serving the last good map for another TTL; with a COLD one it
|
|
160
|
+
// is what stops every request paying the full fetch timeout.
|
|
118
161
|
freshUntil = Date.now() + (cached ? ttlMs : FAILURE_BACKOFF_MS);
|
|
119
162
|
}
|
|
163
|
+
/** Warm the map without anyone waiting on it. Never rejects. */
|
|
120
164
|
function refreshInBackground() {
|
|
121
165
|
void loadOnce().then(() => {
|
|
122
166
|
lastLoadFailed = false;
|
|
@@ -128,14 +172,25 @@ export function createRedirectStore(config) {
|
|
|
128
172
|
if (Date.now() < freshUntil) {
|
|
129
173
|
return cached;
|
|
130
174
|
}
|
|
175
|
+
// Stale-while-revalidate: once there IS a map, no caller ever waits on the
|
|
176
|
+
// network again. Revalidating in the foreground put one request per TTL —
|
|
177
|
+
// and every request concurrent with it — behind a round-trip that can run to
|
|
178
|
+
// `timeoutMs`, in middleware, ahead of a page render. Serving a map up to
|
|
179
|
+
// one TTL stale is what this store already accepts on error, so accepting it
|
|
180
|
+
// on a slow platform too is the consistent choice.
|
|
131
181
|
if (cached) {
|
|
132
182
|
refreshInBackground();
|
|
133
183
|
return cached;
|
|
134
184
|
}
|
|
185
|
+
// Cold cache AND we already know loads are failing: do not make this caller
|
|
186
|
+
// wait to rediscover that. Retry in the background and let the request
|
|
187
|
+
// through unredirected.
|
|
135
188
|
if (lastLoadFailed) {
|
|
136
189
|
refreshInBackground();
|
|
137
190
|
return null;
|
|
138
191
|
}
|
|
192
|
+
// The very first load IS awaited, so a healthy cold start never misses a
|
|
193
|
+
// redirect it had the data to serve.
|
|
139
194
|
try {
|
|
140
195
|
const snapshot = await loadOnce();
|
|
141
196
|
lastLoadFailed = false;
|
|
@@ -157,6 +212,8 @@ export function createRedirectStore(config) {
|
|
|
157
212
|
const snapshot = await ensureFresh();
|
|
158
213
|
if (snapshot)
|
|
159
214
|
return snapshot;
|
|
215
|
+
// No cached map to fall back on — the caller asked for data we do not
|
|
216
|
+
// have, so surface the load error rather than inventing an empty map.
|
|
160
217
|
return loadOnce();
|
|
161
218
|
},
|
|
162
219
|
async refresh() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/redirects/store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/redirects/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,mBAAmB,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E,CAAC;YACtB,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,4EAA4E;QAC5E,uEAAuE;QACvE,wBAAwB;QACxB,IAAI,cAAc,EAAE,CAAC;YACnB,mBAAmB,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,yEAAyE;QACzE,qCAAqC;QACrC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,QAAQ,EAAE,CAAC;YAClC,cAAc,GAAG,KAAK,CAAC;YACvB,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,aAAa,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK,CAAC,KAAK,CAAC,QAAgB;YAC1B,MAAM,QAAQ,GAAG,MAAM,WAAW,EAAE,CAAC;YACrC,IAAI,CAAC,QAAQ,IAAI,CAAC,KAAK;gBAAE,OAAO,IAAI,CAAC;YACrC,OAAO,KAAK,CAAC,GAAG,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,IAAI,IAAI,CAAC;QAC1D,CAAC;QAED,KAAK,CAAC,QAAQ;YACZ,MAAM,QAAQ,GAAG,MAAM,WAAW,EAAE,CAAC;YACrC,IAAI,QAAQ;gBAAE,OAAO,QAAQ,CAAC;YAC9B,sEAAsE;YACtE,sEAAsE;YACtE,OAAO,QAAQ,EAAE,CAAC;QACpB,CAAC;QAED,KAAK,CAAC,OAAO;YACX,UAAU,GAAG,CAAC,CAAC;YACf,OAAO,iBAAiB,EAAE,CAAC;QAC7B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
/** The redirect statuses the platform accepts. Mirrors the plugins service. */
|
|
1
2
|
export declare const REDIRECT_STATUS_CODES: readonly [301, 302, 303, 307, 308];
|
|
2
3
|
export type RedirectStatusCode = (typeof REDIRECT_STATUS_CODES)[number];
|
|
4
|
+
/** One stored rule. `from` is always a literal path; `to` is a path or an https URL. */
|
|
3
5
|
export interface RedirectRule {
|
|
4
6
|
from: string;
|
|
5
7
|
to: string;
|
|
@@ -7,26 +9,48 @@ export interface RedirectRule {
|
|
|
7
9
|
}
|
|
8
10
|
export interface RedirectSnapshot {
|
|
9
11
|
channelCode: string;
|
|
12
|
+
/** Content hash of the rule set — equal to the ETag the platform served. */
|
|
10
13
|
version: string;
|
|
14
|
+
/** ISO instant the platform rendered this snapshot. */
|
|
11
15
|
generatedAt: string;
|
|
12
16
|
rules: RedirectRule[];
|
|
17
|
+
/**
|
|
18
|
+
* Stored rows the platform could not express as an exact-path rule (legacy
|
|
19
|
+
* wildcard/pattern rows). Non-zero means the merchant has rows to clean up.
|
|
20
|
+
*/
|
|
13
21
|
unservableCount: number;
|
|
14
22
|
}
|
|
15
23
|
export interface RedirectMatch {
|
|
24
|
+
/** Resolved target, exactly as stored. */
|
|
16
25
|
to: string;
|
|
17
26
|
status: RedirectStatusCode;
|
|
18
27
|
}
|
|
19
28
|
export interface RedirectStoreConfig {
|
|
29
|
+
/** Store channel code, e.g. `fashion-store`. */
|
|
20
30
|
storeCode: string;
|
|
31
|
+
/** Plugins service origin. Defaults to the SDK's configured plugins URL. */
|
|
21
32
|
pluginsUrl?: string;
|
|
33
|
+
/** How long a fetched snapshot is served before revalidating. Default 60s. */
|
|
22
34
|
ttlMs?: number;
|
|
35
|
+
/** Upstream fetch timeout. Default 5s — a middleware must not hang a request. */
|
|
23
36
|
timeoutMs?: number;
|
|
24
37
|
fetch?: typeof globalThis.fetch;
|
|
38
|
+
/**
|
|
39
|
+
* Called when a refresh fails. The store keeps serving the last good snapshot
|
|
40
|
+
* (a platform blip must not break the storefront's URLs), so this callback is
|
|
41
|
+
* the only signal that revalidation is failing — wire it to your logger.
|
|
42
|
+
*/
|
|
25
43
|
onError?: (error: Error) => void;
|
|
26
44
|
}
|
|
27
45
|
export interface RedirectStore {
|
|
46
|
+
/**
|
|
47
|
+
* Look up one pathname. Returns null when nothing matches. Never throws:
|
|
48
|
+
* on a cold cache with an unreachable platform it resolves to null.
|
|
49
|
+
*/
|
|
28
50
|
match(pathname: string): Promise<RedirectMatch | null>;
|
|
51
|
+
/** The current snapshot, fetching or revalidating if the TTL has lapsed. */
|
|
29
52
|
snapshot(): Promise<RedirectSnapshot>;
|
|
53
|
+
/** Force a revalidation regardless of TTL. */
|
|
30
54
|
refresh(): Promise<RedirectSnapshot>;
|
|
31
55
|
}
|
|
32
56
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/redirects/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/redirects/types.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,eAAO,MAAM,qBAAqB,oCAAqC,CAAC;AACxE,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAExE,wFAAwF;AACxF,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,kBAAkB,CAAC;CAC5B;AAED,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC5B,0CAA0C;IAC1C,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,kBAAkB,CAAC;CAC5B;AAED,MAAM,WAAW,mBAAmB;IAClC,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;IACvD,4EAA4E;IAC5E,QAAQ,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACtC,8CAA8C;IAC9C,OAAO,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACtC"}
|
package/dist/redirects/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/redirects/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/redirects/types.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAC"}
|
|
@@ -1,23 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event → revalidation mapping. Pure: no `next`, no I/O, so a pull-feed
|
|
3
|
+
* consumer can reuse it exactly as the webhook handler does.
|
|
4
|
+
*
|
|
5
|
+
* Path rules the whole module keeps:
|
|
6
|
+
* - Event paths are channel-relative and locale-UNPREFIXED. Each is composed
|
|
7
|
+
* per locale with the channel's own URL rule (`buildUrl`) and then mapped to
|
|
8
|
+
* a route path (default: the URL's pathname).
|
|
9
|
+
* - A commerce path prefix is never prepended and never stripped: commerce
|
|
10
|
+
* paths on the bus already carry it, and CMS paths never do — a CMS page may
|
|
11
|
+
* legitimately live at `/store/about` beside `commercePathPrefix: '/store'`.
|
|
12
|
+
* - Whenever an event cannot say which URLs moved (a truncated list, a moved
|
|
13
|
+
* base path, a rule change), the plan is the WHOLE site. Never quieter.
|
|
14
|
+
*/
|
|
1
15
|
import type { PlatformEventEnvelope } from '../events/envelope.js';
|
|
2
16
|
import type { ChannelUrlRuleSet, UrlContext } from './url-context.js';
|
|
17
|
+
/** Above this many route paths, one whole-site revalidation replaces them — as the legacy dispatcher does. */
|
|
3
18
|
export declare const DEFAULT_MAX_REVALIDATE_PATHS = 500;
|
|
4
19
|
export type RevalidationSkipReason = 'unknown_type' | 'unsupported_schema_version';
|
|
5
20
|
export interface RevalidationPlan {
|
|
21
|
+
/** Route paths for `revalidatePath`, de-duplicated. Empty when `all`. */
|
|
6
22
|
readonly paths: string[];
|
|
23
|
+
/** Tags for `revalidateTag`. */
|
|
7
24
|
readonly tags: string[];
|
|
25
|
+
/** Revalidate the whole site — `revalidatePath('/', 'layout')`. */
|
|
8
26
|
readonly all: boolean;
|
|
27
|
+
/** Set when the event is not one this SDK acts on; the plan is then empty. */
|
|
9
28
|
readonly skipped?: RevalidationSkipReason;
|
|
29
|
+
/**
|
|
30
|
+
* Set by `createEventRevalidateHandler` when a path event's URLs could not be
|
|
31
|
+
* composed — the URL context could not be read or is unusable, or
|
|
32
|
+
* `toRoutePath` threw or returned a non-path — and it revalidated the whole
|
|
33
|
+
* site instead, answering 200. `planRevalidation` never sets it; it throws.
|
|
34
|
+
*/
|
|
10
35
|
readonly degraded?: RevalidationDegradedReason;
|
|
11
36
|
}
|
|
12
37
|
export type RevalidationDegradedReason = 'url_mapping_failed';
|
|
13
38
|
export interface RevalidationPlanOptions {
|
|
39
|
+
/** Above this many route paths, plan a whole-site revalidation instead. Default 500. */
|
|
14
40
|
maxPaths?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Map a composed storefront URL to the route path to revalidate, or `null` to
|
|
43
|
+
* skip it. Default: `url.pathname`. Override when your routes differ from your
|
|
44
|
+
* public URLs — e.g. `subdomain` locales rewritten to `/[locale]/...` routes.
|
|
45
|
+
*/
|
|
15
46
|
toRoutePath?(url: URL, locale: string): string | null;
|
|
16
47
|
}
|
|
48
|
+
/** A signed, known-type, version-1 event whose `data` does not match its contract. */
|
|
17
49
|
export declare class EventPayloadError extends Error {
|
|
18
50
|
constructor(message: string);
|
|
19
51
|
}
|
|
20
52
|
type PathPair = readonly [path: string, locale: string];
|
|
53
|
+
/** What an event asks for, before any URL is composed. Internal to the SDK. */
|
|
21
54
|
export type RevalidationIntent = {
|
|
22
55
|
readonly kind: 'skip';
|
|
23
56
|
readonly reason: RevalidationSkipReason;
|
|
@@ -31,9 +64,24 @@ export type RevalidationIntent = {
|
|
|
31
64
|
readonly kind: 'paths';
|
|
32
65
|
expand(locales: readonly string[]): PathPair[];
|
|
33
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* Classify an envelope. Unknown types and unsupported versions are skips, not
|
|
69
|
+
* errors — a subscriber on an older SDK must keep accepting newer events.
|
|
70
|
+
* Throws {@link EventPayloadError} for a known v1 type whose `data` is off-contract.
|
|
71
|
+
*/
|
|
34
72
|
export declare function classifyEvent(envelope: Pick<PlatformEventEnvelope, 'type' | 'schema_version' | 'data'>): RevalidationIntent;
|
|
35
73
|
export declare function resolveMaxPaths(maxPaths: number | undefined): number;
|
|
74
|
+
/** Turn an intent into a plan, composing URLs only when the intent has paths. */
|
|
36
75
|
export declare function planFromIntent(intent: RevalidationIntent, urls: UrlContext | null, options?: RevalidationPlanOptions): RevalidationPlan;
|
|
76
|
+
/**
|
|
77
|
+
* The revalidation a platform event calls for — the mapping
|
|
78
|
+
* `createEventRevalidateHandler` applies, for consumers of the pull feed or of
|
|
79
|
+
* their own webhook plumbing.
|
|
80
|
+
*
|
|
81
|
+
* Throws {@link EventPayloadError} when a known version-1 event's `data` does
|
|
82
|
+
* not match its contract, and `TypeError` when `urls` is unusable for an event
|
|
83
|
+
* that carries paths.
|
|
84
|
+
*/
|
|
37
85
|
export declare function planRevalidation(envelope: Pick<PlatformEventEnvelope, 'type' | 'schema_version' | 'data'>, urls: UrlContext, options?: RevalidationPlanOptions): RevalidationPlan;
|
|
38
86
|
export {};
|
|
39
87
|
//# sourceMappingURL=event-plan.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-plan.d.ts","sourceRoot":"","sources":["../../src/revalidation/event-plan.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"event-plan.d.ts","sourceRoot":"","sources":["../../src/revalidation/event-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAGnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEtE,8GAA8G;AAC9G,eAAO,MAAM,4BAA4B,MAAM,CAAC;AAEhD,MAAM,MAAM,sBAAsB,GAAG,cAAc,GAAG,4BAA4B,CAAC;AAEnF,MAAM,WAAW,gBAAgB;IAC/B,yEAAyE;IACzE,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IACzB,gCAAgC;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IACxB,mEAAmE;IACnE,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,8EAA8E;IAC9E,QAAQ,CAAC,OAAO,CAAC,EAAE,sBAAsB,CAAC;IAC1C;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,0BAA0B,CAAC;CAChD;AAED,MAAM,MAAM,0BAA0B,GAAG,oBAAoB,CAAC;AAE9D,MAAM,WAAW,uBAAuB;IACtC,wFAAwF;IACxF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,WAAW,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,M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