@thorprovider/types 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +294 -40
- package/dist/index.d.ts +294 -40
- package/dist/index.js +12 -64
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -64
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
- package/src/admin/MultiTenantAdmin.ts +295 -0
- package/src/admin/index.ts +1 -0
- package/src/auth.ts +15 -28
- package/src/index.ts +36 -7
- package/src/provider.ts +11 -55
- package/src/storefront.ts +11 -9
- package/.turbo/turbo-build.log +0 -18
- package/dist/.tsbuildinfo +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1387,6 +1387,44 @@ interface GetOrdersOptions {
|
|
|
1387
1387
|
customFetcher?: GetOrdersCallback;
|
|
1388
1388
|
}
|
|
1389
1389
|
|
|
1390
|
+
/**
|
|
1391
|
+
* @thorprovider/types — Supported Providers
|
|
1392
|
+
*
|
|
1393
|
+
* Centralized list of all supported commerce providers.
|
|
1394
|
+
* This is the single source of truth for provider types across the monorepo.
|
|
1395
|
+
*
|
|
1396
|
+
* @remarks
|
|
1397
|
+
* - L1 (Foundation): Defines the contract
|
|
1398
|
+
* - L2 (@thorprovider/adapters) imports from here to build the factory
|
|
1399
|
+
* - L5 (Starters) uses the factory which is bound to this enum
|
|
1400
|
+
*
|
|
1401
|
+
* When adding a new provider (e.g., Stel Order):
|
|
1402
|
+
* 1. Add to SupportedProviderType enum below
|
|
1403
|
+
* 2. Update @thorprovider/adapters factory/index.ts with discriminated union
|
|
1404
|
+
* 3. Create packages/adapters/src/providers/shopify/
|
|
1405
|
+
* 4. Implement CommerceProvider interface
|
|
1406
|
+
* 5. Update StorefrontPlatformType in storefront.ts
|
|
1407
|
+
*/
|
|
1408
|
+
/**
|
|
1409
|
+
* All supported commerce platform providers.
|
|
1410
|
+
* `mock` is the backend-optional runtime provider used for layout/design mode.
|
|
1411
|
+
* `medusa` is fully implemented for real backend usage; others are placeholders for future expansion.
|
|
1412
|
+
*
|
|
1413
|
+
* @remarks Implementation status:
|
|
1414
|
+
* - ✅ mock: Fixture-backed provider for backend-optional storefronts
|
|
1415
|
+
* - ✅ medusa: Fully implemented
|
|
1416
|
+
* - 🟡 stelorder: In progress (ERP adapter v1)
|
|
1417
|
+
* - 🟡 shopify: Planned (Phase 2)
|
|
1418
|
+
* - 🟡 bigcommerce: Planned (Phase 2)
|
|
1419
|
+
* - 🟡 woocommerce: Planned (Phase 3)
|
|
1420
|
+
* - 🟡 spree: Planned (Phase 3)
|
|
1421
|
+
* - 🟡 magento: Planned (Phase 3)
|
|
1422
|
+
*/
|
|
1423
|
+
declare enum SupportedProviderType {
|
|
1424
|
+
Mock = "mock",
|
|
1425
|
+
Medusa = "medusa",
|
|
1426
|
+
StelOrder = "stelorder"
|
|
1427
|
+
}
|
|
1390
1428
|
/**
|
|
1391
1429
|
* Union type of all supported provider string values.
|
|
1392
1430
|
* Use this for type annotations when a provider type is expected.
|
|
@@ -1398,7 +1436,7 @@ interface GetOrdersOptions {
|
|
|
1398
1436
|
* }
|
|
1399
1437
|
* ```
|
|
1400
1438
|
*/
|
|
1401
|
-
type ProviderTypeString = 'mock' | 'medusa' | '
|
|
1439
|
+
type ProviderTypeString = 'mock' | 'medusa' | 'stelorder';
|
|
1402
1440
|
/**
|
|
1403
1441
|
* Metadata about each provider.
|
|
1404
1442
|
* Useful for UI, error messages, validation, and documentation.
|
|
@@ -1451,13 +1489,14 @@ declare function getProviderMetadata(type: ProviderTypeString): (typeof PROVIDER
|
|
|
1451
1489
|
* Supported commerce platform types for storefront identification.
|
|
1452
1490
|
*
|
|
1453
1491
|
* @remarks
|
|
1454
|
-
*
|
|
1455
|
-
* When adding a new provider, update packages/types/src/provider.ts
|
|
1456
|
-
* and this type
|
|
1492
|
+
* Keep this type in sync with SupportedProviderType from provider.ts.
|
|
1493
|
+
* When adding a new provider, update both packages/types/src/provider.ts
|
|
1494
|
+
* and this type.
|
|
1457
1495
|
*
|
|
1458
1496
|
* Currently supported:
|
|
1459
1497
|
* - ✅ 'mock': Backend-optional layout/design mode using fixture data
|
|
1460
1498
|
* - ✅ 'medusa': Fully implemented
|
|
1499
|
+
* - 🟡 'stelorder': ERP adapter v1
|
|
1461
1500
|
*
|
|
1462
1501
|
* Planned (not yet implemented):
|
|
1463
1502
|
* - 🟡 'shopify': Phase 2
|
|
@@ -1466,7 +1505,7 @@ declare function getProviderMetadata(type: ProviderTypeString): (typeof PROVIDER
|
|
|
1466
1505
|
* - 🟡 'spree': Phase 3
|
|
1467
1506
|
* - 🟡 'magento': Phase 3
|
|
1468
1507
|
*/
|
|
1469
|
-
type StorefrontPlatformType = 'mock' | 'medusa' | 'shopify' | 'bigcommerce' | 'woocommerce' | 'spree' | 'magento';
|
|
1508
|
+
type StorefrontPlatformType = 'mock' | 'medusa' | 'stelorder' | 'shopify' | 'bigcommerce' | 'woocommerce' | 'spree' | 'magento';
|
|
1470
1509
|
/**
|
|
1471
1510
|
* StorefrontContext
|
|
1472
1511
|
*
|
|
@@ -1502,11 +1541,12 @@ interface StorefrontContext {
|
|
|
1502
1541
|
*
|
|
1503
1542
|
* @remarks
|
|
1504
1543
|
* - Medusa: true (products must be linked to sales channel)
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1544
|
+
* - Shopify: false (products visible by default unless unlisted)
|
|
1545
|
+
* - Stel Order: false (single-company ERP model, no native channel scoping)
|
|
1546
|
+
* - WooCommerce: false (no scoping concept)
|
|
1547
|
+
* - BigCommerce: false (products visible by default unless delisted)
|
|
1548
|
+
* - Spree: true (products must be assigned per store)
|
|
1549
|
+
* - Magento: true (products must be assigned per website)
|
|
1510
1550
|
*/
|
|
1511
1551
|
requiresProductScoping: boolean;
|
|
1512
1552
|
/**
|
|
@@ -1878,28 +1918,21 @@ interface AuthProvider {
|
|
|
1878
1918
|
*/
|
|
1879
1919
|
deleteCustomerAccount(): Promise<void>;
|
|
1880
1920
|
/**
|
|
1881
|
-
*
|
|
1882
|
-
*
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
*
|
|
1887
|
-
*
|
|
1888
|
-
*
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
/**
|
|
1892
|
-
* Update customer address
|
|
1893
|
-
* @param addressId - Address ID
|
|
1894
|
-
* @param data - Fields to update
|
|
1895
|
-
* @returns Updated address
|
|
1896
|
-
*/
|
|
1897
|
-
updateAddress(addressId: string, data: Partial<CreateAddressData>): Promise<Address>;
|
|
1898
|
-
/**
|
|
1899
|
-
* Delete customer address
|
|
1900
|
-
* @param addressId - Address ID
|
|
1921
|
+
* Link the currently authenticated customer to the storefront's sales channel.
|
|
1922
|
+
*
|
|
1923
|
+
* Call immediately after a successful `login()` so the customer appears in the
|
|
1924
|
+
* correct channel on the admin panel. Idempotent — repeated calls return
|
|
1925
|
+
* `{ linked: false, reason: 'already_linked' }`.
|
|
1926
|
+
*
|
|
1927
|
+
* Implements `POST /store/thor/customers/me/channels`.
|
|
1928
|
+
*
|
|
1929
|
+
* @returns `{ linked: true }` when the link was created, or
|
|
1930
|
+
* `{ linked: false, reason: 'already_linked' }` when it already existed.
|
|
1901
1931
|
*/
|
|
1902
|
-
|
|
1932
|
+
linkCustomerToChannel(): Promise<{
|
|
1933
|
+
linked: boolean;
|
|
1934
|
+
reason?: string;
|
|
1935
|
+
}>;
|
|
1903
1936
|
}
|
|
1904
1937
|
|
|
1905
1938
|
/**
|
|
@@ -3339,16 +3372,237 @@ interface SiteConfigMetadata {
|
|
|
3339
3372
|
}
|
|
3340
3373
|
|
|
3341
3374
|
/**
|
|
3342
|
-
* @thorprovider/types
|
|
3343
|
-
*
|
|
3375
|
+
* @thorprovider/types — Multi-Tenant Admin Types
|
|
3376
|
+
*
|
|
3377
|
+
* Type definitions for admin operations on the Thor Commerce multi-tenant
|
|
3378
|
+
* backend plugin (`/admin/thor/`).
|
|
3344
3379
|
*
|
|
3345
|
-
*
|
|
3346
|
-
*
|
|
3380
|
+
* These types map 1:1 to the API contract defined in
|
|
3381
|
+
* `multitenant-api-contract.md`.
|
|
3382
|
+
*
|
|
3383
|
+
* @module admin/MultiTenantAdmin
|
|
3347
3384
|
*/
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3385
|
+
/**
|
|
3386
|
+
* A customer entry as returned by the admin multi-tenant API.
|
|
3387
|
+
*/
|
|
3388
|
+
interface AdminChannelCustomer {
|
|
3389
|
+
id: string;
|
|
3390
|
+
email: string;
|
|
3391
|
+
first_name: string | null;
|
|
3392
|
+
last_name: string | null;
|
|
3393
|
+
phone: string | null;
|
|
3394
|
+
created_at: string;
|
|
3395
|
+
}
|
|
3396
|
+
/** Response for `GET /admin/thor/sales-channels/:id/customers` */
|
|
3397
|
+
interface GetChannelCustomersResponse {
|
|
3398
|
+
customers: AdminChannelCustomer[];
|
|
3399
|
+
count: number;
|
|
3400
|
+
limit: number;
|
|
3401
|
+
offset: number;
|
|
3402
|
+
}
|
|
3403
|
+
/** Options for paginating channel customers */
|
|
3404
|
+
interface GetChannelCustomersOptions {
|
|
3405
|
+
/** Max customers to return (default 20, max 100) */
|
|
3406
|
+
limit?: number;
|
|
3407
|
+
/** Pagination offset (default 0) */
|
|
3408
|
+
offset?: number;
|
|
3409
|
+
}
|
|
3410
|
+
/**
|
|
3411
|
+
* A publishable API key entry as returned by the admin multi-tenant API.
|
|
3412
|
+
*/
|
|
3413
|
+
interface AdminApiKey {
|
|
3414
|
+
id: string;
|
|
3415
|
+
title: string;
|
|
3416
|
+
token: string;
|
|
3417
|
+
type: 'publishable' | string;
|
|
3418
|
+
created_at: string;
|
|
3419
|
+
}
|
|
3420
|
+
/** Response for `GET /admin/thor/sales-channels/:id/api-keys` */
|
|
3421
|
+
interface GetChannelApiKeysResponse {
|
|
3422
|
+
api_keys: AdminApiKey[];
|
|
3423
|
+
}
|
|
3424
|
+
/**
|
|
3425
|
+
* A product category entry as returned by admin channel category endpoints.
|
|
3426
|
+
*/
|
|
3427
|
+
interface AdminChannelCategory {
|
|
3428
|
+
id: string;
|
|
3429
|
+
name: string;
|
|
3430
|
+
handle: string;
|
|
3431
|
+
description: string | null;
|
|
3432
|
+
parent_category_id: string | null;
|
|
3433
|
+
rank: number;
|
|
3434
|
+
metadata: Record<string, unknown>;
|
|
3435
|
+
}
|
|
3436
|
+
/** Response for `GET /admin/thor/sales-channels/:id/categories` */
|
|
3437
|
+
interface GetChannelCategoriesResponse {
|
|
3438
|
+
categories: AdminChannelCategory[];
|
|
3439
|
+
count: number;
|
|
3440
|
+
}
|
|
3441
|
+
/** Options for listing channel categories */
|
|
3442
|
+
interface GetChannelCategoriesOptions {
|
|
3443
|
+
/** Max categories per page (default 20, max 100) */
|
|
3444
|
+
limit?: number;
|
|
3445
|
+
/** Pagination offset (default 0) */
|
|
3446
|
+
offset?: number;
|
|
3447
|
+
/** Expand child categories in nested tree */
|
|
3448
|
+
include_descendants?: boolean;
|
|
3449
|
+
}
|
|
3450
|
+
/**
|
|
3451
|
+
* A slim sales channel reference returned when listing channels for a resource.
|
|
3452
|
+
*/
|
|
3453
|
+
interface AdminSalesChannelRef {
|
|
3454
|
+
id: string;
|
|
3455
|
+
name: string;
|
|
3456
|
+
description?: string;
|
|
3457
|
+
}
|
|
3458
|
+
/** Response for `GET /admin/thor/categories/:id/sales-channels` */
|
|
3459
|
+
interface GetCategorySalesChannelsResponse {
|
|
3460
|
+
sales_channels: AdminSalesChannelRef[];
|
|
3461
|
+
}
|
|
3462
|
+
/** Body for `POST /admin/thor/categories/:id/sales-channels` */
|
|
3463
|
+
interface AssignCategoriesToChannelsBody {
|
|
3464
|
+
sales_channel_ids: string[];
|
|
3465
|
+
}
|
|
3466
|
+
/** Response for `POST /admin/thor/categories/:id/sales-channels` */
|
|
3467
|
+
interface AssignCategoriesToChannelsResponse {
|
|
3468
|
+
message: string;
|
|
3469
|
+
linked: number;
|
|
3470
|
+
}
|
|
3471
|
+
/** Body for `DELETE /admin/thor/categories/:id/sales-channels` */
|
|
3472
|
+
interface UnassignCategoriesFromChannelsBody {
|
|
3473
|
+
sales_channel_ids: string[];
|
|
3474
|
+
}
|
|
3475
|
+
/** Response for `DELETE /admin/thor/categories/:id/sales-channels` */
|
|
3476
|
+
interface UnassignCategoriesFromChannelsResponse {
|
|
3477
|
+
message: string;
|
|
3478
|
+
dismissed: number;
|
|
3479
|
+
}
|
|
3480
|
+
/** Response for `GET /admin/thor/collections/:id/sales-channels` */
|
|
3481
|
+
interface GetCollectionSalesChannelsResponse {
|
|
3482
|
+
sales_channels: AdminSalesChannelRef[];
|
|
3483
|
+
}
|
|
3484
|
+
/** Body for `POST /admin/thor/collections/:id/sales-channels` */
|
|
3485
|
+
interface AssignCollectionsToChannelsBody {
|
|
3486
|
+
sales_channel_ids: string[];
|
|
3487
|
+
}
|
|
3488
|
+
/** Response for `POST /admin/thor/collections/:id/sales-channels` */
|
|
3489
|
+
interface AssignCollectionsToChannelsResponse {
|
|
3490
|
+
message: string;
|
|
3491
|
+
linked: number;
|
|
3492
|
+
}
|
|
3493
|
+
/** Body for `DELETE /admin/thor/collections/:id/sales-channels` */
|
|
3494
|
+
interface UnassignCollectionsFromChannelsBody {
|
|
3495
|
+
sales_channel_ids: string[];
|
|
3496
|
+
}
|
|
3497
|
+
/** Response for `DELETE /admin/thor/collections/:id/sales-channels` */
|
|
3498
|
+
interface UnassignCollectionsFromChannelsResponse {
|
|
3499
|
+
message: string;
|
|
3500
|
+
dismissed: number;
|
|
3501
|
+
}
|
|
3502
|
+
/**
|
|
3503
|
+
* SEO defaults as stored in the storefront config.
|
|
3504
|
+
*/
|
|
3505
|
+
interface AdminStorefrontSeoDefaults {
|
|
3506
|
+
title: string;
|
|
3507
|
+
description: string;
|
|
3508
|
+
ogImage?: string;
|
|
3509
|
+
}
|
|
3510
|
+
/**
|
|
3511
|
+
* Full storefront config record as returned by admin endpoints.
|
|
3512
|
+
* Uses snake_case to match the API contract response shape exactly.
|
|
3513
|
+
*/
|
|
3514
|
+
interface AdminStorefrontConfig {
|
|
3515
|
+
id: string;
|
|
3516
|
+
sales_channel_id: string;
|
|
3517
|
+
theme_accent_color: string;
|
|
3518
|
+
logo_url: string;
|
|
3519
|
+
currency_code: string;
|
|
3520
|
+
seo_defaults: AdminStorefrontSeoDefaults;
|
|
3521
|
+
frontend_webhook_url?: string;
|
|
3522
|
+
created_at: string;
|
|
3523
|
+
updated_at: string;
|
|
3524
|
+
}
|
|
3525
|
+
/** Response for `GET /admin/thor/storefront-config/:id` */
|
|
3526
|
+
interface GetAdminStorefrontConfigResponse {
|
|
3527
|
+
storefront_config: AdminStorefrontConfig;
|
|
3528
|
+
}
|
|
3529
|
+
/** Body for `PUT /admin/thor/storefront-config/:id` */
|
|
3530
|
+
interface UpdateStorefrontConfigBody {
|
|
3531
|
+
theme_accent_color: string;
|
|
3532
|
+
logo_url: string;
|
|
3533
|
+
currency_code: string;
|
|
3534
|
+
seo_defaults: {
|
|
3535
|
+
title: string;
|
|
3536
|
+
description: string;
|
|
3537
|
+
ogImage?: string;
|
|
3538
|
+
};
|
|
3539
|
+
frontend_webhook_url?: string;
|
|
3540
|
+
}
|
|
3541
|
+
/** Response for `PUT /admin/thor/storefront-config/:id` */
|
|
3542
|
+
interface UpdateStorefrontConfigResponse {
|
|
3543
|
+
storefront_config: AdminStorefrontConfig;
|
|
3544
|
+
}
|
|
3545
|
+
/**
|
|
3546
|
+
* A single history entry for the Site Designer config.
|
|
3547
|
+
*/
|
|
3548
|
+
interface AdminSiteConfigHistoryEntry {
|
|
3549
|
+
id?: string;
|
|
3550
|
+
version: string;
|
|
3551
|
+
createdAt: string;
|
|
3552
|
+
createdBy?: string;
|
|
3553
|
+
}
|
|
3554
|
+
/**
|
|
3555
|
+
* Full site config record as returned by admin endpoints.
|
|
3556
|
+
* `config` is the free-form `DesignerConfig` JSON object.
|
|
3557
|
+
*/
|
|
3558
|
+
interface AdminSiteConfig {
|
|
3559
|
+
id: string;
|
|
3560
|
+
sales_channel_id: string;
|
|
3561
|
+
version: string;
|
|
3562
|
+
/** Free-form DesignerConfig object managed by the Site Designer */
|
|
3563
|
+
config: Record<string, unknown>;
|
|
3564
|
+
history?: AdminSiteConfigHistoryEntry[];
|
|
3565
|
+
created_at?: string;
|
|
3566
|
+
updated_at?: string;
|
|
3567
|
+
}
|
|
3568
|
+
/** Response for `GET /admin/thor/site-config/:sales_channel_id` */
|
|
3569
|
+
interface GetAdminSiteConfigResponse {
|
|
3570
|
+
site_config: AdminSiteConfig;
|
|
3571
|
+
}
|
|
3572
|
+
/** Body for `PUT /admin/thor/site-config/:sales_channel_id` */
|
|
3573
|
+
type UpdateSiteConfigBody = Record<string, unknown>;
|
|
3574
|
+
/** Response for `PUT /admin/thor/site-config/:sales_channel_id` */
|
|
3575
|
+
interface UpdateSiteConfigResponse {
|
|
3576
|
+
site_config: AdminSiteConfig;
|
|
3577
|
+
}
|
|
3578
|
+
/**
|
|
3579
|
+
* A full history entry including the stored config snapshot.
|
|
3580
|
+
*/
|
|
3581
|
+
interface AdminSiteConfigHistoryEntryFull {
|
|
3582
|
+
id: string;
|
|
3583
|
+
version: string;
|
|
3584
|
+
config: Record<string, unknown>;
|
|
3585
|
+
createdAt: string;
|
|
3586
|
+
createdBy?: string;
|
|
3587
|
+
}
|
|
3588
|
+
/** Response for `GET /admin/thor/site-config/:sales_channel_id/history` */
|
|
3589
|
+
interface GetAdminSiteConfigHistoryResponse {
|
|
3590
|
+
history: AdminSiteConfigHistoryEntryFull[];
|
|
3591
|
+
count: number;
|
|
3592
|
+
}
|
|
3593
|
+
/** Options for paginating site config history */
|
|
3594
|
+
interface GetAdminSiteConfigHistoryOptions {
|
|
3595
|
+
limit?: number;
|
|
3596
|
+
offset?: number;
|
|
3597
|
+
}
|
|
3598
|
+
/** Response for `POST /admin/thor/site-config/:sales_channel_id/restore/:version` */
|
|
3599
|
+
interface RestoreSiteConfigResponse {
|
|
3600
|
+
site_config: AdminSiteConfig;
|
|
3601
|
+
}
|
|
3602
|
+
/** Response for `POST /store/thor/customers/me/channels` */
|
|
3603
|
+
interface LinkCustomerToChannelResponse {
|
|
3604
|
+
linked: boolean;
|
|
3605
|
+
reason?: 'already_linked';
|
|
3352
3606
|
}
|
|
3353
3607
|
|
|
3354
|
-
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 };
|
|
3608
|
+
export { type AccountDropdownConfig, type AccountMenuItem, type ActiveFilter, type Address, type AdminApiKey, type AdminChannelCategory, type AdminChannelCustomer, type AdminProduct, type AdminProductVariant, type AdminSalesChannelRef, type AdminSiteConfig, type AdminSiteConfigHistoryEntry, type AdminSiteConfigHistoryEntryFull, type AdminStorefrontConfig, type AdminStorefrontSeoDefaults, type AdminUser, type AdvancedSearchProductsOptions, type AssignCategoriesToChannelsBody, type AssignCategoriesToChannelsResponse, type AssignCollectionsToChannelsBody, type AssignCollectionsToChannelsResponse, 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 GetAdminSiteConfigHistoryOptions, type GetAdminSiteConfigHistoryResponse, type GetAdminSiteConfigResponse, type GetAdminStorefrontConfigResponse, type GetCategoriesCallback, type GetCategoriesOptions, type GetCategorySalesChannelsResponse, type GetChannelApiKeysResponse, type GetChannelCategoriesOptions, type GetChannelCategoriesResponse, type GetChannelCustomersOptions, type GetChannelCustomersResponse, type GetCollectionSalesChannelsResponse, type GetCollectionsOptions, type GetCustomersCallback, type GetCustomersOptions, type GetOrdersCallback, type GetOrdersOptions, type GetProductsOptions, type HeaderLinkItem, type HeaderNavigationConfig, type IconConfig, type Image, type InventoryLevel, type LinkCustomerToChannelResponse, 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 RestoreSiteConfigResponse, 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 UnassignCategoriesFromChannelsBody, type UnassignCategoriesFromChannelsResponse, type UnassignCollectionsFromChannelsBody, type UnassignCollectionsFromChannelsResponse, type UpdateCustomerData, type UpdateSiteConfigBody, type UpdateSiteConfigResponse, type UpdateStorefrontConfigBody, type UpdateStorefrontConfigResponse, getProviderMetadata, isSupportedProviderType };
|
package/dist/index.js
CHANGED
|
@@ -22,22 +22,18 @@ var src_exports = {};
|
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
PROVIDER_METADATA: () => PROVIDER_METADATA,
|
|
24
24
|
StorefrontConfigError: () => StorefrontConfigError,
|
|
25
|
-
SupportedProviderType: () =>
|
|
25
|
+
SupportedProviderType: () => SupportedProviderType,
|
|
26
26
|
getProviderMetadata: () => getProviderMetadata,
|
|
27
27
|
isSupportedProviderType: () => isSupportedProviderType
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(src_exports);
|
|
30
30
|
|
|
31
31
|
// src/provider.ts
|
|
32
|
-
var SupportedProviderType = /* @__PURE__ */ ((
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
SupportedProviderType3["WooCommerce"] = "woocommerce";
|
|
38
|
-
SupportedProviderType3["Spree"] = "spree";
|
|
39
|
-
SupportedProviderType3["Magento"] = "magento";
|
|
40
|
-
return SupportedProviderType3;
|
|
32
|
+
var SupportedProviderType = /* @__PURE__ */ ((SupportedProviderType2) => {
|
|
33
|
+
SupportedProviderType2["Mock"] = "mock";
|
|
34
|
+
SupportedProviderType2["Medusa"] = "medusa";
|
|
35
|
+
SupportedProviderType2["StelOrder"] = "stelorder";
|
|
36
|
+
return SupportedProviderType2;
|
|
41
37
|
})(SupportedProviderType || {});
|
|
42
38
|
var PROVIDER_METADATA = {
|
|
43
39
|
mock: {
|
|
@@ -58,56 +54,15 @@ var PROVIDER_METADATA = {
|
|
|
58
54
|
],
|
|
59
55
|
maxRetries: 3
|
|
60
56
|
},
|
|
61
|
-
|
|
62
|
-
name: "
|
|
63
|
-
description: "
|
|
57
|
+
stelorder: {
|
|
58
|
+
name: "Stel Order",
|
|
59
|
+
description: "Stel Order ERP and sales document API",
|
|
64
60
|
requiresStorefront: false,
|
|
65
61
|
requiredEnvVars: [
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
],
|
|
69
|
-
maxRetries: 3
|
|
70
|
-
},
|
|
71
|
-
bigcommerce: {
|
|
72
|
-
name: "BigCommerce",
|
|
73
|
-
description: "BigCommerce REST Storefront API",
|
|
74
|
-
requiresStorefront: false,
|
|
75
|
-
requiredEnvVars: [
|
|
76
|
-
"BIGCOMMERCE_STORE_HASH",
|
|
77
|
-
"BIGCOMMERCE_STOREFRONT_API_TOKEN",
|
|
78
|
-
"BIGCOMMERCE_CHANNEL_ID"
|
|
79
|
-
],
|
|
80
|
-
maxRetries: 3
|
|
81
|
-
},
|
|
82
|
-
woocommerce: {
|
|
83
|
-
name: "WooCommerce",
|
|
84
|
-
description: "WooCommerce Store API + REST API v3",
|
|
85
|
-
requiresStorefront: false,
|
|
86
|
-
requiredEnvVars: [
|
|
87
|
-
"WOOCOMMERCE_URL",
|
|
88
|
-
"WOOCOMMERCE_CONSUMER_KEY",
|
|
89
|
-
"WOOCOMMERCE_CONSUMER_SECRET"
|
|
90
|
-
],
|
|
91
|
-
maxRetries: 3
|
|
92
|
-
},
|
|
93
|
-
spree: {
|
|
94
|
-
name: "Spree Commerce",
|
|
95
|
-
description: "Spree API v2 Storefront (JSON:API)",
|
|
96
|
-
requiresStorefront: false,
|
|
97
|
-
requiredEnvVars: [
|
|
98
|
-
"SPREE_API_URL"
|
|
99
|
-
],
|
|
100
|
-
maxRetries: 3
|
|
101
|
-
},
|
|
102
|
-
magento: {
|
|
103
|
-
name: "Adobe Commerce (Magento)",
|
|
104
|
-
description: "Adobe Commerce GraphQL + REST API",
|
|
105
|
-
requiresStorefront: true,
|
|
106
|
-
requiredEnvVars: [
|
|
107
|
-
"MAGENTO_URL",
|
|
108
|
-
"MAGENTO_STORE_CODE"
|
|
62
|
+
"NEXT_PUBLIC_COMMERCE_API_URL",
|
|
63
|
+
"NEXT_PUBLIC_COMMERCE_API_KEY"
|
|
109
64
|
],
|
|
110
|
-
maxRetries:
|
|
65
|
+
maxRetries: 2
|
|
111
66
|
}
|
|
112
67
|
};
|
|
113
68
|
function isSupportedProviderType(value) {
|
|
@@ -135,13 +90,6 @@ var StorefrontConfigError = class extends Error {
|
|
|
135
90
|
this.requiredEnvVar = requiredEnvVar;
|
|
136
91
|
}
|
|
137
92
|
};
|
|
138
|
-
|
|
139
|
-
// src/index.ts
|
|
140
|
-
var SupportedProviderType2 = /* @__PURE__ */ ((SupportedProviderType3) => {
|
|
141
|
-
SupportedProviderType3["Mock"] = "mock";
|
|
142
|
-
SupportedProviderType3["Medusa"] = "medusa";
|
|
143
|
-
return SupportedProviderType3;
|
|
144
|
-
})(SupportedProviderType2 || {});
|
|
145
93
|
// Annotate the CommonJS export names for ESM import in node:
|
|
146
94
|
0 && (module.exports = {
|
|
147
95
|
PROVIDER_METADATA,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/provider.ts","../src/storefront.ts"],"sourcesContent":["/**\n * @thorprovider/types v1.0\n * Shared TypeScript types for Thor Commerce ecosystem\n * \n * Pure type definitions with zero runtime dependencies.\n * Foundation for type-safe commerce operations following SOLID principles.\n */\n\n// ============================================\n// Common Types\n// ============================================\nexport type {\n Money,\n Image,\n SEO,\n Connection,\n Edge,\n PaginationOptions,\n SortOptions,\n Country,\n} from './common';\n\nexport type {\n AuthorConfig,\n BrandConfig,\n ModulesConfig,\n NavigationItem,\n SiteConfig,\n SocialConfig,\n} from './site-config';\n\nexport type { SiteConfigLabels } from './site-config-labels';\n\n// ============================================\n// Product Types\n// ============================================\nexport type {\n Product,\n ProductOption,\n ProductVariant,\n SelectedOption,\n PriceRange,\n GetProductsOptions,\n ActiveFilter,\n SortOption,\n FilterSection,\n FilterOption,\n ProductPreview,\n Review,\n CompareProduct,\n AdminProductVariant,\n AdminProduct,\n AdvancedSearchProductsOptions,\n SearchResultMeta,\n FilterConfig,\n} from './product';\n\n// ============================================\n// Cart Types\n// ============================================\nexport type {\n Cart,\n CartItem,\n CartProduct,\n CartCost,\n CartLineInput,\n CartLineUpdate,\n ShippingMethod,\n DiscountCode,\n} from './cart';\n\n// ============================================\n// Inventory & Fulfillment Types\n// ============================================\nexport type {\n StockLocation,\n InventoryLevel,\n FulfillmentSet,\n FulfillmentOption,\n StockStatus,\n StockValidation,\n} from './stock-location';\n\n// ============================================\n// Collection Types\n// ============================================\nexport type {\n Collection,\n CollectionProductsOptions,\n GetCollectionsOptions,\n} from './collection';\n\n// ============================================\n// Category Types\n// ============================================\nexport type {\n ProductCategory,\n GetCategoriesOptions,\n GetCategoriesCallback,\n} from './category';\n\n// ============================================\n// Customer Types\n// ============================================\nexport type {\n Customer,\n Address,\n GetCustomersOptions,\n GetCustomersCallback,\n} from './customer';\n\n// ============================================\n// Region Types\n// ============================================\nexport type {\n Region,\n} from './region';\n\n// ============================================\n// Order Types\n// ============================================\nexport type {\n Order,\n OrderItem,\n OrderStatus,\n PaymentStatus,\n FulfillmentStatus,\n GetOrdersOptions,\n GetOrdersCallback,\n} from './order';\n\n// ============================================\n// Provider Types (L1 - Source of Truth)\n// ============================================\nexport enum SupportedProviderType {\n Mock = 'mock',\n Medusa = 'medusa',\n}\n\n// Re-export provider types directly\nexport { type ProviderTypeString } from './provider';\n\nexport {\n isSupportedProviderType,\n getProviderMetadata,\n PROVIDER_METADATA,\n} from './provider';\n\n// ============================================\n// Storefront Types\n// ============================================\nexport type {\n StorefrontContext,\n StorefrontPlatformType,\n} from './storefront';\n\nexport {\n StorefrontConfigError,\n} from './storefront';\n\n// ============================================\n// Storefront Configuration Types\n// ============================================\nexport type {\n StorefrontConfig,\n StorefrontSeoDefaults,\n} from './storefront-config';\n\n// ============================================\n// Designer Configuration Types\n// ============================================\nexport type {\n DesignerConfig,\n DesignerThemeConfig,\n DesignerThemePreset,\n DesignerNavItem,\n DesignerHistoryEntry,\n} from './designer-config';\n\n// ============================================\n// Auth Types\n// ============================================\nexport type {\n AuthProvider,\n AuthConfig,\n AuthMethod,\n AuthStorage,\n LoginCredentials,\n RegisterData,\n AuthResponse,\n UpdateCustomerData,\n CreateAddressData,\n PasswordResetRequest,\n PasswordResetConfirm,\n} from './auth';\n\n// ============================================\n// Payment Types\n// ============================================\nexport type {\n PaymentMethod,\n PaymentMethodType,\n PaymentMethodFeatures,\n PaymentMethodsOptions,\n CachedPaymentMethods,\n} from './payment';\n\n// ============================================\n// Commerce Provider Interface\n// ============================================\nexport type {\n CommerceProvider,\n BackendCapabilities,\n ProviderConfig,\n} from './commerce-provider';\n\n// ============================================\n// Admin Types\n// ============================================\nexport type {\n AdminUser,\n AuditLog,\n DashboardConfig,\n DashboardMetrics,\n SalesMetrics,\n OrdersMetrics,\n ProductsMetrics,\n ChartDataPoint,\n DashboardMetricsAdapter,\n DashboardOrdersAdapter,\n DashboardProductsAdapter,\n AuditLogAdapter,\n SiteConfigMetadata,\n ConfigHistoryEntry,\n} from './admin';\n\n// ============================================\n// Header Configuration Types\n// ============================================\nexport type {\n IconConfig,\n NavigationCalloutItem,\n NavigationLinkItem,\n DynamicSource,\n HeaderLinkItem,\n AccountMenuItem,\n AccountDropdownConfig,\n SearchBarConfig,\n HeaderNavigationConfig,\n} from './header-config';\n","/**\n * @thorprovider/types — Supported Providers\n *\n * Centralized list of all supported commerce providers.\n * This is the single source of truth for provider types across the monorepo.\n *\n * @remarks\n * - L1 (Foundation): Defines the contract\n * - L2 (@thorprovider/adapters) imports from here to build the factory\n * - L5 (Starters) uses the factory which is bound to this enum\n *\n * When adding a new provider (e.g., Shopify):\n * 1. Add to SupportedProviderType enum below\n * 2. Update @thorprovider/adapters factory/index.ts with discriminated union\n * 3. Create packages/adapters/src/providers/shopify/\n * 4. Implement CommerceProvider interface\n * 5. Update StorefrontPlatformType in storefront.ts (automatically synced)\n */\n\n/**\n * All supported commerce platform providers.\n * `mock` is the backend-optional runtime provider used for layout/design mode.\n * `medusa` is fully implemented for real backend usage; others are placeholders for future expansion.\n *\n * @remarks Implementation status:\n * - ✅ mock: Fixture-backed provider for backend-optional storefronts\n * - ✅ medusa: Fully implemented\n * - 🟡 shopify: Planned (Phase 2)\n * - 🟡 bigcommerce: Planned (Phase 2)\n * - 🟡 woocommerce: Planned (Phase 3)\n * - 🟡 spree: Planned (Phase 3)\n * - 🟡 magento: Planned (Phase 3)\n */\nexport enum SupportedProviderType {\n Mock = 'mock',\n Medusa = 'medusa',\n Shopify = 'shopify',\n BigCommerce = 'bigcommerce',\n WooCommerce = 'woocommerce',\n Spree = 'spree',\n Magento = 'magento',\n}\n\n/**\n * Union type of all supported provider string values.\n * Use this for type annotations when a provider type is expected.\n *\n * @example\n * ```typescript\n * function getProviderName(type: ProviderTypeString): string {\n * // type is 'medusa'\n * }\n * ```\n */\nexport type ProviderTypeString = 'mock' | 'medusa' | 'shopify' | 'bigcommerce' | 'woocommerce' | 'spree' | 'magento';\n\n/**\n * Metadata about each provider.\n * Useful for UI, error messages, validation, and documentation.\n *\n * @internal\n */\nexport const PROVIDER_METADATA: Record<\n ProviderTypeString,\n {\n name: string;\n description: string;\n requiresStorefront: boolean;\n requiredEnvVars: string[];\n maxRetries: number;\n }\n> = {\n mock: {\n name: 'Mock',\n description: 'Fixture-backed runtime provider for layout/design mode without a real backend',\n requiresStorefront: false,\n requiredEnvVars: [],\n maxRetries: 0,\n },\n medusa: {\n name: 'Medusa JS',\n description: 'Medusa v2 commerce engine',\n requiresStorefront: true,\n requiredEnvVars: [\n 'NEXT_PUBLIC_COMMERCE_API_URL',\n 'NEXT_PUBLIC_COMMERCE_API_KEY',\n 'NEXT_PUBLIC_SALES_CHANNEL_ID',\n ],\n maxRetries: 3,\n },\n shopify: {\n name: 'Shopify',\n description: 'Shopify Storefront API (GraphQL)',\n requiresStorefront: false,\n requiredEnvVars: [\n 'NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN',\n 'NEXT_PUBLIC_SHOPIFY_STOREFRONT_TOKEN',\n ],\n maxRetries: 3,\n },\n bigcommerce: {\n name: 'BigCommerce',\n description: 'BigCommerce REST Storefront API',\n requiresStorefront: false,\n requiredEnvVars: [\n 'BIGCOMMERCE_STORE_HASH',\n 'BIGCOMMERCE_STOREFRONT_API_TOKEN',\n 'BIGCOMMERCE_CHANNEL_ID',\n ],\n maxRetries: 3,\n },\n woocommerce: {\n name: 'WooCommerce',\n description: 'WooCommerce Store API + REST API v3',\n requiresStorefront: false,\n requiredEnvVars: [\n 'WOOCOMMERCE_URL',\n 'WOOCOMMERCE_CONSUMER_KEY',\n 'WOOCOMMERCE_CONSUMER_SECRET',\n ],\n maxRetries: 3,\n },\n spree: {\n name: 'Spree Commerce',\n description: 'Spree API v2 Storefront (JSON:API)',\n requiresStorefront: false,\n requiredEnvVars: [\n 'SPREE_API_URL',\n ],\n maxRetries: 3,\n },\n magento: {\n name: 'Adobe Commerce (Magento)',\n description: 'Adobe Commerce GraphQL + REST API',\n requiresStorefront: true,\n requiredEnvVars: [\n 'MAGENTO_URL',\n 'MAGENTO_STORE_CODE',\n ],\n maxRetries: 3,\n },\n};\n\n/**\n * Check if a string is a valid provider type.\n *\n * @example\n * ```typescript\n * if (isSupportedProviderType(process.env.COMMERCE_PROVIDER)) {\n * // type is narrowed to ProviderTypeString\n * }\n * ```\n */\nexport function isSupportedProviderType(\n value: unknown\n): value is ProviderTypeString {\n return (\n typeof value === 'string' &&\n Object.values(SupportedProviderType).includes(value as SupportedProviderType)\n );\n}\n\n/**\n * Get metadata for a provider type.\n * Useful for validation, error messages, and logging.\n *\n * @example\n * ```typescript\n * const meta = getProviderMetadata('medusa');\n * console.log(`Using ${meta.name} with max ${meta.maxRetries} retries`);\n * ```\n */\nexport function getProviderMetadata(\n type: ProviderTypeString\n): (typeof PROVIDER_METADATA)[ProviderTypeString] {\n if (!isSupportedProviderType(type)) {\n throw new Error(\n `Unsupported provider: ${type}. Supported: ${Object.values(\n SupportedProviderType\n ).join(', ')}`\n );\n }\n return PROVIDER_METADATA[type];\n}\n","/**\n * @thorprovider/types — Storefront Context\n *\n * Platform-agnostic representation of a \"sales channel\" or equivalent.\n * Abstracts differences between Medusa sales_channel, Shopify publications,\n * BigCommerce channels, WooCommerce sites, Spree stores, and Magento store views.\n *\n * @remarks\n * - Required for all multi-tenant deployments\n * - Returned by `CommerceProvider.getStorefrontContext()`\n * - MUST be validated on startup; errors should NOT be silently ignored\n */\n\n/**\n * Supported commerce platform types for storefront identification.\n *\n * @remarks\n * This type is automatically synced with SupportedProviderType from provider.ts.\n * When adding a new provider, update packages/types/src/provider.ts,\n * and this type will automatically reflect the new provider.\n *\n * Currently supported:\n * - ✅ 'mock': Backend-optional layout/design mode using fixture data\n * - ✅ 'medusa': Fully implemented\n *\n * Planned (not yet implemented):\n * - 🟡 'shopify': Phase 2\n * - 🟡 'bigcommerce': Phase 2\n * - 🟡 'woocommerce': Phase 3\n * - 🟡 'spree': Phase 3\n * - 🟡 'magento': Phase 3\n */\nexport type StorefrontPlatformType = 'mock' | 'medusa' | 'shopify' | 'bigcommerce' | 'woocommerce' | 'spree' | 'magento';\n\n/**\n * StorefrontContext\n *\n * Platform-agnostic representation of a \"sales channel\" or equivalent.\n *\n * @example\n * ```typescript\n * const ctx: StorefrontContext = {\n * id: 'sc_01J...',\n * name: 'B2C Storefront',\n * platformType: 'medusa',\n * requiresProductScoping: true,\n * currencyCode: 'USD',\n * };\n * ```\n */\nexport interface StorefrontContext {\n /**\n * Unique identifier for this storefront across the system.\n * Examples: \"sc_123\" (Medusa), \"gid://shopify/Channel/789\" (Shopify), \"1\" (WooCommerce)\n */\n id: string;\n\n /**\n * Human-readable name for logging and debugging.\n */\n name: string;\n\n /**\n * Platform this storefront belongs to.\n */\n platformType: StorefrontPlatformType;\n\n /**\n * Whether products must be explicitly linked/published to this storefront.\n *\n * @remarks\n * - Medusa: true (products must be linked to sales channel)\n * - Shopify: false (products visible by default unless unlisted)\n * - WooCommerce: false (no scoping concept)\n * - BigCommerce: false (products visible by default unless delisted)\n * - Spree: true (products must be assigned per store)\n * - Magento: true (products must be assigned per website)\n */\n requiresProductScoping: boolean;\n\n /**\n * Primary currency code for this storefront.\n * Examples: \"USD\", \"EUR\", \"GBP\"\n */\n currencyCode: string;\n\n /**\n * Optional region or locale code.\n * Examples: \"US\", \"EU\", \"en-US\", \"es-ES\"\n */\n locale?: string;\n\n /**\n * Optional: Store/Channel metadata from platform.\n * @internal\n */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Storefront validation error.\n * Thrown when storefront configuration is invalid or missing.\n *\n * @example\n * ```typescript\n * throw new StorefrontConfigError(\n * 'Medusa requires NEXT_PUBLIC_SALES_CHANNEL_ID',\n * 'medusa',\n * 'NEXT_PUBLIC_SALES_CHANNEL_ID',\n * );\n * ```\n */\nexport class StorefrontConfigError extends Error {\n public readonly platformType: string;\n public readonly requiredEnvVar?: string;\n\n constructor(\n message: string,\n platformType: string,\n requiredEnvVar?: string,\n ) {\n super(message);\n this.name = 'StorefrontConfigError';\n this.platformType = platformType;\n this.requiredEnvVar = requiredEnvVar;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;;;ACiCO,IAAK,wBAAL,kBAAKC,2BAAL;AACL,EAAAA,uBAAA,UAAO;AACP,EAAAA,uBAAA,YAAS;AACT,EAAAA,uBAAA,aAAU;AACV,EAAAA,uBAAA,iBAAc;AACd,EAAAA,uBAAA,iBAAc;AACd,EAAAA,uBAAA,WAAQ;AACR,EAAAA,uBAAA,aAAU;AAPA,SAAAA;AAAA,GAAA;AA6BL,IAAM,oBAST;AAAA,EACF,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,iBAAiB,CAAC;AAAA,IAClB,YAAY;AAAA,EACd;AAAA,EACA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,YAAY;AAAA,EACd;AAAA,EACA,SAAS;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,MACf;AAAA,MACA;AAAA,IACF;AAAA,IACA,YAAY;AAAA,EACd;AAAA,EACA,aAAa;AAAA,IACX,MAAM;AAAA,IACN,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,YAAY;AAAA,EACd;AAAA,EACA,aAAa;AAAA,IACX,MAAM;AAAA,IACN,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,YAAY;AAAA,EACd;AAAA,EACA,OAAO;AAAA,IACL,MAAM;AAAA,IACN,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,MACf;AAAA,IACF;AAAA,IACA,YAAY;AAAA,EACd;AAAA,EACA,SAAS;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,MACf;AAAA,MACA;AAAA,IACF;AAAA,IACA,YAAY;AAAA,EACd;AACF;AAYO,SAAS,wBACd,OAC6B;AAC7B,SACE,OAAO,UAAU,YACjB,OAAO,OAAO,qBAAqB,EAAE,SAAS,KAA8B;AAEhF;AAYO,SAAS,oBACd,MACgD;AAChD,MAAI,CAAC,wBAAwB,IAAI,GAAG;AAClC,UAAM,IAAI;AAAA,MACR,yBAAyB,IAAI,gBAAgB,OAAO;AAAA,QAClD;AAAA,MACF,EAAE,KAAK,IAAI,CAAC;AAAA,IACd;AAAA,EACF;AACA,SAAO,kBAAkB,IAAI;AAC/B;;;ACvEO,IAAM,wBAAN,cAAoC,MAAM;AAAA,EAC/B;AAAA,EACA;AAAA,EAEhB,YACE,SACA,cACA,gBACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,eAAe;AACpB,SAAK,iBAAiB;AAAA,EACxB;AACF;;;AFQO,IAAKC,yBAAL,kBAAKA,2BAAL;AACL,EAAAA,uBAAA,UAAO;AACP,EAAAA,uBAAA,YAAS;AAFC,SAAAA;AAAA,6BAAA;","names":["SupportedProviderType","SupportedProviderType","SupportedProviderType"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/provider.ts","../src/storefront.ts"],"sourcesContent":["/**\n * @thorprovider/types v1.0\n * Shared TypeScript types for Thor Commerce ecosystem\n * \n * Pure type definitions with zero runtime dependencies.\n * Foundation for type-safe commerce operations following SOLID principles.\n */\n\n// ============================================\n// Common Types\n// ============================================\nexport type {\n Money,\n Image,\n SEO,\n Connection,\n Edge,\n PaginationOptions,\n SortOptions,\n Country,\n} from './common';\n\nexport type {\n AuthorConfig,\n BrandConfig,\n ModulesConfig,\n NavigationItem,\n SiteConfig,\n SocialConfig,\n} from './site-config';\n\nexport type { SiteConfigLabels } from './site-config-labels';\n\n// ============================================\n// Product Types\n// ============================================\nexport type {\n Product,\n ProductOption,\n ProductVariant,\n SelectedOption,\n PriceRange,\n GetProductsOptions,\n ActiveFilter,\n SortOption,\n FilterSection,\n FilterOption,\n ProductPreview,\n Review,\n CompareProduct,\n AdminProductVariant,\n AdminProduct,\n AdvancedSearchProductsOptions,\n SearchResultMeta,\n FilterConfig,\n} from './product';\n\n// ============================================\n// Cart Types\n// ============================================\nexport type {\n Cart,\n CartItem,\n CartProduct,\n CartCost,\n CartLineInput,\n CartLineUpdate,\n ShippingMethod,\n DiscountCode,\n} from './cart';\n\n// ============================================\n// Inventory & Fulfillment Types\n// ============================================\nexport type {\n StockLocation,\n InventoryLevel,\n FulfillmentSet,\n FulfillmentOption,\n StockStatus,\n StockValidation,\n} from './stock-location';\n\n// ============================================\n// Collection Types\n// ============================================\nexport type {\n Collection,\n CollectionProductsOptions,\n GetCollectionsOptions,\n} from './collection';\n\n// ============================================\n// Category Types\n// ============================================\nexport type {\n ProductCategory,\n GetCategoriesOptions,\n GetCategoriesCallback,\n} from './category';\n\n// ============================================\n// Customer Types\n// ============================================\nexport type {\n Customer,\n Address,\n GetCustomersOptions,\n GetCustomersCallback,\n} from './customer';\n\n// ============================================\n// Region Types\n// ============================================\nexport type {\n Region,\n} from './region';\n\n// ============================================\n// Order Types\n// ============================================\nexport type {\n Order,\n OrderItem,\n OrderStatus,\n PaymentStatus,\n FulfillmentStatus,\n GetOrdersOptions,\n GetOrdersCallback,\n} from './order';\n\n// ============================================\n// Provider Types (L1 - Source of Truth)\n// ============================================\nexport { SupportedProviderType, type ProviderTypeString } from './provider';\n\nexport {\n isSupportedProviderType,\n getProviderMetadata,\n PROVIDER_METADATA,\n} from './provider';\n\n// ============================================\n// Storefront Types\n// ============================================\nexport type {\n StorefrontContext,\n StorefrontPlatformType,\n} from './storefront';\n\nexport {\n StorefrontConfigError,\n} from './storefront';\n\n// ============================================\n// Storefront Configuration Types\n// ============================================\nexport type {\n StorefrontConfig,\n StorefrontSeoDefaults,\n} from './storefront-config';\n\n// ============================================\n// Designer Configuration Types\n// ============================================\nexport type {\n DesignerConfig,\n DesignerThemeConfig,\n DesignerThemePreset,\n DesignerNavItem,\n DesignerHistoryEntry,\n} from './designer-config';\n\n// ============================================\n// Auth Types\n// ============================================\nexport type {\n AuthProvider,\n AuthConfig,\n AuthMethod,\n AuthStorage,\n LoginCredentials,\n RegisterData,\n AuthResponse,\n UpdateCustomerData,\n CreateAddressData,\n PasswordResetRequest,\n PasswordResetConfirm,\n} from './auth';\n\n// ============================================\n// Payment Types\n// ============================================\nexport type {\n PaymentMethod,\n PaymentMethodType,\n PaymentMethodFeatures,\n PaymentMethodsOptions,\n CachedPaymentMethods,\n} from './payment';\n\n// ============================================\n// Commerce Provider Interface\n// ============================================\nexport type {\n CommerceProvider,\n BackendCapabilities,\n ProviderConfig,\n} from './commerce-provider';\n\n// ============================================\n// Admin Types\n// ============================================\nexport type {\n AdminUser,\n AuditLog,\n DashboardConfig,\n DashboardMetrics,\n SalesMetrics,\n OrdersMetrics,\n ProductsMetrics,\n ChartDataPoint,\n DashboardMetricsAdapter,\n DashboardOrdersAdapter,\n DashboardProductsAdapter,\n AuditLogAdapter,\n SiteConfigMetadata,\n ConfigHistoryEntry,\n // Multi-tenant admin types\n AdminChannelCustomer,\n GetChannelCustomersResponse,\n GetChannelCustomersOptions,\n AdminApiKey,\n GetChannelApiKeysResponse,\n AdminChannelCategory,\n GetChannelCategoriesResponse,\n GetChannelCategoriesOptions,\n AdminSalesChannelRef,\n GetCategorySalesChannelsResponse,\n AssignCategoriesToChannelsBody,\n AssignCategoriesToChannelsResponse,\n UnassignCategoriesFromChannelsBody,\n UnassignCategoriesFromChannelsResponse,\n GetCollectionSalesChannelsResponse,\n AssignCollectionsToChannelsBody,\n AssignCollectionsToChannelsResponse,\n UnassignCollectionsFromChannelsBody,\n UnassignCollectionsFromChannelsResponse,\n AdminStorefrontSeoDefaults,\n AdminStorefrontConfig,\n GetAdminStorefrontConfigResponse,\n UpdateStorefrontConfigBody,\n UpdateStorefrontConfigResponse,\n AdminSiteConfigHistoryEntry,\n AdminSiteConfig,\n GetAdminSiteConfigResponse,\n UpdateSiteConfigBody,\n UpdateSiteConfigResponse,\n AdminSiteConfigHistoryEntryFull,\n GetAdminSiteConfigHistoryResponse,\n GetAdminSiteConfigHistoryOptions,\n RestoreSiteConfigResponse,\n LinkCustomerToChannelResponse,\n} from './admin';\n\n// ============================================\n// Header Configuration Types\n// ============================================\nexport type {\n IconConfig,\n NavigationCalloutItem,\n NavigationLinkItem,\n DynamicSource,\n HeaderLinkItem,\n AccountMenuItem,\n AccountDropdownConfig,\n SearchBarConfig,\n HeaderNavigationConfig,\n} from './header-config';\n","/**\n * @thorprovider/types — Supported Providers\n *\n * Centralized list of all supported commerce providers.\n * This is the single source of truth for provider types across the monorepo.\n *\n * @remarks\n * - L1 (Foundation): Defines the contract\n * - L2 (@thorprovider/adapters) imports from here to build the factory\n * - L5 (Starters) uses the factory which is bound to this enum\n *\n * When adding a new provider (e.g., Stel Order):\n * 1. Add to SupportedProviderType enum below\n * 2. Update @thorprovider/adapters factory/index.ts with discriminated union\n * 3. Create packages/adapters/src/providers/shopify/\n * 4. Implement CommerceProvider interface\n * 5. Update StorefrontPlatformType in storefront.ts\n */\n\n/**\n * All supported commerce platform providers.\n * `mock` is the backend-optional runtime provider used for layout/design mode.\n * `medusa` is fully implemented for real backend usage; others are placeholders for future expansion.\n *\n * @remarks Implementation status:\n * - ✅ mock: Fixture-backed provider for backend-optional storefronts\n * - ✅ medusa: Fully implemented\n * - 🟡 stelorder: In progress (ERP adapter v1)\n * - 🟡 shopify: Planned (Phase 2)\n * - 🟡 bigcommerce: Planned (Phase 2)\n * - 🟡 woocommerce: Planned (Phase 3)\n * - 🟡 spree: Planned (Phase 3)\n * - 🟡 magento: Planned (Phase 3)\n */\nexport enum SupportedProviderType {\n Mock = 'mock',\n Medusa = 'medusa',\n StelOrder = 'stelorder',\n}\n\n/**\n * Union type of all supported provider string values.\n * Use this for type annotations when a provider type is expected.\n *\n * @example\n * ```typescript\n * function getProviderName(type: ProviderTypeString): string {\n * // type is 'medusa'\n * }\n * ```\n */\nexport type ProviderTypeString = 'mock' | 'medusa' | 'stelorder';\n\n/**\n * Metadata about each provider.\n * Useful for UI, error messages, validation, and documentation.\n *\n * @internal\n */\nexport const PROVIDER_METADATA: Record<\n ProviderTypeString,\n {\n name: string;\n description: string;\n requiresStorefront: boolean;\n requiredEnvVars: string[];\n maxRetries: number;\n }\n> = {\n mock: {\n name: 'Mock',\n description: 'Fixture-backed runtime provider for layout/design mode without a real backend',\n requiresStorefront: false,\n requiredEnvVars: [],\n maxRetries: 0,\n },\n medusa: {\n name: 'Medusa JS',\n description: 'Medusa v2 commerce engine',\n requiresStorefront: true,\n requiredEnvVars: [\n 'NEXT_PUBLIC_COMMERCE_API_URL',\n 'NEXT_PUBLIC_COMMERCE_API_KEY',\n 'NEXT_PUBLIC_SALES_CHANNEL_ID',\n ],\n maxRetries: 3,\n },\n stelorder: {\n name: 'Stel Order',\n description: 'Stel Order ERP and sales document API',\n requiresStorefront: false,\n requiredEnvVars: [\n 'NEXT_PUBLIC_COMMERCE_API_URL',\n 'NEXT_PUBLIC_COMMERCE_API_KEY',\n ],\n maxRetries: 2,\n },\n};\n\n/**\n * Check if a string is a valid provider type.\n *\n * @example\n * ```typescript\n * if (isSupportedProviderType(process.env.COMMERCE_PROVIDER)) {\n * // type is narrowed to ProviderTypeString\n * }\n * ```\n */\nexport function isSupportedProviderType(\n value: unknown\n): value is ProviderTypeString {\n return (\n typeof value === 'string' &&\n Object.values(SupportedProviderType).includes(value as SupportedProviderType)\n );\n}\n\n/**\n * Get metadata for a provider type.\n * Useful for validation, error messages, and logging.\n *\n * @example\n * ```typescript\n * const meta = getProviderMetadata('medusa');\n * console.log(`Using ${meta.name} with max ${meta.maxRetries} retries`);\n * ```\n */\nexport function getProviderMetadata(\n type: ProviderTypeString\n): (typeof PROVIDER_METADATA)[ProviderTypeString] {\n if (!isSupportedProviderType(type)) {\n throw new Error(\n `Unsupported provider: ${type}. Supported: ${Object.values(\n SupportedProviderType\n ).join(', ')}`\n );\n }\n return PROVIDER_METADATA[type];\n}\n","/**\n * @thorprovider/types — Storefront Context\n *\n * Platform-agnostic representation of a \"sales channel\" or equivalent.\n * Abstracts differences between Medusa sales_channel, Shopify publications,\n * BigCommerce channels, WooCommerce sites, Spree stores, and Magento store views.\n *\n * @remarks\n * - Required for all multi-tenant deployments\n * - Returned by `CommerceProvider.getStorefrontContext()`\n * - MUST be validated on startup; errors should NOT be silently ignored\n */\n\n/**\n * Supported commerce platform types for storefront identification.\n *\n * @remarks\n * Keep this type in sync with SupportedProviderType from provider.ts.\n * When adding a new provider, update both packages/types/src/provider.ts\n * and this type.\n *\n * Currently supported:\n * - ✅ 'mock': Backend-optional layout/design mode using fixture data\n * - ✅ 'medusa': Fully implemented\n * - 🟡 'stelorder': ERP adapter v1\n *\n * Planned (not yet implemented):\n * - 🟡 'shopify': Phase 2\n * - 🟡 'bigcommerce': Phase 2\n * - 🟡 'woocommerce': Phase 3\n * - 🟡 'spree': Phase 3\n * - 🟡 'magento': Phase 3\n */\nexport type StorefrontPlatformType = 'mock' | 'medusa' | 'stelorder' | 'shopify' | 'bigcommerce' | 'woocommerce' | 'spree' | 'magento';\n\n/**\n * StorefrontContext\n *\n * Platform-agnostic representation of a \"sales channel\" or equivalent.\n *\n * @example\n * ```typescript\n * const ctx: StorefrontContext = {\n * id: 'sc_01J...',\n * name: 'B2C Storefront',\n * platformType: 'medusa',\n * requiresProductScoping: true,\n * currencyCode: 'USD',\n * };\n * ```\n */\nexport interface StorefrontContext {\n /**\n * Unique identifier for this storefront across the system.\n * Examples: \"sc_123\" (Medusa), \"gid://shopify/Channel/789\" (Shopify), \"1\" (WooCommerce)\n */\n id: string;\n\n /**\n * Human-readable name for logging and debugging.\n */\n name: string;\n\n /**\n * Platform this storefront belongs to.\n */\n platformType: StorefrontPlatformType;\n\n /**\n * Whether products must be explicitly linked/published to this storefront.\n *\n * @remarks\n * - Medusa: true (products must be linked to sales channel)\n * - Shopify: false (products visible by default unless unlisted)\n * - Stel Order: false (single-company ERP model, no native channel scoping)\n * - WooCommerce: false (no scoping concept)\n * - BigCommerce: false (products visible by default unless delisted)\n * - Spree: true (products must be assigned per store)\n * - Magento: true (products must be assigned per website)\n */\n requiresProductScoping: boolean;\n\n /**\n * Primary currency code for this storefront.\n * Examples: \"USD\", \"EUR\", \"GBP\"\n */\n currencyCode: string;\n\n /**\n * Optional region or locale code.\n * Examples: \"US\", \"EU\", \"en-US\", \"es-ES\"\n */\n locale?: string;\n\n /**\n * Optional: Store/Channel metadata from platform.\n * @internal\n */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Storefront validation error.\n * Thrown when storefront configuration is invalid or missing.\n *\n * @example\n * ```typescript\n * throw new StorefrontConfigError(\n * 'Medusa requires NEXT_PUBLIC_SALES_CHANNEL_ID',\n * 'medusa',\n * 'NEXT_PUBLIC_SALES_CHANNEL_ID',\n * );\n * ```\n */\nexport class StorefrontConfigError extends Error {\n public readonly platformType: string;\n public readonly requiredEnvVar?: string;\n\n constructor(\n message: string,\n platformType: string,\n requiredEnvVar?: string,\n ) {\n super(message);\n this.name = 'StorefrontConfigError';\n this.platformType = platformType;\n this.requiredEnvVar = requiredEnvVar;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACkCO,IAAK,wBAAL,kBAAKA,2BAAL;AACL,EAAAA,uBAAA,UAAO;AACP,EAAAA,uBAAA,YAAS;AACT,EAAAA,uBAAA,eAAY;AAHF,SAAAA;AAAA,GAAA;AAyBL,IAAM,oBAST;AAAA,EACF,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,iBAAiB,CAAC;AAAA,IAClB,YAAY;AAAA,EACd;AAAA,EACA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,YAAY;AAAA,EACd;AAAA,EACA,WAAW;AAAA,IACT,MAAM;AAAA,IACN,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,MACf;AAAA,MACA;AAAA,IACF;AAAA,IACA,YAAY;AAAA,EACd;AACF;AAYO,SAAS,wBACd,OAC6B;AAC7B,SACE,OAAO,UAAU,YACjB,OAAO,OAAO,qBAAqB,EAAE,SAAS,KAA8B;AAEhF;AAYO,SAAS,oBACd,MACgD;AAChD,MAAI,CAAC,wBAAwB,IAAI,GAAG;AAClC,UAAM,IAAI;AAAA,MACR,yBAAyB,IAAI,gBAAgB,OAAO;AAAA,QAClD;AAAA,MACF,EAAE,KAAK,IAAI,CAAC;AAAA,IACd;AAAA,EACF;AACA,SAAO,kBAAkB,IAAI;AAC/B;;;ACzBO,IAAM,wBAAN,cAAoC,MAAM;AAAA,EAC/B;AAAA,EACA;AAAA,EAEhB,YACE,SACA,cACA,gBACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,eAAe;AACpB,SAAK,iBAAiB;AAAA,EACxB;AACF;","names":["SupportedProviderType"]}
|