@react-pakistan/util-functions 1.24.65 → 1.24.67
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 +48 -31
- package/api/stellar-solutions/product/index.js +153 -115
- 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,29 +1,78 @@
|
|
|
1
1
|
import { BranchBE } from '../type';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type PrismaClient = any;
|
|
3
|
+
interface ListBranchArgs {
|
|
4
|
+
currentPage: number;
|
|
5
|
+
include?: {
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
};
|
|
8
|
+
orderBy?: {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
pageLimit: number;
|
|
12
|
+
prisma: PrismaClient;
|
|
13
|
+
queryWhere?: {
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
};
|
|
4
16
|
}
|
|
5
|
-
interface
|
|
6
|
-
|
|
7
|
-
|
|
17
|
+
interface UnitBranchByIdArgs {
|
|
18
|
+
include?: {
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
};
|
|
21
|
+
prisma: PrismaClient;
|
|
22
|
+
queryWhere: {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
};
|
|
8
25
|
}
|
|
9
|
-
interface
|
|
26
|
+
interface UpdateBranchArgs {
|
|
10
27
|
branchAddress: string;
|
|
11
28
|
branchName: string;
|
|
12
29
|
enabled: boolean;
|
|
13
|
-
id
|
|
14
|
-
|
|
30
|
+
id?: string;
|
|
31
|
+
include?: {
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
};
|
|
34
|
+
isDefault?: boolean;
|
|
15
35
|
personEmail: string;
|
|
16
36
|
personName: string;
|
|
17
37
|
personPhone: string;
|
|
18
38
|
preferenceId: string;
|
|
19
|
-
prisma:
|
|
39
|
+
prisma: PrismaClient;
|
|
40
|
+
queryWhere?: {
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
};
|
|
20
43
|
}
|
|
21
44
|
interface DeleteBranchArgs {
|
|
22
|
-
|
|
23
|
-
|
|
45
|
+
include?: {
|
|
46
|
+
[key: string]: any;
|
|
47
|
+
};
|
|
48
|
+
prisma: PrismaClient;
|
|
49
|
+
queryWhere: {
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
};
|
|
24
52
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Retrieves all branches from the database with pagination
|
|
55
|
+
* @param {ListBranchArgs} args - Object containing prisma client, pagination, and filter options
|
|
56
|
+
* @returns {Promise<[number, Array<BranchBE>]>} Tuple of [total count, array of branches]
|
|
57
|
+
*/
|
|
58
|
+
export declare const listBranch: ({ currentPage, include, orderBy, pageLimit, prisma, queryWhere, }: ListBranchArgs) => Promise<[number, Array<BranchBE>]>;
|
|
59
|
+
/**
|
|
60
|
+
* Retrieves a single branch by ID
|
|
61
|
+
* @param {UnitBranchByIdArgs} args - Object containing prisma client and branch id
|
|
62
|
+
* @returns {Promise<BranchBE | null>} Branch if found, null otherwise
|
|
63
|
+
*/
|
|
64
|
+
export declare const unitBranchById: ({ include, prisma, queryWhere, }: UnitBranchByIdArgs) => Promise<BranchBE | null>;
|
|
65
|
+
/**
|
|
66
|
+
* Creates a new branch or updates an existing one
|
|
67
|
+
* @param {UpdateBranchArgs} args - Object containing prisma client and branch data
|
|
68
|
+
* @returns {Promise<BranchBE>} Created or updated branch
|
|
69
|
+
*/
|
|
70
|
+
export declare const updateBranch: ({ branchAddress, branchName, enabled, id, include, isDefault, personEmail, personName, personPhone, preferenceId, prisma, queryWhere, }: UpdateBranchArgs) => Promise<BranchBE>;
|
|
71
|
+
/**
|
|
72
|
+
* Deletes a branch by ID
|
|
73
|
+
* @param {DeleteBranchArgs} args - Object containing prisma client and branch id
|
|
74
|
+
* @returns {Promise<BranchBE>} Deleted branch
|
|
75
|
+
* @throws {Error} If branch ID is not provided or branch not found
|
|
76
|
+
*/
|
|
77
|
+
export declare const deleteBranch: ({ include, prisma, queryWhere, }: DeleteBranchArgs) => Promise<BranchBE>;
|
|
29
78
|
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,90 +47,134 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
47
|
}
|
|
38
48
|
};
|
|
39
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.deleteBranch = exports.
|
|
41
|
-
|
|
50
|
+
exports.deleteBranch = exports.updateBranch = exports.unitBranchById = exports.listBranch = void 0;
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves all branches from the database with pagination
|
|
53
|
+
* @param {ListBranchArgs} args - Object containing prisma client, pagination, and filter options
|
|
54
|
+
* @returns {Promise<[number, Array<BranchBE>]>} Tuple of [total count, array of branches]
|
|
55
|
+
*/
|
|
56
|
+
var listBranch = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
42
57
|
var branches;
|
|
43
|
-
var prisma = _b.prisma;
|
|
44
|
-
return __generator(this, function (
|
|
45
|
-
switch (
|
|
46
|
-
case 0:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
58
|
+
var currentPage = _b.currentPage, _c = _b.include, include = _c === void 0 ? {} : _c, _d = _b.orderBy, orderBy = _d === void 0 ? { createdAt: 'desc' } : _d, pageLimit = _b.pageLimit, prisma = _b.prisma, _e = _b.queryWhere, queryWhere = _e === void 0 ? {} : _e;
|
|
59
|
+
return __generator(this, function (_f) {
|
|
60
|
+
switch (_f.label) {
|
|
61
|
+
case 0:
|
|
62
|
+
if (!currentPage || currentPage < 1) {
|
|
63
|
+
throw new Error('Valid current page is required');
|
|
64
|
+
}
|
|
65
|
+
if (!pageLimit || pageLimit < 1) {
|
|
66
|
+
throw new Error('Valid page limit is required');
|
|
67
|
+
}
|
|
68
|
+
return [4 /*yield*/, prisma.$transaction([
|
|
69
|
+
prisma.branch.count({
|
|
70
|
+
where: queryWhere,
|
|
71
|
+
}),
|
|
72
|
+
prisma.branch.findMany({
|
|
73
|
+
include: include,
|
|
74
|
+
orderBy: orderBy,
|
|
75
|
+
skip: (currentPage - 1) * pageLimit,
|
|
76
|
+
take: pageLimit,
|
|
77
|
+
where: queryWhere,
|
|
78
|
+
}),
|
|
79
|
+
])];
|
|
51
80
|
case 1:
|
|
52
|
-
branches =
|
|
81
|
+
branches = _f.sent();
|
|
53
82
|
return [2 /*return*/, branches];
|
|
54
83
|
}
|
|
55
84
|
});
|
|
56
85
|
}); };
|
|
57
|
-
exports.
|
|
58
|
-
|
|
86
|
+
exports.listBranch = listBranch;
|
|
87
|
+
/**
|
|
88
|
+
* Retrieves a single branch by ID
|
|
89
|
+
* @param {UnitBranchByIdArgs} args - Object containing prisma client and branch id
|
|
90
|
+
* @returns {Promise<BranchBE | null>} Branch if found, null otherwise
|
|
91
|
+
*/
|
|
92
|
+
var unitBranchById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
59
93
|
var branch;
|
|
60
|
-
var prisma = _b.prisma,
|
|
61
|
-
return __generator(this, function (
|
|
62
|
-
switch (
|
|
63
|
-
case 0:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
94
|
+
var _c = _b.include, include = _c === void 0 ? {} : _c, prisma = _b.prisma, queryWhere = _b.queryWhere;
|
|
95
|
+
return __generator(this, function (_d) {
|
|
96
|
+
switch (_d.label) {
|
|
97
|
+
case 0:
|
|
98
|
+
if (!(queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id)) {
|
|
99
|
+
throw new Error('Branch ID is required');
|
|
100
|
+
}
|
|
101
|
+
return [4 /*yield*/, prisma.branch.findUnique({
|
|
102
|
+
include: include,
|
|
103
|
+
where: queryWhere,
|
|
104
|
+
})];
|
|
68
105
|
case 1:
|
|
69
|
-
branch =
|
|
106
|
+
branch = _d.sent();
|
|
70
107
|
return [2 /*return*/, branch];
|
|
71
108
|
}
|
|
72
109
|
});
|
|
73
110
|
}); };
|
|
74
|
-
exports.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
111
|
+
exports.unitBranchById = unitBranchById;
|
|
112
|
+
/**
|
|
113
|
+
* Creates a new branch or updates an existing one
|
|
114
|
+
* @param {UpdateBranchArgs} args - Object containing prisma client and branch data
|
|
115
|
+
* @returns {Promise<BranchBE>} Created or updated branch
|
|
116
|
+
*/
|
|
117
|
+
var updateBranch = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
118
|
+
var branchData, branch;
|
|
119
|
+
var branchAddress = _b.branchAddress, branchName = _b.branchName, enabled = _b.enabled, id = _b.id, include = _b.include, _c = _b.isDefault, isDefault = _c === void 0 ? false : _c, personEmail = _b.personEmail, personName = _b.personName, personPhone = _b.personPhone, preferenceId = _b.preferenceId, prisma = _b.prisma, queryWhere = _b.queryWhere;
|
|
120
|
+
return __generator(this, function (_d) {
|
|
121
|
+
switch (_d.label) {
|
|
122
|
+
case 0:
|
|
123
|
+
if (!branchAddress ||
|
|
124
|
+
!branchName ||
|
|
125
|
+
!personEmail ||
|
|
126
|
+
!personName ||
|
|
127
|
+
!personPhone ||
|
|
128
|
+
!preferenceId) {
|
|
129
|
+
throw new Error('Branch address, branch name, person email, person name, person phone, and preference ID are required');
|
|
130
|
+
}
|
|
131
|
+
if (!id || !(queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id)) {
|
|
132
|
+
throw new Error('Branch ID is required');
|
|
133
|
+
}
|
|
134
|
+
branchData = {
|
|
135
|
+
branchAddress: branchAddress,
|
|
136
|
+
branchName: branchName,
|
|
137
|
+
enabled: enabled,
|
|
138
|
+
isDefault: isDefault,
|
|
139
|
+
personEmail: personEmail,
|
|
140
|
+
personName: personName,
|
|
141
|
+
personPhone: personPhone,
|
|
142
|
+
preferenceId: preferenceId,
|
|
143
|
+
};
|
|
144
|
+
return [4 /*yield*/, prisma.branch.upsert({
|
|
145
|
+
where: queryWhere,
|
|
146
|
+
update: branchData,
|
|
147
|
+
create: __assign({ id: id }, branchData),
|
|
148
|
+
include: include,
|
|
149
|
+
})];
|
|
105
150
|
case 1:
|
|
106
|
-
branch =
|
|
151
|
+
branch = _d.sent();
|
|
107
152
|
return [2 /*return*/, branch];
|
|
108
153
|
}
|
|
109
154
|
});
|
|
110
155
|
}); };
|
|
111
|
-
exports.
|
|
156
|
+
exports.updateBranch = updateBranch;
|
|
157
|
+
/**
|
|
158
|
+
* Deletes a branch by ID
|
|
159
|
+
* @param {DeleteBranchArgs} args - Object containing prisma client and branch id
|
|
160
|
+
* @returns {Promise<BranchBE>} Deleted branch
|
|
161
|
+
* @throws {Error} If branch ID is not provided or branch not found
|
|
162
|
+
*/
|
|
112
163
|
var deleteBranch = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
113
164
|
var branch;
|
|
114
|
-
var prisma = _b.prisma,
|
|
115
|
-
return __generator(this, function (
|
|
116
|
-
switch (
|
|
117
|
-
case 0:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
165
|
+
var _c = _b.include, include = _c === void 0 ? {} : _c, prisma = _b.prisma, queryWhere = _b.queryWhere;
|
|
166
|
+
return __generator(this, function (_d) {
|
|
167
|
+
switch (_d.label) {
|
|
168
|
+
case 0:
|
|
169
|
+
if (!(queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id)) {
|
|
170
|
+
throw new Error('Branch ID is required');
|
|
171
|
+
}
|
|
172
|
+
return [4 /*yield*/, prisma.branch.delete({
|
|
173
|
+
include: include,
|
|
174
|
+
where: queryWhere,
|
|
175
|
+
})];
|
|
122
176
|
case 1:
|
|
123
|
-
branch =
|
|
177
|
+
branch = _d.sent();
|
|
124
178
|
return [2 /*return*/, branch];
|
|
125
179
|
}
|
|
126
180
|
});
|
|
@@ -1,41 +1,75 @@
|
|
|
1
1
|
import { CompanyBE } from '../type';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
interface GetCompanyByIdArgs {
|
|
6
|
-
id: string;
|
|
7
|
-
prisma: any;
|
|
8
|
-
}
|
|
9
|
-
interface PostCompaniesArgs {
|
|
2
|
+
type PrismaClient = any;
|
|
3
|
+
interface ListCompanyArgs {
|
|
10
4
|
currentPage: number;
|
|
11
|
-
include
|
|
5
|
+
include?: {
|
|
12
6
|
[key: string]: any;
|
|
13
7
|
};
|
|
14
|
-
orderBy
|
|
8
|
+
orderBy?: {
|
|
15
9
|
[key: string]: any;
|
|
16
10
|
};
|
|
17
11
|
pageLimit: number;
|
|
18
|
-
prisma:
|
|
12
|
+
prisma: PrismaClient;
|
|
13
|
+
queryWhere?: {
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
interface UnitCompanyByIdArgs {
|
|
18
|
+
include?: {
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
};
|
|
21
|
+
prisma: PrismaClient;
|
|
19
22
|
queryWhere: {
|
|
20
23
|
[key: string]: any;
|
|
21
24
|
};
|
|
22
25
|
}
|
|
23
|
-
interface
|
|
24
|
-
prisma: any;
|
|
26
|
+
interface UpdateCompanyArgs {
|
|
25
27
|
country: string;
|
|
26
28
|
email: string;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
id?: string;
|
|
30
|
+
include?: {
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
};
|
|
33
|
+
name: string;
|
|
34
|
+
phone: string;
|
|
35
|
+
prisma: PrismaClient;
|
|
36
|
+
queryWhere?: {
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
};
|
|
39
|
+
website?: string;
|
|
31
40
|
}
|
|
32
41
|
interface DeleteCompanyArgs {
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
include?: {
|
|
43
|
+
[key: string]: any;
|
|
44
|
+
};
|
|
45
|
+
prisma: PrismaClient;
|
|
46
|
+
queryWhere: {
|
|
47
|
+
[key: string]: any;
|
|
48
|
+
};
|
|
35
49
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Retrieves all companies from the database with pagination
|
|
52
|
+
* @param {ListCompanyArgs} args - Object containing prisma client, pagination, and filter options
|
|
53
|
+
* @returns {Promise<[number, Array<CompanyBE>]>} Tuple of [total count, array of companies]
|
|
54
|
+
*/
|
|
55
|
+
export declare const listCompany: ({ currentPage, include, orderBy, pageLimit, prisma, queryWhere, }: ListCompanyArgs) => Promise<[number, Array<CompanyBE>]>;
|
|
56
|
+
/**
|
|
57
|
+
* Retrieves a single company by ID
|
|
58
|
+
* @param {UnitCompanyByIdArgs} args - Object containing prisma client and company id
|
|
59
|
+
* @returns {Promise<CompanyBE | null>} Company if found, null otherwise
|
|
60
|
+
*/
|
|
61
|
+
export declare const unitCompanyById: ({ include, prisma, queryWhere, }: UnitCompanyByIdArgs) => Promise<CompanyBE | null>;
|
|
62
|
+
/**
|
|
63
|
+
* Creates a new company or updates an existing one
|
|
64
|
+
* @param {UpdateCompanyArgs} args - Object containing prisma client and company data
|
|
65
|
+
* @returns {Promise<CompanyBE>} Created or updated company
|
|
66
|
+
*/
|
|
67
|
+
export declare const updateCompany: ({ country, email, id, include, name, phone, prisma, queryWhere, website, }: UpdateCompanyArgs) => Promise<CompanyBE>;
|
|
68
|
+
/**
|
|
69
|
+
* Deletes a company by ID
|
|
70
|
+
* @param {DeleteCompanyArgs} args - Object containing prisma client and company id
|
|
71
|
+
* @returns {Promise<CompanyBE>} Deleted company
|
|
72
|
+
* @throws {Error} If company ID is not provided or company not found
|
|
73
|
+
*/
|
|
74
|
+
export declare const deleteCompany: ({ include, prisma, queryWhere, }: DeleteCompanyArgs) => Promise<CompanyBE>;
|
|
41
75
|
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,108 +47,126 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
47
|
}
|
|
38
48
|
};
|
|
39
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.deleteCompany = exports.
|
|
41
|
-
|
|
50
|
+
exports.deleteCompany = exports.updateCompany = exports.unitCompanyById = exports.listCompany = void 0;
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves all companies from the database with pagination
|
|
53
|
+
* @param {ListCompanyArgs} args - Object containing prisma client, pagination, and filter options
|
|
54
|
+
* @returns {Promise<[number, Array<CompanyBE>]>} Tuple of [total count, array of companies]
|
|
55
|
+
*/
|
|
56
|
+
var listCompany = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
42
57
|
var companies;
|
|
43
|
-
var prisma = _b.prisma;
|
|
44
|
-
return __generator(this, function (
|
|
45
|
-
switch (
|
|
46
|
-
case 0:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
58
|
+
var currentPage = _b.currentPage, _c = _b.include, include = _c === void 0 ? {} : _c, _d = _b.orderBy, orderBy = _d === void 0 ? { createdAt: 'desc' } : _d, pageLimit = _b.pageLimit, prisma = _b.prisma, _e = _b.queryWhere, queryWhere = _e === void 0 ? {} : _e;
|
|
59
|
+
return __generator(this, function (_f) {
|
|
60
|
+
switch (_f.label) {
|
|
61
|
+
case 0:
|
|
62
|
+
if (!currentPage || currentPage < 1) {
|
|
63
|
+
throw new Error('Valid current page is required');
|
|
64
|
+
}
|
|
65
|
+
if (!pageLimit || pageLimit < 1) {
|
|
66
|
+
throw new Error('Valid page limit is required');
|
|
67
|
+
}
|
|
68
|
+
return [4 /*yield*/, prisma.$transaction([
|
|
69
|
+
prisma.company.count({
|
|
70
|
+
where: queryWhere,
|
|
71
|
+
}),
|
|
72
|
+
prisma.company.findMany({
|
|
73
|
+
include: include,
|
|
74
|
+
orderBy: orderBy,
|
|
75
|
+
skip: (currentPage - 1) * pageLimit,
|
|
76
|
+
take: pageLimit,
|
|
77
|
+
where: queryWhere,
|
|
78
|
+
}),
|
|
79
|
+
])];
|
|
51
80
|
case 1:
|
|
52
|
-
companies =
|
|
81
|
+
companies = _f.sent();
|
|
53
82
|
return [2 /*return*/, companies];
|
|
54
83
|
}
|
|
55
84
|
});
|
|
56
85
|
}); };
|
|
57
|
-
exports.
|
|
58
|
-
|
|
86
|
+
exports.listCompany = listCompany;
|
|
87
|
+
/**
|
|
88
|
+
* Retrieves a single company by ID
|
|
89
|
+
* @param {UnitCompanyByIdArgs} args - Object containing prisma client and company id
|
|
90
|
+
* @returns {Promise<CompanyBE | null>} Company if found, null otherwise
|
|
91
|
+
*/
|
|
92
|
+
var unitCompanyById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
59
93
|
var company;
|
|
60
|
-
var prisma = _b.prisma,
|
|
61
|
-
return __generator(this, function (
|
|
62
|
-
switch (
|
|
63
|
-
case 0:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
94
|
+
var _c = _b.include, include = _c === void 0 ? {} : _c, prisma = _b.prisma, queryWhere = _b.queryWhere;
|
|
95
|
+
return __generator(this, function (_d) {
|
|
96
|
+
switch (_d.label) {
|
|
97
|
+
case 0:
|
|
98
|
+
if (!(queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id)) {
|
|
99
|
+
throw new Error('Company ID is required');
|
|
100
|
+
}
|
|
101
|
+
return [4 /*yield*/, prisma.company.findUnique({
|
|
102
|
+
include: include,
|
|
103
|
+
where: queryWhere,
|
|
104
|
+
})];
|
|
68
105
|
case 1:
|
|
69
|
-
company =
|
|
106
|
+
company = _d.sent();
|
|
70
107
|
return [2 /*return*/, company];
|
|
71
108
|
}
|
|
72
109
|
});
|
|
73
110
|
}); };
|
|
74
|
-
exports.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
111
|
+
exports.unitCompanyById = unitCompanyById;
|
|
112
|
+
/**
|
|
113
|
+
* Creates a new company or updates an existing one
|
|
114
|
+
* @param {UpdateCompanyArgs} args - Object containing prisma client and company data
|
|
115
|
+
* @returns {Promise<CompanyBE>} Created or updated company
|
|
116
|
+
*/
|
|
117
|
+
var updateCompany = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
118
|
+
var companyData, company;
|
|
119
|
+
var country = _b.country, email = _b.email, id = _b.id, include = _b.include, name = _b.name, phone = _b.phone, prisma = _b.prisma, queryWhere = _b.queryWhere, website = _b.website;
|
|
78
120
|
return __generator(this, function (_c) {
|
|
79
121
|
switch (_c.label) {
|
|
80
|
-
case 0:
|
|
81
|
-
|
|
122
|
+
case 0:
|
|
123
|
+
if (!country || !email || !name || !phone) {
|
|
124
|
+
throw new Error('Country, email, name, and phone are required');
|
|
125
|
+
}
|
|
126
|
+
if (!id || !(queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id)) {
|
|
127
|
+
throw new Error('Company ID is required');
|
|
128
|
+
}
|
|
129
|
+
companyData = {
|
|
130
|
+
country: country,
|
|
131
|
+
email: email,
|
|
132
|
+
name: name,
|
|
133
|
+
phone: phone,
|
|
134
|
+
website: website || null,
|
|
135
|
+
};
|
|
136
|
+
return [4 /*yield*/, prisma.company.upsert({
|
|
82
137
|
where: queryWhere,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
orderBy: orderBy,
|
|
138
|
+
update: companyData,
|
|
139
|
+
create: __assign({ id: id }, companyData),
|
|
86
140
|
include: include,
|
|
87
|
-
|
|
88
|
-
take: pageLimit,
|
|
89
|
-
skip: (currentPage - 1) * pageLimit,
|
|
90
|
-
}),
|
|
91
|
-
])];
|
|
92
|
-
case 1:
|
|
93
|
-
companies = _c.sent();
|
|
94
|
-
return [2 /*return*/, companies];
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}); };
|
|
98
|
-
exports.postCompanies = postCompanies;
|
|
99
|
-
var postCompany = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
100
|
-
var company;
|
|
101
|
-
var prisma = _b.prisma, country = _b.country, email = _b.email, name = _b.name, id = _b.id, phone = _b.phone, website = _b.website;
|
|
102
|
-
return __generator(this, function (_c) {
|
|
103
|
-
switch (_c.label) {
|
|
104
|
-
case 0: return [4 /*yield*/, prisma.company.upsert({
|
|
105
|
-
where: {
|
|
106
|
-
id: id,
|
|
107
|
-
},
|
|
108
|
-
update: {
|
|
109
|
-
country: country,
|
|
110
|
-
email: email,
|
|
111
|
-
name: name,
|
|
112
|
-
phone: phone,
|
|
113
|
-
website: website,
|
|
114
|
-
},
|
|
115
|
-
create: {
|
|
116
|
-
country: country,
|
|
117
|
-
email: email,
|
|
118
|
-
name: name,
|
|
119
|
-
phone: phone,
|
|
120
|
-
website: website,
|
|
121
|
-
},
|
|
122
|
-
})];
|
|
141
|
+
})];
|
|
123
142
|
case 1:
|
|
124
143
|
company = _c.sent();
|
|
125
144
|
return [2 /*return*/, company];
|
|
126
145
|
}
|
|
127
146
|
});
|
|
128
147
|
}); };
|
|
129
|
-
exports.
|
|
148
|
+
exports.updateCompany = updateCompany;
|
|
149
|
+
/**
|
|
150
|
+
* Deletes a company by ID
|
|
151
|
+
* @param {DeleteCompanyArgs} args - Object containing prisma client and company id
|
|
152
|
+
* @returns {Promise<CompanyBE>} Deleted company
|
|
153
|
+
* @throws {Error} If company ID is not provided or company not found
|
|
154
|
+
*/
|
|
130
155
|
var deleteCompany = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
131
156
|
var company;
|
|
132
|
-
var prisma = _b.prisma,
|
|
133
|
-
return __generator(this, function (
|
|
134
|
-
switch (
|
|
135
|
-
case 0:
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
157
|
+
var _c = _b.include, include = _c === void 0 ? {} : _c, prisma = _b.prisma, queryWhere = _b.queryWhere;
|
|
158
|
+
return __generator(this, function (_d) {
|
|
159
|
+
switch (_d.label) {
|
|
160
|
+
case 0:
|
|
161
|
+
if (!(queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id)) {
|
|
162
|
+
throw new Error('Company ID is required');
|
|
163
|
+
}
|
|
164
|
+
return [4 /*yield*/, prisma.company.delete({
|
|
165
|
+
include: include,
|
|
166
|
+
where: queryWhere,
|
|
167
|
+
})];
|
|
140
168
|
case 1:
|
|
141
|
-
company =
|
|
169
|
+
company = _d.sent();
|
|
142
170
|
return [2 /*return*/, company];
|
|
143
171
|
}
|
|
144
172
|
});
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import { CompanyBE } from '../type';
|
|
2
|
+
type PrismaClient = any;
|
|
2
3
|
interface PostCompaniesReportArgs {
|
|
3
|
-
prisma:
|
|
4
|
-
queryWhere
|
|
4
|
+
prisma: PrismaClient;
|
|
5
|
+
queryWhere?: {
|
|
5
6
|
[key: string]: any;
|
|
6
7
|
};
|
|
7
|
-
include
|
|
8
|
+
include?: {
|
|
8
9
|
[key: string]: any;
|
|
9
10
|
};
|
|
10
|
-
orderBy
|
|
11
|
+
orderBy?: {
|
|
11
12
|
[key: string]: any;
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves companies report data with count and full list
|
|
17
|
+
* This is typically used for generating reports without pagination
|
|
18
|
+
* @param {PostCompaniesReportArgs} args - Object containing prisma client and query options
|
|
19
|
+
* @returns {Promise<[number, Array<CompanyBE>]>} Tuple containing total count and array of all matching companies
|
|
20
|
+
*/
|
|
21
|
+
export declare const postCompaniesReport: ({ prisma, queryWhere, orderBy, include, }: PostCompaniesReportArgs) => Promise<[number, Array<CompanyBE>]>;
|
|
15
22
|
export {};
|