@numueg/theme-sdk 0.10.1 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +139 -0
- package/dist/{chunk-O4GLTNLE.cjs → chunk-H7RGDWSU.cjs} +3 -3
- package/dist/{chunk-O4GLTNLE.cjs.map → chunk-H7RGDWSU.cjs.map} +1 -1
- package/dist/{chunk-QFFTHIFZ.mjs → chunk-QPXMBK5U.mjs} +3 -3
- package/dist/{chunk-QFFTHIFZ.mjs.map → chunk-QPXMBK5U.mjs.map} +1 -1
- package/dist/{entities-B8378GKp.d.mts → entities-DRKn04q0.d.mts} +77 -1
- package/dist/{entities-B8378GKp.d.ts → entities-DRKn04q0.d.ts} +77 -1
- package/dist/index.cjs +336 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +492 -8
- package/dist/index.d.ts +492 -8
- package/dist/index.mjs +305 -21
- package/dist/index.mjs.map +1 -1
- package/dist/{mount-BDo4a42I.d.mts → mount-BTaDtz8k.d.mts} +1 -1
- package/dist/{mount-DQZu8aBB.d.ts → mount-CLQniVfc.d.ts} +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/v2-compat.d.mts +1 -1
- package/dist/v2-compat.d.ts +1 -1
- package/dist/validation.cjs +11 -11
- package/dist/validation.mjs +1 -1
- package/dist/verify.cjs +3 -3
- package/dist/verify.d.mts +2 -2
- package/dist/verify.d.ts +2 -2
- package/dist/verify.mjs +2 -2
- package/package.json +1 -1
|
@@ -1,3 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A merchant-defined typed field (metafield) exposed on a storefront entity.
|
|
3
|
+
* Only PUBLIC metafields reach the storefront; the value is already coerced
|
|
4
|
+
* to its declared type by the platform (string/number/boolean/date/json/url).
|
|
5
|
+
* Themes usually bind these via a dynamic source
|
|
6
|
+
* (`product.metafield:{namespace}.{key}`) rather than reading the array, but
|
|
7
|
+
* the typed array is available for direct rendering (e.g. a spec table).
|
|
8
|
+
*/
|
|
9
|
+
interface Metafield {
|
|
10
|
+
namespace: string;
|
|
11
|
+
key: string;
|
|
12
|
+
type: string;
|
|
13
|
+
value: unknown;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Blog + Article (merchant content marketing). Text fields are bilingual
|
|
17
|
+
* maps (`{en, ar}`) — resolve with the theme's `localized()` helper or
|
|
18
|
+
* `useLocalization().locale`. Only PUBLISHED content reaches the
|
|
19
|
+
* storefront; the body arrives as UN-sanitized merchant HTML — render it
|
|
20
|
+
* through `<RichText>` (never raw dangerouslySetInnerHTML).
|
|
21
|
+
*/
|
|
22
|
+
interface BlogSummary {
|
|
23
|
+
handle: string;
|
|
24
|
+
title: Record<string, string>;
|
|
25
|
+
description?: Record<string, string> | null;
|
|
26
|
+
}
|
|
27
|
+
interface ArticleSummary {
|
|
28
|
+
handle: string;
|
|
29
|
+
title: Record<string, string>;
|
|
30
|
+
excerpt?: Record<string, string> | null;
|
|
31
|
+
image_url?: string | null;
|
|
32
|
+
published_at?: string | null;
|
|
33
|
+
author?: string | null;
|
|
34
|
+
tags?: string[];
|
|
35
|
+
}
|
|
36
|
+
interface ArticleDetail extends ArticleSummary {
|
|
37
|
+
body?: Record<string, string> | null;
|
|
38
|
+
seo?: Record<string, unknown> | null;
|
|
39
|
+
blog?: BlogSummary | null;
|
|
40
|
+
}
|
|
1
41
|
/** Core store entity */
|
|
2
42
|
interface Store {
|
|
3
43
|
id: string;
|
|
@@ -45,6 +85,8 @@ interface Product {
|
|
|
45
85
|
* shape is open-ended; `useProductSizeChart` narrows the size-chart slot.
|
|
46
86
|
*/
|
|
47
87
|
attributes?: Record<string, unknown>;
|
|
88
|
+
/** Public merchant-defined typed fields. See {@link Metafield}. */
|
|
89
|
+
metafields?: Metafield[];
|
|
48
90
|
}
|
|
49
91
|
/**
|
|
50
92
|
* Size-chart resolution mode (mirrors the merchant hub's editor).
|
|
@@ -139,6 +181,8 @@ interface Collection {
|
|
|
139
181
|
image_url?: string;
|
|
140
182
|
product_count: number;
|
|
141
183
|
products?: Product[];
|
|
184
|
+
/** Public merchant-defined typed fields. See {@link Metafield}. */
|
|
185
|
+
metafields?: Metafield[];
|
|
142
186
|
}
|
|
143
187
|
/** Cart entity */
|
|
144
188
|
interface Cart {
|
|
@@ -150,6 +194,32 @@ interface Cart {
|
|
|
150
194
|
discount_code?: string;
|
|
151
195
|
discount_amount?: number;
|
|
152
196
|
note?: string;
|
|
197
|
+
/**
|
|
198
|
+
* Total of the automatic (no-code) promotions priced into this cart, in
|
|
199
|
+
* MAJOR units — same convention as `subtotal` / `total` /
|
|
200
|
+
* `discount_amount`. `normalizeCartFromServer` converts it from the
|
|
201
|
+
* backend's `automatic_discount_cents` and renames it here on purpose:
|
|
202
|
+
* a field called `_cents` that holds pounds is the single easiest way to
|
|
203
|
+
* get a 100x bug into a theme.
|
|
204
|
+
*/
|
|
205
|
+
automatic_discount?: number;
|
|
206
|
+
/**
|
|
207
|
+
* Which automatic offers fired, and what each one saved — same shape as
|
|
208
|
+
* `Order.applied_promotions` so one component renders the cart, the
|
|
209
|
+
* checkout summary and the order.
|
|
210
|
+
*
|
|
211
|
+
* ⚠️ `amount` is in MAJOR units here (unlike the identically-named field
|
|
212
|
+
* on `Order`, which a theme reads straight from the API in cents). The
|
|
213
|
+
* cart passes through `normalizeCartFromServer`; the order does not.
|
|
214
|
+
* Never divide these by 100 again, and never recompute a saving in the
|
|
215
|
+
* theme — this number is the engine's, and the engine is what charges.
|
|
216
|
+
*/
|
|
217
|
+
applied_promotions?: {
|
|
218
|
+
id: string;
|
|
219
|
+
title: string;
|
|
220
|
+
title_ar?: string;
|
|
221
|
+
amount: number;
|
|
222
|
+
}[];
|
|
153
223
|
}
|
|
154
224
|
interface CartItem {
|
|
155
225
|
id: string;
|
|
@@ -160,6 +230,12 @@ interface CartItem {
|
|
|
160
230
|
price: number;
|
|
161
231
|
quantity: number;
|
|
162
232
|
variant_name?: string;
|
|
233
|
+
/**
|
|
234
|
+
* The product's category. Present so a theme can count how many cart units
|
|
235
|
+
* belong to a category-scoped offer (see `offerProgress`'s `eligibleUnits`)
|
|
236
|
+
* without a second fetch. Not always populated — treat it as a hint.
|
|
237
|
+
*/
|
|
238
|
+
category_id?: string | null;
|
|
163
239
|
}
|
|
164
240
|
/** Customer entity */
|
|
165
241
|
interface Customer {
|
|
@@ -237,4 +313,4 @@ interface Page {
|
|
|
237
313
|
template?: string;
|
|
238
314
|
}
|
|
239
315
|
|
|
240
|
-
export type { Address as A, Cart as C, Order as O, Page as P, SizeChart as S, CartItem as a, Collection as b, Customer as c, OrderItem as d, Product as e, ProductImage as f, ProductVariant as g, SizeChartMode as h, Store as i,
|
|
316
|
+
export type { Address as A, BlogSummary as B, Cart as C, Metafield as M, Order as O, Page as P, SizeChart as S, CartItem as a, Collection as b, Customer as c, OrderItem as d, Product as e, ProductImage as f, ProductVariant as g, SizeChartMode as h, Store as i, ArticleDetail as j, ArticleSummary as k, ProductOption as l };
|
|
@@ -1,3 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A merchant-defined typed field (metafield) exposed on a storefront entity.
|
|
3
|
+
* Only PUBLIC metafields reach the storefront; the value is already coerced
|
|
4
|
+
* to its declared type by the platform (string/number/boolean/date/json/url).
|
|
5
|
+
* Themes usually bind these via a dynamic source
|
|
6
|
+
* (`product.metafield:{namespace}.{key}`) rather than reading the array, but
|
|
7
|
+
* the typed array is available for direct rendering (e.g. a spec table).
|
|
8
|
+
*/
|
|
9
|
+
interface Metafield {
|
|
10
|
+
namespace: string;
|
|
11
|
+
key: string;
|
|
12
|
+
type: string;
|
|
13
|
+
value: unknown;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Blog + Article (merchant content marketing). Text fields are bilingual
|
|
17
|
+
* maps (`{en, ar}`) — resolve with the theme's `localized()` helper or
|
|
18
|
+
* `useLocalization().locale`. Only PUBLISHED content reaches the
|
|
19
|
+
* storefront; the body arrives as UN-sanitized merchant HTML — render it
|
|
20
|
+
* through `<RichText>` (never raw dangerouslySetInnerHTML).
|
|
21
|
+
*/
|
|
22
|
+
interface BlogSummary {
|
|
23
|
+
handle: string;
|
|
24
|
+
title: Record<string, string>;
|
|
25
|
+
description?: Record<string, string> | null;
|
|
26
|
+
}
|
|
27
|
+
interface ArticleSummary {
|
|
28
|
+
handle: string;
|
|
29
|
+
title: Record<string, string>;
|
|
30
|
+
excerpt?: Record<string, string> | null;
|
|
31
|
+
image_url?: string | null;
|
|
32
|
+
published_at?: string | null;
|
|
33
|
+
author?: string | null;
|
|
34
|
+
tags?: string[];
|
|
35
|
+
}
|
|
36
|
+
interface ArticleDetail extends ArticleSummary {
|
|
37
|
+
body?: Record<string, string> | null;
|
|
38
|
+
seo?: Record<string, unknown> | null;
|
|
39
|
+
blog?: BlogSummary | null;
|
|
40
|
+
}
|
|
1
41
|
/** Core store entity */
|
|
2
42
|
interface Store {
|
|
3
43
|
id: string;
|
|
@@ -45,6 +85,8 @@ interface Product {
|
|
|
45
85
|
* shape is open-ended; `useProductSizeChart` narrows the size-chart slot.
|
|
46
86
|
*/
|
|
47
87
|
attributes?: Record<string, unknown>;
|
|
88
|
+
/** Public merchant-defined typed fields. See {@link Metafield}. */
|
|
89
|
+
metafields?: Metafield[];
|
|
48
90
|
}
|
|
49
91
|
/**
|
|
50
92
|
* Size-chart resolution mode (mirrors the merchant hub's editor).
|
|
@@ -139,6 +181,8 @@ interface Collection {
|
|
|
139
181
|
image_url?: string;
|
|
140
182
|
product_count: number;
|
|
141
183
|
products?: Product[];
|
|
184
|
+
/** Public merchant-defined typed fields. See {@link Metafield}. */
|
|
185
|
+
metafields?: Metafield[];
|
|
142
186
|
}
|
|
143
187
|
/** Cart entity */
|
|
144
188
|
interface Cart {
|
|
@@ -150,6 +194,32 @@ interface Cart {
|
|
|
150
194
|
discount_code?: string;
|
|
151
195
|
discount_amount?: number;
|
|
152
196
|
note?: string;
|
|
197
|
+
/**
|
|
198
|
+
* Total of the automatic (no-code) promotions priced into this cart, in
|
|
199
|
+
* MAJOR units — same convention as `subtotal` / `total` /
|
|
200
|
+
* `discount_amount`. `normalizeCartFromServer` converts it from the
|
|
201
|
+
* backend's `automatic_discount_cents` and renames it here on purpose:
|
|
202
|
+
* a field called `_cents` that holds pounds is the single easiest way to
|
|
203
|
+
* get a 100x bug into a theme.
|
|
204
|
+
*/
|
|
205
|
+
automatic_discount?: number;
|
|
206
|
+
/**
|
|
207
|
+
* Which automatic offers fired, and what each one saved — same shape as
|
|
208
|
+
* `Order.applied_promotions` so one component renders the cart, the
|
|
209
|
+
* checkout summary and the order.
|
|
210
|
+
*
|
|
211
|
+
* ⚠️ `amount` is in MAJOR units here (unlike the identically-named field
|
|
212
|
+
* on `Order`, which a theme reads straight from the API in cents). The
|
|
213
|
+
* cart passes through `normalizeCartFromServer`; the order does not.
|
|
214
|
+
* Never divide these by 100 again, and never recompute a saving in the
|
|
215
|
+
* theme — this number is the engine's, and the engine is what charges.
|
|
216
|
+
*/
|
|
217
|
+
applied_promotions?: {
|
|
218
|
+
id: string;
|
|
219
|
+
title: string;
|
|
220
|
+
title_ar?: string;
|
|
221
|
+
amount: number;
|
|
222
|
+
}[];
|
|
153
223
|
}
|
|
154
224
|
interface CartItem {
|
|
155
225
|
id: string;
|
|
@@ -160,6 +230,12 @@ interface CartItem {
|
|
|
160
230
|
price: number;
|
|
161
231
|
quantity: number;
|
|
162
232
|
variant_name?: string;
|
|
233
|
+
/**
|
|
234
|
+
* The product's category. Present so a theme can count how many cart units
|
|
235
|
+
* belong to a category-scoped offer (see `offerProgress`'s `eligibleUnits`)
|
|
236
|
+
* without a second fetch. Not always populated — treat it as a hint.
|
|
237
|
+
*/
|
|
238
|
+
category_id?: string | null;
|
|
163
239
|
}
|
|
164
240
|
/** Customer entity */
|
|
165
241
|
interface Customer {
|
|
@@ -237,4 +313,4 @@ interface Page {
|
|
|
237
313
|
template?: string;
|
|
238
314
|
}
|
|
239
315
|
|
|
240
|
-
export type { Address as A, Cart as C, Order as O, Page as P, SizeChart as S, CartItem as a, Collection as b, Customer as c, OrderItem as d, Product as e, ProductImage as f, ProductVariant as g, SizeChartMode as h, Store as i,
|
|
316
|
+
export type { Address as A, BlogSummary as B, Cart as C, Metafield as M, Order as O, Page as P, SizeChart as S, CartItem as a, Collection as b, Customer as c, OrderItem as d, Product as e, ProductImage as f, ProductVariant as g, SizeChartMode as h, Store as i, ArticleDetail as j, ArticleSummary as k, ProductOption as l };
|