@sixtyninecommerce/client 0.23.1 → 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 +25 -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/index.d.ts +17 -1
- package/dist/commerce/index.d.ts.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 +95 -2
- package/dist/commerce/products.js.map +1 -1
- package/dist/commerce/queries.d.ts +114 -27
- package/dist/commerce/queries.d.ts.map +1 -1
- package/dist/commerce/queries.js +219 -1
- 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/subscriptions.d.ts +32 -8
- package/dist/commerce/subscriptions.d.ts.map +1 -1
- package/dist/commerce/subscriptions.js +90 -2
- package/dist/commerce/subscriptions.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 +50 -3
- 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 +8 -1
- 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 +1283 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/next/json-ld.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline JSON-LD helpers — React-free object literals so the core keeps zero
|
|
3
|
+
* framework dependencies.
|
|
4
|
+
*/
|
|
5
|
+
/** JSON.stringify with `<` escaped — safe for inline `<script>` embedding. */
|
|
1
6
|
export declare function serializeJsonLd(value: object): string;
|
|
7
|
+
/**
|
|
8
|
+
* Props for a JSON-LD script element:
|
|
9
|
+
* `<script {...jsonLdScriptProps(obj)} />`
|
|
10
|
+
*/
|
|
2
11
|
export declare function jsonLdScriptProps(value: object): {
|
|
3
12
|
type: 'application/ld+json';
|
|
4
13
|
dangerouslySetInnerHTML: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-ld.d.ts","sourceRoot":"","sources":["../../src/next/json-ld.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"json-ld.d.ts","sourceRoot":"","sources":["../../src/next/json-ld.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,8EAA8E;AAC9E,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG;IAChD,IAAI,EAAE,qBAAqB,CAAC;IAC5B,uBAAuB,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7C,CAKA"}
|
package/dist/next/json-ld.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline JSON-LD helpers — React-free object literals so the core keeps zero
|
|
3
|
+
* framework dependencies.
|
|
4
|
+
*/
|
|
5
|
+
/** JSON.stringify with `<` escaped — safe for inline `<script>` embedding. */
|
|
1
6
|
export function serializeJsonLd(value) {
|
|
2
7
|
return JSON.stringify(value).replace(/</g, '\\u003c');
|
|
3
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Props for a JSON-LD script element:
|
|
11
|
+
* `<script {...jsonLdScriptProps(obj)} />`
|
|
12
|
+
*/
|
|
4
13
|
export function jsonLdScriptProps(value) {
|
|
5
14
|
return {
|
|
6
15
|
type: 'application/ld+json',
|
package/dist/next/json-ld.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-ld.js","sourceRoot":"","sources":["../../src/next/json-ld.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"json-ld.js","sourceRoot":"","sources":["../../src/next/json-ld.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,8EAA8E;AAC9E,MAAM,UAAU,eAAe,CAAC,KAAa;IAC3C,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AACxD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAI7C,OAAO;QACL,IAAI,EAAE,qBAAqB;QAC3B,uBAAuB,EAAE,EAAE,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC,EAAE;KAC5D,CAAC;AACJ,CAAC"}
|
package/dist/next/metadata.d.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter from the SDK's structured head bundle (`seo.metaTagsFor`) to Next.js
|
|
3
|
+
* App Router `Metadata`. Deliberately ZERO `next` imports: the returned object
|
|
4
|
+
* is typed by a local structural subset (`NextCompatibleMetadata`) that
|
|
5
|
+
* assigns cleanly to Next's `Metadata` — keeping the core framework-agnostic
|
|
6
|
+
* and this subpath dependency-free.
|
|
7
|
+
*
|
|
8
|
+
* Next's typed Metadata API cannot emit arbitrary `property=`-based OG tags
|
|
9
|
+
* (og:type "product", product:price:*, og:locale:alternate). Those come back
|
|
10
|
+
* from `extraOpenGraphTags()` — render them as `<meta property=.../>` in page
|
|
11
|
+
* JSX; React 19 hoists them into <head>.
|
|
12
|
+
*/
|
|
1
13
|
import type { MetaTagsResult, OpenGraphTag } from '../seo/meta-tags.js';
|
|
2
14
|
export interface NextCompatibleMetadata {
|
|
3
15
|
title: string;
|
|
@@ -27,6 +39,12 @@ export interface NextCompatibleMetadata {
|
|
|
27
39
|
images?: string[];
|
|
28
40
|
};
|
|
29
41
|
}
|
|
42
|
+
/** Convert a metaTagsFor() result into a Next `Metadata`-compatible object. */
|
|
30
43
|
export declare function toNextMetadata(result: MetaTagsResult): NextCompatibleMetadata;
|
|
44
|
+
/**
|
|
45
|
+
* OpenGraph tags Next's Metadata API cannot express (og:type=product,
|
|
46
|
+
* product:*, og:locale:alternate). Render each as
|
|
47
|
+
* `<meta property={tag.property} content={tag.content} />` in page JSX.
|
|
48
|
+
*/
|
|
31
49
|
export declare function extraOpenGraphTags(result: MetaTagsResult): OpenGraphTag[];
|
|
32
50
|
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/next/metadata.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/next/metadata.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExE,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE;QACV,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACnC,CAAC;IACF,SAAS,CAAC,EAAE;QACV,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;QAC7B,MAAM,CAAC,EAAE,KAAK,CAAC;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,GAAG,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAC/C,CAAC;IACF,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,SAAS,GAAG,qBAAqB,GAAG,QAAQ,GAAG,KAAK,CAAC;QAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;KACnB,CAAC;CACH;AAmBD,+EAA+E;AAC/E,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,sBAAsB,CA8C7E;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,YAAY,EAAE,CAUzE"}
|
package/dist/next/metadata.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter from the SDK's structured head bundle (`seo.metaTagsFor`) to Next.js
|
|
3
|
+
* App Router `Metadata`. Deliberately ZERO `next` imports: the returned object
|
|
4
|
+
* is typed by a local structural subset (`NextCompatibleMetadata`) that
|
|
5
|
+
* assigns cleanly to Next's `Metadata` — keeping the core framework-agnostic
|
|
6
|
+
* and this subpath dependency-free.
|
|
7
|
+
*
|
|
8
|
+
* Next's typed Metadata API cannot emit arbitrary `property=`-based OG tags
|
|
9
|
+
* (og:type "product", product:price:*, og:locale:alternate). Those come back
|
|
10
|
+
* from `extraOpenGraphTags()` — render them as `<meta property=.../>` in page
|
|
11
|
+
* JSX; React 19 hoists them into <head>.
|
|
12
|
+
*/
|
|
1
13
|
const OG_HANDLED = new Set([
|
|
2
14
|
'og:title',
|
|
3
15
|
'og:description',
|
|
@@ -12,6 +24,7 @@ const TWITTER_CARDS = new Set(['summary', 'summary_large_image', 'player', 'app'
|
|
|
12
24
|
function ogValue(tags, property) {
|
|
13
25
|
return tags.find((t) => t.property === property)?.content;
|
|
14
26
|
}
|
|
27
|
+
/** Convert a metaTagsFor() result into a Next `Metadata`-compatible object. */
|
|
15
28
|
export function toNextMetadata(result) {
|
|
16
29
|
const languages = {};
|
|
17
30
|
for (const link of result.hreflang) {
|
|
@@ -34,6 +47,8 @@ export function toNextMetadata(result) {
|
|
|
34
47
|
url: ogValue(result.openGraph, 'og:url'),
|
|
35
48
|
siteName: ogValue(result.openGraph, 'og:site_name'),
|
|
36
49
|
locale: ogValue(result.openGraph, 'og:locale'),
|
|
50
|
+
// 'product' is not part of Next's typed union — it rides via
|
|
51
|
+
// extraOpenGraphTags() instead.
|
|
37
52
|
type: ogType === 'website' || ogType === 'article' ? ogType : undefined,
|
|
38
53
|
images: ogImages.length > 0 ? ogImages : undefined,
|
|
39
54
|
};
|
|
@@ -51,10 +66,16 @@ export function toNextMetadata(result) {
|
|
|
51
66
|
}
|
|
52
67
|
return metadata;
|
|
53
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* OpenGraph tags Next's Metadata API cannot express (og:type=product,
|
|
71
|
+
* product:*, og:locale:alternate). Render each as
|
|
72
|
+
* `<meta property={tag.property} content={tag.content} />` in page JSX.
|
|
73
|
+
*/
|
|
54
74
|
export function extraOpenGraphTags(result) {
|
|
55
75
|
const ogType = ogValue(result.openGraph, 'og:type');
|
|
56
76
|
return result.openGraph.filter((tag) => {
|
|
57
77
|
if (tag.property === 'og:type') {
|
|
78
|
+
// Only surface og:type here when toNextMetadata could NOT map it.
|
|
58
79
|
return !(ogType === 'website' || ogType === 'article');
|
|
59
80
|
}
|
|
60
81
|
if (tag.property === 'og:locale:alternate')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/next/metadata.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/next/metadata.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA8BH,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,UAAU;IACV,gBAAgB;IAChB,QAAQ;IACR,cAAc;IACd,WAAW;IACX,UAAU;IACV,cAAc;IACd,SAAS;CACV,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,qBAAqB,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;AAEnF,SAAS,OAAO,CAAC,IAAoB,EAAE,QAAgB;IACrD,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,EAAE,OAAO,C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YACpE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS;SACpC,CAAC;IACJ,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAsB;IACvD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACpD,OAAO,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE;QACrC,IAAI,GAAG,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC/B,kEAAkE;YAClE,OAAO,CAAC,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,CAAC,CAAC;QACzD,CAAC;QACD,IAAI,GAAG,CAAC,QAAQ,KAAK,qBAAqB;YAAE,OAAO,IAAI,CAAC;QACxD,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,11 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Middleware factory that applies the tenant's platform-managed redirects.
|
|
3
|
+
*
|
|
4
|
+
* Zero `next` imports by design: it takes a `Request` and returns a plain
|
|
5
|
+
* `Response`, which is exactly what a Next.js middleware may return. It never
|
|
6
|
+
* throws — an unmatched path, a cold cache or an unreachable platform all
|
|
7
|
+
* resolve to `undefined`, meaning "carry on with normal routing".
|
|
8
|
+
*/
|
|
1
9
|
import type { RedirectStore, RedirectStoreConfig } from '../redirects/types.js';
|
|
2
10
|
export interface RedirectMiddlewareOptions extends RedirectStoreConfig {
|
|
11
|
+
/**
|
|
12
|
+
* Carry the incoming query string onto the destination. Default true — a
|
|
13
|
+
* campaign link to a moved page should keep its `utm_*` params. Parameters
|
|
14
|
+
* the destination already sets win.
|
|
15
|
+
*
|
|
16
|
+
* NOTE: this applies to EXTERNAL `https://` destinations too, so the
|
|
17
|
+
* visitor's query string is handed to that third-party origin. If your URLs
|
|
18
|
+
* carry anything you would not want a destination site to see, set this to
|
|
19
|
+
* false — or split those rules onto a middleware instance that has.
|
|
20
|
+
*/
|
|
3
21
|
preserveQuery?: boolean;
|
|
4
22
|
}
|
|
5
23
|
export interface RedirectMiddleware {
|
|
24
|
+
/** Returns a redirect Response, or undefined to fall through. */
|
|
6
25
|
(request: Request): Promise<Response | undefined>;
|
|
26
|
+
/** The underlying store — call `refresh()` from a revalidation webhook. */
|
|
7
27
|
readonly store: RedirectStore;
|
|
8
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Usage (App Router):
|
|
31
|
+
* ```ts
|
|
32
|
+
* // src/middleware.ts
|
|
33
|
+
* import { createRedirectMiddleware } from '@sixtyninecommerce/client/next';
|
|
34
|
+
*
|
|
35
|
+
* const redirects = createRedirectMiddleware({
|
|
36
|
+
* storeCode: process.env.STORE_CODE!,
|
|
37
|
+
* pluginsUrl: process.env.PLUGINS_URL,
|
|
38
|
+
* onError: (error) => console.error('[redirects]', error),
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* export async function middleware(request: Request) {
|
|
42
|
+
* return (await redirects(request)) ?? undefined;
|
|
43
|
+
* }
|
|
44
|
+
*
|
|
45
|
+
* export const config = { matcher: ['/((?!_next|api|.*\\..*).*)'] };
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
9
48
|
export declare function createRedirectMiddleware(options: RedirectMiddlewareOptions | {
|
|
10
49
|
store: RedirectStore;
|
|
11
50
|
preserveQuery?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redirect-middleware.d.ts","sourceRoot":"","sources":["../../src/next/redirect-middleware.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"redirect-middleware.d.ts","sourceRoot":"","sources":["../../src/next/redirect-middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEhF,MAAM,WAAW,yBAA0B,SAAQ,mBAAmB;IACpE;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,kBAAkB;IACjC,iEAAiE;IACjE,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC;IAClD,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;CAC/B;AAsBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,yBAAyB,GAAG;IAAE,KAAK,EAAE,aAAa,CAAC;IAAC,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE,GACrF,kBAAkB,CAuBpB"}
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Middleware factory that applies the tenant's platform-managed redirects.
|
|
3
|
+
*
|
|
4
|
+
* Zero `next` imports by design: it takes a `Request` and returns a plain
|
|
5
|
+
* `Response`, which is exactly what a Next.js middleware may return. It never
|
|
6
|
+
* throws — an unmatched path, a cold cache or an unreachable platform all
|
|
7
|
+
* resolve to `undefined`, meaning "carry on with normal routing".
|
|
8
|
+
*/
|
|
1
9
|
import { createRedirectStore } from '../redirects/store.js';
|
|
10
|
+
/**
|
|
11
|
+
* Build the destination URL against the request origin, so a stored path
|
|
12
|
+
* redirects on the storefront's own host and an absolute `https://` target
|
|
13
|
+
* leaves it.
|
|
14
|
+
*/
|
|
2
15
|
function resolveTarget(to, request, preserveQuery) {
|
|
3
16
|
const requestUrl = new URL(request.url);
|
|
4
17
|
const target = new URL(to, requestUrl.origin);
|
|
@@ -11,6 +24,25 @@ function resolveTarget(to, request, preserveQuery) {
|
|
|
11
24
|
}
|
|
12
25
|
return target.toString();
|
|
13
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Usage (App Router):
|
|
29
|
+
* ```ts
|
|
30
|
+
* // src/middleware.ts
|
|
31
|
+
* import { createRedirectMiddleware } from '@sixtyninecommerce/client/next';
|
|
32
|
+
*
|
|
33
|
+
* const redirects = createRedirectMiddleware({
|
|
34
|
+
* storeCode: process.env.STORE_CODE!,
|
|
35
|
+
* pluginsUrl: process.env.PLUGINS_URL,
|
|
36
|
+
* onError: (error) => console.error('[redirects]', error),
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* export async function middleware(request: Request) {
|
|
40
|
+
* return (await redirects(request)) ?? undefined;
|
|
41
|
+
* }
|
|
42
|
+
*
|
|
43
|
+
* export const config = { matcher: ['/((?!_next|api|.*\\..*).*)'] };
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
14
46
|
export function createRedirectMiddleware(options) {
|
|
15
47
|
const preserveQuery = options.preserveQuery ?? true;
|
|
16
48
|
const store = 'store' in options ? options.store : createRedirectStore(options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redirect-middleware.js","sourceRoot":"","sources":["../../src/next/redirect-middleware.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"redirect-middleware.js","sourceRoot":"","sources":["../../src/next/redirect-middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAwB5D;;;;GAIG;AACH,SAAS,aAAa,CAAC,EAAU,EAAE,OAAgB,EAAE,aAAsB;IACzE,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,EAAE,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAE9C,IAAI,aAAa,EAAE,CAAC;QAClB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,UAAU,CAAC,YAAY,EAAE,CAAC;YACnD,IAAI,CAAC,MAAM,CAAC,YA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point.
|
|
3
|
+
* Framework functions (`revalidatePath`/`revalidateTag` from `next/cache`)
|
|
4
|
+
* are INJECTED so this package never imports `next`; the handler itself uses
|
|
5
|
+
* only web-standard Request/Response and is unit-testable anywhere.
|
|
6
|
+
*
|
|
7
|
+
* Requires ISR-capable hosting (the default Next server build) — under
|
|
8
|
+
* `output: 'export'` there is nothing to revalidate at request time.
|
|
9
|
+
*
|
|
10
|
+
* It speaks only the legacy SEO revalidation webhook, which the platform no
|
|
11
|
+
* longer sends (its sender is retired) — a route mounted with it receives
|
|
12
|
+
* nothing. A platform event envelope is refused here with a 400 (no `paths`),
|
|
13
|
+
* so point an event subscription at `createEventRevalidateHandler` instead,
|
|
14
|
+
* on its own route.
|
|
15
|
+
*/
|
|
1
16
|
import type { RevalidateWebhookPayload } from '../revalidation/types.js';
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Options of the legacy SEO webhook handler — use
|
|
19
|
+
* `EventRevalidateHandlerOptions` with `createEventRevalidateHandler`.
|
|
20
|
+
*/
|
|
2
21
|
export interface RevalidateHandlerOptions {
|
|
22
|
+
/** The shared secret the legacy webhook was signed with. Server-only env. */
|
|
3
23
|
secret: string;
|
|
24
|
+
/** Pass `revalidatePath` from 'next/cache'. */
|
|
4
25
|
revalidatePath(path: string, type?: 'page' | 'layout'): void;
|
|
26
|
+
/** Pass `revalidateTag` from 'next/cache' (optional — tags are skipped without it). */
|
|
5
27
|
revalidateTag?(tag: string): void;
|
|
28
|
+
/** Reject deliveries whose occurred_at is older/newer than this. Default 300s. */
|
|
6
29
|
toleranceSeconds?: number;
|
|
30
|
+
/** Observe accepted deliveries (logging, metrics). Errors are swallowed. */
|
|
7
31
|
onEvent?(payload: RevalidateWebhookPayload): void | Promise<void>;
|
|
8
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated The legacy SEO revalidation webhook, which the platform no longer
|
|
35
|
+
* sends. Kept, unchanged, so existing `/api/revalidate` routes still compile.
|
|
36
|
+
* Storefronts subscribe to platform events and mount
|
|
37
|
+
* `createEventRevalidateHandler` at `/api/revalidate/events`.
|
|
38
|
+
*/
|
|
9
39
|
export declare function createRevalidateHandler(options: RevalidateHandlerOptions): (request: Request) => Promise<Response>;
|
|
10
40
|
//# sourceMappingURL=revalidate-handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revalidate-handler.d.ts","sourceRoot":"","sources":["../../src/next/revalidate-handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"revalidate-handler.d.ts","sourceRoot":"","sources":["../../src/next/revalidate-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAKzE;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,6EAA6E;IAC7E,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAAC;IAC7D,uFAAuF;IACvF,aAAa,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,kFAAkF;IAClF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,4EAA4E;IAC5E,OAAO,CAAC,CAAC,OAAO,EAAE,wBAAwB,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnE;AASD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,wBAAwB,GAChC,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAiEzC"}
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route-handler factory for the storefront's /api/revalidate endpoint.
|
|
3
|
+
* Framework functions (`revalidatePath`/`revalidateTag` from `next/cache`)
|
|
4
|
+
* are INJECTED so this package never imports `next`; the handler itself uses
|
|
5
|
+
* only web-standard Request/Response and is unit-testable anywhere.
|
|
6
|
+
*
|
|
7
|
+
* Requires ISR-capable hosting (the default Next server build) — under
|
|
8
|
+
* `output: 'export'` there is nothing to revalidate at request time.
|
|
9
|
+
*
|
|
10
|
+
* It speaks only the legacy SEO revalidation webhook, which the platform no
|
|
11
|
+
* longer sends (its sender is retired) — a route mounted with it receives
|
|
12
|
+
* nothing. A platform event envelope is refused here with a 400 (no `paths`),
|
|
13
|
+
* so point an event subscription at `createEventRevalidateHandler` instead,
|
|
14
|
+
* on its own route.
|
|
15
|
+
*/
|
|
1
16
|
import { verifyWebhookSignature } from '../revalidation/verify.js';
|
|
2
17
|
const DEFAULT_TOLERANCE_SECONDS = 300;
|
|
3
18
|
function json(status, body) {
|
|
@@ -6,6 +21,12 @@ function json(status, body) {
|
|
|
6
21
|
headers: { 'Content-Type': 'application/json' },
|
|
7
22
|
});
|
|
8
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated The legacy SEO revalidation webhook, which the platform no longer
|
|
26
|
+
* sends. Kept, unchanged, so existing `/api/revalidate` routes still compile.
|
|
27
|
+
* Storefronts subscribe to platform events and mount
|
|
28
|
+
* `createEventRevalidateHandler` at `/api/revalidate/events`.
|
|
29
|
+
*/
|
|
9
30
|
export function createRevalidateHandler(options) {
|
|
10
31
|
const tolerance = (options.toleranceSeconds ?? DEFAULT_TOLERANCE_SECONDS) * 1000;
|
|
11
32
|
return async (request) => {
|
|
@@ -56,6 +77,7 @@ export function createRevalidateHandler(options) {
|
|
|
56
77
|
await options.onEvent(payload);
|
|
57
78
|
}
|
|
58
79
|
catch {
|
|
80
|
+
// observer errors must not fail the delivery
|
|
59
81
|
}
|
|
60
82
|
}
|
|
61
83
|
return json(200, { revalidated: true, paths, tags });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revalidate-handler.js","sourceRoot":"","sources":["../../src/next/revalidate-handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"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,GAAG,CAAC,CAAC;wBAC3B,IAAI,EAAE,CAAC;oBACT,CAAC;gBACH,CAAC;YACH,CAAC;YAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;gBACpB,IAAI,CAAC;oBACH,MAAM,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBACjC,CAAC;gBAAC,MAAM,CAAC;oBACP,6CAA6C;gBAC/C,CAAC;YACH,CAAC;YAED,OAAO,IAAI,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACvD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,IAAI,CAAC,GAAG,EAAE;gBACf,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,qBAAqB;aACtE,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/order-scope.d.ts
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
1
|
import type { OrderScope } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Does an order belong to `scope`?
|
|
4
|
+
*
|
|
5
|
+
* THE CASE DIFFERS ON PURPOSE, and this helper is the one place that has to
|
|
6
|
+
* know. The wire and storage value is lower-case (`'consumer'` / `'trade'`) —
|
|
7
|
+
* it is a Vendure `string` custom field with a `varchar(16)` column and a
|
|
8
|
+
* `'consumer'` default — while the client-side {@link OrderScope} union and the
|
|
9
|
+
* `OrderScope` GraphQL enum are upper-case, because that is what a GraphQL enum
|
|
10
|
+
* looks like. So the obvious comparison,
|
|
11
|
+
*
|
|
12
|
+
* order.customFields.orderScope === client.getOrderScope() // never true
|
|
13
|
+
*
|
|
14
|
+
* silently never matches, and a storefront filtering its own order list on it
|
|
15
|
+
* shows an empty page with no error anywhere.
|
|
16
|
+
*
|
|
17
|
+
* Two rules, both mirroring the engine (`scopeOf` in
|
|
18
|
+
* `services/vendure/src/order-scope/order-scope.ts`):
|
|
19
|
+
*
|
|
20
|
+
* - the comparison is case-insensitive;
|
|
21
|
+
* - an ABSENT, null or unrecognised value reads as `CONSUMER`. Every order
|
|
22
|
+
* placed before the scope existed has no value, and the engine treats those
|
|
23
|
+
* as consumer orders — so must a storefront, or a consumer shop's history
|
|
24
|
+
* page loses everything the customer bought before the feature shipped.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* const mine = orders.filter((o) => orderScopeMatches(o.customFields?.orderScope, 'TRADE'));
|
|
28
|
+
*/
|
|
2
29
|
export declare function orderScopeMatches(customFieldValue: string | null | undefined, scope: OrderScope | string): boolean;
|
|
3
30
|
//# sourceMappingURL=order-scope.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order-scope.d.ts","sourceRoot":"","sources":["../src/order-scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"order-scope.d.ts","sourceRoot":"","sources":["../src/order-scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,iBAAiB,CAC/B,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC3C,KAAK,EAAE,UAAU,GAAG,MAAM,GACzB,OAAO,CAOT"}
|
package/dist/order-scope.js
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Does an order belong to `scope`?
|
|
3
|
+
*
|
|
4
|
+
* THE CASE DIFFERS ON PURPOSE, and this helper is the one place that has to
|
|
5
|
+
* know. The wire and storage value is lower-case (`'consumer'` / `'trade'`) —
|
|
6
|
+
* it is a Vendure `string` custom field with a `varchar(16)` column and a
|
|
7
|
+
* `'consumer'` default — while the client-side {@link OrderScope} union and the
|
|
8
|
+
* `OrderScope` GraphQL enum are upper-case, because that is what a GraphQL enum
|
|
9
|
+
* looks like. So the obvious comparison,
|
|
10
|
+
*
|
|
11
|
+
* order.customFields.orderScope === client.getOrderScope() // never true
|
|
12
|
+
*
|
|
13
|
+
* silently never matches, and a storefront filtering its own order list on it
|
|
14
|
+
* shows an empty page with no error anywhere.
|
|
15
|
+
*
|
|
16
|
+
* Two rules, both mirroring the engine (`scopeOf` in
|
|
17
|
+
* `services/vendure/src/order-scope/order-scope.ts`):
|
|
18
|
+
*
|
|
19
|
+
* - the comparison is case-insensitive;
|
|
20
|
+
* - an ABSENT, null or unrecognised value reads as `CONSUMER`. Every order
|
|
21
|
+
* placed before the scope existed has no value, and the engine treats those
|
|
22
|
+
* as consumer orders — so must a storefront, or a consumer shop's history
|
|
23
|
+
* page loses everything the customer bought before the feature shipped.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const mine = orders.filter((o) => orderScopeMatches(o.customFields?.orderScope, 'TRADE'));
|
|
27
|
+
*/
|
|
1
28
|
export function orderScopeMatches(customFieldValue, scope) {
|
|
2
29
|
const normalized = typeof customFieldValue === 'string' ? customFieldValue.trim().toUpperCase() : '';
|
|
3
30
|
const effective = normalized === 'CONSUMER' || normalized === 'TRADE' ? normalized : 'CONSUMER';
|
|
31
|
+
// Both sides are normalised: a JS caller passing 'trade' must match — the helper
|
|
32
|
+
// exists to absorb exactly this casing split, on either argument.
|
|
4
33
|
return effective === String(scope).trim().toUpperCase();
|
|
5
34
|
}
|
|
6
35
|
//# sourceMappingURL=order-scope.js.map
|
package/dist/order-scope.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order-scope.js","sourceRoot":"","sources":["../src/order-scope.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"order-scope.js","sourceRoot":"","sources":["../src/order-scope.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,iBAAiB,CAC/B,gBAA2C,EAC3C,KAA0B;IAE1B,MAAM,UAAU,GACd,OAAO,gBAAgB,KAAK,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACpF,MAAM,SAAS,GAAG,UAAU,KAAK,UAAU,IAAI,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC;IAChG,iFAAiF;IACjF,kEAAkE;IAClE,OAAO,SAAS,KAAK,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAC1D,CAAC"}
|
package/dist/pricing/format.d.ts
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format a price in minor units to a human-readable string.
|
|
3
|
+
* Uses Intl.NumberFormat for locale-aware formatting.
|
|
4
|
+
*
|
|
5
|
+
* The platform stores money in a currency's minor units, so the divisor is
|
|
6
|
+
* `10 ** fractionDigits`, NOT a hardcoded 100: EUR/USD have 2 digits (÷100),
|
|
7
|
+
* JPY 0 (÷1 — `2999` is ¥2,999, not ¥30), BHD 3 (÷1000). The digit count comes
|
|
8
|
+
* from the same Intl formatter, so it always matches how the value is rendered.
|
|
9
|
+
*
|
|
10
|
+
* Vendure `LanguageCode` region variants use underscores (`pt_BR`, `zh_Hans`),
|
|
11
|
+
* which are not valid BCP-47 separators and make `Intl.NumberFormat` throw —
|
|
12
|
+
* normalize to hyphens so a channel default language can be passed straight in.
|
|
13
|
+
*/
|
|
1
14
|
export declare function formatPrice(amount: number, currencyCode: string, locale?: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Format a price range from two minor-unit amounts.
|
|
17
|
+
* Returns "€10.00 - €20.00" or the single price if min === max.
|
|
18
|
+
*/
|
|
2
19
|
export declare function formatPriceRange(min: number, max: number, currencyCode: string, locale?: string): string;
|
|
3
20
|
//# sourceMappingURL=format.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/pricing/format.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/pricing/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CASzF;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,EACpB,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,CAKR"}
|
package/dist/pricing/format.js
CHANGED
|
@@ -1,11 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format a price in minor units to a human-readable string.
|
|
3
|
+
* Uses Intl.NumberFormat for locale-aware formatting.
|
|
4
|
+
*
|
|
5
|
+
* The platform stores money in a currency's minor units, so the divisor is
|
|
6
|
+
* `10 ** fractionDigits`, NOT a hardcoded 100: EUR/USD have 2 digits (÷100),
|
|
7
|
+
* JPY 0 (÷1 — `2999` is ¥2,999, not ¥30), BHD 3 (÷1000). The digit count comes
|
|
8
|
+
* from the same Intl formatter, so it always matches how the value is rendered.
|
|
9
|
+
*
|
|
10
|
+
* Vendure `LanguageCode` region variants use underscores (`pt_BR`, `zh_Hans`),
|
|
11
|
+
* which are not valid BCP-47 separators and make `Intl.NumberFormat` throw —
|
|
12
|
+
* normalize to hyphens so a channel default language can be passed straight in.
|
|
13
|
+
*/
|
|
1
14
|
export function formatPrice(amount, currencyCode, locale) {
|
|
2
15
|
const format = new Intl.NumberFormat((locale ?? 'en').replace(/_/g, '-'), {
|
|
3
16
|
style: 'currency',
|
|
4
17
|
currency: currencyCode,
|
|
5
18
|
});
|
|
19
|
+
// `currency` style always resolves a digit count; `?? 2` is a defensive
|
|
20
|
+
// fallback for the base type only (`maximumFractionDigits` is `number | undefined`).
|
|
6
21
|
const fractionDigits = format.resolvedOptions().maximumFractionDigits ?? 2;
|
|
7
22
|
return format.format(amount / 10 ** fractionDigits);
|
|
8
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Format a price range from two minor-unit amounts.
|
|
26
|
+
* Returns "€10.00 - €20.00" or the single price if min === max.
|
|
27
|
+
*/
|
|
9
28
|
export function formatPriceRange(min, max, currencyCode, locale) {
|
|
10
29
|
if (min === max) {
|
|
11
30
|
return formatPrice(min, currencyCode, locale);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/pricing/format.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/pricing/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc,EAAE,YAAoB,EAAE,MAAe;IAC/E,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE;QACxE,KAAK,EAAE,UAAU;QACjB,QAAQ,EAAE,YAAY;KACvB,CAAC,CAAC;IACH,wEAAwE;IACxE,qFAAqF;IACrF,MAAM,cAAc,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC,qBAAqB,IAAI,CAAC,CAAC;IAC3E,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,EAAE,IAAI,cAAc,CAAC,CAAC;AACtD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAW,EACX,GAAW,EACX,YAAoB,EACpB,MAAe;IAEf,IAAI,GAAG,KAAK,GAAG,EAAE,CAAC;QAChB,OAAO,WAAW,CAAC,GAAG,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE,YAAY,EAAE,MAAM,CAAC,MAAM,WAAW,CAAC,GAAG,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,CAAC;AACjG,CAAC"}
|
package/dist/pricing/index.d.ts
CHANGED
|
@@ -3,6 +3,13 @@ import type { PricingModule, StoreContext } from '../types.js';
|
|
|
3
3
|
export { formatPrice, formatPriceRange } from './format.js';
|
|
4
4
|
export { ACTIVE_TAX_DISPLAY_MODE, DEFAULT_TAX_DISPLAY_POLICY, identityStamp, parseTaxDisplayPolicy, parseTaxExclusiveCountries, resolveTaxDisplayMode, taxDisplayModeFromEnum, } from './tax-display.js';
|
|
5
5
|
export { computeTierTable, getTierForQuantity } from './tiers.js';
|
|
6
|
-
export { validateOrderMinimums } from './validation.js';
|
|
6
|
+
export { backorderedQuantityForCart, isBackorderOnly, maxOrderableQuantity, type OrderableStockInput, validateOrderMinimums, } from './validation.js';
|
|
7
|
+
/**
|
|
8
|
+
* @param http Optional Shop API client. Without it the module is fully offline
|
|
9
|
+
* (formatting, tier maths, the pure policy helpers) and
|
|
10
|
+
* `getTaxDisplayMode()` degrades to the channel storage mode rather than
|
|
11
|
+
* failing — which is what the `@sixtyninecommerce/client/pricing` subpath and
|
|
12
|
+
* the existing single-argument callers get.
|
|
13
|
+
*/
|
|
7
14
|
export declare function createPricingModule(ctx: StoreContext, http?: HttpClient): PricingModule;
|
|
8
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pricing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAEV,aAAa,EACb,YAAY,EAGb,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pricing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAEV,aAAa,EACb,YAAY,EAGb,MAAM,aAAa,CAAC;AAiBrB,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,aAAa,EACb,qBAAqB,EACrB,0BAA0B,EAC1B,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EACL,0BAA0B,EAC1B,eAAe,EACf,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,YAAY,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,aAAa,CA8GvF"}
|
package/dist/pricing/index.js
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import { formatPrice, formatPriceRange } from './format.js';
|
|
2
2
|
import { ACTIVE_TAX_DISPLAY_MODE, identityStamp, parseTaxDisplayPolicy, resolveTaxDisplayMode, taxDisplayModeFromEnum, } from './tax-display.js';
|
|
3
3
|
import { computeTierTable, getTierForQuantity } from './tiers.js';
|
|
4
|
-
import { validateOrderMinimums } from './validation.js';
|
|
4
|
+
import { backorderedQuantityForCart, isBackorderOnly, maxOrderableQuantity, validateOrderMinimums, } from './validation.js';
|
|
5
5
|
export { formatPrice, formatPriceRange } from './format.js';
|
|
6
6
|
export { ACTIVE_TAX_DISPLAY_MODE, DEFAULT_TAX_DISPLAY_POLICY, identityStamp, parseTaxDisplayPolicy, parseTaxExclusiveCountries, resolveTaxDisplayMode, taxDisplayModeFromEnum, } from './tax-display.js';
|
|
7
7
|
export { computeTierTable, getTierForQuantity } from './tiers.js';
|
|
8
|
-
export { validateOrderMinimums } from './validation.js';
|
|
8
|
+
export { backorderedQuantityForCart, isBackorderOnly, maxOrderableQuantity, validateOrderMinimums, } from './validation.js';
|
|
9
|
+
/**
|
|
10
|
+
* @param http Optional Shop API client. Without it the module is fully offline
|
|
11
|
+
* (formatting, tier maths, the pure policy helpers) and
|
|
12
|
+
* `getTaxDisplayMode()` degrades to the channel storage mode rather than
|
|
13
|
+
* failing — which is what the `@sixtyninecommerce/client/pricing` subpath and
|
|
14
|
+
* the existing single-argument callers get.
|
|
15
|
+
*/
|
|
9
16
|
export function createPricingModule(ctx, http) {
|
|
17
|
+
/** The pre-policy behaviour: display in whatever basis the channel stores. */
|
|
10
18
|
const storageMode = () => (ctx.pricesIncludeTax ? 'gross' : 'net');
|
|
19
|
+
/** The cached mode, but only while it belongs to the current identity. */
|
|
11
20
|
const cachedMode = () => {
|
|
12
21
|
const cached = ctx.taxDisplay;
|
|
13
22
|
return cached && cached.stamp === identityStamp(ctx) ? cached.mode : null;
|
|
@@ -28,10 +37,14 @@ export function createPricingModule(ctx, http) {
|
|
|
28
37
|
mode = taxDisplayModeFromEnum(data?.activeTaxDisplayMode);
|
|
29
38
|
}
|
|
30
39
|
catch {
|
|
40
|
+
// Unreachable engine, an expired session, an engine predating the
|
|
41
|
+
// query — never fail a render over the display mode.
|
|
31
42
|
mode = null;
|
|
32
43
|
}
|
|
33
44
|
if (mode === null)
|
|
34
45
|
return storageMode();
|
|
46
|
+
// Stamp AFTER the round-trip: the response may have rotated the session
|
|
47
|
+
// token, and the answer belongs to the identity that now holds.
|
|
35
48
|
ctx.taxDisplay = { stamp: identityStamp(ctx), mode };
|
|
36
49
|
return mode;
|
|
37
50
|
},
|
|
@@ -85,6 +98,9 @@ export function createPricingModule(ctx, http) {
|
|
|
85
98
|
};
|
|
86
99
|
},
|
|
87
100
|
validateOrderMinimums,
|
|
101
|
+
maxOrderableQuantity,
|
|
102
|
+
isBackorderOnly,
|
|
103
|
+
backorderedQuantityForCart,
|
|
88
104
|
};
|
|
89
105
|
}
|
|
90
106
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pricing/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EACL,uBAAuB,EACvB,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pricing/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EACL,uBAAuB,EACvB,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EACL,0BAA0B,EAC1B,eAAe,EACf,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,aAAa,EACb,qBAAqB,EACrB,0BAA0B,EAC1B,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EACL,0BAA0B,EAC1B,eAAe,EACf,oBAAoB,EAEpB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAiB,EAAE,IAAiB;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