@react-pakistan/util-functions 1.24.65 → 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.
- package/README.md +6 -3
- package/api/stellar-solutions/app-user/index.d.ts +63 -14
- package/api/stellar-solutions/app-user/index.js +106 -52
- package/api/stellar-solutions/bank/index.d.ts +65 -16
- package/api/stellar-solutions/bank/index.js +115 -65
- package/api/stellar-solutions/branch/index.d.ts +64 -15
- package/api/stellar-solutions/branch/index.js +119 -65
- package/api/stellar-solutions/company/index.d.ts +58 -24
- package/api/stellar-solutions/company/index.js +106 -78
- package/api/stellar-solutions/company-report/index.d.ts +12 -5
- package/api/stellar-solutions/company-report/index.js +12 -7
- package/api/stellar-solutions/contact/index.d.ts +54 -20
- package/api/stellar-solutions/contact/index.js +109 -88
- package/api/stellar-solutions/currency/index.d.ts +63 -14
- package/api/stellar-solutions/currency/index.js +113 -61
- package/api/stellar-solutions/customer/index.d.ts +70 -28
- package/api/stellar-solutions/customer/index.js +131 -101
- package/api/stellar-solutions/expense/index.d.ts +58 -22
- package/api/stellar-solutions/expense/index.js +128 -92
- package/api/stellar-solutions/expense-category/index.d.ts +58 -22
- package/api/stellar-solutions/expense-category/index.js +125 -86
- package/api/stellar-solutions/lead/index.js +0 -1
- package/api/stellar-solutions/menu-order/index.d.ts +29 -7
- package/api/stellar-solutions/menu-order/index.js +74 -27
- package/api/stellar-solutions/payment/index.d.ts +62 -27
- package/api/stellar-solutions/payment/index.js +144 -123
- package/api/stellar-solutions/payment-mode/index.d.ts +44 -12
- package/api/stellar-solutions/payment-mode/index.js +115 -49
- package/api/stellar-solutions/preference/index.d.ts +14 -3
- package/api/stellar-solutions/preference/index.js +44 -14
- package/api/stellar-solutions/product/index.d.ts +46 -31
- package/api/stellar-solutions/product/index.js +142 -113
- package/api/stellar-solutions/product-category/index.d.ts +44 -27
- package/api/stellar-solutions/product-category/index.js +123 -87
- package/api/stellar-solutions/profile/index.d.ts +48 -17
- package/api/stellar-solutions/profile/index.js +124 -65
- package/api/stellar-solutions/quote-invoice/index.d.ts +67 -8
- package/api/stellar-solutions/quote-invoice/index.js +123 -57
- package/api/stellar-solutions/quote-invoice-report/index.d.ts +12 -5
- package/api/stellar-solutions/quote-invoice-report/index.js +10 -5
- package/api/stellar-solutions/tax/index.d.ts +46 -14
- package/api/stellar-solutions/tax/index.js +135 -63
- package/api/stellar-solutions/type.d.ts +178 -112
- package/api/stellar-solutions/type.js +60 -2
- package/constants/countries-timezones.js +0 -1
- package/constants/currencies.js +0 -1
- package/general/basic-get.js +22 -21
- package/general/basic-post.js +19 -18
- package/general/calculate-pages.js +3 -1
- package/general/check-even-odd-length.js +3 -2
- package/general/delete-image-from-private-supabase.js +0 -1
- package/general/delete-image-from-public-supabase.js +0 -1
- package/general/dynamic-page-limit.js +3 -2
- package/general/enum-to-text.js +7 -4
- package/general/fetch-data.js +0 -1
- package/general/fetch-supabase-image.js +0 -1
- package/general/fetch-supabase-private-assets.js +15 -14
- package/general/format-date.js +8 -8
- package/general/format-number.js +3 -2
- package/general/format-time.js +3 -2
- package/general/full-year-range.js +2 -2
- package/general/generate-blog-schema.d.ts +3 -3
- package/general/generate-blog-schema.js +20 -13
- package/general/generate-breadcrumb-schema.d.ts +4 -4
- package/general/generate-breadcrumb-schema.js +9 -10
- package/general/generate-faq-schema.d.ts +5 -5
- package/general/generate-faq-schema.js +18 -11
- package/general/generate-grid.js +0 -1
- package/general/generate-organization-schema.d.ts +3 -3
- package/general/generate-organization-schema.js +25 -18
- package/general/get-available-page-limit.js +2 -2
- package/general/get-calendar-dates.js +14 -3
- package/general/get-full-name.d.ts +1 -1
- package/general/get-number-of-days-in-month.d.ts +1 -1
- package/general/get-pathname.js +4 -1
- package/general/is-odd.js +1 -1
- package/general/is-previous-button-disabled.js +3 -1
- package/general/parse-frontmatter.js +0 -1
- package/general/remove-data-image-prefix.js +3 -2
- package/general/repeat-times.js +0 -1
- package/general/resolve-current-date.js +1 -2
- package/general/resolve-grid.js +3 -2
- package/general/slugify.js +11 -9
- package/general/text-to-enum.js +6 -1
- package/general/text-to-sentence-case.js +3 -1
- package/general/time-out.js +5 -4
- package/general/truncate-text.js +3 -1
- package/general/upload-blob-to-private-supabase.js +2 -2
- package/general/upload-blob-to-public-supabase.js +2 -2
- package/general/upload-image-to-private-supabase.js +2 -2
- package/general/upload-image-to-public-supabase.js +2 -2
- package/general/validate-email.js +1 -1
- package/hooks/use-fetch.js +11 -12
- package/hooks/use-module-entity.js +5 -6
- package/hooks/use-sticky.js +0 -1
- package/hooks/with-seo.d.ts +1 -1
- package/hooks/with-seo.js +3 -4
- package/local-storage/get-storage-value.js +0 -1
- package/package.json +22 -13
- package/setupTests.js +1 -2
- package/storybook/generate-sitemap.js +0 -1
- package/storybook/preview.js +1 -4
- package/storybook/react-design-story-script.js +0 -2
- package/storybook/react-emoji-collection.js +8 -6
- package/storybook/react-emoji-story-script.js +0 -2
- package/storybook/react-icon-collection.js +4 -3
- package/storybook/react-icon-story-script.js +0 -2
- package/storybook/react-logo-collection.js +4 -3
- package/storybook/react-logo-story-script.js +0 -2
- package/storybook/responsive-component.js +14 -7
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
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) {
|
|
@@ -38,6 +48,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
48
|
};
|
|
39
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
50
|
exports.postPreference = exports.getPreferences = void 0;
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves all preferences with related data
|
|
53
|
+
* @param {GetPreferencesArgs} args - Object containing prisma client
|
|
54
|
+
* @returns {Promise<Array<PreferenceBE>>} Array of preferences with related entities (banks, branches, currencies, etc.)
|
|
55
|
+
*/
|
|
41
56
|
var getPreferences = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
42
57
|
var preferences;
|
|
43
58
|
var prisma = _b.prisma;
|
|
@@ -48,7 +63,7 @@ var getPreferences = function (_a) { return __awaiter(void 0, [_a], void 0, func
|
|
|
48
63
|
createdAt: 'desc',
|
|
49
64
|
},
|
|
50
65
|
include: {
|
|
51
|
-
|
|
66
|
+
banks: true,
|
|
52
67
|
branches: true,
|
|
53
68
|
currencies: true,
|
|
54
69
|
menuOrder: true,
|
|
@@ -63,23 +78,38 @@ var getPreferences = function (_a) { return __awaiter(void 0, [_a], void 0, func
|
|
|
63
78
|
});
|
|
64
79
|
}); };
|
|
65
80
|
exports.getPreferences = getPreferences;
|
|
81
|
+
/**
|
|
82
|
+
* Creates a new preference or updates an existing one
|
|
83
|
+
* @param {PostPreferenceArgs} args - Object containing prisma client, optional preference ID, and onboarding status
|
|
84
|
+
* @returns {Promise<PreferenceBE>} Created or updated preference
|
|
85
|
+
*/
|
|
66
86
|
var postPreference = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
67
|
-
var preference;
|
|
87
|
+
var preferenceData, preference_1, preference;
|
|
68
88
|
var prisma = _b.prisma, id = _b.id, onboarding = _b.onboarding;
|
|
69
89
|
return __generator(this, function (_c) {
|
|
70
90
|
switch (_c.label) {
|
|
71
|
-
case 0:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
91
|
+
case 0:
|
|
92
|
+
if (typeof onboarding !== 'boolean') {
|
|
93
|
+
throw new Error('Onboarding status must be a boolean');
|
|
94
|
+
}
|
|
95
|
+
preferenceData = {
|
|
96
|
+
onboarding: onboarding,
|
|
97
|
+
};
|
|
98
|
+
if (!id) return [3 /*break*/, 2];
|
|
99
|
+
return [4 /*yield*/, prisma.preference.upsert({
|
|
100
|
+
where: {
|
|
101
|
+
id: id,
|
|
102
|
+
},
|
|
103
|
+
update: preferenceData,
|
|
104
|
+
create: __assign({ id: id }, preferenceData),
|
|
105
|
+
})];
|
|
82
106
|
case 1:
|
|
107
|
+
preference_1 = _c.sent();
|
|
108
|
+
return [2 /*return*/, preference_1];
|
|
109
|
+
case 2: return [4 /*yield*/, prisma.preference.create({
|
|
110
|
+
data: preferenceData,
|
|
111
|
+
})];
|
|
112
|
+
case 3:
|
|
83
113
|
preference = _c.sent();
|
|
84
114
|
return [2 /*return*/, preference];
|
|
85
115
|
}
|
|
@@ -1,47 +1,62 @@
|
|
|
1
1
|
import { ProductBE } from '../type';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type PrismaClient = any;
|
|
3
|
+
interface ListProductArgs {
|
|
4
|
+
currentPage?: number;
|
|
5
|
+
include?: any;
|
|
6
|
+
orderBy?: any;
|
|
7
|
+
pageLimit?: number;
|
|
8
|
+
prisma: PrismaClient;
|
|
9
|
+
queryWhere?: any;
|
|
4
10
|
}
|
|
5
|
-
interface
|
|
11
|
+
interface UnitProductByIdArgs {
|
|
6
12
|
id: string;
|
|
7
|
-
|
|
13
|
+
include?: any;
|
|
14
|
+
prisma: PrismaClient;
|
|
15
|
+
queryWhere?: any;
|
|
8
16
|
}
|
|
9
|
-
interface
|
|
10
|
-
currentPage: number;
|
|
11
|
-
include: {
|
|
12
|
-
[key: string]: any;
|
|
13
|
-
};
|
|
14
|
-
orderBy: {
|
|
15
|
-
[key: string]: any;
|
|
16
|
-
};
|
|
17
|
-
pageLimit: number;
|
|
18
|
-
prisma: any;
|
|
19
|
-
queryWhere: {
|
|
20
|
-
[key: string]: any;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
interface PostProductArgs {
|
|
24
|
-
authorName: string;
|
|
17
|
+
interface UpdateProductArgs {
|
|
25
18
|
buyPrice: string;
|
|
26
19
|
currency: string;
|
|
27
|
-
description
|
|
20
|
+
description?: string;
|
|
28
21
|
id: string;
|
|
29
|
-
image
|
|
30
|
-
isbn: string;
|
|
22
|
+
image?: string;
|
|
31
23
|
name: string;
|
|
32
|
-
|
|
24
|
+
include?: any;
|
|
25
|
+
prisma: PrismaClient;
|
|
33
26
|
productCategoryId: string;
|
|
34
27
|
quantity: string;
|
|
35
|
-
|
|
28
|
+
queryWhere?: any;
|
|
29
|
+
ref?: string;
|
|
36
30
|
salePrice: string;
|
|
37
31
|
}
|
|
38
32
|
interface DeleteProductArgs {
|
|
39
|
-
prisma: any;
|
|
40
33
|
id: string;
|
|
34
|
+
include?: any;
|
|
35
|
+
prisma: PrismaClient;
|
|
36
|
+
queryWhere?: any;
|
|
41
37
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Retrieves a paginated list of products
|
|
40
|
+
* @param {ListProductArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
41
|
+
* @returns {Promise<[number, Array<ProductBE>]>} Tuple containing total count and array of products
|
|
42
|
+
*/
|
|
43
|
+
export declare const listProduct: ({ currentPage, include, orderBy, pageLimit, prisma, queryWhere, }: ListProductArgs) => Promise<[number, Array<ProductBE>]>;
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves a single product by its ID
|
|
46
|
+
* @param {UnitProductByIdArgs} args - Object containing prisma client, product ID, and optional query parameters
|
|
47
|
+
* @returns {Promise<ProductBE | null>} Product or null if not found
|
|
48
|
+
*/
|
|
49
|
+
export declare const unitProductById: ({ id, include, prisma, queryWhere, }: UnitProductByIdArgs) => Promise<ProductBE | null>;
|
|
50
|
+
/**
|
|
51
|
+
* Creates or updates a product
|
|
52
|
+
* @param {UpdateProductArgs} args - Object containing prisma client, product data, and optional query parameters
|
|
53
|
+
* @returns {Promise<ProductBE>} Created or updated product
|
|
54
|
+
*/
|
|
55
|
+
export declare const updateProduct: ({ buyPrice, currency, description, id, image, include, name, prisma, productCategoryId, quantity, queryWhere, ref, salePrice, }: UpdateProductArgs) => Promise<ProductBE>;
|
|
56
|
+
/**
|
|
57
|
+
* Deletes a product by ID
|
|
58
|
+
* @param {DeleteProductArgs} args - Object containing prisma client, product ID, and optional query parameters
|
|
59
|
+
* @returns {Promise<ProductBE>} Deleted product
|
|
60
|
+
*/
|
|
61
|
+
export declare const deleteProduct: ({ id, include, prisma, queryWhere, }: DeleteProductArgs) => Promise<ProductBE>;
|
|
47
62
|
export {};
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
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,137 +47,156 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
47
|
}
|
|
38
48
|
};
|
|
39
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.deleteProduct = exports.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
exports.deleteProduct = exports.updateProduct = exports.unitProductById = exports.listProduct = void 0;
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves a paginated list of products
|
|
53
|
+
* @param {ListProductArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
54
|
+
* @returns {Promise<[number, Array<ProductBE>]>} Tuple containing total count and array of products
|
|
55
|
+
*/
|
|
56
|
+
var listProduct = 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 ? {
|
|
59
|
+
productCategory: true,
|
|
60
|
+
quotesInvoices: true,
|
|
61
|
+
} : _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;
|
|
62
|
+
return __generator(this, function (_j) {
|
|
63
|
+
switch (_j.label) {
|
|
64
|
+
case 0:
|
|
65
|
+
if (currentPage < 1) {
|
|
66
|
+
throw new Error('Current page must be greater than or equal to 1');
|
|
67
|
+
}
|
|
68
|
+
if (pageLimit < 1) {
|
|
69
|
+
throw new Error('Page limit must be greater than or equal to 1');
|
|
70
|
+
}
|
|
71
|
+
skip = (currentPage - 1) * pageLimit;
|
|
72
|
+
return [4 /*yield*/, Promise.all([
|
|
73
|
+
prisma.product.count({
|
|
74
|
+
where: queryWhere,
|
|
75
|
+
}),
|
|
76
|
+
prisma.product.findMany({
|
|
77
|
+
include: include || null,
|
|
78
|
+
orderBy: orderBy,
|
|
79
|
+
skip: skip,
|
|
80
|
+
take: pageLimit,
|
|
81
|
+
where: queryWhere,
|
|
82
|
+
}),
|
|
83
|
+
])];
|
|
55
84
|
case 1:
|
|
56
|
-
|
|
57
|
-
return [2 /*return*/,
|
|
85
|
+
_c = _j.sent(), count = _c[0], data = _c[1];
|
|
86
|
+
return [2 /*return*/, [count, data]];
|
|
58
87
|
}
|
|
59
88
|
});
|
|
60
89
|
}); };
|
|
61
|
-
exports.
|
|
62
|
-
|
|
90
|
+
exports.listProduct = listProduct;
|
|
91
|
+
/**
|
|
92
|
+
* Retrieves a single product by its ID
|
|
93
|
+
* @param {UnitProductByIdArgs} args - Object containing prisma client, product ID, and optional query parameters
|
|
94
|
+
* @returns {Promise<ProductBE | null>} Product or null if not found
|
|
95
|
+
*/
|
|
96
|
+
var unitProductById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
63
97
|
var product;
|
|
64
|
-
var
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
98
|
+
var id = _b.id, _c = _b.include, include = _c === void 0 ? {
|
|
99
|
+
productCategory: true,
|
|
100
|
+
quotesInvoices: true,
|
|
101
|
+
} : _c, prisma = _b.prisma, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d;
|
|
102
|
+
return __generator(this, function (_e) {
|
|
103
|
+
switch (_e.label) {
|
|
104
|
+
case 0:
|
|
105
|
+
if (!id) {
|
|
106
|
+
throw new Error('Product ID is required');
|
|
107
|
+
}
|
|
108
|
+
if ((queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id) && queryWhere.id !== id) {
|
|
109
|
+
throw new Error('ID mismatch between parameter and queryWhere');
|
|
110
|
+
}
|
|
111
|
+
return [4 /*yield*/, prisma.product.findUnique({
|
|
112
|
+
include: include || null,
|
|
113
|
+
where: __assign({ id: id }, queryWhere),
|
|
114
|
+
})];
|
|
76
115
|
case 1:
|
|
77
|
-
product =
|
|
116
|
+
product = _e.sent();
|
|
78
117
|
return [2 /*return*/, product];
|
|
79
118
|
}
|
|
80
119
|
});
|
|
81
120
|
}); };
|
|
82
|
-
exports.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
take: pageLimit,
|
|
97
|
-
where: queryWhere,
|
|
98
|
-
}),
|
|
99
|
-
])];
|
|
100
|
-
case 1:
|
|
101
|
-
products = _c.sent();
|
|
102
|
-
return [2 /*return*/, products];
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}); };
|
|
106
|
-
exports.postProducts = postProducts;
|
|
107
|
-
var postProduct = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
108
|
-
var product, error_1;
|
|
109
|
-
var authorName = _b.authorName, buyPrice = _b.buyPrice, currency = _b.currency, description = _b.description, id = _b.id, image = _b.image, isbn = _b.isbn, name = _b.name, prisma = _b.prisma, productCategoryId = _b.productCategoryId, quantity = _b.quantity, ref = _b.ref, salePrice = _b.salePrice;
|
|
110
|
-
return __generator(this, function (_c) {
|
|
111
|
-
switch (_c.label) {
|
|
121
|
+
exports.unitProductById = unitProductById;
|
|
122
|
+
/**
|
|
123
|
+
* Creates or updates a product
|
|
124
|
+
* @param {UpdateProductArgs} args - Object containing prisma client, product data, and optional query parameters
|
|
125
|
+
* @returns {Promise<ProductBE>} Created or updated product
|
|
126
|
+
*/
|
|
127
|
+
var updateProduct = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
128
|
+
var productData, product;
|
|
129
|
+
var buyPrice = _b.buyPrice, currency = _b.currency, description = _b.description, id = _b.id, image = _b.image, _c = _b.include, include = _c === void 0 ? {
|
|
130
|
+
productCategory: true,
|
|
131
|
+
quotesInvoices: true,
|
|
132
|
+
} : _c, name = _b.name, prisma = _b.prisma, productCategoryId = _b.productCategoryId, quantity = _b.quantity, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d, ref = _b.ref, salePrice = _b.salePrice;
|
|
133
|
+
return __generator(this, function (_e) {
|
|
134
|
+
switch (_e.label) {
|
|
112
135
|
case 0:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
136
|
+
if (!id) {
|
|
137
|
+
throw new Error('Product ID is required');
|
|
138
|
+
}
|
|
139
|
+
if (!buyPrice ||
|
|
140
|
+
!currency ||
|
|
141
|
+
!name ||
|
|
142
|
+
!productCategoryId ||
|
|
143
|
+
!quantity ||
|
|
144
|
+
!salePrice) {
|
|
145
|
+
throw new Error('Buy price, currency, name, product category ID, quantity, and sale price are required');
|
|
146
|
+
}
|
|
147
|
+
if ((queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id) && queryWhere.id !== id) {
|
|
148
|
+
throw new Error('ID mismatch between parameter and queryWhere');
|
|
149
|
+
}
|
|
150
|
+
productData = {
|
|
151
|
+
buyPrice: buyPrice,
|
|
152
|
+
currency: currency,
|
|
153
|
+
description: description || null,
|
|
154
|
+
image: image || null,
|
|
155
|
+
name: name,
|
|
156
|
+
productCategoryId: productCategoryId,
|
|
157
|
+
quantity: quantity,
|
|
158
|
+
ref: ref || null,
|
|
159
|
+
salePrice: salePrice,
|
|
160
|
+
};
|
|
117
161
|
return [4 /*yield*/, prisma.product.upsert({
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
authorName: authorName,
|
|
123
|
-
buyPrice: buyPrice,
|
|
124
|
-
currency: currency,
|
|
125
|
-
description: description,
|
|
126
|
-
image: image,
|
|
127
|
-
isbn: isbn,
|
|
128
|
-
name: name,
|
|
129
|
-
productCategoryId: productCategoryId,
|
|
130
|
-
quantity: quantity,
|
|
131
|
-
ref: ref,
|
|
132
|
-
salePrice: salePrice,
|
|
133
|
-
},
|
|
134
|
-
create: {
|
|
135
|
-
authorName: authorName,
|
|
136
|
-
buyPrice: buyPrice,
|
|
137
|
-
currency: currency,
|
|
138
|
-
description: description,
|
|
139
|
-
image: image,
|
|
140
|
-
isbn: isbn,
|
|
141
|
-
name: name,
|
|
142
|
-
productCategoryId: productCategoryId,
|
|
143
|
-
quantity: quantity,
|
|
144
|
-
ref: ref,
|
|
145
|
-
salePrice: salePrice,
|
|
146
|
-
},
|
|
162
|
+
include: include || null,
|
|
163
|
+
where: __assign({ id: id }, queryWhere),
|
|
164
|
+
update: productData,
|
|
165
|
+
create: __assign({ id: id }, productData),
|
|
147
166
|
})];
|
|
148
|
-
case
|
|
149
|
-
product =
|
|
150
|
-
return [
|
|
151
|
-
case 3:
|
|
152
|
-
error_1 = _c.sent();
|
|
153
|
-
return [2 /*return*/, error_1];
|
|
154
|
-
case 4: return [2 /*return*/, product];
|
|
167
|
+
case 1:
|
|
168
|
+
product = _e.sent();
|
|
169
|
+
return [2 /*return*/, product];
|
|
155
170
|
}
|
|
156
171
|
});
|
|
157
172
|
}); };
|
|
158
|
-
exports.
|
|
173
|
+
exports.updateProduct = updateProduct;
|
|
174
|
+
/**
|
|
175
|
+
* Deletes a product by ID
|
|
176
|
+
* @param {DeleteProductArgs} args - Object containing prisma client, product ID, and optional query parameters
|
|
177
|
+
* @returns {Promise<ProductBE>} Deleted product
|
|
178
|
+
*/
|
|
159
179
|
var deleteProduct = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
160
180
|
var product;
|
|
161
|
-
var
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
181
|
+
var id = _b.id, _c = _b.include, include = _c === void 0 ? {
|
|
182
|
+
productCategory: true,
|
|
183
|
+
quotesInvoices: true,
|
|
184
|
+
} : _c, prisma = _b.prisma, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d;
|
|
185
|
+
return __generator(this, function (_e) {
|
|
186
|
+
switch (_e.label) {
|
|
187
|
+
case 0:
|
|
188
|
+
if (!id) {
|
|
189
|
+
throw new Error('Product ID is required');
|
|
190
|
+
}
|
|
191
|
+
if ((queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id) && queryWhere.id !== id) {
|
|
192
|
+
throw new Error('ID mismatch between parameter and queryWhere');
|
|
193
|
+
}
|
|
194
|
+
return [4 /*yield*/, prisma.product.delete({
|
|
195
|
+
include: include || null,
|
|
196
|
+
where: __assign({ id: id }, queryWhere),
|
|
197
|
+
})];
|
|
169
198
|
case 1:
|
|
170
|
-
product =
|
|
199
|
+
product = _e.sent();
|
|
171
200
|
return [2 /*return*/, product];
|
|
172
201
|
}
|
|
173
202
|
});
|
|
@@ -1,38 +1,55 @@
|
|
|
1
1
|
import { ProductCategoryBE } from '../type';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type PrismaClient = any;
|
|
3
|
+
interface ListProductCategoryArgs {
|
|
4
|
+
currentPage?: number;
|
|
5
|
+
include?: any;
|
|
6
|
+
orderBy?: any;
|
|
7
|
+
pageLimit?: number;
|
|
8
|
+
prisma: PrismaClient;
|
|
9
|
+
queryWhere?: any;
|
|
4
10
|
}
|
|
5
|
-
interface
|
|
11
|
+
interface UnitProductCategoryByIdArgs {
|
|
6
12
|
id: string;
|
|
7
|
-
|
|
13
|
+
include?: any;
|
|
14
|
+
prisma: PrismaClient;
|
|
15
|
+
queryWhere?: any;
|
|
8
16
|
}
|
|
9
|
-
interface
|
|
10
|
-
|
|
11
|
-
include: {
|
|
12
|
-
[key: string]: any;
|
|
13
|
-
};
|
|
14
|
-
orderBy: {
|
|
15
|
-
[key: string]: any;
|
|
16
|
-
};
|
|
17
|
-
pageLimit: number;
|
|
18
|
-
prisma: any;
|
|
19
|
-
queryWhere: {
|
|
20
|
-
[key: string]: any;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
interface PostProductCategoryArgs {
|
|
24
|
-
description: string;
|
|
17
|
+
interface UpdateProductCategoryArgs {
|
|
18
|
+
description?: string;
|
|
25
19
|
id: string;
|
|
20
|
+
include?: any;
|
|
26
21
|
name: string;
|
|
27
|
-
prisma:
|
|
22
|
+
prisma: PrismaClient;
|
|
23
|
+
queryWhere?: any;
|
|
28
24
|
}
|
|
29
25
|
interface DeleteProductCategoryArgs {
|
|
30
|
-
prisma: any;
|
|
31
26
|
id: string;
|
|
27
|
+
include?: any;
|
|
28
|
+
prisma: PrismaClient;
|
|
29
|
+
queryWhere?: any;
|
|
32
30
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Retrieves a paginated list of product categories
|
|
33
|
+
* @param {ListProductCategoryArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
34
|
+
* @returns {Promise<[number, Array<ProductCategoryBE>]>} Tuple containing total count and array of product categories
|
|
35
|
+
*/
|
|
36
|
+
export declare const listProductCategory: ({ currentPage, include, orderBy, pageLimit, prisma, queryWhere, }: ListProductCategoryArgs) => Promise<[number, Array<ProductCategoryBE>]>;
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves a single product category by its ID
|
|
39
|
+
* @param {UnitProductCategoryByIdArgs} args - Object containing prisma client, product category ID, and optional query parameters
|
|
40
|
+
* @returns {Promise<ProductCategoryBE | null>} Product category or null if not found
|
|
41
|
+
*/
|
|
42
|
+
export declare const unitProductCategoryById: ({ id, include, prisma, queryWhere, }: UnitProductCategoryByIdArgs) => Promise<ProductCategoryBE | null>;
|
|
43
|
+
/**
|
|
44
|
+
* Creates or updates a product category
|
|
45
|
+
* @param {UpdateProductCategoryArgs} args - Object containing prisma client, product category data, and optional query parameters
|
|
46
|
+
* @returns {Promise<ProductCategoryBE>} Created or updated product category
|
|
47
|
+
*/
|
|
48
|
+
export declare const updateProductCategory: ({ description, id, include, name, prisma, queryWhere, }: UpdateProductCategoryArgs) => Promise<ProductCategoryBE>;
|
|
49
|
+
/**
|
|
50
|
+
* Deletes a product category by ID
|
|
51
|
+
* @param {DeleteProductCategoryArgs} args - Object containing prisma client, product category ID, and optional query parameters
|
|
52
|
+
* @returns {Promise<ProductCategoryBE>} Deleted product category
|
|
53
|
+
*/
|
|
54
|
+
export declare const deleteProductCategory: ({ id, include, prisma, queryWhere, }: DeleteProductCategoryArgs) => Promise<ProductCategoryBE>;
|
|
38
55
|
export {};
|