@thorprovider/types 3.2.1 → 3.4.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.
@@ -0,0 +1,295 @@
1
+ /**
2
+ * @thorprovider/types — Multi-Tenant Admin Types
3
+ *
4
+ * Type definitions for admin operations on the Thor Commerce multi-tenant
5
+ * backend plugin (`/admin/thor/`).
6
+ *
7
+ * These types map 1:1 to the API contract defined in
8
+ * `multitenant-api-contract.md`.
9
+ *
10
+ * @module admin/MultiTenantAdmin
11
+ */
12
+
13
+ // ============================================================
14
+ // Sales Channel — Customers
15
+ // ============================================================
16
+
17
+ /**
18
+ * A customer entry as returned by the admin multi-tenant API.
19
+ */
20
+ export interface AdminChannelCustomer {
21
+ id: string;
22
+ email: string;
23
+ first_name: string | null;
24
+ last_name: string | null;
25
+ phone: string | null;
26
+ created_at: string;
27
+ }
28
+
29
+ /** Response for `GET /admin/thor/sales-channels/:id/customers` */
30
+ export interface GetChannelCustomersResponse {
31
+ customers: AdminChannelCustomer[];
32
+ count: number;
33
+ limit: number;
34
+ offset: number;
35
+ }
36
+
37
+ /** Options for paginating channel customers */
38
+ export interface GetChannelCustomersOptions {
39
+ /** Max customers to return (default 20, max 100) */
40
+ limit?: number;
41
+ /** Pagination offset (default 0) */
42
+ offset?: number;
43
+ }
44
+
45
+ // ============================================================
46
+ // Sales Channel — API Keys
47
+ // ============================================================
48
+
49
+ /**
50
+ * A publishable API key entry as returned by the admin multi-tenant API.
51
+ */
52
+ export interface AdminApiKey {
53
+ id: string;
54
+ title: string;
55
+ token: string;
56
+ type: 'publishable' | string;
57
+ created_at: string;
58
+ }
59
+
60
+ /** Response for `GET /admin/thor/sales-channels/:id/api-keys` */
61
+ export interface GetChannelApiKeysResponse {
62
+ api_keys: AdminApiKey[];
63
+ }
64
+
65
+ // ============================================================
66
+ // Sales Channel — Categories
67
+ // ============================================================
68
+
69
+ /**
70
+ * A product category entry as returned by admin channel category endpoints.
71
+ */
72
+ export interface AdminChannelCategory {
73
+ id: string;
74
+ name: string;
75
+ handle: string;
76
+ description: string | null;
77
+ parent_category_id: string | null;
78
+ rank: number;
79
+ metadata: Record<string, unknown>;
80
+ }
81
+
82
+ /** Response for `GET /admin/thor/sales-channels/:id/categories` */
83
+ export interface GetChannelCategoriesResponse {
84
+ categories: AdminChannelCategory[];
85
+ count: number;
86
+ }
87
+
88
+ /** Options for listing channel categories */
89
+ export interface GetChannelCategoriesOptions {
90
+ /** Max categories per page (default 20, max 100) */
91
+ limit?: number;
92
+ /** Pagination offset (default 0) */
93
+ offset?: number;
94
+ /** Expand child categories in nested tree */
95
+ include_descendants?: boolean;
96
+ }
97
+
98
+ /**
99
+ * A slim sales channel reference returned when listing channels for a resource.
100
+ */
101
+ export interface AdminSalesChannelRef {
102
+ id: string;
103
+ name: string;
104
+ description?: string;
105
+ }
106
+
107
+ /** Response for `GET /admin/thor/categories/:id/sales-channels` */
108
+ export interface GetCategorySalesChannelsResponse {
109
+ sales_channels: AdminSalesChannelRef[];
110
+ }
111
+
112
+ /** Body for `POST /admin/thor/categories/:id/sales-channels` */
113
+ export interface AssignCategoriesToChannelsBody {
114
+ sales_channel_ids: string[];
115
+ }
116
+
117
+ /** Response for `POST /admin/thor/categories/:id/sales-channels` */
118
+ export interface AssignCategoriesToChannelsResponse {
119
+ message: string;
120
+ linked: number;
121
+ }
122
+
123
+ /** Body for `DELETE /admin/thor/categories/:id/sales-channels` */
124
+ export interface UnassignCategoriesFromChannelsBody {
125
+ sales_channel_ids: string[];
126
+ }
127
+
128
+ /** Response for `DELETE /admin/thor/categories/:id/sales-channels` */
129
+ export interface UnassignCategoriesFromChannelsResponse {
130
+ message: string;
131
+ dismissed: number;
132
+ }
133
+
134
+ // ============================================================
135
+ // Collections — Channel Mapping
136
+ // ============================================================
137
+
138
+ /** Response for `GET /admin/thor/collections/:id/sales-channels` */
139
+ export interface GetCollectionSalesChannelsResponse {
140
+ sales_channels: AdminSalesChannelRef[];
141
+ }
142
+
143
+ /** Body for `POST /admin/thor/collections/:id/sales-channels` */
144
+ export interface AssignCollectionsToChannelsBody {
145
+ sales_channel_ids: string[];
146
+ }
147
+
148
+ /** Response for `POST /admin/thor/collections/:id/sales-channels` */
149
+ export interface AssignCollectionsToChannelsResponse {
150
+ message: string;
151
+ linked: number;
152
+ }
153
+
154
+ /** Body for `DELETE /admin/thor/collections/:id/sales-channels` */
155
+ export interface UnassignCollectionsFromChannelsBody {
156
+ sales_channel_ids: string[];
157
+ }
158
+
159
+ /** Response for `DELETE /admin/thor/collections/:id/sales-channels` */
160
+ export interface UnassignCollectionsFromChannelsResponse {
161
+ message: string;
162
+ dismissed: number;
163
+ }
164
+
165
+ // ============================================================
166
+ // Storefront Config (Admin CRUD)
167
+ // ============================================================
168
+
169
+ /**
170
+ * SEO defaults as stored in the storefront config.
171
+ */
172
+ export interface AdminStorefrontSeoDefaults {
173
+ title: string;
174
+ description: string;
175
+ ogImage?: string;
176
+ }
177
+
178
+ /**
179
+ * Full storefront config record as returned by admin endpoints.
180
+ * Uses snake_case to match the API contract response shape exactly.
181
+ */
182
+ export interface AdminStorefrontConfig {
183
+ id: string;
184
+ sales_channel_id: string;
185
+ theme_accent_color: string;
186
+ logo_url: string;
187
+ currency_code: string;
188
+ seo_defaults: AdminStorefrontSeoDefaults;
189
+ frontend_webhook_url?: string;
190
+ created_at: string;
191
+ updated_at: string;
192
+ }
193
+
194
+ /** Response for `GET /admin/thor/storefront-config/:id` */
195
+ export interface GetAdminStorefrontConfigResponse {
196
+ storefront_config: AdminStorefrontConfig;
197
+ }
198
+
199
+ /** Body for `PUT /admin/thor/storefront-config/:id` */
200
+ export interface UpdateStorefrontConfigBody {
201
+ theme_accent_color: string;
202
+ logo_url: string;
203
+ currency_code: string;
204
+ seo_defaults: {
205
+ title: string;
206
+ description: string;
207
+ ogImage?: string;
208
+ };
209
+ frontend_webhook_url?: string;
210
+ }
211
+
212
+ /** Response for `PUT /admin/thor/storefront-config/:id` */
213
+ export interface UpdateStorefrontConfigResponse {
214
+ storefront_config: AdminStorefrontConfig;
215
+ }
216
+
217
+ // ============================================================
218
+ // Site Designer Config (Admin CRUD + History + Restore)
219
+ // ============================================================
220
+
221
+ /**
222
+ * A single history entry for the Site Designer config.
223
+ */
224
+ export interface AdminSiteConfigHistoryEntry {
225
+ id?: string;
226
+ version: string;
227
+ createdAt: string;
228
+ createdBy?: string;
229
+ }
230
+
231
+ /**
232
+ * Full site config record as returned by admin endpoints.
233
+ * `config` is the free-form `DesignerConfig` JSON object.
234
+ */
235
+ export interface AdminSiteConfig {
236
+ id: string;
237
+ sales_channel_id: string;
238
+ version: string;
239
+ /** Free-form DesignerConfig object managed by the Site Designer */
240
+ config: Record<string, unknown>;
241
+ history?: AdminSiteConfigHistoryEntry[];
242
+ created_at?: string;
243
+ updated_at?: string;
244
+ }
245
+
246
+ /** Response for `GET /admin/thor/site-config/:sales_channel_id` */
247
+ export interface GetAdminSiteConfigResponse {
248
+ site_config: AdminSiteConfig;
249
+ }
250
+
251
+ /** Body for `PUT /admin/thor/site-config/:sales_channel_id` */
252
+ export type UpdateSiteConfigBody = Record<string, unknown>;
253
+
254
+ /** Response for `PUT /admin/thor/site-config/:sales_channel_id` */
255
+ export interface UpdateSiteConfigResponse {
256
+ site_config: AdminSiteConfig;
257
+ }
258
+
259
+ /**
260
+ * A full history entry including the stored config snapshot.
261
+ */
262
+ export interface AdminSiteConfigHistoryEntryFull {
263
+ id: string;
264
+ version: string;
265
+ config: Record<string, unknown>;
266
+ createdAt: string;
267
+ createdBy?: string;
268
+ }
269
+
270
+ /** Response for `GET /admin/thor/site-config/:sales_channel_id/history` */
271
+ export interface GetAdminSiteConfigHistoryResponse {
272
+ history: AdminSiteConfigHistoryEntryFull[];
273
+ count: number;
274
+ }
275
+
276
+ /** Options for paginating site config history */
277
+ export interface GetAdminSiteConfigHistoryOptions {
278
+ limit?: number;
279
+ offset?: number;
280
+ }
281
+
282
+ /** Response for `POST /admin/thor/site-config/:sales_channel_id/restore/:version` */
283
+ export interface RestoreSiteConfigResponse {
284
+ site_config: AdminSiteConfig;
285
+ }
286
+
287
+ // ============================================================
288
+ // Channel Link — Store endpoints
289
+ // ============================================================
290
+
291
+ /** Response for `POST /store/thor/customers/me/channels` */
292
+ export interface LinkCustomerToChannelResponse {
293
+ linked: boolean;
294
+ reason?: 'already_linked';
295
+ }
@@ -11,3 +11,5 @@ export * from './AuditLog';
11
11
  export * from './DashboardConfig';
