@tanqory/theme-kit 0.1.0 → 2.0.0-alpha.17

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.
Files changed (210) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +125 -10
  3. package/dist/abi/canvas-live.d.ts +67 -0
  4. package/dist/abi/canvas-live.js +154 -0
  5. package/dist/abi/cart.d.ts +59 -0
  6. package/dist/abi/cart.js +387 -0
  7. package/dist/abi/convert.d.ts +344 -0
  8. package/dist/abi/convert.js +1278 -0
  9. package/dist/abi/data-api.d.ts +15 -0
  10. package/dist/abi/data-api.js +209 -0
  11. package/dist/abi/jcs.d.ts +6 -0
  12. package/dist/abi/jcs.js +28 -0
  13. package/dist/abi/labels.d.ts +3 -0
  14. package/dist/abi/labels.js +34 -0
  15. package/dist/abi/page-data.d.ts +256 -0
  16. package/dist/abi/page-data.js +678 -0
  17. package/dist/abi/page.d.ts +28 -0
  18. package/dist/abi/page.js +57 -0
  19. package/dist/abi/referrals.d.ts +23 -0
  20. package/dist/abi/referrals.js +89 -0
  21. package/dist/abi/rewards.d.ts +27 -0
  22. package/dist/abi/rewards.js +82 -0
  23. package/dist/abi/seo.d.ts +47 -0
  24. package/dist/abi/seo.js +68 -0
  25. package/dist/abi/shell.d.ts +23 -0
  26. package/dist/abi/shell.js +10 -0
  27. package/dist/abi/state-pack.d.ts +17 -0
  28. package/dist/abi/state-pack.js +43 -0
  29. package/dist/abi/wire.d.ts +38 -0
  30. package/dist/abi/wire.js +84 -0
  31. package/dist/build.d.ts +116 -0
  32. package/dist/build.js +310 -0
  33. package/dist/client.d.ts +19 -0
  34. package/dist/client.js +87 -0
  35. package/dist/contract.d.ts +6 -0
  36. package/dist/contract.js +6 -0
  37. package/dist/headless/ai.d.ts +132 -0
  38. package/dist/headless/ai.js +99 -0
  39. package/dist/headless/hooks.d.ts +276 -0
  40. package/dist/headless/hooks.js +540 -0
  41. package/dist/headless/i18n.d.ts +13 -0
  42. package/dist/headless/i18n.js +45 -0
  43. package/dist/headless/index.d.ts +37 -0
  44. package/dist/headless/index.js +38 -0
  45. package/dist/headless/money.d.ts +25 -0
  46. package/dist/headless/money.js +61 -0
  47. package/dist/headless/page.d.ts +43 -0
  48. package/dist/headless/page.js +53 -0
  49. package/dist/headless/platform.d.ts +55 -0
  50. package/dist/headless/platform.js +77 -0
  51. package/dist/headless/primitives/cart.d.ts +90 -0
  52. package/dist/headless/primitives/cart.js +153 -0
  53. package/dist/headless/primitives/collection.d.ts +68 -0
  54. package/dist/headless/primitives/collection.js +80 -0
  55. package/dist/headless/primitives/product.d.ts +101 -0
  56. package/dist/headless/primitives/product.js +117 -0
  57. package/dist/headless/primitives/storefront.d.ts +106 -0
  58. package/dist/headless/primitives/storefront.js +186 -0
  59. package/dist/headless/primitives/util.d.ts +19 -0
  60. package/dist/headless/primitives/util.js +42 -0
  61. package/dist/headless/strings.d.ts +9 -0
  62. package/dist/headless/strings.js +190 -0
  63. package/dist/headless/structured-data.d.ts +31 -0
  64. package/dist/headless/structured-data.js +57 -0
  65. package/dist/headless/theme.d.ts +99 -0
  66. package/dist/headless/theme.js +54 -0
  67. package/dist/index.d.ts +20 -0
  68. package/dist/index.js +18 -553
  69. package/dist/runtime/data/StoreProvider.d.ts +84 -0
  70. package/dist/runtime/data/StoreProvider.js +373 -0
  71. package/dist/runtime/data/handle.d.ts +14 -0
  72. package/dist/runtime/data/handle.js +16 -0
  73. package/dist/runtime/data/routes.d.ts +87 -0
  74. package/dist/runtime/data/routes.js +158 -0
  75. package/dist/runtime/data/to-ui.d.ts +281 -0
  76. package/dist/runtime/data/to-ui.js +977 -0
  77. package/dist/runtime/entries/register.d.ts +9 -0
  78. package/dist/runtime/entries/register.js +9 -0
  79. package/dist/runtime/entries/sections.d.ts +16 -0
  80. package/dist/runtime/entries/sections.js +19 -0
  81. package/dist/{types → runtime/kit}/SectionTree.d.ts +2 -1
  82. package/dist/runtime/kit/SectionTree.js +100 -0
  83. package/dist/runtime/kit/analytics.d.ts +63 -0
  84. package/dist/runtime/kit/analytics.js +250 -0
  85. package/dist/runtime/kit/cart.d.ts +215 -0
  86. package/dist/runtime/kit/cart.js +545 -0
  87. package/dist/{types → runtime/kit}/composition.d.ts +1 -1
  88. package/dist/runtime/kit/composition.js +3 -0
  89. package/dist/{types → runtime/kit}/config.d.ts +2 -2
  90. package/dist/runtime/kit/config.js +6 -0
  91. package/dist/runtime/kit/consent.d.ts +29 -0
  92. package/dist/runtime/kit/consent.js +159 -0
  93. package/dist/runtime/kit/contract/content.d.ts +199 -0
  94. package/dist/runtime/kit/contract/content.js +106 -0
  95. package/dist/runtime/kit/contract/field-types.d.ts +337 -0
  96. package/dist/runtime/kit/contract/field-types.js +206 -0
  97. package/dist/runtime/kit/contract/groups.d.ts +230 -0
  98. package/dist/runtime/kit/contract/groups.js +402 -0
  99. package/dist/runtime/kit/contract/index.d.ts +33 -0
  100. package/dist/runtime/kit/contract/index.js +33 -0
  101. package/dist/runtime/kit/contract/transform.d.ts +82 -0
  102. package/dist/runtime/kit/contract/transform.js +133 -0
  103. package/dist/runtime/kit/contract/validate.d.ts +75 -0
  104. package/dist/runtime/kit/contract/validate.js +480 -0
  105. package/dist/runtime/kit/data.d.ts +720 -0
  106. package/dist/runtime/kit/data.js +1117 -0
  107. package/dist/{types → runtime/kit}/defineSection.d.ts +1 -1
  108. package/dist/runtime/kit/defineSection.js +10 -0
  109. package/dist/{types → runtime/kit}/dynamic-source.d.ts +40 -18
  110. package/dist/runtime/kit/dynamic-source.js +294 -0
  111. package/dist/runtime/kit/index.d.ts +24 -0
  112. package/dist/runtime/kit/index.js +24 -0
  113. package/dist/{types → runtime/kit}/jsx-to-json.d.ts +1 -1
  114. package/dist/runtime/kit/jsx-to-json.js +28 -0
  115. package/dist/{types → runtime/kit}/mount.d.ts +25 -4
  116. package/dist/runtime/kit/mount.js +124 -0
  117. package/dist/{types → runtime/kit}/registry.d.ts +1 -1
  118. package/dist/runtime/kit/registry.js +12 -0
  119. package/dist/{types → runtime/kit}/ssg.d.ts +9 -3
  120. package/dist/runtime/kit/ssg.js +56 -0
  121. package/dist/runtime/kit/storefront.d.ts +639 -0
  122. package/dist/runtime/kit/storefront.js +723 -0
  123. package/dist/{types → runtime/kit}/theme-context.d.ts +8 -2
  124. package/dist/runtime/kit/theme-context.js +25 -0
  125. package/dist/runtime/kit/types.d.ts +147 -0
  126. package/dist/runtime/kit/types.js +1 -0
  127. package/dist/runtime/platform/TrackingPixels.d.ts +14 -0
  128. package/dist/runtime/platform/TrackingPixels.js +63 -0
  129. package/dist/runtime/platform/environment.d.ts +68 -0
  130. package/dist/runtime/platform/environment.js +85 -0
  131. package/dist/runtime/platform/locale.d.ts +27 -0
  132. package/dist/runtime/platform/locale.js +42 -0
  133. package/dist/runtime/platform/route-analytics.d.ts +15 -0
  134. package/dist/runtime/platform/route-analytics.js +72 -0
  135. package/dist/runtime/platform/safe-href.d.ts +25 -0
  136. package/dist/runtime/platform/safe-href.js +69 -0
  137. package/dist/runtime/platform/safe-values.d.ts +37 -0
  138. package/dist/runtime/platform/safe-values.js +140 -0
  139. package/dist/runtime/render/SectionRenderer.d.ts +4 -0
  140. package/dist/runtime/render/SectionRenderer.js +166 -0
  141. package/dist/runtime/render/listing-query.d.ts +52 -0
  142. package/dist/runtime/render/listing-query.js +122 -0
  143. package/dist/runtime/render/localized-copy.d.ts +86 -0
  144. package/dist/runtime/render/localized-copy.js +129 -0
  145. package/dist/runtime/render/product-listing.d.ts +11 -0
  146. package/dist/runtime/render/product-listing.js +243 -0
  147. package/dist/runtime/render/section-actions.d.ts +66 -0
  148. package/dist/runtime/render/section-actions.js +202 -0
  149. package/dist/runtime/render/starter.d.ts +11 -0
  150. package/dist/runtime/render/starter.js +81 -0
  151. package/dist/runtime/seo/head.d.ts +115 -0
  152. package/dist/runtime/seo/head.js +281 -0
  153. package/dist/runtime/seo/structured-data.d.ts +83 -0
  154. package/dist/runtime/seo/structured-data.js +252 -0
  155. package/dist/runtime/shell/PageShell.d.ts +18 -0
  156. package/dist/runtime/shell/PageShell.js +113 -0
  157. package/dist/runtime/shell/RuntimeBridge.d.ts +14 -0
  158. package/dist/runtime/shell/RuntimeBridge.js +93 -0
  159. package/dist/runtime/shell/overlay-state.d.ts +31 -0
  160. package/dist/runtime/shell/overlay-state.js +59 -0
  161. package/dist/runtime/shell/preview-mode.d.ts +2 -0
  162. package/dist/runtime/shell/preview-mode.js +11 -0
  163. package/dist/runtime/shell/spa-router.d.ts +14 -0
  164. package/dist/runtime/shell/spa-router.js +76 -0
  165. package/dist/runtime/shell/url-redirects.d.ts +6 -0
  166. package/dist/runtime/shell/url-redirects.js +37 -0
  167. package/dist/runtime/slots.d.ts +74 -0
  168. package/dist/runtime/slots.js +16 -0
  169. package/dist/runtime.d.ts +34 -0
  170. package/dist/runtime.js +40 -0
  171. package/dist/sdk/app-block.d.ts +29 -0
  172. package/dist/sdk/app-block.js +22 -0
  173. package/dist/sdk/index.d.ts +26 -0
  174. package/dist/sdk/index.js +26 -0
  175. package/dist/sdk/referrals.d.ts +62 -0
  176. package/dist/sdk/referrals.js +20 -0
  177. package/dist/sdk/rewards.d.ts +85 -0
  178. package/dist/sdk/rewards.js +29 -0
  179. package/dist/sdk/runtime-context.d.ts +202 -0
  180. package/dist/sdk/runtime-context.js +73 -0
  181. package/dist/sdk/schema.d.ts +206 -0
  182. package/dist/sdk/schema.js +121 -0
  183. package/dist/sdk/server-render.d.ts +8 -0
  184. package/dist/sdk/server-render.js +12 -0
  185. package/dist/sdk/store-lookup.d.ts +27 -0
  186. package/dist/sdk/store-lookup.js +29 -0
  187. package/dist/sdk/store.d.ts +149 -0
  188. package/dist/sdk/store.js +5 -0
  189. package/dist/sdk/sx.d.ts +40 -0
  190. package/dist/sdk/sx.js +112 -0
  191. package/dist/sdk/theme.d.ts +191 -0
  192. package/dist/sdk/theme.js +10 -0
  193. package/dist/sdk/types.d.ts +757 -0
  194. package/dist/sdk/types.js +7 -0
  195. package/dist/server.d.ts +111 -0
  196. package/dist/server.js +533 -0
  197. package/docs/headless-api.md +220 -0
  198. package/package.json +76 -22
  199. package/dist/index.js.map +0 -1
  200. package/dist/ssg-BZ5FYTw7.js +0 -1802
  201. package/dist/ssg-BZ5FYTw7.js.map +0 -1
  202. package/dist/ssg.js +0 -8
  203. package/dist/ssg.js.map +0 -1
  204. package/dist/types/cart.d.ts +0 -86
  205. package/dist/types/data.d.ts +0 -357
  206. package/dist/types/editor.d.ts +0 -5
  207. package/dist/types/index.d.ts +0 -20
  208. package/dist/types/preview-bridge.d.ts +0 -9
  209. package/dist/types/storefront.d.ts +0 -333
  210. package/dist/types/types.d.ts +0 -44
