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