12
12
  export * from './DashboardMetrics';
13
13
  export * from './SiteConfigMetadata';
14
+ export * from './MultiTenantAdmin';
15
+ export * from './DropshippingAdmin';
@@ -740,6 +740,48 @@ export interface CommerceProvider {
740
740
  * ```
741
741
  */
742
742
  updateBillingAddress?(cartId: string, address: Address): Promise<Cart>;
743
+
744
+ /**
745
+ * Update the shipping address on a cart.
746
+ *
747
+ * Sets the customer's delivery address and email before proceeding to
748
+ * shipping method and payment selection.
749
+ *
750
+ * @param cartId - Cart ID
751
+ * @param address - Shipping address and contact details
752
+ * @throws {ProviderAPIError} If cart not found or address is invalid
753
+ *
754
+ * @example
755
+ * ```typescript
756
+ * await commerce.updateShippingAddress(cartId, {
757
+ * email: 'customer@example.com',
758
+ * firstName: 'Jane',
759
+ * lastName: 'Doe',
760
+ * address1: '123 Main St',
761
+ * city: 'Madrid',
762
+ * province: 'Madrid',
763
+ * postalCode: '28001',
764
+ * countryCode: 'ES',
765
+ * phone: '+34 600 000 000',
766
+ * });
767
+ * ```
768
+ */
769
+ updateShippingAddress?(
770
+ cartId: string,
771
+ address: {
772
+ email: string;
773
+ firstName: string;
774
+ lastName: string;
775
+ address1: string;
776
+ address2?: string;
777
+ company?: string;
778
+ city: string;
779
+ province: string;
780
+ postalCode: string;
781
+ countryCode: string;
782
+ phone: string;
783
+ },
784
+ ): Promise<void>;
743
785
 
744
786
  // ============================================ // Customer Operations (Optional)
745
787
  // ============================================
package/src/index.ts CHANGED
@@ -226,7 +226,147 @@ export type {
226
226
  AuditLogAdapter,
227
227
  SiteConfigMetadata,
228
228
  ConfigHistoryEntry,
229
- } from './admin';
229
+ // Multi-tenant admin types
230
+ AdminChannelCustomer,
231
+ GetChannelCustomersResponse,
232
+ GetChannelCustomersOptions,
233
+ AdminApiKey,
234
+ GetChannelApiKeysResponse,
235
+ AdminChannelCategory,
236
+ GetChannelCategoriesResponse,
237
+ GetChannelCategoriesOptions,
238
+ AdminSalesChannelRef,
239
+ GetCategorySalesChannelsResponse,
240
+ AssignCategoriesToChannelsBody,
241
+ AssignCategoriesToChannelsResponse,
242
+ UnassignCategoriesFromChannelsBody,
243
+ UnassignCategoriesFromChannelsResponse,
244
+ GetCollectionSalesChannelsResponse,
245
+ AssignCollectionsToChannelsBody,
246
+ AssignCollectionsToChannelsResponse,
247
+ UnassignCollectionsFromChannelsBody,
248
+ UnassignCollectionsFromChannelsResponse,
249
+ AdminStorefrontSeoDefaults,
250
+ AdminStorefrontConfig,
251
+ GetAdminStorefrontConfigResponse,
252
+ UpdateStorefrontConfigBody,
253
+ UpdateStorefrontConfigResponse,
254
+ AdminSiteConfigHistoryEntry,
255
+ AdminSiteConfig,
256
+ GetAdminSiteConfigResponse,
257
+ UpdateSiteConfigBody,
258
+ UpdateSiteConfigResponse,
259
+ AdminSiteConfigHistoryEntryFull,
260
+ GetAdminSiteConfigHistoryResponse,
261
+ GetAdminSiteConfigHistoryOptions,
262
+ RestoreSiteConfigResponse,
263
+ LinkCustomerToChannelResponse,
264
+ // Dropshipping types
265
+ DropshipperAccountRef,
266
+ OnboardDropshipperBody,
267
+ OnboardDropshipperResponse,
268
+ VariantCost,
269
+ GetVariantCostsOptions,
270
+ GetVariantCostsResponse,
271
+ CreateVariantCostBody,
272
+ CreateVariantCostResponse,
273
+ BatchVariantCostItem,
274
+ BatchVariantCostsBody,
275
+ BatchVariantCostsResponse,
276
+ DeleteVariantCostResponse,
277
+ DropshipperVariant,
278
+ DropshipperProduct,
279
+ GetDropshipperProductsOptions,
280
+ GetDropshipperProductsResponse,
281
+ DropshipperPriceItem,
282
+ UpdateDropshipperPricesBody,
283
+ UpdateDropshipperPricesResponse,
284
+ DropshipperOrderCustomer,
285
+ DropshipperOrder,
286
+ GetDropshipperOrdersOptions,
287
+ GetDropshipperOrdersResponse,
288
+ DropshipperOrderShippingAddress,
289
+ DropshipperOrderItem,
290
+ DropshipperOrderTotals,
291
+ DropshipperOrderTimelineEvent,
292
+ DropshipperOrderDetail,
293
+ GetDropshipperOrderDetailResponse,
294
+ CreateOrderItem,
295
+ CreateDropshipperOrderBody,
296
+ CreateDropshipperOrderResponse,
297
+ SetPaymentCollectorBody,
298
+ SetPaymentCollectorResponse,
299
+ DropshipperCategory,
300
+ GetDropshipperCategoriesOptions,
301
+ GetDropshipperCategoriesResponse,
302
+ CreateDropshipperCategoryBody,
303
+ UpdateDropshipperCategoryBody,
304
+ DeleteDropshipperCategoryResponse,
305
+ CreateCategoryMappingBody,
306
+ CreateCategoryMappingResponse,
307
+ DeleteCategoryMappingResponse,
308
+ DropshipperCustomer,
309
+ DropshipperCustomerStats,
310
+ DropshipperCustomerOrderRef,
311
+ DropshipperCustomerDetail,
312
+ GetDropshipperCustomersOptions,
313
+ GetDropshipperCustomersResponse,
314
+ GetDropshipperCustomerDetailResponse,
315
+ CreateDropshipperCustomerBody,
316
+ CreateDropshipperCustomerResponse,
317
+ DropshipperBalance,
318
+ DropshipperPendingOrders,
319
+ DropshipperAccount,
320
+ GetDropshipperAccountResponse,
321
+ DropshipperPayableOrder,
322
+ GetDropshipperPayableResponse,
323
+ DropshipperReceivableOrder,
324
+ GetDropshipperReceivableResponse,
325
+ SettlementRecord,
326
+ GetSettlementsOptions,
327
+ GetSettlementsResponse,
328
+ GetSettlementDetailResponse,
329
+ CreateSettlementBody,
330
+ CreateSettlementResponse,
331
+ ConfirmSettlementBody,
332
+ CancelSettlementBody,
333
+ UpdateSettlementStatusResponse,
334
+ AdminDropshipperAccount,
335
+ AdminDropshipperBalance,
336
+ GetAdminDropshipperAccountsResponse,
337
+ GetAdminAccountBalanceResponse,
338
+ GetAdminPriceListsResponse,
339
+ GetUserChannelResponse,
340
+ DropshipperPromotion,
341
+ GetDropshipperPromotionsOptions,
342
+ GetDropshipperPromotionsResponse,
343
+ PromotionRule,
344
+ CreateDropshipperPromotionBody,
345
+ UpdateDropshipperPromotionBody,
346
+ DeleteDropshipperPromotionResponse,
347
+ GetDashboardStatsOptions,
348
+ DashboardPeriodMetrics,
349
+ DashboardChanges,
350
+ DashboardTopProduct,
351
+ DashboardStats,
352
+ GetDashboardStatsResponse,
353
+ GetStorefrontDropshipperCategoriesResponse,
354
+ OrderNote,
355
+ CreateOrderNoteBody,
356
+ GetOrderNotesResponse,
357
+ DeleteOrderNoteResponse,
358
+ // Order cancel and edits
359
+ CancelDropshipperOrderResponse,
360
+ CreateOrderEditBody,
361
+ CreateOrderEditResponse,
362
+ AddOrderEditItemBody,
363
+ AddOrderEditItemResponse,
364
+ ConfirmOrderEditResponse,
365
+ // Dropshipper addresses (channel-scoped)
366
+ DropshipperAddressBody,
367
+ DropshipperAddressResponse,
368
+ GetDropshipperAddressesResponse,
369
+ } from './admin';
230
370
 
231
371
  // ============================================
232
372
  // Header Configuration Types