@react-pakistan/util-functions 1.24.70 → 1.24.72
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/app-user/index.d.ts +8 -7
- package/api/stellar-solutions/app-user/index.js +60 -24
- package/api/stellar-solutions/bank/index.d.ts +11 -8
- package/api/stellar-solutions/bank/index.js +58 -20
- package/api/stellar-solutions/branch/index.d.ts +11 -8
- package/api/stellar-solutions/branch/index.js +61 -17
- package/api/stellar-solutions/company/index.d.ts +12 -8
- package/api/stellar-solutions/company/index.js +41 -27
- package/api/stellar-solutions/company-report/index.d.ts +1 -1
- package/api/stellar-solutions/contact/index.d.ts +12 -9
- package/api/stellar-solutions/contact/index.js +70 -22
- package/api/stellar-solutions/currency/index.d.ts +11 -8
- package/api/stellar-solutions/currency/index.js +66 -31
- package/api/stellar-solutions/customer/index.d.ts +14 -10
- package/api/stellar-solutions/customer/index.js +80 -35
- package/api/stellar-solutions/expense/index.d.ts +8 -7
- package/api/stellar-solutions/expense/index.js +77 -29
- package/api/stellar-solutions/expense-category/index.d.ts +8 -9
- package/api/stellar-solutions/expense-category/index.js +45 -30
- package/api/stellar-solutions/lead/index.d.ts +6 -5
- package/api/stellar-solutions/lead/index.js +46 -28
- package/api/stellar-solutions/menu-order/index.d.ts +11 -8
- package/api/stellar-solutions/menu-order/index.js +56 -29
- package/api/stellar-solutions/payment/index.d.ts +9 -8
- package/api/stellar-solutions/payment/index.js +56 -39
- package/api/stellar-solutions/payment-mode/index.d.ts +13 -7
- package/api/stellar-solutions/payment-mode/index.js +65 -33
- package/api/stellar-solutions/preference/index.d.ts +4 -4
- package/api/stellar-solutions/preference/index.js +11 -11
- package/api/stellar-solutions/product/index.d.ts +9 -12
- package/api/stellar-solutions/product/index.js +45 -32
- package/api/stellar-solutions/product-category/index.d.ts +8 -9
- package/api/stellar-solutions/product-category/index.js +45 -30
- package/api/stellar-solutions/quote-invoice/index.d.ts +9 -8
- package/api/stellar-solutions/quote-invoice/index.js +40 -25
- package/api/stellar-solutions/quote-invoice-report/index.d.ts +1 -1
- package/api/stellar-solutions/tax/index.d.ts +9 -6
- package/api/stellar-solutions/tax/index.js +44 -21
- package/package.json +1 -1
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
import { PaymentModeBE } from '../type';
|
|
2
2
|
type PrismaClient = any;
|
|
3
|
-
interface ListPaymentModeArgs {
|
|
3
|
+
export interface ListPaymentModeArgs {
|
|
4
4
|
currentPage?: number;
|
|
5
|
+
includePayments?: boolean;
|
|
6
|
+
includePreference?: boolean;
|
|
5
7
|
orderByColumn?: string;
|
|
6
8
|
orderByDirection?: 'asc' | 'desc';
|
|
7
9
|
pageLimit?: number;
|
|
8
10
|
prisma: PrismaClient;
|
|
11
|
+
searchQuery?: string;
|
|
9
12
|
}
|
|
10
|
-
interface UnitPaymentModeByIdArgs {
|
|
13
|
+
export interface UnitPaymentModeByIdArgs {
|
|
14
|
+
includePayments?: boolean;
|
|
11
15
|
id: string;
|
|
16
|
+
includePreference?: boolean;
|
|
12
17
|
prisma: PrismaClient;
|
|
13
18
|
}
|
|
14
|
-
interface UpdatePaymentModeArgs {
|
|
19
|
+
export interface UpdatePaymentModeArgs {
|
|
15
20
|
enabled: boolean;
|
|
21
|
+
isDefault: boolean;
|
|
16
22
|
id: string;
|
|
17
23
|
prisma: PrismaClient;
|
|
18
24
|
}
|
|
19
|
-
interface DeletePaymentModeArgs {
|
|
25
|
+
export interface DeletePaymentModeArgs {
|
|
20
26
|
id: string;
|
|
21
27
|
prisma: PrismaClient;
|
|
22
28
|
}
|
|
@@ -25,19 +31,19 @@ interface DeletePaymentModeArgs {
|
|
|
25
31
|
* @param {ListPaymentModeArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
26
32
|
* @returns {Promise<[number, Array<PaymentModeBE>]>} Tuple containing total count and array of payment modes
|
|
27
33
|
*/
|
|
28
|
-
export declare const listPaymentMode: ({ currentPage, orderByColumn, orderByDirection, pageLimit, prisma, }: ListPaymentModeArgs) => Promise<[number, Array<PaymentModeBE>]>;
|
|
34
|
+
export declare const listPaymentMode: ({ currentPage, includePayments, includePreference, orderByColumn, orderByDirection, pageLimit, prisma, searchQuery, }: ListPaymentModeArgs) => Promise<[number, Array<PaymentModeBE>]>;
|
|
29
35
|
/**
|
|
30
36
|
* Retrieves a single payment mode by its ID
|
|
31
37
|
* @param {UnitPaymentModeByIdArgs} args - Object containing prisma client, payment mode ID, and optional query parameters
|
|
32
38
|
* @returns {Promise<PaymentModeBE | null>} Payment mode or null if not found
|
|
33
39
|
*/
|
|
34
|
-
export declare const unitPaymentModeById: ({ id, prisma, }: UnitPaymentModeByIdArgs) => Promise<PaymentModeBE | null>;
|
|
40
|
+
export declare const unitPaymentModeById: ({ id, includePayments, includePreference, prisma, }: UnitPaymentModeByIdArgs) => Promise<PaymentModeBE | null>;
|
|
35
41
|
/**
|
|
36
42
|
* Updates a payment mode's enabled status
|
|
37
43
|
* @param {UpdatePaymentModeArgs} args - Object containing prisma client, payment mode ID, enabled status, and optional query parameters
|
|
38
44
|
* @returns {Promise<PaymentModeBE>} Updated payment mode
|
|
39
45
|
*/
|
|
40
|
-
export declare const updatePaymentMode: ({ enabled, id, prisma, }: UpdatePaymentModeArgs) => Promise<PaymentModeBE>;
|
|
46
|
+
export declare const updatePaymentMode: ({ enabled, isDefault, id, prisma, }: UpdatePaymentModeArgs) => Promise<PaymentModeBE>;
|
|
41
47
|
/**
|
|
42
48
|
* Deletes a payment mode by ID
|
|
43
49
|
* @param {DeletePaymentModeArgs} args - Object containing prisma client, payment mode ID, and optional query parameters
|
|
@@ -35,40 +35,69 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
+
if (ar || !(i in from)) {
|
|
41
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
+
ar[i] = from[i];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
+
};
|
|
38
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
48
|
exports.deletePaymentMode = exports.updatePaymentMode = exports.unitPaymentModeById = exports.listPaymentMode = void 0;
|
|
49
|
+
var multi_part_search_1 = require("../../../general/multi-part-search");
|
|
40
50
|
/**
|
|
41
51
|
* Retrieves a paginated list of payment modes
|
|
42
52
|
* @param {ListPaymentModeArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
43
53
|
* @returns {Promise<[number, Array<PaymentModeBE>]>} Tuple containing total count and array of payment modes
|
|
44
54
|
*/
|
|
45
55
|
var listPaymentMode = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
46
|
-
var
|
|
56
|
+
var include, orderBy, idSearchQuery, labelSearchQuery, where, _c, count, items;
|
|
47
57
|
var _d;
|
|
48
|
-
var
|
|
49
|
-
return __generator(this, function (
|
|
50
|
-
switch (
|
|
58
|
+
var currentPage = _b.currentPage, _e = _b.includePayments, includePayments = _e === void 0 ? false : _e, _f = _b.includePreference, includePreference = _f === void 0 ? false : _f, _g = _b.orderByColumn, orderByColumn = _g === void 0 ? 'createdAt' : _g, _h = _b.orderByDirection, orderByDirection = _h === void 0 ? 'desc' : _h, pageLimit = _b.pageLimit, prisma = _b.prisma, _j = _b.searchQuery, searchQuery = _j === void 0 ? '' : _j;
|
|
59
|
+
return __generator(this, function (_k) {
|
|
60
|
+
switch (_k.label) {
|
|
51
61
|
case 0:
|
|
52
|
-
if (currentPage < 1) {
|
|
53
|
-
throw new Error('
|
|
62
|
+
if (!currentPage || currentPage < 1) {
|
|
63
|
+
throw new Error('Valid current page is required');
|
|
54
64
|
}
|
|
55
|
-
if (pageLimit < 1) {
|
|
56
|
-
throw new Error('
|
|
65
|
+
if (!pageLimit || pageLimit < 1) {
|
|
66
|
+
throw new Error('Valid page limit is required');
|
|
57
67
|
}
|
|
58
|
-
|
|
68
|
+
include = {
|
|
69
|
+
payments: includePayments,
|
|
70
|
+
preference: includePreference,
|
|
71
|
+
};
|
|
72
|
+
orderBy = (_d = {},
|
|
73
|
+
_d[orderByColumn] = orderByDirection,
|
|
74
|
+
_d);
|
|
75
|
+
idSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
76
|
+
columnName: 'id',
|
|
77
|
+
fullText: searchQuery,
|
|
78
|
+
});
|
|
79
|
+
labelSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
80
|
+
columnName: 'label',
|
|
81
|
+
fullText: searchQuery,
|
|
82
|
+
});
|
|
83
|
+
where = {
|
|
84
|
+
OR: __spreadArray(__spreadArray([], idSearchQuery, true), labelSearchQuery, true),
|
|
85
|
+
};
|
|
59
86
|
return [4 /*yield*/, prisma.$transaction([
|
|
60
|
-
prisma.paymentMode.count(
|
|
87
|
+
prisma.paymentMode.count({
|
|
88
|
+
where: where,
|
|
89
|
+
}),
|
|
61
90
|
prisma.paymentMode.findMany({
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
skip: skip,
|
|
91
|
+
include: include,
|
|
92
|
+
orderBy: orderBy,
|
|
93
|
+
skip: (currentPage - 1) * pageLimit,
|
|
66
94
|
take: pageLimit,
|
|
95
|
+
where: where,
|
|
67
96
|
}),
|
|
68
97
|
])];
|
|
69
98
|
case 1:
|
|
70
|
-
_c =
|
|
71
|
-
return [2 /*return*/, [count,
|
|
99
|
+
_c = _k.sent(), count = _c[0], items = _c[1];
|
|
100
|
+
return [2 /*return*/, [count, items]];
|
|
72
101
|
}
|
|
73
102
|
});
|
|
74
103
|
}); };
|
|
@@ -79,21 +108,25 @@ exports.listPaymentMode = listPaymentMode;
|
|
|
79
108
|
* @returns {Promise<PaymentModeBE | null>} Payment mode or null if not found
|
|
80
109
|
*/
|
|
81
110
|
var unitPaymentModeById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
82
|
-
var paymentMode;
|
|
83
|
-
var id = _b.id, prisma = _b.prisma;
|
|
84
|
-
return __generator(this, function (
|
|
85
|
-
switch (
|
|
111
|
+
var include, where, paymentMode;
|
|
112
|
+
var id = _b.id, _c = _b.includePayments, includePayments = _c === void 0 ? false : _c, _d = _b.includePreference, includePreference = _d === void 0 ? false : _d, prisma = _b.prisma;
|
|
113
|
+
return __generator(this, function (_e) {
|
|
114
|
+
switch (_e.label) {
|
|
86
115
|
case 0:
|
|
87
116
|
if (!id) {
|
|
88
117
|
throw new Error('Payment mode ID is required');
|
|
89
118
|
}
|
|
119
|
+
include = {
|
|
120
|
+
payments: includePayments,
|
|
121
|
+
preference: includePreference,
|
|
122
|
+
};
|
|
123
|
+
where = { id: id };
|
|
90
124
|
return [4 /*yield*/, prisma.paymentMode.findUnique({
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
},
|
|
125
|
+
include: include,
|
|
126
|
+
where: where,
|
|
94
127
|
})];
|
|
95
128
|
case 1:
|
|
96
|
-
paymentMode =
|
|
129
|
+
paymentMode = _e.sent();
|
|
97
130
|
return [2 /*return*/, paymentMode];
|
|
98
131
|
}
|
|
99
132
|
});
|
|
@@ -105,8 +138,8 @@ exports.unitPaymentModeById = unitPaymentModeById;
|
|
|
105
138
|
* @returns {Promise<PaymentModeBE>} Updated payment mode
|
|
106
139
|
*/
|
|
107
140
|
var updatePaymentMode = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
108
|
-
var paymentMode;
|
|
109
|
-
var enabled = _b.enabled, id = _b.id, prisma = _b.prisma;
|
|
141
|
+
var where, paymentMode;
|
|
142
|
+
var enabled = _b.enabled, isDefault = _b.isDefault, id = _b.id, prisma = _b.prisma;
|
|
110
143
|
return __generator(this, function (_c) {
|
|
111
144
|
switch (_c.label) {
|
|
112
145
|
case 0:
|
|
@@ -116,13 +149,13 @@ var updatePaymentMode = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
116
149
|
if (typeof enabled !== 'boolean') {
|
|
117
150
|
throw new Error('Enabled status must be a boolean');
|
|
118
151
|
}
|
|
152
|
+
where = { id: id };
|
|
119
153
|
return [4 /*yield*/, prisma.paymentMode.update({
|
|
120
|
-
where: {
|
|
121
|
-
id: id,
|
|
122
|
-
},
|
|
123
154
|
data: {
|
|
124
155
|
enabled: enabled,
|
|
156
|
+
isDefault: isDefault,
|
|
125
157
|
},
|
|
158
|
+
where: where,
|
|
126
159
|
})];
|
|
127
160
|
case 1:
|
|
128
161
|
paymentMode = _c.sent();
|
|
@@ -137,7 +170,7 @@ exports.updatePaymentMode = updatePaymentMode;
|
|
|
137
170
|
* @returns {Promise<PaymentModeBE>} Deleted payment mode
|
|
138
171
|
*/
|
|
139
172
|
var deletePaymentMode = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
140
|
-
var paymentMode;
|
|
173
|
+
var where, paymentMode;
|
|
141
174
|
var id = _b.id, prisma = _b.prisma;
|
|
142
175
|
return __generator(this, function (_c) {
|
|
143
176
|
switch (_c.label) {
|
|
@@ -145,10 +178,9 @@ var deletePaymentMode = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
145
178
|
if (!id) {
|
|
146
179
|
throw new Error('Payment mode ID is required');
|
|
147
180
|
}
|
|
181
|
+
where = { id: id };
|
|
148
182
|
return [4 /*yield*/, prisma.paymentMode.delete({
|
|
149
|
-
where:
|
|
150
|
-
id: id,
|
|
151
|
-
},
|
|
183
|
+
where: where,
|
|
152
184
|
})];
|
|
153
185
|
case 1:
|
|
154
186
|
paymentMode = _c.sent();
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { PreferenceBE } from '../type';
|
|
2
2
|
type PrismaClient = any;
|
|
3
|
-
interface
|
|
3
|
+
export interface ListPreferencesArgs {
|
|
4
4
|
orderByColumn?: string;
|
|
5
5
|
orderByDirection?: 'asc' | 'desc';
|
|
6
6
|
prisma: PrismaClient;
|
|
7
7
|
}
|
|
8
|
-
interface PostPreferenceArgs {
|
|
8
|
+
export interface PostPreferenceArgs {
|
|
9
9
|
id: string;
|
|
10
10
|
onboarding: boolean;
|
|
11
11
|
prisma: PrismaClient;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Retrieves all preferences
|
|
15
|
-
* @param {
|
|
15
|
+
* @param {ListPreferencesArgs} args - Object containing prisma client and ordering options
|
|
16
16
|
* @returns {Promise<Array<PreferenceBE>>} Array of preferences
|
|
17
17
|
*/
|
|
18
|
-
export declare const listPreference: ({ orderByColumn, orderByDirection, prisma, }:
|
|
18
|
+
export declare const listPreference: ({ orderByColumn, orderByDirection, prisma, }: ListPreferencesArgs) => Promise<Array<PreferenceBE>>;
|
|
19
19
|
/**
|
|
20
20
|
* Updates a preference using upsert
|
|
21
21
|
* @param {PostPreferenceArgs} args - Object containing prisma client, preference ID, and onboarding status
|
|
@@ -50,20 +50,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
50
50
|
exports.updatePreference = exports.listPreference = void 0;
|
|
51
51
|
/**
|
|
52
52
|
* Retrieves all preferences
|
|
53
|
-
* @param {
|
|
53
|
+
* @param {ListPreferencesArgs} args - Object containing prisma client and ordering options
|
|
54
54
|
* @returns {Promise<Array<PreferenceBE>>} Array of preferences
|
|
55
55
|
*/
|
|
56
56
|
var listPreference = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
57
|
-
var include, orderBy, where,
|
|
58
|
-
var
|
|
59
|
-
var
|
|
60
|
-
return __generator(this, function (
|
|
61
|
-
switch (
|
|
57
|
+
var include, orderBy, where, _c, count, items;
|
|
58
|
+
var _d;
|
|
59
|
+
var _e = _b.orderByColumn, orderByColumn = _e === void 0 ? 'createdAt' : _e, _f = _b.orderByDirection, orderByDirection = _f === void 0 ? 'desc' : _f, prisma = _b.prisma;
|
|
60
|
+
return __generator(this, function (_g) {
|
|
61
|
+
switch (_g.label) {
|
|
62
62
|
case 0:
|
|
63
63
|
include = {};
|
|
64
|
-
orderBy = (
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
orderBy = (_d = {},
|
|
65
|
+
_d[orderByColumn] = orderByDirection,
|
|
66
|
+
_d);
|
|
67
67
|
where = {};
|
|
68
68
|
return [4 /*yield*/, prisma.preference.findMany({
|
|
69
69
|
include: include,
|
|
@@ -71,8 +71,8 @@ var listPreference = function (_a) { return __awaiter(void 0, [_a], void 0, func
|
|
|
71
71
|
where: where,
|
|
72
72
|
})];
|
|
73
73
|
case 1:
|
|
74
|
-
|
|
75
|
-
return [2 /*return*/,
|
|
74
|
+
_c = _g.sent(), count = _c[0], items = _c[1];
|
|
75
|
+
return [2 /*return*/, [count, items]];
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
78
|
}); };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ProductBE } from '../type';
|
|
2
2
|
type PrismaClient = any;
|
|
3
|
-
interface ListProductArgs {
|
|
3
|
+
export interface ListProductArgs {
|
|
4
4
|
currentPage?: number;
|
|
5
5
|
includeProductCategory?: boolean;
|
|
6
6
|
includeQuotesInvoices?: boolean;
|
|
@@ -8,22 +8,21 @@ interface ListProductArgs {
|
|
|
8
8
|
orderByDirection?: 'asc' | 'desc';
|
|
9
9
|
pageLimit?: number;
|
|
10
10
|
prisma: PrismaClient;
|
|
11
|
+
searchQuery?: string;
|
|
11
12
|
}
|
|
12
|
-
interface UnitProductByIdArgs {
|
|
13
|
+
export interface UnitProductByIdArgs {
|
|
13
14
|
id: string;
|
|
15
|
+
prisma: PrismaClient;
|
|
14
16
|
includeProductCategory?: boolean;
|
|
15
17
|
includeQuotesInvoices?: boolean;
|
|
16
|
-
prisma: PrismaClient;
|
|
17
18
|
}
|
|
18
|
-
interface UpdateProductArgs {
|
|
19
|
+
export interface UpdateProductArgs {
|
|
19
20
|
buyPrice: string;
|
|
20
21
|
currency: string;
|
|
21
22
|
description?: string;
|
|
22
23
|
id: string;
|
|
23
24
|
image?: string;
|
|
24
25
|
include?: any;
|
|
25
|
-
includeProductCategory?: boolean;
|
|
26
|
-
includeQuotesInvoices?: boolean;
|
|
27
26
|
name: string;
|
|
28
27
|
prisma: PrismaClient;
|
|
29
28
|
productCategoryId: string;
|
|
@@ -31,10 +30,8 @@ interface UpdateProductArgs {
|
|
|
31
30
|
ref?: string;
|
|
32
31
|
salePrice: string;
|
|
33
32
|
}
|
|
34
|
-
interface DeleteProductArgs {
|
|
33
|
+
export interface DeleteProductArgs {
|
|
35
34
|
id: string;
|
|
36
|
-
includeProductCategory?: boolean;
|
|
37
|
-
includeQuotesInvoices?: boolean;
|
|
38
35
|
prisma: PrismaClient;
|
|
39
36
|
}
|
|
40
37
|
/**
|
|
@@ -42,7 +39,7 @@ interface DeleteProductArgs {
|
|
|
42
39
|
* @param {ListProductArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
43
40
|
* @returns {Promise<[number, Array<ProductBE>]>} Tuple containing total count and array of products
|
|
44
41
|
*/
|
|
45
|
-
export declare const listProduct: ({ currentPage, includeProductCategory, includeQuotesInvoices, orderByColumn, orderByDirection, pageLimit, prisma, }: ListProductArgs) => Promise<[number, Array<ProductBE>]>;
|
|
42
|
+
export declare const listProduct: ({ currentPage, includeProductCategory, includeQuotesInvoices, orderByColumn, orderByDirection, pageLimit, prisma, searchQuery, }: ListProductArgs) => Promise<[number, Array<ProductBE>]>;
|
|
46
43
|
/**
|
|
47
44
|
* Retrieves a single product by its ID
|
|
48
45
|
* @param {UnitProductByIdArgs} args - Object containing prisma client, product ID, and optional query parameters
|
|
@@ -54,11 +51,11 @@ export declare const unitProductById: ({ id, includeProductCategory, includeQuot
|
|
|
54
51
|
* @param {UpdateProductArgs} args - Object containing prisma client, product data, and optional query parameters
|
|
55
52
|
* @returns {Promise<ProductBE>} Created or updated product
|
|
56
53
|
*/
|
|
57
|
-
export declare const updateProduct: ({ buyPrice, currency, description, id, image,
|
|
54
|
+
export declare const updateProduct: ({ buyPrice, currency, description, id, image, name, prisma, productCategoryId, quantity, ref, salePrice, }: UpdateProductArgs) => Promise<ProductBE>;
|
|
58
55
|
/**
|
|
59
56
|
* Deletes a product by ID
|
|
60
57
|
* @param {DeleteProductArgs} args - Object containing prisma client, product ID, and optional query parameters
|
|
61
58
|
* @returns {Promise<ProductBE>} Deleted product
|
|
62
59
|
*/
|
|
63
|
-
export declare const deleteProduct: ({ id,
|
|
60
|
+
export declare const deleteProduct: ({ id, prisma, }: DeleteProductArgs) => Promise<ProductBE>;
|
|
64
61
|
export {};
|
|
@@ -46,25 +46,35 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
+
if (ar || !(i in from)) {
|
|
52
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
+
ar[i] = from[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
+
};
|
|
49
58
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
59
|
exports.deleteProduct = exports.updateProduct = exports.unitProductById = exports.listProduct = void 0;
|
|
60
|
+
var multi_part_search_1 = require("../../../general/multi-part-search");
|
|
51
61
|
/**
|
|
52
62
|
* Retrieves a paginated list of products
|
|
53
63
|
* @param {ListProductArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
54
64
|
* @returns {Promise<[number, Array<ProductBE>]>} Tuple containing total count and array of products
|
|
55
65
|
*/
|
|
56
66
|
var listProduct = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
57
|
-
var include, orderBy,
|
|
67
|
+
var include, orderBy, idSearchQuery, nameSearchQuery, refSearchQuery, where, _c, count, items;
|
|
58
68
|
var _d;
|
|
59
|
-
var _e = _b.currentPage, currentPage = _e === void 0 ? 1 : _e, _f = _b.includeProductCategory, includeProductCategory = _f === void 0 ? false : _f, _g = _b.includeQuotesInvoices, includeQuotesInvoices = _g === void 0 ? false : _g, _h = _b.orderByColumn, orderByColumn = _h === void 0 ? 'createdAt' : _h, _j = _b.orderByDirection, orderByDirection = _j === void 0 ? 'desc' : _j, _k = _b.pageLimit, pageLimit = _k === void 0 ?
|
|
60
|
-
return __generator(this, function (
|
|
61
|
-
switch (
|
|
69
|
+
var _e = _b.currentPage, currentPage = _e === void 0 ? 1 : _e, _f = _b.includeProductCategory, includeProductCategory = _f === void 0 ? false : _f, _g = _b.includeQuotesInvoices, includeQuotesInvoices = _g === void 0 ? false : _g, _h = _b.orderByColumn, orderByColumn = _h === void 0 ? 'createdAt' : _h, _j = _b.orderByDirection, orderByDirection = _j === void 0 ? 'desc' : _j, _k = _b.pageLimit, pageLimit = _k === void 0 ? 5 : _k, prisma = _b.prisma, _l = _b.searchQuery, searchQuery = _l === void 0 ? '' : _l;
|
|
70
|
+
return __generator(this, function (_m) {
|
|
71
|
+
switch (_m.label) {
|
|
62
72
|
case 0:
|
|
63
|
-
if (currentPage < 1) {
|
|
64
|
-
throw new Error('
|
|
73
|
+
if (!currentPage || currentPage < 1) {
|
|
74
|
+
throw new Error('Valid current page is required');
|
|
65
75
|
}
|
|
66
|
-
if (pageLimit < 1) {
|
|
67
|
-
throw new Error('
|
|
76
|
+
if (!pageLimit || pageLimit < 1) {
|
|
77
|
+
throw new Error('Valid page limit is required');
|
|
68
78
|
}
|
|
69
79
|
include = {
|
|
70
80
|
productCategory: includeProductCategory,
|
|
@@ -73,8 +83,21 @@ var listProduct = function (_a) { return __awaiter(void 0, [_a], void 0, functio
|
|
|
73
83
|
orderBy = (_d = {},
|
|
74
84
|
_d[orderByColumn] = orderByDirection,
|
|
75
85
|
_d);
|
|
76
|
-
|
|
77
|
-
|
|
86
|
+
idSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
87
|
+
columnName: 'id',
|
|
88
|
+
fullText: searchQuery,
|
|
89
|
+
});
|
|
90
|
+
nameSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
91
|
+
columnName: 'name',
|
|
92
|
+
fullText: searchQuery,
|
|
93
|
+
});
|
|
94
|
+
refSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
95
|
+
columnName: 'ref',
|
|
96
|
+
fullText: searchQuery,
|
|
97
|
+
});
|
|
98
|
+
where = {
|
|
99
|
+
OR: __spreadArray(__spreadArray(__spreadArray([], idSearchQuery, true), nameSearchQuery, true), refSearchQuery, true),
|
|
100
|
+
};
|
|
78
101
|
return [4 /*yield*/, prisma.$transaction([
|
|
79
102
|
prisma.product.count({
|
|
80
103
|
where: where,
|
|
@@ -82,13 +105,13 @@ var listProduct = function (_a) { return __awaiter(void 0, [_a], void 0, functio
|
|
|
82
105
|
prisma.product.findMany({
|
|
83
106
|
include: include,
|
|
84
107
|
orderBy: orderBy,
|
|
85
|
-
skip:
|
|
108
|
+
skip: (currentPage - 1) * pageLimit,
|
|
86
109
|
take: pageLimit,
|
|
87
110
|
where: where,
|
|
88
111
|
}),
|
|
89
112
|
])];
|
|
90
113
|
case 1:
|
|
91
|
-
_c =
|
|
114
|
+
_c = _m.sent(), count = _c[0], items = _c[1];
|
|
92
115
|
return [2 /*return*/, [count, items]];
|
|
93
116
|
}
|
|
94
117
|
});
|
|
@@ -132,10 +155,10 @@ exports.unitProductById = unitProductById;
|
|
|
132
155
|
* @returns {Promise<ProductBE>} Created or updated product
|
|
133
156
|
*/
|
|
134
157
|
var updateProduct = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
135
|
-
var productData,
|
|
136
|
-
var buyPrice = _b.buyPrice, currency = _b.currency, description = _b.description, id = _b.id, image = _b.image,
|
|
137
|
-
return __generator(this, function (
|
|
138
|
-
switch (
|
|
158
|
+
var productData, where, product;
|
|
159
|
+
var buyPrice = _b.buyPrice, currency = _b.currency, description = _b.description, id = _b.id, image = _b.image, name = _b.name, prisma = _b.prisma, productCategoryId = _b.productCategoryId, quantity = _b.quantity, ref = _b.ref, salePrice = _b.salePrice;
|
|
160
|
+
return __generator(this, function (_c) {
|
|
161
|
+
switch (_c.label) {
|
|
139
162
|
case 0:
|
|
140
163
|
if (!id) {
|
|
141
164
|
throw new Error('Product ID is required');
|
|
@@ -159,21 +182,16 @@ var updateProduct = function (_a) { return __awaiter(void 0, [_a], void 0, funct
|
|
|
159
182
|
ref: ref || null,
|
|
160
183
|
salePrice: salePrice,
|
|
161
184
|
};
|
|
162
|
-
include = {
|
|
163
|
-
productCategory: includeProductCategory,
|
|
164
|
-
quotesInvoices: includeQuotesInvoices,
|
|
165
|
-
};
|
|
166
185
|
where = {
|
|
167
186
|
id: id,
|
|
168
187
|
};
|
|
169
188
|
return [4 /*yield*/, prisma.product.upsert({
|
|
170
189
|
create: __assign({ id: id }, productData),
|
|
171
|
-
include: include,
|
|
172
190
|
update: productData,
|
|
173
191
|
where: where,
|
|
174
192
|
})];
|
|
175
193
|
case 1:
|
|
176
|
-
product =
|
|
194
|
+
product = _c.sent();
|
|
177
195
|
return [2 /*return*/, product];
|
|
178
196
|
}
|
|
179
197
|
});
|
|
@@ -185,27 +203,22 @@ exports.updateProduct = updateProduct;
|
|
|
185
203
|
* @returns {Promise<ProductBE>} Deleted product
|
|
186
204
|
*/
|
|
187
205
|
var deleteProduct = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
188
|
-
var
|
|
189
|
-
var id = _b.id,
|
|
190
|
-
return __generator(this, function (
|
|
191
|
-
switch (
|
|
206
|
+
var where, product;
|
|
207
|
+
var id = _b.id, prisma = _b.prisma;
|
|
208
|
+
return __generator(this, function (_c) {
|
|
209
|
+
switch (_c.label) {
|
|
192
210
|
case 0:
|
|
193
211
|
if (!id) {
|
|
194
212
|
throw new Error('Product ID is required');
|
|
195
213
|
}
|
|
196
|
-
include = {
|
|
197
|
-
productCategory: includeProductCategory,
|
|
198
|
-
quotesInvoices: includeQuotesInvoices,
|
|
199
|
-
};
|
|
200
214
|
where = {
|
|
201
215
|
id: id,
|
|
202
216
|
};
|
|
203
217
|
return [4 /*yield*/, prisma.product.delete({
|
|
204
|
-
include: include,
|
|
205
218
|
where: where,
|
|
206
219
|
})];
|
|
207
220
|
case 1:
|
|
208
|
-
product =
|
|
221
|
+
product = _c.sent();
|
|
209
222
|
return [2 /*return*/, product];
|
|
210
223
|
}
|
|
211
224
|
});
|
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
import { ProductCategoryBE } from '../type';
|
|
2
2
|
type PrismaClient = any;
|
|
3
|
-
interface ListProductCategoryArgs {
|
|
3
|
+
export interface ListProductCategoryArgs {
|
|
4
4
|
currentPage?: number;
|
|
5
5
|
includeProducts?: boolean;
|
|
6
6
|
orderByColumn?: string;
|
|
7
7
|
orderByDirection?: 'asc' | 'desc';
|
|
8
8
|
pageLimit?: number;
|
|
9
9
|
prisma: PrismaClient;
|
|
10
|
+
searchQuery?: string;
|
|
10
11
|
}
|
|
11
|
-
interface UnitProductCategoryByIdArgs {
|
|
12
|
+
export interface UnitProductCategoryByIdArgs {
|
|
12
13
|
id: string;
|
|
13
14
|
includeProducts?: boolean;
|
|
14
15
|
prisma: PrismaClient;
|
|
15
16
|
}
|
|
16
|
-
interface UpdateProductCategoryArgs {
|
|
17
|
+
export interface UpdateProductCategoryArgs {
|
|
17
18
|
description?: string;
|
|
18
19
|
id: string;
|
|
19
|
-
includeProducts?: boolean;
|
|
20
20
|
name: string;
|
|
21
21
|
prisma: PrismaClient;
|
|
22
22
|
}
|
|
23
|
-
interface DeleteProductCategoryArgs {
|
|
23
|
+
export interface DeleteProductCategoryArgs {
|
|
24
24
|
id: string;
|
|
25
|
-
includeProducts?: boolean;
|
|
26
25
|
prisma: PrismaClient;
|
|
27
26
|
}
|
|
28
27
|
/**
|
|
@@ -30,7 +29,7 @@ interface DeleteProductCategoryArgs {
|
|
|
30
29
|
* @param {ListProductCategoryArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
31
30
|
* @returns {Promise<[number, Array<ProductCategoryBE>]>} Tuple containing total count and array of product categories
|
|
32
31
|
*/
|
|
33
|
-
export declare const listProductCategory: ({ currentPage, includeProducts, orderByColumn, orderByDirection, pageLimit, prisma, }: ListProductCategoryArgs) => Promise<[number, Array<ProductCategoryBE>]>;
|
|
32
|
+
export declare const listProductCategory: ({ currentPage, includeProducts, orderByColumn, orderByDirection, pageLimit, prisma, searchQuery, }: ListProductCategoryArgs) => Promise<[number, Array<ProductCategoryBE>]>;
|
|
34
33
|
/**
|
|
35
34
|
* Retrieves a single product category by its ID
|
|
36
35
|
* @param {UnitProductCategoryByIdArgs} args - Object containing prisma client, product category ID, and optional query parameters
|
|
@@ -42,11 +41,11 @@ export declare const unitProductCategoryById: ({ id, includeProducts, prisma, }:
|
|
|
42
41
|
* @param {UpdateProductCategoryArgs} args - Object containing prisma client, product category data, and optional query parameters
|
|
43
42
|
* @returns {Promise<ProductCategoryBE>} Created or updated product category
|
|
44
43
|
*/
|
|
45
|
-
export declare const updateProductCategory: ({ description, id,
|
|
44
|
+
export declare const updateProductCategory: ({ description, id, name, prisma, }: UpdateProductCategoryArgs) => Promise<ProductCategoryBE>;
|
|
46
45
|
/**
|
|
47
46
|
* Deletes a product category by ID
|
|
48
47
|
* @param {DeleteProductCategoryArgs} args - Object containing prisma client, product category ID, and optional query parameters
|
|
49
48
|
* @returns {Promise<ProductCategoryBE>} Deleted product category
|
|
50
49
|
*/
|
|
51
|
-
export declare const deleteProductCategory: ({ id,
|
|
50
|
+
export declare const deleteProductCategory: ({ id, prisma, }: DeleteProductCategoryArgs) => Promise<ProductCategoryBE>;
|
|
52
51
|
export {};
|