@meeovi/commerce 1.0.0 → 1.0.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/README.md +66 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# @meeovi/commerce
|
|
2
|
+
|
|
3
|
+
A backend‑agnostic commerce domain module for the Meeovi ecosystem.
|
|
4
|
+
This package provides a unified interface for products, categories, carts, and other commerce operations — regardless of the underlying backend (Directus, Medusa, Shopify, custom APIs, etc.).
|
|
5
|
+
|
|
6
|
+
## ✨ Features
|
|
7
|
+
|
|
8
|
+
- Pluggable provider architecture
|
|
9
|
+
- Unified composables (`useProducts`, `useCart`, `useCategories`)
|
|
10
|
+
- Backend‑agnostic types
|
|
11
|
+
- Runtime configuration
|
|
12
|
+
- Zero Nuxt dependency
|
|
13
|
+
- Works in any JS/TS environment
|
|
14
|
+
|
|
15
|
+
## 📦 Installation
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install @meeovi/commerce
|
|
19
|
+
|
|
20
|
+
⚙️ Configuration
|
|
21
|
+
Configure the active providers at runtime:
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
import { setCommerceConfig } from '@meeovi/commerce'
|
|
25
|
+
|
|
26
|
+
setCommerceConfig({
|
|
27
|
+
productProvider: 'directus',
|
|
28
|
+
cartProvider: 'directus',
|
|
29
|
+
categoryProvider: 'directus'
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
🧩 Usage
|
|
33
|
+
|
|
34
|
+
import { useProducts } from '@meeovi/commerce'
|
|
35
|
+
|
|
36
|
+
const { listProducts, getProduct } = useProducts()
|
|
37
|
+
|
|
38
|
+
const products = await listProducts()
|
|
39
|
+
const product = await getProduct('123')
|
|
40
|
+
🔌 Providers
|
|
41
|
+
A provider implements one or more domain interfaces:
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
export interface ProductProvider {
|
|
45
|
+
getProduct(id: string): Promise<Product>
|
|
46
|
+
listProducts(params?: any): Promise<Product[]>
|
|
47
|
+
}
|
|
48
|
+
Register a provider:
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
import { registerProductProvider } from '@meeovi/commerce'
|
|
52
|
+
|
|
53
|
+
registerProductProvider('directus', {
|
|
54
|
+
getProduct: async (id) => { ... },
|
|
55
|
+
listProducts: async () => { ... }
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
🧱 Folder Structure
|
|
59
|
+
Code
|
|
60
|
+
src/
|
|
61
|
+
products/
|
|
62
|
+
cart/
|
|
63
|
+
categories/
|
|
64
|
+
config.
|
|
65
|
+
registry.
|
|
66
|
+
useCommerce.
|