@react-pakistan/util-functions 1.24.99 → 1.25.0

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 (73) hide show
  1. package/api/stellar-solutions/app-user/index.d.ts +9 -9
  2. package/api/stellar-solutions/app-user/index.js +4 -4
  3. package/api/stellar-solutions/bank/cache.d.ts +99 -0
  4. package/api/stellar-solutions/bank/cache.js +256 -0
  5. package/api/stellar-solutions/bank/index.d.ts +10 -10
  6. package/api/stellar-solutions/bank/index.js +19 -4
  7. package/api/stellar-solutions/branch/cache.d.ts +97 -0
  8. package/api/stellar-solutions/branch/cache.js +256 -0
  9. package/api/stellar-solutions/branch/index.d.ts +10 -10
  10. package/api/stellar-solutions/branch/index.js +19 -4
  11. package/api/stellar-solutions/company/cache.d.ts +106 -0
  12. package/api/stellar-solutions/company/cache.js +307 -0
  13. package/api/stellar-solutions/company/index.d.ts +10 -10
  14. package/api/stellar-solutions/company/index.js +19 -4
  15. package/api/stellar-solutions/company-report/index.d.ts +3 -3
  16. package/api/stellar-solutions/company-report/index.js +1 -1
  17. package/api/stellar-solutions/constants.d.ts +12 -0
  18. package/api/stellar-solutions/constants.js +13 -1
  19. package/api/stellar-solutions/contact/cache.d.ts +108 -0
  20. package/api/stellar-solutions/contact/cache.js +307 -0
  21. package/api/stellar-solutions/contact/index.d.ts +10 -10
  22. package/api/stellar-solutions/contact/index.js +19 -4
  23. package/api/stellar-solutions/currency/cache.d.ts +99 -0
  24. package/api/stellar-solutions/currency/cache.js +256 -0
  25. package/api/stellar-solutions/currency/index.d.ts +10 -10
  26. package/api/stellar-solutions/currency/index.js +19 -4
  27. package/api/stellar-solutions/customer/cache.d.ts +108 -0
  28. package/api/stellar-solutions/customer/cache.js +307 -0
  29. package/api/stellar-solutions/customer/index.d.ts +12 -12
  30. package/api/stellar-solutions/customer/index.js +20 -5
  31. package/api/stellar-solutions/expense/cache.d.ts +106 -0
  32. package/api/stellar-solutions/expense/cache.js +307 -0
  33. package/api/stellar-solutions/expense/index.d.ts +10 -10
  34. package/api/stellar-solutions/expense/index.js +19 -4
  35. package/api/stellar-solutions/expense-category/cache.d.ts +94 -0
  36. package/api/stellar-solutions/expense-category/cache.js +280 -0
  37. package/api/stellar-solutions/expense-category/index.d.ts +10 -10
  38. package/api/stellar-solutions/expense-category/index.js +19 -4
  39. package/api/stellar-solutions/lead/index.d.ts +9 -9
  40. package/api/stellar-solutions/lead/index.js +4 -4
  41. package/api/stellar-solutions/menu-order/index.d.ts +9 -9
  42. package/api/stellar-solutions/menu-order/index.js +4 -4
  43. package/api/stellar-solutions/payment/index.d.ts +9 -9
  44. package/api/stellar-solutions/payment/index.js +4 -4
  45. package/api/stellar-solutions/payment-mode/cache.d.ts +97 -0
  46. package/api/stellar-solutions/payment-mode/cache.js +256 -0
  47. package/api/stellar-solutions/payment-mode/index.d.ts +10 -10
  48. package/api/stellar-solutions/payment-mode/index.js +19 -4
  49. package/api/stellar-solutions/preference/cache.d.ts +85 -0
  50. package/api/stellar-solutions/preference/cache.js +229 -0
  51. package/api/stellar-solutions/preference/index.d.ts +6 -6
  52. package/api/stellar-solutions/preference/index.js +17 -2
  53. package/api/stellar-solutions/product/cache.d.ts +9 -9
  54. package/api/stellar-solutions/product/cache.js +4 -4
  55. package/api/stellar-solutions/product/index.d.ts +9 -9
  56. package/api/stellar-solutions/product/index.js +4 -4
  57. package/api/stellar-solutions/product-category/cache.d.ts +9 -9
  58. package/api/stellar-solutions/product-category/cache.js +4 -4
  59. package/api/stellar-solutions/product-category/index.d.ts +9 -9
  60. package/api/stellar-solutions/product-category/index.js +4 -4
  61. package/api/stellar-solutions/profile/index.d.ts +13 -13
  62. package/api/stellar-solutions/profile/index.js +6 -6
  63. package/api/stellar-solutions/quote-invoice/index.d.ts +9 -9
  64. package/api/stellar-solutions/quote-invoice/index.js +4 -4
  65. package/api/stellar-solutions/quote-invoice-report/index.d.ts +3 -3
  66. package/api/stellar-solutions/quote-invoice-report/index.js +1 -1
  67. package/api/stellar-solutions/tax/cache.d.ts +97 -0
  68. package/api/stellar-solutions/tax/cache.js +256 -0
  69. package/api/stellar-solutions/tax/index.d.ts +10 -10
  70. package/api/stellar-solutions/tax/index.js +19 -4
  71. package/api/stellar-solutions/type.d.ts +57 -46
  72. package/api/stellar-solutions/type.js +11 -0
  73. package/package.json +1 -1
