@thorprovider/adapters 4.2.1 → 4.2.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/.turbo/turbo-build.log +18 -0
- package/.turbo/turbo-test.log +1 -0
- package/.turbo/turbo-type-check.log +0 -0
- package/AGENTS.md +1 -1
- package/CHANGELOG.md +6 -0
- package/PROVIDER_IMPLEMENTATION_ANALYSIS.md +659 -0
- package/README.md +3 -3
- package/dist/.tsbuildinfo +1 -0
- package/dist/index.d.mts +51 -1
- package/dist/index.d.ts +51 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -0
- package/dist/index.mjs.map +1 -1
- package/docs/RETRY_SOLUTION_SUMMARY.md +26 -11
- package/docs/authentication.md +89 -62
- package/docs/capabilities-system.md +70 -38
- package/docs/category-customization.md +37 -29
- package/docs/fetch-reliability-solution.md +127 -278
- package/docs/getting-started.md +43 -29
- package/docs/profile-management.md +68 -38
- package/docs/services-overview.md +4 -2
- package/docs/update-documentation.md +10 -8
- package/package.json +3 -2
- package/publish.log +93 -0
- package/src/index.ts +4 -0
- package/src/providers/medusa/admin.test.ts +404 -0
- package/src/providers/medusa/admin.ts +442 -0
- package/src/providers/medusa/auth.test.ts +95 -0
- package/src/providers/medusa/index.test.ts +392 -0
- package/src/providers/medusa/live-smoke.test.ts +412 -0
- package/src/resilience/README.md +70 -48
- package/vitest.live.config.ts +18 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
CLI Building entry: {"index":"src/index.ts"}
|
|
2
|
+
CLI Using tsconfig: tsconfig.json
|
|
3
|
+
CLI tsup v8.5.1
|
|
4
|
+
CLI Using tsup config: /home/nelson/dev/thorprovider/repos/thorcommerce/packages/adapters/tsup.config.ts
|
|
5
|
+
CLI Target: esnext
|
|
6
|
+
CLI Cleaning output folder
|
|
7
|
+
CJS Build start
|
|
8
|
+
ESM Build start
|
|
9
|
+
ESM dist/index.mjs 337.86 KB
|
|
10
|
+
ESM dist/index.mjs.map 692.12 KB
|
|
11
|
+
ESM ⚡️ Build success in 91ms
|
|
12
|
+
CJS dist/index.js 342.55 KB
|
|
13
|
+
CJS dist/index.js.map 692.49 KB
|
|
14
|
+
CJS ⚡️ Build success in 99ms
|
|
15
|
+
DTS Build start
|
|
16
|
+
DTS ⚡️ Build success in 2836ms
|
|
17
|
+
DTS dist/index.d.ts 95.95 KB
|
|
18
|
+
DTS dist/index.d.mts 95.95 KB
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
No tests yet
|
|
File without changes
|
package/AGENTS.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!-- ADAPTERS-AGENTS-MD-START -->[@thorprovider/adapters Docs]|root: ./adapters|CRITICAL: Framework-agnostic business logic only. Never import Next.js or React. Check IMPORT_GUIDE.md for proper usage patterns.|To regenerate: yarn workspace @thorprovider/adapters generate:agent-index|.:{README.md,quick-reference.md}|docs:{RETRY_SOLUTION_SUMMARY.md,authentication.md,capabilities-system.md,category-customization.md,fetch-reliability-solution.md,getting-started.md,multi-tenant-channel-scoping.md,profile-management.md,providers-overview.md,services-overview.md,update-documentation.md}|src/resilience:{README.md}<!-- ADAPTERS-AGENTS-MD-END -->
|
|
1
|
+
<!-- ADAPTERS-AGENTS-MD-START -->[@thorprovider/adapters Docs]|root: ./adapters|CRITICAL: Framework-agnostic business logic only. Never import Next.js or React. Check IMPORT_GUIDE.md for proper usage patterns.|To regenerate: yarn workspace @thorprovider/adapters generate:agent-index|.:{PROVIDER_IMPLEMENTATION_ANALYSIS.md,README.md,quick-reference.md}|docs:{RETRY_SOLUTION_SUMMARY.md,authentication.md,capabilities-system.md,category-customization.md,fetch-reliability-solution.md,getting-started.md,multi-tenant-channel-scoping.md,profile-management.md,providers-overview.md,services-overview.md,update-documentation.md}|src/resilience:{README.md}<!-- ADAPTERS-AGENTS-MD-END -->
|
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,659 @@
|
|
|
1
|
+
# @thorprovider/adapters Package Analysis Report
|
|
2
|
+
|
|
3
|
+
## Executive Summary
|
|
4
|
+
|
|
5
|
+
The adapters package provides a unified commerce API across multiple e-commerce platforms. **3 providers are fully/substantially implemented, 5 are stub implementations with basic method skeletons.**
|
|
6
|
+
|
|
7
|
+
### Provider Implementation Status
|
|
8
|
+
|
|
9
|
+
- ✅ **Medusa v2**: ~4,239 LOC - PRODUCTION READY
|
|
10
|
+
- ✅ **Mock**: ~427 LOC - Fixture-backed for testing/previews
|
|
11
|
+
- ✅ **Stel Order ERP**: ~685 LOC - Catalog/CRM read-only (no cart/checkout/auth)
|
|
12
|
+
- 🟡 **Shopify**: ~444 LOC - 60% implemented (cart/products done, orders/admin stub)
|
|
13
|
+
- 🟡 **BigCommerce**: ~315 LOC - 50% implemented (cart/products done, orders/inventory/admin stub)
|
|
14
|
+
- 🟡 **WooCommerce**: ~310 LOC - 50% implemented (cart/products done, orders/admin stub)
|
|
15
|
+
- 🟡 **Spree**: ~344 LOC - 60% implemented (cart/products done, inventory/admin stub)
|
|
16
|
+
- 🟡 **Magento**: ~387 LOC - 50% implemented (cart/products done, orders/admin stub)
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 1. PROVIDER IMPLEMENTATIONS
|
|
21
|
+
|
|
22
|
+
### ✅ MEDUSA v2 (FULLY IMPLEMENTED)
|
|
23
|
+
|
|
24
|
+
**Status**: Production Ready | 105 public async methods
|
|
25
|
+
|
|
26
|
+
**File**: `src/providers/medusa/index.ts`
|
|
27
|
+
|
|
28
|
+
#### Implemented Methods:
|
|
29
|
+
|
|
30
|
+
**Products & Catalog**:
|
|
31
|
+
- `getProduct(handle)` - ✅
|
|
32
|
+
- `getProducts(options)` - ✅
|
|
33
|
+
- `getProductRecommendations(productId)` - ✅
|
|
34
|
+
- `searchProductsAdvanced(options)` - ✅
|
|
35
|
+
- `getAvailableFilters(options)` - ✅
|
|
36
|
+
- `getCollection(handle)` - ✅
|
|
37
|
+
- `getCollections(options)` - ✅
|
|
38
|
+
- `getCollectionProducts(handle, options)` - ✅
|
|
39
|
+
- `getCategory(idOrHandle)` - ✅
|
|
40
|
+
- `getCategories(options)` - ✅
|
|
41
|
+
- `getCategoryProducts(handle, options)` - ✅
|
|
42
|
+
- `getRegions()` - ✅
|
|
43
|
+
|
|
44
|
+
**Cart Operations**:
|
|
45
|
+
- `createCart(options)` - ✅
|
|
46
|
+
- `getCart(cartId)` - ✅
|
|
47
|
+
- `addToCart(cartId, lines)` - ✅
|
|
48
|
+
- `removeFromCart(cartId, lineIds)` - ✅
|
|
49
|
+
- `updateCart(cartId, lines)` - ✅
|
|
50
|
+
- `applyDiscountCode(cartId, code)` - ✅
|
|
51
|
+
- `removeDiscountCode(cartId, code)` - ✅
|
|
52
|
+
|
|
53
|
+
**Checkout**:
|
|
54
|
+
- `completeCheckout(cartId)` - ✅
|
|
55
|
+
- `getShippingMethods(cartId)` - ✅
|
|
56
|
+
- `addShippingMethod(cartId, methodId)` - ✅
|
|
57
|
+
- `initiatePaymentSession(cartId, providerId)` - ✅
|
|
58
|
+
- `updateShippingAddress(cartId, address)` - ✅
|
|
59
|
+
- `updateBillingAddress(cartId, address)` - ✅
|
|
60
|
+
- `getRegionCountries(regionId)` - ✅
|
|
61
|
+
|
|
62
|
+
**Orders**:
|
|
63
|
+
- `getOrders(options)` - ✅
|
|
64
|
+
- `getOrder(orderId)` - ✅
|
|
65
|
+
- `cancelOrder(orderId)` - ✅
|
|
66
|
+
- `createRefund(orderId)` - ✅
|
|
67
|
+
- `createFulfillment(orderId)` - ✅
|
|
68
|
+
|
|
69
|
+
**Customers** (with JWT auth):
|
|
70
|
+
- `getCustomers(options)` - ✅
|
|
71
|
+
- `getCustomer(customerId)` - ✅
|
|
72
|
+
- `updateCustomer(customerId, data)` - ✅
|
|
73
|
+
- `getCustomerOrders(customerId)` - ✅
|
|
74
|
+
- `getAdminCustomers(options)` - ✅
|
|
75
|
+
- `getAdminCustomer(customerId)` - ✅
|
|
76
|
+
|
|
77
|
+
**Inventory/Admin**:
|
|
78
|
+
- `getStockLocations(params)` - ✅ (requires admin config)
|
|
79
|
+
- `checkInventoryLevels(variantId)` - ✅
|
|
80
|
+
- `validateCartStock(cartId)` - ✅
|
|
81
|
+
- `getFulfillmentOptions(cartId)` - ✅
|
|
82
|
+
- `getAdminOrders(options)` - ✅
|
|
83
|
+
- `getAdminProducts(options)` - ✅
|
|
84
|
+
- `getAdminProductStatuses(options)` - ✅
|
|
85
|
+
- `getAvailableProductStatuses()` - ✅
|
|
86
|
+
|
|
87
|
+
**Designer Config** (Custom):
|
|
88
|
+
- `getStorefrontConfig()` - ✅
|
|
89
|
+
- `getDesignerConfig()` - ✅
|
|
90
|
+
- `getAdminDesignerConfig(salesChannelId)` - ✅
|
|
91
|
+
- `updateAdminDesignerConfig(salesChannelId, config)` - ✅
|
|
92
|
+
- `restoreAdminDesignerConfig(salesChannelId, version)` - ✅
|
|
93
|
+
- `getAdminRegions()` - ✅
|
|
94
|
+
- `getAdminOrder(orderId)` - ✅
|
|
95
|
+
- `createDraftOrder(data)` - ✅
|
|
96
|
+
- `undraftOrder(orderId)` - ✅
|
|
97
|
+
|
|
98
|
+
**Special Features**:
|
|
99
|
+
- Dynamic capabilities fetching (GET `/store/thor/capabilities`)
|
|
100
|
+
- Multi-tenant sales channel scoping (NEXT_PUBLIC_SALES_CHANNEL_ID)
|
|
101
|
+
- Automatic retry logic with exponential backoff
|
|
102
|
+
- JWT/session auth with auto-token refresh
|
|
103
|
+
- Channel-scoped data isolation
|
|
104
|
+
|
|
105
|
+
**Capabilities**: 21/21 ✅ FULL SUPPORT
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
### ✅ MOCK PROVIDER (PRODUCTION READY)
|
|
110
|
+
|
|
111
|
+
**Status**: For testing, previews, backend-optional storefronts
|
|
112
|
+
|
|
113
|
+
**File**: `src/providers/mock/index.ts`
|
|
114
|
+
|
|
115
|
+
**Implemented**:
|
|
116
|
+
- `getProduct()` ✅
|
|
117
|
+
- `getProducts()` ✅
|
|
118
|
+
- `getProductRecommendations()` ✅
|
|
119
|
+
- `getCollection()` ✅
|
|
120
|
+
- `getCollections()` ✅
|
|
121
|
+
- `getCollectionProducts()` ✅
|
|
122
|
+
- `getCategory()` ✅
|
|
123
|
+
- `getCategories()` ✅
|
|
124
|
+
- `getCategoryProducts()` ✅
|
|
125
|
+
- `createCart()` ✅
|
|
126
|
+
- `getCart()` ✅
|
|
127
|
+
- `addToCart()` ✅
|
|
128
|
+
- `removeFromCart()` ✅
|
|
129
|
+
- `updateCart()` ✅
|
|
130
|
+
- `completeCheckout()` ✅
|
|
131
|
+
- `getShippingMethods()` ✅
|
|
132
|
+
- `applyDiscountCode()` ✅
|
|
133
|
+
- `getPaymentMethods()` ✅
|
|
134
|
+
- `getOrders()` ✅
|
|
135
|
+
- `getOrder()` ✅
|
|
136
|
+
- `getStorefrontContext()` ✅
|
|
137
|
+
|
|
138
|
+
**Capabilities**: 12/21 partial support (covers basic flows)
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
### ✅ STEL ORDER ERP ADAPTER
|
|
143
|
+
|
|
144
|
+
**Status**: Production Ready | Catalog/CRM read-only (no cart/checkout/auth)
|
|
145
|
+
|
|
146
|
+
**File**: `src/providers/stelorder/index.ts`
|
|
147
|
+
|
|
148
|
+
**Implemented**:
|
|
149
|
+
- `getProduct()` ✅
|
|
150
|
+
- `getProducts()` ✅ (client-side text search, server-side category filter)
|
|
151
|
+
- `getCategory()` ✅
|
|
152
|
+
- `getCategories()` ✅
|
|
153
|
+
- `getCategoryProducts()` ✅
|
|
154
|
+
- `getCustomers()` ✅ (read-only)
|
|
155
|
+
- `getCustomer()` ✅ (read-only)
|
|
156
|
+
- `getOrders()` ✅ (read-only, supports filters)
|
|
157
|
+
- `getPaymentMethods()` ✅ (delivery/payment options)
|
|
158
|
+
- `getShippingMethods()` ✅ (delivery options)
|
|
159
|
+
- `getAddresses()` ✅ (customer addresses)
|
|
160
|
+
- `updateCustomerAddresses()` ✅ (write support)
|
|
161
|
+
- `createStockLocation()` ✅ (warehouse mapping)
|
|
162
|
+
- `getStockLocations()` ✅
|
|
163
|
+
- `checkInventoryLevels()` ✅
|
|
164
|
+
|
|
165
|
+
**NOT Implemented**:
|
|
166
|
+
- ❌ `createCart()` - ERP doesn't support carts
|
|
167
|
+
- ❌ `addToCart()` - N/A
|
|
168
|
+
- ❌ `completeCheckout()` - N/A
|
|
169
|
+
- ❌ `auth` service - No customer auth
|
|
170
|
+
- ❌ Orders write operations (cancel, refund, fulfillment) - Read-only ERP
|
|
171
|
+
|
|
172
|
+
**Capabilities**: 6/21 (catalog + CRM read, no cart/auth)
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## 2. STUB IMPLEMENTATIONS (PARTIAL)
|
|
177
|
+
|
|
178
|
+
### 🟡 SHOPIFY PROVIDER
|
|
179
|
+
|
|
180
|
+
**File**: `src/providers/shopify/index.ts` (444 LOC)
|
|
181
|
+
|
|
182
|
+
**Implementation Level**: ~60%
|
|
183
|
+
|
|
184
|
+
**Implemented**:
|
|
185
|
+
- ✅ `getProduct()` - Via GraphQL
|
|
186
|
+
- ✅ `getProducts()` - Via GraphQL with sort
|
|
187
|
+
- ✅ `getProductRecommendations()` - Via GraphQL
|
|
188
|
+
- ✅ `getCollection()` - Via GraphQL
|
|
189
|
+
- ✅ `getCollections()` - Via GraphQL
|
|
190
|
+
- ✅ `getCollectionProducts()` - Via GraphQL
|
|
191
|
+
- ✅ `createCart()` - GraphQL mutation
|
|
192
|
+
- ✅ `getCart()` - GraphQL query
|
|
193
|
+
- ✅ `addToCart()` - GraphQL mutation
|
|
194
|
+
- ✅ `removeFromCart()` - GraphQL mutation
|
|
195
|
+
- ✅ `updateCart()` - GraphQL mutation
|
|
196
|
+
- ✅ `applyDiscountCode()` - GraphQL mutation
|
|
197
|
+
- ✅ `removeDiscountCode()` - GraphQL mutation
|
|
198
|
+
|
|
199
|
+
**Return Empty/Stub** (❌):
|
|
200
|
+
- `getCategory()` - Returns `undefined` with warning
|
|
201
|
+
- `getCategories()` - Returns `[]` (Shopify uses collections, not categories)
|
|
202
|
+
- `getCategoryProducts()` - Returns `[]`
|
|
203
|
+
- `completeCheckout()` - Throws error (hosted checkout only)
|
|
204
|
+
- `getShippingMethods()` - Returns `[]` (hosted checkout)
|
|
205
|
+
- `getRegionCountries()` - Returns `[]`
|
|
206
|
+
- `addShippingMethod()` - Throws error
|
|
207
|
+
- `initiatePaymentSession()` - Throws error
|
|
208
|
+
- `getOrders()` - Warns "requires Customer Account API" → returns `[]`
|
|
209
|
+
- `getPaymentMethods()` - Returns `[]` (hosted checkout)
|
|
210
|
+
- `getStockLocations()` - Returns `[]`
|
|
211
|
+
- `checkInventoryLevels()` - Returns `[]`
|
|
212
|
+
- `validateCartStock()` - Returns `{ allAvailable: true, unavailableItems: [] }`
|
|
213
|
+
- `getFulfillmentOptions()` - Returns `[]`
|
|
214
|
+
- `cancelOrder()` - Throws error (admin API required)
|
|
215
|
+
- `createFulfillment()` - Throws error
|
|
216
|
+
- `createRefund()` - Throws error
|
|
217
|
+
- `getAdminOrders()` - Returns `{ orders: [], count: 0 }`
|
|
218
|
+
|
|
219
|
+
**Capabilities**: 9/21 ✅ Correct
|
|
220
|
+
|
|
221
|
+
**Notes**:
|
|
222
|
+
- Uses Storefront API (not Admin API)
|
|
223
|
+
- No native categories (uses collections)
|
|
224
|
+
- Hosted checkout model (can't programmatically complete)
|
|
225
|
+
- Orders require Customer Account API upgrade
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
### 🟡 BIGCOMMERCE PROVIDER
|
|
230
|
+
|
|
231
|
+
**File**: `src/providers/bigcommerce/index.ts` (315 LOC)
|
|
232
|
+
|
|
233
|
+
**Implementation Level**: ~50%
|
|
234
|
+
|
|
235
|
+
**Implemented**:
|
|
236
|
+
- ✅ `getProduct()` - REST Storefront API
|
|
237
|
+
- ✅ `getProducts()` - REST Storefront API
|
|
238
|
+
- ✅ `getCollection()` - Maps to categories
|
|
239
|
+
- ✅ `getCollections()` - REST API
|
|
240
|
+
- ✅ `getCollectionProducts()` - REST API
|
|
241
|
+
- ✅ `getCategory()` - Alias to getCollection
|
|
242
|
+
- ✅ `getCategories()` - Alias to getCollections
|
|
243
|
+
- ✅ `getCategoryProducts()` - Alias to getCollectionProducts
|
|
244
|
+
- ✅ `createCart()` - REST API
|
|
245
|
+
- ✅ `getCart()` - REST API
|
|
246
|
+
- ✅ `addToCart()` - REST API
|
|
247
|
+
- ✅ `removeFromCart()` - REST API
|
|
248
|
+
- ✅ `updateCart()` - REST API
|
|
249
|
+
- ✅ `applyDiscountCode()` - REST API (coupons)
|
|
250
|
+
- ✅ `removeDiscountCode()` - REST API
|
|
251
|
+
|
|
252
|
+
**Return Empty/Stub** (❌):
|
|
253
|
+
- `getProductRecommendations()` - Returns `[]` (no Storefront API)
|
|
254
|
+
- `completeCheckout()` - Throws error (Embedded Checkout only)
|
|
255
|
+
- `getShippingMethods()` - Returns `[]`
|
|
256
|
+
- `getRegionCountries()` - Returns `[]`
|
|
257
|
+
- `addShippingMethod()` - Throws error
|
|
258
|
+
- `initiatePaymentSession()` - Throws error
|
|
259
|
+
- `getOrders()` - Returns `[]`
|
|
260
|
+
- `getPaymentMethods()` - Returns `[]`
|
|
261
|
+
- `getStockLocations()` - Returns `[]`
|
|
262
|
+
- `checkInventoryLevels()` - Returns `[]`
|
|
263
|
+
- `validateCartStock()` - Returns `{ allAvailable: true }`
|
|
264
|
+
- `getFulfillmentOptions()` - Returns `[]`
|
|
265
|
+
- `cancelOrder()` - Throws error
|
|
266
|
+
- `createFulfillment()` - Throws error
|
|
267
|
+
- `createRefund()` - Throws error
|
|
268
|
+
- `getAdminOrders()` - Returns `{ orders: [], count: 0 }`
|
|
269
|
+
|
|
270
|
+
**Capabilities**: 8/21 ✅ Correct
|
|
271
|
+
|
|
272
|
+
**Notes**:
|
|
273
|
+
- Storefront API only (no customer/order endpoints)
|
|
274
|
+
- Embedded checkout model
|
|
275
|
+
- Categories mapped to collections
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
### 🟡 WOOCOMMERCE PROVIDER
|
|
280
|
+
|
|
281
|
+
**File**: `src/providers/woocommerce/index.ts` (310 LOC)
|
|
282
|
+
|
|
283
|
+
**Implementation Level**: ~50%
|
|
284
|
+
|
|
285
|
+
**Implemented**:
|
|
286
|
+
- ✅ `getProduct()` - Store API
|
|
287
|
+
- ✅ `getProducts()` - Store API
|
|
288
|
+
- ✅ `getCollection()` - Categories
|
|
289
|
+
- ✅ `getCollections()` - Categories
|
|
290
|
+
- ✅ `getCollectionProducts()` - Categories
|
|
291
|
+
- ✅ `getCategory()` - Alias
|
|
292
|
+
- ✅ `getCategories()` - Alias
|
|
293
|
+
- ✅ `getCategoryProducts()` - Alias
|
|
294
|
+
- ✅ `createCart()` - Store API
|
|
295
|
+
- ✅ `getCart()` - Store API (cart endpoint)
|
|
296
|
+
- ✅ `addToCart()` - Store API
|
|
297
|
+
- ✅ `removeFromCart()` - Store API
|
|
298
|
+
- ✅ `updateCart()` - Store API
|
|
299
|
+
- ✅ `completeCheckout()` - Store API ✅
|
|
300
|
+
- ✅ `applyDiscountCode()` - Store API
|
|
301
|
+
- ✅ `removeDiscountCode()` - Store API
|
|
302
|
+
- ✅ `addShippingMethod()` - Store API
|
|
303
|
+
|
|
304
|
+
**Return Empty/Stub** (❌):
|
|
305
|
+
- `getProductRecommendations()` - Returns `[]`
|
|
306
|
+
- `getShippingMethods()` - Returns `[]`
|
|
307
|
+
- `getRegionCountries()` - Returns `[]`
|
|
308
|
+
- `initiatePaymentSession()` - Noop (handled during checkout)
|
|
309
|
+
- `getOrders()` - Returns `[]`
|
|
310
|
+
- `getPaymentMethods()` - Returns `[]`
|
|
311
|
+
- `getStockLocations()` - Returns `[]`
|
|
312
|
+
- `checkInventoryLevels()` - Returns `[]`
|
|
313
|
+
- `validateCartStock()` - Returns `{ allAvailable: true }`
|
|
314
|
+
- `getFulfillmentOptions()` - Returns `[]`
|
|
315
|
+
- `cancelOrder()` - Throws error (REST API auth required)
|
|
316
|
+
- `createFulfillment()` - Throws error
|
|
317
|
+
- `createRefund()` - Throws error
|
|
318
|
+
- `getAdminOrders()` - Returns `{ orders: [], count: 0 }`
|
|
319
|
+
|
|
320
|
+
**Capabilities**: 8/21 ✅ Correct
|
|
321
|
+
|
|
322
|
+
**Notes**:
|
|
323
|
+
- Dual API: Store API (unauthenticated cart/products) + REST API v3 (authenticated orders)
|
|
324
|
+
- Store API handles most operations
|
|
325
|
+
- Orders require admin credentials
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
### 🟡 SPREE PROVIDER
|
|
330
|
+
|
|
331
|
+
**File**: `src/providers/spree/index.ts` (344 LOC)
|
|
332
|
+
|
|
333
|
+
**Implementation Level**: ~60%
|
|
334
|
+
|
|
335
|
+
**Implemented**:
|
|
336
|
+
- ✅ `getProduct()` - JSON:API storefront
|
|
337
|
+
- ✅ `getProducts()` - JSON:API with filtering
|
|
338
|
+
- ✅ `getCollection()` - Taxons (JSON:API)
|
|
339
|
+
- ✅ `getCollections()` - JSON:API
|
|
340
|
+
- ✅ `getCollectionProducts()` - JSON:API filtering
|
|
341
|
+
- ✅ `getCategory()` - Alias to getCollection
|
|
342
|
+
- ✅ `getCategories()` - Alias to getCollections
|
|
343
|
+
- ✅ `getCategoryProducts()` - Alias
|
|
344
|
+
- ✅ `createCart()` - JSON:API mutation
|
|
345
|
+
- ✅ `getCart()` - JSON:API query
|
|
346
|
+
- ✅ `addToCart()` - JSON:API mutation
|
|
347
|
+
- ✅ `removeFromCart()` - JSON:API delete
|
|
348
|
+
- ✅ `updateCart()` - JSON:API PATCH
|
|
349
|
+
- ✅ `completeCheckout()` - JSON:API
|
|
350
|
+
- ✅ `getShippingMethods()` - JSON:API (shipping rates)
|
|
351
|
+
- ✅ `addShippingMethod()` - JSON:API
|
|
352
|
+
- ✅ `applyDiscountCode()` - JSON:API
|
|
353
|
+
- ✅ `removeDiscountCode()` - JSON:API
|
|
354
|
+
- ✅ `getOrders()` - Attempts `account/orders`
|
|
355
|
+
|
|
356
|
+
**Return Empty/Stub** (❌):
|
|
357
|
+
- `getProductRecommendations()` - Returns `[]`
|
|
358
|
+
- `getRegionCountries()` - Returns `[]`
|
|
359
|
+
- `initiatePaymentSession()` - Noop
|
|
360
|
+
- `getPaymentMethods()` - Returns `[]` (attempts checkout API)
|
|
361
|
+
- `getStockLocations()` - Returns `[]`
|
|
362
|
+
- `checkInventoryLevels()` - Returns `[]`
|
|
363
|
+
- `validateCartStock()` - Returns `{ allAvailable: true }`
|
|
364
|
+
- `getFulfillmentOptions()` - Returns `[]`
|
|
365
|
+
- `cancelOrder()` - Throws error (admin API required)
|
|
366
|
+
- `createFulfillment()` - Throws error
|
|
367
|
+
- `createRefund()` - Throws error
|
|
368
|
+
- `getAdminOrders()` - Returns `{ orders: [], count: 0 }`
|
|
369
|
+
|
|
370
|
+
**Capabilities**: 8/21 ✅ Correct
|
|
371
|
+
|
|
372
|
+
**Notes**:
|
|
373
|
+
- JSON:API format (not REST/GraphQL)
|
|
374
|
+
- Guest token + bearer token auth support
|
|
375
|
+
- `getOrders()` attempts but may fail if customer not authenticated
|
|
376
|
+
|
|
377
|
+
---
|
|
378
|
+
|
|
379
|
+
### 🟡 MAGENTO PROVIDER
|
|
380
|
+
|
|
381
|
+
**File**: `src/providers/magento/index.ts` (387 LOC)
|
|
382
|
+
|
|
383
|
+
**Implementation Level**: ~50%
|
|
384
|
+
|
|
385
|
+
**Implemented**:
|
|
386
|
+
- ✅ `getProduct()` - GraphQL by URL key
|
|
387
|
+
- ✅ `getProducts()` - GraphQL with sort/pagination
|
|
388
|
+
- ✅ `getCollection()` - GraphQL categories by URL key
|
|
389
|
+
- ✅ `getCollections()` - GraphQL categories
|
|
390
|
+
- ✅ `getCollectionProducts()` - GraphQL filtered
|
|
391
|
+
- ✅ `getCategory()` - Alias
|
|
392
|
+
- ✅ `getCategories()` - Alias
|
|
393
|
+
- ✅ `getCategoryProducts()` - Alias
|
|
394
|
+
- ✅ `createCart()` - GraphQL mutation
|
|
395
|
+
- ✅ `getCart()` - GraphQL query
|
|
396
|
+
- ✅ `addToCart()` - GraphQL mutation
|
|
397
|
+
- ✅ `removeFromCart()` - GraphQL mutation (loop per item)
|
|
398
|
+
- ✅ `updateCart()` - GraphQL mutation
|
|
399
|
+
- ✅ `applyDiscountCode()` - GraphQL mutation
|
|
400
|
+
- ✅ `removeDiscountCode()` - GraphQL mutation
|
|
401
|
+
- ✅ `getOrders()` - GraphQL (requires customerToken)
|
|
402
|
+
|
|
403
|
+
**Return Empty/Stub** (❌):
|
|
404
|
+
- `getProductRecommendations()` - Returns `[]`
|
|
405
|
+
- `completeCheckout()` - Throws error (multi-step process)
|
|
406
|
+
- `getShippingMethods()` - Returns `[]` (multi-step)
|
|
407
|
+
- `getRegionCountries()` - Returns `[]`
|
|
408
|
+
- `addShippingMethod()` - Throws error
|
|
409
|
+
- `initiatePaymentSession()` - Noop
|
|
410
|
+
- `getPaymentMethods()` - Returns `[]`
|
|
411
|
+
- `getStockLocations()` - Returns `[]`
|
|
412
|
+
- `checkInventoryLevels()` - Returns `[]`
|
|
413
|
+
- `validateCartStock()` - Returns `{ allAvailable: true }`
|
|
414
|
+
- `getFulfillmentOptions()` - Returns `[]`
|
|
415
|
+
- `cancelOrder()` - Throws error (admin API)
|
|
416
|
+
- `createFulfillment()` - Throws error
|
|
417
|
+
- `createRefund()` - Throws error
|
|
418
|
+
- `getAdminOrders()` - Returns `{ orders: [], count: 0 }`
|
|
419
|
+
|
|
420
|
+
**Capabilities**: 8/21 ✅ Correct
|
|
421
|
+
|
|
422
|
+
**Notes**:
|
|
423
|
+
- GraphQL-first approach
|
|
424
|
+
- Checkout is multi-step (not single-call completeCheckout)
|
|
425
|
+
- Requires customerToken for orders
|
|
426
|
+
|
|
427
|
+
---
|
|
428
|
+
|
|
429
|
+
## 3. CORE TYPES & INTERFACES
|
|
430
|
+
|
|
431
|
+
**File**: `src/types/provider.ts`
|
|
432
|
+
|
|
433
|
+
Re-exports from `@thorprovider/types`:
|
|
434
|
+
- `CommerceProvider` interface
|
|
435
|
+
- `BackendCapabilities` interface
|
|
436
|
+
- `ProviderConfig` type
|
|
437
|
+
|
|
438
|
+
**File**: `src/types/capabilities.types.ts`
|
|
439
|
+
|
|
440
|
+
Defines 21 capabilities across 5 categories:
|
|
441
|
+
|
|
442
|
+
**Profile Management** (6):
|
|
443
|
+
- `updateProfile`
|
|
444
|
+
- `updateEmail`
|
|
445
|
+
- `changePasswordDirect`
|
|
446
|
+
- `changePasswordViaEmail`
|
|
447
|
+
- `deleteAccount`
|
|
448
|
+
|
|
449
|
+
**Avatar** (2):
|
|
450
|
+
- `uploadAvatar`
|
|
451
|
+
- `avatarViaMetadata`
|
|
452
|
+
|
|
453
|
+
**Cart/Checkout** (7):
|
|
454
|
+
- `customAttributes`
|
|
455
|
+
- `applyDiscounts`
|
|
456
|
+
- `shippingCalculation`
|
|
457
|
+
- `guestCheckout`
|
|
458
|
+
- `savedPaymentMethods`
|
|
459
|
+
- `listPaymentProviders`
|
|
460
|
+
- `regionSpecificPayments`
|
|
461
|
+
|
|
462
|
+
**Products** (4):
|
|
463
|
+
- `advancedSearch`
|
|
464
|
+
- `facetedFilters`
|
|
465
|
+
- `productReviews`
|
|
466
|
+
- `wishlist`
|
|
467
|
+
|
|
468
|
+
**Loyalty** (1):
|
|
469
|
+
- `loyaltyProgram`
|
|
470
|
+
|
|
471
|
+
**Orders** (2):
|
|
472
|
+
- `fetchOrders`
|
|
473
|
+
- `cancelOrder`
|
|
474
|
+
|
|
475
|
+
**Addresses** (2):
|
|
476
|
+
- `manageAddresses`
|
|
477
|
+
- `defaultAddress`
|
|
478
|
+
|
|
479
|
+
---
|
|
480
|
+
|
|
481
|
+
## 4. MISSING IMPLEMENTATIONS SUMMARY
|
|
482
|
+
|
|
483
|
+
### ✅ Fully Implemented
|
|
484
|
+
- **Medusa**: All 105+ methods, all 21 capabilities
|
|
485
|
+
- **Mock**: 21 methods, 12 capabilities (sufficient for testing)
|
|
486
|
+
- **Stel Order**: Catalog + CRM focused, 14 methods, 6 capabilities
|
|
487
|
+
|
|
488
|
+
### 🟡 Significantly Missing (All Stubs)
|
|
489
|
+
|
|
490
|
+
**Inventory/Stock Management** (❌ All stubs except Medusa):
|
|
491
|
+
- `getStockLocations()` - Empty in: Shopify, BigCommerce, WooCommerce, Spree, Magento
|
|
492
|
+
- `checkInventoryLevels()` - Empty in: Shopify, BigCommerce, WooCommerce, Spree, Magento
|
|
493
|
+
- `validateCartStock()` - Returns hardcoded true in all stubs
|
|
494
|
+
- `getFulfillmentOptions()` - Empty in: Shopify, BigCommerce, WooCommerce, Spree, Magento
|
|
495
|
+
|
|
496
|
+
**Admin Operations** (❌ All stubs):
|
|
497
|
+
- `getAdminOrders()` - Returns `{ orders: [], count: 0 }` in all stubs
|
|
498
|
+
- `cancelOrder()` - Throws "requires admin API" error in all stubs
|
|
499
|
+
- `createFulfillment()` - Throws error in all stubs
|
|
500
|
+
- `createRefund()` - Throws error in all stubs
|
|
501
|
+
- `getAdminProducts()` - Not implemented in any stub
|
|
502
|
+
|
|
503
|
+
**Customer/Order Management** (❌ Partial stubs):
|
|
504
|
+
- `getOrders()` - Empty in: Shopify, BigCommerce, WooCommerce
|
|
505
|
+
- `getPaymentMethods()` - Empty in: Shopify, BigCommerce, Magento
|
|
506
|
+
|
|
507
|
+
**Shipping** (❌ All stubs):
|
|
508
|
+
- `getShippingMethods()` - Returns `[]` in: Shopify, BigCommerce, Magento
|
|
509
|
+
- `addShippingMethod()` - Throws error in: Shopify, BigCommerce, Magento
|
|
510
|
+
- `getRegionCountries()` - Returns `[]` in all stubs
|
|
511
|
+
|
|
512
|
+
**Checkout** (❌ Partial):
|
|
513
|
+
- `completeCheckout()` - Throws error in: Shopify (hosted), BigCommerce (embedded), Magento (multi-step)
|
|
514
|
+
- `initiatePaymentSession()` - Noop/throws in all stubs
|
|
515
|
+
|
|
516
|
+
**Discovery** (❌ All stubs):
|
|
517
|
+
- `getProductRecommendations()` - Returns `[]` in all stubs
|
|
518
|
+
|
|
519
|
+
---
|
|
520
|
+
|
|
521
|
+
## 5. ERROR HANDLING PATTERNS
|
|
522
|
+
|
|
523
|
+
### Medusa (Best Practice):
|
|
524
|
+
```typescript
|
|
525
|
+
private async withRetry<T>(
|
|
526
|
+
fn: () => Promise<T>,
|
|
527
|
+
operationName: string,
|
|
528
|
+
retryConfig?: RetryConfig
|
|
529
|
+
): Promise<T> {
|
|
530
|
+
// Exponential backoff + jitter
|
|
531
|
+
// Circuit breaker patterns
|
|
532
|
+
// Detailed error logging
|
|
533
|
+
}
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
### Shopify/BigCommerce/WooCommerce/Spree/Magento:
|
|
537
|
+
```typescript
|
|
538
|
+
try {
|
|
539
|
+
// Fetch operation
|
|
540
|
+
} catch (error) {
|
|
541
|
+
// Log or return []
|
|
542
|
+
}
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
**Issue**: Limited error context in stubs; should use `ProviderAPIError` consistently.
|
|
546
|
+
|
|
547
|
+
---
|
|
548
|
+
|
|
549
|
+
## 6. ADMIN SERVICES
|
|
550
|
+
|
|
551
|
+
**File**: `src/admin/`
|
|
552
|
+
|
|
553
|
+
- `AdminAuthService.ts` - Session/JWT management
|
|
554
|
+
- `AdminSessionService.ts` - Session persistence
|
|
555
|
+
- `MetricsService.ts` - Order/product metrics
|
|
556
|
+
|
|
557
|
+
**Note**: These are utilities, not provider-level admin APIs. Actual admin endpoints are in provider implementations (Medusa only).
|
|
558
|
+
|
|
559
|
+
---
|
|
560
|
+
|
|
561
|
+
## 7. COMPARISON AGAINST THOR API CONTRACT
|
|
562
|
+
|
|
563
|
+
### Expected Endpoints (from Thor Commerce API):
|
|
564
|
+
|
|
565
|
+
#### Storefront API ✅
|
|
566
|
+
| Method | Medusa | Shopify | BigCommerce | WooCommerce | Spree | Magento | Mock |
|
|
567
|
+
|--------|--------|---------|-------------|------------|-------|---------|------|
|
|
568
|
+
| `getProducts()` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
569
|
+
| `getProduct()` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
570
|
+
| `getCategories()` | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
571
|
+
| `getCategory()` | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
572
|
+
| `getCollections()` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
573
|
+
| `getCollection()` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
574
|
+
|
|
575
|
+
#### Cart & Checkout ✅
|
|
576
|
+
| Method | Medusa | Shopify | BigCommerce | WooCommerce | Spree | Magento | Mock |
|
|
577
|
+
|--------|--------|---------|-------------|------------|-------|---------|------|
|
|
578
|
+
| `createCart()` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
579
|
+
| `getCart()` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
580
|
+
| `addToCart()` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
581
|
+
| `removeFromCart()` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
582
|
+
| `updateCart()` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
583
|
+
| `applyDiscountCode()` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
584
|
+
| `removeDiscountCode()` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
585
|
+
| `completeCheckout()` | ✅ | ❌* | ❌* | ✅ | ✅ | ❌* | ✅ |
|
|
586
|
+
|
|
587
|
+
**\*** Hosted checkout models (Shopify, BigCommerce, Magento) cannot complete programmatically
|
|
588
|
+
|
|
589
|
+
#### Orders 🟡
|
|
590
|
+
| Method | Medusa | Shopify | BigCommerce | WooCommerce | Spree | Magento | Mock |
|
|
591
|
+
|--------|--------|---------|-------------|------------|-------|---------|------|
|
|
592
|
+
| `getOrders()` | ✅ | ❌ | ❌ | ❌ | ⚠️ | ✅* | ✅ |
|
|
593
|
+
| `getOrder()` | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |
|
|
594
|
+
| `cancelOrder()` | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |
|
|
595
|
+
|
|
596
|
+
**\*** Requires customerToken
|
|
597
|
+
|
|
598
|
+
#### Admin 🟡
|
|
599
|
+
| Method | Medusa | Shopify | BigCommerce | WooCommerce | Spree | Magento | Mock |
|
|
600
|
+
|--------|--------|---------|-------------|------------|-------|---------|------|
|
|
601
|
+
| `getAdminOrders()` | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
|
602
|
+
| `getAdminProducts()` | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
|
603
|
+
| `createFulfillment()` | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
|
604
|
+
| `createRefund()` | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
|
605
|
+
|
|
606
|
+
#### Inventory 🟡
|
|
607
|
+
| Method | Medusa | Shopify | BigCommerce | WooCommerce | Spree | Magento | Mock |
|
|
608
|
+
|--------|--------|---------|-------------|------------|-------|---------|------|
|
|
609
|
+
| `getStockLocations()` | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
|
610
|
+
| `checkInventoryLevels()` | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
|
611
|
+
| `validateCartStock()` | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
|
612
|
+
|
|
613
|
+
---
|
|
614
|
+
|
|
615
|
+
## SUMMARY OF FINDINGS
|
|
616
|
+
|
|
617
|
+
### Overall Implementation Status
|
|
618
|
+
|
|
619
|
+
**Tier 1 - Production Ready**:
|
|
620
|
+
- Medusa: 105+ methods, 21/21 capabilities
|
|
621
|
+
- Mock: 21 methods, 12/21 capabilities (sufficient)
|
|
622
|
+
|
|
623
|
+
**Tier 2 - Partial Implementation**:
|
|
624
|
+
- Shopify: ~40 methods, 9/21 capabilities (storefront-only API)
|
|
625
|
+
- BigCommerce: ~35 methods, 8/21 capabilities (storefront-only API)
|
|
626
|
+
- WooCommerce: ~35 methods, 8/21 capabilities (storefront + basic checkout)
|
|
627
|
+
- Spree: ~40 methods, 8/21 capabilities (JSON:API with guest checkout)
|
|
628
|
+
- Magento: ~35 methods, 8/21 capabilities (GraphQL-first, multi-step checkout)
|
|
629
|
+
|
|
630
|
+
**Tier 3 - Catalog-Only**:
|
|
631
|
+
- Stel Order: 14 methods, 6/21 capabilities (catalog + CRM read-only)
|
|
632
|
+
|
|
633
|
+
### Key Gaps Across All Non-Medusa Providers
|
|
634
|
+
|
|
635
|
+
❌ **Inventory/Stock Management**: No stock location or inventory level data
|
|
636
|
+
❌ **Admin Operations**: No order management, fulfillment, or refund operations
|
|
637
|
+
❌ **Payment Methods Listing**: Returns empty except Spree (which attempts)
|
|
638
|
+
❌ **Product Recommendations**: Returns empty across all stubs
|
|
639
|
+
❌ **Shipping Methods**: Limited/missing in most
|
|
640
|
+
❌ **Programmatic Checkout Completion**: Hosted models (Shopify, BigCommerce, Magento) throw errors
|
|
641
|
+
|
|
642
|
+
### Medusa Advantages
|
|
643
|
+
|
|
644
|
+
✅ Admin SDK integration (secret key support)
|
|
645
|
+
✅ Inventory & fulfillment tracking
|
|
646
|
+
✅ Dynamic capabilities fetching
|
|
647
|
+
✅ Sales channel scoping (multi-tenant)
|
|
648
|
+
✅ Complete order lifecycle (create, cancel, refund, fulfill)
|
|
649
|
+
✅ Custom storefront/designer config endpoints
|
|
650
|
+
✅ Retry logic with exponential backoff
|
|
651
|
+
|
|
652
|
+
### Recommendations
|
|
653
|
+
|
|
654
|
+
1. **Prioritize**: Orders API for Shopify (requires Customer Account API upgrade in Shopify)
|
|
655
|
+
2. **Inventory**: BigCommerce, WooCommerce need inventory endpoints research
|
|
656
|
+
3. **Admin APIs**: All stubs need admin SDK integration (currently blocked)
|
|
657
|
+
4. **Error Handling**: Standardize error context across providers
|
|
658
|
+
5. **Testing**: Implement smoke tests for each provider (Stel Order has live-smoke.test.ts example)
|
|
659
|
+
|