@simpleapps-com/augur-api 0.4.6 → 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.
Files changed (78) hide show
  1. package/README.md +96 -141
  2. package/TIPS-AND-TRICKS.md +887 -0
  3. package/dist/cjs/index.d.ts +1 -1
  4. package/dist/cjs/index.js +1 -1
  5. package/dist/cjs/services/customers/client.d.ts +55 -0
  6. package/dist/cjs/services/customers/client.d.ts.map +1 -1
  7. package/dist/cjs/services/customers/client.js +17 -0
  8. package/dist/cjs/services/customers/client.js.map +1 -1
  9. package/dist/cjs/services/customers/schemas/customer.d.ts +178 -0
  10. package/dist/cjs/services/customers/schemas/customer.d.ts.map +1 -1
  11. package/dist/cjs/services/customers/schemas/customer.js +2 -1
  12. package/dist/cjs/services/customers/schemas/customer.js.map +1 -1
  13. package/dist/cjs/services/items/client.d.ts +23 -65
  14. package/dist/cjs/services/items/client.d.ts.map +1 -1
  15. package/dist/cjs/services/items/client.js +4 -4
  16. package/dist/cjs/services/items/client.js.map +1 -1
  17. package/dist/cjs/services/items/schemas/index.d.ts +1 -0
  18. package/dist/cjs/services/items/schemas/index.d.ts.map +1 -1
  19. package/dist/cjs/services/items/schemas/index.js +2 -0
  20. package/dist/cjs/services/items/schemas/index.js.map +1 -1
  21. package/dist/cjs/services/items/schemas/invMast.d.ts +20 -23
  22. package/dist/cjs/services/items/schemas/invMast.d.ts.map +1 -1
  23. package/dist/cjs/services/items/schemas/invMast.js +2 -3
  24. package/dist/cjs/services/items/schemas/invMast.js.map +1 -1
  25. package/dist/cjs/services/items/schemas/invMastLocationsBins.d.ts +37 -147
  26. package/dist/cjs/services/items/schemas/invMastLocationsBins.d.ts.map +1 -1
  27. package/dist/cjs/services/items/schemas/invMastLocationsBins.js +20 -11
  28. package/dist/cjs/services/items/schemas/invMastLocationsBins.js.map +1 -1
  29. package/dist/cjs/services/items/schemas/invMastLookup.d.ts +185 -0
  30. package/dist/cjs/services/items/schemas/invMastLookup.d.ts.map +1 -0
  31. package/dist/cjs/services/items/schemas/invMastLookup.js +37 -0
  32. package/dist/cjs/services/items/schemas/invMastLookup.js.map +1 -0
  33. package/dist/esm/index.d.ts +1 -1
  34. package/dist/esm/index.js +1 -1
  35. package/dist/esm/services/customers/client.d.ts +55 -0
  36. package/dist/esm/services/customers/client.d.ts.map +1 -1
  37. package/dist/esm/services/customers/client.js +18 -1
  38. package/dist/esm/services/customers/client.js.map +1 -1
  39. package/dist/esm/services/customers/schemas/customer.d.ts +178 -0
  40. package/dist/esm/services/customers/schemas/customer.d.ts.map +1 -1
  41. package/dist/esm/services/customers/schemas/customer.js +1 -0
  42. package/dist/esm/services/customers/schemas/customer.js.map +1 -1
  43. package/dist/esm/services/items/client.d.ts +23 -65
  44. package/dist/esm/services/items/client.d.ts.map +1 -1
  45. package/dist/esm/services/items/client.js +9 -7
  46. package/dist/esm/services/items/client.js.map +1 -1
  47. package/dist/esm/services/items/schemas/index.d.ts +1 -0
  48. package/dist/esm/services/items/schemas/index.d.ts.map +1 -1
  49. package/dist/esm/services/items/schemas/index.js +2 -0
  50. package/dist/esm/services/items/schemas/index.js.map +1 -1
  51. package/dist/esm/services/items/schemas/invMast.d.ts +20 -23
  52. package/dist/esm/services/items/schemas/invMast.d.ts.map +1 -1
  53. package/dist/esm/services/items/schemas/invMast.js +2 -3
  54. package/dist/esm/services/items/schemas/invMast.js.map +1 -1
  55. package/dist/esm/services/items/schemas/invMastLocationsBins.d.ts +37 -147
  56. package/dist/esm/services/items/schemas/invMastLocationsBins.d.ts.map +1 -1
  57. package/dist/esm/services/items/schemas/invMastLocationsBins.js +19 -10
  58. package/dist/esm/services/items/schemas/invMastLocationsBins.js.map +1 -1
  59. package/dist/esm/services/items/schemas/invMastLookup.d.ts +185 -0
  60. package/dist/esm/services/items/schemas/invMastLookup.d.ts.map +1 -0
  61. package/dist/esm/services/items/schemas/invMastLookup.js +34 -0
  62. package/dist/esm/services/items/schemas/invMastLookup.js.map +1 -0
  63. package/dist/types/index.d.ts +1 -1
  64. package/dist/types/services/customers/client.d.ts +55 -0
  65. package/dist/types/services/customers/client.d.ts.map +1 -1
  66. package/dist/types/services/customers/schemas/customer.d.ts +178 -0
  67. package/dist/types/services/customers/schemas/customer.d.ts.map +1 -1
  68. package/dist/types/services/items/client.d.ts +23 -65
  69. package/dist/types/services/items/client.d.ts.map +1 -1
  70. package/dist/types/services/items/schemas/index.d.ts +1 -0
  71. package/dist/types/services/items/schemas/index.d.ts.map +1 -1
  72. package/dist/types/services/items/schemas/invMast.d.ts +20 -23
  73. package/dist/types/services/items/schemas/invMast.d.ts.map +1 -1
  74. package/dist/types/services/items/schemas/invMastLocationsBins.d.ts +37 -147
  75. package/dist/types/services/items/schemas/invMastLocationsBins.d.ts.map +1 -1
  76. package/dist/types/services/items/schemas/invMastLookup.d.ts +185 -0
  77. package/dist/types/services/items/schemas/invMastLookup.d.ts.map +1 -0
  78. 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
