@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
package/README.md
CHANGED
|
@@ -54,6 +54,7 @@ A central place to declare all React Web util functions for ReactPakistan eco-sy
|
|
|
54
54
|
- Clone the repo
|
|
55
55
|
- Cd into the project folder
|
|
56
56
|
- Figure out which package manager you have on your system, then run following commands for their specific use cases.
|
|
57
|
+
|
|
57
58
|
```console
|
|
58
59
|
// to install dependencies
|
|
59
60
|
yarn
|
|
@@ -62,7 +63,9 @@ A central place to declare all React Web util functions for ReactPakistan eco-sy
|
|
|
62
63
|
// to run all tests locally
|
|
63
64
|
yarn test
|
|
64
65
|
```
|
|
66
|
+
|
|
65
67
|
OR
|
|
68
|
+
|
|
66
69
|
```console
|
|
67
70
|
// cd to website directory
|
|
68
71
|
cd website
|
|
@@ -89,8 +92,8 @@ Should you like this project and would like to see more coming in future, please
|
|
|
89
92
|
|
|
90
93
|
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
91
94
|
|
|
92
|
-
| Contributors
|
|
93
|
-
|
|
|
95
|
+
| Contributors | GitHub | Emoji |
|
|
96
|
+
| ------------------------------------------------------------------------- | :-----------------------------------------------------: | :----------: |
|
|
94
97
|
| <img src="https://avatars0.githubusercontent.com/u/27800340?s=150&v=4" /> | <a href="https://github.com/taimoormk">Taimoor Khan</a> | 🎨🤔🚧📆👀⚠️ |
|
|
95
98
|
|
|
96
99
|
### 📌 Other Libraries from ReactPakistan 🚀
|
|
@@ -338,7 +341,7 @@ I can be reachable via [Taimoor Web](https://taimoor.io) or else should you wish
|
|
|
338
341
|
<a
|
|
339
342
|
href="https://www.buymeacoffee.com/60whp8FM3"
|
|
340
343
|
target="_blank">
|
|
341
|
-
|
|
344
|
+
<img
|
|
342
345
|
alt="Buy Me A Coffee"
|
|
343
346
|
src="https://bmc-cdn.nyc3.digitaloceanspaces.com/BMC-button-images/custom_images/yellow_img.png"
|
|
344
347
|
/>
|
|
@@ -1,24 +1,73 @@
|
|
|
1
1
|
import { AppUserBE } from '../type';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type PrismaClient = any;
|
|
3
|
+
interface ListAppUserArgs {
|
|
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 UnitAppUserByIdArgs {
|
|
18
|
+
include?: {
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
};
|
|
21
|
+
prisma: PrismaClient;
|
|
22
|
+
queryWhere: {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
};
|
|
8
25
|
}
|
|
9
|
-
interface
|
|
10
|
-
prisma: any;
|
|
11
|
-
id: string;
|
|
26
|
+
interface UpdateAppUserArgs {
|
|
12
27
|
email: string;
|
|
13
28
|
firstName: string;
|
|
29
|
+
id: string;
|
|
30
|
+
include?: {
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
};
|
|
14
33
|
lastName: string;
|
|
34
|
+
prisma: PrismaClient;
|
|
35
|
+
queryWhere?: {
|
|
36
|
+
[key: string]: any;
|
|
37
|
+
};
|
|
15
38
|
}
|
|
16
39
|
interface DeleteAppUserArgs {
|
|
17
|
-
|
|
18
|
-
|
|
40
|
+
include?: {
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
};
|
|
43
|
+
prisma: PrismaClient;
|
|
44
|
+
queryWhere: {
|
|
45
|
+
[key: string]: any;
|
|
46
|
+
};
|
|
19
47
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Retrieves all app users from the database with pagination
|
|
50
|
+
* @param {ListAppUserArgs} args - Object containing prisma client, pagination, and query options
|
|
51
|
+
* @returns {Promise<[number, Array<AppUserBE>]>} Tuple of [total count, array of app users]
|
|
52
|
+
*/
|
|
53
|
+
export declare const listAppUser: ({ currentPage, include, orderBy, pageLimit, prisma, queryWhere, }: ListAppUserArgs) => Promise<[number, Array<AppUserBE>]>;
|
|
54
|
+
/**
|
|
55
|
+
* Retrieves a single app user by ID
|
|
56
|
+
* @param {UnitAppUserByIdArgs} args - Object containing prisma client and user query
|
|
57
|
+
* @returns {Promise<AppUserBE | null>} App user if found, null otherwise
|
|
58
|
+
*/
|
|
59
|
+
export declare const unitAppUserById: ({ include, prisma, queryWhere, }: UnitAppUserByIdArgs) => Promise<AppUserBE | null>;
|
|
60
|
+
/**
|
|
61
|
+
* Creates a new app user or updates an existing one
|
|
62
|
+
* @param {UpdateAppUserArgs} args - Object containing prisma client and user data
|
|
63
|
+
* @returns {Promise<AppUserBE>} Created or updated app user
|
|
64
|
+
*/
|
|
65
|
+
export declare const updateAppUser: ({ email, firstName, id, include, lastName, prisma, queryWhere, }: UpdateAppUserArgs) => Promise<AppUserBE>;
|
|
66
|
+
/**
|
|
67
|
+
* Deletes an app user by ID
|
|
68
|
+
* @param {DeleteAppUserArgs} args - Object containing prisma client and user query
|
|
69
|
+
* @returns {Promise<AppUserBE>} Deleted app user
|
|
70
|
+
* @throws {Error} If user ID is not provided or user not found
|
|
71
|
+
*/
|
|
72
|
+
export declare const deleteAppUser: ({ include, prisma, queryWhere, }: DeleteAppUserArgs) => Promise<AppUserBE>;
|
|
24
73
|
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,80 +47,124 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
47
|
}
|
|
38
48
|
};
|
|
39
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.deleteAppUser = exports.
|
|
41
|
-
|
|
50
|
+
exports.deleteAppUser = exports.updateAppUser = exports.unitAppUserById = exports.listAppUser = void 0;
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves all app users from the database with pagination
|
|
53
|
+
* @param {ListAppUserArgs} args - Object containing prisma client, pagination, and query options
|
|
54
|
+
* @returns {Promise<[number, Array<AppUserBE>]>} Tuple of [total count, array of app users]
|
|
55
|
+
*/
|
|
56
|
+
var listAppUser = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
42
57
|
var appUsers;
|
|
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.appUser.count({
|
|
70
|
+
where: queryWhere,
|
|
71
|
+
}),
|
|
72
|
+
prisma.appUser.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
|
-
appUsers =
|
|
81
|
+
appUsers = _f.sent();
|
|
53
82
|
return [2 /*return*/, appUsers];
|
|
54
83
|
}
|
|
55
84
|
});
|
|
56
85
|
}); };
|
|
57
|
-
exports.
|
|
58
|
-
|
|
86
|
+
exports.listAppUser = listAppUser;
|
|
87
|
+
/**
|
|
88
|
+
* Retrieves a single app user by ID
|
|
89
|
+
* @param {UnitAppUserByIdArgs} args - Object containing prisma client and user query
|
|
90
|
+
* @returns {Promise<AppUserBE | null>} App user if found, null otherwise
|
|
91
|
+
*/
|
|
92
|
+
var unitAppUserById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
59
93
|
var appUser;
|
|
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('User ID is required');
|
|
100
|
+
}
|
|
101
|
+
return [4 /*yield*/, prisma.appUser.findUnique({
|
|
102
|
+
include: include,
|
|
103
|
+
where: queryWhere,
|
|
104
|
+
})];
|
|
68
105
|
case 1:
|
|
69
|
-
appUser =
|
|
106
|
+
appUser = _d.sent();
|
|
70
107
|
return [2 /*return*/, appUser];
|
|
71
108
|
}
|
|
72
109
|
});
|
|
73
110
|
}); };
|
|
74
|
-
exports.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
111
|
+
exports.unitAppUserById = unitAppUserById;
|
|
112
|
+
/**
|
|
113
|
+
* Creates a new app user or updates an existing one
|
|
114
|
+
* @param {UpdateAppUserArgs} args - Object containing prisma client and user data
|
|
115
|
+
* @returns {Promise<AppUserBE>} Created or updated app user
|
|
116
|
+
*/
|
|
117
|
+
var updateAppUser = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
118
|
+
var userData, appUser;
|
|
119
|
+
var email = _b.email, firstName = _b.firstName, id = _b.id, include = _b.include, lastName = _b.lastName, prisma = _b.prisma, queryWhere = _b.queryWhere;
|
|
78
120
|
return __generator(this, function (_c) {
|
|
79
121
|
switch (_c.label) {
|
|
80
|
-
case 0:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
122
|
+
case 0:
|
|
123
|
+
if (!email || !firstName || !lastName) {
|
|
124
|
+
throw new Error('Email, first name, and last name are required');
|
|
125
|
+
}
|
|
126
|
+
if (!id) {
|
|
127
|
+
throw new Error('User ID is required');
|
|
128
|
+
}
|
|
129
|
+
userData = {
|
|
130
|
+
email: email,
|
|
131
|
+
firstName: firstName,
|
|
132
|
+
lastName: lastName,
|
|
133
|
+
};
|
|
134
|
+
return [4 /*yield*/, prisma.appUser.upsert({
|
|
135
|
+
where: queryWhere,
|
|
136
|
+
update: userData,
|
|
137
|
+
create: __assign({ id: id }, userData),
|
|
138
|
+
include: include,
|
|
139
|
+
})];
|
|
95
140
|
case 1:
|
|
96
141
|
appUser = _c.sent();
|
|
97
142
|
return [2 /*return*/, appUser];
|
|
98
143
|
}
|
|
99
144
|
});
|
|
100
145
|
}); };
|
|
101
|
-
exports.
|
|
146
|
+
exports.updateAppUser = updateAppUser;
|
|
147
|
+
/**
|
|
148
|
+
* Deletes an app user by ID
|
|
149
|
+
* @param {DeleteAppUserArgs} args - Object containing prisma client and user query
|
|
150
|
+
* @returns {Promise<AppUserBE>} Deleted app user
|
|
151
|
+
* @throws {Error} If user ID is not provided or user not found
|
|
152
|
+
*/
|
|
102
153
|
var deleteAppUser = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
103
154
|
var appUser;
|
|
104
|
-
var prisma = _b.prisma,
|
|
105
|
-
return __generator(this, function (
|
|
106
|
-
switch (
|
|
107
|
-
case 0:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
155
|
+
var _c = _b.include, include = _c === void 0 ? {} : _c, prisma = _b.prisma, queryWhere = _b.queryWhere;
|
|
156
|
+
return __generator(this, function (_d) {
|
|
157
|
+
switch (_d.label) {
|
|
158
|
+
case 0:
|
|
159
|
+
if (!(queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id)) {
|
|
160
|
+
throw new Error('User ID is required');
|
|
161
|
+
}
|
|
162
|
+
return [4 /*yield*/, prisma.appUser.delete({
|
|
163
|
+
include: include,
|
|
164
|
+
where: queryWhere,
|
|
165
|
+
})];
|
|
112
166
|
case 1:
|
|
113
|
-
appUser =
|
|
167
|
+
appUser = _d.sent();
|
|
114
168
|
return [2 /*return*/, appUser];
|
|
115
169
|
}
|
|
116
170
|
});
|
|
@@ -1,30 +1,79 @@
|
|
|
1
1
|
import { BankBE } from '../type';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type PrismaClient = any;
|
|
3
|
+
interface ListBankArgs {
|
|
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
17
|
interface GetBankByIdArgs {
|
|
6
|
-
|
|
7
|
-
|
|
18
|
+
include?: {
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
};
|
|
21
|
+
prisma: PrismaClient;
|
|
22
|
+
queryWhere: {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
};
|
|
8
25
|
}
|
|
9
26
|
interface PostBankArgs {
|
|
10
27
|
accountNumber: string;
|
|
11
28
|
accountTitle: string;
|
|
12
|
-
bankAddress
|
|
29
|
+
bankAddress?: string;
|
|
13
30
|
bankName: string;
|
|
14
|
-
createdAt: string;
|
|
15
31
|
enabled: boolean;
|
|
16
|
-
iban
|
|
17
|
-
id
|
|
32
|
+
iban?: string;
|
|
33
|
+
id?: string;
|
|
34
|
+
include?: {
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
};
|
|
37
|
+
isDefault?: boolean;
|
|
18
38
|
preferenceId: string;
|
|
19
|
-
prisma:
|
|
20
|
-
|
|
39
|
+
prisma: PrismaClient;
|
|
40
|
+
queryWhere?: {
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
};
|
|
43
|
+
swiftCode?: string;
|
|
21
44
|
}
|
|
22
45
|
interface DeleteBankArgs {
|
|
23
|
-
|
|
24
|
-
|
|
46
|
+
include?: {
|
|
47
|
+
[key: string]: any;
|
|
48
|
+
};
|
|
49
|
+
prisma: PrismaClient;
|
|
50
|
+
queryWhere: {
|
|
51
|
+
[key: string]: any;
|
|
52
|
+
};
|
|
25
53
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Retrieves all banks from the database with pagination
|
|
56
|
+
* @param {ListBankArgs} args - Object containing prisma client, pagination, and filter options
|
|
57
|
+
* @returns {Promise<[number, Array<BankBE>]>} Tuple of [total count, array of banks]
|
|
58
|
+
*/
|
|
59
|
+
export declare const listBank: ({ currentPage, include, orderBy, pageLimit, prisma, queryWhere, }: ListBankArgs) => Promise<[number, Array<BankBE>]>;
|
|
60
|
+
/**
|
|
61
|
+
* Retrieves a single bank by ID
|
|
62
|
+
* @param {GetBankByIdArgs} args - Object containing prisma client and bank id
|
|
63
|
+
* @returns {Promise<BankBE | null>} Bank if found, null otherwise
|
|
64
|
+
*/
|
|
65
|
+
export declare const unitBankById: ({ include, prisma, queryWhere, }: GetBankByIdArgs) => Promise<BankBE | null>;
|
|
66
|
+
/**
|
|
67
|
+
* Creates a new bank or updates an existing one
|
|
68
|
+
* @param {PostBankArgs} args - Object containing prisma client and bank data
|
|
69
|
+
* @returns {Promise<BankBE>} Created or updated bank
|
|
70
|
+
*/
|
|
71
|
+
export declare const updateBank: ({ accountNumber, accountTitle, bankAddress, bankName, enabled, iban, id, include, isDefault, preferenceId, prisma, queryWhere, swiftCode, }: PostBankArgs) => Promise<BankBE>;
|
|
72
|
+
/**
|
|
73
|
+
* Deletes a bank by ID
|
|
74
|
+
* @param {DeleteBankArgs} args - Object containing prisma client and bank id
|
|
75
|
+
* @returns {Promise<BankBE>} Deleted bank
|
|
76
|
+
* @throws {Error} If bank ID is not provided or bank not found
|
|
77
|
+
*/
|
|
78
|
+
export declare const deleteBank: ({ include, prisma, queryWhere, }: DeleteBankArgs) => Promise<BankBE>;
|
|
30
79
|
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,130 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
47
|
}
|
|
38
48
|
};
|
|
39
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.deleteBank = exports.
|
|
41
|
-
|
|
50
|
+
exports.deleteBank = exports.updateBank = exports.unitBankById = exports.listBank = void 0;
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves all banks from the database with pagination
|
|
53
|
+
* @param {ListBankArgs} args - Object containing prisma client, pagination, and filter options
|
|
54
|
+
* @returns {Promise<[number, Array<BankBE>]>} Tuple of [total count, array of banks]
|
|
55
|
+
*/
|
|
56
|
+
var listBank = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
42
57
|
var banks;
|
|
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.bank.count({
|
|
70
|
+
where: queryWhere,
|
|
71
|
+
}),
|
|
72
|
+
prisma.bank.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
|
-
banks =
|
|
81
|
+
banks = _f.sent();
|
|
53
82
|
return [2 /*return*/, banks];
|
|
54
83
|
}
|
|
55
84
|
});
|
|
56
85
|
}); };
|
|
57
|
-
exports.
|
|
58
|
-
|
|
86
|
+
exports.listBank = listBank;
|
|
87
|
+
/**
|
|
88
|
+
* Retrieves a single bank by ID
|
|
89
|
+
* @param {GetBankByIdArgs} args - Object containing prisma client and bank id
|
|
90
|
+
* @returns {Promise<BankBE | null>} Bank if found, null otherwise
|
|
91
|
+
*/
|
|
92
|
+
var unitBankById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
59
93
|
var bank;
|
|
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('Bank ID is required');
|
|
100
|
+
}
|
|
101
|
+
return [4 /*yield*/, prisma.bank.findUnique({
|
|
102
|
+
include: include,
|
|
103
|
+
where: queryWhere,
|
|
104
|
+
})];
|
|
68
105
|
case 1:
|
|
69
|
-
bank =
|
|
106
|
+
bank = _d.sent();
|
|
70
107
|
return [2 /*return*/, bank];
|
|
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.unitBankById = unitBankById;
|
|
112
|
+
/**
|
|
113
|
+
* Creates a new bank or updates an existing one
|
|
114
|
+
* @param {PostBankArgs} args - Object containing prisma client and bank data
|
|
115
|
+
* @returns {Promise<BankBE>} Created or updated bank
|
|
116
|
+
*/
|
|
117
|
+
var updateBank = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
118
|
+
var bankData, bank;
|
|
119
|
+
var accountNumber = _b.accountNumber, accountTitle = _b.accountTitle, bankAddress = _b.bankAddress, bankName = _b.bankName, enabled = _b.enabled, iban = _b.iban, id = _b.id, include = _b.include, _c = _b.isDefault, isDefault = _c === void 0 ? false : _c, preferenceId = _b.preferenceId, prisma = _b.prisma, queryWhere = _b.queryWhere, swiftCode = _b.swiftCode;
|
|
120
|
+
return __generator(this, function (_d) {
|
|
121
|
+
switch (_d.label) {
|
|
122
|
+
case 0:
|
|
123
|
+
if (!accountNumber || !accountTitle || !bankName || !preferenceId) {
|
|
124
|
+
throw new Error('Account number, account title, bank name, and preference ID are required');
|
|
125
|
+
}
|
|
126
|
+
if (!id || !(queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id)) {
|
|
127
|
+
throw new Error('Bank ID is required');
|
|
128
|
+
}
|
|
129
|
+
bankData = {
|
|
130
|
+
accountNumber: accountNumber,
|
|
131
|
+
accountTitle: accountTitle,
|
|
132
|
+
bankAddress: bankAddress || null,
|
|
133
|
+
bankName: bankName,
|
|
134
|
+
enabled: enabled,
|
|
135
|
+
iban: iban || null,
|
|
136
|
+
isDefault: isDefault,
|
|
137
|
+
preferenceId: preferenceId,
|
|
138
|
+
swiftCode: swiftCode || null,
|
|
139
|
+
};
|
|
140
|
+
return [4 /*yield*/, prisma.bank.upsert({
|
|
141
|
+
where: queryWhere,
|
|
142
|
+
update: bankData,
|
|
143
|
+
create: __assign({ id: id }, bankData),
|
|
144
|
+
include: include,
|
|
145
|
+
})];
|
|
105
146
|
case 1:
|
|
106
|
-
bank =
|
|
147
|
+
bank = _d.sent();
|
|
107
148
|
return [2 /*return*/, bank];
|
|
108
149
|
}
|
|
109
150
|
});
|
|
110
151
|
}); };
|
|
111
|
-
exports.
|
|
152
|
+
exports.updateBank = updateBank;
|
|
153
|
+
/**
|
|
154
|
+
* Deletes a bank by ID
|
|
155
|
+
* @param {DeleteBankArgs} args - Object containing prisma client and bank id
|
|
156
|
+
* @returns {Promise<BankBE>} Deleted bank
|
|
157
|
+
* @throws {Error} If bank ID is not provided or bank not found
|
|
158
|
+
*/
|
|
112
159
|
var deleteBank = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
113
160
|
var bank;
|
|
114
|
-
var prisma = _b.prisma,
|
|
115
|
-
return __generator(this, function (
|
|
116
|
-
switch (
|
|
117
|
-
case 0:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
161
|
+
var _c = _b.include, include = _c === void 0 ? {} : _c, prisma = _b.prisma, queryWhere = _b.queryWhere;
|
|
162
|
+
return __generator(this, function (_d) {
|
|
163
|
+
switch (_d.label) {
|
|
164
|
+
case 0:
|
|
165
|
+
if (!(queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id)) {
|
|
166
|
+
throw new Error('Bank ID is required');
|
|
167
|
+
}
|
|
168
|
+
return [4 /*yield*/, prisma.bank.delete({
|
|
169
|
+
include: include,
|
|
170
|
+
where: queryWhere,
|
|
171
|
+
})];
|
|
122
172
|
case 1:
|
|
123
|
-
bank =
|
|
173
|
+
bank = _d.sent();
|
|
124
174
|
return [2 /*return*/, bank];
|
|
125
175
|
}
|
|
126
176
|
});
|