@react-pakistan/util-functions 1.24.64 → 1.24.66

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 (110) hide show
  1. package/README.md +6 -3
  2. package/api/stellar-solutions/app-user/index.d.ts +63 -14
  3. package/api/stellar-solutions/app-user/index.js +106 -52
  4. package/api/stellar-solutions/bank/index.d.ts +65 -16
  5. package/api/stellar-solutions/bank/index.js +115 -65
  6. package/api/stellar-solutions/branch/index.d.ts +64 -15
  7. package/api/stellar-solutions/branch/index.js +119 -65
  8. package/api/stellar-solutions/company/index.d.ts +58 -24
  9. package/api/stellar-solutions/company/index.js +106 -78
  10. package/api/stellar-solutions/company-report/index.d.ts +12 -5
  11. package/api/stellar-solutions/company-report/index.js +12 -7
  12. package/api/stellar-solutions/contact/index.d.ts +54 -20
  13. package/api/stellar-solutions/contact/index.js +109 -88
  14. package/api/stellar-solutions/currency/index.d.ts +63 -14
  15. package/api/stellar-solutions/currency/index.js +113 -61
  16. package/api/stellar-solutions/customer/index.d.ts +70 -28
  17. package/api/stellar-solutions/customer/index.js +131 -101
  18. package/api/stellar-solutions/expense/index.d.ts +58 -22
  19. package/api/stellar-solutions/expense/index.js +128 -92
  20. package/api/stellar-solutions/expense-category/index.d.ts +58 -22
  21. package/api/stellar-solutions/expense-category/index.js +125 -86
  22. package/api/stellar-solutions/lead/index.js +0 -1
  23. package/api/stellar-solutions/menu-order/index.d.ts +29 -7
  24. package/api/stellar-solutions/menu-order/index.js +74 -27
  25. package/api/stellar-solutions/payment/index.d.ts +62 -27
  26. package/api/stellar-solutions/payment/index.js +144 -123
  27. package/api/stellar-solutions/payment-mode/index.d.ts +44 -12
  28. package/api/stellar-solutions/payment-mode/index.js +115 -49
  29. package/api/stellar-solutions/preference/index.d.ts +14 -3
  30. package/api/stellar-solutions/preference/index.js +44 -14
  31. package/api/stellar-solutions/product/index.d.ts +46 -31
  32. package/api/stellar-solutions/product/index.js +142 -113
  33. package/api/stellar-solutions/product-category/index.d.ts +44 -27
  34. package/api/stellar-solutions/product-category/index.js +123 -87
  35. package/api/stellar-solutions/profile/index.d.ts +48 -17
  36. package/api/stellar-solutions/profile/index.js +124 -65
  37. package/api/stellar-solutions/quote-invoice/index.d.ts +67 -8
  38. package/api/stellar-solutions/quote-invoice/index.js +123 -57
  39. package/api/stellar-solutions/quote-invoice-report/index.d.ts +12 -5
  40. package/api/stellar-solutions/quote-invoice-report/index.js +10 -5
  41. package/api/stellar-solutions/tax/index.d.ts +46 -14
  42. package/api/stellar-solutions/tax/index.js +135 -63
  43. package/api/stellar-solutions/type.d.ts +292 -177
  44. package/api/stellar-solutions/type.js +93 -1
  45. package/constants/countries-timezones.js +0 -1
  46. package/constants/currencies.js +0 -1
  47. package/general/basic-get.js +22 -21
  48. package/general/basic-post.js +19 -18
  49. package/general/calculate-pages.js +3 -1
  50. package/general/check-even-odd-length.js +3 -2
  51. package/general/delete-image-from-private-supabase.js +0 -1
  52. package/general/delete-image-from-public-supabase.js +0 -1
  53. package/general/dynamic-page-limit.js +3 -2
  54. package/general/enum-to-text.js +7 -4
  55. package/general/fetch-data.js +0 -1
  56. package/general/fetch-supabase-image.js +0 -1
  57. package/general/fetch-supabase-private-assets.js +15 -14
  58. package/general/format-date.js +8 -8
  59. package/general/format-number.js +3 -2
  60. package/general/format-time.js +3 -2
  61. package/general/full-year-range.js +2 -2
  62. package/general/generate-blog-schema.d.ts +3 -3
  63. package/general/generate-blog-schema.js +20 -13
  64. package/general/generate-breadcrumb-schema.d.ts +4 -4
  65. package/general/generate-breadcrumb-schema.js +9 -10
  66. package/general/generate-faq-schema.d.ts +5 -5
  67. package/general/generate-faq-schema.js +18 -11
  68. package/general/generate-grid.js +0 -1
  69. package/general/generate-organization-schema.d.ts +3 -3
  70. package/general/generate-organization-schema.js +25 -18
  71. package/general/get-available-page-limit.js +2 -2
  72. package/general/get-calendar-dates.js +14 -3
  73. package/general/get-full-name.d.ts +1 -1
  74. package/general/get-number-of-days-in-month.d.ts +1 -1
  75. package/general/get-pathname.js +4 -1
  76. package/general/is-odd.js +1 -1
  77. package/general/is-previous-button-disabled.js +3 -1
  78. package/general/parse-frontmatter.js +0 -1
  79. package/general/remove-data-image-prefix.js +3 -2
  80. package/general/repeat-times.js +0 -1
  81. package/general/resolve-current-date.js +1 -2
  82. package/general/resolve-grid.js +3 -2
  83. package/general/slugify.js +11 -9
  84. package/general/text-to-enum.js +6 -1
  85. package/general/text-to-sentence-case.js +3 -1
  86. package/general/time-out.js +5 -4
  87. package/general/truncate-text.js +3 -1
  88. package/general/upload-blob-to-private-supabase.js +2 -2
  89. package/general/upload-blob-to-public-supabase.js +2 -2
  90. package/general/upload-image-to-private-supabase.js +2 -2
  91. package/general/upload-image-to-public-supabase.js +2 -2
  92. package/general/validate-email.js +1 -1
  93. package/hooks/use-fetch.js +11 -12
  94. package/hooks/use-module-entity.js +5 -6
  95. package/hooks/use-sticky.js +0 -1
  96. package/hooks/with-seo.d.ts +1 -1
  97. package/hooks/with-seo.js +3 -4
  98. package/local-storage/get-storage-value.js +0 -1
  99. package/package.json +22 -13
  100. package/setupTests.js +1 -2
  101. package/storybook/generate-sitemap.js +0 -1
  102. package/storybook/preview.js +1 -4
  103. package/storybook/react-design-story-script.js +0 -2
  104. package/storybook/react-emoji-collection.js +8 -6
  105. package/storybook/react-emoji-story-script.js +0 -2
  106. package/storybook/react-icon-collection.js +4 -3
  107. package/storybook/react-icon-story-script.js +0 -2
  108. package/storybook/react-logo-collection.js +4 -3
  109. package/storybook/react-logo-story-script.js +0 -2
  110. package/storybook/responsive-component.js +14 -7
