@react-pakistan/util-functions 1.25.8 → 1.25.10

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 (63) hide show
  1. package/api/stellar-solutions/bank/cache.d.ts +0 -104
  2. package/api/stellar-solutions/bank/cache.js +237 -295
  3. package/api/stellar-solutions/bank/index.d.ts +1 -1
  4. package/api/stellar-solutions/bank/index.js +0 -15
  5. package/api/stellar-solutions/branch/cache.d.ts +0 -102
  6. package/api/stellar-solutions/branch/cache.js +241 -295
  7. package/api/stellar-solutions/branch/index.d.ts +1 -1
  8. package/api/stellar-solutions/branch/index.js +0 -15
  9. package/api/stellar-solutions/company/cache.d.ts +0 -106
  10. package/api/stellar-solutions/company/cache.js +247 -307
  11. package/api/stellar-solutions/company/index.d.ts +1 -1
  12. package/api/stellar-solutions/company/index.js +0 -15
  13. package/api/stellar-solutions/constants.d.ts +0 -2
  14. package/api/stellar-solutions/constants.js +1 -3
  15. package/api/stellar-solutions/contact/cache.d.ts +0 -108
  16. package/api/stellar-solutions/contact/cache.js +247 -307
  17. package/api/stellar-solutions/contact/index.d.ts +1 -1
  18. package/api/stellar-solutions/contact/index.js +0 -15
  19. package/api/stellar-solutions/currency/cache.d.ts +0 -104
  20. package/api/stellar-solutions/currency/cache.js +243 -295
  21. package/api/stellar-solutions/currency/index.d.ts +1 -1
  22. package/api/stellar-solutions/currency/index.js +0 -15
  23. package/api/stellar-solutions/customer/cache.d.ts +0 -108
  24. package/api/stellar-solutions/customer/cache.js +249 -307
  25. package/api/stellar-solutions/customer/index.d.ts +1 -1
  26. package/api/stellar-solutions/customer/index.js +0 -15
  27. package/api/stellar-solutions/expense/cache.d.ts +0 -106
  28. package/api/stellar-solutions/expense/cache.js +247 -307
  29. package/api/stellar-solutions/expense/index.d.ts +1 -1
  30. package/api/stellar-solutions/expense/index.js +0 -15
  31. package/api/stellar-solutions/expense-category/cache.d.ts +0 -94
  32. package/api/stellar-solutions/expense-category/cache.js +224 -280
  33. package/api/stellar-solutions/expense-category/index.d.ts +1 -1
  34. package/api/stellar-solutions/expense-category/index.js +0 -15
  35. package/api/stellar-solutions/payment-mode/cache.d.ts +0 -102
  36. package/api/stellar-solutions/payment-mode/cache.js +245 -295
  37. package/api/stellar-solutions/payment-mode/index.d.ts +1 -1
  38. package/api/stellar-solutions/payment-mode/index.js +0 -15
  39. package/api/stellar-solutions/preference/cache.d.ts +0 -90
  40. package/api/stellar-solutions/preference/cache.js +218 -268
  41. package/api/stellar-solutions/preference/index.d.ts +1 -1
  42. package/api/stellar-solutions/preference/index.js +0 -15
  43. package/api/stellar-solutions/product/cache.d.ts +0 -94
  44. package/api/stellar-solutions/product/cache.js +222 -280
  45. package/api/stellar-solutions/product/index.d.ts +1 -1
  46. package/api/stellar-solutions/product/index.js +0 -15
  47. package/api/stellar-solutions/product-category/cache.d.ts +0 -94
  48. package/api/stellar-solutions/product-category/cache.js +224 -280
  49. package/api/stellar-solutions/product-category/index.d.ts +1 -1
  50. package/api/stellar-solutions/product-category/index.js +0 -15
  51. package/api/stellar-solutions/tax/cache.d.ts +0 -102
  52. package/api/stellar-solutions/tax/cache.js +235 -295
  53. package/api/stellar-solutions/tax/index.d.ts +1 -1
  54. package/api/stellar-solutions/tax/index.js +0 -15
  55. package/constants/cache-time.d.ts +3 -0
  56. package/constants/cache-time.js +6 -0
  57. package/constants/index.d.ts +2 -1
  58. package/constants/index.js +2 -1
  59. package/general/generic-cache.d.ts +143 -0
  60. package/general/generic-cache.js +411 -0
  61. package/general/index.d.ts +1 -0
  62. package/general/index.js +1 -0
  63. package/package.json +1 -1
