@simpleapps-com/augur-api 0.2.6 → 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/QUICKSTART.md ADDED
@@ -0,0 +1,352 @@
1
+ # Experience the Magic: Zero to Production in 30 Seconds
2
+
3
+ Transform enterprise API complexity into pure business intent with intelligent discovery and context-aware client generation.
4
+
5
+ ## The Magic Revealed
6
+
7
+ Watch enterprise API chaos become elegant business logic:
8
+
9
+ ```typescript
10
+ import { AugurAPI } from '@simpleapps-com/augur-api';
11
+
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 });
38
+ ```
39
+
40
+ ## Installation - One Command
41
+
42
+ ```bash
43
+ npm install @simpleapps-com/augur-api
44
+ ```
45
+
46
+ ## First Contact: The 30-Second Demo
47
+
48
+ ### Instant Context Recognition
49
+
50
+ ```typescript
51
+ // Your context object (middleware, tool handlers, etc.)
52
+ const context = {
53
+ siteId: 'my-site-123',
54
+ jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
55
+ userId: 456
56
+ };
57
+
58
+ // Magic happens here - zero configuration
59
+ const api = AugurAPI.fromContext(context);
60
+
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`));
66
+ ```
67
+
68
+ **Expected output:**
69
+ ```
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
+ ...
77
+ ```
78
+
79
+ ### Natural Language Discovery
80
+
81
+ ```typescript
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)})`);
87
+ });
88
+
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
+ });
95
+ ```
96
+
97
+ ## Business Domain Intelligence
98
+
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
+ });
128
+ ```
129
+
130
+ ### Inventory Management Intelligence
131
+
132
+ ```typescript
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
+ ]
152
+ });
153
+ ```
154
+
155
+ ## Context Patterns That Just Work
156
+
157
+ ### Framework Integration Magic
158
+
159
+ ```typescript
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
+ }
189
+ ```
190
+
191
+ ### Dual Access Pattern Innovation
192
+
193
+ Every endpoint provides two access patterns for maximum developer productivity:
194
+
195
+ ```typescript
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
+ });
211
+ ```
212
+
213
+ ## Business Capability Explorer
214
+
215
+ The platform connects you to comprehensive business operations across 13 microservices:
216
+
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 |
224
+
225
+ ## Intelligent Caching Architecture
226
+
227
+ Business-aware caching that understands data volatility:
228
+
229
+ ```typescript
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 });
233
+
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 });
237
+
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 });
241
+
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);
245
+ ```
246
+
247
+ ## Pattern Recognition & Workflows
248
+
249
+ ### Business Process Discovery
250
+
251
+ ```typescript
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
255
+
256
+ const inventoryWorkflow = await api.findEndpoint('inventory optimization');
257
+ // Suggests: availability check → replenishment calculation → distributor ordering
258
+
259
+ const contentWorkflow = await api.findEndpoint('AI content generation');
260
+ // Suggests: content analysis → AI enhancement → search optimization
261
+ ```
262
+
263
+ ### Advanced Search Intelligence
264
+
265
+ ```typescript
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
272
+ });
273
+
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(', ')}`);
280
+ });
281
+ ```
282
+
283
+ ## Next Steps: Explore the Platform
284
+
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
289
+
290
+ ## You're Now Ready for Production
291
+
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
298
+
299
+ The platform transforms enterprise API complexity into elegant business logic. Start building!
300
+
301
+ ## Error Handling
302
+
303
+ Wrap your API calls in try/catch:
304
+
305
+ ```typescript
306
+ try {
307
+ const users = await api.joomla.users.list();
308
+ console.log('Got users:', users.data.length);
309
+ } catch (error) {
310
+ if (error.message.includes('401')) {
311
+ console.error('Authentication failed - check your token');
312
+ } else if (error.message.includes('404')) {
313
+ console.error('Endpoint not found - check your URL');
314
+ } else {
315
+ console.error('Something else went wrong:', error.message);
316
+ }
317
+ }
318
+ ```
319
+
320
+ ## Troubleshooting
321
+
322
+ **"Authentication failed"**
323
+ - Check your `bearerToken` is correct and not expired
324
+ - Verify your `siteId` matches your environment
325
+
326
+ **"Cannot find endpoint"**
327
+ - Try a health check first: `api.joomla.getHealthCheck()`
328
+ - Verify you're using the right service name
329
+
330
+ **"Network error"**
331
+ - Check your internet connection
332
+ - Verify the API endpoints are accessible from your network
333
+
334
+ **"Validation error"**
335
+ - Check the parameter names and types match the examples
336
+ - Look at the error message for specific field issues
337
+
338
+ ## Next Steps
339
+
340
+ 1. **Read the main [README](./README.md)** for comprehensive documentation
341
+ 2. **Explore the [API Discovery Guide](./API-DISCOVERY.md)** to find functionality
342
+ 3. **Check the Integration Guides** in the README for React, Node.js, etc.
343
+ 4. **Look at Error Handling** section for production-ready error management
344
+
345
+ ## Need Help?
346
+
347
+ - Check the comprehensive [README](./README.md) for detailed examples
348
+ - Use `api.discover()` to explore available functionality
349
+ - Look at the error messages - they usually tell you what's wrong
350
+ - Ask your team lead or system administrator for credentials
351
+
352
+ You're ready to build! Start with simple calls like listing users or checking health, then gradually explore more functionality as you need it.