@thorprovider/medusa-extended 1.13.0 → 1.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/dropshipper.test.ts +58 -0
- package/src/dropshipper.ts +34 -1
- package/src/recovery.ts +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thorprovider/medusa-extended",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.2",
|
|
4
4
|
"description": "Thor Commerce multi-tenant admin extensions for Medusa v2",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@thorprovider/adapters": "^5.0.8",
|
|
28
|
-
"@thorprovider/types": "^5.
|
|
28
|
+
"@thorprovider/types": "^5.7.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"msw": "^2.12.3",
|
package/src/dropshipper.test.ts
CHANGED
|
@@ -1011,6 +1011,64 @@ describe('DropshipperClient.getAccount', () => {
|
|
|
1011
1011
|
})
|
|
1012
1012
|
})
|
|
1013
1013
|
|
|
1014
|
+
describe('DropshipperClient.getBusinessPolicy', () => {
|
|
1015
|
+
it('GET /admin/thor/dropshipper/account/policies', async () => {
|
|
1016
|
+
server.use(
|
|
1017
|
+
http.get(`${BASE}/admin/thor/dropshipper/account/policies`, ({ request }) => {
|
|
1018
|
+
requireBearerToken(request)
|
|
1019
|
+
return HttpResponse.json({ business_policy: 'Devoluciones dentro de 30 días.' })
|
|
1020
|
+
}),
|
|
1021
|
+
)
|
|
1022
|
+
|
|
1023
|
+
const result = await client().getBusinessPolicy()
|
|
1024
|
+
expect(result.business_policy).toBe('Devoluciones dentro de 30 días.')
|
|
1025
|
+
})
|
|
1026
|
+
|
|
1027
|
+
it('returns an empty string when no policy is set', async () => {
|
|
1028
|
+
server.use(
|
|
1029
|
+
http.get(`${BASE}/admin/thor/dropshipper/account/policies`, ({ request }) => {
|
|
1030
|
+
requireBearerToken(request)
|
|
1031
|
+
return HttpResponse.json({ business_policy: '' })
|
|
1032
|
+
}),
|
|
1033
|
+
)
|
|
1034
|
+
|
|
1035
|
+
const result = await client().getBusinessPolicy()
|
|
1036
|
+
expect(result.business_policy).toBe('')
|
|
1037
|
+
})
|
|
1038
|
+
})
|
|
1039
|
+
|
|
1040
|
+
describe('DropshipperClient.updateBusinessPolicy', () => {
|
|
1041
|
+
it('PATCH /admin/thor/dropshipper/account/policies', async () => {
|
|
1042
|
+
server.use(
|
|
1043
|
+
http.patch(`${BASE}/admin/thor/dropshipper/account/policies`, async ({ request }) => {
|
|
1044
|
+
requireBearerToken(request)
|
|
1045
|
+
const body = await request.json() as any
|
|
1046
|
+
expect(body.business_policy).toBe('Devoluciones dentro de 30 días.')
|
|
1047
|
+
return HttpResponse.json({ business_policy: 'Devoluciones dentro de 30 días.' })
|
|
1048
|
+
}),
|
|
1049
|
+
)
|
|
1050
|
+
|
|
1051
|
+
const result = await client().updateBusinessPolicy({
|
|
1052
|
+
business_policy: 'Devoluciones dentro de 30 días.',
|
|
1053
|
+
})
|
|
1054
|
+
expect(result.business_policy).toBe('Devoluciones dentro de 30 días.')
|
|
1055
|
+
})
|
|
1056
|
+
|
|
1057
|
+
it('returns the trimmed value persisted by the server', async () => {
|
|
1058
|
+
server.use(
|
|
1059
|
+
http.patch(`${BASE}/admin/thor/dropshipper/account/policies`, async ({ request }) => {
|
|
1060
|
+
requireBearerToken(request)
|
|
1061
|
+
const body = await request.json() as any
|
|
1062
|
+
expect(body.business_policy).toBe(' Política ')
|
|
1063
|
+
return HttpResponse.json({ business_policy: 'Política' })
|
|
1064
|
+
}),
|
|
1065
|
+
)
|
|
1066
|
+
|
|
1067
|
+
const result = await client().updateBusinessPolicy({ business_policy: ' Política ' })
|
|
1068
|
+
expect(result.business_policy).toBe('Política')
|
|
1069
|
+
})
|
|
1070
|
+
})
|
|
1071
|
+
|
|
1014
1072
|
describe('DropshipperClient.getSettlements', () => {
|
|
1015
1073
|
it('GET /admin/thor/dropshipper/settlements with defaults', async () => {
|
|
1016
1074
|
server.use(
|
package/src/dropshipper.ts
CHANGED
|
@@ -171,6 +171,10 @@ import type {
|
|
|
171
171
|
DropshipperNotificationPreference,
|
|
172
172
|
UpdateNotificationPreferencesBody,
|
|
173
173
|
GetNotificationPreferencesResponse,
|
|
174
|
+
// Dropshipper business policy
|
|
175
|
+
GetBusinessPolicyResponse,
|
|
176
|
+
UpdateBusinessPolicyBody,
|
|
177
|
+
UpdateBusinessPolicyResponse,
|
|
174
178
|
// Inline return types
|
|
175
179
|
DropshipperCategory,
|
|
176
180
|
DropshipperPromotion,
|
|
@@ -1327,6 +1331,35 @@ export class DropshipperClient {
|
|
|
1327
1331
|
);
|
|
1328
1332
|
}
|
|
1329
1333
|
|
|
1334
|
+
/**
|
|
1335
|
+
* Get the authenticated dropshipper's business policy text.
|
|
1336
|
+
* Returns an empty string when no policy is set.
|
|
1337
|
+
*
|
|
1338
|
+
* `GET /admin/thor/dropshipper/account/policies`
|
|
1339
|
+
*/
|
|
1340
|
+
async getBusinessPolicy(): Promise<GetBusinessPolicyResponse> {
|
|
1341
|
+
return this.request<GetBusinessPolicyResponse>(
|
|
1342
|
+
'GET',
|
|
1343
|
+
'/admin/thor/dropshipper/account/policies',
|
|
1344
|
+
);
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
/**
|
|
1348
|
+
* Update the authenticated dropshipper's business policy text.
|
|
1349
|
+
* The value is trimmed server-side before being persisted.
|
|
1350
|
+
*
|
|
1351
|
+
* `PATCH /admin/thor/dropshipper/account/policies`
|
|
1352
|
+
*/
|
|
1353
|
+
async updateBusinessPolicy(
|
|
1354
|
+
body: UpdateBusinessPolicyBody,
|
|
1355
|
+
): Promise<UpdateBusinessPolicyResponse> {
|
|
1356
|
+
return this.request<UpdateBusinessPolicyResponse>(
|
|
1357
|
+
'PATCH',
|
|
1358
|
+
'/admin/thor/dropshipper/account/policies',
|
|
1359
|
+
body,
|
|
1360
|
+
);
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1330
1363
|
/**
|
|
1331
1364
|
* Orders where Y owes money to X (Y collected payment, needs to pay costs).
|
|
1332
1365
|
*
|
|
@@ -2033,7 +2066,7 @@ export class DropshipperClient {
|
|
|
2033
2066
|
}
|
|
2034
2067
|
|
|
2035
2068
|
// Re-export types used by callers so they don't need to import from @thorprovider/types directly.
|
|
2036
|
-
export type { DropshipperCategory, DropshipperPromotion, NotificationData, PriceUpdatedNotificationData, ProductAssignedNotificationData, StockChangeNotificationData, ManualAdminNotificationData, RawNotification, GetNotificationsOptions, GetNotificationsResponse, DropshipperNotificationEventType, DropshipperNotificationPreference, UpdateNotificationPreferencesBody, GetNotificationPreferencesResponse, ChatRequest, ChatResponse, ChatMessage, ChatIntent, ChatSource, ChatSourceVariant } from '@thorprovider/types';
|
|
2069
|
+
export type { DropshipperCategory, DropshipperPromotion, NotificationData, PriceUpdatedNotificationData, ProductAssignedNotificationData, StockChangeNotificationData, ManualAdminNotificationData, RawNotification, GetNotificationsOptions, GetNotificationsResponse, DropshipperNotificationEventType, DropshipperNotificationPreference, UpdateNotificationPreferencesBody, GetNotificationPreferencesResponse, GetBusinessPolicyResponse, UpdateBusinessPolicyBody, UpdateBusinessPolicyResponse, ChatRequest, ChatResponse, ChatMessage, ChatIntent, ChatSource, ChatSourceVariant } from '@thorprovider/types';
|
|
2037
2070
|
|
|
2038
2071
|
// ---------------------------------------------------------------------------
|
|
2039
2072
|
// AI Assistant — streaming helpers
|
package/src/recovery.ts
CHANGED
|
@@ -314,6 +314,13 @@ export class RecoveryClient {
|
|
|
314
314
|
retryAfterSeconds: details.retry_after_seconds,
|
|
315
315
|
};
|
|
316
316
|
}
|
|
317
|
+
if (error.status === 400 && details?.type === 'challenge_failed') {
|
|
318
|
+
return {
|
|
319
|
+
ok: false,
|
|
320
|
+
reason: 'challenge_failed',
|
|
321
|
+
...(typeof details.message === 'string' ? { message: details.message } : {}),
|
|
322
|
+
};
|
|
323
|
+
}
|
|
317
324
|
if (error.status === 400) {
|
|
318
325
|
return {
|
|
319
326
|
ok: false,
|