@ecommaps/client 1.1.0 โ†’ 1.2.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 ADDED
@@ -0,0 +1,134 @@
1
+ # @ecommaps/client
2
+
3
+ [![NPM Version](https://img.shields.io/npm/v/@ecommaps/client)](https://www.npmjs.com/package/@ecommaps/client)
4
+ [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)
5
+
6
+ The official, high-performance JavaScript/TypeScript SDK for building custom, headless storefronts on the **Ecommaps** ecosystem. Designed for developers and AI agents to build, scale, and manage modern commerce experiences with ease.
7
+
8
+ ---
9
+
10
+ ## ๐Ÿš€ Quick Start
11
+
12
+ ### Installation
13
+
14
+ ```bash
15
+ npm install @ecommaps/client
16
+ # or
17
+ pnpm add @ecommaps/client
18
+ ```
19
+
20
+ ### Configuration
21
+
22
+ The client automatically reads from environment variables but can also be configured per request.
23
+
24
+ ```typescript
25
+ import { ecommapsClient } from "@ecommaps/client";
26
+
27
+ // Set these in your .env
28
+ // NEXT_PUBLIC_ECOMMAPS_API_URL=http://localhost:8001/api/v1/storefront
29
+ // ECOMMAPS_API_KEY=your_store_key
30
+ ```
31
+
32
+ ---
33
+
34
+ ## ๐Ÿ›  Features & Examples
35
+
36
+ ### ๐Ÿ” Authentication & Customer Profile
37
+ Handle customer sessions using industry-standard JWT.
38
+
39
+ ```typescript
40
+ // Login
41
+ const { token, user } = await ecommapsClient.auth.login({
42
+ email: "customer@example.com",
43
+ password: "secure_password"
44
+ });
45
+
46
+ // Get Current User Profile (Authenticated)
47
+ const { customer } = await ecommapsClient.auth.me({
48
+ headers: { Authorization: `Bearer ${token}` }
49
+ });
50
+
51
+ // Add Address to Customer Profile
52
+ await ecommapsClient.auth.addAddress({
53
+ line1: "123 Main St",
54
+ city: "Algiers",
55
+ state: "16",
56
+ country: "DZ",
57
+ postal_code: "16000",
58
+ phone: "0555000000",
59
+ label: "Home"
60
+ }, {
61
+ headers: { Authorization: `Bearer ${token}` }
62
+ });
63
+ ```
64
+
65
+ ### ๐Ÿ“ฆ Products & Collections
66
+ Retrieve catalog data with built-in pagination.
67
+
68
+ ```typescript
69
+ // List Products
70
+ const products = await ecommapsClient.products.list({ limit: 10, offset: 0 });
71
+
72
+ // Retrieve Single Product by Slug
73
+ const product = await ecommapsClient.products.retrieve("summer-t-shirt");
74
+
75
+ // List Collections
76
+ const { data: collections } = await ecommapsClient.collections.list();
77
+ ```
78
+
79
+ ### ๐Ÿ›’ Cart Management
80
+ Highly flexible cart APIs optimized for sub-second performance.
81
+
82
+ ```typescript
83
+ // Create a new Cart
84
+ const cart = await ecommapsClient.cart.create();
85
+
86
+ // Add Item
87
+ await ecommapsClient.cart.addItem(cart.id, {
88
+ product_id: "prod_123",
89
+ quantity: 2
90
+ });
91
+
92
+ // Retrieve Cart
93
+ const currentCart = await ecommapsClient.cart.retrieve(cart.id);
94
+ ```
95
+
96
+ ### ๐Ÿงพ Orders
97
+ Seamless order management from creation to tracking.
98
+
99
+ ```typescript
100
+ // List Customer Orders (Authenticated)
101
+ const { data: orders } = await ecommapsClient.orders.list({
102
+ headers: { Authorization: `Bearer ${token}` },
103
+ params: { limit: 5 }
104
+ });
105
+
106
+ // Retrieve Order Details
107
+ const order = await ecommapsClient.orders.retrieve("ECORD-2024-XXXX");
108
+ ```
109
+
110
+ ---
111
+
112
+ ## ๐Ÿค– AI Agent Integration (Skills)
113
+
114
+ This SDK is **Agent-Ready**. If you are an AI agent building for a user, follow these conventions:
115
+
116
+ 1. **Mapping**: Always map the backend JSON structure to the UI components (e.g., Use `line1` for `address_1`, `name` for `title`).
117
+ 2. **Context**: Use `ecommapsClient.auth.me` to verify user status before attempting protected operations.
118
+ 3. **Optimistic UI**: Use the returned data from cart/order operations to update local state immediately.
119
+
120
+ ---
121
+
122
+ ## ๐Ÿ— Developing the Storefront
123
+
124
+ To build a complete store:
125
+ 1. Initialize a Next.js 14+ project.
126
+ 2. Install `@ecommaps/client`.
127
+ 3. Use Next.js **Server Actions** to wrap SDK calls (see `auth` and `cart`).
128
+ 4. Implement **Dynamic Routing** (`/[slug]`) using `products.retrieve`.
129
+
130
+ ---
131
+
132
+ ## ๐Ÿ“„ License
133
+
134
+ Distributed under the ISC License. ยฉ 2026 EcoBaseAI.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecommaps/client",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "description": "The official JS SDK for Ecommaps Headless Storefronts.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -18,4 +18,4 @@
18
18
  },
19
19
  "author": "EcoBaseAI",
20
20
  "license": "ISC"
21
- }
21
+ }
package/package.json.bak DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "name": "ecommaps-client",
3
- "version": "1.0.0",
4
- "description": "",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "keywords": [],
10
- "author": "",
11
- "license": "ISC",
12
- "packageManager": "pnpm@10.24.0"
13
- }