@@ -0,0 +1,229 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.isPreferencesCacheStale = exports.preloadPreferences = exports.invalidatePreferencesCache = exports.getCachedPreferenceById = exports.getCachedPreferences = exports.getCachedPreferencesSync = void 0;
40
+ var constants_1 = require("../constants");
41
+ var type_1 = require("../type");
42
+ var api_methods_1 = require("../../../constants/api-methods");
43
+ var fetch_data_1 = require("../../../general/fetch-data");
44
+ var get_storage_value_1 = require("../../../local-storage/get-storage-value");
45
+ var set_storage_value_1 = require("../../../local-storage/set-storage-value");
46
+ /**
47
+ * Synchronous utility function to get preferences from cache only
48
+ * Returns cached data immediately if available and fresh, otherwise returns empty array
49
+ * Does not trigger any API calls
50
+ *
51
+ * @returns PreferenceBE[] - Array of cached preferences or empty array wrapper ({count, items})
52
+ *
53
+ * @example
54
+ * const preferences = getCachedPreferencesSync();
55
+ * if (preferences.items.length > 0) {
56
+ * console.log(preferences.items[0].onboarding);
57
+ * }
58
+ */
59
+ var getCachedPreferencesSync = function () {
60
+ try {
61
+ var cachedData = (0, get_storage_value_1.getStorageValue)(type_1.LS_KEYS.PREFERENCES);
62
+ if (!cachedData) {
63
+ return { count: 0, items: [] };
64
+ }
65
+ var currentTime = new Date().getTime();
66
+ var cachedTime = new Date(cachedData.cachedAt).getTime();
67
+ var ageInMs = currentTime - cachedTime;
68
+ // If cached data is less than 1 day old, return it
69
+ if (ageInMs < constants_1.ONE_WEEK_IN_MS) {
70
+ return {
71
+ count: cachedData.preferences.length,
72
+ items: cachedData.preferences,
73
+ };
74
+ }
75
+ return { count: 0, items: [] };
76
+ }
77
+ catch (error) {
78
+ console.error('Error getting cached preferences:', error);
79
+ return { count: 0, items: [] };
80
+ }
81
+ };
82
+ exports.getCachedPreferencesSync = getCachedPreferencesSync;
83
+ /**
84
+ * Utility function to get preferences from cache or fetch from API
85
+ *
86
+ * This function manages a localStorage cache of preferences with the following logic:
87
+ * - If preferences exist in cache and are less than 1 day old, return cached version
88
+ * - If preferences exist but are older than 1 day, fetch fresh data and update cache
89
+ * - If preferences don't exist in cache, fetch from API and cache them
90
+ *
91
+ * @returns Promise<{count:number, items: PreferenceBE[]}> - Paged preferences
92
+ *
93
+ * @example
94
+ * const preferences = await getCachedPreferences();
95
+ * console.log(preferences.items[0].onboarding);
96
+ */
97
+ var getCachedPreferences = function () { return __awaiter(void 0, void 0, void 0, function () {
98
+ var cachedData, currentTime, cachedTime, ageInMs, response, updatedCache, error_1;
99
+ var _a;
100
+ return __generator(this, function (_b) {
101
+ switch (_b.label) {
102
+ case 0:
103
+ _b.trys.push([0, 2, , 3]);
104
+ cachedData = (0, get_storage_value_1.getStorageValue)(type_1.LS_KEYS.PREFERENCES);
105
+ currentTime = new Date().getTime();
106
+ // Check if cached data exists and is still fresh
107
+ if (cachedData) {
108
+ cachedTime = new Date(cachedData.cachedAt).getTime();
109
+ ageInMs = currentTime - cachedTime;
110
+ // If cached data is less than 1 day old, return it
111
+ if (ageInMs < constants_1.ONE_WEEK_IN_MS) {
112
+ return [2 /*return*/, {
113
+ count: cachedData.preferences.length,
114
+ items: cachedData.preferences,
115
+ }];
116
+ }
117
+ }
118
+ return [4 /*yield*/, (0, fetch_data_1.fetchData)({
119
+ url: constants_1.API_ROUTES.PREFERENCES,
120
+ method: api_methods_1.API_METHODS.GET,
121
+ })];
122
+ case 1:
123
+ response = _b.sent();
124
+ if ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.items) {
125
+ updatedCache = {
126
+ preferences: response.data.items,
127
+ cachedAt: new Date().toISOString(),
128
+ };
129
+ (0, set_storage_value_1.setStorageValue)(type_1.LS_KEYS.PREFERENCES, updatedCache);
130
+ return [2 /*return*/, response.data];
131
+ }
132
+ return [2 /*return*/, { count: 0, items: [] }];
133
+ case 2:
134
+ error_1 = _b.sent();
135
+ console.error('Error fetching preferences:', error_1);
136
+ return [2 /*return*/, { count: 0, items: [] }];
137
+ case 3: return [2 /*return*/];
138
+ }
139
+ });
140
+ }); };
141
+ exports.getCachedPreferences = getCachedPreferences;
142
+ /**
143
+ * Utility function to get a specific preference by ID from cache
144
+ * If not found in cache, returns null (does not trigger API call)
145
+ *
146
+ * @param preferenceId - The ID of the preference to retrieve
147
+ * @returns PreferenceBE | null - The preference or null if not found
148
+ *
149
+ * @example
150
+ * const preference = getCachedPreferenceById('pref-123');
151
+ * if (preference) {
152
+ * console.log(preference.onboarding);
153
+ * }
154
+ */
155
+ var getCachedPreferenceById = function (preferenceId) {
156
+ if (!preferenceId) {
157
+ return null;
158
+ }
159
+ try {
160
+ var preferences = (0, exports.getCachedPreferencesSync)().items;
161
+ return preferences.find(function (pref) { return pref.id === preferenceId; }) || null;
162
+ }
163
+ catch (error) {
164
+ console.error('Error getting cached preference by ID:', error);
165
+ return null;
166
+ }
167
+ };
168
+ exports.getCachedPreferenceById = getCachedPreferenceById;
169
+ /**
170
+ * Utility function to invalidate (remove) preferences from cache
171
+ * Useful when preferences have been updated and you want to force a refresh
172
+ *
173
+ * @example
174
+ * invalidatePreferencesCache();
175
+ * const freshPreferences = await getCachedPreferences();
176
+ */
177
+ var invalidatePreferencesCache = function () {
178
+ try {
179
+ localStorage.removeItem(type_1.LS_KEYS.PREFERENCES);
180
+ }
181
+ catch (error) {
182
+ console.error('Error invalidating preferences cache:', error);
183
+ }
184
+ };
185
+ exports.invalidatePreferencesCache = invalidatePreferencesCache;
186
+ /**
187
+ * Utility function to preload preferences into cache
188
+ * Useful to call on app initialization or login
189
+ *
190
+ * @returns Promise<{count:number, items: PreferenceBE[]}> - Array of preloaded preferences
191
+ *
192
+ * @example
193
+ * // On app initialization
194
+ * await preloadPreferences();
195
+ */
196
+ var preloadPreferences = function () { return __awaiter(void 0, void 0, void 0, function () {
197
+ return __generator(this, function (_a) {
198
+ return [2 /*return*/, (0, exports.getCachedPreferences)()];
199
+ });
200
+ }); };
201
+ exports.preloadPreferences = preloadPreferences;
202
+ /**
203
+ * Utility function to check if preferences cache is stale
204
+ * Returns true if cache is older than 1 day or doesn't exist
205
+ *
206
+ * @returns boolean - True if cache is stale or doesn't exist
207
+ *
208
+ * @example
209
+ * if (isPreferencesCacheStale()) {
210
+ * await getCachedPreferences(); // This will fetch fresh data
211
+ * }
212
+ */
213
+ var isPreferencesCacheStale = function () {
214
+ try {
215
+ var cachedData = (0, get_storage_value_1.getStorageValue)(type_1.LS_KEYS.PREFERENCES);
216
+ if (!cachedData) {
217
+ return true;
218
+ }
219
+ var currentTime = new Date().getTime();
220
+ var cachedTime = new Date(cachedData.cachedAt).getTime();
221
+ var ageInMs = currentTime - cachedTime;
222
+ return ageInMs >= constants_1.ONE_WEEK_IN_MS;
223
+ }
224
+ catch (error) {
225
+ console.error('Error checking preferences cache staleness:', error);
226
+ return true;
227
+ }
228
+ };
229
+ exports.isPreferencesCacheStale = isPreferencesCacheStale;
@@ -1,4 +1,5 @@
1
- import { PreferenceTypeBE } from '../type';
1
+ export * from './cache';
2
+ import { PreferenceBE } from '../type';
2
3
  type PrismaClient = any;
