@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
|
@@ -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.deleteProduct = exports.updateProduct = exports.unitProductById = exports.listProduct = void 0;
|
|
74
|
-
__exportStar(require("./cache"), exports);
|
|
75
60
|
var multi_part_search_1 = require("../../../general/multi-part-search");
|
|
76
61
|
/**
|
|
77
62
|
* Retrieves a paginated list of products
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { ProductCategoryBE } from '../type';
|
|
2
|
-
/**
|
|
3
|
-
* Synchronous utility function to get product categories 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 ProductCategoryBE[] - Array of cached product categories or empty array
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* const categories = getCachedProductCategoriesSync();
|
|
11
|
-
* if (categories.length > 0) {
|
|
12
|
-
* console.log(categories[0].name);
|
|
13
|
-
* }
|
|
14
|
-
*/
|
|
15
|
-
export declare const getCachedProductCategoriesSync: () => {
|
|
16
|
-
count: number;
|
|
17
|
-
items: ProductCategoryBE[];
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Utility function to get product categories from cache or fetch from API
|
|
21
|
-
*
|
|
22
|
-
* This function manages a localStorage cache of product categories with the following logic:
|
|
23
|
-
* - If categories exist in cache and are less than 1 week old, return cached version
|
|
24
|
-
* - If categories exist but are older than 1 week, fetch fresh data and update cache
|
|
25
|
-
* - If categories don't exist in cache, fetch from API and cache them
|
|
26
|
-
*
|
|
27
|
-
* @param searchQuery - Optional search query to filter categories
|
|
28
|
-
* @param filters - Optional filters object to apply additional filtering (bypasses cache)
|
|
29
|
-
* @param pageLimit - Number of categories to fetch (default: 100)
|
|
30
|
-
* @returns Promise<ProductCategoryBE[]> - Array of product categories
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* const categories = await getCachedProductCategories();
|
|
34
|
-
* console.log(categories[0].name);
|
|
35
|
-
*
|
|
36
|
-
* // With search
|
|
37
|
-
* const filtered = await getCachedProductCategories('Electronics');
|
|
38
|
-
*
|
|
39
|
-
* // With filters
|
|
40
|
-
* const filteredCategories = await getCachedProductCategories(undefined, { enabled: true });
|
|
41
|
-
*/
|
|
42
|
-
export declare const getCachedProductCategories: (searchQuery?: string, filters?: Record<string, unknown>, pageLimit?: number) => Promise<{
|
|
43
|
-
count: number;
|
|
44
|
-
items: ProductCategoryBE[];
|
|
45
|
-
}>;
|
|
46
|
-
/**
|
|
47
|
-
* Utility function to get a specific product category by ID from cache
|
|
48
|
-
* If not found in cache, returns null (does not trigger API call)
|
|
49
|
-
*
|
|
50
|
-
* @param categoryId - The ID of the category to retrieve
|
|
51
|
-
* @returns ProductCategoryBE | null - The category or null if not found
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* const category = getCachedProductCategoryById('cat-123');
|
|
55
|
-
* if (category) {
|
|
56
|
-
* console.log(category.name);
|
|
57
|
-
* }
|
|
58
|
-
*/
|
|
59
|
-
export declare const getCachedProductCategoryById: (categoryId: string) => ProductCategoryBE | null;
|
|
60
|
-
/**
|
|
61
|
-
* Utility function to invalidate (remove) product categories from cache
|
|
62
|
-
* Useful when categories have been updated and you want to force a refresh
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* invalidateProductCategoriesCache();
|
|
66
|
-
* const freshCategories = await getCachedProductCategories();
|
|
67
|
-
*/
|
|
68
|
-
export declare const invalidateProductCategoriesCache: () => void;
|
|
69
|
-
/**
|
|
70
|
-
* Utility function to preload product categories into cache
|
|
71
|
-
* Useful to call on app initialization or login
|
|
72
|
-
*
|
|
73
|
-
* @returns Promise<ProductCategoryBE[]> - Array of preloaded categories
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* // On app initialization
|
|
77
|
-
* await preloadProductCategories();
|
|
78
|
-
*/
|
|
79
|
-
export declare const preloadProductCategories: () => Promise<{
|
|
80
|
-
count: number;
|
|
81
|
-
items: ProductCategoryBE[];
|
|
82
|
-
}>;
|
|
83
|
-
/**
|
|
84
|
-
* Utility function to check if product categories cache is stale
|
|
85
|
-
* Returns true if cache is older than 1 week or doesn't exist
|
|
86
|
-
*
|
|
87
|
-
* @returns boolean - True if cache is stale or doesn't exist
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* if (isProductCategoriesCacheStale()) {
|
|
91
|
-
* await getCachedProductCategories(); // This will fetch fresh data
|
|
92
|
-
* }
|
|
93
|
-
*/
|
|
94
|
-
export declare const isProductCategoriesCacheStale: () => boolean;
|