@simpleapps-com/augur-api 0.2.7 → 0.2.8
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/API-DISCOVERY.md +206 -83
- package/QUICKSTART.md +232 -135
- package/README.md +368 -97
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/services/commerce/client.d.ts +222 -18
- package/dist/cjs/services/commerce/client.d.ts.map +1 -1
- package/dist/cjs/services/commerce/client.js +156 -17
- package/dist/cjs/services/commerce/client.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/services/commerce/client.d.ts +222 -18
- package/dist/esm/services/commerce/client.d.ts.map +1 -1
- package/dist/esm/services/commerce/client.js +156 -17
- package/dist/esm/services/commerce/client.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/services/commerce/client.d.ts +222 -18
- package/dist/types/services/commerce/client.d.ts.map +1 -1
- package/package.json +1 -1
package/QUICKSTART.md
CHANGED
|
@@ -1,205 +1,302 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Experience the Magic: Zero to Production in 30 Seconds
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Transform enterprise API complexity into pure business intent with intelligent discovery and context-aware client generation.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## The Magic Revealed
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Watch enterprise API chaos become elegant business logic:
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
```typescript
|
|
10
|
+
import { AugurAPI } from '@simpleapps-com/augur-api';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
// Instead of this enterprise nightmare (35+ lines)
|
|
13
|
+
const userJwt = await getToken({ req: request });
|
|
14
|
+
if (!userJwt?.jwtToken) {
|
|
15
|
+
throw new Error('Authentication failed');
|
|
16
|
+
}
|
|
17
|
+
const apiConfig = {
|
|
18
|
+
siteId: context.siteId,
|
|
19
|
+
bearerToken: userJwt.jwtToken,
|
|
20
|
+
timeout: 30000,
|
|
21
|
+
retries: 3,
|
|
22
|
+
headers: { 'x-site-id': context.siteId }
|
|
23
|
+
};
|
|
24
|
+
const api = new AugurAPI(apiConfig);
|
|
25
|
+
|
|
26
|
+
// Pure business intent ✨
|
|
27
|
+
const api = AugurAPI.fromContext(context);
|
|
28
|
+
|
|
29
|
+
// Ask for anything - the system finds it
|
|
30
|
+
const userOps = await api.findEndpoint('user management');
|
|
31
|
+
const inventory = await api.findEndpoint('stock levels');
|
|
32
|
+
const pricing = await api.findEndpoint('product pricing');
|
|
33
|
+
|
|
34
|
+
// Code that reads like business requirements
|
|
35
|
+
const users = await api.joomla.users.list({ limit: 10, edgeCache: 2 });
|
|
36
|
+
const availability = await api.vmi.inventory.checkAvailability(warehouse);
|
|
37
|
+
const price = await api.pricing.getPrice({ customerId, itemId, quantity });
|
|
13
38
|
```
|
|
14
39
|
|
|
15
|
-
##
|
|
16
|
-
|
|
17
|
-
### Step 1: Get Your Credentials
|
|
40
|
+
## Installation - One Command
|
|
18
41
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
42
|
+
```bash
|
|
43
|
+
npm install @simpleapps-com/augur-api
|
|
44
|
+
```
|
|
22
45
|
|
|
23
|
-
|
|
46
|
+
## First Contact: The 30-Second Demo
|
|
24
47
|
|
|
25
|
-
###
|
|
48
|
+
### Instant Context Recognition
|
|
26
49
|
|
|
27
50
|
```typescript
|
|
28
|
-
|
|
51
|
+
// Your context object (middleware, tool handlers, etc.)
|
|
52
|
+
const context = {
|
|
53
|
+
siteId: 'my-site-123',
|
|
54
|
+
jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
|
|
55
|
+
userId: 456
|
|
56
|
+
};
|
|
29
57
|
|
|
30
|
-
//
|
|
31
|
-
const api =
|
|
32
|
-
siteId: 'your-site-id', // Replace with your actual site ID
|
|
33
|
-
bearerToken: 'your-jwt-token' // Replace with your actual token
|
|
34
|
-
});
|
|
58
|
+
// Magic happens here - zero configuration
|
|
59
|
+
const api = AugurAPI.fromContext(context);
|
|
35
60
|
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} catch (error) {
|
|
42
|
-
console.error('Something went wrong:', error.message);
|
|
43
|
-
}
|
|
61
|
+
// Verify the magic worked
|
|
62
|
+
const services = await api.discover();
|
|
63
|
+
console.log(`🚀 Connected to ${services.length} business services`);
|
|
64
|
+
console.log('Available capabilities:');
|
|
65
|
+
services.forEach(s => console.log(` ${s.serviceName}: ${s.endpointCount} operations`));
|
|
44
66
|
```
|
|
45
67
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
If you see output like this, you're ready to go:
|
|
68
|
+
**Expected output:**
|
|
49
69
|
```
|
|
50
|
-
|
|
51
|
-
|
|
70
|
+
🚀 Connected to 13 business services
|
|
71
|
+
Available capabilities:
|
|
72
|
+
joomla: 24 operations
|
|
73
|
+
commerce: 18 operations
|
|
74
|
+
pricing: 12 operations
|
|
75
|
+
vmi: 31 operations
|
|
76
|
+
...
|
|
52
77
|
```
|
|
53
78
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
### Health Check (No Authentication Required)
|
|
57
|
-
Test your connection without needing authentication:
|
|
79
|
+
### Natural Language Discovery
|
|
58
80
|
|
|
59
81
|
```typescript
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
82
|
+
// Never memorize endpoints again
|
|
83
|
+
const userStuff = await api.findEndpoint('user management');
|
|
84
|
+
console.log('User operations found:');
|
|
85
|
+
userStuff.forEach(result => {
|
|
86
|
+
console.log(` ${result.endpoint.fullPath} (${result.score.toFixed(2)})`);
|
|
63
87
|
});
|
|
64
88
|
|
|
65
|
-
|
|
66
|
-
|
|
89
|
+
// Find inventory operations
|
|
90
|
+
const inventoryOps = await api.findEndpoint('stock management');
|
|
91
|
+
console.log('Inventory operations found:');
|
|
92
|
+
inventoryOps.forEach(result => {
|
|
93
|
+
console.log(` ${result.endpoint.fullPath} - ${result.matchReason}`);
|
|
94
|
+
});
|
|
67
95
|
```
|
|
68
96
|
|
|
69
|
-
|
|
70
|
-
Create a `.env` file in your project:
|
|
97
|
+
## Business Domain Intelligence
|
|
71
98
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
99
|
+
The platform understands your business context and connects related operations:
|
|
100
|
+
|
|
101
|
+
### E-commerce Workflow Discovery
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
// Search by business process, not technical implementation
|
|
105
|
+
const ecommerce = await api.findEndpoint('customer shopping experience');
|
|
106
|
+
|
|
107
|
+
// Platform suggests complete workflow:
|
|
108
|
+
// 1. Product discovery: api.opensearch.itemSearch.search()
|
|
109
|
+
// 2. Pricing calculation: api.pricing.getPrice()
|
|
110
|
+
// 3. Cart management: api.commerce.cartHeaders.lookup()
|
|
111
|
+
// 4. Checkout process: api.commerce.checkout.get()
|
|
112
|
+
// 5. Payment processing: api.payments.unified.transactionSetup()
|
|
113
|
+
|
|
114
|
+
// Execute the workflow
|
|
115
|
+
const products = await api.opensearch.itemSearch.search({
|
|
116
|
+
q: 'electrical wire 12 AWG',
|
|
117
|
+
searchType: 'query',
|
|
118
|
+
size: 20,
|
|
119
|
+
edgeCache: 4 // Intelligent caching
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const pricing = await api.pricing.getPrice({
|
|
123
|
+
customerId: 12345,
|
|
124
|
+
itemId: products.data.items[0].item_id,
|
|
125
|
+
quantity: 100,
|
|
126
|
+
edgeCache: 3 // Business-aware TTL
|
|
127
|
+
});
|
|
76
128
|
```
|
|
77
129
|
|
|
78
|
-
|
|
130
|
+
### Inventory Management Intelligence
|
|
79
131
|
|
|
80
132
|
```typescript
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
133
|
+
// Natural language reveals complex operations
|
|
134
|
+
const inventory = await api.findEndpoint('warehouse stock management');
|
|
135
|
+
|
|
136
|
+
// Platform maps the complete inventory ecosystem:
|
|
137
|
+
const warehouses = await api.vmi.warehouses.list({
|
|
138
|
+
customerId: 12345,
|
|
139
|
+
edgeCache: 4 // Reference data cached longer
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const availability = await api.vmi.inventory.checkAvailability(warehouses.data[0].warehouse_uid, {
|
|
143
|
+
q: 'electrical' // Smart search within inventory
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// Context-aware replenishment
|
|
147
|
+
await api.vmi.inventory.replenish(warehouse.warehouse_uid, {
|
|
148
|
+
distributor_uid: 789,
|
|
149
|
+
restock_items: [
|
|
150
|
+
{ inv_mast_uid: 456, qty_to_order: 100.0 }
|
|
151
|
+
]
|
|
84
152
|
});
|
|
85
153
|
```
|
|
86
154
|
|
|
87
|
-
##
|
|
155
|
+
## Context Patterns That Just Work
|
|
88
156
|
|
|
89
|
-
|
|
157
|
+
### Framework Integration Magic
|
|
90
158
|
|
|
91
159
|
```typescript
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
//
|
|
103
|
-
|
|
104
|
-
const
|
|
160
|
+
// Express.js middleware
|
|
161
|
+
app.use((req, res, next) => {
|
|
162
|
+
req.api = AugurAPI.fromContext({
|
|
163
|
+
siteId: req.headers['x-site-id'],
|
|
164
|
+
jwt: req.headers.authorization?.replace('Bearer ', ''),
|
|
165
|
+
userId: req.user?.id
|
|
166
|
+
});
|
|
167
|
+
next();
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// Next.js API routes
|
|
171
|
+
export default async function handler(req, res) {
|
|
172
|
+
const api = AugurAPI.fromContext({
|
|
173
|
+
siteId: process.env.NEXT_PUBLIC_SITE_ID,
|
|
174
|
+
jwt: req.session.accessToken
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
const users = await api.joomla.users.list();
|
|
178
|
+
res.json(users);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// React components with hooks
|
|
182
|
+
function useAugurAPI() {
|
|
183
|
+
const { session } = useAuth();
|
|
184
|
+
return useMemo(() => AugurAPI.fromContext({
|
|
185
|
+
siteId: process.env.REACT_APP_SITE_ID,
|
|
186
|
+
jwt: session?.token
|
|
187
|
+
}), [session]);
|
|
188
|
+
}
|
|
105
189
|
```
|
|
106
190
|
|
|
107
|
-
|
|
191
|
+
### Dual Access Pattern Innovation
|
|
108
192
|
|
|
109
|
-
Every
|
|
193
|
+
Every endpoint provides two access patterns for maximum developer productivity:
|
|
110
194
|
|
|
111
195
|
```typescript
|
|
112
|
-
//
|
|
113
|
-
const response = await api.joomla.users.list();
|
|
114
|
-
console.log(
|
|
115
|
-
console.log(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
196
|
+
// Metadata-rich response (when you need context)
|
|
197
|
+
const response = await api.joomla.users.list({ limit: 10 });
|
|
198
|
+
console.log(`Found ${response.data.length} of ${response.totalResults} users`);
|
|
199
|
+
console.log(`Request status: ${response.message}`);
|
|
200
|
+
console.log(`Response metadata:`, response.params);
|
|
201
|
+
|
|
202
|
+
// Pure data access (when you just want the data)
|
|
203
|
+
const users = await api.joomla.users.listData({ limit: 10 });
|
|
204
|
+
console.log(users); // Direct array - no wrapper object
|
|
205
|
+
|
|
206
|
+
// Both methods support the same parameters and caching
|
|
207
|
+
const cachedUsers = await api.joomla.users.listData({
|
|
208
|
+
limit: 10,
|
|
209
|
+
edgeCache: 2 // Cache for 2 hours
|
|
210
|
+
});
|
|
120
211
|
```
|
|
121
212
|
|
|
122
|
-
##
|
|
213
|
+
## Business Capability Explorer
|
|
123
214
|
|
|
124
|
-
The
|
|
215
|
+
The platform connects you to comprehensive business operations across 13 microservices:
|
|
125
216
|
|
|
126
|
-
|
|
|
127
|
-
|
|
128
|
-
| **
|
|
129
|
-
| **commerce** |
|
|
130
|
-
| **
|
|
131
|
-
| **
|
|
132
|
-
| **
|
|
133
|
-
| **items** | Product catalog | `api.items.categories.list()` |
|
|
134
|
-
| **customers** | Customer data | `api.customers.customer.list()` |
|
|
217
|
+
| Business Domain | Platform Services | Intelligence Level |
|
|
218
|
+
|-----------------|-------------------|-------------------|
|
|
219
|
+
| **User & Identity** | `joomla.users`, `customers.customer` | Cross-service user correlation |
|
|
220
|
+
| **E-commerce** | `commerce.cartHeaders`, `opensearch.itemSearch`, `pricing.getPrice` | Complete shopping workflows |
|
|
221
|
+
| **Inventory** | `vmi.warehouses`, `vmi.inventory`, `items.products` | Supply chain intelligence |
|
|
222
|
+
| **Orders & Fulfillment** | `orders.orders`, `payments.unified`, `nexus.binTransfers` | End-to-end order processing |
|
|
223
|
+
| **Content & AI** | `agrSite.settings`, `p21Pim.items.suggestWebDescription` | AI-enhanced content management |
|
|
135
224
|
|
|
136
|
-
##
|
|
225
|
+
## Intelligent Caching Architecture
|
|
226
|
+
|
|
227
|
+
Business-aware caching that understands data volatility:
|
|
137
228
|
|
|
138
|
-
### List Things with Limits
|
|
139
229
|
```typescript
|
|
140
|
-
//
|
|
141
|
-
const
|
|
230
|
+
// Reference data - cache aggressively (8 hours)
|
|
231
|
+
const categories = await api.items.categories.list({ edgeCache: 8 });
|
|
232
|
+
const distributors = await api.vmi.distributors.list({ edgeCache: 8 });
|
|
142
233
|
|
|
143
|
-
//
|
|
144
|
-
const
|
|
145
|
-
|
|
234
|
+
// Operational data - moderate caching (2-4 hours)
|
|
235
|
+
const users = await api.joomla.users.list({ limit: 50, edgeCache: 2 });
|
|
236
|
+
const warehouses = await api.vmi.warehouses.list({ customerId: 12345, edgeCache: 4 });
|
|
146
237
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const user = await api.joomla.users.get('123');
|
|
238
|
+
// Transactional data - short caching (1 hour)
|
|
239
|
+
const cart = await api.commerce.cartHeaders.list({ userId: 123, edgeCache: 1 });
|
|
240
|
+
const pricing = await api.pricing.getPrice({ customerId, itemId, quantity, edgeCache: 1 });
|
|
151
241
|
|
|
152
|
-
//
|
|
153
|
-
const
|
|
242
|
+
// Real-time operations - never cached
|
|
243
|
+
const auth = await api.joomla.users.verifyPassword({ username, password });
|
|
244
|
+
const checkout = await api.commerce.checkout.get(checkoutUid);
|
|
154
245
|
```
|
|
155
246
|
|
|
156
|
-
|
|
247
|
+
## Pattern Recognition & Workflows
|
|
248
|
+
|
|
249
|
+
### Business Process Discovery
|
|
250
|
+
|
|
157
251
|
```typescript
|
|
158
|
-
//
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
size: 10 // Number of results
|
|
162
|
-
});
|
|
163
|
-
```
|
|
252
|
+
// The platform understands business processes
|
|
253
|
+
const customerJourney = await api.findEndpoint('customer lifecycle management');
|
|
254
|
+
// Suggests: user creation → customer profile → order history → payment setup
|
|
164
255
|
|
|
165
|
-
|
|
256
|
+
const inventoryWorkflow = await api.findEndpoint('inventory optimization');
|
|
257
|
+
// Suggests: availability check → replenishment calculation → distributor ordering
|
|
166
258
|
|
|
167
|
-
|
|
259
|
+
const contentWorkflow = await api.findEndpoint('AI content generation');
|
|
260
|
+
// Suggests: content analysis → AI enhancement → search optimization
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Advanced Search Intelligence
|
|
168
264
|
|
|
169
265
|
```typescript
|
|
170
|
-
//
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
266
|
+
// Multi-criteria business search
|
|
267
|
+
const results = await api.findEndpoint('customer service operations', {
|
|
268
|
+
domain: 'customer-management', // Business domain filter
|
|
269
|
+
readOnly: true, // Only query operations
|
|
270
|
+
minScore: 0.3, // High relevance threshold
|
|
271
|
+
maxResults: 5 // Focused results
|
|
174
272
|
});
|
|
175
273
|
|
|
176
|
-
//
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
274
|
+
// Each result includes business context
|
|
275
|
+
results.forEach(result => {
|
|
276
|
+
console.log(`Operation: ${result.endpoint.fullPath}`);
|
|
277
|
+
console.log(`Business value: ${result.endpoint.description}`);
|
|
278
|
+
console.log(`Workflow stage: ${result.endpoint.domain}`);
|
|
279
|
+
console.log(`Related ops: ${result.endpoint.relatedEndpoints.join(', ')}`);
|
|
181
280
|
});
|
|
182
281
|
```
|
|
183
282
|
|
|
184
|
-
|
|
283
|
+
## Next Steps: Explore the Platform
|
|
185
284
|
|
|
186
|
-
|
|
285
|
+
- **[Complete Platform Guide](./README.md)** - Discover all advanced capabilities
|
|
286
|
+
- **[AI Discovery System](./API-DISCOVERY.md)** - Master natural language API navigation
|
|
287
|
+
- **[Integration Patterns](./README.md#platform-integration)** - React, Next.js, Node.js examples
|
|
288
|
+
- **[Performance Optimization](./README.md#performance--caching)** - Advanced caching strategies
|
|
187
289
|
|
|
188
|
-
|
|
290
|
+
## You're Now Ready for Production
|
|
189
291
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
// Find specific functionality
|
|
198
|
-
const userStuff = await api.findEndpoint('user management');
|
|
199
|
-
const inventoryStuff = await api.findEndpoint('inventory');
|
|
200
|
-
```
|
|
292
|
+
You've experienced the magic:
|
|
293
|
+
- ✅ Context-aware client creation eliminates boilerplate
|
|
294
|
+
- ✅ Natural language discovery replaces documentation hunting
|
|
295
|
+
- ✅ Business-aware caching optimizes performance automatically
|
|
296
|
+
- ✅ Cross-service intelligence reveals complete workflows
|
|
297
|
+
- ✅ Dual access patterns maximize developer productivity
|
|
201
298
|
|
|
202
|
-
|
|
299
|
+
The platform transforms enterprise API complexity into elegant business logic. Start building!
|
|
203
300
|
|
|
204
301
|
## Error Handling
|
|
205
302
|
|