3
4
  export interface ListPreferencesArgs {
4
5
  orderByColumn?: string;
@@ -13,13 +14,12 @@ export interface PostPreferenceArgs {
13
14
  /**
14
15
  * Retrieves all preferences
15
16
  * @param {ListPreferencesArgs} args - Object containing prisma client and ordering options
16
- * @returns {Promise<Array<PreferenceTypeBE>>} Array of preferences
17
+ * @returns {Promise<Array<PreferenceBE>>} Array of preferences
17
18
  */
18
- export declare const listPreference: ({ orderByColumn, orderByDirection, prisma, }: ListPreferencesArgs) => Promise<Array<PreferenceTypeBE>>;
19
+ export declare const listPreference: ({ orderByColumn, orderByDirection, prisma, }: ListPreferencesArgs) => Promise<Array<PreferenceBE>>;
19
20
  /**
20
21
  * Updates a preference using upsert
21
22
  * @param {PostPreferenceArgs} args - Object containing prisma client, preference ID, and onboarding status
22
- * @returns {Promise<PreferenceTypeBE>} Updated preference
23
+ * @returns {Promise<PreferenceBE>} Updated preference
23
24
  */
24
- export declare const updatePreference: ({ id, onboarding, prisma, }: PostPreferenceArgs) => Promise<PreferenceTypeBE>;
25
- export {};
25
+ export declare const updatePreference: ({ id, onboarding, prisma, }: PostPreferenceArgs) => Promise<PreferenceBE>;
@@ -10,6 +10,20 @@ 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
+ };
13
27
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
28
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
29
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -48,10 +62,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
48
62
  };