@@ -1,5 +1,15 @@
1
1
  "use strict";
2
- /* eslint-disable @typescript-eslint/no-explicit-any, no-restricted-globals */
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
3
13
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
14
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
15
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -37,86 +47,148 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
47
  }
38
48
  };
39
49
  Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.deleteTax = exports.postTax = exports.getTaxById = exports.getTaxes = void 0;
41
- var getTaxes = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
42
- var taxes;
43
- var prisma = _b.prisma;
44
- return __generator(this, function (_c) {
45
- switch (_c.label) {
46
- case 0: return [4 /*yield*/, prisma.tax.findMany({
47
- orderBy: {
48
- createdAt: 'desc',
49
- },
50
- })];
50
+ exports.deleteTax = exports.updateTax = exports.unitTaxById = exports.listTax = void 0;
51
+ /**
52
+ * Retrieves a paginated list of taxes
53
+ * @param {ListTaxArgs} args - Object containing prisma client, pagination, and filter options
54
+ * @returns {Promise<[number, Array<TaxBE>]>} Tuple of [total count, tax array]
55
+ */
56
+ var listTax = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
57
+ var skip, _c, count, data;
58
+ var _d = _b.currentPage, currentPage = _d === void 0 ? 1 : _d, _e = _b.include, include = _e === void 0 ? {} : _e, _f = _b.orderBy, orderBy = _f === void 0 ? { createdAt: 'desc' } : _f, _g = _b.pageLimit, pageLimit = _g === void 0 ? 10 : _g, prisma = _b.prisma, _h = _b.queryWhere, queryWhere = _h === void 0 ? {} : _h;
59
+ return __generator(this, function (_j) {
60
+ switch (_j.label) {
61
+ case 0:
62
+ if (currentPage < 1) {
63
+ throw new Error('Current page must be greater than or equal to 1');
64
+ }
65
+ if (pageLimit < 1) {
66
+ throw new Error('Page limit must be greater than or equal to 1');
67
+ }
68
+ skip = (currentPage - 1) * pageLimit;
69
+ return [4 /*yield*/, Promise.all([
70
+ prisma.tax.count({
71
+ where: queryWhere,
72
+ }),
73
+ prisma.tax.findMany({
74
+ include: include,
75
+ orderBy: orderBy,
76
+ skip: skip,
77
+ take: pageLimit,
78
+ where: queryWhere,
79
+ }),
80
+ ])];
51
81
  case 1:
52
- taxes = _c.sent();
53
- return [2 /*return*/, taxes];
82
+ _c = _j.sent(), count = _c[0], data = _c[1];
83
+ return [2 /*return*/, [count, data]];
54
84
  }
55
85
  });
56
86
  }); };
