@thorprovider/medusa-extended 1.11.5 → 1.11.7
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/dist/index.d.mts +44 -5
- package/dist/index.d.ts +44 -5
- package/dist/index.js +88 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +88 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/dropshipper.test.ts +4 -4
- package/src/dropshipper.ts +106 -6
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, ChatIntent, ChatSource, DropshipperDashboardCapabilities, GetMyProfileResponse, ChatRequest, ChatResponse, GetNotificationsOptions, GetNotificationsResponse, OnboardDropshipperBody, OnboardDropshipperResponse, GetDropshipperProductsOptions, GetDropshipperProductsResponse, ValidateCheckoutItemsRequest, ValidateCheckoutItemsResponse, CostPriceChangesCheckResponse, CostPriceChangesResponse, AcknowledgeCostPriceChangesResponse, UpdateDropshipperProductStatusBody, UpdateDropshipperProductStatusResponse, GetProductAttributesResponse, GetDropshipperAttributesResponse, UpdateDropshipperPricesBody, UpdateDropshipperPricesResponse, GetDropshipperOrdersOptions, GetDropshipperOrdersResponse, GetDropshipperOrderDetailResponse, GetDropshipperShippingOptionsParams, GetDropshipperShippingOptionsResponse, ExtendedCreateDropshipperOrderBody, ExtendedCreateDropshipperOrderResponse, SetPaymentCollectorBody, SetPaymentCollectorResponse, SetPaymentMethodBody, SetPaymentMethodResponse, CancelDropshipperOrderResponse, CreateOrderEditBody, CreateOrderEditResponse, AddOrderEditItemBody, AddOrderEditItemResponse, ConfirmOrderEditResponse, GetOrderNotesResponse, CreateOrderNoteBody, CreateOrderNoteResponse, DeleteOrderNoteResponse, GetProviderCategoriesResponse, GetDropshipperCategoriesOptions, GetDropshipperCategoriesResponse, CreateDropshipperCategoryBody, DropshipperCategory, UpdateDropshipperCategoryBody, DeleteDropshipperCategoryResponse, GetCategoryMappingsOptions, GetCategoryMappingsResponse, CreateCategoryMappingBody, CreateCategoryMappingResponse, DeleteCategoryMappingResponse, GetDropshipperCustomersOptions, GetDropshipperCustomersResponse, GetDropshipperCustomerDetailResponse, CreateDropshipperCustomerBody, CreateDropshipperCustomerResponse, UpdateDropshipperCustomerBody, UpdateDropshipperCustomerResponse, GetDropshipperAddressesResponse, DropshipperAddressBody, DropshipperAddressResponse, GetDropshipperAccountResponse, GetDropshipperPayableResponse, GetDropshipperReceivableResponse, GetSettlementsOptions, GetSettlementsResponse, GetSettlementDetailResponse, GetDropshipperAccountBalanceResponse, GetDropshipperAccountOrdersOptions, GetDropshipperAccountOrdersResponse, CreateSettlementBody, CreateSettlementResponse, ConfirmSettlementBody, UpdateSettlementStatusResponse, CancelSettlementBody, GetAdminDropshipperAccountsResponse, GetAdminAccountBalanceResponse, GetAdminPriceListsResponse, GetUserChannelResponse, GetAdminDropshipperAccountOrdersResponse, GetAdminDropshipperAccountSettlementsOptions, GetAdminDropshipperAccountSettlementsResponse, ResolveGuaranteeBody, ResolveGuaranteeResponse, CreateCompensacionBody, CreateCompensacionResponse, CreateAjusteBody, CreateAjusteResponse, CreateCobroBody, CreateCobroResponse, CreatePagoBody, CreatePagoResponse, CreateReversoBody, CreateReversoResponse, ConfirmMovementBody, ConfirmMovementResponse, CancelMovementBody, CancelMovementResponse, GetFinancialAnalysisResponse, RegisterPaymentBody, RegisterPaymentResponse, GetDropshipperPromotionsOptions, GetDropshipperPromotionsResponse, CreateDropshipperPromotionBody, DropshipperPromotion, UpdateDropshipperPromotionBody, DeleteDropshipperPromotionResponse, GetDashboardStatsOptions, GetDashboardStatsResponse, GetStorefrontDropshipperCategoriesResponse, GetDropshipperDraftOrdersOptions, GetDropshipperDraftOrdersResponse, GetDropshipperDraftOrderDetailResponse, CreateDropshipperDraftOrderBody, CreateDropshipperDraftOrderResponse, UpdateDropshipperDraftOrderBody, UpdateDropshipperDraftOrderResponse, ConvertDropshipperDraftOrderBody, ConvertDropshipperDraftOrderResponse, DeleteDropshipperDraftOrderResponse, GetGeoCountriesResponse, GetGeoProvincesResponse, GetGeoCitiesResponse } from '@thorprovider/types';
|
|
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, ChatIntent, ChatSource, QueryEntitiesInput, QueryResponse, DropshipperDashboardCapabilities, GetMyProfileResponse, ChatRequest, ChatResponse, ChatAssistantHealthResponse, GetNotificationsOptions, GetNotificationsResponse, OnboardDropshipperBody, OnboardDropshipperResponse, GetDropshipperProductsOptions, GetDropshipperProductsResponse, ValidateCheckoutItemsRequest, ValidateCheckoutItemsResponse, CostPriceChangesCheckResponse, CostPriceChangesResponse, AcknowledgeCostPriceChangesResponse, UpdateDropshipperProductStatusBody, UpdateDropshipperProductStatusResponse, GetProductAttributesResponse, GetDropshipperAttributesResponse, UpdateDropshipperPricesBody, UpdateDropshipperPricesResponse, GetDropshipperOrdersOptions, GetDropshipperOrdersResponse, GetDropshipperOrderDetailResponse, GetDropshipperShippingOptionsParams, GetDropshipperShippingOptionsResponse, ExtendedCreateDropshipperOrderBody, ExtendedCreateDropshipperOrderResponse, SetPaymentCollectorBody, SetPaymentCollectorResponse, SetPaymentMethodBody, SetPaymentMethodResponse, CancelDropshipperOrderResponse, CreateOrderEditBody, CreateOrderEditResponse, AddOrderEditItemBody, AddOrderEditItemResponse, ConfirmOrderEditResponse, GetOrderNotesResponse, CreateOrderNoteBody, CreateOrderNoteResponse, DeleteOrderNoteResponse, GetProviderCategoriesResponse, GetDropshipperCategoriesOptions, GetDropshipperCategoriesResponse, CreateDropshipperCategoryBody, DropshipperCategory, UpdateDropshipperCategoryBody, DeleteDropshipperCategoryResponse, GetCategoryMappingsOptions, GetCategoryMappingsResponse, CreateCategoryMappingBody, CreateCategoryMappingResponse, DeleteCategoryMappingResponse, GetDropshipperCustomersOptions, GetDropshipperCustomersResponse, GetDropshipperCustomerDetailResponse, CreateDropshipperCustomerBody, CreateDropshipperCustomerResponse, UpdateDropshipperCustomerBody, UpdateDropshipperCustomerResponse, GetDropshipperAddressesResponse, DropshipperAddressBody, DropshipperAddressResponse, GetDropshipperAccountResponse, GetDropshipperPayableResponse, GetDropshipperReceivableResponse, GetSettlementsOptions, GetSettlementsResponse, GetSettlementDetailResponse, GetDropshipperAccountBalanceResponse, GetDropshipperAccountOrdersOptions, GetDropshipperAccountOrdersResponse, CreateSettlementBody, CreateSettlementResponse, ConfirmSettlementBody, UpdateSettlementStatusResponse, CancelSettlementBody, GetAdminDropshipperAccountsResponse, GetAdminAccountBalanceResponse, GetAdminPriceListsResponse, GetUserChannelResponse, GetAdminDropshipperAccountOrdersResponse, GetAdminDropshipperAccountSettlementsOptions, GetAdminDropshipperAccountSettlementsResponse, ResolveGuaranteeBody, ResolveGuaranteeResponse, CreateCompensacionBody, CreateCompensacionResponse, CreateAjusteBody, CreateAjusteResponse, CreateCobroBody, CreateCobroResponse, CreatePagoBody, CreatePagoResponse, CreateReversoBody, CreateReversoResponse, ConfirmMovementBody, ConfirmMovementResponse, CancelMovementBody, CancelMovementResponse, GetFinancialAnalysisResponse, RegisterPaymentBody, RegisterPaymentResponse, GetDropshipperPromotionsOptions, GetDropshipperPromotionsResponse, CreateDropshipperPromotionBody, DropshipperPromotion, UpdateDropshipperPromotionBody, DeleteDropshipperPromotionResponse, GetDashboardStatsOptions, GetDashboardStatsResponse, GetStorefrontDropshipperCategoriesResponse, GetDropshipperDraftOrdersOptions, GetDropshipperDraftOrdersResponse, GetDropshipperDraftOrderDetailResponse, CreateDropshipperDraftOrderBody, CreateDropshipperDraftOrderResponse, UpdateDropshipperDraftOrderBody, UpdateDropshipperDraftOrderResponse, ConvertDropshipperDraftOrderBody, ConvertDropshipperDraftOrderResponse, DeleteDropshipperDraftOrderResponse, GetGeoCountriesResponse, GetGeoProvincesResponse, GetGeoCitiesResponse } from '@thorprovider/types';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @fileoverview Medusa Multi-Tenant Admin Client
|
|
@@ -167,8 +167,8 @@ declare class MedusaAdminClient {
|
|
|
167
167
|
* One event from the streamed AI assistant chat (`chatAssistantStream`).
|
|
168
168
|
*
|
|
169
169
|
* The backend returns a UI-message stream (SSE over `text/event-stream`) for
|
|
170
|
-
* catalog searches, and a plain JSON `ChatResponse` for
|
|
171
|
-
*
|
|
170
|
+
* catalog searches, and a plain JSON `ChatResponse` for `default` intents.
|
|
171
|
+
* `chatAssistantStream` normalizes both into this single event type so
|
|
172
172
|
* consumers can render incremental text and update the "thinking" label as the
|
|
173
173
|
* model progresses without knowing the transport details.
|
|
174
174
|
*/
|
|
@@ -183,7 +183,7 @@ type ChatStreamEvent = {
|
|
|
183
183
|
} | {
|
|
184
184
|
type: 'finish';
|
|
185
185
|
intent: ChatIntent;
|
|
186
|
-
/** Products referenced by the answer (empty for
|
|
186
|
+
/** Products referenced by the answer (empty for `default` intents). */
|
|
187
187
|
sources: ChatSource[];
|
|
188
188
|
} | {
|
|
189
189
|
type: 'error';
|
|
@@ -228,6 +228,28 @@ declare class DropshipperClient {
|
|
|
228
228
|
private logger;
|
|
229
229
|
constructor(config: DropshipperClientConfig);
|
|
230
230
|
private request;
|
|
231
|
+
/**
|
|
232
|
+
* Resolve multiple entities in a single request.
|
|
233
|
+
*
|
|
234
|
+
* `POST /admin/thor/dropshipper/query`
|
|
235
|
+
*
|
|
236
|
+
* Entities are resolved in parallel (per layer) and errors are isolated per
|
|
237
|
+
* entity: `response.errors[key]` holds the per-entity error while the rest
|
|
238
|
+
* of `data` still resolves. `data[key]` is an array (list entities) or a
|
|
239
|
+
* single object (singular entities such as account, balance, me).
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```typescript
|
|
243
|
+
* const { data } = await client.query({
|
|
244
|
+
* entities: [
|
|
245
|
+
* { entity: 'capabilities' },
|
|
246
|
+
* { entity: 'me' },
|
|
247
|
+
* { entity: 'account' },
|
|
248
|
+
* ],
|
|
249
|
+
* });
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
query(input: QueryEntitiesInput): Promise<QueryResponse>;
|
|
231
253
|
/**
|
|
232
254
|
* Fetch dashboard capabilities from the backend.
|
|
233
255
|
*
|
|
@@ -261,13 +283,30 @@ declare class DropshipperClient {
|
|
|
261
283
|
*
|
|
262
284
|
* Unlike `chatAssistant`, this surfaces the model's progress: the backend
|
|
263
285
|
* resolves the intent first and then streams the answer token by token
|
|
264
|
-
* (catalog searches) or returns the full answer in one shot (
|
|
286
|
+
* (catalog searches) or returns the full answer in one shot (`default`).
|
|
265
287
|
* The response is normalized into a single `ReadableStream<ChatStreamEvent>`
|
|
266
288
|
* so callers can show a live "thinking" label and render text incrementally.
|
|
267
289
|
*
|
|
268
290
|
* `POST /admin/thor/dropshipper/ai/chat`
|
|
269
291
|
*/
|
|
270
292
|
chatAssistantStream(body: ChatRequest): Promise<ReadableStream<ChatStreamEvent>>;
|
|
293
|
+
/**
|
|
294
|
+
* Cheap liveness probe for the AI assistant.
|
|
295
|
+
*
|
|
296
|
+
* The backend performs no LLM or retrieval work, so this is safe to poll
|
|
297
|
+
* (e.g. from a dashboard availability indicator). Returns 200 with
|
|
298
|
+
* `available: true` when the assistant is configured; the backend answers
|
|
299
|
+
* HTTP 503 with `available: false` when `AI_GATEWAY_API_KEY` is missing.
|
|
300
|
+
*
|
|
301
|
+
* Deliberately does NOT go through `fetchBackendWithResilience`: that layer
|
|
302
|
+
* funnels every call through the SHARED `backendCircuitBreaker`, and the
|
|
303
|
+
* definitive 503 "not configured" answer would count as failures and could
|
|
304
|
+
* open the circuit, taking down all dropshipper API traffic. A health probe
|
|
305
|
+
* must stay isolated, with no retries and a short timeout.
|
|
306
|
+
*
|
|
307
|
+
* `GET /admin/thor/dropshipper/ai/health`
|
|
308
|
+
*/
|
|
309
|
+
chatAssistantHealth(): Promise<ChatAssistantHealthResponse>;
|
|
271
310
|
/**
|
|
272
311
|
* List feed notifications for the authenticated dropshipper.
|
|
273
312
|
*
|
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, ChatIntent, ChatSource, DropshipperDashboardCapabilities, GetMyProfileResponse, ChatRequest, ChatResponse, GetNotificationsOptions, GetNotificationsResponse, OnboardDropshipperBody, OnboardDropshipperResponse, GetDropshipperProductsOptions, GetDropshipperProductsResponse, ValidateCheckoutItemsRequest, ValidateCheckoutItemsResponse, CostPriceChangesCheckResponse, CostPriceChangesResponse, AcknowledgeCostPriceChangesResponse, UpdateDropshipperProductStatusBody, UpdateDropshipperProductStatusResponse, GetProductAttributesResponse, GetDropshipperAttributesResponse, UpdateDropshipperPricesBody, UpdateDropshipperPricesResponse, GetDropshipperOrdersOptions, GetDropshipperOrdersResponse, GetDropshipperOrderDetailResponse, GetDropshipperShippingOptionsParams, GetDropshipperShippingOptionsResponse, ExtendedCreateDropshipperOrderBody, ExtendedCreateDropshipperOrderResponse, SetPaymentCollectorBody, SetPaymentCollectorResponse, SetPaymentMethodBody, SetPaymentMethodResponse, CancelDropshipperOrderResponse, CreateOrderEditBody, CreateOrderEditResponse, AddOrderEditItemBody, AddOrderEditItemResponse, ConfirmOrderEditResponse, GetOrderNotesResponse, CreateOrderNoteBody, CreateOrderNoteResponse, DeleteOrderNoteResponse, GetProviderCategoriesResponse, GetDropshipperCategoriesOptions, GetDropshipperCategoriesResponse, CreateDropshipperCategoryBody, DropshipperCategory, UpdateDropshipperCategoryBody, DeleteDropshipperCategoryResponse, GetCategoryMappingsOptions, GetCategoryMappingsResponse, CreateCategoryMappingBody, CreateCategoryMappingResponse, DeleteCategoryMappingResponse, GetDropshipperCustomersOptions, GetDropshipperCustomersResponse, GetDropshipperCustomerDetailResponse, CreateDropshipperCustomerBody, CreateDropshipperCustomerResponse, UpdateDropshipperCustomerBody, UpdateDropshipperCustomerResponse, GetDropshipperAddressesResponse, DropshipperAddressBody, DropshipperAddressResponse, GetDropshipperAccountResponse, GetDropshipperPayableResponse, GetDropshipperReceivableResponse, GetSettlementsOptions, GetSettlementsResponse, GetSettlementDetailResponse, GetDropshipperAccountBalanceResponse, GetDropshipperAccountOrdersOptions, GetDropshipperAccountOrdersResponse, CreateSettlementBody, CreateSettlementResponse, ConfirmSettlementBody, UpdateSettlementStatusResponse, CancelSettlementBody, GetAdminDropshipperAccountsResponse, GetAdminAccountBalanceResponse, GetAdminPriceListsResponse, GetUserChannelResponse, GetAdminDropshipperAccountOrdersResponse, GetAdminDropshipperAccountSettlementsOptions, GetAdminDropshipperAccountSettlementsResponse, ResolveGuaranteeBody, ResolveGuaranteeResponse, CreateCompensacionBody, CreateCompensacionResponse, CreateAjusteBody, CreateAjusteResponse, CreateCobroBody, CreateCobroResponse, CreatePagoBody, CreatePagoResponse, CreateReversoBody, CreateReversoResponse, ConfirmMovementBody, ConfirmMovementResponse, CancelMovementBody, CancelMovementResponse, GetFinancialAnalysisResponse, RegisterPaymentBody, RegisterPaymentResponse, GetDropshipperPromotionsOptions, GetDropshipperPromotionsResponse, CreateDropshipperPromotionBody, DropshipperPromotion, UpdateDropshipperPromotionBody, DeleteDropshipperPromotionResponse, GetDashboardStatsOptions, GetDashboardStatsResponse, GetStorefrontDropshipperCategoriesResponse, GetDropshipperDraftOrdersOptions, GetDropshipperDraftOrdersResponse, GetDropshipperDraftOrderDetailResponse, CreateDropshipperDraftOrderBody, CreateDropshipperDraftOrderResponse, UpdateDropshipperDraftOrderBody, UpdateDropshipperDraftOrderResponse, ConvertDropshipperDraftOrderBody, ConvertDropshipperDraftOrderResponse, DeleteDropshipperDraftOrderResponse, GetGeoCountriesResponse, GetGeoProvincesResponse, GetGeoCitiesResponse } from '@thorprovider/types';
|
|
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, ChatIntent, ChatSource, QueryEntitiesInput, QueryResponse, DropshipperDashboardCapabilities, GetMyProfileResponse, ChatRequest, ChatResponse, ChatAssistantHealthResponse, GetNotificationsOptions, GetNotificationsResponse, OnboardDropshipperBody, OnboardDropshipperResponse, GetDropshipperProductsOptions, GetDropshipperProductsResponse, ValidateCheckoutItemsRequest, ValidateCheckoutItemsResponse, CostPriceChangesCheckResponse, CostPriceChangesResponse, AcknowledgeCostPriceChangesResponse, UpdateDropshipperProductStatusBody, UpdateDropshipperProductStatusResponse, GetProductAttributesResponse, GetDropshipperAttributesResponse, UpdateDropshipperPricesBody, UpdateDropshipperPricesResponse, GetDropshipperOrdersOptions, GetDropshipperOrdersResponse, GetDropshipperOrderDetailResponse, GetDropshipperShippingOptionsParams, GetDropshipperShippingOptionsResponse, ExtendedCreateDropshipperOrderBody, ExtendedCreateDropshipperOrderResponse, SetPaymentCollectorBody, SetPaymentCollectorResponse, SetPaymentMethodBody, SetPaymentMethodResponse, CancelDropshipperOrderResponse, CreateOrderEditBody, CreateOrderEditResponse, AddOrderEditItemBody, AddOrderEditItemResponse, ConfirmOrderEditResponse, GetOrderNotesResponse, CreateOrderNoteBody, CreateOrderNoteResponse, DeleteOrderNoteResponse, GetProviderCategoriesResponse, GetDropshipperCategoriesOptions, GetDropshipperCategoriesResponse, CreateDropshipperCategoryBody, DropshipperCategory, UpdateDropshipperCategoryBody, DeleteDropshipperCategoryResponse, GetCategoryMappingsOptions, GetCategoryMappingsResponse, CreateCategoryMappingBody, CreateCategoryMappingResponse, DeleteCategoryMappingResponse, GetDropshipperCustomersOptions, GetDropshipperCustomersResponse, GetDropshipperCustomerDetailResponse, CreateDropshipperCustomerBody, CreateDropshipperCustomerResponse, UpdateDropshipperCustomerBody, UpdateDropshipperCustomerResponse, GetDropshipperAddressesResponse, DropshipperAddressBody, DropshipperAddressResponse, GetDropshipperAccountResponse, GetDropshipperPayableResponse, GetDropshipperReceivableResponse, GetSettlementsOptions, GetSettlementsResponse, GetSettlementDetailResponse, GetDropshipperAccountBalanceResponse, GetDropshipperAccountOrdersOptions, GetDropshipperAccountOrdersResponse, CreateSettlementBody, CreateSettlementResponse, ConfirmSettlementBody, UpdateSettlementStatusResponse, CancelSettlementBody, GetAdminDropshipperAccountsResponse, GetAdminAccountBalanceResponse, GetAdminPriceListsResponse, GetUserChannelResponse, GetAdminDropshipperAccountOrdersResponse, GetAdminDropshipperAccountSettlementsOptions, GetAdminDropshipperAccountSettlementsResponse, ResolveGuaranteeBody, ResolveGuaranteeResponse, CreateCompensacionBody, CreateCompensacionResponse, CreateAjusteBody, CreateAjusteResponse, CreateCobroBody, CreateCobroResponse, CreatePagoBody, CreatePagoResponse, CreateReversoBody, CreateReversoResponse, ConfirmMovementBody, ConfirmMovementResponse, CancelMovementBody, CancelMovementResponse, GetFinancialAnalysisResponse, RegisterPaymentBody, RegisterPaymentResponse, GetDropshipperPromotionsOptions, GetDropshipperPromotionsResponse, CreateDropshipperPromotionBody, DropshipperPromotion, UpdateDropshipperPromotionBody, DeleteDropshipperPromotionResponse, GetDashboardStatsOptions, GetDashboardStatsResponse, GetStorefrontDropshipperCategoriesResponse, GetDropshipperDraftOrdersOptions, GetDropshipperDraftOrdersResponse, GetDropshipperDraftOrderDetailResponse, CreateDropshipperDraftOrderBody, CreateDropshipperDraftOrderResponse, UpdateDropshipperDraftOrderBody, UpdateDropshipperDraftOrderResponse, ConvertDropshipperDraftOrderBody, ConvertDropshipperDraftOrderResponse, DeleteDropshipperDraftOrderResponse, GetGeoCountriesResponse, GetGeoProvincesResponse, GetGeoCitiesResponse } from '@thorprovider/types';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @fileoverview Medusa Multi-Tenant Admin Client
|
|
@@ -167,8 +167,8 @@ declare class MedusaAdminClient {
|
|
|
167
167
|
* One event from the streamed AI assistant chat (`chatAssistantStream`).
|
|
168
168
|
*
|
|
169
169
|
* The backend returns a UI-message stream (SSE over `text/event-stream`) for
|
|
170
|
-
* catalog searches, and a plain JSON `ChatResponse` for
|
|
171
|
-
*
|
|
170
|
+
* catalog searches, and a plain JSON `ChatResponse` for `default` intents.
|
|
171
|
+
* `chatAssistantStream` normalizes both into this single event type so
|
|
172
172
|
* consumers can render incremental text and update the "thinking" label as the
|
|
173
173
|
* model progresses without knowing the transport details.
|
|
174
174
|
*/
|
|
@@ -183,7 +183,7 @@ type ChatStreamEvent = {
|
|
|
183
183
|
} | {
|
|
184
184
|
type: 'finish';
|
|
185
185
|
intent: ChatIntent;
|
|
186
|
-
/** Products referenced by the answer (empty for
|
|
186
|
+
/** Products referenced by the answer (empty for `default` intents). */
|
|
187
187
|
sources: ChatSource[];
|
|
188
188
|
} | {
|
|
189
189
|
type: 'error';
|
|
@@ -228,6 +228,28 @@ declare class DropshipperClient {
|
|
|
228
228
|
private logger;
|
|
229
229
|
constructor(config: DropshipperClientConfig);
|
|
230
230
|
private request;
|
|
231
|
+
/**
|
|
232
|
+
* Resolve multiple entities in a single request.
|
|
233
|
+
*
|
|
234
|
+
* `POST /admin/thor/dropshipper/query`
|
|
235
|
+
*
|
|
236
|
+
* Entities are resolved in parallel (per layer) and errors are isolated per
|
|
237
|
+
* entity: `response.errors[key]` holds the per-entity error while the rest
|
|
238
|
+
* of `data` still resolves. `data[key]` is an array (list entities) or a
|
|
239
|
+
* single object (singular entities such as account, balance, me).
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```typescript
|
|
243
|
+
* const { data } = await client.query({
|
|
244
|
+
* entities: [
|
|
245
|
+
* { entity: 'capabilities' },
|
|
246
|
+
* { entity: 'me' },
|
|
247
|
+
* { entity: 'account' },
|
|
248
|
+
* ],
|
|
249
|
+
* });
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
query(input: QueryEntitiesInput): Promise<QueryResponse>;
|
|
231
253
|
/**
|
|
232
254
|
* Fetch dashboard capabilities from the backend.
|
|
233
255
|
*
|
|
@@ -261,13 +283,30 @@ declare class DropshipperClient {
|
|
|
261
283
|
*
|
|
262
284
|
* Unlike `chatAssistant`, this surfaces the model's progress: the backend
|
|
263
285
|
* resolves the intent first and then streams the answer token by token
|
|
264
|
-
* (catalog searches) or returns the full answer in one shot (
|
|
286
|
+
* (catalog searches) or returns the full answer in one shot (`default`).
|
|
265
287
|
* The response is normalized into a single `ReadableStream<ChatStreamEvent>`
|
|
266
288
|
* so callers can show a live "thinking" label and render text incrementally.
|
|
267
289
|
*
|
|
268
290
|
* `POST /admin/thor/dropshipper/ai/chat`
|
|
269
291
|
*/
|
|
270
292
|
chatAssistantStream(body: ChatRequest): Promise<ReadableStream<ChatStreamEvent>>;
|
|
293
|
+
/**
|
|
294
|
+
* Cheap liveness probe for the AI assistant.
|
|
295
|
+
*
|
|
296
|
+
* The backend performs no LLM or retrieval work, so this is safe to poll
|
|
297
|
+
* (e.g. from a dashboard availability indicator). Returns 200 with
|
|
298
|
+
* `available: true` when the assistant is configured; the backend answers
|
|
299
|
+
* HTTP 503 with `available: false` when `AI_GATEWAY_API_KEY` is missing.
|
|
300
|
+
*
|
|
301
|
+
* Deliberately does NOT go through `fetchBackendWithResilience`: that layer
|
|
302
|
+
* funnels every call through the SHARED `backendCircuitBreaker`, and the
|
|
303
|
+
* definitive 503 "not configured" answer would count as failures and could
|
|
304
|
+
* open the circuit, taking down all dropshipper API traffic. A health probe
|
|
305
|
+
* must stay isolated, with no retries and a short timeout.
|
|
306
|
+
*
|
|
307
|
+
* `GET /admin/thor/dropshipper/ai/health`
|
|
308
|
+
*/
|
|
309
|
+
chatAssistantHealth(): Promise<ChatAssistantHealthResponse>;
|
|
271
310
|
/**
|
|
272
311
|
* List feed notifications for the authenticated dropshipper.
|
|
273
312
|
*
|
package/dist/index.js
CHANGED
|
@@ -430,6 +430,37 @@ var DropshipperClient = class {
|
|
|
430
430
|
return response.json();
|
|
431
431
|
}
|
|
432
432
|
// -------------------------------------------------------------------------
|
|
433
|
+
// Unified Query
|
|
434
|
+
// -------------------------------------------------------------------------
|
|
435
|
+
/**
|
|
436
|
+
* Resolve multiple entities in a single request.
|
|
437
|
+
*
|
|
438
|
+
* `POST /admin/thor/dropshipper/query`
|
|
439
|
+
*
|
|
440
|
+
* Entities are resolved in parallel (per layer) and errors are isolated per
|
|
441
|
+
* entity: `response.errors[key]` holds the per-entity error while the rest
|
|
442
|
+
* of `data` still resolves. `data[key]` is an array (list entities) or a
|
|
443
|
+
* single object (singular entities such as account, balance, me).
|
|
444
|
+
*
|
|
445
|
+
* @example
|
|
446
|
+
* ```typescript
|
|
447
|
+
* const { data } = await client.query({
|
|
448
|
+
* entities: [
|
|
449
|
+
* { entity: 'capabilities' },
|
|
450
|
+
* { entity: 'me' },
|
|
451
|
+
* { entity: 'account' },
|
|
452
|
+
* ],
|
|
453
|
+
* });
|
|
454
|
+
* ```
|
|
455
|
+
*/
|
|
456
|
+
async query(input) {
|
|
457
|
+
return this.request(
|
|
458
|
+
"POST",
|
|
459
|
+
"/admin/thor/dropshipper/query",
|
|
460
|
+
input
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
// -------------------------------------------------------------------------
|
|
433
464
|
// Capabilities
|
|
434
465
|
// -------------------------------------------------------------------------
|
|
435
466
|
/**
|
|
@@ -481,7 +512,7 @@ var DropshipperClient = class {
|
|
|
481
512
|
*
|
|
482
513
|
* Unlike `chatAssistant`, this surfaces the model's progress: the backend
|
|
483
514
|
* resolves the intent first and then streams the answer token by token
|
|
484
|
-
* (catalog searches) or returns the full answer in one shot (
|
|
515
|
+
* (catalog searches) or returns the full answer in one shot (`default`).
|
|
485
516
|
* The response is normalized into a single `ReadableStream<ChatStreamEvent>`
|
|
486
517
|
* so callers can show a live "thinking" label and render text incrementally.
|
|
487
518
|
*
|
|
@@ -559,6 +590,61 @@ var DropshipperClient = class {
|
|
|
559
590
|
}
|
|
560
591
|
});
|
|
561
592
|
}
|
|
593
|
+
/**
|
|
594
|
+
* Cheap liveness probe for the AI assistant.
|
|
595
|
+
*
|
|
596
|
+
* The backend performs no LLM or retrieval work, so this is safe to poll
|
|
597
|
+
* (e.g. from a dashboard availability indicator). Returns 200 with
|
|
598
|
+
* `available: true` when the assistant is configured; the backend answers
|
|
599
|
+
* HTTP 503 with `available: false` when `AI_GATEWAY_API_KEY` is missing.
|
|
600
|
+
*
|
|
601
|
+
* Deliberately does NOT go through `fetchBackendWithResilience`: that layer
|
|
602
|
+
* funnels every call through the SHARED `backendCircuitBreaker`, and the
|
|
603
|
+
* definitive 503 "not configured" answer would count as failures and could
|
|
604
|
+
* open the circuit, taking down all dropshipper API traffic. A health probe
|
|
605
|
+
* must stay isolated, with no retries and a short timeout.
|
|
606
|
+
*
|
|
607
|
+
* `GET /admin/thor/dropshipper/ai/health`
|
|
608
|
+
*/
|
|
609
|
+
async chatAssistantHealth() {
|
|
610
|
+
const url = `${this.baseUrl}/admin/thor/dropshipper/ai/health`;
|
|
611
|
+
const controller = new AbortController();
|
|
612
|
+
const timeoutId = setTimeout(() => controller.abort(), 5e3);
|
|
613
|
+
let response;
|
|
614
|
+
try {
|
|
615
|
+
response = await fetch(url, {
|
|
616
|
+
method: "GET",
|
|
617
|
+
headers: { Authorization: `Bearer ${this.token}` },
|
|
618
|
+
signal: controller.signal,
|
|
619
|
+
cache: "no-store"
|
|
620
|
+
});
|
|
621
|
+
} catch (error) {
|
|
622
|
+
clearTimeout(timeoutId);
|
|
623
|
+
throw new import_adapters3.ProviderAPIError(
|
|
624
|
+
`[dropshipper] Network error on GET /admin/thor/dropshipper/ai/health: ${error.message}`,
|
|
625
|
+
"NETWORK_ERROR",
|
|
626
|
+
0
|
|
627
|
+
);
|
|
628
|
+
}
|
|
629
|
+
clearTimeout(timeoutId);
|
|
630
|
+
if (response.status === 503) {
|
|
631
|
+
try {
|
|
632
|
+
const body = await response.json();
|
|
633
|
+
if (body && typeof body.available === "boolean") {
|
|
634
|
+
return body;
|
|
635
|
+
}
|
|
636
|
+
} catch {
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
if (!response.ok) {
|
|
640
|
+
throw new import_adapters3.ProviderAPIError(
|
|
641
|
+
`[dropshipper] GET /admin/thor/dropshipper/ai/health failed: HTTP ${response.status}`,
|
|
642
|
+
`DROPSHIPPER_API_${response.status}`,
|
|
643
|
+
response.status
|
|
644
|
+
);
|
|
645
|
+
}
|
|
646
|
+
return response.json();
|
|
647
|
+
}
|
|
562
648
|
// -------------------------------------------------------------------------
|
|
563
649
|
// Notifications
|
|
564
650
|
// -------------------------------------------------------------------------
|
|
@@ -1785,7 +1871,7 @@ function mapUiMessageStreamToEvents(stream, logger) {
|
|
|
1785
1871
|
case "finish":
|
|
1786
1872
|
controller.enqueue({
|
|
1787
1873
|
type: "finish",
|
|
1788
|
-
intent: chunk.messageMetadata?.intent ?? "
|
|
1874
|
+
intent: chunk.messageMetadata?.intent ?? "default",
|
|
1789
1875
|
sources: chunk.messageMetadata?.sources ?? []
|
|
1790
1876
|
});
|
|
1791
1877
|
eventCount += 1;
|