49
63
  Object.defineProperty(exports, "__esModule", { value: true });
50
64
  exports.updatePreference = exports.listPreference = void 0;
65
+ __exportStar(require("./cache"), exports);
51
66
  /**
52
67
  * Retrieves all preferences
53
68
  * @param {ListPreferencesArgs} args - Object containing prisma client and ordering options
54
- * @returns {Promise<Array<PreferenceTypeBE>>} Array of preferences
69
+ * @returns {Promise<Array<PreferenceBE>>} Array of preferences
55
70
  */
56
71
  var listPreference = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
57
72
  var include, orderBy, where, _c, count, items;
@@ -80,7 +95,7 @@ exports.listPreference = listPreference;
80
95
  /**
81
96
  * Updates a preference using upsert
82
97
  * @param {PostPreferenceArgs} args - Object containing prisma client, preference ID, and onboarding status
83
- * @returns {Promise<PreferenceTypeBE>} Updated preference
98
+ * @returns {Promise<PreferenceBE>} Updated preference
84
99
  */
85
100
  var updatePreference = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
86
101
  var preferenceData, where, preference;
@@ -1,10 +1,10 @@
1
- import { ProductTypeBE } from '../type';
1
+ import { ProductBE } from '../type';
2
2
  /**
3
3
  * Synchronous utility function to get products from cache only
4
4
  * Returns cached data immediately if available and fresh, otherwise returns empty array
5
5
  * Does not trigger any API calls
6
6
  *
7
- * @returns ProductTypeBE[] - Array of cached products or empty array wrapper ({count, items})
7
+ * @returns ProductBE[] - Array of cached products or empty array wrapper ({count, items})
8
8
  *
9
9
  * @example
10
10
  * const products = getCachedProductsSync();
@@ -14,7 +14,7 @@ import { ProductTypeBE } from '../type';
14
14
  */
15
15
  export declare const getCachedProductsSync: () => {
16
16
  count: number;
17
- items: ProductTypeBE[];
17
+ items: ProductBE[];
18
18
  };
19
19
  /**
20
20
  * Utility function to get products from cache or fetch from API
@@ -27,7 +27,7 @@ export declare const getCachedProductsSync: () => {
27
27
  * @param searchQuery - Optional search query to filter products
28
28
  * @param filters - Optional filters object to apply additional filtering (bypasses cache)
29
29
  * @param pageLimit - Number of products to fetch (default: 100)
30
- * @returns Promise<{count:number, items: ProductTypeBE[]}> - Paged products
30
+ * @returns Promise<{count:number, items: ProductBE[]}> - Paged products
31
31
  *
32
32
  * @example
33
33
  * const products = await getCachedProducts();
@@ -41,14 +41,14 @@ export declare const getCachedProductsSync: () => {
41
41
  */
42
42
  export declare const getCachedProducts: (searchQuery?: string, filters?: Record<string, unknown>, pageLimit?: number) => Promise<{
43
43
  count: number;
44
- items: ProductTypeBE[];
44
+ items: ProductBE[];
45
45
  }>;
