@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.
- 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 +292 -177
- package/api/stellar-solutions/type.js +93 -1
- 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) {
|
|
@@ -37,114 +47,140 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
47
|
}
|
|
38
48
|
};
|
|
39
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.deleteProductCategory = exports.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
})];
|
|
54
|
-
case 1:
|
|
55
|
-
productCategories = _c.sent();
|
|
56
|
-
return [2 /*return*/, productCategories];
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}); };
|
|
60
|
-
exports.getProductCategories = getProductCategories;
|
|
61
|
-
var getProductCategoryById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
62
|
-
var productCategory;
|
|
63
|
-
var prisma = _b.prisma, id = _b.id;
|
|
64
|
-
return __generator(this, function (_c) {
|
|
65
|
-
switch (_c.label) {
|
|
66
|
-
case 0: return [4 /*yield*/, prisma.productCategory.findUnique({
|
|
67
|
-
where: {
|
|
68
|
-
id: id,
|
|
69
|
-
},
|
|
70
|
-
include: {
|
|
71
|
-
products: true,
|
|
72
|
-
},
|
|
73
|
-
})];
|
|
74
|
-
case 1:
|
|
75
|
-
productCategory = _c.sent();
|
|
76
|
-
return [2 /*return*/, productCategory];
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}); };
|
|
80
|
-
exports.getProductCategoryById = getProductCategoryById;
|
|
81
|
-
var postProductCategories = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
82
|
-
var productCategories, err_1;
|
|
83
|
-
var currentPage = _b.currentPage, include = _b.include, orderBy = _b.orderBy, pageLimit = _b.pageLimit, prisma = _b.prisma, queryWhere = _b.queryWhere;
|
|
84
|
-
return __generator(this, function (_c) {
|
|
85
|
-
switch (_c.label) {
|
|
50
|
+
exports.deleteProductCategory = exports.updateProductCategory = exports.unitProductCategoryById = exports.listProductCategory = void 0;
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves a paginated list of product categories
|
|
53
|
+
* @param {ListProductCategoryArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
54
|
+
* @returns {Promise<[number, Array<ProductCategoryBE>]>} Tuple containing total count and array of product categories
|
|
55
|
+
*/
|
|
56
|
+
var listProductCategory = 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
|
+
products: true,
|
|
60
|
+
} : _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;
|
|
61
|
+
return __generator(this, function (_j) {
|
|
62
|
+
switch (_j.label) {
|
|
86
63
|
case 0:
|
|
87
|
-
|
|
88
|
-
|
|
64
|
+
if (currentPage < 1) {
|
|
65
|
+
throw new Error('Current page must be greater than or equal to 1');
|
|
66
|
+
}
|
|
67
|
+
if (pageLimit < 1) {
|
|
68
|
+
throw new Error('Page limit must be greater than or equal to 1');
|
|
69
|
+
}
|
|
70
|
+
skip = (currentPage - 1) * pageLimit;
|
|
71
|
+
return [4 /*yield*/, Promise.all([
|
|
89
72
|
prisma.productCategory.count({
|
|
90
73
|
where: queryWhere,
|
|
91
74
|
}),
|
|
92
75
|
prisma.productCategory.findMany({
|
|
76
|
+
include: include || null,
|
|
93
77
|
orderBy: orderBy,
|
|
94
|
-
|
|
95
|
-
where: queryWhere,
|
|
78
|
+
skip: skip,
|
|
96
79
|
take: pageLimit,
|
|
97
|
-
|
|
80
|
+
where: queryWhere,
|
|
98
81
|
}),
|
|
99
82
|
])];
|
|
100
83
|
case 1:
|
|
101
|
-
|
|
102
|
-
return [
|
|
103
|
-
case 2:
|
|
104
|
-
err_1 = _c.sent();
|
|
105
|
-
return [2 /*return*/, err_1];
|
|
106
|
-
case 3: return [2 /*return*/, productCategories];
|
|
84
|
+
_c = _j.sent(), count = _c[0], data = _c[1];
|
|
85
|
+
return [2 /*return*/, [count, data]];
|
|
107
86
|
}
|
|
108
87
|
});
|
|
109
88
|
}); };
|
|
110
|
-
exports.
|
|
111
|
-
|
|
89
|
+
exports.listProductCategory = listProductCategory;
|
|
90
|
+
/**
|
|
91
|
+
* Retrieves a single product category by its ID
|
|
92
|
+
* @param {UnitProductCategoryByIdArgs} args - Object containing prisma client, product category ID, and optional query parameters
|
|
93
|
+
* @returns {Promise<ProductCategoryBE | null>} Product category or null if not found
|
|
94
|
+
*/
|
|
95
|
+
var unitProductCategoryById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
112
96
|
var productCategory;
|
|
113
|
-
var
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
97
|
+
var id = _b.id, _c = _b.include, include = _c === void 0 ? {
|
|
98
|
+
products: true,
|
|
99
|
+
} : _c, prisma = _b.prisma, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d;
|
|
100
|
+
return __generator(this, function (_e) {
|
|
101
|
+
switch (_e.label) {
|
|
102
|
+
case 0:
|
|
103
|
+
if (!id) {
|
|
104
|
+
throw new Error('Product category ID is required');
|
|
105
|
+
}
|
|
106
|
+
if ((queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id) && queryWhere.id !== id) {
|
|
107
|
+
throw new Error('ID mismatch between parameter and queryWhere');
|
|
108
|
+
}
|
|
109
|
+
return [4 /*yield*/, prisma.productCategory.findUnique({
|
|
110
|
+
include: include || null,
|
|
111
|
+
where: __assign({ id: id }, queryWhere),
|
|
112
|
+
})];
|
|
129
113
|
case 1:
|
|
130
|
-
productCategory =
|
|
114
|
+
productCategory = _e.sent();
|
|
131
115
|
return [2 /*return*/, productCategory];
|
|
132
116
|
}
|
|
133
117
|
});
|
|
134
118
|
}); };
|
|
135
|
-
exports.
|
|
119
|
+
exports.unitProductCategoryById = unitProductCategoryById;
|
|
120
|
+
/**
|
|
121
|
+
* Creates or updates a product category
|
|
122
|
+
* @param {UpdateProductCategoryArgs} args - Object containing prisma client, product category data, and optional query parameters
|
|
123
|
+
* @returns {Promise<ProductCategoryBE>} Created or updated product category
|
|
124
|
+
*/
|
|
125
|
+
var updateProductCategory = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
126
|
+
var productCategoryData, productCategory;
|
|
127
|
+
var description = _b.description, id = _b.id, _c = _b.include, include = _c === void 0 ? {
|
|
128
|
+
products: true,
|
|
129
|
+
} : _c, name = _b.name, prisma = _b.prisma, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d;
|
|
130
|
+
return __generator(this, function (_e) {
|
|
131
|
+
switch (_e.label) {
|
|
132
|
+
case 0:
|
|
133
|
+
if (!id) {
|
|
134
|
+
throw new Error('Product category ID is required');
|
|
135
|
+
}
|
|
136
|
+
if (!name) {
|
|
137
|
+
throw new Error('Product category name is required');
|
|
138
|
+
}
|
|
139
|
+
if ((queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id) && queryWhere.id !== id) {
|
|
140
|
+
throw new Error('ID mismatch between parameter and queryWhere');
|
|
141
|
+
}
|
|
142
|
+
productCategoryData = {
|
|
143
|
+
description: description || null,
|
|
144
|
+
name: name,
|
|
145
|
+
};
|
|
146
|
+
return [4 /*yield*/, prisma.productCategory.upsert({
|
|
147
|
+
include: include || null,
|
|
148
|
+
where: __assign({ id: id }, queryWhere),
|
|
149
|
+
update: productCategoryData,
|
|
150
|
+
create: __assign({ id: id }, productCategoryData),
|
|
151
|
+
})];
|
|
152
|
+
case 1:
|
|
153
|
+
productCategory = _e.sent();
|
|
154
|
+
return [2 /*return*/, productCategory];
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}); };
|
|
158
|
+
exports.updateProductCategory = updateProductCategory;
|
|
159
|
+
/**
|
|
160
|
+
* Deletes a product category by ID
|
|
161
|
+
* @param {DeleteProductCategoryArgs} args - Object containing prisma client, product category ID, and optional query parameters
|
|
162
|
+
* @returns {Promise<ProductCategoryBE>} Deleted product category
|
|
163
|
+
*/
|
|
136
164
|
var deleteProductCategory = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
137
165
|
var productCategory;
|
|
138
|
-
var
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
166
|
+
var id = _b.id, _c = _b.include, include = _c === void 0 ? {
|
|
167
|
+
products: true,
|
|
168
|
+
} : _c, prisma = _b.prisma, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d;
|
|
169
|
+
return __generator(this, function (_e) {
|
|
170
|
+
switch (_e.label) {
|
|
171
|
+
case 0:
|
|
172
|
+
if (!id) {
|
|
173
|
+
throw new Error('Product category ID is required');
|
|
174
|
+
}
|
|
175
|
+
if ((queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id) && queryWhere.id !== id) {
|
|
176
|
+
throw new Error('ID mismatch between parameter and queryWhere');
|
|
177
|
+
}
|
|
178
|
+
return [4 /*yield*/, prisma.productCategory.delete({
|
|
179
|
+
include: include || null,
|
|
180
|
+
where: __assign({ id: id }, queryWhere),
|
|
181
|
+
})];
|
|
146
182
|
case 1:
|
|
147
|
-
productCategory =
|
|
183
|
+
productCategory = _e.sent();
|
|
148
184
|
return [2 /*return*/, productCategory];
|
|
149
185
|
}
|
|
150
186
|
});
|
|
@@ -1,46 +1,77 @@
|
|
|
1
1
|
import { ProfileBE } from '../type';
|
|
2
|
+
type PrismaClient = any;
|
|
2
3
|
interface GetProfilesArgs {
|
|
3
|
-
prisma:
|
|
4
|
+
prisma: PrismaClient;
|
|
4
5
|
}
|
|
5
6
|
interface GetProfileByIdArgs {
|
|
6
7
|
id: string;
|
|
7
|
-
prisma:
|
|
8
|
+
prisma: PrismaClient;
|
|
8
9
|
}
|
|
9
10
|
interface GetProfileByUserIdArgs {
|
|
10
|
-
prisma:
|
|
11
|
+
prisma: PrismaClient;
|
|
11
12
|
userId: string;
|
|
12
13
|
}
|
|
13
14
|
interface PostProfilesArgs {
|
|
14
15
|
currentPage: number;
|
|
15
16
|
pageLimit: number;
|
|
16
|
-
prisma:
|
|
17
|
-
queryWhere
|
|
17
|
+
prisma: PrismaClient;
|
|
18
|
+
queryWhere?: {
|
|
18
19
|
[key: string]: any;
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
22
|
interface PostProfileArgs {
|
|
22
|
-
avatar
|
|
23
|
-
dob
|
|
23
|
+
avatar?: string;
|
|
24
|
+
dob?: string;
|
|
24
25
|
email: string;
|
|
25
26
|
firstName: string;
|
|
26
27
|
gender: string;
|
|
27
|
-
id
|
|
28
|
-
language
|
|
28
|
+
id?: string;
|
|
29
|
+
language?: string;
|
|
29
30
|
lastName: string;
|
|
30
|
-
location
|
|
31
|
+
location?: string;
|
|
31
32
|
phone: string;
|
|
32
|
-
prisma:
|
|
33
|
-
skill
|
|
33
|
+
prisma: PrismaClient;
|
|
34
|
+
skill?: string;
|
|
34
35
|
userId: string;
|
|
35
36
|
}
|
|
36
37
|
interface DeleteProfileArgs {
|
|
37
|
-
prisma:
|
|
38
|
+
prisma: PrismaClient;
|
|
38
39
|
id: string;
|
|
39
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Retrieves all profiles
|
|
43
|
+
* @param {GetProfilesArgs} args - Object containing prisma client
|
|
44
|
+
* @returns {Promise<Array<ProfileBE>>} Array of profiles ordered by creation date (newest first)
|
|
45
|
+
*/
|
|
40
46
|
export declare const getProfiles: ({ prisma, }: GetProfilesArgs) => Promise<Array<ProfileBE>>;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves a profile by its ID
|
|
49
|
+
* @param {GetProfileByIdArgs} args - Object containing prisma client and profile ID
|
|
50
|
+
* @returns {Promise<ProfileBE | null>} Profile or null if not found
|
|
51
|
+
*/
|
|
52
|
+
export declare const getProfileById: ({ prisma, id, }: GetProfileByIdArgs) => Promise<ProfileBE | null>;
|
|
53
|
+
/**
|
|
54
|
+
* Retrieves a profile by user ID
|
|
55
|
+
* @param {GetProfileByUserIdArgs} args - Object containing prisma client and user ID
|
|
56
|
+
* @returns {Promise<ProfileBE | null>} Profile or null if not found
|
|
57
|
+
*/
|
|
58
|
+
export declare const getProfileByUserId: ({ prisma, userId, }: GetProfileByUserIdArgs) => Promise<ProfileBE | null>;
|
|
59
|
+
/**
|
|
60
|
+
* Retrieves paginated profiles with filtering
|
|
61
|
+
* @param {PostProfilesArgs} args - Object containing prisma client, pagination, and filtering options
|
|
62
|
+
* @returns {Promise<[number, Array<ProfileBE>]>} Tuple of [total count, profiles array]
|
|
63
|
+
*/
|
|
64
|
+
export declare const postProfiles: ({ currentPage, pageLimit, prisma, queryWhere, }: PostProfilesArgs) => Promise<[number, Array<ProfileBE>]>;
|
|
65
|
+
/**
|
|
66
|
+
* Creates a new profile or updates an existing one
|
|
67
|
+
* @param {PostProfileArgs} args - Object containing prisma client and profile data
|
|
68
|
+
* @returns {Promise<ProfileBE>} Created or updated profile
|
|
69
|
+
*/
|
|
70
|
+
export declare const postProfile: ({ avatar, dob, email, firstName, gender, id, language, lastName, location, phone, prisma, skill, userId, }: PostProfileArgs) => Promise<ProfileBE>;
|
|
71
|
+
/**
|
|
72
|
+
* Deletes a profile by ID
|
|
73
|
+
* @param {DeleteProfileArgs} args - Object containing prisma client and profile ID
|
|
74
|
+
* @returns {Promise<ProfileBE>} Deleted profile
|
|
75
|
+
*/
|
|
45
76
|
export declare const deleteProfile: ({ prisma, id, }: DeleteProfileArgs) => Promise<ProfileBE>;
|
|
46
77
|
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) {
|
|
@@ -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.deleteProfile = exports.postProfile = exports.postProfiles = exports.getProfileByUserId = exports.getProfileById = exports.getProfiles = void 0;
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves all profiles
|
|
53
|
+
* @param {GetProfilesArgs} args - Object containing prisma client
|
|
54
|
+
* @returns {Promise<Array<ProfileBE>>} Array of profiles ordered by creation date (newest first)
|
|
55
|
+
*/
|
|
41
56
|
var getProfiles = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
42
57
|
var profiles;
|
|
43
58
|
var prisma = _b.prisma;
|
|
@@ -55,16 +70,25 @@ var getProfiles = function (_a) { return __awaiter(void 0, [_a], void 0, functio
|
|
|
55
70
|
});
|
|
56
71
|
}); };
|
|
57
72
|
exports.getProfiles = getProfiles;
|
|
73
|
+
/**
|
|
74
|
+
* Retrieves a profile by its ID
|
|
75
|
+
* @param {GetProfileByIdArgs} args - Object containing prisma client and profile ID
|
|
76
|
+
* @returns {Promise<ProfileBE | null>} Profile or null if not found
|
|
77
|
+
*/
|
|
58
78
|
var getProfileById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
59
79
|
var profile;
|
|
60
80
|
var prisma = _b.prisma, id = _b.id;
|
|
61
81
|
return __generator(this, function (_c) {
|
|
62
82
|
switch (_c.label) {
|
|
63
|
-
case 0:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
83
|
+
case 0:
|
|
84
|
+
if (!id) {
|
|
85
|
+
throw new Error('Profile ID is required');
|
|
86
|
+
}
|
|
87
|
+
return [4 /*yield*/, prisma.profile.findUnique({
|
|
88
|
+
where: {
|
|
89
|
+
id: id,
|
|
90
|
+
},
|
|
91
|
+
})];
|
|
68
92
|
case 1:
|
|
69
93
|
profile = _c.sent();
|
|
70
94
|
return [2 /*return*/, profile];
|
|
@@ -72,16 +96,25 @@ var getProfileById = function (_a) { return __awaiter(void 0, [_a], void 0, func
|
|
|
72
96
|
});
|
|
73
97
|
}); };
|
|
74
98
|
exports.getProfileById = getProfileById;
|
|
99
|
+
/**
|
|
100
|
+
* Retrieves a profile by user ID
|
|
101
|
+
* @param {GetProfileByUserIdArgs} args - Object containing prisma client and user ID
|
|
102
|
+
* @returns {Promise<ProfileBE | null>} Profile or null if not found
|
|
103
|
+
*/
|
|
75
104
|
var getProfileByUserId = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
76
105
|
var profile;
|
|
77
106
|
var prisma = _b.prisma, userId = _b.userId;
|
|
78
107
|
return __generator(this, function (_c) {
|
|
79
108
|
switch (_c.label) {
|
|
80
|
-
case 0:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
109
|
+
case 0:
|
|
110
|
+
if (!userId) {
|
|
111
|
+
throw new Error('User ID is required');
|
|
112
|
+
}
|
|
113
|
+
return [4 /*yield*/, prisma.profile.findFirst({
|
|
114
|
+
where: {
|
|
115
|
+
userId: userId,
|
|
116
|
+
},
|
|
117
|
+
})];
|
|
85
118
|
case 1:
|
|
86
119
|
profile = _c.sent();
|
|
87
120
|
return [2 /*return*/, profile];
|
|
@@ -89,84 +122,110 @@ var getProfileByUserId = function (_a) { return __awaiter(void 0, [_a], void 0,
|
|
|
89
122
|
});
|
|
90
123
|
}); };
|
|
91
124
|
exports.getProfileByUserId = getProfileByUserId;
|
|
125
|
+
/**
|
|
126
|
+
* Retrieves paginated profiles with filtering
|
|
127
|
+
* @param {PostProfilesArgs} args - Object containing prisma client, pagination, and filtering options
|
|
128
|
+
* @returns {Promise<[number, Array<ProfileBE>]>} Tuple of [total count, profiles array]
|
|
129
|
+
*/
|
|
92
130
|
var postProfiles = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
93
131
|
var profiles;
|
|
94
|
-
var
|
|
95
|
-
return __generator(this, function (
|
|
96
|
-
switch (
|
|
97
|
-
case 0:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
132
|
+
var _c = _b.currentPage, currentPage = _c === void 0 ? 1 : _c, _d = _b.pageLimit, pageLimit = _d === void 0 ? 10 : _d, prisma = _b.prisma, _e = _b.queryWhere, queryWhere = _e === void 0 ? {} : _e;
|
|
133
|
+
return __generator(this, function (_f) {
|
|
134
|
+
switch (_f.label) {
|
|
135
|
+
case 0:
|
|
136
|
+
if (currentPage < 1) {
|
|
137
|
+
throw new Error('Current page must be greater than 0');
|
|
138
|
+
}
|
|
139
|
+
if (pageLimit < 1) {
|
|
140
|
+
throw new Error('Page limit must be greater than 0');
|
|
141
|
+
}
|
|
142
|
+
return [4 /*yield*/, prisma.$transaction([
|
|
143
|
+
prisma.profile.count({
|
|
144
|
+
where: queryWhere,
|
|
145
|
+
}),
|
|
146
|
+
prisma.profile.findMany({
|
|
147
|
+
orderBy: {
|
|
148
|
+
createdAt: 'desc',
|
|
149
|
+
},
|
|
150
|
+
where: queryWhere,
|
|
151
|
+
take: pageLimit,
|
|
152
|
+
skip: (currentPage - 1) * pageLimit,
|
|
153
|
+
}),
|
|
154
|
+
])];
|
|
110
155
|
case 1:
|
|
111
|
-
profiles =
|
|
156
|
+
profiles = _f.sent();
|
|
112
157
|
return [2 /*return*/, profiles];
|
|
113
158
|
}
|
|
114
159
|
});
|
|
115
160
|
}); };
|
|
116
161
|
exports.postProfiles = postProfiles;
|
|
162
|
+
/**
|
|
163
|
+
* Creates a new profile or updates an existing one
|
|
164
|
+
* @param {PostProfileArgs} args - Object containing prisma client and profile data
|
|
165
|
+
* @returns {Promise<ProfileBE>} Created or updated profile
|
|
166
|
+
*/
|
|
117
167
|
var postProfile = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
118
|
-
var profile;
|
|
168
|
+
var profileData, profile_1, profile;
|
|
119
169
|
var avatar = _b.avatar, dob = _b.dob, email = _b.email, firstName = _b.firstName, gender = _b.gender, id = _b.id, language = _b.language, lastName = _b.lastName, location = _b.location, phone = _b.phone, prisma = _b.prisma, skill = _b.skill, userId = _b.userId;
|
|
120
170
|
return __generator(this, function (_c) {
|
|
121
171
|
switch (_c.label) {
|
|
122
|
-
case 0:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
location: location,
|
|
148
|
-
phone: phone,
|
|
149
|
-
skill: skill,
|
|
150
|
-
userId: userId,
|
|
151
|
-
},
|
|
152
|
-
})];
|
|
172
|
+
case 0:
|
|
173
|
+
if (!email || !firstName || !gender || !lastName || !phone || !userId) {
|
|
174
|
+
throw new Error('Email, first name, gender, last name, phone, and user ID are required');
|
|
175
|
+
}
|
|
176
|
+
profileData = {
|
|
177
|
+
avatar: avatar || null,
|
|
178
|
+
dob: dob || null,
|
|
179
|
+
email: email,
|
|
180
|
+
firstName: firstName,
|
|
181
|
+
gender: gender,
|
|
182
|
+
language: language || null,
|
|
183
|
+
lastName: lastName,
|
|
184
|
+
location: location || null,
|
|
185
|
+
phone: phone,
|
|
186
|
+
skill: skill || null,
|
|
187
|
+
userId: userId,
|
|
188
|
+
};
|
|
189
|
+
if (!id) return [3 /*break*/, 2];
|
|
190
|
+
return [4 /*yield*/, prisma.profile.upsert({
|
|
191
|
+
where: {
|
|
192
|
+
id: id,
|
|
193
|
+
},
|
|
194
|
+
update: profileData,
|
|
195
|
+
create: __assign({ id: id }, profileData),
|
|
196
|
+
})];
|
|
153
197
|
case 1:
|
|
198
|
+
profile_1 = _c.sent();
|
|
199
|
+
return [2 /*return*/, profile_1];
|
|
200
|
+
case 2: return [4 /*yield*/, prisma.profile.create({
|
|
201
|
+
data: profileData,
|
|
202
|
+
})];
|
|
203
|
+
case 3:
|
|
154
204
|
profile = _c.sent();
|
|
155
205
|
return [2 /*return*/, profile];
|
|
156
206
|
}
|
|
157
207
|
});
|
|
158
208
|
}); };
|
|
159
209
|
exports.postProfile = postProfile;
|
|
210
|
+
/**
|
|
211
|
+
* Deletes a profile by ID
|
|
212
|
+
* @param {DeleteProfileArgs} args - Object containing prisma client and profile ID
|
|
213
|
+
* @returns {Promise<ProfileBE>} Deleted profile
|
|
214
|
+
*/
|
|
160
215
|
var deleteProfile = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
161
216
|
var profile;
|
|
162
217
|
var prisma = _b.prisma, id = _b.id;
|
|
163
218
|
return __generator(this, function (_c) {
|
|
164
219
|
switch (_c.label) {
|
|
165
|
-
case 0:
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
220
|
+
case 0:
|
|
221
|
+
if (!id) {
|
|
222
|
+
throw new Error('Profile ID is required');
|
|
223
|
+
}
|
|
224
|
+
return [4 /*yield*/, prisma.profile.delete({
|
|
225
|
+
where: {
|
|
226
|
+
id: id,
|
|
227
|
+
},
|
|
228
|
+
})];
|
|
170
229
|
case 1:
|
|
171
230
|
profile = _c.sent();
|
|
172
231
|
return [2 /*return*/, profile];
|