@thorprovider/medusa-extended 1.0.0 → 1.1.1

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 ADDED
@@ -0,0 +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 workspace @thorprovider/medusa-extended generate:agent-index|.:{README.md}<!-- MEDUSA-EXTENDED-AGENTS-MD-END -->
package/README.md ADDED
@@ -0,0 +1,206 @@
1
+ ---
2
+ title: "@thorprovider/medusa-extended"
3
+ purpose: "HTTP clients for custom Thor Commerce admin endpoints (dropshipper, multi-tenant) that extend the standard Medusa v2 API"
4
+ lastReviewed: "2026-05-23"
5
+ ---
6
+
7
+ # @thorprovider/medusa-extended
8
+
9
+ **Thor Commerce multi-tenant admin extensions for Medusa v2**
10
+
11
+ HTTP clients for custom Thor endpoints that are not part of the Medusa standard API.
12
+
13
+ ---
14
+
15
+ ## Packages exported
16
+
17
+ | Export | Description |
18
+ |---|---|
19
+ | `MedusaAdminClient` | Thin wrapper around the Medusa Admin REST API (`/admin/*`). Uses `x-medusa-access-token`. |
20
+ | `DropshipperClient` | Client for all dropshipping endpoints (`/admin/thor/dropshipper/*`). Uses `Authorization: Bearer <jwt>`. |
21
+
22
+ ---
23
+
24
+ ## MedusaAdminClient
25
+
26
+ ```typescript
27
+ import { MedusaAdminClient } from '@thorprovider/medusa-extended';
28
+
29
+ const admin = new MedusaAdminClient({
30
+ baseUrl: process.env.MEDUSA_BACKEND_URL!,
31
+ apiKey: process.env.MEDUSA_API_KEY!,
32
+ });
33
+ ```
34
+
35
+ ---
36
+
37
+ ## DropshipperClient
38
+
39
+ Covers **all 43 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
+
41
+ ### Configuration
42
+
43
+ ```typescript
44
+ import { DropshipperClient } from '@thorprovider/medusa-extended';
45
+
46
+ const client = new DropshipperClient({
47
+ baseUrl: process.env.MEDUSA_BACKEND_URL!,
48
+ // JWT obtained from POST /auth/user/emailpass
49
+ token: jwtFromLogin,
50
+ debug: false, // optional — logs every request
51
+ });
52
+ ```
53
+
54
+ ### Authentication
55
+
56
+ Every request sends `Authorization: Bearer <token>`. The JWT is obtained from Medusa's native auth endpoint:
57
+
58
+ ```
59
+ POST /auth/user/emailpass
60
+ { "email": "...", "password": "..." }
61
+ → { "token": "eyJ..." }
62
+ ```
63
+
64
+ ### Methods
65
+
66
+ #### Onboarding (Solo X — Admin role required)
67
+
68
+ | Method | Endpoint |
69
+ |---|---|
70
+ | `onboardDropshipper(body)` | `POST /admin/thor/dropshipper/onboard` |
71
+
72
+ #### Variant Costs (Solo X)
73
+
74
+ | Method | Endpoint |
75
+ |---|---|
76
+ | `getVariantCosts(options?)` | `GET /admin/thor/dropshipper/variant-costs` |
77
+ | `createVariantCost(body)` | `POST /admin/thor/dropshipper/variant-costs` |
78
+ | `batchVariantCosts(body)` | `POST /admin/thor/dropshipper/variant-costs/batch` |
79
+ | `deleteVariantCost(id)` | `DELETE /admin/thor/dropshipper/variant-costs/:id` |
80
+
81
+ #### Products & Prices (Solo Y)
82
+
83
+ | Method | Endpoint |
84
+ |---|---|
85
+ | `getProducts(options?)` | `GET /admin/thor/dropshipper/products` |
86
+ | `updatePrices(body)` | `PUT /admin/thor/dropshipper/prices` |
87
+
88
+ #### Orders (Y + X for set-payment-collector)
89
+
90
+ | Method | Endpoint |
91
+ |---|---|
92
+ | `getOrders(options?)` | `GET /admin/thor/dropshipper/orders` |
93
+ | `getOrder(id)` | `GET /admin/thor/dropshipper/orders/:id` |
94
+ | `createOrder(body)` | `POST /admin/thor/dropshipper/orders` |
95
+ | `setPaymentCollector(id, body)` | `POST /admin/thor/dropshipper/orders/:id/set-payment-collector` |
96
+ | `cancelOrder(id)` | `POST /admin/thor/dropshipper/orders/:id/cancel` |
97
+ | `createOrderEdit(id, body?)` | `POST /admin/thor/dropshipper/orders/:id/edit` |
98
+ | `addOrderEditItem(id, body)` | `POST /admin/thor/dropshipper/orders/:id/edit/items` |
99
+ | `confirmOrderEdit(id)` | `POST /admin/thor/dropshipper/orders/:id/edit/confirm` |
100
+
101
+ #### Order Notes (Y)
102
+
103
+ | Method | Endpoint |
104
+ |---|---|
105
+ | `getOrderNotes(orderId)` | `GET /admin/thor/dropshipper/orders/:id/notes` |
106
+ | `createOrderNote(orderId, body)` | `POST /admin/thor/dropshipper/orders/:id/notes` |
107
+ | `deleteOrderNote(orderId, noteId)` | `DELETE /admin/thor/dropshipper/orders/:id/notes/:noteId` |
108
+
109
+ #### Custom Categories (Solo Y)
110
+
111
+ | Method | Endpoint |
112
+ |---|---|
113
+ | `getCategories(options?)` | `GET /admin/thor/dropshipper/categories` |
114
+ | `createCategory(body)` | `POST /admin/thor/dropshipper/categories` |
115
+ | `updateCategory(id, body)` | `PUT /admin/thor/dropshipper/categories/:id` |
116
+ | `deleteCategory(id)` | `DELETE /admin/thor/dropshipper/categories/:id` |
117
+ | `createCategoryMapping(body)` | `POST /admin/thor/dropshipper/category-mappings` |
118
+ | `deleteCategoryMapping(id)` | `DELETE /admin/thor/dropshipper/category-mappings/:id` |
119
+
120
+ #### Customers (Solo Y)
121
+
122
+ | Method | Endpoint |
123
+ |---|---|
124
+ | `getCustomers(options?)` | `GET /admin/thor/dropshipper/customers` |
125
+ | `getCustomer(id)` | `GET /admin/thor/dropshipper/customers/:id` |
126
+ | `createCustomer(body)` | `POST /admin/thor/dropshipper/customers` |
127
+ | `getCustomerAddresses(customerId)` | `GET /admin/thor/dropshipper/customers/:id/addresses` |
128
+ | `createCustomerAddress(customerId, body)` | `POST /admin/thor/dropshipper/customers/:id/addresses` |
129
+ | `updateCustomerAddress(customerId, addressId, body)` | `PUT /admin/thor/dropshipper/customers/:id/addresses/:addr_id` |
130
+ | `deleteCustomerAddress(customerId, addressId)` | `DELETE /admin/thor/dropshipper/customers/:id/addresses/:addr_id` |
131
+
132
+ #### Account & Settlements (Solo Y — read-only)
133
+
134
+ | Method | Endpoint |
135
+ |---|---|
136
+ | `getAccount()` | `GET /admin/thor/dropshipper/account` |
137
+ | `getPayable()` | `GET /admin/thor/dropshipper/account/payable` |
138
+ | `getReceivable()` | `GET /admin/thor/dropshipper/account/receivable` |
139
+ | `getSettlements(options?)` | `GET /admin/thor/dropshipper/settlements` |
140
+ | `getSettlement(id)` | `GET /admin/thor/dropshipper/settlements/:id` |
141
+
142
+ #### Admin Settlements (Solo X)
143
+
144
+ | Method | Endpoint |
145
+ |---|---|
146
+ | `getAdminSettlements(options?)` | `GET /admin/thor/dropshipper/admin/settlements` |
147
+ | `createSettlement(body)` | `POST /admin/thor/dropshipper/admin/settlements` |
148
+ | `confirmSettlement(id, body?)` | `POST /admin/thor/dropshipper/admin/settlements/:id/confirm` |
149
+ | `cancelSettlement(id, body?)` | `POST /admin/thor/dropshipper/admin/settlements/:id/cancel` |
150
+
151
+ #### Admin Account Management (Solo X)
152
+
153
+ | Method | Endpoint |
154
+ |---|---|
155
+ | `getAdminAccounts()` | `GET /admin/thor/dropshipper/admin/accounts` |
156
+ | `getAdminAccountBalance(id)` | `GET /admin/thor/dropshipper/admin/accounts/:id/balance` |
157
+ | `getAdminPriceLists()` | `GET /admin/thor/dropshipper/admin/price-lists` |
158
+ | `getUserChannel()` | `GET /admin/thor/dropshipper/admin/user-channel` |
159
+
160
+ #### Promotions (Solo Y)
161
+
162
+ | Method | Endpoint |
163
+ |---|---|
164
+ | `getPromotions(options?)` | `GET /admin/thor/dropshipper/promotions` |
165
+ | `createPromotion(body)` | `POST /admin/thor/dropshipper/promotions` |
166
+ | `getPromotion(id)` | `GET /admin/thor/dropshipper/promotions/:id` |
167
+ | `updatePromotion(id, body)` | `PUT /admin/thor/dropshipper/promotions/:id` |
168
+ | `deletePromotion(id)` | `DELETE /admin/thor/dropshipper/promotions/:id` |
169
+
170
+ #### Dashboard (Solo Y)
171
+
172
+ | Method | Endpoint |
173
+ |---|---|
174
+ | `getDashboardStats(options?)` | `GET /admin/thor/dropshipper/dashboard/stats` |
175
+
176
+ #### Storefront (public — uses publishable API key)
177
+
178
+ | Method | Endpoint |
179
+ |---|---|
180
+ | `getStorefrontCategories()` | `GET /store/thor/dropshipper-categories` |
181
+
182
+ > The storefront endpoint resolves the channel from the `x-publishable-api-key` header, not from the JWT. When calling this method directly from a server context, pass the publishable key via a separate fetch or configure an HTTP proxy. The client itself always sends `Authorization: Bearer` — this method is included for completeness.
183
+
184
+ ### Error handling
185
+
186
+ All methods throw `ProviderAPIError` on non-2xx responses:
187
+
188
+ ```typescript
189
+ import { ProviderAPIError } from '@thorprovider/adapters';
190
+
191
+ try {
192
+ const result = await client.getProducts();
193
+ } catch (err) {
194
+ if (err instanceof ProviderAPIError) {
195
+ console.error(err.code); // e.g. "DROPSHIPPER_API_403"
196
+ }
197
+ }
198
+ ```
199
+
200
+ ---
201
+
202
+ ## Endpoint reference
203
+
204
+ Full request/response contracts: `docs/multitenant/dropshipping-api-contract.md`
205
+
206
+ Operational detail and middleware breakdown: `docs/multitenant/dropshipping-feature-reference.md`