57
- exports.getTaxes = getTaxes;
58
- var getTaxById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
87
+ exports.listTax = listTax;
88
+ /**
89
+ * Retrieves a single tax by its ID
90
+ * @param {UnitTaxByIdArgs} args - Object containing prisma client, tax ID, and optional filters
91
+ * @returns {Promise<TaxBE | null>} Tax or null if not found
92
+ */
93
+ var unitTaxById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
59
94
  var tax;
60
- var prisma = _b.prisma, id = _b.id;
61
- return __generator(this, function (_c) {
62
- switch (_c.label) {
63
- case 0: return [4 /*yield*/, prisma.tax.findUnique({
64
- where: {
65
- id: id,
66
- },
67
- })];
95
+ var id = _b.id, _c = _b.include, include = _c === void 0 ? {} : _c, prisma = _b.prisma, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d;
96
+ return __generator(this, function (_e) {
97
+ switch (_e.label) {
98
+ case 0:
99
+ if (!id) {
100
+ throw new Error('Tax ID is required');
101
+ }
102
+ if (queryWhere.id && queryWhere.id !== id) {
103
+ throw new Error('ID mismatch between parameter and queryWhere');
104
+ }
105
+ return [4 /*yield*/, prisma.tax.findUnique({
106
+ include: include,
107
+ where: __assign({ id: id }, queryWhere),
108
+ })];
68
109
  case 1:
69
- tax = _c.sent();
110
+ tax = _e.sent();
70
111
  return [2 /*return*/, tax];
71
112
  }
72
113
  });
73
114
  }); };
