@react-pakistan/util-functions 1.24.68 → 1.24.70
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.
|
@@ -6,6 +6,7 @@ interface ListCompanyArgs {
|
|
|
6
6
|
orderByDirection?: 'asc' | 'desc';
|
|
7
7
|
pageLimit: number;
|
|
8
8
|
prisma: PrismaClient;
|
|
9
|
+
searchQuery?: string;
|
|
9
10
|
}
|
|
10
11
|
interface UnitCompanyByIdArgs {
|
|
11
12
|
id: string;
|
|
@@ -29,7 +30,7 @@ interface DeleteCompanyArgs {
|
|
|
29
30
|
* @param {ListCompanyArgs} args - Object containing prisma client, pagination, and filter options
|
|
30
31
|
* @returns {Promise<[number, Array<CompanyBE>]>} Tuple of [total count, array of companies]
|
|
31
32
|
*/
|
|
32
|
-
export declare const listCompany: ({ currentPage, orderByColumn, orderByDirection, pageLimit, prisma, }: ListCompanyArgs) => Promise<[number, Array<CompanyBE>]>;
|
|
33
|
+
export declare const listCompany: ({ currentPage, orderByColumn, orderByDirection, pageLimit, prisma, searchQuery, }: ListCompanyArgs) => Promise<[number, Array<CompanyBE>]>;
|
|
33
34
|
/**
|
|
34
35
|
* Retrieves a single company by ID
|
|
35
36
|
* @param {UnitCompanyByIdArgs} args - Object containing prisma client and company id
|
|
@@ -46,19 +46,29 @@ 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.deleteCompany = exports.updateCompany = exports.unitCompanyById = exports.listCompany = void 0;
|
|
60
|
+
var multi_part_search_1 = require("../../../general/multi-part-search");
|
|
51
61
|
/**
|
|
52
62
|
* Retrieves all companies from the database with pagination
|
|
53
63
|
* @param {ListCompanyArgs} args - Object containing prisma client, pagination, and filter options
|
|
54
64
|
* @returns {Promise<[number, Array<CompanyBE>]>} Tuple of [total count, array of companies]
|
|
55
65
|
*/
|
|
56
66
|
var listCompany = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
57
|
-
var companies;
|
|
67
|
+
var idSearchQuery, nameSearchQuery, emailSearchQuery, where, companies;
|
|
58
68
|
var _c;
|
|
59
|
-
var currentPage = _b.currentPage, _d = _b.orderByColumn, orderByColumn = _d === void 0 ? 'createdAt' : _d, _e = _b.orderByDirection, orderByDirection = _e === void 0 ? 'desc' : _e, pageLimit = _b.pageLimit, prisma = _b.prisma;
|
|
60
|
-
return __generator(this, function (
|
|
61
|
-
switch (
|
|
69
|
+
var currentPage = _b.currentPage, _d = _b.orderByColumn, orderByColumn = _d === void 0 ? 'createdAt' : _d, _e = _b.orderByDirection, orderByDirection = _e === void 0 ? 'desc' : _e, pageLimit = _b.pageLimit, prisma = _b.prisma, _f = _b.searchQuery, searchQuery = _f === void 0 ? '' : _f;
|
|
70
|
+
return __generator(this, function (_g) {
|
|
71
|
+
switch (_g.label) {
|
|
62
72
|
case 0:
|
|
63
73
|
if (!currentPage || currentPage < 1) {
|
|
64
74
|
throw new Error('Valid current page is required');
|
|
@@ -66,18 +76,36 @@ var listCompany = function (_a) { return __awaiter(void 0, [_a], void 0, functio
|
|
|
66
76
|
if (!pageLimit || pageLimit < 1) {
|
|
67
77
|
throw new Error('Valid page limit is required');
|
|
68
78
|
}
|
|
79
|
+
idSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
80
|
+
columnName: 'id',
|
|
81
|
+
fullText: searchQuery,
|
|
82
|
+
});
|
|
83
|
+
nameSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
84
|
+
columnName: 'name',
|
|
85
|
+
fullText: searchQuery,
|
|
86
|
+
});
|
|
87
|
+
emailSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
88
|
+
columnName: 'email',
|
|
89
|
+
fullText: searchQuery,
|
|
90
|
+
});
|
|
91
|
+
where = {
|
|
92
|
+
OR: __spreadArray(__spreadArray(__spreadArray([], idSearchQuery, true), nameSearchQuery, true), emailSearchQuery, true),
|
|
93
|
+
};
|
|
69
94
|
return [4 /*yield*/, prisma.$transaction([
|
|
70
|
-
prisma.company.count(
|
|
95
|
+
prisma.company.count({
|
|
96
|
+
where: where,
|
|
97
|
+
}),
|
|
71
98
|
prisma.company.findMany({
|
|
72
99
|
orderBy: (_c = {},
|
|
73
100
|
_c[orderByColumn] = orderByDirection,
|
|
74
101
|
_c),
|
|
75
102
|
skip: (currentPage - 1) * pageLimit,
|
|
76
103
|
take: pageLimit,
|
|
104
|
+
where: where,
|
|
77
105
|
}),
|
|
78
106
|
])];
|
|
79
107
|
case 1:
|
|
80
|
-
companies =
|
|
108
|
+
companies = _g.sent();
|
|
81
109
|
return [2 /*return*/, companies];
|
|
82
110
|
}
|
|
83
111
|
});
|
|
@@ -15,11 +15,11 @@ interface PostPreferenceArgs {
|
|
|
15
15
|
* @param {GetPreferencesArgs} args - Object containing prisma client and ordering options
|
|
16
16
|
* @returns {Promise<Array<PreferenceBE>>} Array of preferences
|
|
17
17
|
*/
|
|
18
|
-
export declare const
|
|
18
|
+
export declare const listPreference: ({ orderByColumn, orderByDirection, prisma, }: GetPreferencesArgs) => 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
|
|
22
22
|
* @returns {Promise<PreferenceBE>} Updated preference
|
|
23
23
|
*/
|
|
24
|
-
export declare const
|
|
24
|
+
export declare const updatePreference: ({ id, onboarding, prisma, }: PostPreferenceArgs) => Promise<PreferenceBE>;
|
|
25
25
|
export {};
|
|
@@ -47,13 +47,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.
|
|
50
|
+
exports.updatePreference = exports.listPreference = void 0;
|
|
51
51
|
/**
|
|
52
52
|
* Retrieves all preferences
|
|
53
53
|
* @param {GetPreferencesArgs} args - Object containing prisma client and ordering options
|
|
54
54
|
* @returns {Promise<Array<PreferenceBE>>} Array of preferences
|
|
55
55
|
*/
|
|
56
|
-
var
|
|
56
|
+
var listPreference = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
57
57
|
var include, orderBy, where, preferences;
|
|
58
58
|
var _c;
|
|
59
59
|
var _d = _b.orderByColumn, orderByColumn = _d === void 0 ? 'createdAt' : _d, _e = _b.orderByDirection, orderByDirection = _e === void 0 ? 'desc' : _e, prisma = _b.prisma;
|
|
@@ -76,14 +76,14 @@ var getPreferences = function (_a) { return __awaiter(void 0, [_a], void 0, func
|
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
78
|
}); };
|
|
79
|
-
exports.
|
|
79
|
+
exports.listPreference = listPreference;
|
|
80
80
|
/**
|
|
81
81
|
* Updates a preference using upsert
|
|
82
82
|
* @param {PostPreferenceArgs} args - Object containing prisma client, preference ID, and onboarding status
|
|
83
83
|
* @returns {Promise<PreferenceBE>} Updated preference
|
|
84
84
|
*/
|
|
85
|
-
var
|
|
86
|
-
var preferenceData, preference;
|
|
85
|
+
var updatePreference = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
86
|
+
var preferenceData, where, preference;
|
|
87
87
|
var id = _b.id, onboarding = _b.onboarding, prisma = _b.prisma;
|
|
88
88
|
return __generator(this, function (_c) {
|
|
89
89
|
switch (_c.label) {
|
|
@@ -97,10 +97,13 @@ var postPreference = function (_a) { return __awaiter(void 0, [_a], void 0, func
|
|
|
97
97
|
preferenceData = {
|
|
98
98
|
onboarding: onboarding,
|
|
99
99
|
};
|
|
100
|
+
where = {
|
|
101
|
+
id: id,
|
|
102
|
+
};
|
|
100
103
|
return [4 /*yield*/, prisma.preference.upsert({
|
|
101
104
|
create: __assign({ id: id }, preferenceData),
|
|
102
105
|
update: preferenceData,
|
|
103
|
-
where:
|
|
106
|
+
where: where,
|
|
104
107
|
})];
|
|
105
108
|
case 1:
|
|
106
109
|
preference = _c.sent();
|
|
@@ -108,4 +111,4 @@ var postPreference = function (_a) { return __awaiter(void 0, [_a], void 0, func
|
|
|
108
111
|
}
|
|
109
112
|
});
|
|
110
113
|
}); };
|
|
111
|
-
exports.
|
|
114
|
+
exports.updatePreference = updatePreference;
|