@tanqory/theme-kit 0.1.0 → 2.0.0-alpha.5
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 +321 -0
- package/dist/abi/convert.d.ts +192 -0
- package/dist/abi/convert.js +670 -0
- package/dist/abi/data-api.d.ts +15 -0
- package/dist/abi/data-api.js +198 -0
- package/dist/abi/jcs.d.ts +6 -0
- package/dist/abi/jcs.js +28 -0
- package/dist/abi/page-data.d.ts +209 -0
- package/dist/abi/page-data.js +583 -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 +258 -0
- package/dist/runtime/data/to-ui.js +820 -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 +186 -0
- package/dist/runtime/kit/cart.js +545 -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/runtime/kit/data.d.ts +636 -0
- 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/runtime/kit/storefront.d.ts +566 -0
- 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 +48 -0
- package/dist/runtime/render/section-actions.js +170 -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 +85 -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 +135 -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 +470 -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/data.d.ts +0 -357
- 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/storefront.d.ts +0 -333
- package/dist/types/types.d.ts +0 -44
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The data Nova components receive. Components are presentational: they never
|
|
3
|
+
* fetch. A storefront adapter maps Tanqory API payloads onto these shapes; the
|
|
4
|
+
* lab maps fixtures onto them. Optional means "a real store can lack it" —
|
|
5
|
+
* every component must render (or deliberately render nothing) without it.
|
|
6
|
+
*/
|
|
7
|
+
export interface Image {
|
|
8
|
+
src: string;
|
|
9
|
+
alt?: string;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
/** Optional responsive candidates; `src` is always the fallback. */
|
|
13
|
+
srcSet?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface Video {
|
|
16
|
+
src: string;
|
|
17
|
+
poster?: Image;
|
|
18
|
+
captions?: string;
|
|
19
|
+
captionsLang?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface Link {
|
|
22
|
+
title: string;
|
|
23
|
+
url: string;
|
|
24
|
+
}
|
|
25
|
+
export interface MenuItem {
|
|
26
|
+
title: string;
|
|
27
|
+
/** null = a heading-only item that exists to group children. */
|
|
28
|
+
url: string | null;
|
|
29
|
+
items?: MenuItem[];
|
|
30
|
+
/** The item matches the current route (drives aria-current + the active rule). */
|
|
31
|
+
active?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface Menu {
|
|
34
|
+
handle: string;
|
|
35
|
+
title: string;
|
|
36
|
+
items: MenuItem[];
|
|
37
|
+
}
|
|
38
|
+
export interface Money {
|
|
39
|
+
/** Minor units avoided on purpose: the storefront API returns decimals. */
|
|
40
|
+
amount: number;
|
|
41
|
+
currencyCode: string;
|
|
42
|
+
}
|
|
43
|
+
export type SocialNetwork = 'instagram' | 'facebook' | 'x' | 'tiktok' | 'youtube';
|
|
44
|
+
export declare const SOCIAL_NETWORKS: readonly SocialNetwork[];
|
|
45
|
+
export type PaymentMethod = 'visa' | 'mastercard' | 'amex' | 'promptpay' | 'paypal' | 'apple-pay' | 'google-pay' | 'jcb' | 'unionpay' | 'truemoney' | 'discover' | 'diners-club';
|
|
46
|
+
/** A store social profile on a network the design draws no mark for (Threads, Pinterest, …): shown with the generic link mark and its name. */
|
|
47
|
+
export interface SocialLink {
|
|
48
|
+
/** The dashboard's lower-case network slug. */
|
|
49
|
+
platform: string;
|
|
50
|
+
/** The network's display name ("Threads"). */
|
|
51
|
+
label: string;
|
|
52
|
+
/** Absolute https: URL. */
|
|
53
|
+
url: string;
|
|
54
|
+
}
|
|
55
|
+
export interface Shop {
|
|
56
|
+
name: string;
|
|
57
|
+
/** Settings → Brand → logo. The header resolves: logo image → header.logo text → name. */
|
|
58
|
+
logo?: Image | null;
|
|
59
|
+
email?: string;
|
|
60
|
+
phone?: string;
|
|
61
|
+
social?: Partial<Record<SocialNetwork, string>>;
|
|
62
|
+
/** The store's other social profiles, in the store's order, after the drawn networks. */
|
|
63
|
+
otherSocial?: SocialLink[];
|
|
64
|
+
paymentMethods?: PaymentMethod[];
|
|
65
|
+
/** Copyright line owner; defaults to name. */
|
|
66
|
+
legalName?: string;
|
|
67
|
+
/** Prices include tax for the shopper's market (Settings › Taxes): the price says "Tax included." */
|
|
68
|
+
taxesIncluded?: boolean;
|
|
69
|
+
/** The lowest "free over" shipping threshold for the shopper's country, in the market's currency. */
|
|
70
|
+
freeShippingThreshold?: Money;
|
|
71
|
+
/** Settings › Customer accounts › "Show sign-in links"; false hides the account links. Absent = shown. */
|
|
72
|
+
signInLinks?: boolean;
|
|
73
|
+
/** The store's published policies, when the platform listed them (footer legal links fallback). */
|
|
74
|
+
policyLinks?: {
|
|
75
|
+
handle: string;
|
|
76
|
+
title: string;
|
|
77
|
+
url: string;
|
|
78
|
+
}[];
|
|
79
|
+
/** Settings › Customer privacy › Cookie banner. Absent = the theme's own banner. */
|
|
80
|
+
consentBanner?: ConsentBannerConfig;
|
|
81
|
+
/** The store's base currency (Settings › General › Store currency), when the platform sent it. */
|
|
82
|
+
currencyCode?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Settings › Markets › Currency formatting, when the merchant set it: patterns holding one `{{amount…}}` token
|
|
85
|
+
* (`฿{{amount}}`, `{{amount_no_decimals}} บาท`). They apply ONLY to amounts in `currencyCode`; any other currency
|
|
86
|
+
* keeps the locale's formatting. The text may hold HTML the merchant typed — render it as text, tags stripped.
|
|
87
|
+
*/
|
|
88
|
+
moneyFormat?: {
|
|
89
|
+
withCurrency?: string;
|
|
90
|
+
withoutCurrency?: string;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Settings › Brand › Business details › Location — the business address the merchant published, as display lines
|
|
94
|
+
* (street, city line, country), when set. Never the billing address.
|
|
95
|
+
*/
|
|
96
|
+
address?: string[];
|
|
97
|
+
}
|
|
98
|
+
/** The merchant's cookie banner (Settings › Customer privacy). Text members are present only when typed. */
|
|
99
|
+
export interface ConsentBannerConfig {
|
|
100
|
+
enabled: boolean;
|
|
101
|
+
/** "Use automated settings": shown wherever the shopper has not decided, not only in `regions`. */
|
|
102
|
+
automated: boolean;
|
|
103
|
+
position: 'bottom' | 'bottom-left' | 'bottom-right' | 'bottom-center' | 'center';
|
|
104
|
+
/** custom = the theme's own colours. */
|
|
105
|
+
colorTheme: 'light' | 'dark' | 'custom';
|
|
106
|
+
/** Countries ("TH") or subdivisions ("US-CA") the merchant chose. */
|
|
107
|
+
regions: string[];
|
|
108
|
+
privacyLinkUrl?: string;
|
|
109
|
+
text: Partial<Record<'title' | 'body' | 'privacyLinkLabel' | 'acceptLabel' | 'declineLabel' | 'manageLabel', string>>;
|
|
110
|
+
preferences: Partial<Record<'title' | 'introTitle' | 'introBody' | 'acceptAllLabel' | 'declineAllLabel' | 'saveLabel' | 'bulletTitle' | 'requiredTitle' | 'requiredDescription' | 'personalizationTitle' | 'personalizationDescription' | 'marketingTitle' | 'marketingDescription' | 'analyticsTitle' | 'analyticsDescription', string>> & {
|
|
111
|
+
bullets?: string[];
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
export interface Market {
|
|
115
|
+
countryCode: string;
|
|
116
|
+
country: string;
|
|
117
|
+
currencyCode: string;
|
|
118
|
+
currencySymbol: string;
|
|
119
|
+
languageCode: string;
|
|
120
|
+
/** The language's own name, in its own script (English, ไทย, 日本語). */
|
|
121
|
+
language: string;
|
|
122
|
+
/** The language's English name, shown muted beside the native one (Thai, Japanese). */
|
|
123
|
+
languageEnglish?: string;
|
|
124
|
+
}
|
|
125
|
+
export interface Localization {
|
|
126
|
+
current: Market;
|
|
127
|
+
available: Market[];
|
|
128
|
+
}
|
|
129
|
+
export interface CartSummary {
|
|
130
|
+
itemCount: number;
|
|
131
|
+
lineCount: number;
|
|
132
|
+
}
|
|
133
|
+
export interface Customer {
|
|
134
|
+
signedIn: boolean;
|
|
135
|
+
firstName?: string;
|
|
136
|
+
}
|
|
137
|
+
export interface BreadcrumbItem {
|
|
138
|
+
title: string;
|
|
139
|
+
/** Absent on the current page. */
|
|
140
|
+
url?: string;
|
|
141
|
+
}
|
|
142
|
+
export interface ProductOption {
|
|
143
|
+
name: string;
|
|
144
|
+
values: string[];
|
|
145
|
+
}
|
|
146
|
+
export interface ProductVariant {
|
|
147
|
+
id: string;
|
|
148
|
+
title: string;
|
|
149
|
+
sku?: string;
|
|
150
|
+
price: Money;
|
|
151
|
+
compareAtPrice?: Money | null;
|
|
152
|
+
available: boolean;
|
|
153
|
+
quantityAvailable?: number | null;
|
|
154
|
+
selectedOptions: {
|
|
155
|
+
name: string;
|
|
156
|
+
value: string;
|
|
157
|
+
}[];
|
|
158
|
+
image?: Image | null;
|
|
159
|
+
}
|
|
160
|
+
export interface Product {
|
|
161
|
+
id: string;
|
|
162
|
+
handle: string;
|
|
163
|
+
title: string;
|
|
164
|
+
vendor?: string;
|
|
165
|
+
productType?: string;
|
|
166
|
+
description?: string;
|
|
167
|
+
descriptionHtml?: string;
|
|
168
|
+
url: string;
|
|
169
|
+
featuredImage?: Image | null;
|
|
170
|
+
images: Image[];
|
|
171
|
+
options: ProductOption[];
|
|
172
|
+
variants: ProductVariant[];
|
|
173
|
+
priceRange: {
|
|
174
|
+
min: Money;
|
|
175
|
+
max: Money;
|
|
176
|
+
};
|
|
177
|
+
compareAtPriceRange?: {
|
|
178
|
+
min: Money;
|
|
179
|
+
max: Money;
|
|
180
|
+
} | null;
|
|
181
|
+
available: boolean;
|
|
182
|
+
tags?: string[];
|
|
183
|
+
/** The product's own low-stock threshold (Products › inventory), which overrides the theme's. */
|
|
184
|
+
lowStockThreshold?: number;
|
|
185
|
+
/**
|
|
186
|
+
* The store's automatic discounts that apply to this product without conditions (storefront-query rev 2.31
|
|
187
|
+
* `Product.automaticDiscounts`), active or scheduled: show one only while now ∈ [startsAt, endsAt). `value` is a
|
|
188
|
+
* percentage (0–100] or, for `fixed`, the amount off each item in the store's base currency. QA D8.
|
|
189
|
+
*/
|
|
190
|
+
automaticDiscounts?: ProductAutomaticDiscount[];
|
|
191
|
+
/**
|
|
192
|
+
* The gallery in the merchant's order when it holds a hosted video (images and videos interleaved). Absent ⇒ the
|
|
193
|
+
* gallery is `images`. Only videos uploaded to the store's own media library appear (mp4 / webm / mov); never
|
|
194
|
+
* YouTube, Vimeo or 3D.
|
|
195
|
+
*/
|
|
196
|
+
media?: ProductMediaItem[];
|
|
197
|
+
/** Merchant-set badge text; the card shows at most one badge. */
|
|
198
|
+
badge?: string | null;
|
|
199
|
+
rating?: {
|
|
200
|
+
value: number;
|
|
201
|
+
count: number;
|
|
202
|
+
} | null;
|
|
203
|
+
}
|
|
204
|
+
export interface Collection {
|
|
205
|
+
id: string;
|
|
206
|
+
handle: string;
|
|
207
|
+
title: string;
|
|
208
|
+
description?: string;
|
|
209
|
+
url: string;
|
|
210
|
+
image?: Image | null;
|
|
211
|
+
productsCount: number;
|
|
212
|
+
products?: Product[];
|
|
213
|
+
}
|
|
214
|
+
/** 12C · listing filters — facets come from the store's filter settings (Search & discovery). */
|
|
215
|
+
export interface FacetValue {
|
|
216
|
+
id: string;
|
|
217
|
+
label: string;
|
|
218
|
+
count: number;
|
|
219
|
+
active: boolean;
|
|
220
|
+
}
|
|
221
|
+
export interface Facet {
|
|
222
|
+
id: string;
|
|
223
|
+
label: string;
|
|
224
|
+
type: 'list' | 'price';
|
|
225
|
+
values?: FacetValue[];
|
|
226
|
+
/** Price facets: the store's bounds and the shopper's current range. */
|
|
227
|
+
range?: {
|
|
228
|
+
min: number;
|
|
229
|
+
max: number;
|
|
230
|
+
from?: number;
|
|
231
|
+
to?: number;
|
|
232
|
+
currencyCode: string;
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
export interface SortOption {
|
|
236
|
+
id: string;
|
|
237
|
+
label: string;
|
|
238
|
+
}
|
|
239
|
+
export interface CartLine {
|
|
240
|
+
id: string;
|
|
241
|
+
quantity: number;
|
|
242
|
+
product: Pick<Product, 'title' | 'handle' | 'url' | 'vendor'>;
|
|
243
|
+
variant: ProductVariant;
|
|
244
|
+
cost: {
|
|
245
|
+
total: Money;
|
|
246
|
+
compareAtTotal?: Money | null;
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
/** One gallery item of `Product.media`: an image, or a hosted video with its files and poster frame. */
|
|
250
|
+
export type ProductMediaItem = {
|
|
251
|
+
type: 'image';
|
|
252
|
+
image: Image;
|
|
253
|
+
} | {
|
|
254
|
+
type: 'video';
|
|
255
|
+
sources: {
|
|
256
|
+
src: string;
|
|
257
|
+
type: string;
|
|
258
|
+
}[];
|
|
259
|
+
poster?: Image;
|
|
260
|
+
alt?: string;
|
|
261
|
+
};
|
|
262
|
+
/** An automatic discount on a product (see `Product.automaticDiscounts`). */
|
|
263
|
+
export interface ProductAutomaticDiscount {
|
|
264
|
+
id: string;
|
|
265
|
+
title: string;
|
|
266
|
+
valueType: 'percentage' | 'fixed';
|
|
267
|
+
/** Percentage (0–100], or the fixed amount off each item in the store's base currency. */
|
|
268
|
+
value: number;
|
|
269
|
+
/** ISO 8601. */
|
|
270
|
+
startsAt: string;
|
|
271
|
+
/** ISO 8601; absent = no end. */
|
|
272
|
+
endsAt?: string;
|
|
273
|
+
}
|
|
274
|
+
export interface Cart {
|
|
275
|
+
id: string;
|
|
276
|
+
lines: CartLine[];
|
|
277
|
+
note?: string;
|
|
278
|
+
itemCount: number;
|
|
279
|
+
subtotal: Money;
|
|
280
|
+
total: Money;
|
|
281
|
+
discounts?: {
|
|
282
|
+
code: string;
|
|
283
|
+
amount: Money;
|
|
284
|
+
}[];
|
|
285
|
+
/**
|
|
286
|
+
* The discount codes the shopper entered, in the order applied. `applicable: false` = the store kept the code but
|
|
287
|
+
* it does not apply to this cart (yet: a minimum not met, or it does not combine). Absent on older hosts.
|
|
288
|
+
*/
|
|
289
|
+
discountCodes?: {
|
|
290
|
+
code: string;
|
|
291
|
+
applicable: boolean;
|
|
292
|
+
}[];
|
|
293
|
+
/**
|
|
294
|
+
* What the cart's discounts (automatic ones and codes) take off the order, from the cart's own totals
|
|
295
|
+
* (`subtotal + tax − total`). Absent when nothing is taken off or it cannot be told.
|
|
296
|
+
*/
|
|
297
|
+
discountTotal?: Money;
|
|
298
|
+
/**
|
|
299
|
+
* The cart's order-level discounts by name, when the platform sends them: `title` for an automatic discount,
|
|
300
|
+
* `code` for a code. Absent on hosts that do not send them — show `discountTotal` under a generic label then.
|
|
301
|
+
*/
|
|
302
|
+
discountAllocations?: {
|
|
303
|
+
title?: string;
|
|
304
|
+
code?: string;
|
|
305
|
+
amount: Money;
|
|
306
|
+
}[];
|
|
307
|
+
}
|
|
308
|
+
export interface Article {
|
|
309
|
+
id: string;
|
|
310
|
+
handle: string;
|
|
311
|
+
title: string;
|
|
312
|
+
excerpt?: string;
|
|
313
|
+
contentHtml?: string;
|
|
314
|
+
url: string;
|
|
315
|
+
image?: Image | null;
|
|
316
|
+
author?: string;
|
|
317
|
+
publishedAt: string;
|
|
318
|
+
readingMinutes?: number;
|
|
319
|
+
tags?: string[];
|
|
320
|
+
blogHandle: string;
|
|
321
|
+
}
|
|
322
|
+
export interface Blog {
|
|
323
|
+
id: string;
|
|
324
|
+
handle: string;
|
|
325
|
+
title: string;
|
|
326
|
+
url: string;
|
|
327
|
+
articles: Article[];
|
|
328
|
+
}
|
|
329
|
+
export interface SearchResults {
|
|
330
|
+
query: string;
|
|
331
|
+
products: Product[];
|
|
332
|
+
articles: Article[];
|
|
333
|
+
pages: {
|
|
334
|
+
title: string;
|
|
335
|
+
url: string;
|
|
336
|
+
excerpt?: string;
|
|
337
|
+
}[];
|
|
338
|
+
total: number;
|
|
339
|
+
}
|
|
340
|
+
export interface Review {
|
|
341
|
+
id: string;
|
|
342
|
+
author: string;
|
|
343
|
+
rating: 1 | 2 | 3 | 4 | 5;
|
|
344
|
+
title?: string;
|
|
345
|
+
body: string;
|
|
346
|
+
createdAt: string;
|
|
347
|
+
verified?: boolean;
|
|
348
|
+
productHandle?: string;
|
|
349
|
+
/** The variant the reviewer bought ("Queen · Oat"), when the source provides it. */
|
|
350
|
+
variant?: string;
|
|
351
|
+
photos?: Image[];
|
|
352
|
+
}
|
|
353
|
+
/** 12F product-reviews · what a reviews source returns for one product (DATA REQUIREMENT). */
|
|
354
|
+
export interface ReviewsData {
|
|
355
|
+
average: number;
|
|
356
|
+
count: number;
|
|
357
|
+
/** Review counts for 5 · 4 · 3 · 2 · 1 stars. */
|
|
358
|
+
distribution: [number, number, number, number, number];
|
|
359
|
+
reviews: Review[];
|
|
360
|
+
}
|
|
361
|
+
export interface Testimonial {
|
|
362
|
+
id: string;
|
|
363
|
+
quote: string;
|
|
364
|
+
name: string;
|
|
365
|
+
role?: string;
|
|
366
|
+
avatar?: Image | null;
|
|
367
|
+
rating?: number | null;
|
|
368
|
+
}
|
|
369
|
+
export interface TeamMember {
|
|
370
|
+
id: string;
|
|
371
|
+
name: string;
|
|
372
|
+
role: string;
|
|
373
|
+
bio?: string;
|
|
374
|
+
image?: Image | null;
|
|
375
|
+
links?: Link[];
|
|
376
|
+
}
|
|
377
|
+
export interface UgcPost {
|
|
378
|
+
id: string;
|
|
379
|
+
image: Image;
|
|
380
|
+
handle: string;
|
|
381
|
+
caption?: string;
|
|
382
|
+
url?: string;
|
|
383
|
+
productHandles?: string[];
|
|
384
|
+
}
|
|
385
|
+
export interface StoreLocation {
|
|
386
|
+
id: string;
|
|
387
|
+
name: string;
|
|
388
|
+
address: string[];
|
|
389
|
+
phone?: string;
|
|
390
|
+
email?: string;
|
|
391
|
+
/** Free text — the platform returns no structured hours or coordinates yet. */
|
|
392
|
+
hours?: string;
|
|
393
|
+
image?: Image | null;
|
|
394
|
+
url?: string;
|
|
395
|
+
}
|
|
396
|
+
export interface OrderSummary {
|
|
397
|
+
id: string;
|
|
398
|
+
number: string;
|
|
399
|
+
processedAt: string;
|
|
400
|
+
status: 'paid' | 'pending' | 'refunded' | 'fulfilled' | 'unfulfilled' | 'cancelled';
|
|
401
|
+
total: Money;
|
|
402
|
+
itemCount: number;
|
|
403
|
+
/** The order in the accounts app. */
|
|
404
|
+
url?: string;
|
|
405
|
+
}
|
|
406
|
+
export interface CustomerAccount {
|
|
407
|
+
firstName: string;
|
|
408
|
+
lastName: string;
|
|
409
|
+
email: string;
|
|
410
|
+
phone?: string;
|
|
411
|
+
orders: OrderSummary[];
|
|
412
|
+
addresses: {
|
|
413
|
+
id: string;
|
|
414
|
+
lines: string[];
|
|
415
|
+
default?: boolean;
|
|
416
|
+
}[];
|
|
417
|
+
}
|
|
418
|
+
export interface Policy {
|
|
419
|
+
handle: string;
|
|
420
|
+
title: string;
|
|
421
|
+
bodyHtml: string;
|
|
422
|
+
url: string;
|
|
423
|
+
/** Not in store data today (12G DATA REQUIREMENT) — "Last updated" renders only with it. */
|
|
424
|
+
updatedAt?: string;
|
|
425
|
+
}
|
|
426
|
+
/** What a product listing section receives from the runtime (products, paging, filters, sort). */
|
|
427
|
+
export interface ListingData {
|
|
428
|
+
/** The products the host has (load-more pages through them; more → onLoadMore). */
|
|
429
|
+
products?: Product[];
|
|
430
|
+
/** Products matching the current filters. */
|
|
431
|
+
total?: number;
|
|
432
|
+
facets?: Facet[];
|
|
433
|
+
sortOptions?: SortOption[];
|
|
434
|
+
sort?: string;
|
|
435
|
+
state?: 'ready' | 'loading' | 'error';
|
|
436
|
+
/** pages mode: the current page and a URL for any page. */
|
|
437
|
+
page?: number;
|
|
438
|
+
pageHref?: (page: number) => string;
|
|
439
|
+
shopAllHref?: string;
|
|
440
|
+
onToggleFilter?: (facetId: string, valueId: string) => void;
|
|
441
|
+
onPriceFilter?: (facetId: string, from?: number, to?: number) => void;
|
|
442
|
+
onClearFilters?: () => void;
|
|
443
|
+
onSortChange?: (id: string) => void;
|
|
444
|
+
/** Fetch the next page (the host appends to `products`). */
|
|
445
|
+
onLoadMore?: () => Promise<unknown> | void;
|
|
446
|
+
onRetry?: () => void;
|
|
447
|
+
onQuickAdd?: (product: Product) => void;
|
|
448
|
+
}
|
|
449
|
+
/** @deprecated Use `Image`. */
|
|
450
|
+
export type NovaImage = Image;
|
|
451
|
+
/** @deprecated Use `Video`. */
|
|
452
|
+
export type NovaVideo = Video;
|
|
453
|
+
/** @deprecated Use `Link`. */
|
|
454
|
+
export type NovaLink = Link;
|
|
455
|
+
/** @deprecated Use `MenuItem`. */
|
|
456
|
+
export type NovaMenuItem = MenuItem;
|
|
457
|
+
/** @deprecated Use `Menu`. */
|
|
458
|
+
export type NovaMenu = Menu;
|
|
459
|
+
/** @deprecated Use `SocialLink`. */
|
|
460
|
+
export type NovaSocialLink = SocialLink;
|
|
461
|
+
/** @deprecated Use `Shop`. */
|
|
462
|
+
export type NovaShop = Shop;
|
|
463
|
+
/** @deprecated Use `Market`. */
|
|
464
|
+
export type NovaMarket = Market;
|
|
465
|
+
/** @deprecated Use `Localization`. */
|
|
466
|
+
export type NovaLocalization = Localization;
|
|
467
|
+
/** @deprecated Use `CartSummary`. */
|
|
468
|
+
export type NovaCartSummary = CartSummary;
|
|
469
|
+
/** @deprecated Use `Customer`. */
|
|
470
|
+
export type NovaCustomer = Customer;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The data Nova components receive. Components are presentational: they never
|
|
3
|
+
* fetch. A storefront adapter maps Tanqory API payloads onto these shapes; the
|
|
4
|
+
* lab maps fixtures onto them. Optional means "a real store can lack it" —
|
|
5
|
+
* every component must render (or deliberately render nothing) without it.
|
|
6
|
+
*/
|
|
7
|
+
export const SOCIAL_NETWORKS = ['instagram', 'facebook', 'x', 'tiktok', 'youtube'];
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { RenderContext, ThemeManifest } from '@tanqory/theme-abi';
|
|
2
|
+
import { type ThemeBundle } from './runtime/slots.js';
|
|
3
|
+
import type { ContentNode } from './runtime/kit/types.js';
|
|
4
|
+
import type { Shop } from './runtime/kit/storefront.js';
|
|
5
|
+
import type { PagePlanOptions } from './abi/page-data.js';
|
|
6
|
+
type Settings = Record<string, unknown>;
|
|
7
|
+
export interface RenderOptions {
|
|
8
|
+
/** The theme's ABI manifest — the same object the entry exports as `manifest`. */
|
|
9
|
+
manifest: ThemeManifest;
|
|
10
|
+
/** The theme: its definition, starter content and locales (store-independent, module scope). */
|
|
11
|
+
bundle: ThemeBundle;
|
|
12
|
+
/**
|
|
13
|
+
* The global settings the theme renders with, from the manifest defaults merged with the store's
|
|
14
|
+
* saved values. Runs before anything else; the result is also what the browser hydrates with.
|
|
15
|
+
* Default: unchanged.
|
|
16
|
+
*/
|
|
17
|
+
effectiveSettings?(settings: Settings): Settings;
|
|
18
|
+
/**
|
|
19
|
+
* The page's section nodes as they render under these settings (e.g. a global setting filling a
|
|
20
|
+
* section's own empty one). Pure; runs on the server and again in the browser (`hydrate`), so both
|
|
21
|
+
* build the same tree. Default: unchanged.
|
|
22
|
+
*/
|
|
23
|
+
transformNodes?(nodes: ContentNode[], settings: Settings): ContentNode[];
|
|
24
|
+
/**
|
|
25
|
+
* The settings once the store's shop record is loaded (e.g. the shop's brand colour as the theme
|
|
26
|
+
* colour's fallback). Default: unchanged.
|
|
27
|
+
*/
|
|
28
|
+
shopSettings?(settings: Settings, shop: Shop): Settings;
|
|
29
|
+
/**
|
|
30
|
+
* `<link rel="alternate" hreflang>` for every language the store publishes (`<canonical>?locale=<language>`),
|
|
31
|
+
* plus `x-default` (the canonical URL), on a 200 page of a store with two or more languages (abi/seo.ts
|
|
32
|
+
* `hreflangAlternates`). Default true (2.0.0-alpha.2); `false` leaves them out.
|
|
33
|
+
*/
|
|
34
|
+
hreflang?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* The storefront extras a theme written against `@tanqory/theme-kit/headless` relies on. Absent (Nova, and every
|
|
37
|
+
* theme built on 2.0.0-alpha.0): the render is exactly the earlier one. Present (`storefront: {}` is enough),
|
|
38
|
+
* every member defaults to on unless it says otherwise.
|
|
39
|
+
*/
|
|
40
|
+
storefront?: StorefrontOptions;
|
|
41
|
+
}
|
|
42
|
+
/** `RenderOptions.storefront`. */
|
|
43
|
+
export interface StorefrontOptions {
|
|
44
|
+
/** BreadcrumbList JSON-LD on product, collection, page and article pages, and CollectionPage JSON-LD on a collection. Default true. */
|
|
45
|
+
structuredData?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* The merchant's dashboard wording for the theme's strings (`ctx.data.localization.strings`), used by `t()`
|
|
48
|
+
* from the headless API. One data call, made beside the page's first round. Default true.
|
|
49
|
+
*/
|
|
50
|
+
merchantStrings?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Data the page loads whatever its sections are called. Default: none of them, so a page that shows no market
|
|
53
|
+
* selector does not vary on the shopper's country.
|
|
54
|
+
*/
|
|
55
|
+
plan?: Omit<PagePlanOptions, 'reservedCalls'>;
|
|
56
|
+
}
|
|
57
|
+
export type RenderFunction = (request: Request, ctx: RenderContext) => Promise<Response>;
|
|
58
|
+
/**
|
|
59
|
+
* The ABI `render(request, ctx)` for one theme. Call it once at module scope: it hands the theme
|
|
60
|
+
* bundle to the runtime and registers the theme's sections (store-independent state only).
|
|
61
|
+
*/
|
|
62
|
+
export declare function createRender(options: RenderOptions): RenderFunction;
|
|
63
|
+
export type { ThemeBundle } from './runtime/slots.js';
|
|
64
|
+
export type { ContentNode } from './runtime/kit/types.js';
|
|
65
|
+
export type { PageData, NativeFormResult } from './abi/page-data.js';
|