- ### Edge Caching with Cloudflare
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
- The client provides built-in edge caching that dramatically improves performance by serving cached responses from Cloudflare's global edge network.
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
- #### Supported Cache Durations
1643
+ ## Integration Guides
1578
1644
 
1579
- Only specific cache durations are supported and validated:
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
- | Value | Duration | Best For |
1582
- |-------|----------|----------|
1583
- | `1` | 1 hour | Frequently changing data, cart contents |
1584
- | `2` | 2 hours | User lists, moderate volatility data |
1585
- | `3` | 3 hours | Standard pricing, product information |
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
- #### Cache Implementation
1653
+ ## Framework-Specific Features
1591
1654
 
1655
+ ### React/Next.js
1592
1656
  ```typescript
1593
- // How it works internally:
1594
- // edgeCache: 4 → adds URL parameter: cacheSiteId4=your-site-id
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
- // Bad: Don't cache user-specific data too long
1633
- const userSpecificData = await api.vmi.invProfileHdr.checkAvailability(warehouseId, {
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
- ### Request Cancellation
1640
-
1664
+ ### Error Handling Integration
1641
1665
  ```typescript
1642
- const controller = new AbortController();
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 users = await usersPromise;
1668
+ const result = await api.joomla.users.list({ limit: 10 });
1657
1669
  } catch (error) {
1658
- if (error.name === 'AbortError') {
1659
- console.log('Request was cancelled');
1660
- }
1670
+ ErrorHandler.handle(error, 'UserList Component');
1661
1671
  }
1662
1672
  ```
1663
1673
 
1664
- ### Custom Headers and Timeouts
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
- ### Middleware Integration
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
- // Add global request/response interceptors
1700
- const api = new AugurAPI({
1701
- siteId: 'your-site-id',
1702
- bearerToken: 'your-token',
1703
-
1704
- // Request interceptor
1705
- onRequest: (config) => {
1706
- console.log(`Making request to: ${config.url}`);
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) {