@thorprovider/medusa-extended 1.1.1 → 1.2.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/AGENTS.md +1 -1
- package/CHANGELOG.md +14 -0
- package/README.md +10 -3
- package/dist/index.d.mts +30 -4
- package/dist/index.d.ts +30 -4
- package/dist/index.js +122 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +121 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/admin.ts +2 -1
- package/src/dropshipper.test.ts +50 -3
- package/src/dropshipper.ts +75 -9
- package/src/request-resilience.ts +81 -0
- package/dist/.tsbuildinfo +0 -1
package/AGENTS.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!-- MEDUSA-EXTENDED-AGENTS-MD-START -->[@thorprovider/medusa-extended Docs]|root: ./medusa-extended|Documentation for @thorprovider/medusa-extended. Always read package docs before making changes.|To regenerate: yarn
|
|
1
|
+
<!-- MEDUSA-EXTENDED-AGENTS-MD-START -->[@thorprovider/medusa-extended Docs]|root: ./medusa-extended|Documentation for @thorprovider/medusa-extended. Always read package docs before making changes.|To regenerate: yarn generate:agents-index|.:{README.md}<!-- MEDUSA-EXTENDED-AGENTS-MD-END -->
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# @thorprovider/medusa-extended
|
|
2
|
+
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add `getOrderShippingOptions()` to the dropshipper client so manual order creation can resolve shipping options through the canonical SDK instead of a local fetch wrapper.
|
|
8
|
+
|
|
9
|
+
## 1.1.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
- @thorprovider/adapters@4.2.2
|
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ const admin = new MedusaAdminClient({
|
|
|
36
36
|
|
|
37
37
|
## DropshipperClient
|
|
38
38
|
|
|
39
|
-
Covers **all
|
|
39
|
+
Covers **all 53 methods** across the dropshipping feature set. Both the ThorProvider admin (X) and the dropshipper panel (Y) use this same client — access control is enforced server-side.
|
|
40
40
|
|
|
41
41
|
### Configuration
|
|
42
42
|
|
|
@@ -106,6 +106,12 @@ POST /auth/user/emailpass
|
|
|
106
106
|
| `createOrderNote(orderId, body)` | `POST /admin/thor/dropshipper/orders/:id/notes` |
|
|
107
107
|
| `deleteOrderNote(orderId, noteId)` | `DELETE /admin/thor/dropshipper/orders/:id/notes/:noteId` |
|
|
108
108
|
|
|
109
|
+
#### Provider Categories (read-only — Medusa native)
|
|
110
|
+
|
|
111
|
+
| Method | Endpoint |
|
|
112
|
+
|---|---|
|
|
113
|
+
| `getProviderCategories()` | `GET /admin/thor/dropshipper/categories/provider` |
|
|
114
|
+
|
|
109
115
|
#### Custom Categories (Solo Y)
|
|
110
116
|
|
|
111
117
|
| Method | Endpoint |
|
|
@@ -113,7 +119,8 @@ POST /auth/user/emailpass
|
|
|
113
119
|
| `getCategories(options?)` | `GET /admin/thor/dropshipper/categories` |
|
|
114
120
|
| `createCategory(body)` | `POST /admin/thor/dropshipper/categories` |
|
|
115
121
|
| `updateCategory(id, body)` | `PUT /admin/thor/dropshipper/categories/:id` |
|
|
116
|
-
| `deleteCategory(id)` | `DELETE /admin/thor/dropshipper/categories/:id` |
|
|
122
|
+
| `deleteCategory(id, options?)` | `DELETE /admin/thor/dropshipper/categories/:id` — pass `{ force: true }` to cascade-delete children |
|
|
123
|
+
| `getCategoryMappings(options?)` | `GET /admin/thor/dropshipper/category-mappings` — filter by `product_id` |
|
|
117
124
|
| `createCategoryMapping(body)` | `POST /admin/thor/dropshipper/category-mappings` |
|
|
118
125
|
| `deleteCategoryMapping(id)` | `DELETE /admin/thor/dropshipper/category-mappings/:id` |
|
|
119
126
|
|
|
@@ -126,7 +133,7 @@ POST /auth/user/emailpass
|
|
|
126
133
|
| `createCustomer(body)` | `POST /admin/thor/dropshipper/customers` |
|
|
127
134
|
| `getCustomerAddresses(customerId)` | `GET /admin/thor/dropshipper/customers/:id/addresses` |
|
|
128
135
|
| `createCustomerAddress(customerId, body)` | `POST /admin/thor/dropshipper/customers/:id/addresses` |
|
|
129
|
-
| `updateCustomerAddress(customerId, addressId, body)` | `
|
|
136
|
+
| `updateCustomerAddress(customerId, addressId, body)` | `POST /admin/thor/dropshipper/customers/:id/addresses/:addr_id` |
|
|
130
137
|
| `deleteCustomerAddress(customerId, addressId)` | `DELETE /admin/thor/dropshipper/customers/:id/addresses/:addr_id` |
|
|
131
138
|
|
|
132
139
|
#### Account & Settlements (Solo Y — read-only)
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GetChannelCustomersOptions, GetChannelCustomersResponse, GetChannelApiKeysResponse, GetChannelCategoriesOptions, GetChannelCategoriesResponse, GetCategorySalesChannelsResponse, AssignCategoriesToChannelsBody, AssignCategoriesToChannelsResponse, UnassignCategoriesFromChannelsBody, UnassignCategoriesFromChannelsResponse, GetCollectionSalesChannelsResponse, AssignCollectionsToChannelsBody, AssignCollectionsToChannelsResponse, UnassignCollectionsFromChannelsBody, UnassignCollectionsFromChannelsResponse, GetAdminStorefrontConfigResponse, UpdateStorefrontConfigBody, UpdateStorefrontConfigResponse, GetAdminSiteConfigResponse, UpdateSiteConfigBody, UpdateSiteConfigResponse, GetAdminSiteConfigHistoryOptions, GetAdminSiteConfigHistoryResponse, RestoreSiteConfigResponse, OnboardDropshipperBody, OnboardDropshipperResponse, GetVariantCostsOptions, GetVariantCostsResponse, CreateVariantCostBody, CreateVariantCostResponse, BatchVariantCostsBody, BatchVariantCostsResponse, DeleteVariantCostResponse, GetDropshipperProductsOptions, GetDropshipperProductsResponse, UpdateDropshipperPricesBody, UpdateDropshipperPricesResponse, GetDropshipperOrdersOptions, GetDropshipperOrdersResponse, GetDropshipperOrderDetailResponse,
|
|
1
|
+
import { GetChannelCustomersOptions, GetChannelCustomersResponse, GetChannelApiKeysResponse, GetChannelCategoriesOptions, GetChannelCategoriesResponse, GetCategorySalesChannelsResponse, AssignCategoriesToChannelsBody, AssignCategoriesToChannelsResponse, UnassignCategoriesFromChannelsBody, UnassignCategoriesFromChannelsResponse, GetCollectionSalesChannelsResponse, AssignCollectionsToChannelsBody, AssignCollectionsToChannelsResponse, UnassignCollectionsFromChannelsBody, UnassignCollectionsFromChannelsResponse, GetAdminStorefrontConfigResponse, UpdateStorefrontConfigBody, UpdateStorefrontConfigResponse, GetAdminSiteConfigResponse, UpdateSiteConfigBody, UpdateSiteConfigResponse, GetAdminSiteConfigHistoryOptions, GetAdminSiteConfigHistoryResponse, RestoreSiteConfigResponse, OnboardDropshipperBody, OnboardDropshipperResponse, GetVariantCostsOptions, GetVariantCostsResponse, CreateVariantCostBody, CreateVariantCostResponse, BatchVariantCostsBody, BatchVariantCostsResponse, DeleteVariantCostResponse, GetDropshipperProductsOptions, GetDropshipperProductsResponse, UpdateDropshipperPricesBody, UpdateDropshipperPricesResponse, GetDropshipperOrdersOptions, GetDropshipperOrdersResponse, GetDropshipperOrderDetailResponse, GetDropshipperShippingOptionsParams, GetDropshipperShippingOptionsResponse, ExtendedCreateDropshipperOrderBody, ExtendedCreateDropshipperOrderResponse, SetPaymentCollectorBody, SetPaymentCollectorResponse, CancelDropshipperOrderResponse, CreateOrderEditBody, CreateOrderEditResponse, AddOrderEditItemBody, AddOrderEditItemResponse, ConfirmOrderEditResponse, GetOrderNotesResponse, CreateOrderNoteBody, OrderNote, DeleteOrderNoteResponse, GetProviderCategoriesResponse, GetDropshipperCategoriesOptions, GetDropshipperCategoriesResponse, CreateDropshipperCategoryBody, DropshipperCategory, UpdateDropshipperCategoryBody, DeleteDropshipperCategoryResponse, GetCategoryMappingsOptions, GetCategoryMappingsResponse, CreateCategoryMappingBody, CreateCategoryMappingResponse, DeleteCategoryMappingResponse, GetDropshipperCustomersOptions, GetDropshipperCustomersResponse, GetDropshipperCustomerDetailResponse, CreateDropshipperCustomerBody, CreateDropshipperCustomerResponse, GetDropshipperAddressesResponse, DropshipperAddressBody, DropshipperAddressResponse, GetDropshipperAccountResponse, GetDropshipperPayableResponse, GetDropshipperReceivableResponse, GetSettlementsOptions, GetSettlementsResponse, GetSettlementDetailResponse, CreateSettlementBody, CreateSettlementResponse, ConfirmSettlementBody, UpdateSettlementStatusResponse, CancelSettlementBody, GetAdminDropshipperAccountsResponse, GetAdminAccountBalanceResponse, GetAdminPriceListsResponse, GetUserChannelResponse, GetDropshipperPromotionsOptions, GetDropshipperPromotionsResponse, CreateDropshipperPromotionBody, DropshipperPromotion, UpdateDropshipperPromotionBody, DeleteDropshipperPromotionResponse, GetDashboardStatsOptions, GetDashboardStatsResponse, GetStorefrontDropshipperCategoriesResponse } from '@thorprovider/types';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @fileoverview Medusa Multi-Tenant Admin Client
|
|
@@ -256,12 +256,18 @@ declare class DropshipperClient {
|
|
|
256
256
|
* `GET /admin/thor/dropshipper/orders/:id`
|
|
257
257
|
*/
|
|
258
258
|
getOrder(orderId: string): Promise<GetDropshipperOrderDetailResponse>;
|
|
259
|
+
/**
|
|
260
|
+
* List shipping options for a manual dropshipper order.
|
|
261
|
+
*
|
|
262
|
+
* `GET /admin/thor/dropshipper/orders/shipping-options`
|
|
263
|
+
*/
|
|
264
|
+
getOrderShippingOptions(params: GetDropshipperShippingOptionsParams): Promise<GetDropshipperShippingOptionsResponse>;
|
|
259
265
|
/**
|
|
260
266
|
* Manually create an order on behalf of a customer.
|
|
261
267
|
*
|
|
262
268
|
* `POST /admin/thor/dropshipper/orders`
|
|
263
269
|
*/
|
|
264
|
-
createOrder(body:
|
|
270
|
+
createOrder(body: ExtendedCreateDropshipperOrderBody): Promise<ExtendedCreateDropshipperOrderResponse>;
|
|
265
271
|
/**
|
|
266
272
|
* Set who collects payment for an order (Solo X).
|
|
267
273
|
*
|
|
@@ -310,6 +316,12 @@ declare class DropshipperClient {
|
|
|
310
316
|
* `DELETE /admin/thor/dropshipper/orders/:id/notes/:noteId`
|
|
311
317
|
*/
|
|
312
318
|
deleteOrderNote(orderId: string, noteId: string): Promise<DeleteOrderNoteResponse>;
|
|
319
|
+
/**
|
|
320
|
+
* List Medusa provider categories linked to Y's channel (read-only).
|
|
321
|
+
*
|
|
322
|
+
* `GET /admin/thor/dropshipper/categories/provider`
|
|
323
|
+
*/
|
|
324
|
+
getProviderCategories(): Promise<GetProviderCategoriesResponse>;
|
|
313
325
|
/**
|
|
314
326
|
* List Y's custom product categories.
|
|
315
327
|
*
|
|
@@ -331,9 +343,19 @@ declare class DropshipperClient {
|
|
|
331
343
|
/**
|
|
332
344
|
* Delete a custom category.
|
|
333
345
|
*
|
|
346
|
+
* Pass `{ force: true }` to cascade-delete child categories.
|
|
347
|
+
*
|
|
334
348
|
* `DELETE /admin/thor/dropshipper/categories/:id`
|
|
335
349
|
*/
|
|
336
|
-
deleteCategory(categoryId: string
|
|
350
|
+
deleteCategory(categoryId: string, options?: {
|
|
351
|
+
force?: boolean;
|
|
352
|
+
}): Promise<DeleteDropshipperCategoryResponse>;
|
|
353
|
+
/**
|
|
354
|
+
* List product-to-category mappings, optionally filtered by product.
|
|
355
|
+
*
|
|
356
|
+
* `GET /admin/thor/dropshipper/category-mappings`
|
|
357
|
+
*/
|
|
358
|
+
getCategoryMappings(options?: GetCategoryMappingsOptions): Promise<GetCategoryMappingsResponse>;
|
|
337
359
|
/**
|
|
338
360
|
* Map a product to a custom category.
|
|
339
361
|
*
|
|
@@ -352,6 +374,10 @@ declare class DropshipperClient {
|
|
|
352
374
|
* `GET /admin/thor/dropshipper/customers`
|
|
353
375
|
*/
|
|
354
376
|
getCustomers(options?: GetDropshipperCustomersOptions): Promise<GetDropshipperCustomersResponse>;
|
|
377
|
+
/**
|
|
378
|
+
* Backwards-compatible alias used by the dashboard checkout flow.
|
|
379
|
+
*/
|
|
380
|
+
getChannelCustomers(_channelId: string, options?: GetDropshipperCustomersOptions): Promise<GetDropshipperCustomersResponse>;
|
|
355
381
|
/**
|
|
356
382
|
* Full detail for a single customer.
|
|
357
383
|
*
|
|
@@ -379,7 +405,7 @@ declare class DropshipperClient {
|
|
|
379
405
|
/**
|
|
380
406
|
* Update an existing customer address.
|
|
381
407
|
*
|
|
382
|
-
* `
|
|
408
|
+
* `POST /admin/thor/dropshipper/customers/:id/addresses/:addressId`
|
|
383
409
|
*/
|
|
384
410
|
updateCustomerAddress(customerId: string, addressId: string, body: Partial<DropshipperAddressBody>): Promise<DropshipperAddressResponse>;
|
|
385
411
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GetChannelCustomersOptions, GetChannelCustomersResponse, GetChannelApiKeysResponse, GetChannelCategoriesOptions, GetChannelCategoriesResponse, GetCategorySalesChannelsResponse, AssignCategoriesToChannelsBody, AssignCategoriesToChannelsResponse, UnassignCategoriesFromChannelsBody, UnassignCategoriesFromChannelsResponse, GetCollectionSalesChannelsResponse, AssignCollectionsToChannelsBody, AssignCollectionsToChannelsResponse, UnassignCollectionsFromChannelsBody, UnassignCollectionsFromChannelsResponse, GetAdminStorefrontConfigResponse, UpdateStorefrontConfigBody, UpdateStorefrontConfigResponse, GetAdminSiteConfigResponse, UpdateSiteConfigBody, UpdateSiteConfigResponse, GetAdminSiteConfigHistoryOptions, GetAdminSiteConfigHistoryResponse, RestoreSiteConfigResponse, OnboardDropshipperBody, OnboardDropshipperResponse, GetVariantCostsOptions, GetVariantCostsResponse, CreateVariantCostBody, CreateVariantCostResponse, BatchVariantCostsBody, BatchVariantCostsResponse, DeleteVariantCostResponse, GetDropshipperProductsOptions, GetDropshipperProductsResponse, UpdateDropshipperPricesBody, UpdateDropshipperPricesResponse, GetDropshipperOrdersOptions, GetDropshipperOrdersResponse, GetDropshipperOrderDetailResponse,
|
|
1
|
+
import { GetChannelCustomersOptions, GetChannelCustomersResponse, GetChannelApiKeysResponse, GetChannelCategoriesOptions, GetChannelCategoriesResponse, GetCategorySalesChannelsResponse, AssignCategoriesToChannelsBody, AssignCategoriesToChannelsResponse, UnassignCategoriesFromChannelsBody, UnassignCategoriesFromChannelsResponse, GetCollectionSalesChannelsResponse, AssignCollectionsToChannelsBody, AssignCollectionsToChannelsResponse, UnassignCollectionsFromChannelsBody, UnassignCollectionsFromChannelsResponse, GetAdminStorefrontConfigResponse, UpdateStorefrontConfigBody, UpdateStorefrontConfigResponse, GetAdminSiteConfigResponse, UpdateSiteConfigBody, UpdateSiteConfigResponse, GetAdminSiteConfigHistoryOptions, GetAdminSiteConfigHistoryResponse, RestoreSiteConfigResponse, OnboardDropshipperBody, OnboardDropshipperResponse, GetVariantCostsOptions, GetVariantCostsResponse, CreateVariantCostBody, CreateVariantCostResponse, BatchVariantCostsBody, BatchVariantCostsResponse, DeleteVariantCostResponse, GetDropshipperProductsOptions, GetDropshipperProductsResponse, UpdateDropshipperPricesBody, UpdateDropshipperPricesResponse, GetDropshipperOrdersOptions, GetDropshipperOrdersResponse, GetDropshipperOrderDetailResponse, GetDropshipperShippingOptionsParams, GetDropshipperShippingOptionsResponse, ExtendedCreateDropshipperOrderBody, ExtendedCreateDropshipperOrderResponse, SetPaymentCollectorBody, SetPaymentCollectorResponse, CancelDropshipperOrderResponse, CreateOrderEditBody, CreateOrderEditResponse, AddOrderEditItemBody, AddOrderEditItemResponse, ConfirmOrderEditResponse, GetOrderNotesResponse, CreateOrderNoteBody, OrderNote, DeleteOrderNoteResponse, GetProviderCategoriesResponse, GetDropshipperCategoriesOptions, GetDropshipperCategoriesResponse, CreateDropshipperCategoryBody, DropshipperCategory, UpdateDropshipperCategoryBody, DeleteDropshipperCategoryResponse, GetCategoryMappingsOptions, GetCategoryMappingsResponse, CreateCategoryMappingBody, CreateCategoryMappingResponse, DeleteCategoryMappingResponse, GetDropshipperCustomersOptions, GetDropshipperCustomersResponse, GetDropshipperCustomerDetailResponse, CreateDropshipperCustomerBody, CreateDropshipperCustomerResponse, GetDropshipperAddressesResponse, DropshipperAddressBody, DropshipperAddressResponse, GetDropshipperAccountResponse, GetDropshipperPayableResponse, GetDropshipperReceivableResponse, GetSettlementsOptions, GetSettlementsResponse, GetSettlementDetailResponse, CreateSettlementBody, CreateSettlementResponse, ConfirmSettlementBody, UpdateSettlementStatusResponse, CancelSettlementBody, GetAdminDropshipperAccountsResponse, GetAdminAccountBalanceResponse, GetAdminPriceListsResponse, GetUserChannelResponse, GetDropshipperPromotionsOptions, GetDropshipperPromotionsResponse, CreateDropshipperPromotionBody, DropshipperPromotion, UpdateDropshipperPromotionBody, DeleteDropshipperPromotionResponse, GetDashboardStatsOptions, GetDashboardStatsResponse, GetStorefrontDropshipperCategoriesResponse } from '@thorprovider/types';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @fileoverview Medusa Multi-Tenant Admin Client
|
|
@@ -256,12 +256,18 @@ declare class DropshipperClient {
|
|
|
256
256
|
* `GET /admin/thor/dropshipper/orders/:id`
|
|
257
257
|
*/
|
|
258
258
|
getOrder(orderId: string): Promise<GetDropshipperOrderDetailResponse>;
|
|
259
|
+
/**
|
|
260
|
+
* List shipping options for a manual dropshipper order.
|
|
261
|
+
*
|
|
262
|
+
* `GET /admin/thor/dropshipper/orders/shipping-options`
|
|
263
|
+
*/
|
|
264
|
+
getOrderShippingOptions(params: GetDropshipperShippingOptionsParams): Promise<GetDropshipperShippingOptionsResponse>;
|
|
259
265
|
/**
|
|
260
266
|
* Manually create an order on behalf of a customer.
|
|
261
267
|
*
|
|
262
268
|
* `POST /admin/thor/dropshipper/orders`
|
|
263
269
|
*/
|
|
264
|
-
createOrder(body:
|
|
270
|
+
createOrder(body: ExtendedCreateDropshipperOrderBody): Promise<ExtendedCreateDropshipperOrderResponse>;
|
|
265
271
|
/**
|
|
266
272
|
* Set who collects payment for an order (Solo X).
|
|
267
273
|
*
|
|
@@ -310,6 +316,12 @@ declare class DropshipperClient {
|
|
|
310
316
|
* `DELETE /admin/thor/dropshipper/orders/:id/notes/:noteId`
|
|
311
317
|
*/
|
|
312
318
|
deleteOrderNote(orderId: string, noteId: string): Promise<DeleteOrderNoteResponse>;
|
|
319
|
+
/**
|
|
320
|
+
* List Medusa provider categories linked to Y's channel (read-only).
|
|
321
|
+
*
|
|
322
|
+
* `GET /admin/thor/dropshipper/categories/provider`
|
|
323
|
+
*/
|
|
324
|
+
getProviderCategories(): Promise<GetProviderCategoriesResponse>;
|
|
313
325
|
/**
|
|
314
326
|
* List Y's custom product categories.
|
|
315
327
|
*
|
|
@@ -331,9 +343,19 @@ declare class DropshipperClient {
|
|
|
331
343
|
/**
|
|
332
344
|
* Delete a custom category.
|
|
333
345
|
*
|
|
346
|
+
* Pass `{ force: true }` to cascade-delete child categories.
|
|
347
|
+
*
|
|
334
348
|
* `DELETE /admin/thor/dropshipper/categories/:id`
|
|
335
349
|
*/
|
|
336
|
-
deleteCategory(categoryId: string
|
|
350
|
+
deleteCategory(categoryId: string, options?: {
|
|
351
|
+
force?: boolean;
|
|
352
|
+
}): Promise<DeleteDropshipperCategoryResponse>;
|
|
353
|
+
/**
|
|
354
|
+
* List product-to-category mappings, optionally filtered by product.
|
|
355
|
+
*
|
|
356
|
+
* `GET /admin/thor/dropshipper/category-mappings`
|
|
357
|
+
*/
|
|
358
|
+
getCategoryMappings(options?: GetCategoryMappingsOptions): Promise<GetCategoryMappingsResponse>;
|
|
337
359
|
/**
|
|
338
360
|
* Map a product to a custom category.
|
|
339
361
|
*
|
|
@@ -352,6 +374,10 @@ declare class DropshipperClient {
|
|
|
352
374
|
* `GET /admin/thor/dropshipper/customers`
|
|
353
375
|
*/
|
|
354
376
|
getCustomers(options?: GetDropshipperCustomersOptions): Promise<GetDropshipperCustomersResponse>;
|
|
377
|
+
/**
|
|
378
|
+
* Backwards-compatible alias used by the dashboard checkout flow.
|
|
379
|
+
*/
|
|
380
|
+
getChannelCustomers(_channelId: string, options?: GetDropshipperCustomersOptions): Promise<GetDropshipperCustomersResponse>;
|
|
355
381
|
/**
|
|
356
382
|
* Full detail for a single customer.
|
|
357
383
|
*
|
|
@@ -379,7 +405,7 @@ declare class DropshipperClient {
|
|
|
379
405
|
/**
|
|
380
406
|
* Update an existing customer address.
|
|
381
407
|
*
|
|
382
|
-
* `
|
|
408
|
+
* `POST /admin/thor/dropshipper/customers/:id/addresses/:addressId`
|
|
383
409
|
*/
|
|
384
410
|
updateCustomerAddress(customerId: string, addressId: string, body: Partial<DropshipperAddressBody>): Promise<DropshipperAddressResponse>;
|
|
385
411
|
/**
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,69 @@ __export(src_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(src_exports);
|
|
27
27
|
|
|
28
28
|
// src/admin.ts
|
|
29
|
+
var import_adapters2 = require("@thorprovider/adapters");
|
|
30
|
+
|
|
31
|
+
// src/request-resilience.ts
|
|
29
32
|
var import_adapters = require("@thorprovider/adapters");
|
|
33
|
+
var DEFAULT_RETRY_CONFIG = {
|
|
34
|
+
maxRetries: 3,
|
|
35
|
+
initialDelayMs: 300,
|
|
36
|
+
backoffMultiplier: 2,
|
|
37
|
+
maxDelayMs: 5e3,
|
|
38
|
+
timeoutMs: 1e4,
|
|
39
|
+
retryableStatusCodes: [408, 429, 500, 502, 503, 504]
|
|
40
|
+
};
|
|
41
|
+
function sleep(ms) {
|
|
42
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
43
|
+
}
|
|
44
|
+
function calculateDelay(attempt, config) {
|
|
45
|
+
const delay = config.initialDelayMs * Math.pow(config.backoffMultiplier, attempt);
|
|
46
|
+
return Math.min(delay, config.maxDelayMs);
|
|
47
|
+
}
|
|
48
|
+
function isRetryableError(error, config) {
|
|
49
|
+
const err = error;
|
|
50
|
+
if (err.name === "TypeError" || err.message?.includes("fetch failed")) return true;
|
|
51
|
+
if (err.name === "AbortError" || err.message?.includes("timeout")) return true;
|
|
52
|
+
if (typeof err.status === "number" && config.retryableStatusCodes.includes(err.status)) return true;
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
async function fetchWithRetry(url, init, retryConfig) {
|
|
56
|
+
const config = { ...DEFAULT_RETRY_CONFIG, ...retryConfig };
|
|
57
|
+
let lastError;
|
|
58
|
+
for (let attempt = 0; attempt <= config.maxRetries; attempt++) {
|
|
59
|
+
try {
|
|
60
|
+
const controller = new AbortController();
|
|
61
|
+
const timeoutId = setTimeout(() => controller.abort(), config.timeoutMs);
|
|
62
|
+
const response = await fetch(url, { ...init, signal: controller.signal });
|
|
63
|
+
clearTimeout(timeoutId);
|
|
64
|
+
if (!response.ok && config.retryableStatusCodes.includes(response.status)) {
|
|
65
|
+
const error = new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
66
|
+
error.status = response.status;
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
return response;
|
|
70
|
+
} catch (error) {
|
|
71
|
+
lastError = error;
|
|
72
|
+
const shouldRetry = attempt < config.maxRetries && isRetryableError(error, config);
|
|
73
|
+
if (shouldRetry) {
|
|
74
|
+
await sleep(calculateDelay(attempt, config));
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
throw lastError instanceof Error ? lastError : new Error("Backend request failed");
|
|
81
|
+
}
|
|
82
|
+
async function fetchBackendWithResilience(url, init, retryConfig) {
|
|
83
|
+
try {
|
|
84
|
+
return await import_adapters.backendCircuitBreaker.execute(() => fetchWithRetry(url, init, retryConfig));
|
|
85
|
+
} catch (error) {
|
|
86
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
87
|
+
throw new import_adapters.ProviderAPIError(`Backend request failed: ${message}`, "backend", 503);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// src/admin.ts
|
|
30
92
|
var MedusaAdminClient = class {
|
|
31
93
|
baseUrl;
|
|
32
94
|
apiKey;
|
|
@@ -34,7 +96,7 @@ var MedusaAdminClient = class {
|
|
|
34
96
|
constructor(config) {
|
|
35
97
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
36
98
|
this.apiKey = config.apiKey;
|
|
37
|
-
this.logger = (0,
|
|
99
|
+
this.logger = (0, import_adapters2.createLogger)("MedusaAdminClient", config.debug);
|
|
38
100
|
}
|
|
39
101
|
// -----------------------------------------------------------------------
|
|
40
102
|
// Private — HTTP helper
|
|
@@ -53,9 +115,9 @@ var MedusaAdminClient = class {
|
|
|
53
115
|
};
|
|
54
116
|
let response;
|
|
55
117
|
try {
|
|
56
|
-
response = await
|
|
118
|
+
response = await fetchBackendWithResilience(url, init);
|
|
57
119
|
} catch (networkError) {
|
|
58
|
-
throw new
|
|
120
|
+
throw new import_adapters2.ProviderAPIError(
|
|
59
121
|
`[admin] Network error on ${method} ${path}: ${networkError.message}`,
|
|
60
122
|
"NETWORK_ERROR",
|
|
61
123
|
networkError
|
|
@@ -68,7 +130,7 @@ var MedusaAdminClient = class {
|
|
|
68
130
|
message = json?.message ?? message;
|
|
69
131
|
} catch {
|
|
70
132
|
}
|
|
71
|
-
throw new
|
|
133
|
+
throw new import_adapters2.ProviderAPIError(
|
|
72
134
|
`[admin] ${method} ${path} failed: ${message}`,
|
|
73
135
|
`ADMIN_API_${response.status}`,
|
|
74
136
|
response.status
|
|
@@ -311,7 +373,7 @@ var MedusaAdminClient = class {
|
|
|
311
373
|
};
|
|
312
374
|
|
|
313
375
|
// src/dropshipper.ts
|
|
314
|
-
var
|
|
376
|
+
var import_adapters3 = require("@thorprovider/adapters");
|
|
315
377
|
var DropshipperClient = class {
|
|
316
378
|
baseUrl;
|
|
317
379
|
token;
|
|
@@ -319,7 +381,7 @@ var DropshipperClient = class {
|
|
|
319
381
|
constructor(config) {
|
|
320
382
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
321
383
|
this.token = config.token;
|
|
322
|
-
this.logger = (0,
|
|
384
|
+
this.logger = (0, import_adapters3.createLogger)("DropshipperClient", config.debug);
|
|
323
385
|
}
|
|
324
386
|
// -------------------------------------------------------------------------
|
|
325
387
|
// Private — HTTP helper
|
|
@@ -338,9 +400,9 @@ var DropshipperClient = class {
|
|
|
338
400
|
};
|
|
339
401
|
let response;
|
|
340
402
|
try {
|
|
341
|
-
response = await
|
|
403
|
+
response = await fetchBackendWithResilience(url, init);
|
|
342
404
|
} catch (networkError) {
|
|
343
|
-
throw new
|
|
405
|
+
throw new import_adapters3.ProviderAPIError(
|
|
344
406
|
`[dropshipper] Network error on ${method} ${path}: ${networkError.message}`,
|
|
345
407
|
"NETWORK_ERROR",
|
|
346
408
|
networkError
|
|
@@ -353,7 +415,7 @@ var DropshipperClient = class {
|
|
|
353
415
|
message = json?.message ?? message;
|
|
354
416
|
} catch {
|
|
355
417
|
}
|
|
356
|
-
throw new
|
|
418
|
+
throw new import_adapters3.ProviderAPIError(
|
|
357
419
|
`[dropshipper] ${method} ${path} failed: ${message}`,
|
|
358
420
|
`DROPSHIPPER_API_${response.status}`,
|
|
359
421
|
response.status
|
|
@@ -507,6 +569,21 @@ var DropshipperClient = class {
|
|
|
507
569
|
`/admin/thor/dropshipper/orders/${orderId}`
|
|
508
570
|
);
|
|
509
571
|
}
|
|
572
|
+
/**
|
|
573
|
+
* List shipping options for a manual dropshipper order.
|
|
574
|
+
*
|
|
575
|
+
* `GET /admin/thor/dropshipper/orders/shipping-options`
|
|
576
|
+
*/
|
|
577
|
+
async getOrderShippingOptions(params) {
|
|
578
|
+
const qs = new URLSearchParams({
|
|
579
|
+
currency_code: params.currency_code.toLowerCase(),
|
|
580
|
+
...params.country_code ? { country_code: params.country_code.toLowerCase() } : {}
|
|
581
|
+
});
|
|
582
|
+
return this.request(
|
|
583
|
+
"GET",
|
|
584
|
+
`/admin/thor/dropshipper/orders/shipping-options?${qs}`
|
|
585
|
+
);
|
|
586
|
+
}
|
|
510
587
|
/**
|
|
511
588
|
* Manually create an order on behalf of a customer.
|
|
512
589
|
*
|
|
@@ -617,6 +694,17 @@ var DropshipperClient = class {
|
|
|
617
694
|
// -------------------------------------------------------------------------
|
|
618
695
|
// Custom Categories (Solo Y)
|
|
619
696
|
// -------------------------------------------------------------------------
|
|
697
|
+
/**
|
|
698
|
+
* List Medusa provider categories linked to Y's channel (read-only).
|
|
699
|
+
*
|
|
700
|
+
* `GET /admin/thor/dropshipper/categories/provider`
|
|
701
|
+
*/
|
|
702
|
+
async getProviderCategories() {
|
|
703
|
+
return this.request(
|
|
704
|
+
"GET",
|
|
705
|
+
"/admin/thor/dropshipper/categories/provider"
|
|
706
|
+
);
|
|
707
|
+
}
|
|
620
708
|
/**
|
|
621
709
|
* List Y's custom product categories.
|
|
622
710
|
*
|
|
@@ -661,12 +749,27 @@ var DropshipperClient = class {
|
|
|
661
749
|
/**
|
|
662
750
|
* Delete a custom category.
|
|
663
751
|
*
|
|
752
|
+
* Pass `{ force: true }` to cascade-delete child categories.
|
|
753
|
+
*
|
|
664
754
|
* `DELETE /admin/thor/dropshipper/categories/:id`
|
|
665
755
|
*/
|
|
666
|
-
async deleteCategory(categoryId) {
|
|
756
|
+
async deleteCategory(categoryId, options = {}) {
|
|
757
|
+
const qs = options.force ? "?force=true" : "";
|
|
667
758
|
return this.request(
|
|
668
759
|
"DELETE",
|
|
669
|
-
`/admin/thor/dropshipper/categories/${categoryId}`
|
|
760
|
+
`/admin/thor/dropshipper/categories/${categoryId}${qs}`
|
|
761
|
+
);
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* List product-to-category mappings, optionally filtered by product.
|
|
765
|
+
*
|
|
766
|
+
* `GET /admin/thor/dropshipper/category-mappings`
|
|
767
|
+
*/
|
|
768
|
+
async getCategoryMappings(options = {}) {
|
|
769
|
+
const qs = options.product_id ? `?product_id=${options.product_id}` : "";
|
|
770
|
+
return this.request(
|
|
771
|
+
"GET",
|
|
772
|
+
`/admin/thor/dropshipper/category-mappings${qs}`
|
|
670
773
|
);
|
|
671
774
|
}
|
|
672
775
|
/**
|
|
@@ -714,6 +817,12 @@ var DropshipperClient = class {
|
|
|
714
817
|
`/admin/thor/dropshipper/customers?${qs}`
|
|
715
818
|
);
|
|
716
819
|
}
|
|
820
|
+
/**
|
|
821
|
+
* Backwards-compatible alias used by the dashboard checkout flow.
|
|
822
|
+
*/
|
|
823
|
+
async getChannelCustomers(_channelId, options = {}) {
|
|
824
|
+
return this.getCustomers(options);
|
|
825
|
+
}
|
|
717
826
|
/**
|
|
718
827
|
* Full detail for a single customer.
|
|
719
828
|
*
|
|
@@ -766,11 +875,11 @@ var DropshipperClient = class {
|
|
|
766
875
|
/**
|
|
767
876
|
* Update an existing customer address.
|
|
768
877
|
*
|
|
769
|
-
* `
|
|
878
|
+
* `POST /admin/thor/dropshipper/customers/:id/addresses/:addressId`
|
|
770
879
|
*/
|
|
771
880
|
async updateCustomerAddress(customerId, addressId, body) {
|
|
772
881
|
return this.request(
|
|
773
|
-
"
|
|
882
|
+
"POST",
|
|
774
883
|
`/admin/thor/dropshipper/customers/${customerId}/addresses/${addressId}`,
|
|
775
884
|
body
|
|
776
885
|
);
|