@simpleapps-com/augur-api 0.4.7 → 0.4.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/README.md +96 -141
- package/TIPS-AND-TRICKS.md +887 -0
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/services/items/client.d.ts +4 -36
- package/dist/cjs/services/items/client.d.ts.map +1 -1
- package/dist/cjs/services/items/schemas/invMast.d.ts +17 -17
- package/dist/cjs/services/items/schemas/invMast.js +1 -1
- package/dist/cjs/services/items/schemas/invMast.js.map +1 -1
- package/dist/cjs/services/items/schemas/invMastLocationsBins.d.ts +20 -148
- package/dist/cjs/services/items/schemas/invMastLocationsBins.d.ts.map +1 -1
- package/dist/cjs/services/items/schemas/invMastLocationsBins.js +10 -10
- package/dist/cjs/services/items/schemas/invMastLocationsBins.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/services/items/client.d.ts +4 -36
- package/dist/esm/services/items/client.d.ts.map +1 -1
- package/dist/esm/services/items/schemas/invMast.d.ts +17 -17
- package/dist/esm/services/items/schemas/invMast.js +1 -1
- package/dist/esm/services/items/schemas/invMast.js.map +1 -1
- package/dist/esm/services/items/schemas/invMastLocationsBins.d.ts +20 -148
- package/dist/esm/services/items/schemas/invMastLocationsBins.d.ts.map +1 -1
- package/dist/esm/services/items/schemas/invMastLocationsBins.js +10 -10
- package/dist/esm/services/items/schemas/invMastLocationsBins.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/services/items/client.d.ts +4 -36
- package/dist/types/services/items/client.d.ts.map +1 -1
- package/dist/types/services/items/schemas/invMast.d.ts +17 -17
- package/dist/types/services/items/schemas/invMastLocationsBins.d.ts +20 -148
- package/dist/types/services/items/schemas/invMastLocationsBins.d.ts.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1092,6 +1092,8 @@ if (result.success) {
|
|
|
1092
1092
|
|
|
1093
1093
|
📋 **[Complete API Services Reference](./API-SERVICES.md)** - Detailed catalog of all 26 services with descriptions, OpenAPI specifications, and Postman collections.
|
|
1094
1094
|
|
|
1095
|
+
💡 **[Tips and Tricks Guide](./TIPS-AND-TRICKS.md)** - Advanced usage patterns, performance optimizations, and helpful techniques including the itemId → invMastUid lookup pattern.
|
|
1096
|
+
|
|
1095
1097
|
### Complete Endpoint Reference
|
|
1096
1098
|
|
|
1097
1099
|
#### Joomla Service
|
|
@@ -1477,6 +1479,65 @@ const ping = await api.opensearch.health.ping();
|
|
|
1477
1479
|
const health = await api.opensearch.health.check();
|
|
1478
1480
|
```
|
|
1479
1481
|
|
|
1482
|
+
#### Items Service
|
|
1483
|
+
|
|
1484
|
+
```typescript
|
|
1485
|
+
// Inventory Master Records
|
|
1486
|
+
const itemDetails = await api.items.invMast.get(invMastUid);
|
|
1487
|
+
|
|
1488
|
+
// Document retrieval for invMast records
|
|
1489
|
+
const itemDoc = await api.items.invMast.doc.get(invMastUid, {
|
|
1490
|
+
q: 'optional-query-pattern' // Search pattern for document filtering
|
|
1491
|
+
});
|
|
1492
|
+
|
|
1493
|
+
// Special lookup pattern: Find invMastUid by itemId
|
|
1494
|
+
// When you only have an itemId but need the invMastUid, use invMastUid = 0
|
|
1495
|
+
// and provide the itemId as the query pattern. This will look up the itemId
|
|
1496
|
+
// and return the full document including the correct invMastUid.
|
|
1497
|
+
const itemByItemId = await api.items.invMast.doc.get(0, {
|
|
1498
|
+
q: 'YOUR-ITEM-ID' // Replace with actual itemId (e.g., 'WIRE-12-AWG-250FT')
|
|
1499
|
+
});
|
|
1500
|
+
// Response includes the actual invMastUid for future direct lookups
|
|
1501
|
+
|
|
1502
|
+
// Categories and attributes
|
|
1503
|
+
const categories = await api.items.categories.list({
|
|
1504
|
+
limit: 50,
|
|
1505
|
+
edgeCache: 8 // Categories rarely change
|
|
1506
|
+
});
|
|
1507
|
+
|
|
1508
|
+
// Product locations and bins
|
|
1509
|
+
const locations = await api.items.invMast.locations.list(invMastUid);
|
|
1510
|
+
const bins = await api.items.invMast.locations.bins.list(invMastUid, locationId);
|
|
1511
|
+
|
|
1512
|
+
// Alternate codes and variants
|
|
1513
|
+
const alternates = await api.items.invMast.alternateCode.list(invMastUid);
|
|
1514
|
+
const variants = await api.items.variants.list({
|
|
1515
|
+
invMastUid: invMastUid,
|
|
1516
|
+
edgeCache: 4 // Variants change occasionally
|
|
1517
|
+
});
|
|
1518
|
+
|
|
1519
|
+
// Attributes and values
|
|
1520
|
+
const attributes = await api.items.attributes.list({
|
|
1521
|
+
edgeCache: 6 // Attribute structure is relatively stable
|
|
1522
|
+
});
|
|
1523
|
+
|
|
1524
|
+
const attributeValues = await api.items.attributes.values.list(attributeUid);
|
|
1525
|
+
|
|
1526
|
+
// Brands and product links
|
|
1527
|
+
const brands = await api.items.brands.list({
|
|
1528
|
+
edgeCache: 8 // Brand data is very stable
|
|
1529
|
+
});
|
|
1530
|
+
|
|
1531
|
+
const productLinks = await api.items.productLinks.list({
|
|
1532
|
+
invMastUid: invMastUid,
|
|
1533
|
+
edgeCache: 2 // Product links may change
|
|
1534
|
+
});
|
|
1535
|
+
|
|
1536
|
+
// Health Monitoring
|
|
1537
|
+
const ping = await api.items.ping();
|
|
1538
|
+
const health = await api.items.healthCheck.get();
|
|
1539
|
+
```
|
|
1540
|
+
|
|
1480
1541
|
### Response Format
|
|
1481
1542
|
|
|
1482
1543
|
All Augur microservices follow a unified response pattern:
|
|
@@ -1570,166 +1631,60 @@ try {
|
|
|
1570
1631
|
|
|
1571
1632
|
## Advanced Features
|
|
1572
1633
|
|
|
1573
|
-
|
|
1634
|
+
💡 **[Complete Tips and Tricks Guide](./TIPS-AND-TRICKS.md)** - Comprehensive advanced patterns including edge caching, request cancellation, middleware integration, framework integrations, and error handling strategies.
|
|
1574
1635
|
|
|
1575
|
-
|
|
1636
|
+
**Quick Advanced Features:**
|
|
1637
|
+
- **Edge Caching**: Built-in Cloudflare caching with configurable TTL (1-8 hours)
|
|
1638
|
+
- **Request Cancellation**: AbortController support for request timeout
|
|
1639
|
+
- **Custom Headers**: Per-request configuration and timeouts
|
|
1640
|
+
- **Batch Operations**: Parallel request execution with Promise.all
|
|
1641
|
+
- **Middleware**: Global request/response/error interceptors
|
|
1576
1642
|
|
|
1577
|
-
|
|
1643
|
+
## Integration Guides
|
|
1578
1644
|
|
|
1579
|
-
|
|
1645
|
+
💡 **[Complete Framework Integration Examples](./TIPS-AND-TRICKS.md#-framework-integration-patterns)** - Detailed React, Next.js, React Native, and Node.js integration patterns with custom hooks, error handling, and best practices.
|
|
1580
1646
|
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
| `4` | 4 hours | Recommendations, warehouse data |
|
|
1587
|
-
| `5` | 5 hours | Tags, categories, reference data |
|
|
1588
|
-
| `8` | 8 hours | Static content, distributor information |
|
|
1647
|
+
**Quick Integration Examples:**
|
|
1648
|
+
- **React**: Custom `useAugurAPI()` hook with context-aware API creation
|
|
1649
|
+
- **Next.js**: Server-side API routes with proper caching and error handling
|
|
1650
|
+
- **React Native**: AsyncStorage integration for offline-first patterns
|
|
1651
|
+
- **Node.js**: Service layer integration with middleware and monitoring
|
|
1589
1652
|
|
|
1590
|
-
|
|
1653
|
+
## Framework-Specific Features
|
|
1591
1654
|
|
|
1655
|
+
### React/Next.js
|
|
1592
1656
|
```typescript
|
|
1593
|
-
//
|
|
1594
|
-
|
|
1595
|
-
// This triggers Cloudflare cache rules for 4-hour TTL
|
|
1596
|
-
|
|
1597
|
-
const users = await api.joomla.users.list({
|
|
1598
|
-
limit: 20,
|
|
1599
|
-
edgeCache: 4 // Cached at edge for 4 hours
|
|
1600
|
-
});
|
|
1601
|
-
```
|
|
1602
|
-
|
|
1603
|
-
#### Caching Best Practices
|
|
1604
|
-
|
|
1605
|
-
```typescript
|
|
1606
|
-
// ✅ Good: Cache stable reference data
|
|
1607
|
-
const categories = await api.items.categories.list({
|
|
1608
|
-
edgeCache: 8 // Categories rarely change
|
|
1609
|
-
});
|
|
1610
|
-
|
|
1611
|
-
// ✅ Good: Cache with appropriate TTL
|
|
1612
|
-
const pricing = await api.pricing.getPrice({
|
|
1613
|
-
customerId: 12345,
|
|
1614
|
-
itemId: 'STANDARD-ITEM',
|
|
1615
|
-
quantity: 10,
|
|
1616
|
-
edgeCache: 3 // Standard pricing changes infrequently
|
|
1617
|
-
});
|
|
1618
|
-
|
|
1619
|
-
// ✅ Good: Short cache for volatile data
|
|
1620
|
-
const cart = await api.commerce.cartHeaders.list({
|
|
1621
|
-
userId: 123,
|
|
1622
|
-
edgeCache: 1 // Cart data changes frequently
|
|
1623
|
-
});
|
|
1624
|
-
|
|
1625
|
-
// ❌ Bad: Don't cache real-time operations
|
|
1626
|
-
const auth = await api.joomla.users.verifyPassword({
|
|
1627
|
-
username: 'user',
|
|
1628
|
-
password: 'pass'
|
|
1629
|
-
// No edgeCache - authentication must be real-time
|
|
1630
|
-
});
|
|
1657
|
+
// Context-aware API creation
|
|
1658
|
+
const api = AugurAPI.fromContext(context);
|
|
1631
1659
|
|
|
1632
|
-
//
|
|
1633
|
-
const
|
|
1634
|
-
q: 'search',
|
|
1635
|
-
edgeCache: 8 // Too long for inventory data
|
|
1636
|
-
});
|
|
1660
|
+
// Custom hook pattern
|
|
1661
|
+
const { api, isReady } = useAugurAPI();
|
|
1637
1662
|
```
|
|
1638
1663
|
|
|
1639
|
-
###
|
|
1640
|
-
|
|
1664
|
+
### Error Handling Integration
|
|
1641
1665
|
```typescript
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
// Start a request
|
|
1645
|
-
const usersPromise = api.joomla.users.list(
|
|
1646
|
-
{ limit: 100 },
|
|
1647
|
-
{ signal: controller.signal } // Pass abort signal
|
|
1648
|
-
);
|
|
1649
|
-
|
|
1650
|
-
// Cancel the request if needed
|
|
1651
|
-
setTimeout(() => {
|
|
1652
|
-
controller.abort();
|
|
1653
|
-
}, 5000);
|
|
1654
|
-
|
|
1666
|
+
// Framework-agnostic error handling
|
|
1655
1667
|
try {
|
|
1656
|
-
const
|
|
1668
|
+
const result = await api.joomla.users.list({ limit: 10 });
|
|
1657
1669
|
} catch (error) {
|
|
1658
|
-
|
|
1659
|
-
console.log('Request was cancelled');
|
|
1660
|
-
}
|
|
1670
|
+
ErrorHandler.handle(error, 'UserList Component');
|
|
1661
1671
|
}
|
|
1662
1672
|
```
|
|
1663
1673
|
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
```typescript
|
|
1667
|
-
// Per-request configuration
|
|
1668
|
-
const users = await api.joomla.users.list(
|
|
1669
|
-
{ limit: 20 },
|
|
1670
|
-
{
|
|
1671
|
-
timeout: 10000, // 10 second timeout
|
|
1672
|
-
headers: {
|
|
1673
|
-
'X-Custom-Header': 'value',
|
|
1674
|
-
'X-Request-ID': 'unique-id'
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1677
|
-
);
|
|
1678
|
-
```
|
|
1679
|
-
|
|
1680
|
-
### Batch Operations
|
|
1681
|
-
|
|
1682
|
-
```typescript
|
|
1683
|
-
// Execute multiple operations in parallel
|
|
1684
|
-
const [users, articles, tags] = await Promise.all([
|
|
1685
|
-
api.joomla.users.list({ limit: 10, edgeCache: 2 }),
|
|
1686
|
-
api.joomla.content.list({ limit: 5, edgeCache: 6 }),
|
|
1687
|
-
api.joomla.tags.list({ limit: 20, edgeCache: 8 })
|
|
1688
|
-
]);
|
|
1689
|
-
|
|
1690
|
-
// Process results
|
|
1691
|
-
console.log(`Found ${users.data.length} users`);
|
|
1692
|
-
console.log(`Found ${articles.data.length} articles`);
|
|
1693
|
-
console.log(`Found ${tags.data.length} tags`);
|
|
1694
|
-
```
|
|
1674
|
+
## Error Handling
|
|
1695
1675
|
|
|
1696
|
-
|
|
1676
|
+
💡 **[Complete Error Handling Guide](./TIPS-AND-TRICKS.md#️-advanced-error-handling)** - Comprehensive error handling patterns including retry logic, exponential backoff, global error handlers, and framework-specific error boundaries.
|
|
1697
1677
|
|
|
1678
|
+
**Quick Error Types:**
|
|
1698
1679
|
```typescript
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
//
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
config.headers['X-Request-Timestamp'] = Date.now().toString();
|
|
1708
|
-
return config;
|
|
1709
|
-
},
|
|
1710
|
-
|
|
1711
|
-
// Response interceptor
|
|
1712
|
-
onResponse: (response) => {
|
|
1713
|
-
console.log(`Response status: ${response.status}`);
|
|
1714
|
-
return response;
|
|
1715
|
-
},
|
|
1716
|
-
|
|
1717
|
-
// Error interceptor
|
|
1718
|
-
onError: (error) => {
|
|
1719
|
-
console.error('API Error:', error.message);
|
|
1720
|
-
// Custom error handling logic
|
|
1721
|
-
throw error;
|
|
1722
|
-
}
|
|
1723
|
-
});
|
|
1724
|
-
```
|
|
1725
|
-
|
|
1726
|
-
## Integration Guides
|
|
1727
|
-
|
|
1728
|
-
### React Integration
|
|
1729
|
-
|
|
1730
|
-
```tsx
|
|
1731
|
-
import React, { useState, useEffect } from 'react';
|
|
1732
|
-
import { AugurAPI, User, AugurAPIError, type AugurContext } from '@simpleapps-com/augur-api';
|
|
1680
|
+
import {
|
|
1681
|
+
AugurAPIError, // Base error class
|
|
1682
|
+
AuthenticationError, // 401 errors
|
|
1683
|
+
ValidationError, // Request validation failures
|
|
1684
|
+
NotFoundError, // 404 errors
|
|
1685
|
+
RateLimitError, // 429 errors
|
|
1686
|
+
NetworkError // Network/connectivity issues
|
|
1687
|
+
} from '@simpleapps-com/augur-api';
|
|
1733
1688
|
|
|
1734
1689
|
// Custom hook for Augur API - Context-aware approach
|
|
1735
1690
|
function useAugurAPI(context?: AugurContext) {
|