@@ -0,0 +1,720 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type StorefrontExtensions, type Menu, type Blog, type Shop, type Filter } from './storefront.js';
3
+ export interface Money {
4
+ amount: string;
5
+ currencyCode: string;
6
+ }
7
+ export interface ProductOption {
8
+ name: string;
9
+ values: string[];
10
+ }
11
+ export interface ImageRef {
12
+ url: string;
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;
19
+ }
20
+ /** SEO snapshot (Product/Page/Article). */
21
+ export interface Seo {
22
+ title?: string | null;
23
+ description?: string | null;
24
+ keywords?: string[] | null;
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;
79
+ /** Per-variant cart quantity bounds (wholesale / case-of-N). Storefront cart enforces these. */
80
+ export interface QuantityRule {
81
+ minimum: number;
82
+ maximum: number | null;
83
+ increment: number;
84
+ }
85
+ /** Per-unit pricing ("$2.50 / 100ml"). */
86
+ export interface UnitPriceMeasurement {
87
+ measuredType: string;
88
+ quantityValue: number;
89
+ quantityUnit: string;
90
+ referenceValue: number;
91
+ referenceUnit: string;
92
+ }
93
+ /** Pickup / in-store stock for one location. */
94
+ export interface StoreAvailability {
95
+ available: boolean;
96
+ quantityAvailable: number;
97
+ pickUpTime?: string | null;
98
+ location: {
99
+ id: string;
100
+ name: string;
101
+ };
102
+ }
103
+ export interface SellingPlanOption {
104
+ name: string;
105
+ value: string;
106
+ }
107
+ export interface SellingPlan {
108
+ id: string;
109
+ name: string;
110
+ description?: string | null;
111
+ recurringDeliveries: boolean;
112
+ options: SellingPlanOption[];
113
+ /** Theme ABI alpha.20 (storefront-query rev 2.39): the delivery schedule and the first-cycle discount, when the source carries them. */
114
+ interval?: 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';
115
+ intervalCount?: number;
116
+ discount?: {
117
+ type: 'percentage' | 'fixed' | 'price';
118
+ value: number;
119
+ } | null;
120
+ }
121
+ export interface SellingPlanGroup {
122
+ /** Theme ABI alpha.20: the group's id; absent on the GraphQL driver, which has none. */
123
+ id?: string;
124
+ name: string;
125
+ appName?: string | null;
126
+ description?: string | null;
127
+ options: Array<{
128
+ name: string;
129
+ values: string[];
130
+ }>;
131
+ sellingPlans: SellingPlan[];
132
+ /** Theme ABI alpha.20: the plans are offered for these variants only; absent ⇒ every variant. */
133
+ variantIds?: string[];
134
+ }
135
+ export interface ProductVariant {
136
+ id: string;
137
+ title: string;
138
+ price: Money;
139
+ /** "Was" price — present when the variant is on sale (compareAtPrice > price). */
140
+ compareAtPrice?: Money | null;
141
+ availableForSale: boolean;
142
+ selectedOptions?: {
143
+ name: string;
144
+ value: string;
145
+ }[];
146
+ image?: ImageRef | null;
147
+ /** Stock-keeping unit. Only after `fetchProduct()`. */
148
+ sku?: string | null;
149
+ /** Barcode (ISBN, UPC, GTIN…). Only after `fetchProduct()`. */
150
+ barcode?: string | null;
151
+ /** On-hand stock for this variant (`inventory_quantity`). */
152
+ inventoryQuantity?: number | null;
153
+ /** rev 2.52 (O3): ids of the store's pickup locations where this variant can be picked up; absent ⇒ unknown. */
154
+ pickupLocationIds?: string[];
155
+ /** `DENY` (stop selling at 0) or `CONTINUE` (oversell) — standard `inventory_policy`. */
156
+ inventoryPolicy?: 'DENY' | 'CONTINUE' | null;
157
+ /** Whether the variant needs shipping (physical vs digital/service). */
158
+ requiresShipping?: boolean | null;
159
+ /** Whether tax applies to the variant. */
160
+ taxable?: boolean | null;
161
+ /** Physical weight (for shipping display). */
162
+ weight?: {
163
+ value: number;
164
+ unit: string;
165
+ } | null;
166
+ /** Cart quantity bounds (min/max/increment). */
167
+ quantityRule?: QuantityRule;
168
+ /** Per-unit price ("$2.50 / 100ml") for measured products. */
169
+ unitPrice?: Money | null;
170
+ unitPriceMeasurement?: UnitPriceMeasurement | null;
171
+ /** Pickup availability per location (only after `fetchProduct()`). */
172
+ storeAvailability?: StoreAvailability[];
173
+ }
174
+ export interface Product {
175
+ /** Storefront GraphQL node id (present for live data). */
176
+ id?: string;
177
+ /** commerce-standard theme template variant (e.g. "bundle"). */
178
+ templateSuffix?: string | null;
179
+ handle: string;
180
+ title: string;
181
+ price: Money;
182
+ /** Highest variant price, when it differs from `price` — a card says "From". */
183
+ priceMax?: Money;
184
+ /** "Was" price paired with `price` (the lowest compareAtPrice) — sale badge on cards. */
185
+ compareAtPrice?: Money | null;
186
+ featuredImage?: ImageRef | null;
187
+ /** Default purchasable variant id (`firstAvailableVariant`) — enough to add
188
+ * to cart from a grid/card without loading the full variant list. */
189
+ variantId?: string;
190
+ availableForSale?: boolean;
191
+ /** The product's own low-stock threshold (Theme ABI `Product.lowStockThreshold`), when the merchant set one. */
192
+ lowStockThreshold?: number;
193
+ /**
194
+ * The store's automatic discounts that apply to this product without conditions (storefront-query rev 2.31
195
+ * `Product.automaticDiscounts`), active or scheduled: show one only while now ∈ [startsAt, endsAt). `value` is a
196
+ * percentage (0–100] or, for `fixed`, the amount off each item in the store's base currency. QA D8.
197
+ */
198
+ automaticDiscounts?: import('../../sdk/types.js').ProductAutomaticDiscount[];
199
+ /** Catalog facets (card badges / filtering). Present from boot. */
200
+ vendor?: string | null;
201
+ productType?: string | null;
202
+ tags?: string[];
203
+ /** Publish/create timestamps (standard `product.published_at`/`created_at`). */
204
+ publishedAt?: string | null;
205
+ createdAt?: string | null;
206
+ /** Canonical storefront URL (`product.url`). */
207
+ onlineStoreUrl?: string | null;
208
+ /** Long description as PLAINTEXT — only populated by `fetchProduct()` (PDP). */
209
+ description?: string;
210
+ /**
211
+ * The same body WITH the merchant's formatting (`Product.descriptionHtml`,
212
+ * `@cost(value: 0)`), already sanitised by store-api. Only populated by
213
+ * `fetchProduct()` (PDP). A theme renders it as HTML and must not re-sanitise
214
+ * it; `description` is the plaintext fallback for text-only surfaces.
215
+ */
216
+ descriptionHtml?: string;
217
+ /** Image gallery — only after `fetchProduct()` (PDP). */
218
+ images?: ImageRef[];
219
+ /** Full media gallery incl. video / 3D (`product.media`) — after `fetchProduct()`. */
220
+ media?: ProductMedia[];
221
+ /** Option definitions (Size, Color…) — only after `fetchProduct()`. */
222
+ options?: ProductOption[];
223
+ /** Full variant list — only after `fetchProduct()` (PDP). */
224
+ variants?: ProductVariant[];
225
+ /** Subscription / selling-plan groups — only after `fetchProduct()`. */
226
+ sellingPlanGroups?: SellingPlanGroup[];
227
+ /** Collections this product belongs to (`product.collections`) — after `fetchProduct()`. */
228
+ collections?: Array<{
229
+ handle: string;
230
+ title: string;
231
+ }>;
232
+ /** True for gift-card products (`product.gift_card`; Theme ABI `Product.isGiftCard`, storefront-query rev 2.50). */
233
+ isGiftCard?: boolean;
234
+ /** Total on-hand stock across variants (`product.totalInventory`). */
235
+ totalInventory?: number | null;
236
+ /** Requested custom metafields ("namespace.key" → value) — pass identifiers to fetchProduct(). */
237
+ metafields?: Record<string, string | null>;
238
+ /** SEO override — only after `fetchProduct()`. */
239
+ seo?: Seo | null;
240
+ /**
241
+ * The product's published-review aggregate (Theme ABI `Product.rating`, storefront-query rev 2.38): on every product
242
+ * answer of a product that has at least one published review, so a card shows its stars. `distribution` counts
243
+ * 5 → 1 stars. Absent (never null) when the product has no published review.
244
+ */
245
+ rating?: ProductRating;
246
+ /**
247
+ * The newest published reviews (Theme ABI `Product.reviews`), only when asked for — the product route's snapshot
248
+ * and `fetchProduct()` ask `reviewsFirst`. `totalCount` = how many the platform can page (at most 50).
249
+ */
250
+ reviews?: {
251
+ nodes: ProductReview[];
252
+ totalCount: number;
253
+ };
254
+ }
255
+ export interface ProductRating {
256
+ value: number;
257
+ count: number;
258
+ distribution: [number, number, number, number, number];
259
+ }
260
+ /** One published review as the platform answers it (Theme ABI `ProductReview`); `author` is a display name only. */
261
+ export interface ProductReview {
262
+ id: string;
263
+ rating: 1 | 2 | 3 | 4 | 5;
264
+ title?: string;
265
+ body: string;
266
+ author: string;
267
+ createdAt: string;
268
+ verifiedPurchase: boolean;
269
+ reply?: {
270
+ body: string;
271
+ createdAt: string;
272
+ };
273
+ }
274
+ /**
275
+ * A product media node — image, video, 3D model, or external (YouTube/Vimeo) video. On the Theme ABI path
276
+ * (storefront-query rev 2.34 `Product.media`) only `image` and hosted `video` (mp4 / webm / quicktime files in the
277
+ * store's own media library) ever appear, and `media` is present only when the product has at least one video.
278
+ */
279
+ export interface ProductMedia {
280
+ id: string;
281
+ type: 'image' | 'video' | 'model_3d' | 'external_video';
282
+ alt?: string | null;
283
+ /** Present for `image`. */
284
+ image?: ImageRef | null;
285
+ /** Poster frame for video / 3D. */
286
+ previewImage?: ImageRef | null;
287
+ /** Playable/loadable sources for `video` / `model_3d`. */
288
+ sources?: {
289
+ url: string;
290
+ mimeType?: string | null;
291
+ format?: string | null;
292
+ }[];
293
+ /** For `external_video` — 'YOUTUBE' | 'VIMEO'. */
294
+ host?: string | null;
295
+ /** For `external_video` — the embed URL. */
296
+ embedUrl?: string | null;
297
+ }
298
+ export interface Collection {
299
+ /** Backend collection id (`collection.id`). */
300
+ id?: string;
301
+ /** commerce-standard theme template variant (e.g. "featured"). */
302
+ templateSuffix?: string | null;
303
+ handle: string;
304
+ title: string;
305
+ /** Collection body/description HTML (`collection.description`). */
306
+ description?: string | null;
307
+ /** Optional hero image; falls back to first product's featuredImage. */
308
+ image?: {
309
+ url?: string;
310
+ altText?: string;
311
+ } | null;
312
+ products: Product[];
313
+ /** Total number of products in the collection (`products_count`). */
314
+ productsCount?: number;
315
+ /** Custom metafields ("namespace.key" → value) for dynamic sources. */
316
+ metafields?: Record<string, string | null>;
317
+ /** SEO title/description (merchant-edited) for the document head. */
318
+ seo?: Seo | null;
319
+ /** The collection's facets, when the platform answered them (Theme ABI `Collection.filters`). */
320
+ filters?: Filter[];
321
+ }
322
+ export interface Page {
323
+ handle: string;
324
+ title: string;
325
+ /** HTML body — rendered via dangerouslySetInnerHTML by the PageBody section. */
326
+ body: string;
327
+ bodySummary?: string;
328
+ author?: string | null;
329
+ publishedAt?: string;
330
+ updatedAt?: string;
331
+ /** commerce-standard template suffix (e.g. "contact"); the theme renders
332
+ * templates/page.<suffix>.json when set, else the default page template. */
333
+ templateSuffix?: string | null;
334
+ /** SEO title/description (merchant-edited) for the document head. */
335
+ seo?: Seo | null;
336
+ /** Storefront-readable page metafields ("namespace.key" → display value), storefront-query rev 2.45 (O4). */
337
+ metafields?: Record<string, string | null>;
338
+ }
339
+ /**
340
+ * The route's entry on a metaobject page (`/pages/<definitionHandle>/<handle>`, Theme ABI route kind `metaobject`):
341
+ * what a setting bound to `metaobject.<field>` reads. `fields`: the entry's field values as the platform answers them
342
+ * — text as stored, a file `{url, alt?}`, a resource reference `{id, handle}`.
343
+ */
344
+ export interface MetaobjectPage {
345
+ handle: string;
346
+ type: string;
347
+ /** The URL handle of the entry's definition (the first path segment after `/pages/`). */
348
+ definitionHandle: string;
349
+ /** The page's own path, `/pages/<definitionHandle>/<handle>`. */
350
+ url: string;
351
+ fields: Readonly<Record<string, unknown>>;
352
+ /**
353
+ * The page's SEO title and meta description, when the platform answers them (storefront-query rev 2.62: the
354
+ * definition's SEO fields, else the entry's display name and its first text field). Absent ⇒ the theme's fallback.
355
+ */
356
+ seo?: {
357
+ title?: string | null;
358
+ description?: string | null;
359
+ };
360
+ }
361
+ /**
362
+ * The data interface every block consumes. Themes provide an implementation.
363
+ *
364
+ * Core read methods (collections/products/pages/localization) are always
365
+ * present. The commerce-standard extensions (shop, menus, search, blog,
366
+ * recommendations, metaobjects, customer account) come from `StorefrontExtensions`
367
+ * and are LIVE-ONLY — undefined under mock data, so themes feature-detect them
368
+ * (`data.search?.(...)`, `data.customer?.login(...)`).
369
+ */
370
+ export interface DataApi extends StorefrontExtensions {
371
+ collectionByHandle: (handle: string) => Collection | null;
372
+ /** All known collections (used by CollectionList). */
373
+ allCollections: () => Collection[];
374
+ /**
375
+ * List every navigation menu the store has (Dashboard → Navigation), for the
376
+ * editor's `link_list` picker. Identity only (handle/title/count) — fetch a
377
+ * menu's items with `fetchMenu(handle)`. Optional: older payloads may omit it.
378
+ */
379
+ listMenus?: () => Promise<Array<{
380
+ handle: string;
381
+ title: string;
382
+ itemsCount: number;
383
+ }>>;
384
+ /** Connected tracking pixels (Settings → Customer events) to inject on the
385
+ * storefront. Optional — older payloads / mock mode return []. */
386
+ pixels?: () => Promise<Array<{
387
+ id: string;
388
+ name: string;
389
+ provider: string | null;
390
+ providerPixelId: string | null;
391
+ code: string | null;
392
+ }>>;
393
+ /**
394
+ * "Notify me when it's back": ask store-api to email `email` ONCE when a sold-out variant is available
395
+ * again. `available` = it is in stock right now (nothing stored). Resolves for both; rejects on a
396
+ * transport/HTTP failure so the form can say so. The address is used for this one email only — there is
397
+ * no marketing opt-in on this path.
398
+ */
399
+ notifyBackInStock?: (input: {
400
+ variantId: string;
401
+ email: string;
402
+ locale?: string;
403
+ country?: string;
404
+ }) => Promise<'subscribed' | 'available'>;
405
+ /** Physical store locations (Settings → Locations) for a store-locator. */
406
+ locations?: () => Promise<Array<{
407
+ id: string;
408
+ name: string;
409
+ code: string | null;
410
+ address: {
411
+ country: string | null;
412
+ address: string | null;
413
+ city: string | null;
414
+ province: string | null;
415
+ postalCode: string | null;
416
+ phone: string | null;
417
+ } | null;
418
+ /** rev 2.52 (O3): the expected pickup time; absent when the platform did not say. */
419
+ pickupReadyIn?: '4h' | '24h' | '1-2d' | '2-4d' | '5d+';
420
+ }>>;
421
+ /**
422
+ * Look up a single product by its handle. Returns null when the handle
423
+ * isn't found. Required by FeaturedProduct / ProductDetails sections
424
+ * (ported from the canonical examples/react theme in PR #2).
425
+ */
426
+ productByHandle: (handle: string) => Product | null;
427
+ /**
428
+ * Look up a Page by handle (the storefront's `/pages/<handle>` content).
429
+ * Returns null if the handle wasn't prefetched at boot or the merchant
430
+ * hasn't published a page with that handle. Live data prefetches only the
431
+ * page matching the current URL, so other handles return null even when
432
+ * they exist in the backend — themes should only call this for the page
433
+ * the user is on.
434
+ */
435
+ pageByHandle: (handle: string) => Page | null;
436
+ /** A page by handle from the storefront — for a page reached by soft navigation;
437
+ * afterwards `pageByHandle` answers for it too. */
438
+ fetchPage?: (handle: string) => Promise<Page | null>;
439
+ /** Localization snapshot — what markets/countries the store has live.
440
+ * null = mock data; the country switcher should hide itself. */
441
+ localization: Localization | null;
442
+ /**
443
+ * Raw GraphQL escape hatch against the same storefront endpoint the live
444
+ * data source was booted with. Present ONLY for live data — undefined for
445
+ * mock data. Powers post-boot interactions (the cart's mutations live here).
446
+ */
447
+ graphql?: <T = unknown>(query: string, variables?: Record<string, unknown>) => Promise<T>;
448
+ /**
449
+ * Fetch a single product WITH its full options + variants on demand (for the
450
+ * product page's variant picker). Live data hits the backend; mock data
451
+ * resolves synchronously from the prefetched cache. Returns null if missing.
452
+ */
453
+ fetchProduct?: (handle: string, opts?: {
454
+ metafields?: Array<{
455
+ namespace: string;
456
+ key: string;
457
+ }>;
458
+ }) => Promise<Product | null>;
459
+ /**
460
+ * Fetch the shop's custom metafields by identifier (for dynamic sources).
461
+ * Live data queries `shop { metafields(identifiers) }`; mock data returns {}
462
+ * (no metafields offline). Result keys are "namespace.key".
463
+ */
464
+ fetchShopMetafields?: (identifiers: Array<{
465
+ namespace: string;
466
+ key: string;
467
+ }>) => Promise<Record<string, string | null>>;
468
+ /**
469
+ * Fetch a collection's custom metafields by identifier (for dynamic sources).
470
+ * Result keys are "namespace.key".
471
+ */
472
+ fetchCollectionMetafields?: (handle: string, identifiers: Array<{
473
+ namespace: string;
474
+ key: string;
475
+ }>) => Promise<Record<string, string | null>>;
476
+ /**
477
+ * The raw serializable bootstrap payload this live DataApi was built from
478
+ * (null for mock data). The SSG step embeds it into the page as
479
+ * `window.__TQ_STATE__` so the client can rebuild the identical DataApi
480
+ * synchronously at hydration via createLiveDataFromSnapshot — SSR markup and
481
+ * the client's first render match by construction.
482
+ */
483
+ getSnapshot?: () => unknown;
484
+ /** Records the server loaded for this route before rendering (`blog:<handle>`,
485
+ * `article:<blog>/<handle>`), keyed like the page's resource cache — so the
486
+ * server html carries them and hydration starts with them instead of refetching. */
487
+ preloaded?: Record<string, unknown>;
488
+ /** The policy handle this page renders (a `/policies/<handle>` route). */
489
+ policyHandle?: string;
490
+ /** A published policy by handle (browser: through /_tq), null when the store has not published it. */
491
+ fetchPolicy?: (handle: string) => Promise<import('./storefront.js').ShopPolicy | null>;
492
+ /** Whether the shopper has a customer session — not who (ABI `request.isSignedIn`). */
493
+ signedIn?: boolean;
494
+ /** ABI consent (browser only): `consent.get` / `consent.set` through /_tq. */
495
+ consent?: {
496
+ get: () => Promise<{
497
+ known: boolean;
498
+ analytics: boolean;
499
+ marketing: boolean;
500
+ functional: boolean;
501
+ region?: string;
502
+ bannerRequired: boolean;
503
+ geo?: {
504
+ country?: string;
505
+ region?: string;
506
+ };
507
+ regionRequiresBanner?: boolean;
508
+ }>;
509
+ set: (input: {
510
+ analytics: boolean;
511
+ marketing: boolean;
512
+ functional: boolean;
513
+ region?: string;
514
+ }) => Promise<void>;
515
+ };
516
+ /** Synchronous reads of what the server already loaded for this page (server and hydrating browser alike). */
517
+ blogSync?: (handle: string) => import('./storefront.js').Blog | null;
518
+ articleSync?: (blogHandle: string, handle: string) => import('./storefront.js').Article | null;
519
+ searchSync?: (query: string, sort?: string) => import('./storefront.js').SearchResults | null;
520
+ recommendationsSync?: (productHandle: string) => Product[] | null;
521
+ /** The route names a resource the platform does not have: the page answers 404. */
522
+ routeMissing?: boolean;
523
+ /** On a metaobject page: the route's entry (dynamic sources `metaobject.<field>`); absent on every other route. */
524
+ routeMetaobject?: MetaobjectPage | null;
525
+ /** The Account BFF URL for the account slot. */
526
+ accountUrl?: (path?: 'orders' | 'addresses' | 'profile') => string;
527
+ /** The platform form endpoint of this page (ABI native forms), when the host has one. */
528
+ formEndpoint?: string;
529
+ /** The route's captured segments (a custom route's `:id`), when the host hands them over. */
530
+ routeParams?: Readonly<Record<string, string>>;
531
+ /** The outcome of the native form POST this page answers. */
532
+ formResult?: {
533
+ formId: string;
534
+ status: 'ok' | 'invalid' | 'rate_limited' | 'unavailable' | 'expired';
535
+ email?: string;
536
+ discountCode?: string;
537
+ giftCard?: import('../../sdk/types.js').GiftCardBalance;
538
+ };
539
+ }
540
+ /** Country/market shape mirrored from storefront GraphQL `Localization`. */
541
+ export interface LocalizedCurrency {
542
+ isoCode: string;
543
+ name?: string;
544
+ symbol?: string;
545
+ }
546
+ export interface LocalizedMarket {
547
+ id: string;
548
+ handle: string;
549
+ name: string;
550
+ }
551
+ export interface LocalizedCountry {
552
+ isoCode: string;
553
+ name: string;
554
+ currency: LocalizedCurrency;
555
+ market: LocalizedMarket | null;
556
+ /**
557
+ * The languages this country's market offers, when the platform names them per market
558
+ * (`ctx.locale.markets`). Absent ⇒ every language in `availableLanguages`.
559
+ */
560
+ availableLanguages?: LocalizedLanguage[];
561
+ }
562
+ /** A language the store has published (dashboard → Markets / Languages). */
563
+ export interface LocalizedLanguage {
564
+ isoCode: string;
565
+ name: string;
566
+ /**
567
+ * The language in itself (the reference Storefront API's `Language.endonymName`), when the platform names it
568
+ * (theme-abi Locale-2). Present ⇒ `name` is the language in the page's language; absent ⇒ `name` is the endonym.
569
+ */
570
+ endonymName?: string;
571
+ }
572
+ export interface Localization {
573
+ /** Currently-active country (resolved from the request's X-Tanqory-Country). */
574
+ country: LocalizedCountry;
575
+ /** Every country the store has an active Market for — what the picker shows. */
576
+ availableCountries: LocalizedCountry[];
577
+ /**
578
+ * Currently-active language + every language the store has PUBLISHED. These
579
+ * are STORE/dashboard data (the merchant's published locales), not a theme
580
+ * config list — the theme only ships the translations. Optional so older live
581
+ * payloads (countries only) still satisfy the type; the picker falls back to a
582
+ * single default when absent.
583
+ */
584
+ language?: LocalizedLanguage;
585
+ availableLanguages?: LocalizedLanguage[];
586
+ }
587
+ /** Wraps the app with a theme-provided data source (mock or live). */
588
+ export declare function DataProvider({ value, children }: {
589
+ value: DataApi;
590
+ children: ReactNode;
591
+ }): JSX.Element;
592
+ export declare function useData(): DataApi;
593
+ type MockLocation = NonNullable<Awaited<ReturnType<NonNullable<DataApi['locations']>>>>[number];
594
+ /**
595
+ * The richer fixture shape `createMockData` also accepts. `app/data/sample-store.json`
596
+ * is a plain `Collection[]` (the theme's own offline fixture); a content pack
597
+ * (`NOVA_CONTENT=<dir>`, e.g. `demo/halden/`) may instead provide this object so
598
+ * its menus, blog, pages, store locations, shop and markets match the store it
599
+ * depicts. Every key is optional; an absent one keeps the built-in sample.
600
+ */
601
+ export interface MockFixture {
602
+ collections: Collection[];
603
+ menus?: Menu[];
604
+ blogs?: Blog[];
605
+ pages?: Page[];
606
+ locations?: MockLocation[];
607
+ shop?: Partial<Shop>;
608
+ localization?: Localization;
609
+ /** Offline "You may also like": product handle → the handles to recommend,
610
+ * in order. Without an entry, the first four other products. */
611
+ recommendations?: Record<string, string[]>;
612
+ }
613
+ /** Build an offline data source from fixture collections (theme passes its JSON). */
614
+ export declare function createMockData(input: Collection[] | MockFixture): DataApi;
615
+ /**
616
+ * Live data source backed by the Tanqory Storefront GraphQL API.
617
+ *
618
+ * const data = await createLiveData({
619
+ * endpoint: 'https://api.example.com',
620
+ * storeId: '<store-uuid>',
621
+ * token: '<publishable-storefront-token>',
622
+ * prefetch: { collectionLimit: 20, productLimitPerCollection: 24 },
623
+ * })
624
+ *
625
+ * Returns the same `DataApi` shape as `createMockData` (sync read methods)
626
+ * by pre-fetching collections + their products at boot and serving every
627
+ * subsequent lookup from an in-memory cache. The trade-off: a single GraphQL
628
+ * round-trip at boot, then zero network on render — exactly what the SSG
629
+ * step + first hydration need.
630
+ *
631
+ * Per-handle pages (e.g. /products/<handle>) that miss the prefetch can
632
+ * still be fetched lazily via `dataApi.refresh()` (TODO) — for now, raise
633
+ * `prefetch.productLimitPerCollection` to cover the catalogue size.
634
+ */
635
+ export interface LiveDataOptions {
636
+ /** Base URL of the store-api (e.g. https://api.example.com). */
637
+ endpoint: string;
638
+ /** Store UUID (the `:storeId` path param). */
639
+ storeId: string;
640
+ /** Publishable storefront token — passed as `x-publishable-key`. */
641
+ token?: string;
642
+ /**
643
+ * ISO 3166 alpha-2 (e.g. "TH", "SG", "US"). When set, the backend resolves
644
+ * the matching Market for this country, applies its currency + exchange
645
+ * rate, and returns Money fields in that currency. Falls back to store
646
+ * base currency if no Market matches the country.
647
+ */
648
+ country?: string;
649
+ /**
650
+ * Content language (BCP-47-ish, e.g. "th", "zh-TW"). When set, the backend
651
+ * overlays the merchant's translations for this locale onto product/
652
+ * collection/page content (X-Tanqory-Lang). Falls back to default-language
653
+ * content when a resource has no translation. Independent of `country`.
654
+ */
655
+ locale?: string;
656
+ /** Optional fetch override (testing / SSR). */
657
+ fetcher?: typeof fetch;
658
+ /**
659
+ * Page handle (from `/pages/<handle>`) to fetch alongside the homepage
660
+ * bootstrap. The theme entry resolves the current URL once at boot and
661
+ * passes the matching handle here so the PageBody section can read
662
+ * `dataApi.pageByHandle(handle)` synchronously during hydration.
663
+ */
664
+ pageHandle?: string;
665
+ /** Handle of the product/collection detail route being loaded, so its
666
+ * template variant (templateSuffix) is prefetched into the bootstrap. */
667
+ productHandle?: string;
668
+ collectionHandle?: string;
669
+ /** A policy route: also load the policies' bodies (the shared bootstrap
670
+ * carries only their titles, which left /policies/* with a heading alone). */
671
+ policyBodies?: boolean;
672
+ /** Tune how much to load at boot. */
673
+ prefetch?: {
674
+ /** Max collections to fetch (default 20). */
675
+ collectionLimit?: number;
676
+ /** Max products to inline under each collection (default 24). */
677
+ productLimitPerCollection?: number;
678
+ /** Max products to fetch at the top level (default 24) — these power the
679
+ * synthesized `featured` / `all` virtual collections when the store has
680
+ * no real collections yet. */
681
+ topProductLimit?: number;
682
+ };
683
+ }
684
+ export declare function createLiveData(opts: LiveDataOptions): Promise<DataApi>;
685
+ /**
686
+ * Build a live DataApi SYNCHRONOUSLY from a previously-fetched bootstrap
687
+ * payload (`data.getSnapshot()`, serialized into the SSG HTML as
688
+ * `window.__TQ_STATE__` by the prerender step). This is what makes hydration
689
+ * deterministic: the client's first render uses the EXACT data the server
690
+ * rendered with — no network round-trip, no drift, no mock fallback — and
691
+ * mount()'s `revalidate` swaps in fresh data after hydration (SWR).
692
+ */
693
+ export declare function createLiveDataFromSnapshot(snapshot: unknown, opts: LiveDataOptions): DataApi;
694
+ /** standard `money` — symbol + amount (e.g. "฿120.00"). */
695
+ export declare function formatMoney(money: Money): string;
696
+ /** standard `money_with_currency` — symbol + amount + ISO code (e.g. "฿120.00 THB"). */
697
+ export declare function formatMoneyWithCurrency(money: Money): string;
698
+ /** standard `money_without_currency` — bare grouped amount (e.g. "120.00"). */
699
+ export declare function formatMoneyWithoutCurrency(money: Money): string;
700
+ /** standard `money_without_trailing_zeros` — symbol + amount, dropping a `.00`
701
+ * fraction (e.g. "฿120", but "฿120.50" stays). */
702
+ export declare function formatMoneyWithoutTrailingZeros(money: Money): string;
703
+ /** standard `date` / `time_tag` — format an ISO date deterministically (identical
704
+ * output on server + client to keep SSR hydration stable). Defaults to a medium
705
+ * date; pass Intl options to customize. */
706
+ export declare function formatDate(input: string | number | Date | null | undefined, opts?: Intl.DateTimeFormatOptions, locale?: string): string;
707
+ /** standard `weight_with_unit` — format a variant weight (e.g. "1.5 kg"). */
708
+ export declare function formatWeight(weight: {
709
+ value: number;
710
+ unit: string;
711
+ } | null | undefined): string;
712
+ /** standard `image_url` — append CDN transform params (width/height/crop) to an
713
+ * image URL. No-op when the src is empty or no transform is requested. React
714
+ * themes render the `<img>` themselves, so there is no separate `image_tag`. */
715
+ export declare function imageUrl(src: string | null | undefined, opts?: {
716
+ width?: number;
717
+ height?: number;
718
+ crop?: string;
719
+ }): string;
720
+ export {};