@thorprovider/types 2.0.2
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/.turbo/turbo-build.log +18 -0
- package/.turbo/turbo-type-check.log +0 -0
- package/AGENTS.md +1 -0
- package/CHANGELOG.md +52 -0
- package/README.md +222 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/index.d.mts +3341 -0
- package/dist/index.d.ts +3341 -0
- package/dist/index.js +144 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +113 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +34 -0
- package/publish.log +60 -0
- package/src/admin/AdminUser.ts +32 -0
- package/src/admin/AuditLog.ts +43 -0
- package/src/admin/DashboardConfig.ts +82 -0
- package/src/admin/DashboardMetrics.ts +81 -0
- package/src/admin/SiteConfigMetadata.ts +46 -0
- package/src/admin/index.ts +13 -0
- package/src/auth.ts +267 -0
- package/src/cart.ts +130 -0
- package/src/category.ts +88 -0
- package/src/collection.ts +39 -0
- package/src/commerce-provider.ts +1139 -0
- package/src/common.ts +95 -0
- package/src/customer.ts +122 -0
- package/src/designer-config.ts +106 -0
- package/src/header-config.README.md +321 -0
- package/src/header-config.ts +197 -0
- package/src/index.ts +249 -0
- package/src/order.ts +188 -0
- package/src/payment.ts +259 -0
- package/src/product.ts +364 -0
- package/src/provider.ts +174 -0
- package/src/region.ts +43 -0
- package/src/site-config-labels.ts +87 -0
- package/src/site-config.ts +148 -0
- package/src/stock-location.ts +65 -0
- package/src/storefront-config.ts +65 -0
- package/src/storefront.ts +126 -0
- package/tsconfig.json +14 -0
- package/tsup.config.ts +13 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3341 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @thorprovider/types v3.0
|
|
3
|
+
* Common types shared across all commerce providers
|
|
4
|
+
* Universal interfaces compatible with: Shopify, Medusa.js, WooCommerce, Magento, BigCommerce
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Monetary value with currency
|
|
8
|
+
*
|
|
9
|
+
* Using string for amount prevents float precision errors.
|
|
10
|
+
* Compatible with:
|
|
11
|
+
* - Shopify: MoneyV2 (amount: Decimal, currencyCode: CurrencyCode)
|
|
12
|
+
* - Medusa: numbers (converted to string)
|
|
13
|
+
* - WooCommerce: strings ("21.99")
|
|
14
|
+
* - Magento: Float (converted to string)
|
|
15
|
+
*/
|
|
16
|
+
interface Money {
|
|
17
|
+
amount: string;
|
|
18
|
+
currencyCode: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Image with metadata
|
|
22
|
+
*
|
|
23
|
+
* Universal format for product/variant images.
|
|
24
|
+
* Compatible with all platforms (URLs are normalized in adapters).
|
|
25
|
+
*/
|
|
26
|
+
interface Image {
|
|
27
|
+
id?: string;
|
|
28
|
+
url: string;
|
|
29
|
+
altText: string;
|
|
30
|
+
width?: number;
|
|
31
|
+
height?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* SEO metadata
|
|
35
|
+
*/
|
|
36
|
+
interface SEO {
|
|
37
|
+
title: string;
|
|
38
|
+
description: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Generic connection type for paginated data
|
|
42
|
+
*/
|
|
43
|
+
interface Connection<T> {
|
|
44
|
+
edges: Array<Edge<T>>;
|
|
45
|
+
}
|
|
46
|
+
interface Edge<T> {
|
|
47
|
+
node: T;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Pagination options
|
|
51
|
+
*/
|
|
52
|
+
interface PaginationOptions {
|
|
53
|
+
first?: number;
|
|
54
|
+
after?: string;
|
|
55
|
+
last?: number;
|
|
56
|
+
before?: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Sort options
|
|
60
|
+
*/
|
|
61
|
+
interface SortOptions {
|
|
62
|
+
sortKey?: string;
|
|
63
|
+
reverse?: boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Country information
|
|
67
|
+
*
|
|
68
|
+
* Represents a country available in a region.
|
|
69
|
+
* Used for shipping address validation and checkout forms.
|
|
70
|
+
* Compatible with:
|
|
71
|
+
* - Medusa: Country entity with iso_2, name, display_name
|
|
72
|
+
* - Shopify: CountryCode enum
|
|
73
|
+
* - WooCommerce: WC_Countries
|
|
74
|
+
*/
|
|
75
|
+
interface Country {
|
|
76
|
+
/** ISO 3166-1 alpha-2 country code (e.g., "US", "ES", "DE") */
|
|
77
|
+
code: string;
|
|
78
|
+
/** Human-readable country name (e.g., "United States", "Spain") */
|
|
79
|
+
name: string;
|
|
80
|
+
/** ISO 3166-1 alpha-3 country code (optional, e.g., "USA", "ESP") */
|
|
81
|
+
iso3?: string;
|
|
82
|
+
/** ISO 3166-1 numeric code (optional, e.g., "840", "724") */
|
|
83
|
+
numCode?: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Header Configuration Types
|
|
88
|
+
*
|
|
89
|
+
* Type definitions for configurable header navigation system.
|
|
90
|
+
* Supports static links, mega menus, preset components (cart, account),
|
|
91
|
+
* dynamic data injection, and hybrid icon system.
|
|
92
|
+
*/
|
|
93
|
+
/**
|
|
94
|
+
* Icon configuration with hybrid support
|
|
95
|
+
* - Lucide: Reference by string name for lucide-react icons
|
|
96
|
+
* - Custom: Provide React component/element directly
|
|
97
|
+
*/
|
|
98
|
+
type IconConfig = {
|
|
99
|
+
type: 'lucide';
|
|
100
|
+
name: string;
|
|
101
|
+
} | {
|
|
102
|
+
type: 'custom';
|
|
103
|
+
component: React.ReactNode;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Navigation callout item (featured content in dropdown)
|
|
107
|
+
*/
|
|
108
|
+
interface NavigationCalloutItem {
|
|
109
|
+
logo?: string;
|
|
110
|
+
image?: string;
|
|
111
|
+
heading: string;
|
|
112
|
+
description: string;
|
|
113
|
+
href: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Navigation link item
|
|
117
|
+
*/
|
|
118
|
+
interface NavigationLinkItem {
|
|
119
|
+
title: string;
|
|
120
|
+
description?: string;
|
|
121
|
+
href: string;
|
|
122
|
+
badge?: {
|
|
123
|
+
content: number | string;
|
|
124
|
+
variant?: 'solid' | 'soft';
|
|
125
|
+
color?: string;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Dynamic data source for navigation content
|
|
130
|
+
* - 'categories': Fetch and inject categories from backend
|
|
131
|
+
* - 'collections': Fetch and inject collections from backend
|
|
132
|
+
*/
|
|
133
|
+
type DynamicSource = 'categories' | 'collections';
|
|
134
|
+
/**
|
|
135
|
+
* Header link item - extends NavigationMenuItem with additional features
|
|
136
|
+
*/
|
|
137
|
+
type HeaderLinkItem = {
|
|
138
|
+
/** Simple direct link */
|
|
139
|
+
type: 'link';
|
|
140
|
+
label: string;
|
|
141
|
+
href: string;
|
|
142
|
+
icon?: IconConfig;
|
|
143
|
+
badge?: {
|
|
144
|
+
content: number | string;
|
|
145
|
+
variant?: 'solid' | 'soft';
|
|
146
|
+
color?: string;
|
|
147
|
+
};
|
|
148
|
+
} | {
|
|
149
|
+
/** Dropdown menu with content */
|
|
150
|
+
type: 'dropdown';
|
|
151
|
+
label: string;
|
|
152
|
+
icon?: IconConfig;
|
|
153
|
+
badge?: {
|
|
154
|
+
content: number | string;
|
|
155
|
+
variant?: 'solid' | 'soft';
|
|
156
|
+
color?: string;
|
|
157
|
+
};
|
|
158
|
+
/** Optional dynamic data injection */
|
|
159
|
+
dynamicSource?: DynamicSource;
|
|
160
|
+
content: {
|
|
161
|
+
callout?: NavigationCalloutItem;
|
|
162
|
+
links: NavigationLinkItem[];
|
|
163
|
+
sideBanner?: NavigationCalloutItem;
|
|
164
|
+
columns?: number;
|
|
165
|
+
layout?: 'one' | 'two';
|
|
166
|
+
};
|
|
167
|
+
} | {
|
|
168
|
+
/** Preset component (cart, account) */
|
|
169
|
+
type: 'preset';
|
|
170
|
+
preset: 'cart' | 'account';
|
|
171
|
+
/** Override default config for preset */
|
|
172
|
+
config?: Record<string, any>;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Account dropdown menu item
|
|
176
|
+
*/
|
|
177
|
+
type AccountMenuItem = {
|
|
178
|
+
/** Menu item label */
|
|
179
|
+
label: string;
|
|
180
|
+
/** Navigation href */
|
|
181
|
+
href?: string;
|
|
182
|
+
/** Icon configuration */
|
|
183
|
+
icon?: IconConfig;
|
|
184
|
+
/** Click handler (for actions like logout) */
|
|
185
|
+
onClick?: () => void;
|
|
186
|
+
/** Destructive action styling (e.g., logout, delete) */
|
|
187
|
+
destructive?: boolean;
|
|
188
|
+
divider?: never;
|
|
189
|
+
} | {
|
|
190
|
+
/** Render as divider */
|
|
191
|
+
divider: true;
|
|
192
|
+
label?: never;
|
|
193
|
+
href?: never;
|
|
194
|
+
icon?: never;
|
|
195
|
+
onClick?: never;
|
|
196
|
+
destructive?: never;
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Account dropdown configuration
|
|
200
|
+
*/
|
|
201
|
+
interface AccountDropdownConfig {
|
|
202
|
+
/** Enable account dropdown */
|
|
203
|
+
enabled: boolean;
|
|
204
|
+
/** Trigger label (e.g., "Mi cuenta") */
|
|
205
|
+
label?: string;
|
|
206
|
+
/** Trigger icon */
|
|
207
|
+
icon?: IconConfig;
|
|
208
|
+
/** Dropdown menu items */
|
|
209
|
+
items: AccountMenuItem[];
|
|
210
|
+
/** Logout handler */
|
|
211
|
+
onLogout?: () => void;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Search bar configuration
|
|
215
|
+
*/
|
|
216
|
+
interface SearchBarConfig {
|
|
217
|
+
/** Enable search bar */
|
|
218
|
+
enabled?: boolean;
|
|
219
|
+
/** Fixed width in pixels */
|
|
220
|
+
width?: number;
|
|
221
|
+
/** Placeholder text */
|
|
222
|
+
placeholder?: string;
|
|
223
|
+
/** Minimum characters to trigger search */
|
|
224
|
+
minChars?: number;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Main header navigation configuration
|
|
228
|
+
*/
|
|
229
|
+
interface HeaderNavigationConfig {
|
|
230
|
+
/** Logo configuration */
|
|
231
|
+
logo?: {
|
|
232
|
+
/** Logo image path */
|
|
233
|
+
src: string;
|
|
234
|
+
/** Logo alt text */
|
|
235
|
+
alt: string;
|
|
236
|
+
/** Logo width (px) */
|
|
237
|
+
width?: number;
|
|
238
|
+
/** Logo height (px) */
|
|
239
|
+
height?: number;
|
|
240
|
+
/** Logo link href */
|
|
241
|
+
href?: string;
|
|
242
|
+
};
|
|
243
|
+
/** Left navigation group (before search bar) */
|
|
244
|
+
leftLinks?: HeaderLinkItem[];
|
|
245
|
+
/** Right navigation group (after search bar) */
|
|
246
|
+
rightLinks?: HeaderLinkItem[];
|
|
247
|
+
/** Search bar configuration */
|
|
248
|
+
search?: SearchBarConfig;
|
|
249
|
+
/** Account dropdown configuration (if not using preset in rightLinks) */
|
|
250
|
+
account?: AccountDropdownConfig;
|
|
251
|
+
/** Cart configuration (if not using preset in rightLinks) */
|
|
252
|
+
cart?: {
|
|
253
|
+
/** Optional label rendered next to the cart icon in header (e.g., "Carrito") */
|
|
254
|
+
label?: string;
|
|
255
|
+
variant?: 'mini' | 'drawer';
|
|
256
|
+
composition?: 'compact' | 'detailed';
|
|
257
|
+
showBadge?: boolean;
|
|
258
|
+
};
|
|
259
|
+
/** Maximum container width (px) */
|
|
260
|
+
maxWidth?: number;
|
|
261
|
+
/** Enable overflow menu for excess links */
|
|
262
|
+
enableOverflow?: boolean;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Site Configuration Types
|
|
267
|
+
*
|
|
268
|
+
* Foundation for multi-tenant, framework-agnostic site configuration.
|
|
269
|
+
* Defines the structure for branding, metadata, navigation, and module presets.
|
|
270
|
+
*
|
|
271
|
+
* @module site-config
|
|
272
|
+
*/
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Brand Information
|
|
276
|
+
*/
|
|
277
|
+
interface BrandConfig {
|
|
278
|
+
name: string;
|
|
279
|
+
title: string;
|
|
280
|
+
description: string;
|
|
281
|
+
tagline?: string;
|
|
282
|
+
logo?: string;
|
|
283
|
+
logoDark?: string;
|
|
284
|
+
preset?: string;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Site Metadata & Authorship
|
|
288
|
+
*/
|
|
289
|
+
interface AuthorConfig {
|
|
290
|
+
/** Name of the author or organization */
|
|
291
|
+
name: string;
|
|
292
|
+
/** Primary contact email */
|
|
293
|
+
email: string;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Social Media Links
|
|
297
|
+
*/
|
|
298
|
+
type SocialConfig = Record<string, string>;
|
|
299
|
+
/**
|
|
300
|
+
* Navigation Item (Simple)
|
|
301
|
+
*/
|
|
302
|
+
interface NavigationItem {
|
|
303
|
+
/** Display name of the link or button */
|
|
304
|
+
name: string;
|
|
305
|
+
/** URL or anchor for the link */
|
|
306
|
+
href: string;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Footer link categorization
|
|
310
|
+
*/
|
|
311
|
+
interface FooterLinksConfig {
|
|
312
|
+
/** Customer shopping shortcuts */
|
|
313
|
+
shop: NavigationItem[];
|
|
314
|
+
/** Customer service and support links */
|
|
315
|
+
support: NavigationItem[];
|
|
316
|
+
/** Corporate and information links */
|
|
317
|
+
company: NavigationItem[];
|
|
318
|
+
/** Legal, privacy, and policy links */
|
|
319
|
+
legal: NavigationItem[];
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Copyright information for the site
|
|
323
|
+
*/
|
|
324
|
+
interface CopyrightConfig {
|
|
325
|
+
/** Current year or range (e.g., "2024" or "2023-2024") */
|
|
326
|
+
year: string | number;
|
|
327
|
+
/** Legal text following the year */
|
|
328
|
+
text: string;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Module-specific configurations
|
|
332
|
+
*/
|
|
333
|
+
interface ModulesConfig {
|
|
334
|
+
cart: {
|
|
335
|
+
mini: {
|
|
336
|
+
variant: 'mini';
|
|
337
|
+
composition: 'compact' | 'full' | 'separate-pages';
|
|
338
|
+
};
|
|
339
|
+
page: {
|
|
340
|
+
variant: 'page';
|
|
341
|
+
composition: 'compact' | 'full';
|
|
342
|
+
};
|
|
343
|
+
};
|
|
344
|
+
checkout: {
|
|
345
|
+
default: {
|
|
346
|
+
variant: 'simple' | 'standard' | 'complete';
|
|
347
|
+
composition: 'accordion' | 'wizard' | 'single-page';
|
|
348
|
+
};
|
|
349
|
+
};
|
|
350
|
+
profile: {
|
|
351
|
+
default: {
|
|
352
|
+
variant: 'basic' | 'standard' | 'complete';
|
|
353
|
+
composition: 'tabs' | 'accordion' | 'separate-pages' | 'side';
|
|
354
|
+
};
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Complete Site Configuration
|
|
359
|
+
*
|
|
360
|
+
* Centralized interface for site-wide settings.
|
|
361
|
+
* Supports merging with database-stored overrides via Developer Dashboard.
|
|
362
|
+
*/
|
|
363
|
+
interface SiteConfig {
|
|
364
|
+
/** Brand identity and basic info */
|
|
365
|
+
name: string;
|
|
366
|
+
title: string;
|
|
367
|
+
description: string;
|
|
368
|
+
tagline?: string;
|
|
369
|
+
logo?: string;
|
|
370
|
+
logoDark?: string;
|
|
371
|
+
preset?: string;
|
|
372
|
+
/** URLs and social */
|
|
373
|
+
url?: string;
|
|
374
|
+
author?: AuthorConfig;
|
|
375
|
+
social?: SocialConfig;
|
|
376
|
+
/** Navigation structures */
|
|
377
|
+
navigation?: NavigationItem[];
|
|
378
|
+
header?: HeaderNavigationConfig;
|
|
379
|
+
/** Footer content and links */
|
|
380
|
+
footerLinks: FooterLinksConfig;
|
|
381
|
+
/** Copyright statement */
|
|
382
|
+
copyright: CopyrightConfig;
|
|
383
|
+
/** Module behavior & UI variants */
|
|
384
|
+
modules: ModulesConfig;
|
|
385
|
+
/**
|
|
386
|
+
* Extension point for custom properties
|
|
387
|
+
* Necessary for experimental features before they are formally typed
|
|
388
|
+
*/
|
|
389
|
+
[key: string]: any;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* SiteConfigLabels - All translatable strings from site-config
|
|
394
|
+
*
|
|
395
|
+
* Maps to messages/siteConfig.* namespace in next-intl.
|
|
396
|
+
* Used in L5 to provide i18n-aware labels to components that otherwise use siteConfig.
|
|
397
|
+
*
|
|
398
|
+
* IMPORTANT: This interface contains ONLY translatable text — no hrefs, images, or structural config.
|
|
399
|
+
* Structural config (hrefs, images, module presets) stays in site-config.ts.
|
|
400
|
+
*
|
|
401
|
+
* Footer/featuredCategories labels are simple string arrays mapped by index to
|
|
402
|
+
* the corresponding entries in siteConfig.footerLinks / siteConfig.featuredCategories.
|
|
403
|
+
*
|
|
404
|
+
* @see packages/core/messages/en.json (siteConfig namespace)
|
|
405
|
+
* @see packages/core/hooks/use-site-config-labels.ts
|
|
406
|
+
*/
|
|
407
|
+
interface SiteConfigLabels {
|
|
408
|
+
title: string;
|
|
409
|
+
description: string;
|
|
410
|
+
tagline: string;
|
|
411
|
+
header: {
|
|
412
|
+
products: {
|
|
413
|
+
label: string;
|
|
414
|
+
newArrivals: {
|
|
415
|
+
heading: string;
|
|
416
|
+
description: string;
|
|
417
|
+
};
|
|
418
|
+
summerSale: {
|
|
419
|
+
heading: string;
|
|
420
|
+
description: string;
|
|
421
|
+
};
|
|
422
|
+
links: {
|
|
423
|
+
allProducts: string;
|
|
424
|
+
allProductsDescription: string;
|
|
425
|
+
newArrivals: string;
|
|
426
|
+
newArrivalsDescription: string;
|
|
427
|
+
bestSellers: string;
|
|
428
|
+
bestSellersDescription: string;
|
|
429
|
+
sale: string;
|
|
430
|
+
saleDescription: string;
|
|
431
|
+
};
|
|
432
|
+
};
|
|
433
|
+
categories: {
|
|
434
|
+
label: string;
|
|
435
|
+
};
|
|
436
|
+
account: {
|
|
437
|
+
label: string;
|
|
438
|
+
items: {
|
|
439
|
+
profile: string;
|
|
440
|
+
orders: string;
|
|
441
|
+
logout: string;
|
|
442
|
+
};
|
|
443
|
+
};
|
|
444
|
+
cart: {
|
|
445
|
+
label: string;
|
|
446
|
+
};
|
|
447
|
+
search: {
|
|
448
|
+
placeholder: string;
|
|
449
|
+
};
|
|
450
|
+
};
|
|
451
|
+
footer: {
|
|
452
|
+
shopTitle: string;
|
|
453
|
+
supportTitle: string;
|
|
454
|
+
companyTitle: string;
|
|
455
|
+
shop: string[];
|
|
456
|
+
support: string[];
|
|
457
|
+
company: string[];
|
|
458
|
+
legal: string[];
|
|
459
|
+
};
|
|
460
|
+
hero: {
|
|
461
|
+
badge: string;
|
|
462
|
+
title: string;
|
|
463
|
+
description: string;
|
|
464
|
+
primaryCta: string;
|
|
465
|
+
secondaryCta: string;
|
|
466
|
+
};
|
|
467
|
+
promo: {
|
|
468
|
+
badge: string;
|
|
469
|
+
title: string;
|
|
470
|
+
description: string;
|
|
471
|
+
emailPlaceholder: string;
|
|
472
|
+
ctaText: string;
|
|
473
|
+
};
|
|
474
|
+
featuredCategories: string[];
|
|
475
|
+
copyright: {
|
|
476
|
+
text: string;
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Inventory & fulfillment types
|
|
482
|
+
*
|
|
483
|
+
* Foundation layer (L1) types used by adapters, UI, and starters.
|
|
484
|
+
*/
|
|
485
|
+
|
|
486
|
+
interface StockLocation {
|
|
487
|
+
id: string;
|
|
488
|
+
name: string;
|
|
489
|
+
address?: {
|
|
490
|
+
address1: string;
|
|
491
|
+
address2?: string;
|
|
492
|
+
city: string;
|
|
493
|
+
countryCode: string;
|
|
494
|
+
postalCode: string;
|
|
495
|
+
province?: string;
|
|
496
|
+
};
|
|
497
|
+
metadata?: {
|
|
498
|
+
lat?: number;
|
|
499
|
+
lng?: number;
|
|
500
|
+
timezone?: string;
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
interface InventoryLevel {
|
|
504
|
+
locationId: string;
|
|
505
|
+
locationName: string;
|
|
506
|
+
availableQuantity: number;
|
|
507
|
+
reservedQuantity: number;
|
|
508
|
+
incomingQuantity?: number;
|
|
509
|
+
stockedQuantity: number;
|
|
510
|
+
}
|
|
511
|
+
interface FulfillmentSet {
|
|
512
|
+
id: string;
|
|
513
|
+
name: string;
|
|
514
|
+
type: 'shipping' | 'pickup' | 'return';
|
|
515
|
+
location: StockLocation;
|
|
516
|
+
}
|
|
517
|
+
interface FulfillmentOption {
|
|
518
|
+
id: string;
|
|
519
|
+
providerId: string;
|
|
520
|
+
name: string;
|
|
521
|
+
description?: string;
|
|
522
|
+
price: Money;
|
|
523
|
+
estimatedDays?: string;
|
|
524
|
+
stockLocation: StockLocation;
|
|
525
|
+
fulfillmentSet?: FulfillmentSet;
|
|
526
|
+
distance?: number;
|
|
527
|
+
}
|
|
528
|
+
type StockStatus = 'in_stock' | 'out_of_stock' | 'low_stock';
|
|
529
|
+
interface StockValidation {
|
|
530
|
+
allAvailable: boolean;
|
|
531
|
+
unavailableItems: Array<{
|
|
532
|
+
variantId: string;
|
|
533
|
+
productName: string;
|
|
534
|
+
requestedQuantity: number;
|
|
535
|
+
availableQuantity: number;
|
|
536
|
+
}>;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* @thorprovider/adapters v2.0
|
|
541
|
+
* Product types - unified interface for all commerce providers
|
|
542
|
+
*/
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Product variant option (e.g., Size: Large, Color: Red)
|
|
546
|
+
*/
|
|
547
|
+
interface ProductOption {
|
|
548
|
+
id: string;
|
|
549
|
+
name: string;
|
|
550
|
+
values: string[];
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Selected option for a variant
|
|
554
|
+
*/
|
|
555
|
+
interface SelectedOption {
|
|
556
|
+
name: string;
|
|
557
|
+
value: string;
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Product variant (SKU)
|
|
561
|
+
*
|
|
562
|
+
* Universal format compatible with:
|
|
563
|
+
* - Shopify: ProductVariant with price/compareAtPrice as MoneyV2
|
|
564
|
+
* - Medusa: StoreProductVariant with calculated_price
|
|
565
|
+
* - WooCommerce: Variation with price/regular_price
|
|
566
|
+
* - Magento: ConfigurableProductOptions
|
|
567
|
+
*/
|
|
568
|
+
interface ProductVariant {
|
|
569
|
+
id: string;
|
|
570
|
+
title: string;
|
|
571
|
+
sku?: string;
|
|
572
|
+
availableForSale: boolean;
|
|
573
|
+
selectedOptions: SelectedOption[];
|
|
574
|
+
price: Money;
|
|
575
|
+
compareAtPrice?: Money;
|
|
576
|
+
quantityAvailable?: number;
|
|
577
|
+
stockStatus?: StockStatus;
|
|
578
|
+
inventoryLevels?: InventoryLevel[];
|
|
579
|
+
image?: Image;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Price range for product
|
|
583
|
+
*/
|
|
584
|
+
interface PriceRange {
|
|
585
|
+
minVariantPrice: Money;
|
|
586
|
+
maxVariantPrice: Money;
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Main product type - normalized across all providers
|
|
590
|
+
*
|
|
591
|
+
* Universal format compatible with:
|
|
592
|
+
* - Shopify: Product (Storefront API 2024-01)
|
|
593
|
+
* - Medusa.js: StoreProduct (v2)
|
|
594
|
+
* - WooCommerce: Product (REST API v3)
|
|
595
|
+
* - Magento/Adobe Commerce: ProductInterface (GraphQL)
|
|
596
|
+
*
|
|
597
|
+
* Platform-specific fields are stored in metadata.
|
|
598
|
+
*/
|
|
599
|
+
interface Product {
|
|
600
|
+
id: string;
|
|
601
|
+
handle: string;
|
|
602
|
+
title: string;
|
|
603
|
+
description: string;
|
|
604
|
+
descriptionHtml?: string;
|
|
605
|
+
availableForSale: boolean;
|
|
606
|
+
options: ProductOption[];
|
|
607
|
+
variants: ProductVariant[];
|
|
608
|
+
featuredImage?: Image;
|
|
609
|
+
images: Image[];
|
|
610
|
+
priceRange: PriceRange;
|
|
611
|
+
collections?: Array<{
|
|
612
|
+
id: string;
|
|
613
|
+
title: string;
|
|
614
|
+
handle: string;
|
|
615
|
+
}>;
|
|
616
|
+
productType?: string;
|
|
617
|
+
vendor?: string;
|
|
618
|
+
tags?: string[];
|
|
619
|
+
seo?: SEO;
|
|
620
|
+
createdAt: string;
|
|
621
|
+
updatedAt: string;
|
|
622
|
+
metadata?: Record<string, unknown>;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Options for fetching products
|
|
626
|
+
*/
|
|
627
|
+
interface GetProductsOptions {
|
|
628
|
+
query?: string;
|
|
629
|
+
sortKey?: string;
|
|
630
|
+
reverse?: boolean;
|
|
631
|
+
first?: number;
|
|
632
|
+
skip?: number;
|
|
633
|
+
/** Cursor (string) or offset (number) for pagination */
|
|
634
|
+
after?: string | number;
|
|
635
|
+
regionId?: string;
|
|
636
|
+
/** Basic category filtering — backend IDs resolved from URL slugs */
|
|
637
|
+
categoryIds?: string[];
|
|
638
|
+
/** Basic collection filtering — backend IDs resolved from URL slugs */
|
|
639
|
+
collectionIds?: string[];
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Represents a single active filter displayed as a chip
|
|
643
|
+
* Used in ActiveFiltersChips component
|
|
644
|
+
*/
|
|
645
|
+
interface ActiveFilter {
|
|
646
|
+
/** Unique identifier (e.g., "material-wood") */
|
|
647
|
+
id: string;
|
|
648
|
+
/** Display category (e.g., "Material") */
|
|
649
|
+
category: string;
|
|
650
|
+
/** Display value (e.g., "Wood") */
|
|
651
|
+
label: string;
|
|
652
|
+
/** Raw value for tracking */
|
|
653
|
+
value: string | string[];
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Sort options available for product listing
|
|
657
|
+
*/
|
|
658
|
+
type SortOption = 'featured' | 'price-asc' | 'price-desc' | 'name' | 'newest' | 'rating';
|
|
659
|
+
/**
|
|
660
|
+
* A single option within a filter section (e.g., "Wood" under "Material")
|
|
661
|
+
*/
|
|
662
|
+
interface FilterOption {
|
|
663
|
+
/** URL-friendly slug (human-readable). This is what goes in the URL. */
|
|
664
|
+
value: string;
|
|
665
|
+
/** Display label shown in the UI. */
|
|
666
|
+
label: string;
|
|
667
|
+
/**
|
|
668
|
+
* Backend identifier (e.g., database ID).
|
|
669
|
+
* Present when `value` is a human-readable slug that differs from the
|
|
670
|
+
* backend ID. Used by L5 page.tsx to resolve slug → ID before querying
|
|
671
|
+
* the adapter. Optional: when absent, `value` is used as the backend ID.
|
|
672
|
+
*/
|
|
673
|
+
id?: string;
|
|
674
|
+
/** Optional facet count */
|
|
675
|
+
count?: number;
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Represents a collapsible filter section in the sidebar
|
|
679
|
+
*/
|
|
680
|
+
interface FilterSection {
|
|
681
|
+
id: string;
|
|
682
|
+
label: string;
|
|
683
|
+
type: 'checkbox' | 'range' | 'radio' | 'select';
|
|
684
|
+
options?: FilterOption[];
|
|
685
|
+
min?: number;
|
|
686
|
+
max?: number;
|
|
687
|
+
defaultExpanded?: boolean;
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Simplified product preview for e-commerce patterns
|
|
691
|
+
* Used in ProductCard, QuickView, etc.
|
|
692
|
+
*/
|
|
693
|
+
interface ProductPreview {
|
|
694
|
+
id: string;
|
|
695
|
+
name: string;
|
|
696
|
+
price: number;
|
|
697
|
+
originalPrice?: number;
|
|
698
|
+
image: string;
|
|
699
|
+
rating: number;
|
|
700
|
+
reviewCount: number;
|
|
701
|
+
isNew?: boolean;
|
|
702
|
+
isOnSale?: boolean;
|
|
703
|
+
isOutOfStock?: boolean;
|
|
704
|
+
discountPercent?: number;
|
|
705
|
+
stock?: number;
|
|
706
|
+
category?: string;
|
|
707
|
+
description?: string;
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Product review type
|
|
711
|
+
*/
|
|
712
|
+
interface Review {
|
|
713
|
+
id: string;
|
|
714
|
+
author: string;
|
|
715
|
+
rating: number;
|
|
716
|
+
date: string;
|
|
717
|
+
title: string;
|
|
718
|
+
body: string;
|
|
719
|
+
verified?: boolean;
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Product compare item structure
|
|
723
|
+
*/
|
|
724
|
+
interface CompareProduct {
|
|
725
|
+
id: string;
|
|
726
|
+
name: string;
|
|
727
|
+
image: string;
|
|
728
|
+
price: number;
|
|
729
|
+
attributes: Record<string, string>;
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Product variant as returned by the admin API.
|
|
733
|
+
*
|
|
734
|
+
* Distinct from `ProductVariant` (storefront API) because admin variants
|
|
735
|
+
* carry backend-specific fields like inventory counts and raw prices.
|
|
736
|
+
*/
|
|
737
|
+
interface AdminProductVariant {
|
|
738
|
+
id: string;
|
|
739
|
+
title: string;
|
|
740
|
+
sku?: string;
|
|
741
|
+
/** Total inventory quantity across all stock locations */
|
|
742
|
+
quantityAvailable?: number;
|
|
743
|
+
/** Prices available for this variant */
|
|
744
|
+
prices?: Array<{
|
|
745
|
+
amount: number;
|
|
746
|
+
currencyCode: string;
|
|
747
|
+
}>;
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* Product as returned by the admin API.
|
|
751
|
+
*
|
|
752
|
+
* Intentionally separate from `Product` (storefront API) because:
|
|
753
|
+
* - The storefront API only returns published products and derives
|
|
754
|
+
* `availableForSale` from stock/sales-channel rules — no explicit status.
|
|
755
|
+
* - The admin API returns ALL products (including draft, proposed, rejected)
|
|
756
|
+
* with the backend-native `status` field.
|
|
757
|
+
*
|
|
758
|
+
* Use this type exclusively in admin dashboard contexts.
|
|
759
|
+
*/
|
|
760
|
+
interface AdminProduct {
|
|
761
|
+
id: string;
|
|
762
|
+
handle: string;
|
|
763
|
+
title: string;
|
|
764
|
+
/** Optional product description */
|
|
765
|
+
description?: string;
|
|
766
|
+
/**
|
|
767
|
+
* Backend-native status string.
|
|
768
|
+
* Values are provider-specific — e.g. 'published' | 'draft' | 'proposed' | 'rejected'.
|
|
769
|
+
*/
|
|
770
|
+
status: string;
|
|
771
|
+
variants: AdminProductVariant[];
|
|
772
|
+
/** URL of the product thumbnail image */
|
|
773
|
+
thumbnail?: string;
|
|
774
|
+
/** URLs of all product images */
|
|
775
|
+
images?: string[];
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* Options for advanced product search (requires backend search engine support).
|
|
779
|
+
* Extends GetProductsOptions so it can be passed as a fallback to getProducts().
|
|
780
|
+
* Used with CommerceProvider.searchProductsAdvanced().
|
|
781
|
+
*/
|
|
782
|
+
interface AdvancedSearchProductsOptions extends GetProductsOptions {
|
|
783
|
+
/** Filter by category IDs */
|
|
784
|
+
categoryIds?: string[];
|
|
785
|
+
/** Filter by collection IDs */
|
|
786
|
+
collectionIds?: string[];
|
|
787
|
+
/** Filter by tag IDs */
|
|
788
|
+
tagIds?: string[];
|
|
789
|
+
/** Minimum price (in major currency units) */
|
|
790
|
+
priceMin?: number;
|
|
791
|
+
/** Maximum price (in major currency units) */
|
|
792
|
+
priceMax?: number;
|
|
793
|
+
/** Currency code for price filtering */
|
|
794
|
+
currencyCode?: string;
|
|
795
|
+
/** Only include products with stock available */
|
|
796
|
+
inStockOnly?: boolean;
|
|
797
|
+
/** Attribute filters (e.g. RAM, brand) */
|
|
798
|
+
attributes?: Array<{
|
|
799
|
+
id: string;
|
|
800
|
+
values: string[];
|
|
801
|
+
}>;
|
|
802
|
+
/** Include variant-level data in results */
|
|
803
|
+
includeVariants?: boolean;
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Metadata returned alongside advanced search results.
|
|
807
|
+
*/
|
|
808
|
+
interface SearchResultMeta {
|
|
809
|
+
/** Total number of matching products */
|
|
810
|
+
total?: number;
|
|
811
|
+
/** Max results requested */
|
|
812
|
+
limit?: number;
|
|
813
|
+
/** Pagination offset */
|
|
814
|
+
offset?: number;
|
|
815
|
+
/** Backend search processing time in milliseconds */
|
|
816
|
+
processingTimeMs?: number;
|
|
817
|
+
/** Whether hybrid (vector + keyword) search was used */
|
|
818
|
+
hybridSearchUsed?: boolean;
|
|
819
|
+
/** Filters that were actually applied by the backend search engine */
|
|
820
|
+
appliedFilters?: Record<string, unknown>;
|
|
821
|
+
/** Price context used for price filtering */
|
|
822
|
+
priceContext?: {
|
|
823
|
+
currencyCode: string;
|
|
824
|
+
regionId?: string;
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Filter configuration returned by CommerceProvider.getAvailableFilters().
|
|
829
|
+
* Represents one filterable dimension (e.g. Color, RAM, Price range).
|
|
830
|
+
*
|
|
831
|
+
* Types:
|
|
832
|
+
* - `checkbox` / `multi` → multiple selectable options
|
|
833
|
+
* - `select` / `single` → single selectable option
|
|
834
|
+
* - `range` → numeric min/max range
|
|
835
|
+
* - `boolean` → on/off toggle (e.g. "In Stock")
|
|
836
|
+
*/
|
|
837
|
+
interface FilterConfig {
|
|
838
|
+
/** Unique filter identifier */
|
|
839
|
+
id: string;
|
|
840
|
+
/** Display label for the filter group */
|
|
841
|
+
label: string;
|
|
842
|
+
/** Filter UI type */
|
|
843
|
+
type: 'checkbox' | 'multi' | 'select' | 'single' | 'range' | 'boolean';
|
|
844
|
+
/** Selectable options (for checkbox/multi/select/single types) */
|
|
845
|
+
options?: FilterOption[];
|
|
846
|
+
/** Min value (for range type) */
|
|
847
|
+
min?: number;
|
|
848
|
+
/** Max value (for range type) */
|
|
849
|
+
max?: number;
|
|
850
|
+
/** Whether this filter is currently applied */
|
|
851
|
+
isActive?: boolean;
|
|
852
|
+
/** Sort priority — lower number = displayed first */
|
|
853
|
+
ranking?: number;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* @thorprovider/adapters v2.0
|
|
858
|
+
* Cart types - unified interface for all commerce providers
|
|
859
|
+
*/
|
|
860
|
+
|
|
861
|
+
/**
|
|
862
|
+
* Product reference in cart
|
|
863
|
+
*/
|
|
864
|
+
interface CartProduct {
|
|
865
|
+
id: string;
|
|
866
|
+
handle: string;
|
|
867
|
+
title: string;
|
|
868
|
+
featuredImage: Image;
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Cart line item
|
|
872
|
+
*/
|
|
873
|
+
interface CartItem {
|
|
874
|
+
id: string | undefined;
|
|
875
|
+
quantity: number;
|
|
876
|
+
stockStatus?: StockStatus;
|
|
877
|
+
cost: {
|
|
878
|
+
totalAmount: Money;
|
|
879
|
+
};
|
|
880
|
+
merchandise: {
|
|
881
|
+
id: string;
|
|
882
|
+
title: string;
|
|
883
|
+
selectedOptions: SelectedOption[];
|
|
884
|
+
product: CartProduct;
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Cart cost breakdown
|
|
889
|
+
*/
|
|
890
|
+
interface CartCost {
|
|
891
|
+
subtotalAmount: Money;
|
|
892
|
+
totalAmount: Money;
|
|
893
|
+
totalTaxAmount?: Money;
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* Shipping method option
|
|
897
|
+
* Used during checkout to display available shipping methods
|
|
898
|
+
*/
|
|
899
|
+
interface ShippingMethod {
|
|
900
|
+
/** Unique identifier for the shipping method */
|
|
901
|
+
id: string;
|
|
902
|
+
/** Display name (e.g., 'Standard Shipping', 'Express') */
|
|
903
|
+
name: string;
|
|
904
|
+
/** Price for this shipping method */
|
|
905
|
+
price: Money;
|
|
906
|
+
/** Optional description */
|
|
907
|
+
description?: string;
|
|
908
|
+
/** Estimated delivery time (e.g., '3-5 business days') */
|
|
909
|
+
estimatedDays?: string;
|
|
910
|
+
}
|
|
911
|
+
/**
|
|
912
|
+
* Main cart type - normalized across all providers
|
|
913
|
+
*/
|
|
914
|
+
interface Cart {
|
|
915
|
+
id: string | undefined;
|
|
916
|
+
checkoutUrl: string;
|
|
917
|
+
cost: CartCost;
|
|
918
|
+
lines: CartItem[];
|
|
919
|
+
totalQuantity: number;
|
|
920
|
+
fulfillmentOptions?: FulfillmentOption[];
|
|
921
|
+
stockValidation?: StockValidation;
|
|
922
|
+
/** ISO timestamp when cart was completed/converted to order (undefined if active) */
|
|
923
|
+
completedAt?: string;
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* Input for adding items to cart
|
|
927
|
+
*/
|
|
928
|
+
interface CartLineInput {
|
|
929
|
+
merchandiseId: string;
|
|
930
|
+
quantity: number;
|
|
931
|
+
}
|
|
932
|
+
/**
|
|
933
|
+
* Input for updating cart items
|
|
934
|
+
*/
|
|
935
|
+
interface CartLineUpdate {
|
|
936
|
+
id: string;
|
|
937
|
+
merchandiseId: string;
|
|
938
|
+
quantity: number;
|
|
939
|
+
}
|
|
940
|
+
/**
|
|
941
|
+
* Discount code applied to the cart
|
|
942
|
+
*
|
|
943
|
+
* Universal format for discount/promo codes across all providers.
|
|
944
|
+
* Adapters transform platform-specific discount formats to this interface.
|
|
945
|
+
*/
|
|
946
|
+
interface DiscountCode {
|
|
947
|
+
/** Discount code string (e.g., "SUMMER2024") */
|
|
948
|
+
code: string;
|
|
949
|
+
/** Discount value (amount or percentage) */
|
|
950
|
+
value: number;
|
|
951
|
+
/** Whether the value is a percentage (true) or fixed amount (false) */
|
|
952
|
+
isPercentage: boolean;
|
|
953
|
+
/** Human-readable description of the discount */
|
|
954
|
+
description?: string;
|
|
955
|
+
/** Minimum purchase amount required */
|
|
956
|
+
minimumAmount?: Money;
|
|
957
|
+
/** Expiration date */
|
|
958
|
+
expiresAt?: Date;
|
|
959
|
+
/** Maximum number of uses allowed */
|
|
960
|
+
maxUses?: number;
|
|
961
|
+
/** Current number of times this code has been used */
|
|
962
|
+
usageCount?: number;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
* @thorprovider/adapters v2.0
|
|
967
|
+
* Collection types - unified interface for all commerce providers
|
|
968
|
+
*/
|
|
969
|
+
|
|
970
|
+
/**
|
|
971
|
+
* Product collection/category
|
|
972
|
+
*/
|
|
973
|
+
interface Collection {
|
|
974
|
+
id: string;
|
|
975
|
+
handle: string;
|
|
976
|
+
title: string;
|
|
977
|
+
description: string;
|
|
978
|
+
seo?: SEO;
|
|
979
|
+
path: string;
|
|
980
|
+
updatedAt: string;
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* Options for fetching collections
|
|
984
|
+
*/
|
|
985
|
+
interface GetCollectionsOptions {
|
|
986
|
+
/** Maximum number of collections to return */
|
|
987
|
+
limit?: number;
|
|
988
|
+
/** Search query to filter collections by title */
|
|
989
|
+
query?: string;
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* Options for fetching collection products
|
|
993
|
+
*/
|
|
994
|
+
interface CollectionProductsOptions {
|
|
995
|
+
sortKey?: string;
|
|
996
|
+
reverse?: boolean;
|
|
997
|
+
first?: number;
|
|
998
|
+
after?: string;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
/**
|
|
1002
|
+
* @thorprovider/types v2.0
|
|
1003
|
+
* Product Category types - unified interface for all commerce providers
|
|
1004
|
+
*/
|
|
1005
|
+
/**
|
|
1006
|
+
* Product category (hierarchical taxonomy)
|
|
1007
|
+
*/
|
|
1008
|
+
interface ProductCategory {
|
|
1009
|
+
/** Unique identifier */
|
|
1010
|
+
id: string;
|
|
1011
|
+
/** Category name */
|
|
1012
|
+
name: string;
|
|
1013
|
+
/** URL-safe handle/slug */
|
|
1014
|
+
handle: string;
|
|
1015
|
+
/** Category description */
|
|
1016
|
+
description?: string;
|
|
1017
|
+
/** Parent category ID (null for root categories) */
|
|
1018
|
+
parentCategoryId?: string;
|
|
1019
|
+
/** Number of products in category */
|
|
1020
|
+
productCount?: number;
|
|
1021
|
+
/** Category image URL */
|
|
1022
|
+
image?: string;
|
|
1023
|
+
/** Metadata */
|
|
1024
|
+
metadata?: Record<string, any>;
|
|
1025
|
+
}
|
|
1026
|
+
/**
|
|
1027
|
+
* Custom fetcher callback for advanced category queries.
|
|
1028
|
+
*
|
|
1029
|
+
* When provided, this callback replaces the default SDK logic entirely.
|
|
1030
|
+
* Useful for: custom API endpoints, backend-specific filters, Module Link queries.
|
|
1031
|
+
*
|
|
1032
|
+
* @example
|
|
1033
|
+
* ```typescript
|
|
1034
|
+
* // Custom endpoint that filters categories by channel server-side
|
|
1035
|
+
* const customFetcher = async (options: GetCategoriesOptions) => {
|
|
1036
|
+
* const response = await fetch(`/api/admin/sales-channels/${options.salesChannelId}/categories`);
|
|
1037
|
+
* return response.json();
|
|
1038
|
+
* };
|
|
1039
|
+
*
|
|
1040
|
+
* const categories = await provider.getCategories({
|
|
1041
|
+
* salesChannelId: 'sc_123',
|
|
1042
|
+
* customFetcher,
|
|
1043
|
+
* });
|
|
1044
|
+
* ```
|
|
1045
|
+
*/
|
|
1046
|
+
type GetCategoriesCallback = (options: GetCategoriesOptions) => Promise<ProductCategory[]>;
|
|
1047
|
+
/**
|
|
1048
|
+
* Options for fetching categories
|
|
1049
|
+
*/
|
|
1050
|
+
interface GetCategoriesOptions {
|
|
1051
|
+
/** Include child categories */
|
|
1052
|
+
includeDescendants?: boolean;
|
|
1053
|
+
/** Parent category ID to filter by */
|
|
1054
|
+
parentCategoryId?: string;
|
|
1055
|
+
/** Maximum number of categories to return */
|
|
1056
|
+
limit?: number;
|
|
1057
|
+
/** Search query to filter categories by name/handle */
|
|
1058
|
+
query?: string;
|
|
1059
|
+
/**
|
|
1060
|
+
* Scope results to a specific sales channel / storefront channel.
|
|
1061
|
+
* When provided, only categories that contain at least one product available
|
|
1062
|
+
* in the given channel will be returned.
|
|
1063
|
+
*
|
|
1064
|
+
* Maps to: Medusa `sales_channel_id`, Shopify Sales Channel, etc.
|
|
1065
|
+
* Adapters that support native server-side filtering should prefer it;
|
|
1066
|
+
* others may fall back to a client-side post-filter pass.
|
|
1067
|
+
*/
|
|
1068
|
+
salesChannelId?: string;
|
|
1069
|
+
/**
|
|
1070
|
+
* Custom fetcher callback (optional).
|
|
1071
|
+
*
|
|
1072
|
+
* When provided, this callback is invoked instead of the default SDK logic.
|
|
1073
|
+
* Allows backends to implement custom filters, Module Link queries, or
|
|
1074
|
+
* call alternative endpoints (e.g., `/api/admin/sales-channels/{id}/categories`).
|
|
1075
|
+
*
|
|
1076
|
+
* This option enables:
|
|
1077
|
+
* - **Medusa Module Link**: Query categories via custom module API
|
|
1078
|
+
* - **Custom endpoints**: Call `/api/admin/sales-channels/{id}/categories` for server-side filtering
|
|
1079
|
+
* - **Backend-specific optimizations**: Shopify/WooCommerce adapters can implement their own logic
|
|
1080
|
+
*
|
|
1081
|
+
* @default undefined (uses default SDK + in-memory filter)
|
|
1082
|
+
* @see {@link GetCategoriesCallback} for callback signature
|
|
1083
|
+
*/
|
|
1084
|
+
customFetcher?: GetCategoriesCallback;
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
/**
|
|
1088
|
+
* @thorprovider/types v3.0
|
|
1089
|
+
* Customer types - unified interface for all commerce providers
|
|
1090
|
+
* Universal interfaces compatible with: Shopify, Medusa.js, WooCommerce, Magento, BigCommerce
|
|
1091
|
+
*/
|
|
1092
|
+
/**
|
|
1093
|
+
* Customer address
|
|
1094
|
+
*
|
|
1095
|
+
* Universal format using camelCase (JavaScript convention).
|
|
1096
|
+
*
|
|
1097
|
+
* Platform mapping:
|
|
1098
|
+
* - Shopify: MailingAddress (firstName, address1, zip, province, countryCodeV2)
|
|
1099
|
+
* - Medusa: Address (first_name, address_1, postal_code, province, country_code)
|
|
1100
|
+
* - WooCommerce: Address (first_name, address_1, postcode, state, country)
|
|
1101
|
+
* - Magento: Address (firstname, street, postcode, region, country_id)
|
|
1102
|
+
*
|
|
1103
|
+
* Adapters transform platform-specific snake_case to universal camelCase.
|
|
1104
|
+
*/
|
|
1105
|
+
interface Address {
|
|
1106
|
+
id?: string;
|
|
1107
|
+
firstName: string;
|
|
1108
|
+
lastName: string;
|
|
1109
|
+
company?: string;
|
|
1110
|
+
address1: string;
|
|
1111
|
+
address2?: string;
|
|
1112
|
+
city: string;
|
|
1113
|
+
province?: string;
|
|
1114
|
+
postalCode: string;
|
|
1115
|
+
countryCode: string;
|
|
1116
|
+
phone?: string;
|
|
1117
|
+
isDefault?: boolean;
|
|
1118
|
+
metadata?: Record<string, unknown>;
|
|
1119
|
+
}
|
|
1120
|
+
/**
|
|
1121
|
+
* Customer
|
|
1122
|
+
*
|
|
1123
|
+
* Universal customer format using camelCase.
|
|
1124
|
+
* Adapters transform platform-specific naming to this format.
|
|
1125
|
+
*/
|
|
1126
|
+
interface Customer {
|
|
1127
|
+
id: string;
|
|
1128
|
+
email: string;
|
|
1129
|
+
firstName: string | null;
|
|
1130
|
+
lastName: string | null;
|
|
1131
|
+
phone?: string | null;
|
|
1132
|
+
hasAccount?: boolean;
|
|
1133
|
+
createdAt?: string;
|
|
1134
|
+
updatedAt?: string;
|
|
1135
|
+
/**
|
|
1136
|
+
* Flexible metadata storage.
|
|
1137
|
+
*
|
|
1138
|
+
* Multi-tenant convention: when `metadata.sales_channel_id` is present the
|
|
1139
|
+
* customer is scoped to that channel. See `@thorprovider/adapters/metadata` helpers.
|
|
1140
|
+
*/
|
|
1141
|
+
metadata?: Record<string, unknown>;
|
|
1142
|
+
}
|
|
1143
|
+
/**
|
|
1144
|
+
* Custom fetcher callback for advanced customer queries.
|
|
1145
|
+
*
|
|
1146
|
+
* When provided, this callback replaces the default SDK logic entirely.
|
|
1147
|
+
* Useful for: custom API endpoints, backend-specific filters, Module Link queries.
|
|
1148
|
+
*
|
|
1149
|
+
* @example
|
|
1150
|
+
* ```typescript
|
|
1151
|
+
* // Custom endpoint that filters by channel server-side
|
|
1152
|
+
* const customFetcher = async (options: GetCustomersOptions) => {
|
|
1153
|
+
* const response = await fetch(`/api/admin/sales-channels/${options.salesChannelId}/customers`);
|
|
1154
|
+
* return response.json();
|
|
1155
|
+
* };
|
|
1156
|
+
*
|
|
1157
|
+
* const customers = await provider.getCustomers({
|
|
1158
|
+
* salesChannelId: 'sc_123',
|
|
1159
|
+
* customFetcher,
|
|
1160
|
+
* });
|
|
1161
|
+
* ```
|
|
1162
|
+
*/
|
|
1163
|
+
type GetCustomersCallback = (options: GetCustomersOptions) => Promise<Customer[]>;
|
|
1164
|
+
/**
|
|
1165
|
+
* Options for querying a list of customers.
|
|
1166
|
+
*
|
|
1167
|
+
* Used by CommerceProvider.getCustomers() and admin list endpoints.
|
|
1168
|
+
*/
|
|
1169
|
+
interface GetCustomersOptions {
|
|
1170
|
+
/** Full-text search by name or email */
|
|
1171
|
+
search?: string;
|
|
1172
|
+
/** Maximum number of results */
|
|
1173
|
+
limit?: number;
|
|
1174
|
+
/** Zero-based offset for pagination */
|
|
1175
|
+
offset?: number;
|
|
1176
|
+
/** Field to sort results by */
|
|
1177
|
+
sortBy?: 'createdAt' | 'email' | 'firstName';
|
|
1178
|
+
/**
|
|
1179
|
+
* Filter customers to a specific sales channel.
|
|
1180
|
+
*
|
|
1181
|
+
* When set, only customers whose `metadata.sales_channel_id` matches
|
|
1182
|
+
* this value are returned. Enables multi-tenant isolation for
|
|
1183
|
+
* dropshippers who should only see their own customers.
|
|
1184
|
+
*
|
|
1185
|
+
* If omitted, all customers are returned (admin/super-admin view).
|
|
1186
|
+
*/
|
|
1187
|
+
salesChannelId?: string;
|
|
1188
|
+
/**
|
|
1189
|
+
* Custom fetcher callback (optional).
|
|
1190
|
+
*
|
|
1191
|
+
* When provided, this callback is invoked instead of the default SDK logic.
|
|
1192
|
+
* Allows backends to implement custom filters, Module Link queries, or
|
|
1193
|
+
* call alternative endpoints (e.g., `/api/admin/sales-channels/{id}/customers`).
|
|
1194
|
+
*
|
|
1195
|
+
* This option enables:
|
|
1196
|
+
* - **Medusa Module Link**: Query customers via custom module API
|
|
1197
|
+
* - **Custom endpoints**: Call `/api/admin/sales-channels/{id}/customers` for server-side filtering
|
|
1198
|
+
* - **Backend-specific optimizations**: Shopify/WooCommerce adapters can implement their own logic
|
|
1199
|
+
*
|
|
1200
|
+
* @default undefined (uses default SDK + in-memory filter)
|
|
1201
|
+
* @see {@link GetCustomersCallback} for callback signature
|
|
1202
|
+
*/
|
|
1203
|
+
customFetcher?: GetCustomersCallback;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
/**
|
|
1207
|
+
* @thorprovider/types v3.0
|
|
1208
|
+
* Region types - geographic region configuration
|
|
1209
|
+
* Universal interfaces compatible with: Shopify Markets, Medusa Regions, WooCommerce Zones
|
|
1210
|
+
*/
|
|
1211
|
+
/**
|
|
1212
|
+
* Geographic region configuration
|
|
1213
|
+
*
|
|
1214
|
+
* Represents a regional market with specific currency, tax, and payment settings.
|
|
1215
|
+
*
|
|
1216
|
+
* Platform mapping:
|
|
1217
|
+
* - Shopify: Market (primaryDomain, regions, currencySettings)
|
|
1218
|
+
* - Medusa: Region (currency_code, countries, payment_providers, tax_rate)
|
|
1219
|
+
* - WooCommerce: Shipping Zone + Tax Settings (combined concept)
|
|
1220
|
+
*
|
|
1221
|
+
* Adapters transform platform-specific region data to this universal format.
|
|
1222
|
+
*/
|
|
1223
|
+
interface Region {
|
|
1224
|
+
/** Unique region identifier */
|
|
1225
|
+
id: string;
|
|
1226
|
+
/** Region name (e.g., "United States", "Europe", "North America") */
|
|
1227
|
+
name: string;
|
|
1228
|
+
/** ISO 3166-1 alpha-2 country codes included in this region (e.g., ["US", "CA"]) */
|
|
1229
|
+
countryCodes: string[];
|
|
1230
|
+
/** Default currency for this region (ISO 4217 code, e.g., "USD", "EUR") */
|
|
1231
|
+
currency: string;
|
|
1232
|
+
/** Available payment provider IDs in this region */
|
|
1233
|
+
paymentProviders?: string[];
|
|
1234
|
+
/** Tax rate for this region (as decimal, e.g., 0.08 for 8%) */
|
|
1235
|
+
taxRate?: number;
|
|
1236
|
+
/** Whether this region is enabled and available for customers */
|
|
1237
|
+
isEnabled?: boolean;
|
|
1238
|
+
/** Additional region metadata for platform-specific features */
|
|
1239
|
+
metadata?: Record<string, unknown>;
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
/**
|
|
1243
|
+
* @thorprovider/types v3.0
|
|
1244
|
+
* Order types - unified interface for all commerce providers
|
|
1245
|
+
* Universal interfaces compatible with: Shopify, Medusa.js, WooCommerce, Magento, BigCommerce
|
|
1246
|
+
*/
|
|
1247
|
+
|
|
1248
|
+
/**
|
|
1249
|
+
* Order status (overall)
|
|
1250
|
+
*
|
|
1251
|
+
* Platform mapping:
|
|
1252
|
+
* - Shopify: Derived from financialStatus + fulfillmentStatus
|
|
1253
|
+
* - Medusa: status field
|
|
1254
|
+
* - WooCommerce: status (pending/processing/completed/cancelled/refunded)
|
|
1255
|
+
* - Magento: status
|
|
1256
|
+
*/
|
|
1257
|
+
type OrderStatus = 'pending' | 'processing' | 'completed' | 'cancelled' | 'refunded';
|
|
1258
|
+
/**
|
|
1259
|
+
* Payment status (separate from order status)
|
|
1260
|
+
*
|
|
1261
|
+
* Platform mapping:
|
|
1262
|
+
* - Shopify: financialStatus (PENDING, AUTHORIZED, PAID, REFUNDED, etc.)
|
|
1263
|
+
* - Medusa: payment_status
|
|
1264
|
+
* - WooCommerce: Derived from order status
|
|
1265
|
+
* - Magento: payment status
|
|
1266
|
+
*/
|
|
1267
|
+
type PaymentStatus = 'pending' | 'authorized' | 'paid' | 'partially_refunded' | 'refunded';
|
|
1268
|
+
/**
|
|
1269
|
+
* Fulfillment status
|
|
1270
|
+
*
|
|
1271
|
+
* Platform mapping:
|
|
1272
|
+
* - Shopify: fulfillmentStatus (FULFILLED, UNFULFILLED, etc.)
|
|
1273
|
+
* - Medusa: fulfillment_status
|
|
1274
|
+
* - WooCommerce: Derived from order status
|
|
1275
|
+
* - Magento: shipping_status
|
|
1276
|
+
*/
|
|
1277
|
+
type FulfillmentStatus = 'unfulfilled' | 'partially_fulfilled' | 'fulfilled' | 'returned';
|
|
1278
|
+
/**
|
|
1279
|
+
* Order line item
|
|
1280
|
+
*
|
|
1281
|
+
* Universal format for order items across platforms.
|
|
1282
|
+
*/
|
|
1283
|
+
interface OrderItem {
|
|
1284
|
+
id: string;
|
|
1285
|
+
title: string;
|
|
1286
|
+
variantTitle?: string;
|
|
1287
|
+
quantity: number;
|
|
1288
|
+
price: Money;
|
|
1289
|
+
total: Money;
|
|
1290
|
+
sku?: string;
|
|
1291
|
+
image?: Image;
|
|
1292
|
+
productId?: string;
|
|
1293
|
+
variantId?: string;
|
|
1294
|
+
}
|
|
1295
|
+
/**
|
|
1296
|
+
* Order
|
|
1297
|
+
*
|
|
1298
|
+
* Universal format compatible with:
|
|
1299
|
+
* - Shopify: Order (Storefront API)
|
|
1300
|
+
* - Medusa: StoreOrder (v2)
|
|
1301
|
+
* - WooCommerce: Order (REST API)
|
|
1302
|
+
* - Magento: Order (GraphQL)
|
|
1303
|
+
*/
|
|
1304
|
+
interface Order {
|
|
1305
|
+
id: string;
|
|
1306
|
+
orderNumber: string;
|
|
1307
|
+
email: string;
|
|
1308
|
+
status: OrderStatus;
|
|
1309
|
+
paymentStatus: PaymentStatus;
|
|
1310
|
+
fulfillmentStatus: FulfillmentStatus;
|
|
1311
|
+
customerId?: string;
|
|
1312
|
+
customer?: Customer;
|
|
1313
|
+
items: OrderItem[];
|
|
1314
|
+
subtotal: Money;
|
|
1315
|
+
total: Money;
|
|
1316
|
+
tax?: Money;
|
|
1317
|
+
shipping?: Money;
|
|
1318
|
+
discount?: Money;
|
|
1319
|
+
shippingAddress?: Address;
|
|
1320
|
+
billingAddress?: Address;
|
|
1321
|
+
createdAt: string;
|
|
1322
|
+
updatedAt: string;
|
|
1323
|
+
completedAt?: string;
|
|
1324
|
+
cancelledAt?: string;
|
|
1325
|
+
isDraft?: boolean;
|
|
1326
|
+
metadata?: Record<string, unknown>;
|
|
1327
|
+
}
|
|
1328
|
+
/**
|
|
1329
|
+
* Custom fetcher callback for advanced order queries.
|
|
1330
|
+
*
|
|
1331
|
+
* When provided, this callback replaces the default SDK logic entirely.
|
|
1332
|
+
* Useful for: custom API endpoints, backend-specific filters, Module Link queries.
|
|
1333
|
+
*
|
|
1334
|
+
* @example
|
|
1335
|
+
* ```typescript
|
|
1336
|
+
* // Custom endpoint that filters orders by channel server-side
|
|
1337
|
+
* const customFetcher = async (options: GetOrdersOptions) => {
|
|
1338
|
+
* const response = await fetch(
|
|
1339
|
+
* `/api/admin/sales-channels/${options.salesChannelId}/orders`
|
|
1340
|
+
* );
|
|
1341
|
+
* return response.json();
|
|
1342
|
+
* };
|
|
1343
|
+
*
|
|
1344
|
+
* const orders = await provider.getOrders({
|
|
1345
|
+
* salesChannelId: 'sc_123',
|
|
1346
|
+
* customFetcher,
|
|
1347
|
+
* });
|
|
1348
|
+
* ```
|
|
1349
|
+
*/
|
|
1350
|
+
type GetOrdersCallback = (options: GetOrdersOptions) => Promise<Order[]>;
|
|
1351
|
+
/**
|
|
1352
|
+
* Options for querying a list of orders.
|
|
1353
|
+
*
|
|
1354
|
+
* Used by CommerceProvider.getOrders() and admin list endpoints.
|
|
1355
|
+
*/
|
|
1356
|
+
interface GetOrdersOptions {
|
|
1357
|
+
/** Customer ID to filter orders by */
|
|
1358
|
+
customerId?: string;
|
|
1359
|
+
/** Maximum number of results */
|
|
1360
|
+
limit?: number;
|
|
1361
|
+
/** Zero-based offset for pagination */
|
|
1362
|
+
offset?: number;
|
|
1363
|
+
/**
|
|
1364
|
+
* Filter orders to a specific sales channel.
|
|
1365
|
+
*
|
|
1366
|
+
* When set, only orders whose `metadata.sales_channel_id` matches
|
|
1367
|
+
* this value are returned. Enables multi-tenant isolation.
|
|
1368
|
+
*
|
|
1369
|
+
* If omitted, orders are returned unfiltered (admin view).
|
|
1370
|
+
*/
|
|
1371
|
+
salesChannelId?: string;
|
|
1372
|
+
/**
|
|
1373
|
+
* Custom fetcher callback (optional).
|
|
1374
|
+
*
|
|
1375
|
+
* When provided, this callback is invoked instead of the default SDK logic.
|
|
1376
|
+
* Allows backends to implement custom filters, Module Link queries, or
|
|
1377
|
+
* call alternative endpoints (e.g., `/api/admin/sales-channels/{id}/orders`).
|
|
1378
|
+
*
|
|
1379
|
+
* This option enables:
|
|
1380
|
+
* - **Medusa Module Link**: Query orders via custom module API
|
|
1381
|
+
* - **Custom endpoints**: Call `/api/admin/sales-channels/{id}/orders` for server-side filtering
|
|
1382
|
+
* - **Backend-specific optimizations**: Shopify/WooCommerce adapters can implement their own logic
|
|
1383
|
+
*
|
|
1384
|
+
* @default undefined (uses default SDK + in-memory filter)
|
|
1385
|
+
* @see {@link GetOrdersCallback} for callback signature
|
|
1386
|
+
*/
|
|
1387
|
+
customFetcher?: GetOrdersCallback;
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
/**
|
|
1391
|
+
* Union type of all supported provider string values.
|
|
1392
|
+
* Use this for type annotations when a provider type is expected.
|
|
1393
|
+
*
|
|
1394
|
+
* @example
|
|
1395
|
+
* ```typescript
|
|
1396
|
+
* function getProviderName(type: ProviderTypeString): string {
|
|
1397
|
+
* // type is 'medusa'
|
|
1398
|
+
* }
|
|
1399
|
+
* ```
|
|
1400
|
+
*/
|
|
1401
|
+
type ProviderTypeString = 'medusa' | 'shopify' | 'bigcommerce' | 'woocommerce' | 'spree' | 'magento';
|
|
1402
|
+
/**
|
|
1403
|
+
* Metadata about each provider.
|
|
1404
|
+
* Useful for UI, error messages, validation, and documentation.
|
|
1405
|
+
*
|
|
1406
|
+
* @internal
|
|
1407
|
+
*/
|
|
1408
|
+
declare const PROVIDER_METADATA: Record<ProviderTypeString, {
|
|
1409
|
+
name: string;
|
|
1410
|
+
description: string;
|
|
1411
|
+
requiresStorefront: boolean;
|
|
1412
|
+
requiredEnvVars: string[];
|
|
1413
|
+
maxRetries: number;
|
|
1414
|
+
}>;
|
|
1415
|
+
/**
|
|
1416
|
+
* Check if a string is a valid provider type.
|
|
1417
|
+
*
|
|
1418
|
+
* @example
|
|
1419
|
+
* ```typescript
|
|
1420
|
+
* if (isSupportedProviderType(process.env.COMMERCE_PROVIDER)) {
|
|
1421
|
+
* // type is narrowed to ProviderTypeString
|
|
1422
|
+
* }
|
|
1423
|
+
* ```
|
|
1424
|
+
*/
|
|
1425
|
+
declare function isSupportedProviderType(value: unknown): value is ProviderTypeString;
|
|
1426
|
+
/**
|
|
1427
|
+
* Get metadata for a provider type.
|
|
1428
|
+
* Useful for validation, error messages, and logging.
|
|
1429
|
+
*
|
|
1430
|
+
* @example
|
|
1431
|
+
* ```typescript
|
|
1432
|
+
* const meta = getProviderMetadata('medusa');
|
|
1433
|
+
* console.log(`Using ${meta.name} with max ${meta.maxRetries} retries`);
|
|
1434
|
+
* ```
|
|
1435
|
+
*/
|
|
1436
|
+
declare function getProviderMetadata(type: ProviderTypeString): (typeof PROVIDER_METADATA)[ProviderTypeString];
|
|
1437
|
+
|
|
1438
|
+
/**
|
|
1439
|
+
* @thorprovider/types — Storefront Context
|
|
1440
|
+
*
|
|
1441
|
+
* Platform-agnostic representation of a "sales channel" or equivalent.
|
|
1442
|
+
* Abstracts differences between Medusa sales_channel, Shopify publications,
|
|
1443
|
+
* BigCommerce channels, WooCommerce sites, Spree stores, and Magento store views.
|
|
1444
|
+
*
|
|
1445
|
+
* @remarks
|
|
1446
|
+
* - Required for all multi-tenant deployments
|
|
1447
|
+
* - Returned by `CommerceProvider.getStorefrontContext()`
|
|
1448
|
+
* - MUST be validated on startup; errors should NOT be silently ignored
|
|
1449
|
+
*/
|
|
1450
|
+
/**
|
|
1451
|
+
* Supported commerce platform types for storefront identification.
|
|
1452
|
+
*
|
|
1453
|
+
* @remarks
|
|
1454
|
+
* This type is automatically synced with SupportedProviderType from provider.ts.
|
|
1455
|
+
* When adding a new provider, update packages/types/src/provider.ts,
|
|
1456
|
+
* and this type will automatically reflect the new provider.
|
|
1457
|
+
*
|
|
1458
|
+
* Currently supported:
|
|
1459
|
+
* - ✅ 'medusa': Fully implemented
|
|
1460
|
+
*
|
|
1461
|
+
* Planned (not yet implemented):
|
|
1462
|
+
* - 🟡 'shopify': Phase 2
|
|
1463
|
+
* - 🟡 'bigcommerce': Phase 2
|
|
1464
|
+
* - 🟡 'woocommerce': Phase 3
|
|
1465
|
+
* - 🟡 'spree': Phase 3
|
|
1466
|
+
* - 🟡 'magento': Phase 3
|
|
1467
|
+
*/
|
|
1468
|
+
type StorefrontPlatformType = 'medusa' | 'shopify' | 'bigcommerce' | 'woocommerce' | 'spree' | 'magento';
|
|
1469
|
+
/**
|
|
1470
|
+
* StorefrontContext
|
|
1471
|
+
*
|
|
1472
|
+
* Platform-agnostic representation of a "sales channel" or equivalent.
|
|
1473
|
+
*
|
|
1474
|
+
* @example
|
|
1475
|
+
* ```typescript
|
|
1476
|
+
* const ctx: StorefrontContext = {
|
|
1477
|
+
* id: 'sc_01J...',
|
|
1478
|
+
* name: 'B2C Storefront',
|
|
1479
|
+
* platformType: 'medusa',
|
|
1480
|
+
* requiresProductScoping: true,
|
|
1481
|
+
* currencyCode: 'USD',
|
|
1482
|
+
* };
|
|
1483
|
+
* ```
|
|
1484
|
+
*/
|
|
1485
|
+
interface StorefrontContext {
|
|
1486
|
+
/**
|
|
1487
|
+
* Unique identifier for this storefront across the system.
|
|
1488
|
+
* Examples: "sc_123" (Medusa), "gid://shopify/Channel/789" (Shopify), "1" (WooCommerce)
|
|
1489
|
+
*/
|
|
1490
|
+
id: string;
|
|
1491
|
+
/**
|
|
1492
|
+
* Human-readable name for logging and debugging.
|
|
1493
|
+
*/
|
|
1494
|
+
name: string;
|
|
1495
|
+
/**
|
|
1496
|
+
* Platform this storefront belongs to.
|
|
1497
|
+
*/
|
|
1498
|
+
platformType: StorefrontPlatformType;
|
|
1499
|
+
/**
|
|
1500
|
+
* Whether products must be explicitly linked/published to this storefront.
|
|
1501
|
+
*
|
|
1502
|
+
* @remarks
|
|
1503
|
+
* - Medusa: true (products must be linked to sales channel)
|
|
1504
|
+
* - Shopify: false (products visible by default unless unlisted)
|
|
1505
|
+
* - WooCommerce: false (no scoping concept)
|
|
1506
|
+
* - BigCommerce: false (products visible by default unless delisted)
|
|
1507
|
+
* - Spree: true (products must be assigned per store)
|
|
1508
|
+
* - Magento: true (products must be assigned per website)
|
|
1509
|
+
*/
|
|
1510
|
+
requiresProductScoping: boolean;
|
|
1511
|
+
/**
|
|
1512
|
+
* Primary currency code for this storefront.
|
|
1513
|
+
* Examples: "USD", "EUR", "GBP"
|
|
1514
|
+
*/
|
|
1515
|
+
currencyCode: string;
|
|
1516
|
+
/**
|
|
1517
|
+
* Optional region or locale code.
|
|
1518
|
+
* Examples: "US", "EU", "en-US", "es-ES"
|
|
1519
|
+
*/
|
|
1520
|
+
locale?: string;
|
|
1521
|
+
/**
|
|
1522
|
+
* Optional: Store/Channel metadata from platform.
|
|
1523
|
+
* @internal
|
|
1524
|
+
*/
|
|
1525
|
+
metadata?: Record<string, unknown>;
|
|
1526
|
+
}
|
|
1527
|
+
/**
|
|
1528
|
+
* Storefront validation error.
|
|
1529
|
+
* Thrown when storefront configuration is invalid or missing.
|
|
1530
|
+
*
|
|
1531
|
+
* @example
|
|
1532
|
+
* ```typescript
|
|
1533
|
+
* throw new StorefrontConfigError(
|
|
1534
|
+
* 'Medusa requires NEXT_PUBLIC_SALES_CHANNEL_ID',
|
|
1535
|
+
* 'medusa',
|
|
1536
|
+
* 'NEXT_PUBLIC_SALES_CHANNEL_ID',
|
|
1537
|
+
* );
|
|
1538
|
+
* ```
|
|
1539
|
+
*/
|
|
1540
|
+
declare class StorefrontConfigError extends Error {
|
|
1541
|
+
readonly platformType: string;
|
|
1542
|
+
readonly requiredEnvVar?: string;
|
|
1543
|
+
constructor(message: string, platformType: string, requiredEnvVar?: string);
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
/**
|
|
1547
|
+
* @thorprovider/types — Storefront Configuration
|
|
1548
|
+
*
|
|
1549
|
+
* Type definitions for per-channel storefront configuration
|
|
1550
|
+
* returned by the Thor Commerce backend plugin.
|
|
1551
|
+
*
|
|
1552
|
+
* Consumed by `CommerceProvider.getStorefrontConfig()` in L2 adapters.
|
|
1553
|
+
* Replaces legacy environment variables: NEXT_PUBLIC_ACCENT_COLOR,
|
|
1554
|
+
* NEXT_PUBLIC_LOGO_URL, NEXT_PUBLIC_CURRENCY_CODE.
|
|
1555
|
+
*
|
|
1556
|
+
* @module storefront-config
|
|
1557
|
+
*/
|
|
1558
|
+
/**
|
|
1559
|
+
* SEO default values for a storefront channel.
|
|
1560
|
+
*/
|
|
1561
|
+
interface StorefrontSeoDefaults {
|
|
1562
|
+
/** Default page title */
|
|
1563
|
+
title: string;
|
|
1564
|
+
/** Default meta description */
|
|
1565
|
+
description: string;
|
|
1566
|
+
/** Default Open Graph image URL */
|
|
1567
|
+
ogImage?: string;
|
|
1568
|
+
}
|
|
1569
|
+
/**
|
|
1570
|
+
* Per-channel storefront configuration.
|
|
1571
|
+
*
|
|
1572
|
+
* Returned by `GET /store/thor/config` (resolved via publishable API key).
|
|
1573
|
+
*
|
|
1574
|
+
* @example
|
|
1575
|
+
* ```typescript
|
|
1576
|
+
* const config = await commerce.getStorefrontConfig();
|
|
1577
|
+
* if (config) {
|
|
1578
|
+
* console.log(config.logoUrl, config.themeAccentColor);
|
|
1579
|
+
* }
|
|
1580
|
+
* ```
|
|
1581
|
+
*/
|
|
1582
|
+
interface StorefrontConfig {
|
|
1583
|
+
/** Unique identifier for this storefront config entry */
|
|
1584
|
+
id: string;
|
|
1585
|
+
/** Sales channel this config belongs to */
|
|
1586
|
+
salesChannelId: string;
|
|
1587
|
+
/** Theme accent color name (e.g., "indigo", "blue", "red") */
|
|
1588
|
+
themeAccentColor: string;
|
|
1589
|
+
/** Logo image URL */
|
|
1590
|
+
logoUrl: string;
|
|
1591
|
+
/** Default currency code (e.g., "EUR", "USD") */
|
|
1592
|
+
currencyCode: string;
|
|
1593
|
+
/** SEO default values */
|
|
1594
|
+
seoDefaults: StorefrontSeoDefaults;
|
|
1595
|
+
/** ISO 8601 creation timestamp */
|
|
1596
|
+
createdAt: string;
|
|
1597
|
+
/** ISO 8601 last update timestamp */
|
|
1598
|
+
updatedAt: string;
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
/**
|
|
1602
|
+
* @thorprovider/types — Site Designer Configuration
|
|
1603
|
+
*
|
|
1604
|
+
* Type definitions for the Site Designer feature.
|
|
1605
|
+
* Describes the visual theme, navigation, and identity configuration
|
|
1606
|
+
* managed through the admin Site Designer and served to storefronts
|
|
1607
|
+
* via `GET /store/thor/site-config`.
|
|
1608
|
+
*
|
|
1609
|
+
* These types are the source of truth (L1) so that both L2 adapters
|
|
1610
|
+
* and L3 components can depend on them without circular imports.
|
|
1611
|
+
*
|
|
1612
|
+
* @module designer-config
|
|
1613
|
+
*/
|
|
1614
|
+
/**
|
|
1615
|
+
* Available theme presets for the Site Designer.
|
|
1616
|
+
*/
|
|
1617
|
+
type DesignerThemePreset = 'electro' | 'midnight' | 'sunset' | 'forest' | 'custom';
|
|
1618
|
+
/**
|
|
1619
|
+
* Theme configuration managed by the Site Designer.
|
|
1620
|
+
*/
|
|
1621
|
+
interface DesignerThemeConfig {
|
|
1622
|
+
/** Active theme preset */
|
|
1623
|
+
preset: DesignerThemePreset;
|
|
1624
|
+
/** Accent color name (e.g., "indigo", "blue", "crimson") */
|
|
1625
|
+
accentColor: string;
|
|
1626
|
+
/** Gray scale family */
|
|
1627
|
+
grayColor: 'auto' | 'gray' | 'mauve' | 'slate' | 'sage' | 'olive' | 'sand';
|
|
1628
|
+
/** Border radius scale */
|
|
1629
|
+
radius: 'none' | 'small' | 'medium' | 'large' | 'full';
|
|
1630
|
+
/** Color scheme */
|
|
1631
|
+
appearance: 'light' | 'dark';
|
|
1632
|
+
/** UI scaling factor */
|
|
1633
|
+
scaling: '90%' | '95%' | '100%' | '105%' | '110%';
|
|
1634
|
+
}
|
|
1635
|
+
/**
|
|
1636
|
+
* A single navigation item in the Site Designer menu.
|
|
1637
|
+
*/
|
|
1638
|
+
interface DesignerNavItem {
|
|
1639
|
+
/** Unique identifier for this nav entry */
|
|
1640
|
+
id: string;
|
|
1641
|
+
/** Display label */
|
|
1642
|
+
label: string;
|
|
1643
|
+
/** Target URL or path */
|
|
1644
|
+
href: string;
|
|
1645
|
+
/** Whether this item is visible to storefront visitors */
|
|
1646
|
+
visible: boolean;
|
|
1647
|
+
}
|
|
1648
|
+
/**
|
|
1649
|
+
* A version history entry for the Site Designer config.
|
|
1650
|
+
*/
|
|
1651
|
+
interface DesignerHistoryEntry {
|
|
1652
|
+
/** Version identifier (typically ISO 8601 timestamp) */
|
|
1653
|
+
version: string;
|
|
1654
|
+
/** ISO 8601 timestamp of when this version was created */
|
|
1655
|
+
createdAt: string;
|
|
1656
|
+
}
|
|
1657
|
+
/**
|
|
1658
|
+
* Complete Site Designer configuration.
|
|
1659
|
+
*
|
|
1660
|
+
* Persisted per sales channel in the backend and served to the
|
|
1661
|
+
* storefront via `GET /store/thor/site-config`.
|
|
1662
|
+
*
|
|
1663
|
+
* @example
|
|
1664
|
+
* ```typescript
|
|
1665
|
+
* const result = await commerce.getDesignerConfig();
|
|
1666
|
+
* if (result) {
|
|
1667
|
+
* const { config } = result;
|
|
1668
|
+
* console.log(config.theme.preset, config.siteName);
|
|
1669
|
+
* }
|
|
1670
|
+
* ```
|
|
1671
|
+
*/
|
|
1672
|
+
interface DesignerConfig {
|
|
1673
|
+
/** Theme visual settings */
|
|
1674
|
+
theme: DesignerThemeConfig;
|
|
1675
|
+
/** Navigation menu items */
|
|
1676
|
+
navigation: DesignerNavItem[];
|
|
1677
|
+
/** Storefront display name */
|
|
1678
|
+
siteName: string;
|
|
1679
|
+
/** Storefront description */
|
|
1680
|
+
siteDescription: string;
|
|
1681
|
+
/** Logo URL (optional, overrides StorefrontConfig.logoUrl) */
|
|
1682
|
+
logo?: string;
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
/**
|
|
1686
|
+
* @fileoverview Authentication types for Thor Commerce adapters
|
|
1687
|
+
* @module @thorprovider/adapters/types/auth
|
|
1688
|
+
*
|
|
1689
|
+
* Framework-agnostic authentication types that work across all commerce providers.
|
|
1690
|
+
* Follows Thor Commerce principles: decoupling, agnostic configuration.
|
|
1691
|
+
*/
|
|
1692
|
+
|
|
1693
|
+
/**
|
|
1694
|
+
* Authentication method configuration
|
|
1695
|
+
*/
|
|
1696
|
+
type AuthMethod = 'jwt' | 'session';
|
|
1697
|
+
/**
|
|
1698
|
+
* Authentication storage strategy
|
|
1699
|
+
*/
|
|
1700
|
+
type AuthStorage = 'cookie' | 'localStorage' | 'sessionStorage' | 'memory';
|
|
1701
|
+
/**
|
|
1702
|
+
* Authentication configuration
|
|
1703
|
+
*/
|
|
1704
|
+
interface AuthConfig {
|
|
1705
|
+
/**
|
|
1706
|
+
* Authentication method to use
|
|
1707
|
+
* - 'jwt': JWT token in Authorization header (good for mobile, SPAs)
|
|
1708
|
+
* - 'session': Cookie-based session (good for server-side rendering)
|
|
1709
|
+
*/
|
|
1710
|
+
method: AuthMethod;
|
|
1711
|
+
/**
|
|
1712
|
+
* Where to store authentication tokens/session
|
|
1713
|
+
* - 'cookie': Browser cookies (automatic with fetch)
|
|
1714
|
+
* - 'localStorage': Browser localStorage (manual management)
|
|
1715
|
+
* - 'sessionStorage': Browser sessionStorage (clears on tab close)
|
|
1716
|
+
* - 'memory': In-memory only (for server-side or testing)
|
|
1717
|
+
*/
|
|
1718
|
+
storage: AuthStorage;
|
|
1719
|
+
/**
|
|
1720
|
+
* Custom storage implementation (optional)
|
|
1721
|
+
* Useful for React Native or non-browser environments
|
|
1722
|
+
*/
|
|
1723
|
+
customStorage?: {
|
|
1724
|
+
getItem: (key: string) => Promise<string | null> | string | null;
|
|
1725
|
+
setItem: (key: string, value: string) => Promise<void> | void;
|
|
1726
|
+
removeItem: (key: string) => Promise<void> | void;
|
|
1727
|
+
};
|
|
1728
|
+
}
|
|
1729
|
+
/**
|
|
1730
|
+
* Login credentials for email/password authentication
|
|
1731
|
+
*/
|
|
1732
|
+
interface LoginCredentials {
|
|
1733
|
+
email: string;
|
|
1734
|
+
password: string;
|
|
1735
|
+
}
|
|
1736
|
+
/**
|
|
1737
|
+
* Registration data for new customer
|
|
1738
|
+
*/
|
|
1739
|
+
interface RegisterData {
|
|
1740
|
+
email: string;
|
|
1741
|
+
password: string;
|
|
1742
|
+
first_name: string;
|
|
1743
|
+
last_name: string;
|
|
1744
|
+
phone?: string;
|
|
1745
|
+
}
|
|
1746
|
+
/**
|
|
1747
|
+
* Authentication response from login/register
|
|
1748
|
+
*/
|
|
1749
|
+
interface AuthResponse {
|
|
1750
|
+
/**
|
|
1751
|
+
* JWT token (if using JWT authentication)
|
|
1752
|
+
*/
|
|
1753
|
+
token?: string;
|
|
1754
|
+
/**
|
|
1755
|
+
* Customer object (if registration was successful)
|
|
1756
|
+
*/
|
|
1757
|
+
customer?: Customer;
|
|
1758
|
+
/**
|
|
1759
|
+
* Whether authentication requires additional steps (e.g., OAuth)
|
|
1760
|
+
*/
|
|
1761
|
+
requiresAction?: boolean;
|
|
1762
|
+
/**
|
|
1763
|
+
* Redirect URL for OAuth flows
|
|
1764
|
+
*/
|
|
1765
|
+
redirectUrl?: string;
|
|
1766
|
+
}
|
|
1767
|
+
/**
|
|
1768
|
+
* Authentication response (used internally by providers)
|
|
1769
|
+
*/
|
|
1770
|
+
interface AuthResponse {
|
|
1771
|
+
customer?: Customer;
|
|
1772
|
+
token?: string;
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1775
|
+
/**
|
|
1776
|
+
* Update customer data
|
|
1777
|
+
*/
|
|
1778
|
+
interface UpdateCustomerData {
|
|
1779
|
+
first_name?: string;
|
|
1780
|
+
last_name?: string;
|
|
1781
|
+
phone?: string | null;
|
|
1782
|
+
email?: string;
|
|
1783
|
+
password?: string;
|
|
1784
|
+
metadata?: Record<string, unknown>;
|
|
1785
|
+
}
|
|
1786
|
+
/**
|
|
1787
|
+
* Create address data (camelCase for universal compatibility)
|
|
1788
|
+
*/
|
|
1789
|
+
interface CreateAddressData {
|
|
1790
|
+
firstName: string;
|
|
1791
|
+
lastName: string;
|
|
1792
|
+
company?: string;
|
|
1793
|
+
address1: string;
|
|
1794
|
+
address2?: string;
|
|
1795
|
+
city: string;
|
|
1796
|
+
province?: string;
|
|
1797
|
+
postalCode: string;
|
|
1798
|
+
countryCode: string;
|
|
1799
|
+
phone?: string;
|
|
1800
|
+
metadata?: Record<string, unknown>;
|
|
1801
|
+
}
|
|
1802
|
+
/**
|
|
1803
|
+
* Password reset request
|
|
1804
|
+
*/
|
|
1805
|
+
interface PasswordResetRequest {
|
|
1806
|
+
email: string;
|
|
1807
|
+
}
|
|
1808
|
+
/**
|
|
1809
|
+
* Password reset confirmation
|
|
1810
|
+
*/
|
|
1811
|
+
interface PasswordResetConfirm {
|
|
1812
|
+
token: string;
|
|
1813
|
+
password: string;
|
|
1814
|
+
}
|
|
1815
|
+
/**
|
|
1816
|
+
* Authentication provider interface
|
|
1817
|
+
*
|
|
1818
|
+
* All commerce providers must implement this interface to support authentication.
|
|
1819
|
+
* This enables framework-agnostic auth across Medusa, Shopify, WooCommerce, etc.
|
|
1820
|
+
*/
|
|
1821
|
+
interface AuthProvider {
|
|
1822
|
+
/**
|
|
1823
|
+
* Login customer with email and password
|
|
1824
|
+
* @param credentials - Email and password
|
|
1825
|
+
* @returns Authentication response with token/customer
|
|
1826
|
+
*/
|
|
1827
|
+
login(credentials: LoginCredentials): Promise<AuthResponse>;
|
|
1828
|
+
/**
|
|
1829
|
+
* Register new customer
|
|
1830
|
+
* @param data - Registration data
|
|
1831
|
+
* @returns Authentication response
|
|
1832
|
+
*/
|
|
1833
|
+
register(data: RegisterData): Promise<AuthResponse>;
|
|
1834
|
+
/**
|
|
1835
|
+
* Logout current customer
|
|
1836
|
+
* Clears authentication token/session
|
|
1837
|
+
*/
|
|
1838
|
+
logout(): Promise<void>;
|
|
1839
|
+
/**
|
|
1840
|
+
* Request password reset email
|
|
1841
|
+
* @param email - Customer email
|
|
1842
|
+
*/
|
|
1843
|
+
requestPasswordReset(email: string): Promise<void>;
|
|
1844
|
+
/**
|
|
1845
|
+
* Reset password with token
|
|
1846
|
+
* @param token - Password reset token from email (provider-specific format)
|
|
1847
|
+
* @param password - New password
|
|
1848
|
+
* @param metadata - Optional metadata for provider-specific requirements
|
|
1849
|
+
*/
|
|
1850
|
+
resetPassword(token: string, password: string, metadata?: Record<string, unknown>): Promise<void>;
|
|
1851
|
+
/**
|
|
1852
|
+
* Get current authenticated customer
|
|
1853
|
+
* @returns Customer object or null if not authenticated
|
|
1854
|
+
*/
|
|
1855
|
+
getCurrentCustomer(): Promise<Customer | null>;
|
|
1856
|
+
/**
|
|
1857
|
+
* Update current customer profile
|
|
1858
|
+
* @param data - Fields to update
|
|
1859
|
+
* @returns Updated customer
|
|
1860
|
+
*/
|
|
1861
|
+
updateCustomer(data: UpdateCustomerData): Promise<Customer>;
|
|
1862
|
+
/**
|
|
1863
|
+
* Check if customer is authenticated
|
|
1864
|
+
* @returns true if authenticated, false otherwise
|
|
1865
|
+
*/
|
|
1866
|
+
isAuthenticated(): Promise<boolean>;
|
|
1867
|
+
/**
|
|
1868
|
+
* Get current authentication token (if using JWT)
|
|
1869
|
+
* @returns JWT token or null
|
|
1870
|
+
*/
|
|
1871
|
+
getAuthToken(): string | null;
|
|
1872
|
+
/**
|
|
1873
|
+
* Delete current customer account
|
|
1874
|
+
*
|
|
1875
|
+
* WARNING: This is a permanent action and cannot be undone.
|
|
1876
|
+
* Only implemented if capabilities.deleteAccount is true.
|
|
1877
|
+
*/
|
|
1878
|
+
deleteCustomerAccount(): Promise<void>;
|
|
1879
|
+
/**
|
|
1880
|
+
* Get customer addresses
|
|
1881
|
+
* @returns List of customer addresses
|
|
1882
|
+
*/
|
|
1883
|
+
getAddresses(): Promise<Address[]>;
|
|
1884
|
+
/**
|
|
1885
|
+
* Create new address for current customer
|
|
1886
|
+
* @param data - Address data
|
|
1887
|
+
* @returns Created address
|
|
1888
|
+
*/
|
|
1889
|
+
createAddress(data: CreateAddressData): Promise<Address>;
|
|
1890
|
+
/**
|
|
1891
|
+
* Update customer address
|
|
1892
|
+
* @param addressId - Address ID
|
|
1893
|
+
* @param data - Fields to update
|
|
1894
|
+
* @returns Updated address
|
|
1895
|
+
*/
|
|
1896
|
+
updateAddress(addressId: string, data: Partial<CreateAddressData>): Promise<Address>;
|
|
1897
|
+
/**
|
|
1898
|
+
* Delete customer address
|
|
1899
|
+
* @param addressId - Address ID
|
|
1900
|
+
*/
|
|
1901
|
+
deleteAddress(addressId: string): Promise<void>;
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
/**
|
|
1905
|
+
* @thorprovider/adapters v2.0
|
|
1906
|
+
* Payment Types - Unified payment method interface
|
|
1907
|
+
*
|
|
1908
|
+
* Provides backend-agnostic types for payment methods and providers.
|
|
1909
|
+
* Each backend transforms its payment providers to this common format.
|
|
1910
|
+
*
|
|
1911
|
+
* @see packages/adapters/PAYMENT_METHODS_ARCHITECTURE.md
|
|
1912
|
+
*/
|
|
1913
|
+
/**
|
|
1914
|
+
* Payment method type identifier
|
|
1915
|
+
* Normalized across all backends
|
|
1916
|
+
*
|
|
1917
|
+
* @example
|
|
1918
|
+
* ```typescript
|
|
1919
|
+
* // Medusa transforms:
|
|
1920
|
+
* 'pp_stripe_stripe' → type: 'card'
|
|
1921
|
+
* 'pp_paypal_paypal' → type: 'wallet'
|
|
1922
|
+
* 'pp_system_default' → type: 'cash_on_delivery'
|
|
1923
|
+
* ```
|
|
1924
|
+
*/
|
|
1925
|
+
type PaymentMethodType = 'card' | 'wallet' | 'bank_transfer' | 'buy_now_pay_later' | 'cash_on_delivery' | 'crypto' | 'other';
|
|
1926
|
+
/**
|
|
1927
|
+
* Payment method features and capabilities
|
|
1928
|
+
* Describes what a payment method supports
|
|
1929
|
+
*/
|
|
1930
|
+
interface PaymentMethodFeatures {
|
|
1931
|
+
/**
|
|
1932
|
+
* Supports saving payment method for future use
|
|
1933
|
+
*
|
|
1934
|
+
* Example: Stripe allows saving cards, PayPal allows vaulting
|
|
1935
|
+
*/
|
|
1936
|
+
saveForLater?: boolean;
|
|
1937
|
+
/**
|
|
1938
|
+
* Requires 3D Secure authentication
|
|
1939
|
+
*
|
|
1940
|
+
* Important for SCA compliance in EU
|
|
1941
|
+
*/
|
|
1942
|
+
requires3DS?: boolean;
|
|
1943
|
+
/**
|
|
1944
|
+
* Supports refunds
|
|
1945
|
+
*
|
|
1946
|
+
* Some methods like COD may not support automatic refunds
|
|
1947
|
+
*/
|
|
1948
|
+
supportsRefunds?: boolean;
|
|
1949
|
+
/**
|
|
1950
|
+
* Minimum transaction amount (in smallest currency unit, e.g., cents)
|
|
1951
|
+
*
|
|
1952
|
+
* Example: Stripe has minimum amounts per currency
|
|
1953
|
+
*/
|
|
1954
|
+
minAmount?: number;
|
|
1955
|
+
/**
|
|
1956
|
+
* Maximum transaction amount (in smallest currency unit, e.g., cents)
|
|
1957
|
+
*
|
|
1958
|
+
* Example: Some BNPL providers have maximum limits
|
|
1959
|
+
*/
|
|
1960
|
+
maxAmount?: number;
|
|
1961
|
+
/**
|
|
1962
|
+
* Supported currencies (ISO 4217 codes)
|
|
1963
|
+
*
|
|
1964
|
+
* If undefined, assumes all currencies supported
|
|
1965
|
+
*/
|
|
1966
|
+
supportedCurrencies?: string[];
|
|
1967
|
+
/**
|
|
1968
|
+
* Requires additional customer verification
|
|
1969
|
+
*
|
|
1970
|
+
* Example: Bank transfers may require identity verification
|
|
1971
|
+
*/
|
|
1972
|
+
requiresVerification?: boolean;
|
|
1973
|
+
}
|
|
1974
|
+
/**
|
|
1975
|
+
* Payment method information
|
|
1976
|
+
* Backend-agnostic representation of a payment provider
|
|
1977
|
+
*
|
|
1978
|
+
* This is the normalized format that all backends transform their
|
|
1979
|
+
* payment providers into, allowing the storefront to work with
|
|
1980
|
+
* any backend without knowing provider-specific details.
|
|
1981
|
+
*
|
|
1982
|
+
* @example
|
|
1983
|
+
* ```typescript
|
|
1984
|
+
* // Medusa Stripe provider:
|
|
1985
|
+
* {
|
|
1986
|
+
* id: 'pp_stripe_stripe',
|
|
1987
|
+
* name: 'Stripe',
|
|
1988
|
+
* type: 'card',
|
|
1989
|
+
* isEnabled: true,
|
|
1990
|
+
* requiresSetup: true,
|
|
1991
|
+
* features: {
|
|
1992
|
+
* saveForLater: true,
|
|
1993
|
+
* requires3DS: true,
|
|
1994
|
+
* supportsRefunds: true
|
|
1995
|
+
* }
|
|
1996
|
+
* }
|
|
1997
|
+
* ```
|
|
1998
|
+
*/
|
|
1999
|
+
interface PaymentMethod {
|
|
2000
|
+
/**
|
|
2001
|
+
* Unique identifier from backend
|
|
2002
|
+
*
|
|
2003
|
+
* Format varies by backend:
|
|
2004
|
+
* - Medusa: "pp_stripe_stripe", "pp_paypal_paypal", "pp_system_default"
|
|
2005
|
+
* - Shopify: "shopify_payments", "paypal_express"
|
|
2006
|
+
* - WooCommerce: "stripe", "paypal", "cod"
|
|
2007
|
+
*/
|
|
2008
|
+
id: string;
|
|
2009
|
+
/**
|
|
2010
|
+
* Display name for UI
|
|
2011
|
+
*
|
|
2012
|
+
* Human-readable name shown to customers
|
|
2013
|
+
* Example: "Credit Card", "PayPal", "Cash on Delivery"
|
|
2014
|
+
*/
|
|
2015
|
+
name: string;
|
|
2016
|
+
/**
|
|
2017
|
+
* Payment method type (normalized)
|
|
2018
|
+
*
|
|
2019
|
+
* Used for categorization and UI rendering
|
|
2020
|
+
*/
|
|
2021
|
+
type: PaymentMethodType;
|
|
2022
|
+
/**
|
|
2023
|
+
* Whether this provider is currently enabled
|
|
2024
|
+
*
|
|
2025
|
+
* Backend administrators control this setting
|
|
2026
|
+
*/
|
|
2027
|
+
isEnabled: boolean;
|
|
2028
|
+
/**
|
|
2029
|
+
* Whether this provider requires additional setup
|
|
2030
|
+
*
|
|
2031
|
+
* Examples:
|
|
2032
|
+
* - Card payments: requires entering card details
|
|
2033
|
+
* - Wallets: requires authorizing wallet connection
|
|
2034
|
+
* - COD: no setup required (false)
|
|
2035
|
+
*/
|
|
2036
|
+
requiresSetup: boolean;
|
|
2037
|
+
/**
|
|
2038
|
+
* Optional description for display
|
|
2039
|
+
*
|
|
2040
|
+
* Additional information shown to customer
|
|
2041
|
+
*/
|
|
2042
|
+
description?: string;
|
|
2043
|
+
/**
|
|
2044
|
+
* Metadata from backend (provider-specific)
|
|
2045
|
+
*
|
|
2046
|
+
* Contains original backend data for advanced use cases
|
|
2047
|
+
* Structure varies by backend
|
|
2048
|
+
*/
|
|
2049
|
+
metadata?: Record<string, unknown>;
|
|
2050
|
+
/**
|
|
2051
|
+
* Supported features and capabilities
|
|
2052
|
+
*/
|
|
2053
|
+
features?: PaymentMethodFeatures;
|
|
2054
|
+
/**
|
|
2055
|
+
* Logo URL or icon identifier
|
|
2056
|
+
*
|
|
2057
|
+
* Optional visual representation
|
|
2058
|
+
*/
|
|
2059
|
+
logo?: string;
|
|
2060
|
+
}
|
|
2061
|
+
/**
|
|
2062
|
+
* Payment methods query options
|
|
2063
|
+
*
|
|
2064
|
+
* Used to filter/query available payment methods
|
|
2065
|
+
* Different backends support different filters
|
|
2066
|
+
*/
|
|
2067
|
+
interface PaymentMethodsOptions {
|
|
2068
|
+
/**
|
|
2069
|
+
* Region ID (for backends that support regional payments)
|
|
2070
|
+
*
|
|
2071
|
+
* Example: Medusa requires region_id
|
|
2072
|
+
* Required for: Medusa
|
|
2073
|
+
* Optional for: Shopify (global), WooCommerce (may use)
|
|
2074
|
+
*/
|
|
2075
|
+
regionId?: string;
|
|
2076
|
+
/**
|
|
2077
|
+
* Cart ID (for cart-specific payment methods)
|
|
2078
|
+
*
|
|
2079
|
+
* Some backends determine available methods based on cart contents
|
|
2080
|
+
* Example: Certain methods only for high-value carts
|
|
2081
|
+
*/
|
|
2082
|
+
cartId?: string;
|
|
2083
|
+
/**
|
|
2084
|
+
* Currency code filter (ISO 4217)
|
|
2085
|
+
*
|
|
2086
|
+
* Filter methods that support this currency
|
|
2087
|
+
* Example: 'USD', 'EUR', 'GBP'
|
|
2088
|
+
*/
|
|
2089
|
+
currencyCode?: string;
|
|
2090
|
+
/**
|
|
2091
|
+
* Filter by enabled status
|
|
2092
|
+
*
|
|
2093
|
+
* If true, only return enabled payment methods
|
|
2094
|
+
* Default: true (recommended for checkout)
|
|
2095
|
+
*/
|
|
2096
|
+
enabledOnly?: boolean;
|
|
2097
|
+
/**
|
|
2098
|
+
* Force refresh from backend (ignore cache)
|
|
2099
|
+
*
|
|
2100
|
+
* Set to true to bypass client-side cache
|
|
2101
|
+
* Default: false
|
|
2102
|
+
*/
|
|
2103
|
+
forceRefresh?: boolean;
|
|
2104
|
+
}
|
|
2105
|
+
/**
|
|
2106
|
+
* Cached payment methods data
|
|
2107
|
+
*
|
|
2108
|
+
* Used for client-side caching with TTL
|
|
2109
|
+
*/
|
|
2110
|
+
interface CachedPaymentMethods {
|
|
2111
|
+
/**
|
|
2112
|
+
* Cache key (stringified options)
|
|
2113
|
+
*/
|
|
2114
|
+
key: string;
|
|
2115
|
+
/**
|
|
2116
|
+
* Cached payment methods
|
|
2117
|
+
*/
|
|
2118
|
+
methods: PaymentMethod[];
|
|
2119
|
+
/**
|
|
2120
|
+
* Timestamp when cached (milliseconds since epoch)
|
|
2121
|
+
*/
|
|
2122
|
+
cachedAt: number;
|
|
2123
|
+
/**
|
|
2124
|
+
* Time-to-live in milliseconds
|
|
2125
|
+
*
|
|
2126
|
+
* Default: 5 minutes (300000ms)
|
|
2127
|
+
*/
|
|
2128
|
+
ttl: number;
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
/**
|
|
2132
|
+
* Backend capabilities interface
|
|
2133
|
+
*
|
|
2134
|
+
* Defines what operations a backend commerce platform supports.
|
|
2135
|
+
* Each capability is a boolean flag indicating support.
|
|
2136
|
+
*
|
|
2137
|
+
* This enables adaptive UI that adjusts based on backend capabilities.
|
|
2138
|
+
*
|
|
2139
|
+
* @example
|
|
2140
|
+
* ```typescript
|
|
2141
|
+
* const { capabilities } = useCommerce();
|
|
2142
|
+
*
|
|
2143
|
+
* // Adaptive UI based on backend capabilities
|
|
2144
|
+
* if (capabilities.updateEmail) {
|
|
2145
|
+
* return <EmailField />;
|
|
2146
|
+
* } else {
|
|
2147
|
+
* return <EmailField disabled />;
|
|
2148
|
+
* }
|
|
2149
|
+
* ```
|
|
2150
|
+
*/
|
|
2151
|
+
interface BackendCapabilities {
|
|
2152
|
+
/**
|
|
2153
|
+
* Profile Management Capabilities
|
|
2154
|
+
*/
|
|
2155
|
+
/** Can update customer profile (name, phone) */
|
|
2156
|
+
updateProfile: boolean;
|
|
2157
|
+
/** Can update customer email address */
|
|
2158
|
+
updateEmail: boolean;
|
|
2159
|
+
/** Can change password directly (current + new password) */
|
|
2160
|
+
changePasswordDirect: boolean;
|
|
2161
|
+
/** Can request password reset via email */
|
|
2162
|
+
changePasswordViaEmail: boolean;
|
|
2163
|
+
/** Can delete customer account (self-service) */
|
|
2164
|
+
deleteAccount: boolean;
|
|
2165
|
+
/**
|
|
2166
|
+
* Avatar/Profile Picture Capabilities
|
|
2167
|
+
*/
|
|
2168
|
+
/** Has native avatar/profile picture upload API */
|
|
2169
|
+
uploadAvatar: boolean;
|
|
2170
|
+
/** Can store avatar URL in customer metadata/attributes */
|
|
2171
|
+
avatarViaMetadata: boolean;
|
|
2172
|
+
/**
|
|
2173
|
+
* Custom Attributes/Metadata Capabilities
|
|
2174
|
+
*/
|
|
2175
|
+
/** Supports custom customer attributes/metadata */
|
|
2176
|
+
customAttributes: boolean;
|
|
2177
|
+
/**
|
|
2178
|
+
* Order Management Capabilities
|
|
2179
|
+
*/
|
|
2180
|
+
/** Can fetch customer order history */
|
|
2181
|
+
fetchOrders: boolean;
|
|
2182
|
+
/** Can cancel orders (before fulfillment) */
|
|
2183
|
+
cancelOrder: boolean;
|
|
2184
|
+
/**
|
|
2185
|
+
* Address Management Capabilities
|
|
2186
|
+
*/
|
|
2187
|
+
/** Can add/update/delete shipping addresses */
|
|
2188
|
+
manageAddresses: boolean;
|
|
2189
|
+
/** Can set default shipping address */
|
|
2190
|
+
defaultAddress: boolean;
|
|
2191
|
+
/**
|
|
2192
|
+
* Cart/Checkout Capabilities
|
|
2193
|
+
*/
|
|
2194
|
+
/** Can apply discount codes to cart */
|
|
2195
|
+
applyDiscounts: boolean;
|
|
2196
|
+
/** Can calculate shipping rates before checkout */
|
|
2197
|
+
shippingCalculation: boolean;
|
|
2198
|
+
/**
|
|
2199
|
+
* Payment/Checkout Capabilities
|
|
2200
|
+
*/
|
|
2201
|
+
/** Supports guest checkout (no account required) */
|
|
2202
|
+
guestCheckout: boolean;
|
|
2203
|
+
/** Can save payment methods for future use */
|
|
2204
|
+
savedPaymentMethods: boolean;
|
|
2205
|
+
/** Can list available payment providers dynamically */
|
|
2206
|
+
listPaymentProviders: boolean;
|
|
2207
|
+
/** Payment providers are region-specific */
|
|
2208
|
+
regionSpecificPayments: boolean;
|
|
2209
|
+
/**
|
|
2210
|
+
* Wishlist/Favorites Capabilities
|
|
2211
|
+
*/
|
|
2212
|
+
/** Has native wishlist/favorites feature */
|
|
2213
|
+
wishlist: boolean;
|
|
2214
|
+
/**
|
|
2215
|
+
* Search/Filter Capabilities
|
|
2216
|
+
*/
|
|
2217
|
+
/** Supports advanced product search (full-text, filters) */
|
|
2218
|
+
advancedSearch: boolean;
|
|
2219
|
+
/** Supports faceted filtering (by attributes) */
|
|
2220
|
+
facetedFilters: boolean;
|
|
2221
|
+
/**
|
|
2222
|
+
* Review/Rating Capabilities
|
|
2223
|
+
*/
|
|
2224
|
+
/** Has native product reviews/ratings system */
|
|
2225
|
+
productReviews: boolean;
|
|
2226
|
+
/**
|
|
2227
|
+
* Loyalty/Rewards Capabilities
|
|
2228
|
+
*/
|
|
2229
|
+
/** Has native loyalty/rewards program */
|
|
2230
|
+
loyaltyProgram: boolean;
|
|
2231
|
+
}
|
|
2232
|
+
/**
|
|
2233
|
+
* Main provider interface that all commerce providers must implement
|
|
2234
|
+
*
|
|
2235
|
+
* This interface defines a unified API for interacting with different
|
|
2236
|
+
* e-commerce platforms (Medusa, Shopify, WooCommerce, etc.)
|
|
2237
|
+
*
|
|
2238
|
+
* @thorprovider/adapters (L2) implements this interface
|
|
2239
|
+
* @thorprovider/components (L3) depends on this abstraction
|
|
2240
|
+
*/
|
|
2241
|
+
interface CommerceProvider {
|
|
2242
|
+
/**
|
|
2243
|
+
* Provider metadata
|
|
2244
|
+
*/
|
|
2245
|
+
readonly name: string;
|
|
2246
|
+
readonly version: string;
|
|
2247
|
+
/**
|
|
2248
|
+
* Backend capabilities
|
|
2249
|
+
*
|
|
2250
|
+
* Defines what operations this backend supports.
|
|
2251
|
+
* Used for adaptive UI that adjusts based on platform features.
|
|
2252
|
+
*
|
|
2253
|
+
* @example
|
|
2254
|
+
* ```typescript
|
|
2255
|
+
* const { capabilities } = useCommerce();
|
|
2256
|
+
*
|
|
2257
|
+
* if (capabilities.updateEmail) {
|
|
2258
|
+
* return <EmailField />;
|
|
2259
|
+
* } else {
|
|
2260
|
+
* return <EmailField disabled />;
|
|
2261
|
+
* }
|
|
2262
|
+
* ```
|
|
2263
|
+
*/
|
|
2264
|
+
readonly capabilities: BackendCapabilities;
|
|
2265
|
+
/**
|
|
2266
|
+
* Authentication provider
|
|
2267
|
+
*
|
|
2268
|
+
* Available if the backend supports authentication and is configured.
|
|
2269
|
+
*/
|
|
2270
|
+
readonly auth?: AuthProvider;
|
|
2271
|
+
/**
|
|
2272
|
+
* Get a single product by handle/slug
|
|
2273
|
+
* @param handle - Product handle (slug)
|
|
2274
|
+
* @param options - Query options (e.g., regionId)
|
|
2275
|
+
* @returns Product or undefined if not found
|
|
2276
|
+
*/
|
|
2277
|
+
getProduct(handle: string, options?: {
|
|
2278
|
+
regionId?: string;
|
|
2279
|
+
}): Promise<Product | undefined>;
|
|
2280
|
+
/**
|
|
2281
|
+
* Get multiple products with optional filtering and sorting
|
|
2282
|
+
* @param options - Query options (search, sort, pagination)
|
|
2283
|
+
* @returns Array of products
|
|
2284
|
+
*/
|
|
2285
|
+
getProducts(options?: GetProductsOptions): Promise<Product[]>;
|
|
2286
|
+
/**
|
|
2287
|
+
* Get product recommendations for a given product
|
|
2288
|
+
* @param productId - Product ID
|
|
2289
|
+
* @returns Array of recommended products
|
|
2290
|
+
*/
|
|
2291
|
+
getProductRecommendations(productId: string): Promise<Product[]>;
|
|
2292
|
+
/**
|
|
2293
|
+
* Advanced product search with filtering (OPTIONAL)
|
|
2294
|
+
*
|
|
2295
|
+
* Performs enhanced product search using backend-specific search engines
|
|
2296
|
+
* (e.g., MeiliSearch, Algolia, Elasticsearch) with advanced filtering:
|
|
2297
|
+
* - Price range filtering
|
|
2298
|
+
* - Stock availability
|
|
2299
|
+
* - Custom product attributes (category-specific)
|
|
2300
|
+
* - Faceted search with metadata
|
|
2301
|
+
*
|
|
2302
|
+
* **Check `capabilities.advancedSearch` before calling.**
|
|
2303
|
+
* Falls back to getProducts() if not supported.
|
|
2304
|
+
*
|
|
2305
|
+
* Only available if backend supports advanced search endpoint.
|
|
2306
|
+
* Backends without this capability should NOT implement this method.
|
|
2307
|
+
*
|
|
2308
|
+
* @param options - Advanced search options with filters
|
|
2309
|
+
* @returns Products matching criteria with search metadata
|
|
2310
|
+
*
|
|
2311
|
+
* @example
|
|
2312
|
+
* ```typescript
|
|
2313
|
+
* // Check capability first
|
|
2314
|
+
* if (!commerce.capabilities.advancedSearch || !commerce.searchProductsAdvanced) {
|
|
2315
|
+
* // Fallback to basic search
|
|
2316
|
+
* const products = await commerce.getProducts({ query: 'laptop' });
|
|
2317
|
+
* return { products, meta: { limit: 20, offset: 0 } };
|
|
2318
|
+
* }
|
|
2319
|
+
*
|
|
2320
|
+
* // Use advanced search
|
|
2321
|
+
* const result = await commerce.searchProductsAdvanced({
|
|
2322
|
+
* query: 'gaming laptop',
|
|
2323
|
+
* categoryIds: ['cat_electronics'],
|
|
2324
|
+
* priceMin: 500,
|
|
2325
|
+
* priceMax: 1500,
|
|
2326
|
+
* currencyCode: 'EUR',
|
|
2327
|
+
* inStockOnly: true,
|
|
2328
|
+
* attributes: [
|
|
2329
|
+
* { id: 'att_ram', values: ['att_val_16gb', 'att_val_32gb'] },
|
|
2330
|
+
* { id: 'att_brand', values: ['att_val_dell'] }
|
|
2331
|
+
* ],
|
|
2332
|
+
* includeVariants: true,
|
|
2333
|
+
* regionId: 'reg_europe',
|
|
2334
|
+
* first: 20,
|
|
2335
|
+
* after: 0
|
|
2336
|
+
* });
|
|
2337
|
+
*
|
|
2338
|
+
* console.log(`Found ${result.meta?.total} products`);
|
|
2339
|
+
* console.log(`Search took ${result.meta?.processingTimeMs}ms`);
|
|
2340
|
+
* console.log(`Hybrid search: ${result.meta?.hybridSearchUsed}`);
|
|
2341
|
+
*
|
|
2342
|
+
* result.products.forEach(product => {
|
|
2343
|
+
* console.log(product.title, product.priceRange);
|
|
2344
|
+
* if (product.variants) {
|
|
2345
|
+
* product.variants.forEach(v => console.log(' -', v.title, v.price));
|
|
2346
|
+
* }
|
|
2347
|
+
* });
|
|
2348
|
+
* ```
|
|
2349
|
+
*
|
|
2350
|
+
* @throws {ProviderAPIError} If backend search service fails
|
|
2351
|
+
* @throws {Error} If required parameters missing (e.g., regionId for price filtering)
|
|
2352
|
+
*
|
|
2353
|
+
* @see AdvancedSearchProductsOptions for all available filter options
|
|
2354
|
+
* @see SearchResultMeta for metadata structure
|
|
2355
|
+
* @see BackendCapabilities.advancedSearch to check if supported
|
|
2356
|
+
*/
|
|
2357
|
+
searchProductsAdvanced?(options?: AdvancedSearchProductsOptions): Promise<{
|
|
2358
|
+
products: Product[];
|
|
2359
|
+
meta?: SearchResultMeta;
|
|
2360
|
+
}>;
|
|
2361
|
+
/**
|
|
2362
|
+
* Get available filter options for product filtering (OPTIONAL)
|
|
2363
|
+
*
|
|
2364
|
+
* Returns dynamic filter configuration based on:
|
|
2365
|
+
* - Backend capabilities (basic vs advanced filters)
|
|
2366
|
+
* - Category context (category-specific custom attributes)
|
|
2367
|
+
* - Current product set (facet counts if supported)
|
|
2368
|
+
*
|
|
2369
|
+
* Enables building adaptive filter UI that shows only relevant filters
|
|
2370
|
+
* for the current context. For example:
|
|
2371
|
+
* - Electronics category: RAM, Storage, Brand filters
|
|
2372
|
+
* - Clothing category: Size, Color, Material filters
|
|
2373
|
+
* - No category: Only basic filters (price, availability)
|
|
2374
|
+
*
|
|
2375
|
+
* **Check `capabilities.facetedFilters` before calling.**
|
|
2376
|
+
* Returns empty array if not supported.
|
|
2377
|
+
*
|
|
2378
|
+
* @param options - Filter query options
|
|
2379
|
+
* @param options.categoryId - Optional category ID for category-specific attributes
|
|
2380
|
+
* @param options.useAdvancedSearch - Enable advanced filters (price, stock, attributes)
|
|
2381
|
+
* @param options.includeBasicFilters - Include basic filters (categories, collections)
|
|
2382
|
+
* @param options.includeFacetCounts - Include product counts per filter value (e.g., "Red (23)")
|
|
2383
|
+
* @returns Array of filter configurations sorted by ranking
|
|
2384
|
+
*
|
|
2385
|
+
* @example
|
|
2386
|
+
* ```typescript
|
|
2387
|
+
* // Get filters for electronics category
|
|
2388
|
+
* const filters = await commerce.getAvailableFilters({
|
|
2389
|
+
* categoryId: 'cat_electronics',
|
|
2390
|
+
* useAdvancedSearch: true,
|
|
2391
|
+
* includeBasicFilters: true,
|
|
2392
|
+
* includeFacetCounts: false
|
|
2393
|
+
* });
|
|
2394
|
+
*
|
|
2395
|
+
* filters.forEach(filter => {
|
|
2396
|
+
* console.log(`${filter.label} (${filter.type})`);
|
|
2397
|
+
*
|
|
2398
|
+
* if (filter.type === 'multi' && filter.options) {
|
|
2399
|
+
* filter.options.forEach(opt => {
|
|
2400
|
+
* console.log(` - ${opt.label}${opt.count ? ` (${opt.count})` : ''}`);
|
|
2401
|
+
* });
|
|
2402
|
+
* } else if (filter.type === 'range') {
|
|
2403
|
+
* console.log(` Range: ${filter.min} - ${filter.max}`);
|
|
2404
|
+
* }
|
|
2405
|
+
* });
|
|
2406
|
+
*
|
|
2407
|
+
* // Output:
|
|
2408
|
+
* // Price (range)
|
|
2409
|
+
* // Range: 0 - 5000
|
|
2410
|
+
* // RAM (multi)
|
|
2411
|
+
* // - 8GB (15)
|
|
2412
|
+
* // - 16GB (23)
|
|
2413
|
+
* // - 32GB (8)
|
|
2414
|
+
* // Brand (multi)
|
|
2415
|
+
* // - Dell (12)
|
|
2416
|
+
* // - HP (8)
|
|
2417
|
+
* // In Stock (boolean)
|
|
2418
|
+
* ```
|
|
2419
|
+
*
|
|
2420
|
+
* @example
|
|
2421
|
+
* ```typescript
|
|
2422
|
+
* // Use in React component
|
|
2423
|
+
* function FilterSidebar({ categoryId }: { categoryId?: string }) {
|
|
2424
|
+
* const [filters, setFilters] = useState<FilterConfig[]>([]);
|
|
2425
|
+
*
|
|
2426
|
+
* useEffect(() => {
|
|
2427
|
+
* if (!commerce.getAvailableFilters) return;
|
|
2428
|
+
*
|
|
2429
|
+
* commerce.getAvailableFilters({
|
|
2430
|
+
* categoryId,
|
|
2431
|
+
* useAdvancedSearch: true,
|
|
2432
|
+
* includeBasicFilters: true
|
|
2433
|
+
* }).then(setFilters);
|
|
2434
|
+
* }, [categoryId]);
|
|
2435
|
+
*
|
|
2436
|
+
* return (
|
|
2437
|
+
* <div>
|
|
2438
|
+
* {filters.map(filter => (
|
|
2439
|
+
* <FilterComponent key={filter.id} filter={filter} />
|
|
2440
|
+
* ))}
|
|
2441
|
+
* </div>
|
|
2442
|
+
* );
|
|
2443
|
+
* }
|
|
2444
|
+
* ```
|
|
2445
|
+
*
|
|
2446
|
+
* @throws {ProviderAPIError} If backend fails to fetch attributes
|
|
2447
|
+
* @throws {Error} If category ID invalid
|
|
2448
|
+
*
|
|
2449
|
+
* @see FilterConfig for filter structure
|
|
2450
|
+
* @see BackendCapabilities.facetedFilters to check if supported
|
|
2451
|
+
*/
|
|
2452
|
+
getAvailableFilters?(options: {
|
|
2453
|
+
categoryId?: string;
|
|
2454
|
+
useAdvancedSearch?: boolean;
|
|
2455
|
+
includeBasicFilters?: boolean;
|
|
2456
|
+
includeFacetCounts?: boolean;
|
|
2457
|
+
}): Promise<FilterConfig[]>;
|
|
2458
|
+
/**
|
|
2459
|
+
* Get a single collection by handle/slug
|
|
2460
|
+
* @param handle - Collection handle (slug)
|
|
2461
|
+
* @returns Collection or undefined if not found
|
|
2462
|
+
*/
|
|
2463
|
+
getCollection(handle: string): Promise<Collection | undefined>;
|
|
2464
|
+
/**
|
|
2465
|
+
* Get all collections
|
|
2466
|
+
* @param options - Query options (limit, search)
|
|
2467
|
+
* @returns Array of collections
|
|
2468
|
+
*/
|
|
2469
|
+
getCollections(options?: GetCollectionsOptions): Promise<Collection[]>;
|
|
2470
|
+
/**
|
|
2471
|
+
* Get products in a collection
|
|
2472
|
+
* @param handle - Collection handle
|
|
2473
|
+
* @param options - Query options (sort, pagination)
|
|
2474
|
+
* @returns Array of products in the collection
|
|
2475
|
+
*/
|
|
2476
|
+
getCollectionProducts(handle: string, options?: CollectionProductsOptions): Promise<Product[]>;
|
|
2477
|
+
/**
|
|
2478
|
+
* Get a single product category by ID or handle
|
|
2479
|
+
* @param idOrHandle - Category ID or handle (slug)
|
|
2480
|
+
* @returns Category or undefined if not found
|
|
2481
|
+
*/
|
|
2482
|
+
getCategory(idOrHandle: string): Promise<ProductCategory | undefined>;
|
|
2483
|
+
/**
|
|
2484
|
+
* Get all product categories
|
|
2485
|
+
* @param options - Query options (parent filter, descendants)
|
|
2486
|
+
* @returns Array of categories
|
|
2487
|
+
*/
|
|
2488
|
+
getCategories(options?: GetCategoriesOptions): Promise<ProductCategory[]>;
|
|
2489
|
+
/**
|
|
2490
|
+
* Get products in a category
|
|
2491
|
+
* @param handle - Category handle (slug)
|
|
2492
|
+
* @param options - Query options (sort, pagination)
|
|
2493
|
+
* @returns Array of products in the category
|
|
2494
|
+
*/
|
|
2495
|
+
getCategoryProducts(handle: string, options?: CollectionProductsOptions): Promise<Product[]>;
|
|
2496
|
+
/**
|
|
2497
|
+
* Create a new empty cart
|
|
2498
|
+
* @param options - Optional cart creation options
|
|
2499
|
+
* @param options.regionId - Region ID for the cart (required for some providers like Medusa)
|
|
2500
|
+
* @returns New cart instance
|
|
2501
|
+
*/
|
|
2502
|
+
createCart(options?: {
|
|
2503
|
+
regionId?: string;
|
|
2504
|
+
}): Promise<Cart>;
|
|
2505
|
+
/**
|
|
2506
|
+
* Get an existing cart by ID
|
|
2507
|
+
* @param cartId - Cart ID
|
|
2508
|
+
* @returns Cart or undefined if not found
|
|
2509
|
+
*/
|
|
2510
|
+
getCart(cartId: string): Promise<Cart | undefined>;
|
|
2511
|
+
/**
|
|
2512
|
+
* Add items to cart
|
|
2513
|
+
* @param cartId - Cart ID
|
|
2514
|
+
* @param lines - Items to add
|
|
2515
|
+
* @returns Updated cart
|
|
2516
|
+
*/
|
|
2517
|
+
addToCart(cartId: string, lines: CartLineInput[]): Promise<Cart>;
|
|
2518
|
+
/**
|
|
2519
|
+
* Remove items from cart
|
|
2520
|
+
* @param cartId - Cart ID
|
|
2521
|
+
* @param lineIds - Line item IDs to remove
|
|
2522
|
+
* @returns Updated cart
|
|
2523
|
+
*/
|
|
2524
|
+
removeFromCart(cartId: string, lineIds: string[]): Promise<Cart>;
|
|
2525
|
+
/**
|
|
2526
|
+
* Update cart items
|
|
2527
|
+
* @param cartId - Cart ID
|
|
2528
|
+
* @param lines - Items to update
|
|
2529
|
+
* @returns Updated cart
|
|
2530
|
+
*/
|
|
2531
|
+
updateCart(cartId: string, lines: CartLineUpdate[]): Promise<Cart>;
|
|
2532
|
+
/**
|
|
2533
|
+
* Get available regions from the backend
|
|
2534
|
+
* @returns Array of regions with id, name, and currency information
|
|
2535
|
+
*/
|
|
2536
|
+
getRegions?(): Promise<Array<{
|
|
2537
|
+
id: string;
|
|
2538
|
+
name: string;
|
|
2539
|
+
currency_code: string;
|
|
2540
|
+
countries?: Array<{
|
|
2541
|
+
id: string;
|
|
2542
|
+
iso_2: string;
|
|
2543
|
+
name: string;
|
|
2544
|
+
display_name?: string;
|
|
2545
|
+
}>;
|
|
2546
|
+
}>>;
|
|
2547
|
+
/**
|
|
2548
|
+
* Complete checkout and create order from cart
|
|
2549
|
+
*
|
|
2550
|
+
* This is the final step in the checkout process that converts
|
|
2551
|
+
* a cart into an order. The cart must have:
|
|
2552
|
+
* - Valid shipping address
|
|
2553
|
+
* - Selected shipping method (via addShippingMethod)
|
|
2554
|
+
* - Initiated payment session (via initiatePaymentSession)
|
|
2555
|
+
*
|
|
2556
|
+
* @param cartId - Cart ID to checkout
|
|
2557
|
+
* @returns Created order
|
|
2558
|
+
* @throws {ProviderAPIError} If checkout fails (invalid cart, payment failure, etc.)
|
|
2559
|
+
*
|
|
2560
|
+
* @example
|
|
2561
|
+
* ```typescript
|
|
2562
|
+
* // Complete checkout flow:
|
|
2563
|
+
* // 1. Add shipping address (via cart update)
|
|
2564
|
+
* // 2. Select shipping method
|
|
2565
|
+
* await commerce.addShippingMethod(cartId, 'shipping_standard');
|
|
2566
|
+
* // 3. Initiate payment
|
|
2567
|
+
* await commerce.initiatePaymentSession(cartId, 'stripe');
|
|
2568
|
+
* // 4. Complete checkout
|
|
2569
|
+
* const order = await commerce.completeCheckout(cartId);
|
|
2570
|
+
* ```
|
|
2571
|
+
*/
|
|
2572
|
+
completeCheckout(cartId: string): Promise<Order>;
|
|
2573
|
+
/**
|
|
2574
|
+
* Get available shipping methods for cart
|
|
2575
|
+
*
|
|
2576
|
+
* Fetches shipping options based on cart contents, shipping address,
|
|
2577
|
+
* and region. Returns empty array if no methods available.
|
|
2578
|
+
*
|
|
2579
|
+
* @param cartId - Cart ID
|
|
2580
|
+
* @returns List of shipping methods with prices
|
|
2581
|
+
* @throws {ProviderAPIError} If cart not found or region not configured
|
|
2582
|
+
*
|
|
2583
|
+
* @example
|
|
2584
|
+
* ```typescript
|
|
2585
|
+
* const methods = await commerce.getShippingMethods(cartId);
|
|
2586
|
+
*
|
|
2587
|
+
* methods.forEach(method => {
|
|
2588
|
+
* console.log(`${method.name}: ${method.price.amount} ${method.price.currencyCode}`);
|
|
2589
|
+
* });
|
|
2590
|
+
* ```
|
|
2591
|
+
*/
|
|
2592
|
+
getShippingMethods(cartId: string): Promise<ShippingMethod[]>;
|
|
2593
|
+
/**
|
|
2594
|
+
* Get available countries for a region
|
|
2595
|
+
*
|
|
2596
|
+
* Returns list of countries that are available for shipping
|
|
2597
|
+
* in the specified region. Used for checkout address validation.
|
|
2598
|
+
*
|
|
2599
|
+
* @param regionId - Region ID
|
|
2600
|
+
* @returns Array of countries with codes and names
|
|
2601
|
+
* @throws {ProviderAPIError} If region not found
|
|
2602
|
+
*
|
|
2603
|
+
* @example
|
|
2604
|
+
* ```typescript
|
|
2605
|
+
* const countries = await commerce.getRegionCountries('reg_europe');
|
|
2606
|
+
*
|
|
2607
|
+
* countries.forEach(country => {
|
|
2608
|
+
* console.log(`${country.code}: ${country.name}`);
|
|
2609
|
+
* });
|
|
2610
|
+
* // Output:
|
|
2611
|
+
* // ES: Spain
|
|
2612
|
+
* // FR: France
|
|
2613
|
+
* // DE: Germany
|
|
2614
|
+
* ```
|
|
2615
|
+
*/
|
|
2616
|
+
getRegionCountries(regionId: string): Promise<Country[]>;
|
|
2617
|
+
/**
|
|
2618
|
+
* Add shipping method to cart
|
|
2619
|
+
*
|
|
2620
|
+
* Selects a shipping method from getShippingMethods() and applies it
|
|
2621
|
+
* to the cart. This updates cart totals to include shipping cost.
|
|
2622
|
+
*
|
|
2623
|
+
* @param cartId - Cart ID
|
|
2624
|
+
* @param methodId - Shipping method ID (from getShippingMethods)
|
|
2625
|
+
* @returns Updated cart with shipping method and updated totals
|
|
2626
|
+
* @throws {ProviderAPIError} If method ID invalid or cart not ready
|
|
2627
|
+
*
|
|
2628
|
+
* @example
|
|
2629
|
+
* ```typescript
|
|
2630
|
+
* const methods = await commerce.getShippingMethods(cartId);
|
|
2631
|
+
* const standardShipping = methods.find(m => m.name === 'Standard');
|
|
2632
|
+
*
|
|
2633
|
+
* const updatedCart = await commerce.addShippingMethod(cartId, standardShipping.id);
|
|
2634
|
+
* console.log('New total:', updatedCart.cost.totalAmount);
|
|
2635
|
+
* ```
|
|
2636
|
+
*/
|
|
2637
|
+
addShippingMethod(cartId: string, methodId: string): Promise<Cart>;
|
|
2638
|
+
/**
|
|
2639
|
+
* Initiate payment session with provider
|
|
2640
|
+
*
|
|
2641
|
+
* Creates a payment session with the selected payment provider.
|
|
2642
|
+
* This is required before completeCheckout() can be called.
|
|
2643
|
+
*
|
|
2644
|
+
* Some providers (like Stripe) may return client secret for
|
|
2645
|
+
* client-side payment confirmation.
|
|
2646
|
+
*
|
|
2647
|
+
* @param cartId - Cart ID
|
|
2648
|
+
* @param providerId - Payment provider ID (from getPaymentMethods)
|
|
2649
|
+
* @throws {ProviderAPIError} If provider invalid or cart not ready
|
|
2650
|
+
*
|
|
2651
|
+
* @example
|
|
2652
|
+
* ```typescript
|
|
2653
|
+
* const paymentMethods = await commerce.getPaymentMethods({ regionId });
|
|
2654
|
+
* const stripeMethod = paymentMethods.find(m => m.id === 'stripe');
|
|
2655
|
+
*
|
|
2656
|
+
* await commerce.initiatePaymentSession(cartId, stripeMethod.id);
|
|
2657
|
+
* // Payment session ready, can now complete checkout
|
|
2658
|
+
* ```
|
|
2659
|
+
*/
|
|
2660
|
+
initiatePaymentSession(cartId: string, providerId: string): Promise<void>;
|
|
2661
|
+
/**
|
|
2662
|
+
* Apply discount code to cart
|
|
2663
|
+
*
|
|
2664
|
+
* Validates and applies a discount/promo code to the cart.
|
|
2665
|
+
* Updates cart totals to reflect discount.
|
|
2666
|
+
*
|
|
2667
|
+
* @param cartId - Cart ID
|
|
2668
|
+
* @param code - Discount code (case-insensitive)
|
|
2669
|
+
* @returns Updated cart with discount applied
|
|
2670
|
+
* @throws {ProviderAPIError} If code invalid, expired, or not applicable
|
|
2671
|
+
*
|
|
2672
|
+
* @example
|
|
2673
|
+
* ```typescript
|
|
2674
|
+
* try {
|
|
2675
|
+
* const updatedCart = await commerce.applyDiscountCode(cartId, 'SUMMER2026');
|
|
2676
|
+
* console.log('Discount applied! New total:', updatedCart.cost.totalAmount);
|
|
2677
|
+
* } catch (error) {
|
|
2678
|
+
* console.error('Invalid code:', error.message);
|
|
2679
|
+
* }
|
|
2680
|
+
* ```
|
|
2681
|
+
*/
|
|
2682
|
+
applyDiscountCode(cartId: string, code: string): Promise<Cart>;
|
|
2683
|
+
/**
|
|
2684
|
+
* Remove discount code from cart
|
|
2685
|
+
*
|
|
2686
|
+
* Removes a previously applied discount code.
|
|
2687
|
+
* Updates cart totals to remove discount.
|
|
2688
|
+
*
|
|
2689
|
+
* @param cartId - Cart ID
|
|
2690
|
+
* @param code - Discount code to remove
|
|
2691
|
+
* @returns Updated cart without discount
|
|
2692
|
+
* @throws {ProviderAPIError} If cart not found
|
|
2693
|
+
*
|
|
2694
|
+
* @example
|
|
2695
|
+
* ```typescript
|
|
2696
|
+
* const updatedCart = await commerce.removeDiscountCode(cartId, 'SUMMER2026');
|
|
2697
|
+
* console.log('Discount removed. New total:', updatedCart.cost.totalAmount);
|
|
2698
|
+
* ```
|
|
2699
|
+
*/
|
|
2700
|
+
removeDiscountCode(cartId: string, code: string): Promise<Cart>;
|
|
2701
|
+
/**
|
|
2702
|
+
* Update billing address for cart (optional)
|
|
2703
|
+
*
|
|
2704
|
+
* Sets or updates the billing address on the cart.
|
|
2705
|
+
* Use when billing address differs from shipping address.
|
|
2706
|
+
*
|
|
2707
|
+
* Recommended to call BEFORE initiatePaymentSession() as some
|
|
2708
|
+
* payment providers may require billing address.
|
|
2709
|
+
*
|
|
2710
|
+
* @param cartId - Cart ID
|
|
2711
|
+
* @param address - Billing address to set
|
|
2712
|
+
* @returns Updated cart with billing address
|
|
2713
|
+
* @throws {ProviderAPIError} If cart not found or address invalid
|
|
2714
|
+
*
|
|
2715
|
+
* @example
|
|
2716
|
+
* ```typescript
|
|
2717
|
+
* await commerce.updateBillingAddress(cartId, {
|
|
2718
|
+
* firstName: 'John',
|
|
2719
|
+
* lastName: 'Doe',
|
|
2720
|
+
* address1: '123 Billing St',
|
|
2721
|
+
* city: 'Madrid',
|
|
2722
|
+
* province: 'Madrid',
|
|
2723
|
+
* postalCode: '28001',
|
|
2724
|
+
* countryCode: 'ES',
|
|
2725
|
+
* phone: '+34 600 000 000'
|
|
2726
|
+
* });
|
|
2727
|
+
* ```
|
|
2728
|
+
*/
|
|
2729
|
+
updateBillingAddress?(cartId: string, address: Address): Promise<Cart>;
|
|
2730
|
+
/**
|
|
2731
|
+
* Get customer by ID (optional)
|
|
2732
|
+
* @param customerId - Customer ID
|
|
2733
|
+
* @returns Customer or undefined if not found
|
|
2734
|
+
*/
|
|
2735
|
+
getCustomer?(customerId: string): Promise<Customer | undefined>;
|
|
2736
|
+
/**
|
|
2737
|
+
* List customers with optional filtering and pagination (optional)
|
|
2738
|
+
* @param options - Query options (search, sort, pagination)
|
|
2739
|
+
* @returns Array of customers
|
|
2740
|
+
*/
|
|
2741
|
+
getCustomers?(options?: GetCustomersOptions): Promise<Customer[]>;
|
|
2742
|
+
/**
|
|
2743
|
+
* Update customer information (optional)
|
|
2744
|
+
* @param customerId - Customer ID
|
|
2745
|
+
* @param data - Fields to update
|
|
2746
|
+
* @returns Updated customer
|
|
2747
|
+
*/
|
|
2748
|
+
updateCustomer?(customerId: string, data: Partial<Omit<Customer, 'id' | 'createdAt'>>): Promise<Customer>;
|
|
2749
|
+
/**
|
|
2750
|
+
* Get order by ID (optional)
|
|
2751
|
+
* @param orderId - Order ID
|
|
2752
|
+
* @returns Order or undefined if not found
|
|
2753
|
+
*/
|
|
2754
|
+
getOrder?(orderId: string): Promise<Order | undefined>;
|
|
2755
|
+
/**
|
|
2756
|
+
* Get all orders for a customer (optional)
|
|
2757
|
+
*
|
|
2758
|
+
* @param options - Order query options (supports callbacks for custom backends)
|
|
2759
|
+
* @returns Array of orders
|
|
2760
|
+
*/
|
|
2761
|
+
getOrders?(options: GetOrdersOptions): Promise<Order[]>;
|
|
2762
|
+
/**
|
|
2763
|
+
* Get available payment methods
|
|
2764
|
+
*
|
|
2765
|
+
* This method queries the backend for available payment providers
|
|
2766
|
+
* based on region, cart, or other contextual factors.
|
|
2767
|
+
*
|
|
2768
|
+
* Backends that don't support dynamic payment method listing
|
|
2769
|
+
* (capabilities.listPaymentProviders === false) should throw
|
|
2770
|
+
* an error or return empty array.
|
|
2771
|
+
*
|
|
2772
|
+
* @param options - Payment methods query options
|
|
2773
|
+
* @returns Array of available payment methods
|
|
2774
|
+
*
|
|
2775
|
+
* @example
|
|
2776
|
+
* ```typescript
|
|
2777
|
+
* // Get payment methods for a specific region
|
|
2778
|
+
* const methods = await provider.getPaymentMethods({
|
|
2779
|
+
* regionId: 'reg_123',
|
|
2780
|
+
* enabledOnly: true
|
|
2781
|
+
* });
|
|
2782
|
+
*
|
|
2783
|
+
* // Display to user
|
|
2784
|
+
* methods.forEach(method => {
|
|
2785
|
+
* console.log(method.name, method.type);
|
|
2786
|
+
* });
|
|
2787
|
+
* ```
|
|
2788
|
+
*
|
|
2789
|
+
* @throws {Error} If backend request fails
|
|
2790
|
+
* @throws {Error} If required options are missing (e.g., regionId for Medusa)
|
|
2791
|
+
*/
|
|
2792
|
+
getPaymentMethods(options: PaymentMethodsOptions): Promise<PaymentMethod[]>;
|
|
2793
|
+
/**
|
|
2794
|
+
* Fetch stock locations, optionally filtered by sales channel.
|
|
2795
|
+
* Returns empty array when admin config is not provided (graceful degradation).
|
|
2796
|
+
*
|
|
2797
|
+
* @param params - Optional filter parameters
|
|
2798
|
+
* @returns Array of stock locations
|
|
2799
|
+
*/
|
|
2800
|
+
getStockLocations(params?: {
|
|
2801
|
+
salesChannelId?: string;
|
|
2802
|
+
}): Promise<StockLocation[]>;
|
|
2803
|
+
/**
|
|
2804
|
+
* Check inventory levels for a variant across locations.
|
|
2805
|
+
* Returns empty array when admin config is not provided (graceful degradation).
|
|
2806
|
+
*
|
|
2807
|
+
* @param variantId - Variant ID to check
|
|
2808
|
+
* @param salesChannelId - Optional sales channel filter
|
|
2809
|
+
* @returns Array of inventory levels per location
|
|
2810
|
+
*/
|
|
2811
|
+
checkInventoryLevels(variantId: string, salesChannelId?: string): Promise<InventoryLevel[]>;
|
|
2812
|
+
/**
|
|
2813
|
+
* Validate cart stock availability across all items.
|
|
2814
|
+
* Returns all-available when admin config is not provided (graceful degradation).
|
|
2815
|
+
*
|
|
2816
|
+
* @param cartId - Cart ID to validate
|
|
2817
|
+
* @returns Stock validation result with unavailable items (if any)
|
|
2818
|
+
*/
|
|
2819
|
+
validateCartStock(cartId: string): Promise<StockValidation>;
|
|
2820
|
+
/**
|
|
2821
|
+
* Get fulfillment options enriched with stock location data.
|
|
2822
|
+
*
|
|
2823
|
+
* @param cartId - Cart ID
|
|
2824
|
+
* @param salesChannelId - Sales channel ID for filtering
|
|
2825
|
+
* @returns Array of fulfillment options
|
|
2826
|
+
*/
|
|
2827
|
+
getFulfillmentOptions(cartId: string, salesChannelId: string): Promise<FulfillmentOption[]>;
|
|
2828
|
+
/**
|
|
2829
|
+
* Get a map of product IDs to their admin-level status.
|
|
2830
|
+
* Only available when admin credentials are configured.
|
|
2831
|
+
* Returns empty object when admin config is not provided (graceful degradation).
|
|
2832
|
+
*
|
|
2833
|
+
* Medusa statuses: 'published' | 'draft' | 'proposed' | 'rejected'
|
|
2834
|
+
*
|
|
2835
|
+
* @param options - Optional pagination (default limit: 1000)
|
|
2836
|
+
* @returns Record mapping productId → status string
|
|
2837
|
+
*/
|
|
2838
|
+
getAdminProductStatuses?(options?: {
|
|
2839
|
+
limit?: number;
|
|
2840
|
+
}): Promise<Record<string, string>>;
|
|
2841
|
+
/**
|
|
2842
|
+
* List ALL products from the admin API, including non-published ones.
|
|
2843
|
+
* Returns real backend status values (provider-specific strings).
|
|
2844
|
+
* Gracefully degrades to empty result when admin credentials are not configured.
|
|
2845
|
+
*
|
|
2846
|
+
* Unlike `getProducts()` (storefront API, published only), this method
|
|
2847
|
+
* uses admin credentials to list products of any status.
|
|
2848
|
+
*
|
|
2849
|
+
* @param options.query - Optional full-text search
|
|
2850
|
+
* @param options.limit - Max products to fetch (default: 1000)
|
|
2851
|
+
* @param options.offset - Pagination offset (default: 0)
|
|
2852
|
+
* @returns { products: AdminProduct[]; count: number }
|
|
2853
|
+
*/
|
|
2854
|
+
getAdminProducts?(options?: {
|
|
2855
|
+
query?: string;
|
|
2856
|
+
limit?: number;
|
|
2857
|
+
offset?: number;
|
|
2858
|
+
}): Promise<{
|
|
2859
|
+
products: AdminProduct[];
|
|
2860
|
+
count: number;
|
|
2861
|
+
}>;
|
|
2862
|
+
/**
|
|
2863
|
+
* List all orders for admin dashboard.
|
|
2864
|
+
* Gracefully degrades to empty result when adminConfig is not provided.
|
|
2865
|
+
*/
|
|
2866
|
+
getAdminOrders(options?: {
|
|
2867
|
+
search?: string;
|
|
2868
|
+
status?: string | string[];
|
|
2869
|
+
limit?: number;
|
|
2870
|
+
offset?: number;
|
|
2871
|
+
order?: string;
|
|
2872
|
+
direction?: 'asc' | 'desc';
|
|
2873
|
+
salesChannelId?: string;
|
|
2874
|
+
/**
|
|
2875
|
+
* When true, also fetches draft orders from /admin/draft-orders and merges
|
|
2876
|
+
* them into the result sorted by created_at desc. Draft orders are stored
|
|
2877
|
+
* as a separate entity from regular orders in Medusa v2.
|
|
2878
|
+
*/
|
|
2879
|
+
includeDrafts?: boolean;
|
|
2880
|
+
}): Promise<{
|
|
2881
|
+
orders: Order[];
|
|
2882
|
+
count: number;
|
|
2883
|
+
}>;
|
|
2884
|
+
/**
|
|
2885
|
+
* Get a single order by ID for admin detail view.
|
|
2886
|
+
*/
|
|
2887
|
+
getAdminOrder?(orderId: string): Promise<Order | undefined>;
|
|
2888
|
+
/**
|
|
2889
|
+
* Get a single product by ID for admin detail view.
|
|
2890
|
+
*/
|
|
2891
|
+
getAdminProduct?(productId: string): Promise<AdminProduct | undefined>;
|
|
2892
|
+
/**
|
|
2893
|
+
* Create a draft order (admin operation).
|
|
2894
|
+
*/
|
|
2895
|
+
createDraftOrder?(params: {
|
|
2896
|
+
email: string;
|
|
2897
|
+
regionId: string;
|
|
2898
|
+
salesChannelId?: string;
|
|
2899
|
+
items: Array<{
|
|
2900
|
+
variantId: string;
|
|
2901
|
+
quantity: number;
|
|
2902
|
+
}>;
|
|
2903
|
+
shippingAddress?: {
|
|
2904
|
+
firstName?: string;
|
|
2905
|
+
lastName?: string;
|
|
2906
|
+
address1?: string;
|
|
2907
|
+
city?: string;
|
|
2908
|
+
countryCode?: string;
|
|
2909
|
+
postalCode?: string;
|
|
2910
|
+
};
|
|
2911
|
+
}): Promise<Order>;
|
|
2912
|
+
/**
|
|
2913
|
+
* Cancel an order (admin operation).
|
|
2914
|
+
* Throws ProviderAPIError when adminConfig is not provided.
|
|
2915
|
+
*/
|
|
2916
|
+
cancelOrder(orderId: string): Promise<Order>;
|
|
2917
|
+
/**
|
|
2918
|
+
* Create a fulfillment for an order (admin operation).
|
|
2919
|
+
* Throws ProviderAPIError when adminConfig is not provided.
|
|
2920
|
+
*/
|
|
2921
|
+
createFulfillment(orderId: string, items?: Array<{
|
|
2922
|
+
id: string;
|
|
2923
|
+
quantity: number;
|
|
2924
|
+
}>): Promise<void>;
|
|
2925
|
+
/**
|
|
2926
|
+
* Convert a draft order into a regular pending order (admin operation).
|
|
2927
|
+
* Throws ProviderAPIError when adminConfig is not provided.
|
|
2928
|
+
*/
|
|
2929
|
+
undraftOrder?(draftOrderId: string): Promise<Order>;
|
|
2930
|
+
/**
|
|
2931
|
+
* Create a refund for an order (admin operation).
|
|
2932
|
+
* Throws ProviderAPIError when adminConfig is not provided.
|
|
2933
|
+
*/
|
|
2934
|
+
createRefund(orderId: string, amount?: number, reason?: string): Promise<void>;
|
|
2935
|
+
/**
|
|
2936
|
+
* List customers via admin API with search and pagination.
|
|
2937
|
+
* Requires admin credentials. Gracefully degrades to empty result when
|
|
2938
|
+
* admin config is not provided.
|
|
2939
|
+
*
|
|
2940
|
+
* @param options - Query options (search, limit, salesChannelId)
|
|
2941
|
+
* @returns Paginated customer list
|
|
2942
|
+
*/
|
|
2943
|
+
getAdminCustomers?(options?: GetCustomersOptions): Promise<{
|
|
2944
|
+
customers: Customer[];
|
|
2945
|
+
count: number;
|
|
2946
|
+
}>;
|
|
2947
|
+
/**
|
|
2948
|
+
* Get a single customer by ID via admin API.
|
|
2949
|
+
* Requires admin credentials.
|
|
2950
|
+
*
|
|
2951
|
+
* @param customerId - Customer ID
|
|
2952
|
+
* @returns Customer or undefined if not found
|
|
2953
|
+
*/
|
|
2954
|
+
getAdminCustomer?(customerId: string): Promise<Customer | undefined>;
|
|
2955
|
+
/**
|
|
2956
|
+
* Get addresses for a specific customer via admin API.
|
|
2957
|
+
* Requires admin credentials.
|
|
2958
|
+
*
|
|
2959
|
+
* @param customerId - Customer ID
|
|
2960
|
+
* @returns Array of customer addresses
|
|
2961
|
+
*/
|
|
2962
|
+
getAdminCustomerAddresses?(customerId: string): Promise<Address[]>;
|
|
2963
|
+
/**
|
|
2964
|
+
* Get orders belonging to a specific customer.
|
|
2965
|
+
* Uses admin API to list orders filtered by customer ID.
|
|
2966
|
+
*
|
|
2967
|
+
* @param customerId - Customer ID
|
|
2968
|
+
* @param limit - Max orders to return (default: 10)
|
|
2969
|
+
* @returns Array of orders
|
|
2970
|
+
*/
|
|
2971
|
+
getCustomerOrders?(customerId: string, limit?: number): Promise<Order[]>;
|
|
2972
|
+
/**
|
|
2973
|
+
* List all regions configured in the backend.
|
|
2974
|
+
* Used by admin dashboard for order creation (region selection).
|
|
2975
|
+
*
|
|
2976
|
+
* @returns Array of regions
|
|
2977
|
+
*/
|
|
2978
|
+
getAdminRegions?(): Promise<Region[]>;
|
|
2979
|
+
/**
|
|
2980
|
+
* Get the current storefront/sales channel context.
|
|
2981
|
+
*
|
|
2982
|
+
* @returns StorefrontContext for the current storefront
|
|
2983
|
+
* @throws StorefrontConfigError if storefront is required but not configured
|
|
2984
|
+
* @throws ProviderAPIError if storefront lookup fails
|
|
2985
|
+
*
|
|
2986
|
+
* @remarks
|
|
2987
|
+
* - Called on every request that accesses scoped data
|
|
2988
|
+
* - Should throw EARLY if configuration is invalid
|
|
2989
|
+
* - NOT optional — must always return a valid context or throw
|
|
2990
|
+
*
|
|
2991
|
+
* @example
|
|
2992
|
+
* ```typescript
|
|
2993
|
+
* const storefront = await commerce.getStorefrontContext();
|
|
2994
|
+
* console.log(storefront.name, storefront.platformType);
|
|
2995
|
+
* ```
|
|
2996
|
+
*/
|
|
2997
|
+
getStorefrontContext(): Promise<StorefrontContext>;
|
|
2998
|
+
/**
|
|
2999
|
+
* Check if this provider requires storefront configuration.
|
|
3000
|
+
*
|
|
3001
|
+
* @returns true if storefront is mandatory for correct operation
|
|
3002
|
+
*
|
|
3003
|
+
* @remarks
|
|
3004
|
+
* - Medusa: true
|
|
3005
|
+
* - Shopify: false (optional for single storefront)
|
|
3006
|
+
* - WooCommerce: false (not supported natively)
|
|
3007
|
+
* - BigCommerce: false (optional)
|
|
3008
|
+
* - Spree: false (optional for single store)
|
|
3009
|
+
* - Magento: true (always required)
|
|
3010
|
+
*/
|
|
3011
|
+
isStorefrontRequired(): boolean;
|
|
3012
|
+
/**
|
|
3013
|
+
* Get per-channel storefront configuration (logo, accent color, currency, SEO).
|
|
3014
|
+
*
|
|
3015
|
+
* Calls `GET /store/thor/config` (resolved via publishable API key).
|
|
3016
|
+
* Returns `null` if the Thor Commerce plugin is not installed or
|
|
3017
|
+
* no config exists for the current channel.
|
|
3018
|
+
*
|
|
3019
|
+
* @returns StorefrontConfig or null
|
|
3020
|
+
*/
|
|
3021
|
+
getStorefrontConfig?(): Promise<StorefrontConfig | null>;
|
|
3022
|
+
/**
|
|
3023
|
+
* Get the active Site Designer configuration for the current channel.
|
|
3024
|
+
*
|
|
3025
|
+
* Calls `GET /store/thor/site-config` (resolved via publishable API key).
|
|
3026
|
+
* Returns `null` if the Thor Commerce plugin is not installed or
|
|
3027
|
+
* no config exists for the current channel.
|
|
3028
|
+
*
|
|
3029
|
+
* @returns Versioned DesignerConfig or null
|
|
3030
|
+
*/
|
|
3031
|
+
getDesignerConfig?(): Promise<{
|
|
3032
|
+
version: string;
|
|
3033
|
+
config: DesignerConfig;
|
|
3034
|
+
} | null>;
|
|
3035
|
+
/**
|
|
3036
|
+
* Get admin Site Designer config + history for a sales channel.
|
|
3037
|
+
*
|
|
3038
|
+
* @param salesChannelId - Target sales channel ID
|
|
3039
|
+
* @returns Config with version history, or null if not found
|
|
3040
|
+
*/
|
|
3041
|
+
getAdminDesignerConfig?(salesChannelId: string): Promise<{
|
|
3042
|
+
version: string;
|
|
3043
|
+
config: DesignerConfig;
|
|
3044
|
+
history?: DesignerHistoryEntry[];
|
|
3045
|
+
} | null>;
|
|
3046
|
+
/**
|
|
3047
|
+
* Update the Site Designer config for a sales channel.
|
|
3048
|
+
*
|
|
3049
|
+
* @param salesChannelId - Target sales channel ID
|
|
3050
|
+
* @param config - New designer configuration
|
|
3051
|
+
* @returns Updated config with new version
|
|
3052
|
+
*/
|
|
3053
|
+
updateAdminDesignerConfig?(salesChannelId: string, config: DesignerConfig): Promise<{
|
|
3054
|
+
version: string;
|
|
3055
|
+
config: DesignerConfig;
|
|
3056
|
+
}>;
|
|
3057
|
+
/**
|
|
3058
|
+
* Restore a previous Site Designer config version.
|
|
3059
|
+
*
|
|
3060
|
+
* @param salesChannelId - Target sales channel ID
|
|
3061
|
+
* @param version - Version string to restore
|
|
3062
|
+
* @returns Restored config with new version
|
|
3063
|
+
*/
|
|
3064
|
+
restoreAdminDesignerConfig?(salesChannelId: string, version: string): Promise<{
|
|
3065
|
+
version: string;
|
|
3066
|
+
config: DesignerConfig;
|
|
3067
|
+
}>;
|
|
3068
|
+
}
|
|
3069
|
+
/**
|
|
3070
|
+
* Provider configuration base type
|
|
3071
|
+
*/
|
|
3072
|
+
interface ProviderConfig {
|
|
3073
|
+
/**
|
|
3074
|
+
* Enable debug mode (verbose logging)
|
|
3075
|
+
*/
|
|
3076
|
+
debug?: boolean;
|
|
3077
|
+
/**
|
|
3078
|
+
* Custom fetch implementation (for server-side use)
|
|
3079
|
+
*/
|
|
3080
|
+
customFetch?: typeof fetch;
|
|
3081
|
+
}
|
|
3082
|
+
|
|
3083
|
+
/**
|
|
3084
|
+
* Admin User Types
|
|
3085
|
+
*
|
|
3086
|
+
* Defines the structure for admin user accounts.
|
|
3087
|
+
* MVP uses single password (no email), but prepared for multi-admin.
|
|
3088
|
+
*
|
|
3089
|
+
* @module admin/AdminUser
|
|
3090
|
+
*/
|
|
3091
|
+
/**
|
|
3092
|
+
* Admin User Account
|
|
3093
|
+
*
|
|
3094
|
+
* @remarks
|
|
3095
|
+
* - MVP: email and passwordHash are optional (uses global password)
|
|
3096
|
+
* - Future: Required fields for multi-admin system
|
|
3097
|
+
*/
|
|
3098
|
+
interface AdminUser {
|
|
3099
|
+
/** Unique identifier */
|
|
3100
|
+
id: string;
|
|
3101
|
+
/** Email address (optional in MVP, required for multi-admin) */
|
|
3102
|
+
email?: string;
|
|
3103
|
+
/** Bcrypt password hash (optional in MVP, required for multi-admin) */
|
|
3104
|
+
passwordHash?: string;
|
|
3105
|
+
/** Account creation timestamp */
|
|
3106
|
+
createdAt: Date;
|
|
3107
|
+
/** Last update timestamp */
|
|
3108
|
+
updatedAt: Date;
|
|
3109
|
+
}
|
|
3110
|
+
|
|
3111
|
+
/**
|
|
3112
|
+
* Audit Log Types
|
|
3113
|
+
*
|
|
3114
|
+
* Defines the structure for audit logging of admin actions.
|
|
3115
|
+
* Tracks all critical operations for security and compliance.
|
|
3116
|
+
*
|
|
3117
|
+
* @module admin/AuditLog
|
|
3118
|
+
*/
|
|
3119
|
+
/**
|
|
3120
|
+
* Audit Log Entry
|
|
3121
|
+
*
|
|
3122
|
+
* @remarks
|
|
3123
|
+
* Records all admin actions for security auditing and compliance
|
|
3124
|
+
*/
|
|
3125
|
+
interface AuditLog {
|
|
3126
|
+
/** Unique identifier */
|
|
3127
|
+
id: string;
|
|
3128
|
+
/** ID of the admin who performed the action */
|
|
3129
|
+
adminId: string;
|
|
3130
|
+
/** Action performed (e.g., 'login_success', 'update_order_status') */
|
|
3131
|
+
action: string;
|
|
3132
|
+
/** Type of resource affected (e.g., 'auth', 'order', 'product') */
|
|
3133
|
+
resourceType: string;
|
|
3134
|
+
/** ID of the specific resource (optional) */
|
|
3135
|
+
resourceId?: string;
|
|
3136
|
+
/** Additional context data */
|
|
3137
|
+
metadata?: Record<string, unknown>;
|
|
3138
|
+
/** IP address of the requester */
|
|
3139
|
+
ipAddress?: string;
|
|
3140
|
+
/** User agent string */
|
|
3141
|
+
userAgent?: string;
|
|
3142
|
+
/** Timestamp of the action */
|
|
3143
|
+
createdAt: Date;
|
|
3144
|
+
}
|
|
3145
|
+
|
|
3146
|
+
/**
|
|
3147
|
+
* Dashboard Metrics Types
|
|
3148
|
+
*
|
|
3149
|
+
* Defines the structure for dashboard analytics and metrics.
|
|
3150
|
+
* Used by the DashboardModule to display key business indicators.
|
|
3151
|
+
*
|
|
3152
|
+
* @module admin/DashboardMetrics
|
|
3153
|
+
*/
|
|
3154
|
+
/**
|
|
3155
|
+
* Sales Metrics
|
|
3156
|
+
*/
|
|
3157
|
+
interface SalesMetrics {
|
|
3158
|
+
/** Total sales amount (all time) */
|
|
3159
|
+
total: number;
|
|
3160
|
+
/** Sales amount today */
|
|
3161
|
+
today: number;
|
|
3162
|
+
/** Sales amount in the last 7 days */
|
|
3163
|
+
week: number;
|
|
3164
|
+
/** Sales amount in the last 30 days */
|
|
3165
|
+
month: number;
|
|
3166
|
+
}
|
|
3167
|
+
/**
|
|
3168
|
+
* Orders Metrics
|
|
3169
|
+
*/
|
|
3170
|
+
interface OrdersMetrics {
|
|
3171
|
+
/** Total number of orders */
|
|
3172
|
+
total: number;
|
|
3173
|
+
/** Number of pending orders */
|
|
3174
|
+
pending: number;
|
|
3175
|
+
/** Number of orders being processed */
|
|
3176
|
+
processing: number;
|
|
3177
|
+
/** Number of completed orders */
|
|
3178
|
+
completed: number;
|
|
3179
|
+
}
|
|
3180
|
+
/**
|
|
3181
|
+
* Products Metrics
|
|
3182
|
+
*/
|
|
3183
|
+
interface ProductsMetrics {
|
|
3184
|
+
/** Total number of products */
|
|
3185
|
+
total: number;
|
|
3186
|
+
/** Number of products with low stock */
|
|
3187
|
+
lowStock: number;
|
|
3188
|
+
}
|
|
3189
|
+
/**
|
|
3190
|
+
* Chart Data Point
|
|
3191
|
+
*/
|
|
3192
|
+
interface ChartDataPoint {
|
|
3193
|
+
/** Date in ISO format (YYYY-MM-DD) */
|
|
3194
|
+
date: string;
|
|
3195
|
+
/** Sales amount for this date */
|
|
3196
|
+
sales: number;
|
|
3197
|
+
}
|
|
3198
|
+
/**
|
|
3199
|
+
* Complete Dashboard Metrics
|
|
3200
|
+
*/
|
|
3201
|
+
interface DashboardMetrics {
|
|
3202
|
+
/** Sales metrics */
|
|
3203
|
+
sales: SalesMetrics;
|
|
3204
|
+
/** Orders metrics */
|
|
3205
|
+
orders: OrdersMetrics;
|
|
3206
|
+
/** Products metrics */
|
|
3207
|
+
products: ProductsMetrics;
|
|
3208
|
+
/** Chart data for visualization (last 7 days) */
|
|
3209
|
+
chartData: ChartDataPoint[];
|
|
3210
|
+
}
|
|
3211
|
+
|
|
3212
|
+
/**
|
|
3213
|
+
* Dashboard Configuration Types
|
|
3214
|
+
*
|
|
3215
|
+
* Defines the configuration structure for the DashboardModule.
|
|
3216
|
+
* Uses adapters pattern for maximum flexibility and testability.
|
|
3217
|
+
*
|
|
3218
|
+
* @module admin/DashboardConfig
|
|
3219
|
+
*/
|
|
3220
|
+
|
|
3221
|
+
/**
|
|
3222
|
+
* Adapter for fetching dashboard metrics
|
|
3223
|
+
*
|
|
3224
|
+
* @remarks
|
|
3225
|
+
* L3 components use this interface, L5 provides HTTP implementation
|
|
3226
|
+
*/
|
|
3227
|
+
interface DashboardMetricsAdapter {
|
|
3228
|
+
getMetrics(): Promise<DashboardMetrics>;
|
|
3229
|
+
}
|
|
3230
|
+
/**
|
|
3231
|
+
* Adapter for fetching and managing orders
|
|
3232
|
+
*/
|
|
3233
|
+
interface DashboardOrdersAdapter {
|
|
3234
|
+
getOrders(params?: {
|
|
3235
|
+
page?: number;
|
|
3236
|
+
limit?: number;
|
|
3237
|
+
search?: string;
|
|
3238
|
+
}): Promise<{
|
|
3239
|
+
orders: Order[];
|
|
3240
|
+
total: number;
|
|
3241
|
+
}>;
|
|
3242
|
+
getOrderById(id: string): Promise<Order>;
|
|
3243
|
+
updateOrderStatus?(id: string, status: string): Promise<Order>;
|
|
3244
|
+
}
|
|
3245
|
+
/**
|
|
3246
|
+
* Adapter for fetching and managing products
|
|
3247
|
+
*/
|
|
3248
|
+
interface DashboardProductsAdapter {
|
|
3249
|
+
getProducts(params?: {
|
|
3250
|
+
page?: number;
|
|
3251
|
+
limit?: number;
|
|
3252
|
+
search?: string;
|
|
3253
|
+
}): Promise<{
|
|
3254
|
+
products: Product[];
|
|
3255
|
+
total: number;
|
|
3256
|
+
}>;
|
|
3257
|
+
getProductById(id: string): Promise<Product>;
|
|
3258
|
+
}
|
|
3259
|
+
/**
|
|
3260
|
+
* Adapter for fetching audit logs
|
|
3261
|
+
*/
|
|
3262
|
+
interface AuditLogAdapter {
|
|
3263
|
+
getLogs(params?: {
|
|
3264
|
+
page?: number;
|
|
3265
|
+
limit?: number;
|
|
3266
|
+
}): Promise<{
|
|
3267
|
+
logs: any[];
|
|
3268
|
+
total: number;
|
|
3269
|
+
}>;
|
|
3270
|
+
}
|
|
3271
|
+
/**
|
|
3272
|
+
* Complete Dashboard Configuration
|
|
3273
|
+
*
|
|
3274
|
+
* @remarks
|
|
3275
|
+
* Passed to DashboardModule component
|
|
3276
|
+
*/
|
|
3277
|
+
interface DashboardConfig {
|
|
3278
|
+
/** Storefront identifier */
|
|
3279
|
+
storefrontId: string;
|
|
3280
|
+
/** Metrics adapter (required for all variants) */
|
|
3281
|
+
metrics: DashboardMetricsAdapter;
|
|
3282
|
+
/** Orders adapter (required for standard and complete variants) */
|
|
3283
|
+
orders: DashboardOrdersAdapter;
|
|
3284
|
+
/** Products adapter (optional, for complete variant) */
|
|
3285
|
+
products?: DashboardProductsAdapter;
|
|
3286
|
+
/** Audit logs adapter (optional, for complete variant) */
|
|
3287
|
+
auditLogs?: AuditLogAdapter;
|
|
3288
|
+
}
|
|
3289
|
+
|
|
3290
|
+
/**
|
|
3291
|
+
* Site Config Metadata Types
|
|
3292
|
+
*
|
|
3293
|
+
* Defines the structure for versioned site configuration storage.
|
|
3294
|
+
* Uses Stripe-style date-based versioning for configuration history.
|
|
3295
|
+
* Stored in backend metadata (no separate database).
|
|
3296
|
+
*
|
|
3297
|
+
* @module admin/SiteConfigMetadata
|
|
3298
|
+
*/
|
|
3299
|
+
|
|
3300
|
+
/**
|
|
3301
|
+
* Configuration History Entry
|
|
3302
|
+
*/
|
|
3303
|
+
interface ConfigHistoryEntry {
|
|
3304
|
+
/** Version identifier (date-based: YYYY-MM-DD) */
|
|
3305
|
+
version: string;
|
|
3306
|
+
/** The site configuration at this version */
|
|
3307
|
+
config: SiteConfig;
|
|
3308
|
+
/** ISO 8601 timestamp when this version was created */
|
|
3309
|
+
createdAt: string;
|
|
3310
|
+
/** Admin ID who created this version (for future RBAC) */
|
|
3311
|
+
createdBy?: string;
|
|
3312
|
+
}
|
|
3313
|
+
/**
|
|
3314
|
+
* Site Configuration Metadata
|
|
3315
|
+
*
|
|
3316
|
+
* @remarks
|
|
3317
|
+
* Stored in backend metadata field (e.g., sales_channel.metadata['site_config'])
|
|
3318
|
+
* Uses date-based versioning inspired by Stripe API versioning
|
|
3319
|
+
*/
|
|
3320
|
+
interface SiteConfigMetadata {
|
|
3321
|
+
/** Current version (date-based: YYYY-MM-DD) */
|
|
3322
|
+
version: string;
|
|
3323
|
+
/** The current active site configuration */
|
|
3324
|
+
config: SiteConfig;
|
|
3325
|
+
/** Configuration history (last 10 versions) */
|
|
3326
|
+
history?: ConfigHistoryEntry[];
|
|
3327
|
+
}
|
|
3328
|
+
|
|
3329
|
+
/**
|
|
3330
|
+
* @thorprovider/types v1.0
|
|
3331
|
+
* Shared TypeScript types for Thor Commerce ecosystem
|
|
3332
|
+
*
|
|
3333
|
+
* Pure type definitions with zero runtime dependencies.
|
|
3334
|
+
* Foundation for type-safe commerce operations following SOLID principles.
|
|
3335
|
+
*/
|
|
3336
|
+
|
|
3337
|
+
declare enum SupportedProviderType {
|
|
3338
|
+
Medusa = "medusa"
|
|
3339
|
+
}
|
|
3340
|
+
|
|
3341
|
+
export { type AccountDropdownConfig, type AccountMenuItem, type ActiveFilter, type Address, type AdminProduct, type AdminProductVariant, type AdminUser, type AdvancedSearchProductsOptions, type AuditLog, type AuditLogAdapter, type AuthConfig, type AuthMethod, type AuthProvider, type AuthResponse, type AuthStorage, type AuthorConfig, type BackendCapabilities, type BrandConfig, type CachedPaymentMethods, type Cart, type CartCost, type CartItem, type CartLineInput, type CartLineUpdate, type CartProduct, type ChartDataPoint, type Collection, type CollectionProductsOptions, type CommerceProvider, type CompareProduct, type ConfigHistoryEntry, type Connection, type Country, type CreateAddressData, type Customer, type DashboardConfig, type DashboardMetrics, type DashboardMetricsAdapter, type DashboardOrdersAdapter, type DashboardProductsAdapter, type DesignerConfig, type DesignerHistoryEntry, type DesignerNavItem, type DesignerThemeConfig, type DesignerThemePreset, type DiscountCode, type DynamicSource, type Edge, type FilterConfig, type FilterOption, type FilterSection, type FulfillmentOption, type FulfillmentSet, type FulfillmentStatus, type GetCategoriesCallback, type GetCategoriesOptions, type GetCollectionsOptions, type GetCustomersCallback, type GetCustomersOptions, type GetOrdersCallback, type GetOrdersOptions, type GetProductsOptions, type HeaderLinkItem, type HeaderNavigationConfig, type IconConfig, type Image, type InventoryLevel, type LoginCredentials, type ModulesConfig, type Money, type NavigationCalloutItem, type NavigationItem, type NavigationLinkItem, type Order, type OrderItem, type OrderStatus, type OrdersMetrics, PROVIDER_METADATA, type PaginationOptions, type PasswordResetConfirm, type PasswordResetRequest, type PaymentMethod, type PaymentMethodFeatures, type PaymentMethodType, type PaymentMethodsOptions, type PaymentStatus, type PriceRange, type Product, type ProductCategory, type ProductOption, type ProductPreview, type ProductVariant, type ProductsMetrics, type ProviderConfig, type ProviderTypeString, type Region, type RegisterData, type Review, type SEO, type SalesMetrics, type SearchBarConfig, type SearchResultMeta, type SelectedOption, type ShippingMethod, type SiteConfig, type SiteConfigLabels, type SiteConfigMetadata, type SocialConfig, type SortOption, type SortOptions, type StockLocation, type StockStatus, type StockValidation, type StorefrontConfig, StorefrontConfigError, type StorefrontContext, type StorefrontPlatformType, type StorefrontSeoDefaults, SupportedProviderType, type UpdateCustomerData, getProviderMetadata, isSupportedProviderType };
|