46
46
  /**
47
47
  * Utility function to get a specific product by ID from cache
48
48
  * If not found in cache, returns null (does not trigger API call)
49
49
  *
50
50
  * @param productId - The ID of the product to retrieve
51
- * @returns ProductTypeBE | null - The product or null if not found
51
+ * @returns ProductBE | null - The product or null if not found
52
52
  *
53
53
  * @example
54
54
  * const product = getCachedProductById('prod-123');
@@ -56,7 +56,7 @@ export declare const getCachedProducts: (searchQuery?: string, filters?: Record<
56
56
  * console.log(product.name);
57
57
  * }
58
58
  */
59
- export declare const getCachedProductById: (categoryId: string) => ProductTypeBE | null;
59
+ export declare const getCachedProductById: (categoryId: string) => ProductBE | null;
60
60
  /**
61
61
  * Utility function to invalidate (remove) products from cache
62
62
  * Useful when products have been updated and you want to force a refresh
@@ -70,7 +70,7 @@ export declare const invalidateProductsCache: () => void;
70
70
  * Utility function to preload products into cache
71
71
  * Useful to call on app initialization or login
72
72
  *
73
- * @returns Promise<{count:number, items: ProductTypeBE[]}> - Array of preloaded products
73
+ * @returns Promise<{count:number, items: ProductBE[]}> - Array of preloaded products
74
74
  *
75
75
  * @example
76
76
  * // On app initialization
@@ -78,7 +78,7 @@ export declare const invalidateProductsCache: () => void;
78
78
  */
79
79
  export declare const preloadProducts: () => Promise<{
80
80
  count: number;
81
- items: ProductTypeBE[];
81
+ items: ProductBE[];
82
82
  }>;
83
83
  /**
84
84
  * Utility function to check if products cache is stale
@@ -68,7 +68,7 @@ var set_storage_value_1 = require("../../../local-storage/set-storage-value");
68
68
  * Returns cached data immediately if available and fresh, otherwise returns empty array
69
69
  * Does not trigger any API calls
70
70
  *
71
- * @returns ProductTypeBE[] - Array of cached products or empty array wrapper ({count, items})
71
+ * @returns ProductBE[] - Array of cached products or empty array wrapper ({count, items})
72
72
  *
73
73
  * @example
74
74
  * const products = getCachedProductsSync();
@@ -111,7 +111,7 @@ exports.getCachedProductsSync = getCachedProductsSync;
111
111
  * @param searchQuery - Optional search query to filter products
112
112
  * @param filters - Optional filters object to apply additional filtering (bypasses cache)
113
113
  * @param pageLimit - Number of products to fetch (default: 100)
114
- * @returns Promise<{count:number, items: ProductTypeBE[]}> - Paged products
114
+ * @returns Promise<{count:number, items: ProductBE[]}> - Paged products
115
115
  *
116
116
  * @example
117
117
  * const products = await getCachedProducts();
@@ -195,7 +195,7 @@ exports.getCachedProducts = getCachedProducts;
195
195
  * If not found in cache, returns null (does not trigger API call)
196
196
  *
197
197
  * @param productId - The ID of the product to retrieve
198
- * @returns ProductTypeBE | null - The product or null if not found
198
+ * @returns ProductBE | null - The product or null if not found
199
199
  *
200
200
  * @example
201
201
  * const product = getCachedProductById('prod-123');
@@ -238,7 +238,7 @@ exports.invalidateProductsCache = invalidateProductsCache;
238
238
  * Utility function to preload products into cache
239
239
  * Useful to call on app initialization or login
240
240
  *
241
- * @returns Promise<{count:number, items: ProductTypeBE[]}> - Array of preloaded products
241
+ * @returns Promise<{count:number, items: ProductBE[]}> - Array of preloaded products
242
242
  *
243
243
  * @example
244
244
  * // On app initialization
@@ -1,5 +1,5 @@
1
1
  export * from './cache';
2
- import { ProductTypeBE } from '../type';
2
+ import { ProductBE } from '../type';
3
3
  type PrismaClient = any;
4
4
  export interface ListProductArgs {
5
5
  buyPrice?: number;
@@ -41,24 +41,24 @@ export interface DeleteProductArgs {
41
41
  /**
42
42
  * Retrieves a paginated list of products
43
43
  * @param {ListProductArgs} args - Object containing prisma client, pagination, filtering, and ordering options
44
- * @returns {Promise<[number, Array<ProductTypeBE>]>} Tuple containing total count and array of products
44
+ * @returns {Promise<[number, Array<ProductBE>]>} Tuple containing total count and array of products
45
45
  */
