@shoppexio/storefront 0.3.7 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +201 -42
- package/dist/__tests__/affiliates.test.d.ts +2 -0
- package/dist/__tests__/affiliates.test.d.ts.map +1 -0
- package/dist/__tests__/analytics.test.d.ts +2 -0
- package/dist/__tests__/analytics.test.d.ts.map +1 -0
- package/dist/__tests__/cache.test.d.ts +2 -0
- package/dist/__tests__/cache.test.d.ts.map +1 -0
- package/dist/__tests__/cart.test.d.ts +2 -0
- package/dist/__tests__/cart.test.d.ts.map +1 -0
- package/dist/__tests__/checkout.test.d.ts +2 -0
- package/dist/__tests__/checkout.test.d.ts.map +1 -0
- package/dist/__tests__/client.test.d.ts +2 -0
- package/dist/__tests__/client.test.d.ts.map +1 -0
- package/dist/__tests__/config.test.d.ts +2 -0
- package/dist/__tests__/config.test.d.ts.map +1 -0
- package/dist/__tests__/coupons.test.d.ts +2 -0
- package/dist/__tests__/coupons.test.d.ts.map +1 -0
- package/dist/__tests__/endpoint.test.d.ts +2 -0
- package/dist/__tests__/endpoint.test.d.ts.map +1 -0
- package/dist/__tests__/invoices.test.d.ts +2 -0
- package/dist/__tests__/invoices.test.d.ts.map +1 -0
- package/dist/__tests__/navigation.test.d.ts +2 -0
- package/dist/__tests__/navigation.test.d.ts.map +1 -0
- package/dist/__tests__/pages.test.d.ts +2 -0
- package/dist/__tests__/pages.test.d.ts.map +1 -0
- package/dist/__tests__/products.test.d.ts +2 -0
- package/dist/__tests__/products.test.d.ts.map +1 -0
- package/dist/__tests__/reviews.test.d.ts +2 -0
- package/dist/__tests__/reviews.test.d.ts.map +1 -0
- package/dist/__tests__/sdk.smoke.test.d.ts +2 -0
- package/dist/__tests__/sdk.smoke.test.d.ts.map +1 -0
- package/dist/__tests__/search.test.d.ts +2 -0
- package/dist/__tests__/search.test.d.ts.map +1 -0
- package/dist/__tests__/setup.d.ts +2 -0
- package/dist/__tests__/setup.d.ts.map +1 -0
- package/dist/__tests__/store.test.d.ts +2 -0
- package/dist/__tests__/store.test.d.ts.map +1 -0
- package/dist/__tests__/storefront-custom-fields.test.d.ts +2 -0
- package/dist/__tests__/storefront-custom-fields.test.d.ts.map +1 -0
- package/dist/__tests__/storefront-stock.test.d.ts +2 -0
- package/dist/__tests__/storefront-stock.test.d.ts.map +1 -0
- package/dist/__tests__/theme.test.d.ts +2 -0
- package/dist/__tests__/theme.test.d.ts.map +1 -0
- package/dist/core/cache.d.ts +26 -0
- package/dist/core/cache.d.ts.map +1 -0
- package/dist/core/client.d.ts +17 -0
- package/dist/core/client.d.ts.map +1 -0
- package/dist/core/config.d.ts +10 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/endpoint.d.ts +2 -0
- package/dist/core/endpoint.d.ts.map +1 -0
- package/dist/core/errors.d.ts +22 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/telemetry.d.ts +20 -0
- package/dist/core/telemetry.d.ts.map +1 -0
- package/dist/core/typed-client.d.ts +15 -0
- package/dist/core/typed-client.d.ts.map +1 -0
- package/dist/index.d.ts +34 -1118
- package/dist/index.d.ts.map +1 -0
- package/dist/modules/affiliates.d.ts +15 -0
- package/dist/modules/affiliates.d.ts.map +1 -0
- package/dist/modules/analytics.d.ts +2 -0
- package/dist/modules/analytics.d.ts.map +1 -0
- package/dist/modules/cart.d.ts +21 -0
- package/dist/modules/cart.d.ts.map +1 -0
- package/dist/modules/checkout.d.ts +28 -0
- package/dist/modules/checkout.d.ts.map +1 -0
- package/dist/modules/coupons.d.ts +3 -0
- package/dist/modules/coupons.d.ts.map +1 -0
- package/dist/modules/invoices.d.ts +6 -0
- package/dist/modules/invoices.d.ts.map +1 -0
- package/dist/modules/navigation.d.ts +20 -0
- package/dist/modules/navigation.d.ts.map +1 -0
- package/dist/modules/pages.d.ts +10 -0
- package/dist/modules/pages.d.ts.map +1 -0
- package/dist/modules/presence.d.ts +6 -0
- package/dist/modules/presence.d.ts.map +1 -0
- package/dist/modules/products.d.ts +16 -0
- package/dist/modules/products.d.ts.map +1 -0
- package/dist/modules/reviews.d.ts +3 -0
- package/dist/modules/reviews.d.ts.map +1 -0
- package/dist/modules/search.d.ts +6 -0
- package/dist/modules/search.d.ts.map +1 -0
- package/dist/modules/store.d.ts +11 -0
- package/dist/modules/store.d.ts.map +1 -0
- package/dist/modules/theme.d.ts +27 -0
- package/dist/modules/theme.d.ts.map +1 -0
- package/dist/shoppex.esm.js +3 -0
- package/dist/shoppex.esm.js.map +1 -0
- package/dist/shoppex.umd.js +2 -0
- package/dist/shoppex.umd.js.map +1 -0
- package/dist/types/api.d.ts +580 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/cart.d.ts +102 -0
- package/dist/types/cart.d.ts.map +1 -0
- package/dist/types/config.d.ts +18 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/theme-config.d.ts +109 -0
- package/dist/types/theme-config.d.ts.map +1 -0
- package/dist/utils/format.d.ts +6 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/storage.d.ts +10 -0
- package/dist/utils/storage.d.ts.map +1 -0
- package/dist/utils/storefront-custom-fields.d.ts +13 -0
- package/dist/utils/storefront-custom-fields.d.ts.map +1 -0
- package/dist/utils/storefront-stock.d.ts +10 -0
- package/dist/utils/storefront-stock.d.ts.map +1 -0
- package/package.json +38 -20
- package/CHANGELOG.md +0 -20
- package/LICENSE +0 -21
- package/dist/index.cjs +0 -18360
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -1192
- package/dist/index.js +0 -18318
- package/dist/index.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,1118 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
data: T;
|
|
33
|
-
error: string | null;
|
|
34
|
-
message?: string | null;
|
|
35
|
-
}
|
|
36
|
-
interface SDKResponse<T> {
|
|
37
|
-
success: boolean;
|
|
38
|
-
data?: T;
|
|
39
|
-
message?: string;
|
|
40
|
-
}
|
|
41
|
-
interface Shop {
|
|
42
|
-
id: string;
|
|
43
|
-
name: string;
|
|
44
|
-
slug: string;
|
|
45
|
-
domain?: string;
|
|
46
|
-
description?: string;
|
|
47
|
-
title?: string;
|
|
48
|
-
message?: string;
|
|
49
|
-
url?: string;
|
|
50
|
-
logo?: string;
|
|
51
|
-
banner?: string;
|
|
52
|
-
avatar?: string;
|
|
53
|
-
average_score?: number | null;
|
|
54
|
-
rating?: number | null;
|
|
55
|
-
products_sold_count?: number;
|
|
56
|
-
customers_count?: number;
|
|
57
|
-
hide_products_sold?: boolean;
|
|
58
|
-
currency: string;
|
|
59
|
-
tos_enabled?: boolean;
|
|
60
|
-
dark_mode?: boolean;
|
|
61
|
-
search_enabled?: boolean;
|
|
62
|
-
sort_enabled?: boolean;
|
|
63
|
-
cart_enabled?: boolean;
|
|
64
|
-
hide_out_of_stock?: boolean;
|
|
65
|
-
hide_stock_counter?: boolean;
|
|
66
|
-
center_product_titles?: boolean;
|
|
67
|
-
center_group_titles?: boolean;
|
|
68
|
-
default_sort?: string;
|
|
69
|
-
social?: Record<string, string | null>;
|
|
70
|
-
discord_link?: string | null;
|
|
71
|
-
twitter_link?: string | null;
|
|
72
|
-
instagram_link?: string | null;
|
|
73
|
-
facebook_link?: string | null;
|
|
74
|
-
telegram_link?: string | null;
|
|
75
|
-
youtube_link?: string | null;
|
|
76
|
-
reddit_link?: string | null;
|
|
77
|
-
tiktok_link?: string | null;
|
|
78
|
-
verified?: boolean;
|
|
79
|
-
on_hold?: boolean;
|
|
80
|
-
theme?: ShopTheme | null;
|
|
81
|
-
builder_settings?: Record<string, unknown> | null;
|
|
82
|
-
feedback?: ShopFeedback;
|
|
83
|
-
trusted_checks?: TrustedChecks | null;
|
|
84
|
-
available_gateways?: string[];
|
|
85
|
-
reward_program_summary?: RewardProgramSummary | null;
|
|
86
|
-
}
|
|
87
|
-
interface RewardProgramTeaserItem {
|
|
88
|
-
trigger_type: RewardReason;
|
|
89
|
-
action_type: RewardActionType;
|
|
90
|
-
label: string;
|
|
91
|
-
}
|
|
92
|
-
interface RewardProgramSummary {
|
|
93
|
-
enabled: boolean;
|
|
94
|
-
headline: string;
|
|
95
|
-
items: RewardProgramTeaserItem[];
|
|
96
|
-
}
|
|
97
|
-
interface ShopTheme {
|
|
98
|
-
primary_color?: string;
|
|
99
|
-
secondary_color?: string;
|
|
100
|
-
font?: string;
|
|
101
|
-
logo?: string | null;
|
|
102
|
-
logo_cloudflare_image_id?: string | null;
|
|
103
|
-
background_image?: string | null;
|
|
104
|
-
background_image_cloudflare_image_id?: string | null;
|
|
105
|
-
cards_in_row?: number | string;
|
|
106
|
-
cards_align?: string;
|
|
107
|
-
card_animation?: string;
|
|
108
|
-
dark_color?: string;
|
|
109
|
-
light_color?: string;
|
|
110
|
-
border_color?: string;
|
|
111
|
-
button_color?: string;
|
|
112
|
-
}
|
|
113
|
-
interface ShopFeedback {
|
|
114
|
-
positive: number;
|
|
115
|
-
neutral: number;
|
|
116
|
-
negative: number;
|
|
117
|
-
total: number;
|
|
118
|
-
}
|
|
119
|
-
interface TrustedChecks {
|
|
120
|
-
identity_verified?: boolean;
|
|
121
|
-
feedback_score?: string | null;
|
|
122
|
-
trusted_score?: number;
|
|
123
|
-
sales_last14days_metric?: string;
|
|
124
|
-
}
|
|
125
|
-
interface ProductCategory {
|
|
126
|
-
uniqid: string;
|
|
127
|
-
title: string;
|
|
128
|
-
description?: string | null;
|
|
129
|
-
image_attachment?: string | null;
|
|
130
|
-
image_name?: string | null;
|
|
131
|
-
image_storage?: string | null;
|
|
132
|
-
cloudflare_image_id?: string | null;
|
|
133
|
-
cdn_image_url?: string | null;
|
|
134
|
-
}
|
|
135
|
-
interface Product {
|
|
136
|
-
id?: string;
|
|
137
|
-
uniqid: string;
|
|
138
|
-
title: string;
|
|
139
|
-
slug?: string | null;
|
|
140
|
-
description?: string | null;
|
|
141
|
-
product_highlights?: string[];
|
|
142
|
-
price: string;
|
|
143
|
-
price_display?: string;
|
|
144
|
-
price_discount?: number;
|
|
145
|
-
currency: string;
|
|
146
|
-
stock?: number;
|
|
147
|
-
quantity_min?: number;
|
|
148
|
-
quantity_max?: number;
|
|
149
|
-
min_quantity?: number;
|
|
150
|
-
max_quantity?: number;
|
|
151
|
-
on_hold?: boolean | number;
|
|
152
|
-
unlisted?: boolean | number;
|
|
153
|
-
private?: boolean | number;
|
|
154
|
-
bestseller?: boolean | number;
|
|
155
|
-
type?: string;
|
|
156
|
-
subtype?: string | null;
|
|
157
|
-
isSubscription?: boolean;
|
|
158
|
-
isGroup?: boolean;
|
|
159
|
-
images: ProductImage[];
|
|
160
|
-
image_name?: string | null;
|
|
161
|
-
image_storage?: string | null;
|
|
162
|
-
cloudflare_image_id?: string | null;
|
|
163
|
-
image_attachment?: string | null;
|
|
164
|
-
sold_count?: number;
|
|
165
|
-
soldCount?: number;
|
|
166
|
-
image_attachments?: unknown[];
|
|
167
|
-
file_attachments?: unknown[];
|
|
168
|
-
variants?: ProductVariant[];
|
|
169
|
-
addons?: ProductAddon[];
|
|
170
|
-
price_variants?: PriceVariant[];
|
|
171
|
-
volume_discounts?: unknown;
|
|
172
|
-
custom_fields?: string | unknown[] | null;
|
|
173
|
-
categories?: ProductCategory[];
|
|
174
|
-
bundles?: ProductBundle[];
|
|
175
|
-
faqs?: ProductFaq[];
|
|
176
|
-
subscription?: Subscription;
|
|
177
|
-
feedbacks?: Feedback[];
|
|
178
|
-
feedback?: ProductFeedback;
|
|
179
|
-
cdn_image_url?: string;
|
|
180
|
-
detail_image_url?: string | null;
|
|
181
|
-
recurring_interval?: string | null;
|
|
182
|
-
recurring_interval_count?: number | null;
|
|
183
|
-
trial_period?: number | null;
|
|
184
|
-
setup_cost?: string;
|
|
185
|
-
licensing_enabled?: boolean | number;
|
|
186
|
-
license_period?: number | null;
|
|
187
|
-
gateways?: string;
|
|
188
|
-
delivery_text?: string;
|
|
189
|
-
service_text?: string;
|
|
190
|
-
terms_of_service?: string | null;
|
|
191
|
-
warranty?: number;
|
|
192
|
-
warranty_text?: string | null;
|
|
193
|
-
sort_priority?: number;
|
|
194
|
-
price_conversions?: Record<string, number>;
|
|
195
|
-
pay_what_you_want?: boolean | number;
|
|
196
|
-
cost?: string | null;
|
|
197
|
-
cost_display?: string | null;
|
|
198
|
-
}
|
|
199
|
-
interface ProductFeedback {
|
|
200
|
-
total: number;
|
|
201
|
-
positive: number;
|
|
202
|
-
neutral: number;
|
|
203
|
-
negative: number;
|
|
204
|
-
numbers?: Record<number, number>;
|
|
205
|
-
list?: Array<{
|
|
206
|
-
score: number;
|
|
207
|
-
message: string | null;
|
|
208
|
-
reply: string | null;
|
|
209
|
-
created_at: string | null;
|
|
210
|
-
createdAt?: string | null;
|
|
211
|
-
updated_at: string | null;
|
|
212
|
-
updatedAt?: string | null;
|
|
213
|
-
is_automated?: boolean;
|
|
214
|
-
isAutomated?: boolean;
|
|
215
|
-
}>;
|
|
216
|
-
}
|
|
217
|
-
interface ProductImage {
|
|
218
|
-
id: string;
|
|
219
|
-
url: string;
|
|
220
|
-
cloudflare_image_id?: string;
|
|
221
|
-
alt?: string;
|
|
222
|
-
}
|
|
223
|
-
interface ProductVariant {
|
|
224
|
-
id: string;
|
|
225
|
-
title: string;
|
|
226
|
-
price?: number;
|
|
227
|
-
stock?: number;
|
|
228
|
-
quantity_min?: number;
|
|
229
|
-
quantity_max?: number;
|
|
230
|
-
quantityMin?: number;
|
|
231
|
-
quantityMax?: number;
|
|
232
|
-
image_id?: string | null;
|
|
233
|
-
imageId?: string | null;
|
|
234
|
-
cloudflare_image_id?: string | null;
|
|
235
|
-
cloudflareImageId?: string | null;
|
|
236
|
-
image_url?: string | null;
|
|
237
|
-
imageUrl?: string | null;
|
|
238
|
-
}
|
|
239
|
-
interface ProductAddon {
|
|
240
|
-
id: string;
|
|
241
|
-
name?: string;
|
|
242
|
-
title?: string;
|
|
243
|
-
price: number;
|
|
244
|
-
required?: boolean;
|
|
245
|
-
}
|
|
246
|
-
interface PriceVariant {
|
|
247
|
-
id: string;
|
|
248
|
-
label?: string;
|
|
249
|
-
title?: string;
|
|
250
|
-
price: number;
|
|
251
|
-
stock?: number;
|
|
252
|
-
quantity_min?: number;
|
|
253
|
-
quantity_max?: number;
|
|
254
|
-
quantityMin?: number;
|
|
255
|
-
quantityMax?: number;
|
|
256
|
-
image_id?: string | null;
|
|
257
|
-
imageId?: string | null;
|
|
258
|
-
cloudflare_image_id?: string | null;
|
|
259
|
-
cloudflareImageId?: string | null;
|
|
260
|
-
image_url?: string | null;
|
|
261
|
-
imageUrl?: string | null;
|
|
262
|
-
}
|
|
263
|
-
interface CustomFieldDefinition {
|
|
264
|
-
id: string;
|
|
265
|
-
name: string;
|
|
266
|
-
type: 'text' | 'textarea' | 'select' | 'checkbox';
|
|
267
|
-
required?: boolean;
|
|
268
|
-
options?: string[];
|
|
269
|
-
}
|
|
270
|
-
interface Feedback {
|
|
271
|
-
id: string;
|
|
272
|
-
rating: number;
|
|
273
|
-
score?: number;
|
|
274
|
-
author?: string;
|
|
275
|
-
customer_name?: string;
|
|
276
|
-
comment?: string;
|
|
277
|
-
message?: string | null;
|
|
278
|
-
reply?: string | null;
|
|
279
|
-
is_automated?: boolean;
|
|
280
|
-
isAutomated?: boolean;
|
|
281
|
-
product_id?: string | null;
|
|
282
|
-
product_title?: string | null;
|
|
283
|
-
cloudflare_image_id?: string | null;
|
|
284
|
-
created_at: string;
|
|
285
|
-
updated_at?: string | number | null;
|
|
286
|
-
}
|
|
287
|
-
interface ProductBundle {
|
|
288
|
-
id?: string;
|
|
289
|
-
uniqid?: string;
|
|
290
|
-
title?: string;
|
|
291
|
-
discount_type?: 'PERCENTAGE' | 'FIXED';
|
|
292
|
-
discount_amount?: number;
|
|
293
|
-
products?: ProductBundleProduct[];
|
|
294
|
-
}
|
|
295
|
-
interface ProductBundleProduct {
|
|
296
|
-
id?: string;
|
|
297
|
-
uniqid: string;
|
|
298
|
-
title?: string | null;
|
|
299
|
-
default_variant_id?: string;
|
|
300
|
-
}
|
|
301
|
-
interface ProductFaq {
|
|
302
|
-
id?: string;
|
|
303
|
-
uniqid?: string;
|
|
304
|
-
question: string;
|
|
305
|
-
answer: string;
|
|
306
|
-
}
|
|
307
|
-
interface SubscriptionInterval {
|
|
308
|
-
unit?: string;
|
|
309
|
-
count?: number;
|
|
310
|
-
label?: string;
|
|
311
|
-
}
|
|
312
|
-
interface SubscriptionFlags {
|
|
313
|
-
cancel_anytime?: boolean;
|
|
314
|
-
}
|
|
315
|
-
interface Subscription {
|
|
316
|
-
id?: string;
|
|
317
|
-
name?: string;
|
|
318
|
-
description?: string;
|
|
319
|
-
badge?: string;
|
|
320
|
-
interval?: SubscriptionInterval;
|
|
321
|
-
flags?: SubscriptionFlags;
|
|
322
|
-
}
|
|
323
|
-
interface Invoice {
|
|
324
|
-
uniqid: string;
|
|
325
|
-
status: string;
|
|
326
|
-
total: number;
|
|
327
|
-
currency: string;
|
|
328
|
-
gateway?: string;
|
|
329
|
-
products: InvoiceProduct[];
|
|
330
|
-
created_at: string;
|
|
331
|
-
rewards?: BuyerRewards | null;
|
|
332
|
-
}
|
|
333
|
-
interface InvoiceProduct {
|
|
334
|
-
product_id: string;
|
|
335
|
-
title: string;
|
|
336
|
-
quantity: number;
|
|
337
|
-
price: number;
|
|
338
|
-
}
|
|
339
|
-
type RewardActionType = 'WALLET_CREDIT' | 'COUPON';
|
|
340
|
-
type RewardGrantStatus = 'PENDING' | 'FULFILLED' | 'FAILED' | 'REVOKED';
|
|
341
|
-
type RewardReason = 'ORDER_COMPLETED' | 'ORDER_COUNT_REACHED' | 'SPEND_AMOUNT_REACHED' | 'POSITIVE_REVIEW_LEFT' | 'FIRST_PURCHASE_COMPLETED';
|
|
342
|
-
interface BuyerRewardActivityItem {
|
|
343
|
-
id: string;
|
|
344
|
-
type: RewardActionType;
|
|
345
|
-
status: RewardGrantStatus;
|
|
346
|
-
amount: string | null;
|
|
347
|
-
currency: string | null;
|
|
348
|
-
coupon_code: string | null;
|
|
349
|
-
reason: RewardReason;
|
|
350
|
-
trigger_reference_type: string;
|
|
351
|
-
trigger_reference_id: string;
|
|
352
|
-
created_at: number;
|
|
353
|
-
fulfilled_at: number | null;
|
|
354
|
-
expires_at: number | null;
|
|
355
|
-
}
|
|
356
|
-
interface BuyerRewards {
|
|
357
|
-
summary: {
|
|
358
|
-
available: string;
|
|
359
|
-
pending: string;
|
|
360
|
-
lifetime_earned: string;
|
|
361
|
-
redeemed: string | null;
|
|
362
|
-
currency: string;
|
|
363
|
-
};
|
|
364
|
-
activity: BuyerRewardActivityItem[];
|
|
365
|
-
earned_after_invoice: BuyerRewardActivityItem[];
|
|
366
|
-
pending_after_invoice: BuyerRewardActivityItem[];
|
|
367
|
-
}
|
|
368
|
-
interface CouponValidation {
|
|
369
|
-
valid: boolean;
|
|
370
|
-
discount?: number;
|
|
371
|
-
discount_type?: 'percentage' | 'fixed';
|
|
372
|
-
source?: 'COUPON' | 'AFFILIATE';
|
|
373
|
-
product_restricted?: boolean;
|
|
374
|
-
variant_restricted?: boolean;
|
|
375
|
-
restriction_scope?: 'all' | 'products' | 'variants' | 'products_and_variants';
|
|
376
|
-
allowed_product_ids?: string[];
|
|
377
|
-
allowed_variant_ids?: string[];
|
|
378
|
-
message?: string;
|
|
379
|
-
}
|
|
380
|
-
interface CouponValidationOptions {
|
|
381
|
-
productId?: string;
|
|
382
|
-
variantId?: string;
|
|
383
|
-
}
|
|
384
|
-
interface AffiliateValidation {
|
|
385
|
-
valid: boolean;
|
|
386
|
-
program_enabled?: boolean;
|
|
387
|
-
affiliate_code: string | null;
|
|
388
|
-
discount_active: boolean;
|
|
389
|
-
discount_percent: number;
|
|
390
|
-
message?: string;
|
|
391
|
-
}
|
|
392
|
-
interface ProductGroup {
|
|
393
|
-
id?: string;
|
|
394
|
-
uniqid: string;
|
|
395
|
-
category_id?: string | null;
|
|
396
|
-
slug?: string | null;
|
|
397
|
-
name?: string | null;
|
|
398
|
-
title: string;
|
|
399
|
-
description?: string | null;
|
|
400
|
-
products_bound?: Product[];
|
|
401
|
-
products_count?: number;
|
|
402
|
-
image_attachment?: string | null;
|
|
403
|
-
image_name?: string | null;
|
|
404
|
-
image_storage?: string | null;
|
|
405
|
-
cloudflare_image_id?: string | null;
|
|
406
|
-
cdn_image_url?: string | null;
|
|
407
|
-
sort_priority?: number | null;
|
|
408
|
-
}
|
|
409
|
-
interface Category {
|
|
410
|
-
uniqid: string;
|
|
411
|
-
title: string;
|
|
412
|
-
description?: string | null;
|
|
413
|
-
image_attachment?: string | null;
|
|
414
|
-
image_name?: string | null;
|
|
415
|
-
image_storage?: string | null;
|
|
416
|
-
cloudflare_image_id?: string | null;
|
|
417
|
-
cdn_image_url?: string | null;
|
|
418
|
-
product_uniqids?: string[];
|
|
419
|
-
products_bound?: Product[];
|
|
420
|
-
products_count?: number;
|
|
421
|
-
groups_bound?: ProductGroup[];
|
|
422
|
-
groups_count?: number;
|
|
423
|
-
}
|
|
424
|
-
interface CursorPagination {
|
|
425
|
-
next_cursor: string | null;
|
|
426
|
-
has_more: boolean;
|
|
427
|
-
}
|
|
428
|
-
interface StorefrontAnnouncementBarAddon {
|
|
429
|
-
id: string;
|
|
430
|
-
type: 'announcement_bar';
|
|
431
|
-
slot: string;
|
|
432
|
-
component: 'announcement_bar';
|
|
433
|
-
sort_order: number;
|
|
434
|
-
props: {
|
|
435
|
-
addon_id: string;
|
|
436
|
-
text: string;
|
|
437
|
-
link_label?: string | null;
|
|
438
|
-
link_url?: string | null;
|
|
439
|
-
dismissible: boolean;
|
|
440
|
-
display_mode: 'static' | 'marquee';
|
|
441
|
-
theme_preset: 'brand_blue' | 'emerald' | 'sunset' | 'rose' | 'charcoal' | 'custom';
|
|
442
|
-
animation_speed_seconds: number;
|
|
443
|
-
background_color: string;
|
|
444
|
-
text_color: string;
|
|
445
|
-
};
|
|
446
|
-
}
|
|
447
|
-
interface StorefrontCountdownBarAddon {
|
|
448
|
-
id: string;
|
|
449
|
-
type: 'countdown_bar';
|
|
450
|
-
slot: string;
|
|
451
|
-
component: 'countdown_bar';
|
|
452
|
-
sort_order: number;
|
|
453
|
-
props: {
|
|
454
|
-
addon_id: string;
|
|
455
|
-
text: string;
|
|
456
|
-
end_at: string;
|
|
457
|
-
link_label?: string | null;
|
|
458
|
-
link_url?: string | null;
|
|
459
|
-
dismissible: boolean;
|
|
460
|
-
theme_preset: 'brand_blue' | 'emerald' | 'sunset' | 'rose' | 'charcoal' | 'custom';
|
|
461
|
-
expired_behavior: 'hide' | 'message';
|
|
462
|
-
expired_message?: string | null;
|
|
463
|
-
density: 'compact' | 'comfortable';
|
|
464
|
-
cta_style: 'subtle' | 'outline' | 'solid';
|
|
465
|
-
timer_style: 'minimal' | 'boxed';
|
|
466
|
-
background_color: string;
|
|
467
|
-
text_color: string;
|
|
468
|
-
};
|
|
469
|
-
}
|
|
470
|
-
interface StorefrontPromoInfoCardAddon {
|
|
471
|
-
id: string;
|
|
472
|
-
type: 'promo_info_card';
|
|
473
|
-
slot: string;
|
|
474
|
-
component: 'promo_info_card';
|
|
475
|
-
sort_order: number;
|
|
476
|
-
props: {
|
|
477
|
-
addon_id: string;
|
|
478
|
-
eyebrow?: string | null;
|
|
479
|
-
title: string;
|
|
480
|
-
body: string;
|
|
481
|
-
link_label?: string | null;
|
|
482
|
-
link_url?: string | null;
|
|
483
|
-
theme_preset: 'indigo' | 'emerald' | 'amber' | 'rose' | 'slate' | 'custom';
|
|
484
|
-
layout_style: 'compact' | 'feature' | 'alert';
|
|
485
|
-
density: 'compact' | 'comfortable';
|
|
486
|
-
cta_style: 'subtle' | 'outline' | 'solid';
|
|
487
|
-
icon: 'sparkles' | 'megaphone' | 'gift' | 'truck' | 'shield' | 'support' | 'none';
|
|
488
|
-
icon_visibility: 'show' | 'hide';
|
|
489
|
-
background_color: string;
|
|
490
|
-
text_color: string;
|
|
491
|
-
accent_color: string;
|
|
492
|
-
};
|
|
493
|
-
}
|
|
494
|
-
interface StorefrontRecentPurchasePopupAddon {
|
|
495
|
-
id: string;
|
|
496
|
-
type: 'recent_purchase_popup';
|
|
497
|
-
slot: string;
|
|
498
|
-
component: 'recent_purchase_popup';
|
|
499
|
-
sort_order: number;
|
|
500
|
-
props: {
|
|
501
|
-
addon_id: string;
|
|
502
|
-
title: string;
|
|
503
|
-
cooldown_seconds: number;
|
|
504
|
-
items: Array<{
|
|
505
|
-
customer_label: string;
|
|
506
|
-
product_title: string;
|
|
507
|
-
created_at: string;
|
|
508
|
-
}>;
|
|
509
|
-
};
|
|
510
|
-
}
|
|
511
|
-
interface StorefrontCouponPopupModalAddon {
|
|
512
|
-
id: string;
|
|
513
|
-
type: 'coupon_popup_modal';
|
|
514
|
-
slot: string;
|
|
515
|
-
component: 'coupon_popup_modal';
|
|
516
|
-
sort_order: number;
|
|
517
|
-
props: {
|
|
518
|
-
addon_id: string;
|
|
519
|
-
eyebrow?: string | null;
|
|
520
|
-
title: string;
|
|
521
|
-
body: string;
|
|
522
|
-
coupon_code: string;
|
|
523
|
-
primary_button_label: string;
|
|
524
|
-
secondary_button_label: string;
|
|
525
|
-
disclaimer?: string | null;
|
|
526
|
-
theme_preset: 'midnight' | 'ocean' | 'ember' | 'forest' | 'custom';
|
|
527
|
-
trigger: 'delay' | 'exit_intent';
|
|
528
|
-
delay_seconds: number;
|
|
529
|
-
show_once_per_session: boolean;
|
|
530
|
-
reminder_hours: number;
|
|
531
|
-
background_color: string;
|
|
532
|
-
text_color: string;
|
|
533
|
-
accent_color: string;
|
|
534
|
-
hero_image_url?: string | null;
|
|
535
|
-
discount_display?: string | null;
|
|
536
|
-
expires_at?: string | null;
|
|
537
|
-
};
|
|
538
|
-
}
|
|
539
|
-
type StorefrontAddon = StorefrontAnnouncementBarAddon | StorefrontCountdownBarAddon | StorefrontPromoInfoCardAddon | StorefrontRecentPurchasePopupAddon | StorefrontCouponPopupModalAddon;
|
|
540
|
-
interface StorefrontAddonBootstrap {
|
|
541
|
-
items: StorefrontAddon[];
|
|
542
|
-
}
|
|
543
|
-
interface StorefrontOnlineUsers {
|
|
544
|
-
count: number;
|
|
545
|
-
window_seconds: number;
|
|
546
|
-
}
|
|
547
|
-
type StorefrontItem = {
|
|
548
|
-
item_type: 'PRODUCT' | 'GROUP';
|
|
549
|
-
uniqid: string;
|
|
550
|
-
sort_priority?: number | null;
|
|
551
|
-
title?: string | null;
|
|
552
|
-
name?: string | null;
|
|
553
|
-
};
|
|
554
|
-
interface StorefrontData {
|
|
555
|
-
shop: Shop;
|
|
556
|
-
products: Product[];
|
|
557
|
-
products_pagination?: CursorPagination | null;
|
|
558
|
-
groups: ProductGroup[];
|
|
559
|
-
items: StorefrontItem[];
|
|
560
|
-
categories: Category[];
|
|
561
|
-
addons: StorefrontAddonBootstrap;
|
|
562
|
-
}
|
|
563
|
-
interface Page {
|
|
564
|
-
id: string;
|
|
565
|
-
shop_id?: string;
|
|
566
|
-
slug: string;
|
|
567
|
-
name: string;
|
|
568
|
-
content: string | null;
|
|
569
|
-
template_type: string;
|
|
570
|
-
is_system: boolean;
|
|
571
|
-
settings: Record<string, unknown> | null;
|
|
572
|
-
visible_after: string | null;
|
|
573
|
-
created_at: number;
|
|
574
|
-
updated_at: number;
|
|
575
|
-
}
|
|
576
|
-
interface Menu {
|
|
577
|
-
id: string;
|
|
578
|
-
shop_id: string;
|
|
579
|
-
title: string;
|
|
580
|
-
slot?: NavigationMenuSlot | null;
|
|
581
|
-
item_count?: number | null;
|
|
582
|
-
items?: MenuItem[];
|
|
583
|
-
created_at: number;
|
|
584
|
-
updated_at: number;
|
|
585
|
-
}
|
|
586
|
-
interface MenuItem {
|
|
587
|
-
id: string;
|
|
588
|
-
shop_id?: string;
|
|
589
|
-
menu_id: string;
|
|
590
|
-
page_id: string | null;
|
|
591
|
-
title: string;
|
|
592
|
-
url?: string | null;
|
|
593
|
-
link_type?: 'LINK' | 'PAGE' | 'link' | 'page' | null;
|
|
594
|
-
target?: '_self' | '_blank' | null;
|
|
595
|
-
sort_order: number;
|
|
596
|
-
page_slug: string | null;
|
|
597
|
-
created_at: number;
|
|
598
|
-
updated_at: number;
|
|
599
|
-
children?: MenuItem[];
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
/**
|
|
603
|
-
* Cart Types
|
|
604
|
-
*
|
|
605
|
-
* Extended cart schema supporting Shoppex features:
|
|
606
|
-
* - Addons (express shipping, gift wrap, etc.)
|
|
607
|
-
* - Custom Fields (engraving, gift message, etc.)
|
|
608
|
-
* - Price Variants (different pricing tiers)
|
|
609
|
-
*
|
|
610
|
-
* All fields use snake_case to match API conventions.
|
|
611
|
-
*/
|
|
612
|
-
interface CartAddon {
|
|
613
|
-
id: string;
|
|
614
|
-
quantity?: number;
|
|
615
|
-
}
|
|
616
|
-
interface CartItem {
|
|
617
|
-
product_id: string;
|
|
618
|
-
variant_id: string;
|
|
619
|
-
quantity: number;
|
|
620
|
-
addons?: CartAddon[];
|
|
621
|
-
custom_fields?: Record<string, string>;
|
|
622
|
-
price_variant_id?: string;
|
|
623
|
-
price_data?: {
|
|
624
|
-
unit_price: number;
|
|
625
|
-
};
|
|
626
|
-
}
|
|
627
|
-
interface CartAddOptions {
|
|
628
|
-
addons?: CartAddon[];
|
|
629
|
-
custom_fields?: Record<string, string>;
|
|
630
|
-
price_variant_id?: string;
|
|
631
|
-
price_data?: {
|
|
632
|
-
unit_price: number;
|
|
633
|
-
};
|
|
634
|
-
}
|
|
635
|
-
interface CartPayload {
|
|
636
|
-
store_slug: string;
|
|
637
|
-
items: CartItem[];
|
|
638
|
-
coupon?: string;
|
|
639
|
-
}
|
|
640
|
-
interface CartAppliedDiscount {
|
|
641
|
-
source: 'PRODUCT_DISCOUNT' | 'VOLUME_DISCOUNT' | 'AUTOMATIC_PRODUCT_DEAL' | 'BUNDLE_DEAL' | 'COUPON';
|
|
642
|
-
source_id: string | null;
|
|
643
|
-
source_uniqid: string | null;
|
|
644
|
-
label: string;
|
|
645
|
-
amount: string;
|
|
646
|
-
}
|
|
647
|
-
interface EligibleCartDeal {
|
|
648
|
-
source?: 'AUTOMATIC_PRODUCT_DEAL';
|
|
649
|
-
deal_id: string;
|
|
650
|
-
deal_uniqid: string;
|
|
651
|
-
product_id: string;
|
|
652
|
-
product_uniqid: string | null;
|
|
653
|
-
label: string;
|
|
654
|
-
missing_quantity: number;
|
|
655
|
-
required_quantity: number;
|
|
656
|
-
}
|
|
657
|
-
interface EligibleBundleDealProduct {
|
|
658
|
-
product_id: string;
|
|
659
|
-
product_uniqid: string;
|
|
660
|
-
title: string;
|
|
661
|
-
quantity: number;
|
|
662
|
-
price: string;
|
|
663
|
-
currency: string;
|
|
664
|
-
default_variant_id: string;
|
|
665
|
-
}
|
|
666
|
-
interface EligibleBundleDeal {
|
|
667
|
-
source: 'BUNDLE_DEAL';
|
|
668
|
-
bundle_id: string;
|
|
669
|
-
bundle_uniqid: string;
|
|
670
|
-
label: string;
|
|
671
|
-
discount_type: 'PERCENTAGE' | 'FIXED';
|
|
672
|
-
discount_amount: string;
|
|
673
|
-
missing_products: EligibleBundleDealProduct[];
|
|
674
|
-
products: EligibleBundleDealProduct[];
|
|
675
|
-
}
|
|
676
|
-
interface CartQuote {
|
|
677
|
-
subtotal: string;
|
|
678
|
-
discount: string;
|
|
679
|
-
total: string;
|
|
680
|
-
currency: string;
|
|
681
|
-
applied_discounts: CartAppliedDiscount[];
|
|
682
|
-
automatic_product_deals: Array<Record<string, unknown>>;
|
|
683
|
-
bundle_deals: Array<Record<string, unknown>>;
|
|
684
|
-
eligible_deals: EligibleCartDeal[];
|
|
685
|
-
eligible_bundle_deals: EligibleBundleDeal[];
|
|
686
|
-
}
|
|
687
|
-
interface CartMetadata {
|
|
688
|
-
created_at: number;
|
|
689
|
-
last_modified: number;
|
|
690
|
-
version: number;
|
|
691
|
-
checksum: string;
|
|
692
|
-
}
|
|
693
|
-
interface CartStats {
|
|
694
|
-
item_count: number;
|
|
695
|
-
total_quantity: number;
|
|
696
|
-
last_modified: number;
|
|
697
|
-
version: number;
|
|
698
|
-
has_backup: boolean;
|
|
699
|
-
integrity_valid: boolean;
|
|
700
|
-
total_price: number;
|
|
701
|
-
total_price_is_estimate: boolean;
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
/**
|
|
705
|
-
* SDK Configuration Management
|
|
706
|
-
*/
|
|
707
|
-
|
|
708
|
-
declare function getConfig(): ShoppexConfig;
|
|
709
|
-
declare function isInitialized(): boolean;
|
|
710
|
-
|
|
711
|
-
/**
|
|
712
|
-
* Typed OpenAPI client factory.
|
|
713
|
-
*
|
|
714
|
-
* Surfaces the generated `createApiClient` from `@shoppex/contracts` with the
|
|
715
|
-
* SDK's configured `apiBaseUrl`. This lets consumers of `@shoppexio/storefront`
|
|
716
|
-
* call any public Dev API endpoint with full end-to-end types without
|
|
717
|
-
* rebuilding a client from scratch.
|
|
718
|
-
*
|
|
719
|
-
* Prefer the high-level modules (`shoppex.getProducts()` etc.) for common
|
|
720
|
-
* read flows — they handle caching, pagination defaults, and storefront
|
|
721
|
-
* scoping. Drop down to `shoppex.client()` only when you need an endpoint
|
|
722
|
-
* the high-level API does not cover yet.
|
|
723
|
-
*/
|
|
724
|
-
|
|
725
|
-
type ApiClient = ReturnType<typeof createApiClient>;
|
|
726
|
-
/**
|
|
727
|
-
* Return a typed OpenAPI client bound to the SDK's configured API base URL.
|
|
728
|
-
* The client is cached per base URL and recreated when the SDK is re-initialized
|
|
729
|
-
* against a different host.
|
|
730
|
-
*/
|
|
731
|
-
declare function getTypedClient(token?: string): ApiClient;
|
|
732
|
-
|
|
733
|
-
/**
|
|
734
|
-
* SDK Error Classes
|
|
735
|
-
*/
|
|
736
|
-
declare class ShoppexError extends Error {
|
|
737
|
-
readonly code: string;
|
|
738
|
-
readonly statusCode?: number;
|
|
739
|
-
constructor(message: string, code: string, statusCode?: number);
|
|
740
|
-
}
|
|
741
|
-
declare class NotInitializedError extends ShoppexError {
|
|
742
|
-
constructor();
|
|
743
|
-
}
|
|
744
|
-
declare class NetworkError extends ShoppexError {
|
|
745
|
-
constructor(message: string, statusCode?: number);
|
|
746
|
-
}
|
|
747
|
-
declare class ValidationError extends ShoppexError {
|
|
748
|
-
readonly invalidFields?: string[];
|
|
749
|
-
constructor(message: string, invalidFields?: string[]);
|
|
750
|
-
}
|
|
751
|
-
declare class CartError extends ShoppexError {
|
|
752
|
-
constructor(message: string);
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
interface StorefrontCustomField {
|
|
756
|
-
name: string;
|
|
757
|
-
type: string;
|
|
758
|
-
required: boolean;
|
|
759
|
-
defaultValue: string;
|
|
760
|
-
placeholder: string;
|
|
761
|
-
regex?: string;
|
|
762
|
-
}
|
|
763
|
-
declare function normalizeStorefrontCustomFields(raw: unknown): StorefrontCustomField[];
|
|
764
|
-
declare function isStorefrontCheckboxCustomFieldValueChecked(value: string | undefined): boolean;
|
|
765
|
-
declare function validateStorefrontCustomFieldValue(field: StorefrontCustomField, value: string): string | null;
|
|
766
|
-
declare function buildStorefrontCustomFieldPayload(fields: StorefrontCustomField[], values: Record<string, string>): Record<string, string>;
|
|
767
|
-
|
|
768
|
-
/**
|
|
769
|
-
* Theme configuration types (framework agnostic)
|
|
770
|
-
*/
|
|
771
|
-
type SettingFieldType = 'color' | 'text' | 'range' | 'select' | 'boolean' | 'image' | 'font' | 'richtext' | 'products' | 'images';
|
|
772
|
-
interface BaseSettingField {
|
|
773
|
-
type: SettingFieldType;
|
|
774
|
-
label: string;
|
|
775
|
-
description?: string;
|
|
776
|
-
}
|
|
777
|
-
interface ColorField extends BaseSettingField {
|
|
778
|
-
type: 'color';
|
|
779
|
-
default: string;
|
|
780
|
-
}
|
|
781
|
-
interface RangeField extends BaseSettingField {
|
|
782
|
-
type: 'range';
|
|
783
|
-
default: number;
|
|
784
|
-
min: number;
|
|
785
|
-
max: number;
|
|
786
|
-
step?: number;
|
|
787
|
-
unit?: string;
|
|
788
|
-
}
|
|
789
|
-
interface SelectField extends BaseSettingField {
|
|
790
|
-
type: 'select';
|
|
791
|
-
default: string;
|
|
792
|
-
options: string[] | {
|
|
793
|
-
value: string;
|
|
794
|
-
label: string;
|
|
795
|
-
}[];
|
|
796
|
-
}
|
|
797
|
-
interface BooleanField extends BaseSettingField {
|
|
798
|
-
type: 'boolean';
|
|
799
|
-
default: boolean;
|
|
800
|
-
}
|
|
801
|
-
interface TextField extends BaseSettingField {
|
|
802
|
-
type: 'text';
|
|
803
|
-
default: string;
|
|
804
|
-
}
|
|
805
|
-
interface ImageField extends BaseSettingField {
|
|
806
|
-
type: 'image';
|
|
807
|
-
default: string | null;
|
|
808
|
-
}
|
|
809
|
-
interface FontField extends BaseSettingField {
|
|
810
|
-
type: 'font';
|
|
811
|
-
default: string;
|
|
812
|
-
options?: string[];
|
|
813
|
-
}
|
|
814
|
-
interface RichtextField extends BaseSettingField {
|
|
815
|
-
type: 'richtext';
|
|
816
|
-
default: string;
|
|
817
|
-
}
|
|
818
|
-
interface ProductsField extends BaseSettingField {
|
|
819
|
-
type: 'products';
|
|
820
|
-
default: string[];
|
|
821
|
-
max?: number;
|
|
822
|
-
}
|
|
823
|
-
interface ImagesField extends BaseSettingField {
|
|
824
|
-
type: 'images';
|
|
825
|
-
default: string[];
|
|
826
|
-
max?: number;
|
|
827
|
-
}
|
|
828
|
-
type SettingField = ColorField | RangeField | SelectField | BooleanField | TextField | ImageField | FontField | RichtextField | ProductsField | ImagesField;
|
|
829
|
-
interface SectionDefinition {
|
|
830
|
-
name: string;
|
|
831
|
-
description?: string;
|
|
832
|
-
icon?: string;
|
|
833
|
-
settings: Record<string, SettingField>;
|
|
834
|
-
}
|
|
835
|
-
interface BlockDefinition {
|
|
836
|
-
name: string;
|
|
837
|
-
description?: string;
|
|
838
|
-
icon?: string;
|
|
839
|
-
settings: Record<string, SettingField>;
|
|
840
|
-
allowedPages?: string[];
|
|
841
|
-
maxPerPage?: number;
|
|
842
|
-
}
|
|
843
|
-
interface BlockInstance {
|
|
844
|
-
id: string;
|
|
845
|
-
type: string;
|
|
846
|
-
visible?: boolean;
|
|
847
|
-
settings?: Record<string, SettingValue>;
|
|
848
|
-
}
|
|
849
|
-
interface PageLayout {
|
|
850
|
-
blocks: BlockInstance[];
|
|
851
|
-
}
|
|
852
|
-
interface ThemeBlockManifest {
|
|
853
|
-
pages: string[];
|
|
854
|
-
blocks: Record<string, BlockDefinition>;
|
|
855
|
-
defaultLayouts?: Record<string, PageLayout>;
|
|
856
|
-
}
|
|
857
|
-
interface ThemeConfig {
|
|
858
|
-
id: string;
|
|
859
|
-
name: string;
|
|
860
|
-
description?: string;
|
|
861
|
-
version: string;
|
|
862
|
-
author?: string;
|
|
863
|
-
preview?: string;
|
|
864
|
-
settings: Record<string, Record<string, SettingField>>;
|
|
865
|
-
sections: Record<string, SectionDefinition>;
|
|
866
|
-
blocks?: Record<string, BlockDefinition>;
|
|
867
|
-
pageLayouts?: Record<string, PageLayout>;
|
|
868
|
-
builder?: ThemeBlockManifest;
|
|
869
|
-
}
|
|
870
|
-
type SettingValue = string | number | boolean | null | string[] | Record<string, unknown>;
|
|
871
|
-
type ResolvedThemeSettings = {
|
|
872
|
-
[Category: string]: {
|
|
873
|
-
[Key: string]: SettingValue;
|
|
874
|
-
};
|
|
875
|
-
};
|
|
876
|
-
|
|
877
|
-
type JsonRecord = Record<string, unknown>;
|
|
878
|
-
interface PublishedBuilderSettings {
|
|
879
|
-
version: number;
|
|
880
|
-
revision: number;
|
|
881
|
-
theme: {
|
|
882
|
-
content: JsonRecord;
|
|
883
|
-
layout: JsonRecord;
|
|
884
|
-
style_slots: JsonRecord;
|
|
885
|
-
pages?: unknown[];
|
|
886
|
-
terms?: JsonRecord;
|
|
887
|
-
[key: string]: unknown;
|
|
888
|
-
};
|
|
889
|
-
[key: string]: unknown;
|
|
890
|
-
}
|
|
891
|
-
interface PublishedThemeSettingsPayload {
|
|
892
|
-
settings: ResolvedThemeSettings;
|
|
893
|
-
builder_settings: PublishedBuilderSettings | null;
|
|
894
|
-
content: JsonRecord;
|
|
895
|
-
style_slots: JsonRecord;
|
|
896
|
-
}
|
|
897
|
-
declare function fetchPublishedBuilderSettings(shopSlug: string): Promise<PublishedThemeSettingsPayload | null>;
|
|
898
|
-
declare function fetchPublishedThemeSettings(shopSlug: string): Promise<ResolvedThemeSettings | null>;
|
|
899
|
-
declare function resolveDefaults(config: ThemeConfig): ResolvedThemeSettings;
|
|
900
|
-
declare function mergeSettings(defaults: ResolvedThemeSettings, overrides: Partial<ResolvedThemeSettings>): ResolvedThemeSettings;
|
|
901
|
-
|
|
902
|
-
/**
|
|
903
|
-
* Store Module
|
|
904
|
-
*
|
|
905
|
-
* API methods for store data.
|
|
906
|
-
*/
|
|
907
|
-
|
|
908
|
-
interface GetStorefrontOptions {
|
|
909
|
-
productsLimit?: number;
|
|
910
|
-
productsCursor?: string | null;
|
|
911
|
-
}
|
|
912
|
-
declare function getStore(): Promise<SDKResponse<Shop>>;
|
|
913
|
-
declare function resolveStoreByDomain(domain?: string, apiBaseUrl?: string): Promise<SDKResponse<Shop>>;
|
|
914
|
-
declare function getStorefront(options?: GetStorefrontOptions): Promise<SDKResponse<StorefrontData>>;
|
|
915
|
-
declare function getStoreLogoUrl(): Promise<string | null>;
|
|
916
|
-
declare function getStoreBannerUrl(): Promise<string | null>;
|
|
917
|
-
|
|
918
|
-
/**
|
|
919
|
-
* Products Module
|
|
920
|
-
*
|
|
921
|
-
* API methods for product data.
|
|
922
|
-
*/
|
|
923
|
-
|
|
924
|
-
interface GetStorefrontProductsPageOptions {
|
|
925
|
-
cursor?: string | null;
|
|
926
|
-
limit?: number;
|
|
927
|
-
sort?: 'featured' | 'newest' | 'price-asc' | 'price-desc' | string | null;
|
|
928
|
-
category?: string | null;
|
|
929
|
-
hideOutOfStock?: boolean;
|
|
930
|
-
}
|
|
931
|
-
declare function getProducts(): Promise<SDKResponse<Product[]>>;
|
|
932
|
-
declare function getStorefrontProductsPage(options?: GetStorefrontProductsPageOptions): Promise<SDKResponse<{
|
|
933
|
-
products: Product[];
|
|
934
|
-
pagination: CursorPagination | null;
|
|
935
|
-
}>>;
|
|
936
|
-
declare function getProduct(idOrSlug: string): Promise<SDKResponse<Product>>;
|
|
937
|
-
declare function getCategories(): Promise<SDKResponse<string[]>>;
|
|
938
|
-
|
|
939
|
-
declare function getCartCoupon(): string | null;
|
|
940
|
-
declare function setCartCoupon(coupon: string | null | undefined): string | null;
|
|
941
|
-
declare function clearCartCoupon(): void;
|
|
942
|
-
declare function getCart(): CartItem[];
|
|
943
|
-
declare function getCartItemCount(): number;
|
|
944
|
-
declare function addToCart(productId: string, variantId: string, quantity?: number, options?: CartAddOptions): void;
|
|
945
|
-
declare function setCartItem(productId: string, variantId: string, quantity?: number, options?: CartAddOptions): void;
|
|
946
|
-
declare function updateCartItem(productId: string, variantId: string, updates: Partial<Omit<CartItem, 'product_id' | 'variant_id'>>): void;
|
|
947
|
-
declare function removeFromCart(productId: string, variantId: string): void;
|
|
948
|
-
declare function clearCart(): void;
|
|
949
|
-
declare function createCartBackup(): void;
|
|
950
|
-
declare function restoreCartFromBackup(): boolean;
|
|
951
|
-
declare function mergeBaskets(items: CartItem[]): CartItem[];
|
|
952
|
-
declare function moveBasketItem(fromProductId: string, fromVariantId: string, toProductId: string, toVariantId: string): void;
|
|
953
|
-
declare function validateCartIntegrity(): boolean;
|
|
954
|
-
declare function getCartStats(): CartStats;
|
|
955
|
-
declare function quoteCart(coupon?: string): Promise<src.SDKResponse<CartQuote>>;
|
|
956
|
-
|
|
957
|
-
/**
|
|
958
|
-
* Checkout Module
|
|
959
|
-
*
|
|
960
|
-
* Creates invoice via backend API and redirects to hosted checkout page.
|
|
961
|
-
* All checkout flows go through: checkout.shoppex.io/invoice/{invoiceId}
|
|
962
|
-
*/
|
|
963
|
-
|
|
964
|
-
interface CheckoutOptions {
|
|
965
|
-
autoRedirect?: boolean;
|
|
966
|
-
locale?: string;
|
|
967
|
-
email?: string;
|
|
968
|
-
coupon?: string;
|
|
969
|
-
affiliateCode?: string;
|
|
970
|
-
referralCode?: string;
|
|
971
|
-
}
|
|
972
|
-
interface CheckoutResult {
|
|
973
|
-
success: boolean;
|
|
974
|
-
redirectUrl?: string;
|
|
975
|
-
invoiceId?: string;
|
|
976
|
-
rewards?: BuyerRewards | null;
|
|
977
|
-
message?: string;
|
|
978
|
-
}
|
|
979
|
-
declare function checkout(couponOrOptions?: string | CheckoutOptions, options?: CheckoutOptions): Promise<CheckoutResult>;
|
|
980
|
-
/**
|
|
981
|
-
* Build checkout URL by creating invoice first.
|
|
982
|
-
* Returns the checkout URL for the created invoice.
|
|
983
|
-
*/
|
|
984
|
-
declare function buildCheckoutUrl(couponOrOptions?: string | CheckoutOptions, options?: CheckoutOptions): Promise<string>;
|
|
985
|
-
/**
|
|
986
|
-
* @deprecated Use buildCheckoutUrl instead.
|
|
987
|
-
* Sync version is no longer supported as invoice creation requires API call.
|
|
988
|
-
*/
|
|
989
|
-
declare function buildCheckoutUrlSync(): never;
|
|
990
|
-
|
|
991
|
-
declare function setAffiliateCode(code: string | null | undefined, ttlDays?: number): string | null;
|
|
992
|
-
declare function clearAffiliateCode(): void;
|
|
993
|
-
declare function getAffiliateCode(): string | null;
|
|
994
|
-
declare function validateAffiliateCode(code: string): Promise<SDKResponse<AffiliateValidation>>;
|
|
995
|
-
declare function applyAffiliateCode(code: string): Promise<SDKResponse<AffiliateValidation>>;
|
|
996
|
-
/**
|
|
997
|
-
* Capture an affiliate code from the current URL and store it for 30 days (last-click).
|
|
998
|
-
*
|
|
999
|
-
* Example:
|
|
1000
|
-
* - URL: https://mystore.com/product/abc?ref=deadbeef
|
|
1001
|
-
* - captureAffiliateFromUrl() stores "deadbeef" and returns it.
|
|
1002
|
-
*/
|
|
1003
|
-
declare function captureAffiliateFromUrl(param?: string): Promise<string | null>;
|
|
1004
|
-
|
|
1005
|
-
/**
|
|
1006
|
-
* Coupons Module
|
|
1007
|
-
*
|
|
1008
|
-
* Coupon validation before checkout.
|
|
1009
|
-
*/
|
|
1010
|
-
|
|
1011
|
-
declare function validateCoupon(code: string, productOrOptions?: string | CouponValidationOptions): Promise<SDKResponse<CouponValidation>>;
|
|
1012
|
-
|
|
1013
|
-
/**
|
|
1014
|
-
* Reviews Module
|
|
1015
|
-
*
|
|
1016
|
-
* Shop-level feedback/reviews.
|
|
1017
|
-
* Note: Shoppex has shop-level feedback, not product-level reviews.
|
|
1018
|
-
*/
|
|
1019
|
-
|
|
1020
|
-
declare function getShopReviews(): Promise<SDKResponse<Feedback[]>>;
|
|
1021
|
-
|
|
1022
|
-
interface SearchOptions {
|
|
1023
|
-
hideOutOfStock?: boolean;
|
|
1024
|
-
}
|
|
1025
|
-
declare function searchProducts(query: string, options?: SearchOptions): Promise<SDKResponse<Product[]>>;
|
|
1026
|
-
|
|
1027
|
-
/**
|
|
1028
|
-
* Invoices Module
|
|
1029
|
-
*
|
|
1030
|
-
* Invoice status checking after payment.
|
|
1031
|
-
*/
|
|
1032
|
-
|
|
1033
|
-
declare function getInvoice(invoiceId: string): Promise<SDKResponse<Invoice>>;
|
|
1034
|
-
declare function getInvoiceStatus(invoiceId: string): Promise<SDKResponse<{
|
|
1035
|
-
status: string;
|
|
1036
|
-
}>>;
|
|
1037
|
-
|
|
1038
|
-
/**
|
|
1039
|
-
* Pages Module
|
|
1040
|
-
*
|
|
1041
|
-
* API methods for public pages.
|
|
1042
|
-
*/
|
|
1043
|
-
|
|
1044
|
-
/**
|
|
1045
|
-
* Get all public pages for the store
|
|
1046
|
-
*/
|
|
1047
|
-
declare function getPages(): Promise<SDKResponse<Page[]>>;
|
|
1048
|
-
/**
|
|
1049
|
-
* Get a public page by slug
|
|
1050
|
-
*/
|
|
1051
|
-
declare function getPage(slug: string): Promise<SDKResponse<Page>>;
|
|
1052
|
-
|
|
1053
|
-
/**
|
|
1054
|
-
* Navigation Module
|
|
1055
|
-
*
|
|
1056
|
-
* API methods for menus and navigation.
|
|
1057
|
-
*/
|
|
1058
|
-
|
|
1059
|
-
/**
|
|
1060
|
-
* Get all menus for the store
|
|
1061
|
-
*/
|
|
1062
|
-
declare function getMenus(): Promise<SDKResponse<Menu[]>>;
|
|
1063
|
-
/**
|
|
1064
|
-
* Get a menu by its exact title.
|
|
1065
|
-
*/
|
|
1066
|
-
declare function getMenuByTitle(title: string): Promise<SDKResponse<Menu>>;
|
|
1067
|
-
/**
|
|
1068
|
-
* Get a menu by its exact title.
|
|
1069
|
-
*/
|
|
1070
|
-
declare function getMenu(title: string): Promise<SDKResponse<Menu>>;
|
|
1071
|
-
/**
|
|
1072
|
-
* Get a menu by canonical slot. The backend resolves legacy menu titles too.
|
|
1073
|
-
*/
|
|
1074
|
-
declare function getMenuBySlot(slot: NavigationMenuSlot): Promise<SDKResponse<Menu>>;
|
|
1075
|
-
declare function getMenuSlotTitles(slot: NavigationMenuSlot): string[];
|
|
1076
|
-
|
|
1077
|
-
declare function trackPageView(cartValue?: number, itemCount?: number): Promise<void>;
|
|
1078
|
-
|
|
1079
|
-
declare function getStorefrontOnlineUsers(): Promise<SDKResponse<StorefrontOnlineUsers>>;
|
|
1080
|
-
declare function touchStorefrontPresence(): Promise<SDKResponse<{
|
|
1081
|
-
pong: string;
|
|
1082
|
-
}>>;
|
|
1083
|
-
|
|
1084
|
-
/**
|
|
1085
|
-
* Formatting Utilities
|
|
1086
|
-
*/
|
|
1087
|
-
declare function createFormatter(currency?: string, locale?: string): Intl.NumberFormat;
|
|
1088
|
-
declare function formatPrice(amount: number | string, currency?: string, locale?: string): string;
|
|
1089
|
-
|
|
1090
|
-
interface CacheStats {
|
|
1091
|
-
hits: number;
|
|
1092
|
-
misses: number;
|
|
1093
|
-
pendingRequests: number;
|
|
1094
|
-
entries: number;
|
|
1095
|
-
}
|
|
1096
|
-
declare function getCacheStats(): CacheStats;
|
|
1097
|
-
declare function clearCache(): void;
|
|
1098
|
-
declare function invalidateCache(prefixOrKey: string): void;
|
|
1099
|
-
|
|
1100
|
-
/**
|
|
1101
|
-
* Shoppex Storefront SDK
|
|
1102
|
-
*
|
|
1103
|
-
* Usage:
|
|
1104
|
-
* ```html
|
|
1105
|
-
* <script src="https://cdn.shoppex.io/sdk/v0.3/shoppex.umd.js"></script>
|
|
1106
|
-
* <script>
|
|
1107
|
-
* shoppex.init('my-store');
|
|
1108
|
-
*
|
|
1109
|
-
* shoppex.getStore().then(store => console.log(store));
|
|
1110
|
-
* shoppex.addToCart('product-id', 'variant-id', 2);
|
|
1111
|
-
* shoppex.checkout();
|
|
1112
|
-
* </script>
|
|
1113
|
-
* ```
|
|
1114
|
-
*/
|
|
1115
|
-
|
|
1
|
+
import { isInitialized, getConfig } from './core/config';
|
|
2
|
+
import { getTypedClient } from './core/typed-client';
|
|
3
|
+
import { ShoppexInitOptions } from './types';
|
|
4
|
+
import { getStore, getStorefront, getStoreLogoUrl, getStoreBannerUrl, resolveStoreByDomain } from './modules/store';
|
|
5
|
+
import { getProducts, getProduct, getCategories, getStorefrontProductsPage } from './modules/products';
|
|
6
|
+
import { getCart, getCartItemCount, getCartCoupon, setCartCoupon, clearCartCoupon, addToCart, setCartItem, updateCartItem, removeFromCart, clearCart, createCartBackup, restoreCartFromBackup, mergeBaskets, moveBasketItem, getCartStats, validateCartIntegrity, quoteCart } from './modules/cart';
|
|
7
|
+
import { checkout, buildCheckoutUrl, buildCheckoutUrlSync } from './modules/checkout';
|
|
8
|
+
import { applyAffiliateCode, captureAffiliateFromUrl, getAffiliateCode, setAffiliateCode, clearAffiliateCode, validateAffiliateCode } from './modules/affiliates';
|
|
9
|
+
import { validateCoupon } from './modules/coupons';
|
|
10
|
+
import { getShopReviews } from './modules/reviews';
|
|
11
|
+
import { searchProducts } from './modules/search';
|
|
12
|
+
import { getInvoice, getInvoiceStatus } from './modules/invoices';
|
|
13
|
+
import { getPages, getPage } from './modules/pages';
|
|
14
|
+
import { getMenus, getMenu, getMenuBySlot, getMenuByTitle, getMenuSlotTitles } from './modules/navigation';
|
|
15
|
+
import { trackPageView } from './modules/analytics';
|
|
16
|
+
import { getStorefrontOnlineUsers, touchStorefrontPresence } from './modules/presence';
|
|
17
|
+
import { createFormatter, formatPrice } from './utils/format';
|
|
18
|
+
import { clearCache, invalidateCache, getCacheStats } from './core/cache';
|
|
19
|
+
import { fetchPublishedBuilderSettings, fetchPublishedThemeSettings, resolveDefaults, mergeSettings } from './modules/theme';
|
|
20
|
+
export * from './types';
|
|
21
|
+
export * from './core/errors';
|
|
22
|
+
export { buildStorefrontCustomFieldPayload, isStorefrontCheckboxCustomFieldValueChecked, normalizeStorefrontCustomFields, validateStorefrontCustomFieldValue, } from './utils/storefront-custom-fields';
|
|
23
|
+
export type { StorefrontCustomField } from './utils/storefront-custom-fields';
|
|
24
|
+
export { isProductInStock, isProductOutOfStock, isVariantOutOfStock, resolveDisplayStock, resolveVariantStockValue, } from './utils/storefront-stock';
|
|
25
|
+
export type { BlockDefinition, BlockInstance, PageLayout, ThemeConfig, ThemeBlockManifest, SettingField, SectionDefinition, ResolvedThemeSettings, } from './types/theme-config';
|
|
26
|
+
export type { PublishedBuilderSettings, PublishedThemeSettingsPayload } from './modules/theme';
|
|
27
|
+
export type { NavigationMenuSlot } from '@shoppex/contracts/navigation';
|
|
28
|
+
export { fetchPublishedBuilderSettings, fetchPublishedThemeSettings, resolveDefaults, mergeSettings } from './modules/theme';
|
|
29
|
+
export { trackPageView } from './modules/analytics';
|
|
30
|
+
export { getStorefrontOnlineUsers, touchStorefrontPresence } from './modules/presence';
|
|
31
|
+
export { getMenus, getMenu, getMenuBySlot, getMenuByTitle, getMenuSlotTitles } from './modules/navigation';
|
|
1116
32
|
/**
|
|
1117
33
|
* Initialize the SDK with a store slug
|
|
1118
34
|
*/
|
|
@@ -1123,7 +39,7 @@ declare function init(options: ShoppexInitOptions & {
|
|
|
1123
39
|
/**
|
|
1124
40
|
* Shoppex SDK instance
|
|
1125
41
|
*/
|
|
1126
|
-
declare const shoppex: {
|
|
42
|
+
export declare const shoppex: {
|
|
1127
43
|
init: typeof init;
|
|
1128
44
|
isInitialized: typeof isInitialized;
|
|
1129
45
|
getConfig: typeof getConfig;
|
|
@@ -1188,5 +104,5 @@ declare const shoppex: {
|
|
|
1188
104
|
resolveDefaults: typeof resolveDefaults;
|
|
1189
105
|
mergeSettings: typeof mergeSettings;
|
|
1190
106
|
};
|
|
1191
|
-
|
|
1192
|
-
|
|
107
|
+
export default shoppex;
|
|
108
|
+
//# sourceMappingURL=index.d.ts.map
|