@@ -1,108 +0,0 @@
1
- import { CustomerBE } from '../type';
2
- /**
3
- * Synchronous utility function to get customers from cache only
4
- * Returns cached data immediately if available and fresh, otherwise returns empty array
5
- * Does not trigger any API calls
6
- *
7
- * @returns CustomerBE[] - Array of cached customers or empty array wrapper ({count, items})
8
- *
9
- * @example
10
- * const customers = getCachedCustomersSync();
11
- * if (customers.items.length > 0) {
12
- * console.log(customers.items[0].firstName);
13
- * }
14
- */
15
- export declare const getCachedCustomersSync: () => {
16
- count: number;
17
- items: CustomerBE[];
18
- };
19
- /**
20
- * Utility function to get customers from cache or fetch from API
21
- *
22
- * This function manages a localStorage cache of customers with the following logic:
23
- * - If customers exist in cache and are less than 1 day old, return cached version
24
- * - If customers exist but are older than 1 day, fetch fresh data and update cache
25
- * - If customers don't exist in cache, fetch from API and cache them
26
- *
27
- * @param searchQuery - Optional search query to filter customers
28
- * @param filters - Optional filters object to apply additional filtering (bypasses cache)
29
- * @param pageLimit - Number of customers to fetch (default: 100)
30
- * @returns Promise<{count:number, items: CustomerBE[]}> - Paged customers
31
- *
32
- * @example
33
- * const customers = await getCachedCustomers();
34
- * console.log(customers.items[0].firstName);
35
- *
36
- * // With search
37
- * const filtered = await getCachedCustomers('John');
38
- *
39
- * // With filters
40
- * const filteredByCountry = await getCachedCustomers(undefined, { country: 'USA' });
41
- */
42
- export declare const getCachedCustomers: (searchQuery?: string, filters?: Record<string, unknown>, pageLimit?: number) => Promise<{
43
- count: number;
44
- items: CustomerBE[];
45
- }>;
46
- /**
47
- * Utility function to get a specific customer by ID from cache
48
- * If not found in cache, returns null (does not trigger API call)
49
- *
50
- * @param customerId - The ID of the customer to retrieve
51
- * @returns CustomerBE | null - The customer or null if not found
52
- *
53
- * @example
54
- * const customer = getCachedCustomerById('customer-123');
55
- * if (customer) {
56
- * console.log(customer.firstName);
57
- * }
58
- */
59
- export declare const getCachedCustomerById: (customerId: string) => CustomerBE | null;
60
- /**
61
- * Utility function to get a specific customer by phone from cache
62
- * If not found in cache, returns null (does not trigger API call)
63
- *
64
- * @param phone - The phone number of the customer to search for
65
- * @returns CustomerBE | null - The customer or null if not found
66
- *
67
- * @example
68
- * const customer = getCachedCustomerByPhone('+1234567890');
69
- * if (customer) {
70
- * console.log(customer.firstName);
71
- * }
72
- */
73
- export declare const getCachedCustomerByPhone: (phone: string) => CustomerBE | null;
74
- /**
75
- * Utility function to invalidate (remove) customers from cache
76
- * Useful when customers have been updated and you want to force a refresh
77
- *
78
- * @example
79
- * invalidateCustomersCache();
80
- * const freshCustomers = await getCachedCustomers();
81
- */
82
- export declare const invalidateCustomersCache: () => void;
83
- /**
84
- * Utility function to preload customers into cache
85
- * Useful to call on app initialization or login
86
- *
87
- * @returns Promise<{count:number, items: CustomerBE[]}> - Array of preloaded customers
88
- *
89
- * @example
90
- * // On app initialization
91
- * await preloadCustomers();
92
- */
93
- export declare const preloadCustomers: () => Promise<{
94
- count: number;
95
- items: CustomerBE[];
96
- }>;
97
- /**
98
- * Utility function to check if customers cache is stale
99
- * Returns true if cache is older than 1 day or doesn't exist
100
- *
101
- * @returns boolean - True if cache is stale or doesn't exist
102
- *
103
- * @example
104
- * if (isCustomersCacheStale()) {
105
- * await getCachedCustomers(); // This will fetch fresh data
106
- * }
107
- */
108
- export declare const isCustomersCacheStale: () => boolean;