46
- export declare const listProduct: ({ buyPrice, currentPage, includeProductCategory, includeQuotesInvoices, orderByColumn, orderByDirection, pageLimit, prisma, productCategoryId, salePrice, searchQuery, }: ListProductArgs) => Promise<[number, Array<ProductTypeBE>]>;
46
+ export declare const listProduct: ({ buyPrice, currentPage, includeProductCategory, includeQuotesInvoices, orderByColumn, orderByDirection, pageLimit, prisma, productCategoryId, salePrice, searchQuery, }: ListProductArgs) => Promise<[number, Array<ProductBE>]>;
47
47
  /**
48
48
  * Retrieves a single product by its ID
49
49
  * @param {UnitProductByIdArgs} args - Object containing prisma client, product ID, and optional query parameters
50
- * @returns {Promise<ProductTypeBE | null>} Product or null if not found
50
+ * @returns {Promise<ProductBE | null>} Product or null if not found
51
51
  */
52
- export declare const unitProductById: ({ id, includeProductCategory, includeQuotesInvoices, prisma, }: UnitProductByIdArgs) => Promise<ProductTypeBE | null>;
52
+ export declare const unitProductById: ({ id, includeProductCategory, includeQuotesInvoices, prisma, }: UnitProductByIdArgs) => Promise<ProductBE | null>;
53
53
  /**
54
54
  * Creates or updates a product
55
55
  * @param {UpdateProductArgs} args - Object containing prisma client, product data, and optional query parameters
56
- * @returns {Promise<ProductTypeBE>} Created or updated product
56
+ * @returns {Promise<ProductBE>} Created or updated product
57
57
  */
58
- export declare const updateProduct: ({ buyPrice, currency, description, id, image, name, prisma, productCategoryId, quantity, ref, salePrice, }: UpdateProductArgs) => Promise<ProductTypeBE>;
58
+ export declare const updateProduct: ({ buyPrice, currency, description, id, image, name, prisma, productCategoryId, quantity, ref, salePrice, }: UpdateProductArgs) => Promise<ProductBE>;
59
59
  /**
60
60
  * Deletes a product by ID
61
61
  * @param {DeleteProductArgs} args - Object containing prisma client, product ID, and optional query parameters
62
- * @returns {Promise<ProductTypeBE>} Deleted product
62
+ * @returns {Promise<ProductBE>} Deleted product
63
63
  */
64
- export declare const deleteProduct: ({ id, prisma, }: DeleteProductArgs) => Promise<ProductTypeBE>;
64
+ export declare const deleteProduct: ({ id, prisma, }: DeleteProductArgs) => Promise<ProductBE>;
@@ -76,7 +76,7 @@ var multi_part_search_1 = require("../../../general/multi-part-search");
76
76
  /**
77
77
  * Retrieves a paginated list of products
78
78
  * @param {ListProductArgs} args - Object containing prisma client, pagination, filtering, and ordering options
79
- * @returns {Promise<[number, Array<ProductTypeBE>]>} Tuple containing total count and array of products
79
+ * @returns {Promise<[number, Array<ProductBE>]>} Tuple containing total count and array of products
80
80
  */
81
81
  var listProduct = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
82
82
  var include, orderBy, idSearchQuery, nameSearchQuery, refSearchQuery, where, _c, count, items;
@@ -144,7 +144,7 @@ exports.listProduct = listProduct;
144
144
  /**
145
145
  * Retrieves a single product by its ID
146
146
  * @param {UnitProductByIdArgs} args - Object containing prisma client, product ID, and optional query parameters
147
- * @returns {Promise<ProductTypeBE | null>} Product or null if not found
147
+ * @returns {Promise<ProductBE | null>} Product or null if not found
148
148
  */
149
149
  var unitProductById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
150
150
  var include, where, product;
@@ -176,7 +176,7 @@ exports.unitProductById = unitProductById;
176
176
  /**
177
177
  * Creates or updates a product
178
178
  * @param {UpdateProductArgs} args - Object containing prisma client, product data, and optional query parameters
179
- * @returns {Promise<ProductTypeBE>} Created or updated product
179
+ * @returns {Promise<ProductBE>} Created or updated product
180
180
  */
181
181
  var updateProduct = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
182
182
  var productData, where, product;
@@ -224,7 +224,7 @@ exports.updateProduct = updateProduct;
224
224
  /**
225
225
  * Deletes a product by ID
226
226
  * @param {DeleteProductArgs} args - Object containing prisma client, product ID, and optional query parameters
227
- * @returns {Promise<ProductTypeBE>} Deleted product
227
+ * @returns {Promise<ProductBE>} Deleted product
228
228
  */
229
229
  var deleteProduct = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
230
230
  var where, product;