74
- exports.getTaxById = getTaxById;
75
- var postTax = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
76
- var tax;
77
- var description = _b.description, enabled = _b.enabled, id = _b.id, isDefault = _b.isDefault, preferenceId = _b.preferenceId, prisma = _b.prisma, taxName = _b.taxName, taxRate = _b.taxRate;
78
- return __generator(this, function (_c) {
79
- switch (_c.label) {
80
- case 0: return [4 /*yield*/, prisma.tax.upsert({
81
- where: {
82
- id: id,
83
- },
84
- update: {
85
- description: description,
86
- enabled: enabled,
87
- isDefault: isDefault,
88
- preferenceId: preferenceId,
89
- taxName: taxName,
90
- taxRate: taxRate,
91
- },
92
- create: {
93
- description: description,
94
- enabled: enabled,
95
- isDefault: isDefault,
96
- preferenceId: preferenceId,
97
- taxName: taxName,
98
- taxRate: taxRate,
99
- },
100
- })];
115
+ exports.unitTaxById = unitTaxById;
116
+ /**
117
+ * Creates or updates a tax
118
+ * @param {UpdateTaxArgs} args - Object containing prisma client and tax data
119
+ * @returns {Promise<TaxBE>} Created or updated tax
120
+ */
121
+ var updateTax = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
122
+ var taxData, tax;
123
+ var description = _b.description, enabled = _b.enabled, id = _b.id, _c = _b.include, include = _c === void 0 ? {} : _c, isDefault = _b.isDefault, preferenceId = _b.preferenceId, prisma = _b.prisma, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d, taxName = _b.taxName, taxRate = _b.taxRate;
124
+ return __generator(this, function (_e) {
125
+ switch (_e.label) {
126
+ case 0:
127
+ if (!id) {
128
+ throw new Error('Tax ID is required');
129
+ }
130
+ if (!preferenceId) {
131
+ throw new Error('Preference ID is required');
132
+ }
133
+ if (!taxName) {
134
+ throw new Error('Tax name is required');
135
+ }
136
+ if (!taxRate) {
137
+ throw new Error('Tax rate is required');
138
+ }
139
+ if (typeof enabled !== 'boolean') {
140
+ throw new Error('Enabled must be a boolean');
141
+ }
142
+ if (typeof isDefault !== 'boolean') {
143
+ throw new Error('Is default must be a boolean');
144
+ }
145
+ if (queryWhere.id && queryWhere.id !== id) {
146
+ throw new Error('ID mismatch between parameter and queryWhere');
147
+ }
148
+ taxData = {
149
+ description: description || null,
150
+ enabled: enabled,
151
+ isDefault: isDefault,
152
+ preferenceId: preferenceId,
153
+ taxName: taxName,
154
+ taxRate: taxRate,
155
+ };
156
+ return [4 /*yield*/, prisma.tax.upsert({
157
+ include: include,
158
+ where: __assign({ id: id }, queryWhere),
159
+ update: taxData,
160
+ create: __assign({ id: id }, taxData),
161
+ })];
101
162
  case 1:
102
- tax = _c.sent();
163
+ tax = _e.sent();
103
164
  return [2 /*return*/, tax];
104
165
  }
105
166
  });
106
167
  }); };
107
- exports.postTax = postTax;
168
+ exports.updateTax = updateTax;
169
+ /**
170
+ * Deletes a tax by ID
171
+ * @param {DeleteTaxArgs} args - Object containing prisma client, tax ID, and optional filters
172
+ * @returns {Promise<TaxBE>} Deleted tax
173
+ */
108
174
  var deleteTax = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
109
175
  var tax;
110
- var prisma = _b.prisma, id = _b.id;
111
- return __generator(this, function (_c) {
112
- switch (_c.label) {
113
- case 0: return [4 /*yield*/, prisma.tax.delete({
114
- where: {
115
- id: id,
116
- },
117
- })];
176
+ var id = _b.id, _c = _b.include, include = _c === void 0 ? {} : _c, prisma = _b.prisma, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d;
177
+ return __generator(this, function (_e) {
178
+ switch (_e.label) {
179
+ case 0:
180
+ if (!id) {
181
+ throw new Error('Tax ID is required');
182
+ }
183
+ if (queryWhere.id && queryWhere.id !== id) {
184
+ throw new Error('ID mismatch between parameter and queryWhere');
185
+ }
186
+ return [4 /*yield*/, prisma.tax.delete({
187
+ include: include,
188
+ where: __assign({ id: id }, queryWhere),
189
+ })];
118
190
  case 1:
119
- tax = _c.sent();
191
+ tax = _e.sent();
120
192
  return [2 /*return*/, tax];
121
193
  }
122
194
  });