@tanqory/theme-kit 0.1.0 → 2.0.0-alpha.3
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/LICENSE +21 -0
- package/README.md +98 -10
- package/dist/abi/canvas-live.d.ts +49 -0
- package/dist/abi/canvas-live.js +88 -0
- package/dist/abi/cart.d.ts +48 -0
- package/dist/abi/cart.js +256 -0
- package/dist/abi/convert.d.ts +126 -0
- package/dist/abi/convert.js +493 -0
- package/dist/abi/data-api.d.ts +11 -0
- package/dist/abi/data-api.js +178 -0
- package/dist/abi/jcs.d.ts +6 -0
- package/dist/abi/jcs.js +28 -0
- package/dist/abi/page-data.d.ts +198 -0
- package/dist/abi/page-data.js +577 -0
- package/dist/abi/page.d.ts +23 -0
- package/dist/abi/page.js +46 -0
- package/dist/abi/referrals.d.ts +23 -0
- package/dist/abi/referrals.js +89 -0
- package/dist/abi/rewards.d.ts +27 -0
- package/dist/abi/rewards.js +82 -0
- package/dist/abi/seo.d.ts +47 -0
- package/dist/abi/seo.js +68 -0
- package/dist/abi/shell.d.ts +22 -0
- package/dist/abi/shell.js +10 -0
- package/dist/abi/wire.d.ts +38 -0
- package/dist/abi/wire.js +84 -0
- package/dist/build.d.ts +113 -0
- package/dist/build.js +294 -0
- package/dist/client.d.ts +19 -0
- package/dist/client.js +76 -0
- package/dist/contract.d.ts +6 -0
- package/dist/contract.js +6 -0
- package/dist/headless/ai.d.ts +132 -0
- package/dist/headless/ai.js +99 -0
- package/dist/headless/hooks.d.ts +273 -0
- package/dist/headless/hooks.js +533 -0
- package/dist/headless/i18n.d.ts +13 -0
- package/dist/headless/i18n.js +45 -0
- package/dist/headless/index.d.ts +36 -0
- package/dist/headless/index.js +38 -0
- package/dist/headless/money.d.ts +25 -0
- package/dist/headless/money.js +61 -0
- package/dist/headless/page.d.ts +43 -0
- package/dist/headless/page.js +53 -0
- package/dist/headless/platform.d.ts +55 -0
- package/dist/headless/platform.js +77 -0
- package/dist/headless/primitives/cart.d.ts +90 -0
- package/dist/headless/primitives/cart.js +153 -0
- package/dist/headless/primitives/collection.d.ts +68 -0
- package/dist/headless/primitives/collection.js +80 -0
- package/dist/headless/primitives/product.d.ts +101 -0
- package/dist/headless/primitives/product.js +117 -0
- package/dist/headless/primitives/storefront.d.ts +106 -0
- package/dist/headless/primitives/storefront.js +186 -0
- package/dist/headless/primitives/util.d.ts +19 -0
- package/dist/headless/primitives/util.js +42 -0
- package/dist/headless/strings.d.ts +9 -0
- package/dist/headless/strings.js +186 -0
- package/dist/headless/structured-data.d.ts +31 -0
- package/dist/headless/structured-data.js +57 -0
- package/dist/headless/theme.d.ts +99 -0
- package/dist/headless/theme.js +54 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +18 -553
- package/dist/runtime/data/StoreProvider.d.ts +56 -0
- package/dist/runtime/data/StoreProvider.js +308 -0
- package/dist/runtime/data/handle.d.ts +14 -0
- package/dist/runtime/data/handle.js +16 -0
- package/dist/runtime/data/routes.d.ts +87 -0
- package/dist/runtime/data/routes.js +154 -0
- package/dist/runtime/data/to-ui.d.ts +237 -0
- package/dist/runtime/data/to-ui.js +759 -0
- package/dist/runtime/entries/register.d.ts +9 -0
- package/dist/runtime/entries/register.js +9 -0
- package/dist/runtime/entries/sections.d.ts +16 -0
- package/dist/runtime/entries/sections.js +19 -0
- package/dist/{types → runtime/kit}/SectionTree.d.ts +2 -1
- package/dist/runtime/kit/SectionTree.js +100 -0
- package/dist/runtime/kit/analytics.d.ts +63 -0
- package/dist/runtime/kit/analytics.js +233 -0
- package/dist/runtime/kit/cart.d.ts +167 -0
- package/dist/runtime/kit/cart.js +544 -0
- package/dist/{types → runtime/kit}/composition.d.ts +1 -1
- package/dist/runtime/kit/composition.js +3 -0
- package/dist/{types → runtime/kit}/config.d.ts +2 -2
- package/dist/runtime/kit/config.js +6 -0
- package/dist/runtime/kit/consent.d.ts +29 -0
- package/dist/runtime/kit/consent.js +159 -0
- package/dist/runtime/kit/contract/content.d.ts +164 -0
- package/dist/runtime/kit/contract/content.js +83 -0
- package/dist/runtime/kit/contract/field-types.d.ts +290 -0
- package/dist/runtime/kit/contract/field-types.js +129 -0
- package/dist/runtime/kit/contract/groups.d.ts +230 -0
- package/dist/runtime/kit/contract/groups.js +402 -0
- package/dist/runtime/kit/contract/index.d.ts +33 -0
- package/dist/runtime/kit/contract/index.js +33 -0
- package/dist/runtime/kit/contract/transform.d.ts +82 -0
- package/dist/runtime/kit/contract/transform.js +133 -0
- package/dist/runtime/kit/contract/validate.d.ts +67 -0
- package/dist/runtime/kit/contract/validate.js +388 -0
- package/dist/{types → runtime/kit}/data.d.ts +276 -7
- package/dist/runtime/kit/data.js +1117 -0
- package/dist/{types → runtime/kit}/defineSection.d.ts +1 -1
- package/dist/runtime/kit/defineSection.js +10 -0
- package/dist/{types → runtime/kit}/dynamic-source.d.ts +4 -4
- package/dist/runtime/kit/dynamic-source.js +143 -0
- package/dist/runtime/kit/index.d.ts +24 -0
- package/dist/runtime/kit/index.js +24 -0
- package/dist/{types → runtime/kit}/jsx-to-json.d.ts +1 -1
- package/dist/runtime/kit/jsx-to-json.js +28 -0
- package/dist/{types → runtime/kit}/mount.d.ts +25 -4
- package/dist/runtime/kit/mount.js +124 -0
- package/dist/{types → runtime/kit}/registry.d.ts +1 -1
- package/dist/runtime/kit/registry.js +12 -0
- package/dist/{types → runtime/kit}/ssg.d.ts +9 -3
- package/dist/runtime/kit/ssg.js +56 -0
- package/dist/{types → runtime/kit}/storefront.d.ts +206 -7
- package/dist/runtime/kit/storefront.js +723 -0
- package/dist/{types → runtime/kit}/theme-context.d.ts +8 -2
- package/dist/runtime/kit/theme-context.js +25 -0
- package/dist/runtime/kit/types.d.ts +142 -0
- package/dist/runtime/kit/types.js +1 -0
- package/dist/runtime/platform/TrackingPixels.d.ts +14 -0
- package/dist/runtime/platform/TrackingPixels.js +63 -0
- package/dist/runtime/platform/environment.d.ts +68 -0
- package/dist/runtime/platform/environment.js +85 -0
- package/dist/runtime/platform/locale.d.ts +27 -0
- package/dist/runtime/platform/locale.js +42 -0
- package/dist/runtime/platform/route-analytics.d.ts +15 -0
- package/dist/runtime/platform/route-analytics.js +72 -0
- package/dist/runtime/platform/safe-href.d.ts +25 -0
- package/dist/runtime/platform/safe-href.js +69 -0
- package/dist/runtime/platform/safe-values.d.ts +37 -0
- package/dist/runtime/platform/safe-values.js +140 -0
- package/dist/runtime/render/SectionRenderer.d.ts +4 -0
- package/dist/runtime/render/SectionRenderer.js +111 -0
- package/dist/runtime/render/listing-query.d.ts +47 -0
- package/dist/runtime/render/listing-query.js +114 -0
- package/dist/runtime/render/localized-copy.d.ts +86 -0
- package/dist/runtime/render/localized-copy.js +129 -0
- package/dist/runtime/render/product-listing.d.ts +11 -0
- package/dist/runtime/render/product-listing.js +240 -0
- package/dist/runtime/render/section-actions.d.ts +44 -0
- package/dist/runtime/render/section-actions.js +169 -0
- package/dist/runtime/render/starter.d.ts +11 -0
- package/dist/runtime/render/starter.js +81 -0
- package/dist/runtime/seo/head.d.ts +87 -0
- package/dist/runtime/seo/head.js +224 -0
- package/dist/runtime/seo/structured-data.d.ts +22 -0
- package/dist/runtime/seo/structured-data.js +115 -0
- package/dist/runtime/shell/PageShell.d.ts +18 -0
- package/dist/runtime/shell/PageShell.js +113 -0
- package/dist/runtime/shell/RuntimeBridge.d.ts +14 -0
- package/dist/runtime/shell/RuntimeBridge.js +82 -0
- package/dist/runtime/shell/overlay-state.d.ts +31 -0
- package/dist/runtime/shell/overlay-state.js +59 -0
- package/dist/runtime/shell/preview-mode.d.ts +2 -0
- package/dist/runtime/shell/preview-mode.js +11 -0
- package/dist/runtime/shell/spa-router.d.ts +14 -0
- package/dist/runtime/shell/spa-router.js +76 -0
- package/dist/runtime/shell/url-redirects.d.ts +6 -0
- package/dist/runtime/shell/url-redirects.js +37 -0
- package/dist/runtime/slots.d.ts +74 -0
- package/dist/runtime/slots.js +16 -0
- package/dist/runtime.d.ts +34 -0
- package/dist/runtime.js +40 -0
- package/dist/sdk/index.d.ts +24 -0
- package/dist/sdk/index.js +24 -0
- package/dist/sdk/referrals.d.ts +62 -0
- package/dist/sdk/referrals.js +20 -0
- package/dist/sdk/rewards.d.ts +85 -0
- package/dist/sdk/rewards.js +29 -0
- package/dist/sdk/runtime-context.d.ts +120 -0
- package/dist/sdk/runtime-context.js +73 -0
- package/dist/sdk/schema.d.ts +197 -0
- package/dist/sdk/schema.js +121 -0
- package/dist/sdk/server-render.d.ts +8 -0
- package/dist/sdk/server-render.js +12 -0
- package/dist/sdk/store-lookup.d.ts +27 -0
- package/dist/sdk/store-lookup.js +29 -0
- package/dist/sdk/store.d.ts +115 -0
- package/dist/sdk/store.js +1 -0
- package/dist/sdk/sx.d.ts +40 -0
- package/dist/sdk/sx.js +112 -0
- package/dist/sdk/theme.d.ts +152 -0
- package/dist/sdk/theme.js +10 -0
- package/dist/sdk/types.d.ts +395 -0
- package/dist/sdk/types.js +7 -0
- package/dist/server.d.ts +65 -0
- package/dist/server.js +370 -0
- package/docs/headless-api.md +220 -0
- package/package.json +77 -23
- package/dist/index.js.map +0 -1
- package/dist/ssg-BZ5FYTw7.js +0 -1802
- package/dist/ssg-BZ5FYTw7.js.map +0 -1
- package/dist/ssg.js +0 -8
- package/dist/ssg.js.map +0 -1
- package/dist/types/cart.d.ts +0 -86
- package/dist/types/editor.d.ts +0 -5
- package/dist/types/index.d.ts +0 -20
- package/dist/types/preview-bridge.d.ts +0 -9
- package/dist/types/types.d.ts +0 -44
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
import { type StorefrontExtensions } from './storefront';
|
|
2
|
+
import { type StorefrontExtensions, type Menu, type Blog, type Shop, type Filter } from './storefront.js';
|
|
3
3
|
export interface Money {
|
|
4
4
|
amount: string;
|
|
5
5
|
currencyCode: string;
|
|
@@ -11,12 +11,71 @@ export interface ProductOption {
|
|
|
11
11
|
export interface ImageRef {
|
|
12
12
|
url: string;
|
|
13
13
|
altText?: string;
|
|
14
|
+
/** Intrinsic pixel dimensions (standard `image.width`/`image.height`). */
|
|
15
|
+
width?: number | null;
|
|
16
|
+
height?: number | null;
|
|
17
|
+
/** width / height (`image.aspect_ratio`) — for responsive layouts. */
|
|
18
|
+
aspectRatio?: number | null;
|
|
14
19
|
}
|
|
15
20
|
/** SEO snapshot (Product/Page/Article). */
|
|
16
21
|
export interface Seo {
|
|
17
22
|
title?: string | null;
|
|
18
23
|
description?: string | null;
|
|
24
|
+
keywords?: string[] | null;
|
|
19
25
|
}
|
|
26
|
+
/** standard `measurement` (a `dimension`/`volume`/`weight` metafield value). */
|
|
27
|
+
export interface Measurement {
|
|
28
|
+
value: number;
|
|
29
|
+
unit: string;
|
|
30
|
+
}
|
|
31
|
+
/** standard `rating` metafield value. */
|
|
32
|
+
export interface Rating {
|
|
33
|
+
value: number;
|
|
34
|
+
scaleMin: number;
|
|
35
|
+
scaleMax: number;
|
|
36
|
+
}
|
|
37
|
+
/** standard `focal_point` — normalized 0..1 crop centre. */
|
|
38
|
+
export interface FocalPoint {
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
}
|
|
42
|
+
/** standard `image_presentation`. */
|
|
43
|
+
export interface ImagePresentation {
|
|
44
|
+
focalPoint?: FocalPoint | null;
|
|
45
|
+
}
|
|
46
|
+
/** standard `model_source` (a 3D model file source). */
|
|
47
|
+
export interface ModelSource {
|
|
48
|
+
url: string;
|
|
49
|
+
format?: string | null;
|
|
50
|
+
mimeType?: string | null;
|
|
51
|
+
filesize?: number | null;
|
|
52
|
+
}
|
|
53
|
+
/** standard `video_source` (one encoding of a hosted video). */
|
|
54
|
+
export interface VideoSource {
|
|
55
|
+
url: string;
|
|
56
|
+
format?: string | null;
|
|
57
|
+
mimeType?: string | null;
|
|
58
|
+
width?: number | null;
|
|
59
|
+
height?: number | null;
|
|
60
|
+
}
|
|
61
|
+
/** standard `generic_file` (a File reference from a metafield). */
|
|
62
|
+
export interface GenericFile {
|
|
63
|
+
id?: string;
|
|
64
|
+
url: string;
|
|
65
|
+
previewImage?: ImageRef | null;
|
|
66
|
+
mimeType?: string | null;
|
|
67
|
+
originalFileSize?: number | null;
|
|
68
|
+
}
|
|
69
|
+
/** standard `recommendations` object — wraps the `productRecommendations()` list. */
|
|
70
|
+
export interface Recommendations {
|
|
71
|
+
products: Product[];
|
|
72
|
+
productsCount: number;
|
|
73
|
+
intent?: 'related' | 'complementary' | string;
|
|
74
|
+
performed?: boolean;
|
|
75
|
+
}
|
|
76
|
+
/** Build a `recommendations` object from a product list (parity with the commerce standard
|
|
77
|
+
* `recommendations` legacy templating object, whose `.products` our API returns directly). */
|
|
78
|
+
export declare function toRecommendations(products: Product[], intent?: string): Recommendations;
|
|
20
79
|
/** Per-variant cart quantity bounds (wholesale / case-of-N). Storefront cart enforces these. */
|
|
21
80
|
export interface QuantityRule {
|
|
22
81
|
minimum: number;
|
|
@@ -75,6 +134,21 @@ export interface ProductVariant {
|
|
|
75
134
|
image?: ImageRef | null;
|
|
76
135
|
/** Stock-keeping unit. Only after `fetchProduct()`. */
|
|
77
136
|
sku?: string | null;
|
|
137
|
+
/** Barcode (ISBN, UPC, GTIN…). Only after `fetchProduct()`. */
|
|
138
|
+
barcode?: string | null;
|
|
139
|
+
/** On-hand stock for this variant (`inventory_quantity`). */
|
|
140
|
+
inventoryQuantity?: number | null;
|
|
141
|
+
/** `DENY` (stop selling at 0) or `CONTINUE` (oversell) — standard `inventory_policy`. */
|
|
142
|
+
inventoryPolicy?: 'DENY' | 'CONTINUE' | null;
|
|
143
|
+
/** Whether the variant needs shipping (physical vs digital/service). */
|
|
144
|
+
requiresShipping?: boolean | null;
|
|
145
|
+
/** Whether tax applies to the variant. */
|
|
146
|
+
taxable?: boolean | null;
|
|
147
|
+
/** Physical weight (for shipping display). */
|
|
148
|
+
weight?: {
|
|
149
|
+
value: number;
|
|
150
|
+
unit: string;
|
|
151
|
+
} | null;
|
|
78
152
|
/** Cart quantity bounds (min/max/increment). */
|
|
79
153
|
quantityRule?: QuantityRule;
|
|
80
154
|
/** Per-unit price ("$2.50 / 100ml") for measured products. */
|
|
@@ -86,46 +160,107 @@ export interface ProductVariant {
|
|
|
86
160
|
export interface Product {
|
|
87
161
|
/** Storefront GraphQL node id (present for live data). */
|
|
88
162
|
id?: string;
|
|
163
|
+
/** commerce-standard theme template variant (e.g. "bundle"). */
|
|
164
|
+
templateSuffix?: string | null;
|
|
89
165
|
handle: string;
|
|
90
166
|
title: string;
|
|
91
167
|
price: Money;
|
|
92
|
-
/**
|
|
168
|
+
/** Highest variant price, when it differs from `price` — a card says "From". */
|
|
169
|
+
priceMax?: Money;
|
|
170
|
+
/** "Was" price paired with `price` (the lowest compareAtPrice) — sale badge on cards. */
|
|
93
171
|
compareAtPrice?: Money | null;
|
|
94
172
|
featuredImage?: ImageRef | null;
|
|
95
173
|
/** Default purchasable variant id (`firstAvailableVariant`) — enough to add
|
|
96
174
|
* to cart from a grid/card without loading the full variant list. */
|
|
97
175
|
variantId?: string;
|
|
98
176
|
availableForSale?: boolean;
|
|
177
|
+
/** The product's own low-stock threshold (Theme ABI `Product.lowStockThreshold`), when the merchant set one. */
|
|
178
|
+
lowStockThreshold?: number;
|
|
99
179
|
/** Catalog facets (card badges / filtering). Present from boot. */
|
|
100
180
|
vendor?: string | null;
|
|
101
181
|
productType?: string | null;
|
|
102
182
|
tags?: string[];
|
|
103
|
-
/**
|
|
183
|
+
/** Publish/create timestamps (standard `product.published_at`/`created_at`). */
|
|
184
|
+
publishedAt?: string | null;
|
|
185
|
+
createdAt?: string | null;
|
|
186
|
+
/** Canonical storefront URL (`product.url`). */
|
|
187
|
+
onlineStoreUrl?: string | null;
|
|
188
|
+
/** Long description as PLAINTEXT — only populated by `fetchProduct()` (PDP). */
|
|
104
189
|
description?: string;
|
|
190
|
+
/**
|
|
191
|
+
* The same body WITH the merchant's formatting (`Product.descriptionHtml`,
|
|
192
|
+
* `@cost(value: 0)`), already sanitised by store-api. Only populated by
|
|
193
|
+
* `fetchProduct()` (PDP). A theme renders it as HTML and must not re-sanitise
|
|
194
|
+
* it; `description` is the plaintext fallback for text-only surfaces.
|
|
195
|
+
*/
|
|
196
|
+
descriptionHtml?: string;
|
|
105
197
|
/** Image gallery — only after `fetchProduct()` (PDP). */
|
|
106
198
|
images?: ImageRef[];
|
|
199
|
+
/** Full media gallery incl. video / 3D (`product.media`) — after `fetchProduct()`. */
|
|
200
|
+
media?: ProductMedia[];
|
|
107
201
|
/** Option definitions (Size, Color…) — only after `fetchProduct()`. */
|
|
108
202
|
options?: ProductOption[];
|
|
109
203
|
/** Full variant list — only after `fetchProduct()` (PDP). */
|
|
110
204
|
variants?: ProductVariant[];
|
|
111
205
|
/** Subscription / selling-plan groups — only after `fetchProduct()`. */
|
|
112
206
|
sellingPlanGroups?: SellingPlanGroup[];
|
|
207
|
+
/** Collections this product belongs to (`product.collections`) — after `fetchProduct()`. */
|
|
208
|
+
collections?: Array<{
|
|
209
|
+
handle: string;
|
|
210
|
+
title: string;
|
|
211
|
+
}>;
|
|
212
|
+
/** True for gift-card products (`product.gift_card`) — after `fetchProduct()`. */
|
|
213
|
+
isGiftCard?: boolean;
|
|
214
|
+
/** Total on-hand stock across variants (`product.totalInventory`). */
|
|
215
|
+
totalInventory?: number | null;
|
|
113
216
|
/** Requested custom metafields ("namespace.key" → value) — pass identifiers to fetchProduct(). */
|
|
114
217
|
metafields?: Record<string, string | null>;
|
|
115
218
|
/** SEO override — only after `fetchProduct()`. */
|
|
116
219
|
seo?: Seo | null;
|
|
117
220
|
}
|
|
221
|
+
/** A product media node — image, video, 3D model, or external (YouTube/Vimeo) video. */
|
|
222
|
+
export interface ProductMedia {
|
|
223
|
+
id: string;
|
|
224
|
+
type: 'image' | 'video' | 'model_3d' | 'external_video';
|
|
225
|
+
alt?: string | null;
|
|
226
|
+
/** Present for `image`. */
|
|
227
|
+
image?: ImageRef | null;
|
|
228
|
+
/** Poster frame for video / 3D. */
|
|
229
|
+
previewImage?: ImageRef | null;
|
|
230
|
+
/** Playable/loadable sources for `video` / `model_3d`. */
|
|
231
|
+
sources?: {
|
|
232
|
+
url: string;
|
|
233
|
+
mimeType?: string | null;
|
|
234
|
+
format?: string | null;
|
|
235
|
+
}[];
|
|
236
|
+
/** For `external_video` — 'YOUTUBE' | 'VIMEO'. */
|
|
237
|
+
host?: string | null;
|
|
238
|
+
/** For `external_video` — the embed URL. */
|
|
239
|
+
embedUrl?: string | null;
|
|
240
|
+
}
|
|
118
241
|
export interface Collection {
|
|
242
|
+
/** Backend collection id (`collection.id`). */
|
|
243
|
+
id?: string;
|
|
244
|
+
/** commerce-standard theme template variant (e.g. "featured"). */
|
|
245
|
+
templateSuffix?: string | null;
|
|
119
246
|
handle: string;
|
|
120
247
|
title: string;
|
|
248
|
+
/** Collection body/description HTML (`collection.description`). */
|
|
249
|
+
description?: string | null;
|
|
121
250
|
/** Optional hero image; falls back to first product's featuredImage. */
|
|
122
251
|
image?: {
|
|
123
252
|
url?: string;
|
|
124
253
|
altText?: string;
|
|
125
254
|
} | null;
|
|
126
255
|
products: Product[];
|
|
256
|
+
/** Total number of products in the collection (`products_count`). */
|
|
257
|
+
productsCount?: number;
|
|
127
258
|
/** Custom metafields ("namespace.key" → value) for dynamic sources. */
|
|
128
259
|
metafields?: Record<string, string | null>;
|
|
260
|
+
/** SEO title/description (merchant-edited) for the document head. */
|
|
261
|
+
seo?: Seo | null;
|
|
262
|
+
/** The collection's facets, when the platform answered them (Theme ABI `Collection.filters`). */
|
|
263
|
+
filters?: Filter[];
|
|
129
264
|
}
|
|
130
265
|
export interface Page {
|
|
131
266
|
handle: string;
|
|
@@ -136,12 +271,17 @@ export interface Page {
|
|
|
136
271
|
author?: string | null;
|
|
137
272
|
publishedAt?: string;
|
|
138
273
|
updatedAt?: string;
|
|
274
|
+
/** commerce-standard template suffix (e.g. "contact"); the theme renders
|
|
275
|
+
* templates/page.<suffix>.json when set, else the default page template. */
|
|
276
|
+
templateSuffix?: string | null;
|
|
277
|
+
/** SEO title/description (merchant-edited) for the document head. */
|
|
278
|
+
seo?: Seo | null;
|
|
139
279
|
}
|
|
140
280
|
/**
|
|
141
281
|
* The data interface every block consumes. Themes provide an implementation.
|
|
142
282
|
*
|
|
143
283
|
* Core read methods (collections/products/pages/localization) are always
|
|
144
|
-
* present. The
|
|
284
|
+
* present. The commerce-standard extensions (shop, menus, search, blog,
|
|
145
285
|
* recommendations, metaobjects, customer account) come from `StorefrontExtensions`
|
|
146
286
|
* and are LIVE-ONLY — undefined under mock data, so themes feature-detect them
|
|
147
287
|
* (`data.search?.(...)`, `data.customer?.login(...)`).
|
|
@@ -169,6 +309,18 @@ export interface DataApi extends StorefrontExtensions {
|
|
|
169
309
|
providerPixelId: string | null;
|
|
170
310
|
code: string | null;
|
|
171
311
|
}>>;
|
|
312
|
+
/**
|
|
313
|
+
* "Notify me when it's back": ask store-api to email `email` ONCE when a sold-out variant is available
|
|
314
|
+
* again. `available` = it is in stock right now (nothing stored). Resolves for both; rejects on a
|
|
315
|
+
* transport/HTTP failure so the form can say so. The address is used for this one email only — there is
|
|
316
|
+
* no marketing opt-in on this path.
|
|
317
|
+
*/
|
|
318
|
+
notifyBackInStock?: (input: {
|
|
319
|
+
variantId: string;
|
|
320
|
+
email: string;
|
|
321
|
+
locale?: string;
|
|
322
|
+
country?: string;
|
|
323
|
+
}) => Promise<'subscribed' | 'available'>;
|
|
172
324
|
/** Physical store locations (Settings → Locations) for a store-locator. */
|
|
173
325
|
locations?: () => Promise<Array<{
|
|
174
326
|
id: string;
|
|
@@ -198,6 +350,9 @@ export interface DataApi extends StorefrontExtensions {
|
|
|
198
350
|
* the user is on.
|
|
199
351
|
*/
|
|
200
352
|
pageByHandle: (handle: string) => Page | null;
|
|
353
|
+
/** A page by handle from the storefront — for a page reached by soft navigation;
|
|
354
|
+
* afterwards `pageByHandle` answers for it too. */
|
|
355
|
+
fetchPage?: (handle: string) => Promise<Page | null>;
|
|
201
356
|
/** Localization snapshot — what markets/countries the store has live.
|
|
202
357
|
* null = mock data; the country switcher should hide itself. */
|
|
203
358
|
localization: Localization | null;
|
|
@@ -243,6 +398,55 @@ export interface DataApi extends StorefrontExtensions {
|
|
|
243
398
|
* the client's first render match by construction.
|
|
244
399
|
*/
|
|
245
400
|
getSnapshot?: () => unknown;
|
|
401
|
+
/** Records the server loaded for this route before rendering (`blog:<handle>`,
|
|
402
|
+
* `article:<blog>/<handle>`), keyed like the page's resource cache — so the
|
|
403
|
+
* server html carries them and hydration starts with them instead of refetching. */
|
|
404
|
+
preloaded?: Record<string, unknown>;
|
|
405
|
+
/** The policy handle this page renders (a `/policies/<handle>` route). */
|
|
406
|
+
policyHandle?: string;
|
|
407
|
+
/** A published policy by handle (browser: through /_tq), null when the store has not published it. */
|
|
408
|
+
fetchPolicy?: (handle: string) => Promise<import('./storefront.js').ShopPolicy | null>;
|
|
409
|
+
/** Whether the shopper has a customer session — not who (ABI `request.isSignedIn`). */
|
|
410
|
+
signedIn?: boolean;
|
|
411
|
+
/** ABI consent (browser only): `consent.get` / `consent.set` through /_tq. */
|
|
412
|
+
consent?: {
|
|
413
|
+
get: () => Promise<{
|
|
414
|
+
known: boolean;
|
|
415
|
+
analytics: boolean;
|
|
416
|
+
marketing: boolean;
|
|
417
|
+
functional: boolean;
|
|
418
|
+
region?: string;
|
|
419
|
+
bannerRequired: boolean;
|
|
420
|
+
geo?: {
|
|
421
|
+
country?: string;
|
|
422
|
+
region?: string;
|
|
423
|
+
};
|
|
424
|
+
regionRequiresBanner?: boolean;
|
|
425
|
+
}>;
|
|
426
|
+
set: (input: {
|
|
427
|
+
analytics: boolean;
|
|
428
|
+
marketing: boolean;
|
|
429
|
+
functional: boolean;
|
|
430
|
+
region?: string;
|
|
431
|
+
}) => Promise<void>;
|
|
432
|
+
};
|
|
433
|
+
/** Synchronous reads of what the server already loaded for this page (server and hydrating browser alike). */
|
|
434
|
+
blogSync?: (handle: string) => import('./storefront.js').Blog | null;
|
|
435
|
+
articleSync?: (blogHandle: string, handle: string) => import('./storefront.js').Article | null;
|
|
436
|
+
searchSync?: (query: string, sort?: string) => import('./storefront.js').SearchResults | null;
|
|
437
|
+
recommendationsSync?: (productHandle: string) => Product[] | null;
|
|
438
|
+
/** The route names a resource the platform does not have: the page answers 404. */
|
|
439
|
+
routeMissing?: boolean;
|
|
440
|
+
/** The Account BFF URL for the account slot. */
|
|
441
|
+
accountUrl?: (path?: 'orders' | 'addresses' | 'profile') => string;
|
|
442
|
+
/** The platform form endpoint of this page (ABI native forms), when the host has one. */
|
|
443
|
+
formEndpoint?: string;
|
|
444
|
+
/** The outcome of the native form POST this page answers. */
|
|
445
|
+
formResult?: {
|
|
446
|
+
formId: string;
|
|
447
|
+
status: 'ok' | 'invalid' | 'rate_limited' | 'unavailable' | 'expired';
|
|
448
|
+
email?: string;
|
|
449
|
+
};
|
|
246
450
|
}
|
|
247
451
|
/** Country/market shape mirrored from storefront GraphQL `Localization`. */
|
|
248
452
|
export interface LocalizedCurrency {
|
|
@@ -260,6 +464,11 @@ export interface LocalizedCountry {
|
|
|
260
464
|
name: string;
|
|
261
465
|
currency: LocalizedCurrency;
|
|
262
466
|
market: LocalizedMarket | null;
|
|
467
|
+
/**
|
|
468
|
+
* The languages this country's market offers, when the platform names them per market
|
|
469
|
+
* (`ctx.locale.markets`). Absent ⇒ every language in `availableLanguages`.
|
|
470
|
+
*/
|
|
471
|
+
availableLanguages?: LocalizedLanguage[];
|
|
263
472
|
}
|
|
264
473
|
/** A language the store has published (dashboard → Markets / Languages). */
|
|
265
474
|
export interface LocalizedLanguage {
|
|
@@ -287,13 +496,33 @@ export declare function DataProvider({ value, children }: {
|
|
|
287
496
|
children: ReactNode;
|
|
288
497
|
}): JSX.Element;
|
|
289
498
|
export declare function useData(): DataApi;
|
|
499
|
+
type MockLocation = NonNullable<Awaited<ReturnType<NonNullable<DataApi['locations']>>>>[number];
|
|
500
|
+
/**
|
|
501
|
+
* The richer fixture shape `createMockData` also accepts. `app/data/sample-store.json`
|
|
502
|
+
* is a plain `Collection[]` (the theme's own offline fixture); a content pack
|
|
503
|
+
* (`NOVA_CONTENT=<dir>`, e.g. `demo/halden/`) may instead provide this object so
|
|
504
|
+
* its menus, blog, pages, store locations, shop and markets match the store it
|
|
505
|
+
* depicts. Every key is optional; an absent one keeps the built-in sample.
|
|
506
|
+
*/
|
|
507
|
+
export interface MockFixture {
|
|
508
|
+
collections: Collection[];
|
|
509
|
+
menus?: Menu[];
|
|
510
|
+
blogs?: Blog[];
|
|
511
|
+
pages?: Page[];
|
|
512
|
+
locations?: MockLocation[];
|
|
513
|
+
shop?: Partial<Shop>;
|
|
514
|
+
localization?: Localization;
|
|
515
|
+
/** Offline "You may also like": product handle → the handles to recommend,
|
|
516
|
+
* in order. Without an entry, the first four other products. */
|
|
517
|
+
recommendations?: Record<string, string[]>;
|
|
518
|
+
}
|
|
290
519
|
/** Build an offline data source from fixture collections (theme passes its JSON). */
|
|
291
|
-
export declare function createMockData(
|
|
520
|
+
export declare function createMockData(input: Collection[] | MockFixture): DataApi;
|
|
292
521
|
/**
|
|
293
522
|
* Live data source backed by the Tanqory Storefront GraphQL API.
|
|
294
523
|
*
|
|
295
524
|
* const data = await createLiveData({
|
|
296
|
-
* endpoint: 'https://api
|
|
525
|
+
* endpoint: 'https://api.example.com',
|
|
297
526
|
* storeId: '<store-uuid>',
|
|
298
527
|
* token: '<publishable-storefront-token>',
|
|
299
528
|
* prefetch: { collectionLimit: 20, productLimitPerCollection: 24 },
|
|
@@ -310,7 +539,7 @@ export declare function createMockData(collections: Collection[]): DataApi;
|
|
|
310
539
|
* `prefetch.productLimitPerCollection` to cover the catalogue size.
|
|
311
540
|
*/
|
|
312
541
|
export interface LiveDataOptions {
|
|
313
|
-
/** Base URL of the store-api (e.g. https://api
|
|
542
|
+
/** Base URL of the store-api (e.g. https://api.example.com). */
|
|
314
543
|
endpoint: string;
|
|
315
544
|
/** Store UUID (the `:storeId` path param). */
|
|
316
545
|
storeId: string;
|
|
@@ -323,6 +552,13 @@ export interface LiveDataOptions {
|
|
|
323
552
|
* base currency if no Market matches the country.
|
|
324
553
|
*/
|
|
325
554
|
country?: string;
|
|
555
|
+
/**
|
|
556
|
+
* Content language (BCP-47-ish, e.g. "th", "zh-TW"). When set, the backend
|
|
557
|
+
* overlays the merchant's translations for this locale onto product/
|
|
558
|
+
* collection/page content (X-Tanqory-Lang). Falls back to default-language
|
|
559
|
+
* content when a resource has no translation. Independent of `country`.
|
|
560
|
+
*/
|
|
561
|
+
locale?: string;
|
|
326
562
|
/** Optional fetch override (testing / SSR). */
|
|
327
563
|
fetcher?: typeof fetch;
|
|
328
564
|
/**
|
|
@@ -332,6 +568,13 @@ export interface LiveDataOptions {
|
|
|
332
568
|
* `dataApi.pageByHandle(handle)` synchronously during hydration.
|
|
333
569
|
*/
|
|
334
570
|
pageHandle?: string;
|
|
571
|
+
/** Handle of the product/collection detail route being loaded, so its
|
|
572
|
+
* template variant (templateSuffix) is prefetched into the bootstrap. */
|
|
573
|
+
productHandle?: string;
|
|
574
|
+
collectionHandle?: string;
|
|
575
|
+
/** A policy route: also load the policies' bodies (the shared bootstrap
|
|
576
|
+
* carries only their titles, which left /policies/* with a heading alone). */
|
|
577
|
+
policyBodies?: boolean;
|
|
335
578
|
/** Tune how much to load at boot. */
|
|
336
579
|
prefetch?: {
|
|
337
580
|
/** Max collections to fetch (default 20). */
|
|
@@ -354,4 +597,30 @@ export declare function createLiveData(opts: LiveDataOptions): Promise<DataApi>;
|
|
|
354
597
|
* mount()'s `revalidate` swaps in fresh data after hydration (SWR).
|
|
355
598
|
*/
|
|
356
599
|
export declare function createLiveDataFromSnapshot(snapshot: unknown, opts: LiveDataOptions): DataApi;
|
|
600
|
+
/** standard `money` — symbol + amount (e.g. "฿120.00"). */
|
|
357
601
|
export declare function formatMoney(money: Money): string;
|
|
602
|
+
/** standard `money_with_currency` — symbol + amount + ISO code (e.g. "฿120.00 THB"). */
|
|
603
|
+
export declare function formatMoneyWithCurrency(money: Money): string;
|
|
604
|
+
/** standard `money_without_currency` — bare grouped amount (e.g. "120.00"). */
|
|
605
|
+
export declare function formatMoneyWithoutCurrency(money: Money): string;
|
|
606
|
+
/** standard `money_without_trailing_zeros` — symbol + amount, dropping a `.00`
|
|
607
|
+
* fraction (e.g. "฿120", but "฿120.50" stays). */
|
|
608
|
+
export declare function formatMoneyWithoutTrailingZeros(money: Money): string;
|
|
609
|
+
/** standard `date` / `time_tag` — format an ISO date deterministically (identical
|
|
610
|
+
* output on server + client to keep SSR hydration stable). Defaults to a medium
|
|
611
|
+
* date; pass Intl options to customize. */
|
|
612
|
+
export declare function formatDate(input: string | number | Date | null | undefined, opts?: Intl.DateTimeFormatOptions, locale?: string): string;
|
|
613
|
+
/** standard `weight_with_unit` — format a variant weight (e.g. "1.5 kg"). */
|
|
614
|
+
export declare function formatWeight(weight: {
|
|
615
|
+
value: number;
|
|
616
|
+
unit: string;
|
|
617
|
+
} | null | undefined): string;
|
|
618
|
+
/** standard `image_url` — append CDN transform params (width/height/crop) to an
|
|
619
|
+
* image URL. No-op when the src is empty or no transform is requested. React
|
|
620
|
+
* themes render the `<img>` themselves, so there is no separate `image_tag`. */
|
|
621
|
+
export declare function imageUrl(src: string | null | undefined, opts?: {
|
|
622
|
+
width?: number;
|
|
623
|
+
height?: number;
|
|
624
|
+
crop?: string;
|
|
625
|
+
}): string;
|
|
626
|
+
export {};
|