@@ -1,10 +1,10 @@
1
- import { ProductCategoryTypeBE } from '../type';
1
+ import { ProductCategoryBE } from '../type';
2
2
  /**
3
3
  * Synchronous utility function to get product categories from cache only
4
4
  * Returns cached data immediately if available and fresh, otherwise returns empty array
5
5
  * Does not trigger any API calls
6
6
  *
7
- * @returns ProductCategoryTypeBE[] - Array of cached product categories or empty array
7
+ * @returns ProductCategoryBE[] - Array of cached product categories or empty array
8
8
  *
9
9
  * @example
10
10
  * const categories = getCachedProductCategoriesSync();
@@ -14,7 +14,7 @@ import { ProductCategoryTypeBE } from '../type';
14
14
  */
15
15
  export declare const getCachedProductCategoriesSync: () => {
16
16
  count: number;
17
- items: ProductCategoryTypeBE[];
17
+ items: ProductCategoryBE[];
18
18
  };
19
19
  /**
20
20
  * Utility function to get product categories from cache or fetch from API
@@ -27,7 +27,7 @@ export declare const getCachedProductCategoriesSync: () => {
27
27
  * @param searchQuery - Optional search query to filter categories
28
28
  * @param filters - Optional filters object to apply additional filtering (bypasses cache)
29
29
  * @param pageLimit - Number of categories to fetch (default: 100)
30
- * @returns Promise<ProductCategoryTypeBE[]> - Array of product categories
30
+ * @returns Promise<ProductCategoryBE[]> - Array of product categories
31
31
  *
32
32
  * @example
33
33
  * const categories = await getCachedProductCategories();
@@ -41,14 +41,14 @@ export declare const getCachedProductCategoriesSync: () => {
41
41
  */
42
42
  export declare const getCachedProductCategories: (searchQuery?: string, filters?: Record<string, unknown>, pageLimit?: number) => Promise<{
43
43
  count: number;
44
- items: ProductCategoryTypeBE[];
44
+ items: ProductCategoryBE[];
45
45
  }>;
46
46
  /**
47
47
  * Utility function to get a specific product category by ID from cache
48
48
  * If not found in cache, returns null (does not trigger API call)
49
49
  *
50
50
  * @param categoryId - The ID of the category to retrieve
51
- * @returns ProductCategoryTypeBE | null - The category or null if not found
51
+ * @returns ProductCategoryBE | null - The category or null if not found
52
52
  *
53
53
  * @example
54
54
  * const category = getCachedProductCategoryById('cat-123');
@@ -56,7 +56,7 @@ export declare const getCachedProductCategories: (searchQuery?: string, filters?
56
56
  * console.log(category.name);
57
57
  * }
58
58
  */
59
- export declare const getCachedProductCategoryById: (categoryId: string) => ProductCategoryTypeBE | null;
59
+ export declare const getCachedProductCategoryById: (categoryId: string) => ProductCategoryBE | null;
60
60
  /**
61
61
  * Utility function to invalidate (remove) product categories from cache
62
62
  * Useful when categories have been updated and you want to force a refresh
@@ -70,7 +70,7 @@ export declare const invalidateProductCategoriesCache: () => void;
70
70
  * Utility function to preload product categories into cache
71
71
  * Useful to call on app initialization or login
72
72
  *
73
- * @returns Promise<ProductCategoryTypeBE[]> - Array of preloaded categories
73
+ * @returns Promise<ProductCategoryBE[]> - Array of preloaded categories
74
74
  *
75
75
  * @example
76
76
  * // On app initialization
@@ -78,7 +78,7 @@ export declare const invalidateProductCategoriesCache: () => void;
78
78
  */
79
79
  export declare const preloadProductCategories: () => Promise<{
80
80
  count: number;
81
- items: ProductCategoryTypeBE[];
81
+ items: ProductCategoryBE[];
82
82
  }>;
