@react-pakistan/util-functions 1.25.9 → 1.25.11
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 -296
- 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 -296
- 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 -308
- package/api/stellar-solutions/company/index.d.ts +1 -1
- package/api/stellar-solutions/company/index.js +0 -15
- package/api/stellar-solutions/contact/cache.d.ts +0 -108
- package/api/stellar-solutions/contact/cache.js +247 -308
- 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 -296
- 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 -308
- 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 -308
- 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 -281
- 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 -296
- 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 -269
- 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 -281
- 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 -281
- 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 -296
- package/api/stellar-solutions/tax/index.d.ts +1 -1
- package/api/stellar-solutions/tax/index.js +0 -15
- package/general/format-secs.d.ts +1 -0
- package/general/format-secs.js +21 -0
- package/general/index.d.ts +1 -0
- package/general/index.js +1 -0
- package/package.json +1 -1
|
@@ -1,296 +1,237 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
* Useful when banks have been updated and you want to force a refresh
|
|
239
|
-
*
|
|
240
|
-
* @example
|
|
241
|
-
* invalidateBanksCache();
|
|
242
|
-
* const freshBanks = await getCachedBanks();
|
|
243
|
-
*/
|
|
244
|
-
var invalidateBanksCache = function () {
|
|
245
|
-
try {
|
|
246
|
-
localStorage.removeItem(type_1.LS_KEYS.BANKS);
|
|
247
|
-
}
|
|
248
|
-
catch (error) {
|
|
249
|
-
console.error('Error invalidating banks cache:', error);
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
exports.invalidateBanksCache = invalidateBanksCache;
|
|
253
|
-
/**
|
|
254
|
-
* Utility function to preload banks into cache
|
|
255
|
-
* Useful to call on app initialization or login
|
|
256
|
-
*
|
|
257
|
-
* @returns Promise<{count:number, items: BankBE[]}> - Array of preloaded banks
|
|
258
|
-
*
|
|
259
|
-
* @example
|
|
260
|
-
* // On app initialization
|
|
261
|
-
* await preloadBanks();
|
|
262
|
-
*/
|
|
263
|
-
var preloadBanks = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
264
|
-
return __generator(this, function (_a) {
|
|
265
|
-
return [2 /*return*/, (0, exports.getCachedBanks)()];
|
|
266
|
-
});
|
|
267
|
-
}); };
|
|
268
|
-
exports.preloadBanks = preloadBanks;
|
|
269
|
-
/**
|
|
270
|
-
* Utility function to check if banks cache is stale
|
|
271
|
-
* Returns true if cache is older than 1 week or doesn't exist
|
|
272
|
-
*
|
|
273
|
-
* @returns boolean - True if cache is stale or doesn't exist
|
|
274
|
-
*
|
|
275
|
-
* @example
|
|
276
|
-
* if (isBanksCacheStale()) {
|
|
277
|
-
* await getCachedBanks(); // This will fetch fresh data
|
|
278
|
-
* }
|
|
279
|
-
*/
|
|
280
|
-
var isBanksCacheStale = function () {
|
|
281
|
-
try {
|
|
282
|
-
var cachedData = (0, get_storage_value_1.getStorageValue)(type_1.LS_KEYS.BANKS);
|
|
283
|
-
if (!cachedData) {
|
|
284
|
-
return true;
|
|
285
|
-
}
|
|
286
|
-
var currentTime = new Date().getTime();
|
|
287
|
-
var cachedTime = new Date(cachedData.cachedAt).getTime();
|
|
288
|
-
var ageInMs = currentTime - cachedTime;
|
|
289
|
-
return ageInMs >= constants_2.ONE_WEEK_IN_MS;
|
|
290
|
-
}
|
|
291
|
-
catch (error) {
|
|
292
|
-
console.error('Error checking banks cache staleness:', error);
|
|
293
|
-
return true;
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
exports.isBanksCacheStale = isBanksCacheStale;
|
|
1
|
+
// import { API_ROUTES } from '../constants';
|
|
2
|
+
// import { BankBE, LS_KEYS } from '../type';
|
|
3
|
+
// import { API_METHODS } from '../../../constants/api-methods';
|
|
4
|
+
// import { fetchData } from '../../../general/fetch-data';
|
|
5
|
+
// import { getStorageValue } from '../../../local-storage/get-storage-value';
|
|
6
|
+
// import { setStorageValue } from '../../../local-storage/set-storage-value';
|
|
7
|
+
// import { ONE_WEEK_IN_MS } from '../../../constants';
|
|
8
|
+
// interface CachedBanks {
|
|
9
|
+
// banks: BankBE[];
|
|
10
|
+
// cachedAt: string;
|
|
11
|
+
// }
|
|
12
|
+
// /**
|
|
13
|
+
// * Synchronous utility function to get banks from cache only
|
|
14
|
+
// * Returns cached data immediately if available and fresh, otherwise returns empty array
|
|
15
|
+
// * Does not trigger any API calls
|
|
16
|
+
// *
|
|
17
|
+
// * @returns BankBE[] - Array of cached banks or empty array wrapper ({count, items})
|
|
18
|
+
// *
|
|
19
|
+
// * @example
|
|
20
|
+
// * const banks = getCachedBanksSync();
|
|
21
|
+
// * if (banks.items.length > 0) {
|
|
22
|
+
// * console.log(banks.items[0].bankName);
|
|
23
|
+
// * }
|
|
24
|
+
// */
|
|
25
|
+
// export const getCachedBanksSync = (): {
|
|
26
|
+
// count: number;
|
|
27
|
+
// items: BankBE[];
|
|
28
|
+
// } => {
|
|
29
|
+
// try {
|
|
30
|
+
// const cachedData = getStorageValue(LS_KEYS.BANKS) as CachedBanks | null;
|
|
31
|
+
// if (!cachedData) {
|
|
32
|
+
// return { count: 0, items: [] };
|
|
33
|
+
// }
|
|
34
|
+
// const currentTime = new Date().getTime();
|
|
35
|
+
// const cachedTime = new Date(cachedData.cachedAt).getTime();
|
|
36
|
+
// const ageInMs = currentTime - cachedTime;
|
|
37
|
+
// // If cached data is less than 1 week old, return it
|
|
38
|
+
// if (ageInMs < ONE_WEEK_IN_MS) {
|
|
39
|
+
// return {
|
|
40
|
+
// count: cachedData.banks.length,
|
|
41
|
+
// items: cachedData.banks,
|
|
42
|
+
// };
|
|
43
|
+
// }
|
|
44
|
+
// return { count: 0, items: [] };
|
|
45
|
+
// } catch (error) {
|
|
46
|
+
// console.error('Error getting cached banks:', error);
|
|
47
|
+
// return { count: 0, items: [] };
|
|
48
|
+
// }
|
|
49
|
+
// };
|
|
50
|
+
// /**
|
|
51
|
+
// * Utility function to get banks from cache or fetch from API
|
|
52
|
+
// *
|
|
53
|
+
// * This function manages a localStorage cache of banks with the following logic:
|
|
54
|
+
// * - If banks exist in cache and are less than 1 week old, return cached version
|
|
55
|
+
// * - If banks exist but are older than 1 week, fetch fresh data and update cache
|
|
56
|
+
// * - If banks don't exist in cache, fetch from API and cache them
|
|
57
|
+
// *
|
|
58
|
+
// * @param searchQuery - Optional search query to filter banks
|
|
59
|
+
// * @param pageLimit - Number of banks to fetch (default: 100)
|
|
60
|
+
// * @returns Promise<{count:number, items: BankBE[]}> - Paged banks
|
|
61
|
+
// *
|
|
62
|
+
// * @example
|
|
63
|
+
// * const banks = await getCachedBanks();
|
|
64
|
+
// * console.log(banks.items[0].bankName);
|
|
65
|
+
// *
|
|
66
|
+
// * // With search
|
|
67
|
+
// * const filtered = await getCachedBanks('Chase');
|
|
68
|
+
// */
|
|
69
|
+
// export const getCachedBanks = async (
|
|
70
|
+
// searchQuery?: string,
|
|
71
|
+
// pageLimit: number = 100
|
|
72
|
+
// ): Promise<{
|
|
73
|
+
// count: number;
|
|
74
|
+
// items: BankBE[];
|
|
75
|
+
// }> => {
|
|
76
|
+
// try {
|
|
77
|
+
// // If there's a search query, always fetch fresh data (don't use cache)
|
|
78
|
+
// if (searchQuery && searchQuery.trim()) {
|
|
79
|
+
// const response = await fetchData({
|
|
80
|
+
// url: API_ROUTES.BANKS,
|
|
81
|
+
// body: JSON.stringify({
|
|
82
|
+
// searchQuery,
|
|
83
|
+
// pageLimit,
|
|
84
|
+
// currentPage: 1,
|
|
85
|
+
// }),
|
|
86
|
+
// method: API_METHODS.POST,
|
|
87
|
+
// });
|
|
88
|
+
// return response?.data || { count: 0, items: [] };
|
|
89
|
+
// }
|
|
90
|
+
// // Get the cached data from localStorage
|
|
91
|
+
// const cachedData = getStorageValue(LS_KEYS.BANKS) as CachedBanks | null;
|
|
92
|
+
// const currentTime = new Date().getTime();
|
|
93
|
+
// // Check if cached data exists and is still fresh
|
|
94
|
+
// if (cachedData) {
|
|
95
|
+
// const cachedTime = new Date(cachedData.cachedAt).getTime();
|
|
96
|
+
// const ageInMs = currentTime - cachedTime;
|
|
97
|
+
// // If cached data is less than 1 week old, return it
|
|
98
|
+
// if (ageInMs < ONE_WEEK_IN_MS) {
|
|
99
|
+
// return {
|
|
100
|
+
// count: cachedData.banks.length,
|
|
101
|
+
// items: cachedData.banks,
|
|
102
|
+
// };
|
|
103
|
+
// }
|
|
104
|
+
// }
|
|
105
|
+
// // If no cached data or data is older than 1 week, fetch fresh data
|
|
106
|
+
// const response = await fetchData({
|
|
107
|
+
// url: API_ROUTES.BANKS,
|
|
108
|
+
// body: JSON.stringify({
|
|
109
|
+
// pageLimit,
|
|
110
|
+
// currentPage: 1,
|
|
111
|
+
// }),
|
|
112
|
+
// method: API_METHODS.POST,
|
|
113
|
+
// });
|
|
114
|
+
// if (response?.data?.items) {
|
|
115
|
+
// // Update the cache with fresh data
|
|
116
|
+
// const updatedCache: CachedBanks = {
|
|
117
|
+
// banks: response.data.items,
|
|
118
|
+
// cachedAt: new Date().toISOString(),
|
|
119
|
+
// };
|
|
120
|
+
// setStorageValue(LS_KEYS.BANKS, updatedCache);
|
|
121
|
+
// return response.data;
|
|
122
|
+
// }
|
|
123
|
+
// return { count: 0, items: [] };
|
|
124
|
+
// } catch (error) {
|
|
125
|
+
// console.error('Error fetching banks:', error);
|
|
126
|
+
// return { count: 0, items: [] };
|
|
127
|
+
// }
|
|
128
|
+
// };
|
|
129
|
+
// /**
|
|
130
|
+
// * Utility function to get a specific bank by ID from cache
|
|
131
|
+
// * If not found in cache, returns null (does not trigger API call)
|
|
132
|
+
// *
|
|
133
|
+
// * @param bankId - The ID of the bank to retrieve
|
|
134
|
+
// * @returns BankBE | null - The bank or null if not found
|
|
135
|
+
// *
|
|
136
|
+
// * @example
|
|
137
|
+
// * const bank = getCachedBankById('bank-123');
|
|
138
|
+
// * if (bank) {
|
|
139
|
+
// * console.log(bank.bankName);
|
|
140
|
+
// * }
|
|
141
|
+
// */
|
|
142
|
+
// export const getCachedBankById = (bankId: string): BankBE | null => {
|
|
143
|
+
// if (!bankId) {
|
|
144
|
+
// return null;
|
|
145
|
+
// }
|
|
146
|
+
// try {
|
|
147
|
+
// const banks = getCachedBanksSync().items;
|
|
148
|
+
// return banks.find((bank) => bank.id === bankId) || null;
|
|
149
|
+
// } catch (error) {
|
|
150
|
+
// console.error('Error getting cached bank by ID:', error);
|
|
151
|
+
// return null;
|
|
152
|
+
// }
|
|
153
|
+
// };
|
|
154
|
+
// /**
|
|
155
|
+
// * Utility function to get a specific bank by account number from cache
|
|
156
|
+
// * If not found in cache, returns null (does not trigger API call)
|
|
157
|
+
// *
|
|
158
|
+
// * @param accountNumber - The account number of the bank to retrieve
|
|
159
|
+
// * @returns BankBE | null - The bank or null if not found
|
|
160
|
+
// *
|
|
161
|
+
// * @example
|
|
162
|
+
// * const bank = getCachedBankByAccountNumber('1234567890');
|
|
163
|
+
// * if (bank) {
|
|
164
|
+
// * console.log(bank.bankName);
|
|
165
|
+
// * }
|
|
166
|
+
// */
|
|
167
|
+
// export const getCachedBankByAccountNumber = (
|
|
168
|
+
// accountNumber: string
|
|
169
|
+
// ): BankBE | null => {
|
|
170
|
+
// if (!accountNumber) {
|
|
171
|
+
// return null;
|
|
172
|
+
// }
|
|
173
|
+
// try {
|
|
174
|
+
// const banks = getCachedBanksSync().items;
|
|
175
|
+
// return banks.find((bank) => bank.accountNumber === accountNumber) || null;
|
|
176
|
+
// } catch (error) {
|
|
177
|
+
// console.error('Error getting cached bank by account number:', error);
|
|
178
|
+
// return null;
|
|
179
|
+
// }
|
|
180
|
+
// };
|
|
181
|
+
// /**
|
|
182
|
+
// * Utility function to invalidate (remove) banks from cache
|
|
183
|
+
// * Useful when banks have been updated and you want to force a refresh
|
|
184
|
+
// *
|
|
185
|
+
// * @example
|
|
186
|
+
// * invalidateBanksCache();
|
|
187
|
+
// * const freshBanks = await getCachedBanks();
|
|
188
|
+
// */
|
|
189
|
+
// export const invalidateBanksCache = (): void => {
|
|
190
|
+
// try {
|
|
191
|
+
// localStorage.removeItem(LS_KEYS.BANKS);
|
|
192
|
+
// } catch (error) {
|
|
193
|
+
// console.error('Error invalidating banks cache:', error);
|
|
194
|
+
// }
|
|
195
|
+
// };
|
|
196
|
+
// /**
|
|
197
|
+
// * Utility function to preload banks into cache
|
|
198
|
+
// * Useful to call on app initialization or login
|
|
199
|
+
// *
|
|
200
|
+
// * @returns Promise<{count:number, items: BankBE[]}> - Array of preloaded banks
|
|
201
|
+
// *
|
|
202
|
+
// * @example
|
|
203
|
+
// * // On app initialization
|
|
204
|
+
// * await preloadBanks();
|
|
205
|
+
// */
|
|
206
|
+
// export const preloadBanks = async (): Promise<{
|
|
207
|
+
// count: number;
|
|
208
|
+
// items: BankBE[];
|
|
209
|
+
// }> => {
|
|
210
|
+
// return getCachedBanks();
|
|
211
|
+
// };
|
|
212
|
+
// /**
|
|
213
|
+
// * Utility function to check if banks cache is stale
|
|
214
|
+
// * Returns true if cache is older than 1 week or doesn't exist
|
|
215
|
+
// *
|
|
216
|
+
// * @returns boolean - True if cache is stale or doesn't exist
|
|
217
|
+
// *
|
|
218
|
+
// * @example
|
|
219
|
+
// * if (isBanksCacheStale()) {
|
|
220
|
+
// * await getCachedBanks(); // This will fetch fresh data
|
|
221
|
+
// * }
|
|
222
|
+
// */
|
|
223
|
+
// export const isBanksCacheStale = (): boolean => {
|
|
224
|
+
// try {
|
|
225
|
+
// const cachedData = getStorageValue(LS_KEYS.BANKS) as CachedBanks | null;
|
|
226
|
+
// if (!cachedData) {
|
|
227
|
+
// return true;
|
|
228
|
+
// }
|
|
229
|
+
// const currentTime = new Date().getTime();
|
|
230
|
+
// const cachedTime = new Date(cachedData.cachedAt).getTime();
|
|
231
|
+
// const ageInMs = currentTime - cachedTime;
|
|
232
|
+
// return ageInMs >= ONE_WEEK_IN_MS;
|
|
233
|
+
// } catch (error) {
|
|
234
|
+
// console.error('Error checking banks cache staleness:', error);
|
|
235
|
+
// return true;
|
|
236
|
+
// }
|
|
237
|
+
// };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export * from './cache';
|
|
2
1
|
import { BankBE } from '../type';
|
|
3
2
|
type PrismaClient = any;
|
|
4
3
|
export interface ListBankArgs {
|
|
@@ -57,3 +56,4 @@ export declare const updateBank: ({ accountNumber, accountTitle, bankAddress, ba
|
|
|
57
56
|
* @throws {Error} If bank ID is not provided or bank not found
|
|
58
57
|
*/
|
|
59
58
|
export declare const deleteBank: ({ prisma, id, }: DeleteBankArgs) => Promise<BankBE>;
|
|
59
|
+
export {};
|
|
@@ -10,20 +10,6 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
25
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
26
|
-
};
|
|
27
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
28
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
29
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -71,7 +57,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
71
57
|
};
|
|
72
58
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
73
59
|
exports.deleteBank = exports.updateBank = exports.unitBankById = exports.listBank = void 0;
|
|
74
|
-
__exportStar(require("./cache"), exports);
|
|
75
60
|
var multi_part_search_1 = require("../../../general/multi-part-search");
|
|
76
61
|
/**
|
|
77
62
|
* Retrieves all banks from the database with pagination
|