83
83
  /**
84
84
  * Utility function to check if product categories cache is stale
@@ -68,7 +68,7 @@ var set_storage_value_1 = require("../../../local-storage/set-storage-value");
68
68
  * Returns cached data immediately if available and fresh, otherwise returns empty array
69
69
  * Does not trigger any API calls
70
70
  *
71
- * @returns ProductCategoryTypeBE[] - Array of cached product categories or empty array
71
+ * @returns ProductCategoryBE[] - Array of cached product categories or empty array
72
72
  *
73
73
  * @example
74
74
  * const categories = getCachedProductCategoriesSync();
@@ -111,7 +111,7 @@ exports.getCachedProductCategoriesSync = getCachedProductCategoriesSync;
111
111
  * @param searchQuery - Optional search query to filter categories
112
112
  * @param filters - Optional filters object to apply additional filtering (bypasses cache)
113
113
  * @param pageLimit - Number of categories to fetch (default: 100)
114
- * @returns Promise<ProductCategoryTypeBE[]> - Array of product categories
114
+ * @returns Promise<ProductCategoryBE[]> - Array of product categories
115
115
  *
116
116
  * @example
117
117
  * const categories = await getCachedProductCategories();
@@ -195,7 +195,7 @@ exports.getCachedProductCategories = getCachedProductCategories;
195
195
  * If not found in cache, returns null (does not trigger API call)
196
196
  *
197
197
  * @param categoryId - The ID of the category to retrieve
198
- * @returns ProductCategoryTypeBE | null - The category or null if not found
198
+ * @returns ProductCategoryBE | null - The category or null if not found
199
199
  *
200
200
  * @example
201
201
  * const category = getCachedProductCategoryById('cat-123');
@@ -238,7 +238,7 @@ exports.invalidateProductCategoriesCache = invalidateProductCategoriesCache;
238
238
  * Utility function to preload product categories into cache
239
239
  * Useful to call on app initialization or login
240
240
  *
241
- * @returns Promise<ProductCategoryTypeBE[]> - Array of preloaded categories
241
+ * @returns Promise<ProductCategoryBE[]> - Array of preloaded categories
242
242
  *
243
243
  * @example
244
244
  * // On app initialization
@@ -1,5 +1,5 @@
1
1
  export * from './cache';
2
- import { ProductCategoryTypeBE } from '../type';
2
+ import { ProductCategoryBE } from '../type';
3
3
  type PrismaClient = any;
4
4
  export interface ListProductCategoryArgs {
5
5
  currentPage?: number;
@@ -28,24 +28,24 @@ export interface DeleteProductCategoryArgs {
28
28
  /**
29
29
  * Retrieves a paginated list of product categories
30
30
  * @param {ListProductCategoryArgs} args - Object containing prisma client, pagination, filtering, and ordering options
31
- * @returns {Promise<[number, Array<ProductCategoryTypeBE>]>} Tuple containing total count and array of product categories
31
+ * @returns {Promise<[number, Array<ProductCategoryBE>]>} Tuple containing total count and array of product categories
32
32
  */
33
- export declare const listProductCategory: ({ currentPage, includeProducts, orderByColumn, orderByDirection, pageLimit, prisma, searchQuery, }: ListProductCategoryArgs) => Promise<[number, Array<ProductCategoryTypeBE>]>;
33
+ export declare const listProductCategory: ({ currentPage, includeProducts, orderByColumn, orderByDirection, pageLimit, prisma, searchQuery, }: ListProductCategoryArgs) => Promise<[number, Array<ProductCategoryBE>]>;
34
34
  /**
35
35
  * Retrieves a single product category by its ID
36
36
  * @param {UnitProductCategoryByIdArgs} args - Object containing prisma client, product category ID, and optional query parameters
37
- * @returns {Promise<ProductCategoryTypeBE | null>} Product category or null if not found
37
+ * @returns {Promise<ProductCategoryBE | null>} Product category or null if not found
38
38
  */
39
- export declare const unitProductCategoryById: ({ id, includeProducts, prisma, }: UnitProductCategoryByIdArgs) => Promise<ProductCategoryTypeBE | null>;
39
+ export declare const unitProductCategoryById: ({ id, includeProducts, prisma, }: UnitProductCategoryByIdArgs) => Promise<ProductCategoryBE | null>;
40
40
  /**
41
41
  * Creates or updates a product category
42
42
  * @param {UpdateProductCategoryArgs} args - Object containing prisma client, product category data, and optional query parameters
43
- * @returns {Promise<ProductCategoryTypeBE>} Created or updated product category
43
+ * @returns {Promise<ProductCategoryBE>} Created or updated product category
44
44
  */
45
- export declare const updateProductCategory: ({ description, id, name, prisma, }: UpdateProductCategoryArgs) => Promise<ProductCategoryTypeBE>;
45
+ export declare const updateProductCategory: ({ description, id, name, prisma, }: UpdateProductCategoryArgs) => Promise<ProductCategoryBE>;
46
46
  /**
47
47
  * Deletes a product category by ID
48
48
  * @param {DeleteProductCategoryArgs} args - Object containing prisma client, product category ID, and optional query parameters
49
- * @returns {Promise<ProductCategoryTypeBE>} Deleted product category
49
+ * @returns {Promise<ProductCategoryBE>} Deleted product category
50
50
  */
51
- export declare const deleteProductCategory: ({ id, prisma, }: DeleteProductCategoryArgs) => Promise<ProductCategoryTypeBE>;
51
+ export declare const deleteProductCategory: ({ id, prisma, }: DeleteProductCategoryArgs) => Promise<ProductCategoryBE>;