@react-pakistan/util-functions 1.24.67 → 1.24.68

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.
Files changed (41) hide show
  1. package/api/stellar-solutions/app-user/index.d.ts +8 -31
  2. package/api/stellar-solutions/app-user/index.js +26 -24
  3. package/api/stellar-solutions/bank/index.d.ts +9 -32
  4. package/api/stellar-solutions/bank/index.js +19 -25
  5. package/api/stellar-solutions/branch/index.d.ts +9 -32
  6. package/api/stellar-solutions/branch/index.js +19 -25
  7. package/api/stellar-solutions/company/index.d.ts +9 -32
  8. package/api/stellar-solutions/company/index.js +29 -27
  9. package/api/stellar-solutions/company-report/index.d.ts +5 -12
  10. package/api/stellar-solutions/company-report/index.js +23 -16
  11. package/api/stellar-solutions/contact/index.d.ts +8 -31
  12. package/api/stellar-solutions/contact/index.js +19 -25
  13. package/api/stellar-solutions/currency/index.d.ts +8 -31
  14. package/api/stellar-solutions/currency/index.js +30 -27
  15. package/api/stellar-solutions/customer/index.d.ts +9 -35
  16. package/api/stellar-solutions/customer/index.js +31 -30
  17. package/api/stellar-solutions/expense/index.d.ts +11 -32
  18. package/api/stellar-solutions/expense/index.js +41 -50
  19. package/api/stellar-solutions/expense-category/index.d.ts +13 -34
  20. package/api/stellar-solutions/expense-category/index.js +64 -52
  21. package/api/stellar-solutions/lead/index.d.ts +35 -19
  22. package/api/stellar-solutions/lead/index.js +117 -82
  23. package/api/stellar-solutions/menu-order/index.d.ts +19 -15
  24. package/api/stellar-solutions/menu-order/index.js +43 -33
  25. package/api/stellar-solutions/payment/index.d.ts +30 -47
  26. package/api/stellar-solutions/payment/index.js +64 -65
  27. package/api/stellar-solutions/payment-mode/index.d.ts +6 -13
  28. package/api/stellar-solutions/payment-mode/index.js +28 -46
  29. package/api/stellar-solutions/preference/index.d.ts +11 -9
  30. package/api/stellar-solutions/preference/index.js +30 -37
  31. package/api/stellar-solutions/product-category/index.d.ts +10 -13
  32. package/api/stellar-solutions/product-category/index.js +58 -49
  33. package/api/stellar-solutions/profile/index.d.ts +6 -5
  34. package/api/stellar-solutions/profile/index.js +17 -18
  35. package/api/stellar-solutions/quote-invoice/index.d.ts +41 -31
  36. package/api/stellar-solutions/quote-invoice/index.js +116 -124
  37. package/api/stellar-solutions/quote-invoice-report/index.d.ts +7 -14
  38. package/api/stellar-solutions/quote-invoice-report/index.js +27 -20
  39. package/api/stellar-solutions/tax/index.d.ts +11 -18
  40. package/api/stellar-solutions/tax/index.js +49 -40
  41. package/package.json +1 -1
@@ -2,72 +2,49 @@ import { AppUserBE } from '../type';
2
2
  type PrismaClient = any;
3
3
  interface ListAppUserArgs {
4
4
  currentPage: number;
5
- include?: {
6
- [key: string]: any;
7
- };
8
- orderBy?: {
9
- [key: string]: any;
10
- };
5
+ orderByColumn?: string;
6
+ orderByDirection?: 'asc' | 'desc';
11
7
  pageLimit: number;
12
8
  prisma: PrismaClient;
13
- queryWhere?: {
14
- [key: string]: any;
15
- };
16
9
  }
17
10
  interface UnitAppUserByIdArgs {
18
- include?: {
19
- [key: string]: any;
20
- };
11
+ id: string;
21
12
  prisma: PrismaClient;
22
- queryWhere: {
23
- [key: string]: any;
24
- };
25
13
  }
26
14
  interface UpdateAppUserArgs {
27
15
  email: string;
28
16
  firstName: string;
29
17
  id: string;
30
- include?: {
31
- [key: string]: any;
32
- };
33
18
  lastName: string;
34
19
  prisma: PrismaClient;
35
- queryWhere?: {
36
- [key: string]: any;
37
- };
38
20
  }
39
21
  interface DeleteAppUserArgs {
40
- include?: {
41
- [key: string]: any;
42
- };
22
+ id: string;
43
23
  prisma: PrismaClient;
44
- queryWhere: {
45
- [key: string]: any;
46
- };
47
24
  }
48
25
  /**
49
26
  * Retrieves all app users from the database with pagination
50
27
  * @param {ListAppUserArgs} args - Object containing prisma client, pagination, and query options
51
28
  * @returns {Promise<[number, Array<AppUserBE>]>} Tuple of [total count, array of app users]
52
29
  */
53
- export declare const listAppUser: ({ currentPage, include, orderBy, pageLimit, prisma, queryWhere, }: ListAppUserArgs) => Promise<[number, Array<AppUserBE>]>;
30
+ export declare const listAppUser: ({ currentPage, orderByColumn, orderByDirection, pageLimit, prisma, }: ListAppUserArgs) => Promise<[number, Array<AppUserBE>]>;
54
31
  /**
55
32
  * Retrieves a single app user by ID
56
33
  * @param {UnitAppUserByIdArgs} args - Object containing prisma client and user query
57
34
  * @returns {Promise<AppUserBE | null>} App user if found, null otherwise
58
35
  */
59
- export declare const unitAppUserById: ({ include, prisma, queryWhere, }: UnitAppUserByIdArgs) => Promise<AppUserBE | null>;
36
+ export declare const unitAppUserById: ({ id, prisma, }: UnitAppUserByIdArgs) => Promise<AppUserBE | null>;
60
37
  /**
61
38
  * Creates a new app user or updates an existing one
62
39
  * @param {UpdateAppUserArgs} args - Object containing prisma client and user data
63
40
  * @returns {Promise<AppUserBE>} Created or updated app user
64
41
  */
65
- export declare const updateAppUser: ({ email, firstName, id, include, lastName, prisma, queryWhere, }: UpdateAppUserArgs) => Promise<AppUserBE>;
42
+ export declare const updateAppUser: ({ email, firstName, id, lastName, prisma, }: UpdateAppUserArgs) => Promise<AppUserBE>;
66
43
  /**
67
44
  * Deletes an app user by ID
68
45
  * @param {DeleteAppUserArgs} args - Object containing prisma client and user query
69
46
  * @returns {Promise<AppUserBE>} Deleted app user
70
47
  * @throws {Error} If user ID is not provided or user not found
71
48
  */
72
- export declare const deleteAppUser: ({ include, prisma, queryWhere, }: DeleteAppUserArgs) => Promise<AppUserBE>;
49
+ export declare const deleteAppUser: ({ id, prisma, }: DeleteAppUserArgs) => Promise<AppUserBE>;
73
50
  export {};
@@ -55,7 +55,8 @@ exports.deleteAppUser = exports.updateAppUser = exports.unitAppUserById = export
55
55
  */
56
56
  var listAppUser = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
57
57
  var appUsers;
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;
58
+ 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;
59
60
  return __generator(this, function (_f) {
60
61
  switch (_f.label) {
61
62
  case 0:
@@ -66,15 +67,13 @@ var listAppUser = function (_a) { return __awaiter(void 0, [_a], void 0, functio
66
67
  throw new Error('Valid page limit is required');
67
68
  }
68
69
  return [4 /*yield*/, prisma.$transaction([
69
- prisma.appUser.count({
70
- where: queryWhere,
71
- }),
70
+ prisma.appUser.count(),
72
71
  prisma.appUser.findMany({
73
- include: include,
74
- orderBy: orderBy,
72
+ orderBy: (_c = {},
73
+ _c[orderByColumn] = orderByDirection,
74
+ _c),
75
75
  skip: (currentPage - 1) * pageLimit,
76
76
  take: pageLimit,
77
- where: queryWhere,
78
77
  }),
79
78
  ])];
80
79
  case 1:
@@ -91,19 +90,20 @@ exports.listAppUser = listAppUser;
91
90
  */
92
91
  var unitAppUserById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
93
92
  var appUser;
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) {
93
+ var id = _b.id, prisma = _b.prisma;
94
+ return __generator(this, function (_c) {
95
+ switch (_c.label) {
97
96
  case 0:
98
- if (!(queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id)) {
97
+ if (!id) {
99
98
  throw new Error('User ID is required');
100
99
  }
101
100
  return [4 /*yield*/, prisma.appUser.findUnique({
102
- include: include,
103
- where: queryWhere,
101
+ where: {
102
+ id: id,
103
+ },
104
104
  })];
105
105
  case 1:
106
- appUser = _d.sent();
106
+ appUser = _c.sent();
107
107
  return [2 /*return*/, appUser];
108
108
  }
109
109
  });
@@ -116,7 +116,7 @@ exports.unitAppUserById = unitAppUserById;
116
116
  */
117
117
  var updateAppUser = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
118
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;
119
+ var email = _b.email, firstName = _b.firstName, id = _b.id, lastName = _b.lastName, prisma = _b.prisma;
120
120
  return __generator(this, function (_c) {
121
121
  switch (_c.label) {
122
122
  case 0:
@@ -132,10 +132,11 @@ var updateAppUser = function (_a) { return __awaiter(void 0, [_a], void 0, funct
132
132
  lastName: lastName,
133
133
  };
134
134
  return [4 /*yield*/, prisma.appUser.upsert({
135
- where: queryWhere,
135
+ where: {
136
+ id: id,
137
+ },
136
138
  update: userData,
137
139
  create: __assign({ id: id }, userData),
138
- include: include,
139
140
  })];
140
141
  case 1:
141
142
  appUser = _c.sent();
@@ -152,19 +153,20 @@ exports.updateAppUser = updateAppUser;
152
153
  */
153
154
  var deleteAppUser = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
154
155
  var appUser;
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) {
156
+ var id = _b.id, prisma = _b.prisma;
157
+ return __generator(this, function (_c) {
158
+ switch (_c.label) {
158
159
  case 0:
159
- if (!(queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id)) {
160
+ if (!id) {
160
161
  throw new Error('User ID is required');
161
162
  }
162
163
  return [4 /*yield*/, prisma.appUser.delete({
163
- include: include,
164
- where: queryWhere,
164
+ where: {
165
+ id: id,
166
+ },
165
167
  })];
166
168
  case 1:
167
- appUser = _d.sent();
169
+ appUser = _c.sent();
168
170
  return [2 /*return*/, appUser];
169
171
  }
170
172
  });
@@ -2,26 +2,14 @@ import { BankBE } from '../type';
2
2
  type PrismaClient = any;
3
3
  interface ListBankArgs {
4
4
  currentPage: number;
5
- include?: {
6
- [key: string]: any;
7
- };
8
- orderBy?: {
9
- [key: string]: any;
10
- };
5
+ orderByColumn?: string;
6
+ orderByDirection?: 'asc' | 'desc';
11
7
  pageLimit: number;
12
8
  prisma: PrismaClient;
13
- queryWhere?: {
14
- [key: string]: any;
15
- };
16
9
  }
17
10
  interface GetBankByIdArgs {
18
- include?: {
19
- [key: string]: any;
20
- };
11
+ id: string;
21
12
  prisma: PrismaClient;
22
- queryWhere: {
23
- [key: string]: any;
24
- };
25
13
  }
26
14
  interface PostBankArgs {
27
15
  accountNumber: string;
@@ -30,50 +18,39 @@ interface PostBankArgs {
30
18
  bankName: string;
31
19
  enabled: boolean;
32
20
  iban?: string;
33
- id?: string;
34
- include?: {
35
- [key: string]: any;
36
- };
21
+ id: string;
37
22
  isDefault?: boolean;
38
23
  preferenceId: string;
39
24
  prisma: PrismaClient;
40
- queryWhere?: {
41
- [key: string]: any;
42
- };
43
25
  swiftCode?: string;
44
26
  }
45
27
  interface DeleteBankArgs {
46
- include?: {
47
- [key: string]: any;
48
- };
28
+ id: string;
49
29
  prisma: PrismaClient;
50
- queryWhere: {
51
- [key: string]: any;
52
- };
53
30
  }
54
31
  /**
55
32
  * Retrieves all banks from the database with pagination
56
33
  * @param {ListBankArgs} args - Object containing prisma client, pagination, and filter options
57
34
  * @returns {Promise<[number, Array<BankBE>]>} Tuple of [total count, array of banks]
58
35
  */
59
- export declare const listBank: ({ currentPage, include, orderBy, pageLimit, prisma, queryWhere, }: ListBankArgs) => Promise<[number, Array<BankBE>]>;
36
+ export declare const listBank: ({ currentPage, orderByColumn, orderByDirection, pageLimit, prisma, }: ListBankArgs) => Promise<[number, Array<BankBE>]>;
60
37
  /**
61
38
  * Retrieves a single bank by ID
62
39
  * @param {GetBankByIdArgs} args - Object containing prisma client and bank id
63
40
  * @returns {Promise<BankBE | null>} Bank if found, null otherwise
64
41
  */
65
- export declare const unitBankById: ({ include, prisma, queryWhere, }: GetBankByIdArgs) => Promise<BankBE | null>;
42
+ export declare const unitBankById: ({ prisma, id, }: GetBankByIdArgs) => Promise<BankBE | null>;
66
43
  /**
67
44
  * Creates a new bank or updates an existing one
68
45
  * @param {PostBankArgs} args - Object containing prisma client and bank data
69
46
  * @returns {Promise<BankBE>} Created or updated bank
70
47
  */
71
- export declare const updateBank: ({ accountNumber, accountTitle, bankAddress, bankName, enabled, iban, id, include, isDefault, preferenceId, prisma, queryWhere, swiftCode, }: PostBankArgs) => Promise<BankBE>;
48
+ export declare const updateBank: ({ accountNumber, accountTitle, bankAddress, bankName, enabled, iban, id, isDefault, preferenceId, prisma, swiftCode, }: PostBankArgs) => Promise<BankBE>;
72
49
  /**
73
50
  * Deletes a bank by ID
74
51
  * @param {DeleteBankArgs} args - Object containing prisma client and bank id
75
52
  * @returns {Promise<BankBE>} Deleted bank
76
53
  * @throws {Error} If bank ID is not provided or bank not found
77
54
  */
78
- export declare const deleteBank: ({ include, prisma, queryWhere, }: DeleteBankArgs) => Promise<BankBE>;
55
+ export declare const deleteBank: ({ prisma, id, }: DeleteBankArgs) => Promise<BankBE>;
79
56
  export {};
@@ -55,7 +55,8 @@ exports.deleteBank = exports.updateBank = exports.unitBankById = exports.listBan
55
55
  */
56
56
  var listBank = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
57
57
  var banks;
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;
58
+ 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;
59
60
  return __generator(this, function (_f) {
60
61
  switch (_f.label) {
61
62
  case 0:
@@ -66,15 +67,11 @@ var listBank = function (_a) { return __awaiter(void 0, [_a], void 0, function (
66
67
  throw new Error('Valid page limit is required');
67
68
  }
68
69
  return [4 /*yield*/, prisma.$transaction([
69
- prisma.bank.count({
70
- where: queryWhere,
71
- }),
70
+ prisma.bank.count(),
72
71
  prisma.bank.findMany({
73
- include: include,
74
- orderBy: orderBy,
72
+ orderBy: (_c = {}, _c[orderByColumn] = orderByDirection, _c),
75
73
  skip: (currentPage - 1) * pageLimit,
76
74
  take: pageLimit,
77
- where: queryWhere,
78
75
  }),
79
76
  ])];
80
77
  case 1:
@@ -91,19 +88,18 @@ exports.listBank = listBank;
91
88
  */
92
89
  var unitBankById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
93
90
  var bank;
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) {
91
+ var prisma = _b.prisma, id = _b.id;
92
+ return __generator(this, function (_c) {
93
+ switch (_c.label) {
97
94
  case 0:
98
- if (!(queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id)) {
95
+ if (!id) {
99
96
  throw new Error('Bank ID is required');
100
97
  }
101
98
  return [4 /*yield*/, prisma.bank.findUnique({
102
- include: include,
103
- where: queryWhere,
99
+ where: { id: id },
104
100
  })];
105
101
  case 1:
106
- bank = _d.sent();
102
+ bank = _c.sent();
107
103
  return [2 /*return*/, bank];
108
104
  }
109
105
  });
@@ -116,14 +112,14 @@ exports.unitBankById = unitBankById;
116
112
  */
117
113
  var updateBank = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
118
114
  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;
115
+ var accountNumber = _b.accountNumber, accountTitle = _b.accountTitle, bankAddress = _b.bankAddress, bankName = _b.bankName, enabled = _b.enabled, iban = _b.iban, id = _b.id, _c = _b.isDefault, isDefault = _c === void 0 ? false : _c, preferenceId = _b.preferenceId, prisma = _b.prisma, swiftCode = _b.swiftCode;
120
116
  return __generator(this, function (_d) {
121
117
  switch (_d.label) {
122
118
  case 0:
123
119
  if (!accountNumber || !accountTitle || !bankName || !preferenceId) {
124
120
  throw new Error('Account number, account title, bank name, and preference ID are required');
125
121
  }
126
- if (!id || !(queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id)) {
122
+ if (!id) {
127
123
  throw new Error('Bank ID is required');
128
124
  }
129
125
  bankData = {
@@ -138,10 +134,9 @@ var updateBank = function (_a) { return __awaiter(void 0, [_a], void 0, function
138
134
  swiftCode: swiftCode || null,
139
135
  };
140
136
  return [4 /*yield*/, prisma.bank.upsert({
141
- where: queryWhere,
137
+ where: { id: id },
142
138
  update: bankData,
143
139
  create: __assign({ id: id }, bankData),
144
- include: include,
145
140
  })];
146
141
  case 1:
147
142
  bank = _d.sent();
@@ -158,19 +153,18 @@ exports.updateBank = updateBank;
158
153
  */
159
154
  var deleteBank = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
160
155
  var bank;
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) {
156
+ var prisma = _b.prisma, id = _b.id;
157
+ return __generator(this, function (_c) {
158
+ switch (_c.label) {
164
159
  case 0:
165
- if (!(queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id)) {
160
+ if (!id) {
166
161
  throw new Error('Bank ID is required');
167
162
  }
168
163
  return [4 /*yield*/, prisma.bank.delete({
169
- include: include,
170
- where: queryWhere,
164
+ where: { id: id },
171
165
  })];
172
166
  case 1:
173
- bank = _d.sent();
167
+ bank = _c.sent();
174
168
  return [2 /*return*/, bank];
175
169
  }
176
170
  });
@@ -2,77 +2,54 @@ import { BranchBE } from '../type';
2
2
  type PrismaClient = any;
3
3
  interface ListBranchArgs {
4
4
  currentPage: number;
5
- include?: {
6
- [key: string]: any;
7
- };
8
- orderBy?: {
9
- [key: string]: any;
10
- };
5
+ orderByColumn?: string;
6
+ orderByDirection?: 'asc' | 'desc';
11
7
  pageLimit: number;
12
8
  prisma: PrismaClient;
13
- queryWhere?: {
14
- [key: string]: any;
15
- };
16
9
  }
17
10
  interface UnitBranchByIdArgs {
18
- include?: {
19
- [key: string]: any;
20
- };
11
+ id: string;
21
12
  prisma: PrismaClient;
22
- queryWhere: {
23
- [key: string]: any;
24
- };
25
13
  }
26
14
  interface UpdateBranchArgs {
27
15
  branchAddress: string;
28
16
  branchName: string;
29
17
  enabled: boolean;
30
- id?: string;
31
- include?: {
32
- [key: string]: any;
33
- };
18
+ id: string;
34
19
  isDefault?: boolean;
35
20
  personEmail: string;
36
21
  personName: string;
37
22
  personPhone: string;
38
23
  preferenceId: string;
39
24
  prisma: PrismaClient;
40
- queryWhere?: {
41
- [key: string]: any;
42
- };
43
25
  }
44
26
  interface DeleteBranchArgs {
45
- include?: {
46
- [key: string]: any;
47
- };
27
+ id: string;
48
28
  prisma: PrismaClient;
49
- queryWhere: {
50
- [key: string]: any;
51
- };
52
29
  }
53
30
  /**
54
31
  * Retrieves all branches from the database with pagination
55
32
  * @param {ListBranchArgs} args - Object containing prisma client, pagination, and filter options
56
33
  * @returns {Promise<[number, Array<BranchBE>]>} Tuple of [total count, array of branches]
57
34
  */
58
- export declare const listBranch: ({ currentPage, include, orderBy, pageLimit, prisma, queryWhere, }: ListBranchArgs) => Promise<[number, Array<BranchBE>]>;
35
+ export declare const listBranch: ({ currentPage, orderByColumn, orderByDirection, pageLimit, prisma, }: ListBranchArgs) => Promise<[number, Array<BranchBE>]>;
59
36
  /**
60
37
  * Retrieves a single branch by ID
61
38
  * @param {UnitBranchByIdArgs} args - Object containing prisma client and branch id
62
39
  * @returns {Promise<BranchBE | null>} Branch if found, null otherwise
63
40
  */
64
- export declare const unitBranchById: ({ include, prisma, queryWhere, }: UnitBranchByIdArgs) => Promise<BranchBE | null>;
41
+ export declare const unitBranchById: ({ prisma, id, }: UnitBranchByIdArgs) => Promise<BranchBE | null>;
65
42
  /**
66
43
  * Creates a new branch or updates an existing one
67
44
  * @param {UpdateBranchArgs} args - Object containing prisma client and branch data
68
45
  * @returns {Promise<BranchBE>} Created or updated branch
69
46
  */
70
- export declare const updateBranch: ({ branchAddress, branchName, enabled, id, include, isDefault, personEmail, personName, personPhone, preferenceId, prisma, queryWhere, }: UpdateBranchArgs) => Promise<BranchBE>;
47
+ export declare const updateBranch: ({ branchAddress, branchName, enabled, id, isDefault, personEmail, personName, personPhone, preferenceId, prisma, }: UpdateBranchArgs) => Promise<BranchBE>;
71
48
  /**
72
49
  * Deletes a branch by ID
73
50
  * @param {DeleteBranchArgs} args - Object containing prisma client and branch id
74
51
  * @returns {Promise<BranchBE>} Deleted branch
75
52
  * @throws {Error} If branch ID is not provided or branch not found
76
53
  */
77
- export declare const deleteBranch: ({ include, prisma, queryWhere, }: DeleteBranchArgs) => Promise<BranchBE>;
54
+ export declare const deleteBranch: ({ prisma, id, }: DeleteBranchArgs) => Promise<BranchBE>;
78
55
  export {};
@@ -55,7 +55,8 @@ exports.deleteBranch = exports.updateBranch = exports.unitBranchById = exports.l
55
55
  */
56
56
  var listBranch = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
57
57
  var branches;
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;
58
+ 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;
59
60
  return __generator(this, function (_f) {
60
61
  switch (_f.label) {
61
62
  case 0:
@@ -66,15 +67,11 @@ var listBranch = function (_a) { return __awaiter(void 0, [_a], void 0, function
66
67
  throw new Error('Valid page limit is required');
67
68
  }
68
69
  return [4 /*yield*/, prisma.$transaction([
69
- prisma.branch.count({
70
- where: queryWhere,
71
- }),
70
+ prisma.branch.count(),
72
71
  prisma.branch.findMany({
73
- include: include,
74
- orderBy: orderBy,
72
+ orderBy: (_c = {}, _c[orderByColumn] = orderByDirection, _c),
75
73
  skip: (currentPage - 1) * pageLimit,
76
74
  take: pageLimit,
77
- where: queryWhere,
78
75
  }),
79
76
  ])];
80
77
  case 1:
@@ -91,19 +88,18 @@ exports.listBranch = listBranch;
91
88
  */
92
89
  var unitBranchById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
93
90
  var branch;
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) {
91
+ var prisma = _b.prisma, id = _b.id;
92
+ return __generator(this, function (_c) {
93
+ switch (_c.label) {
97
94
  case 0:
98
- if (!(queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id)) {
95
+ if (!id) {
99
96
  throw new Error('Branch ID is required');
100
97
  }
101
98
  return [4 /*yield*/, prisma.branch.findUnique({
102
- include: include,
103
- where: queryWhere,
99
+ where: { id: id },
104
100
  })];
105
101
  case 1:
106
- branch = _d.sent();
102
+ branch = _c.sent();
107
103
  return [2 /*return*/, branch];
108
104
  }
109
105
  });
@@ -116,7 +112,7 @@ exports.unitBranchById = unitBranchById;
116
112
  */
117
113
  var updateBranch = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
118
114
  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;
115
+ var branchAddress = _b.branchAddress, branchName = _b.branchName, enabled = _b.enabled, id = _b.id, _c = _b.isDefault, isDefault = _c === void 0 ? false : _c, personEmail = _b.personEmail, personName = _b.personName, personPhone = _b.personPhone, preferenceId = _b.preferenceId, prisma = _b.prisma;
120
116
  return __generator(this, function (_d) {
121
117
  switch (_d.label) {
122
118
  case 0:
@@ -128,7 +124,7 @@ var updateBranch = function (_a) { return __awaiter(void 0, [_a], void 0, functi
128
124
  !preferenceId) {
129
125
  throw new Error('Branch address, branch name, person email, person name, person phone, and preference ID are required');
130
126
  }
131
- if (!id || !(queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id)) {
127
+ if (!id) {
132
128
  throw new Error('Branch ID is required');
133
129
  }
134
130
  branchData = {
@@ -142,10 +138,9 @@ var updateBranch = function (_a) { return __awaiter(void 0, [_a], void 0, functi
142
138
  preferenceId: preferenceId,
143
139
  };
144
140
  return [4 /*yield*/, prisma.branch.upsert({
145
- where: queryWhere,
141
+ where: { id: id },
146
142
  update: branchData,
147
143
  create: __assign({ id: id }, branchData),
148
- include: include,
149
144
  })];
150
145
  case 1:
151
146
  branch = _d.sent();
@@ -162,19 +157,18 @@ exports.updateBranch = updateBranch;
162
157
  */
163
158
  var deleteBranch = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
164
159
  var branch;
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) {
160
+ var prisma = _b.prisma, id = _b.id;
161
+ return __generator(this, function (_c) {
162
+ switch (_c.label) {
168
163
  case 0:
169
- if (!(queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id)) {
164
+ if (!id) {
170
165
  throw new Error('Branch ID is required');
171
166
  }
172
167
  return [4 /*yield*/, prisma.branch.delete({
173
- include: include,
174
- where: queryWhere,
168
+ where: { id: id },
175
169
  })];
176
170
  case 1:
177
- branch = _d.sent();
171
+ branch = _c.sent();
178
172
  return [2 /*return*/, branch];
179
173
  }
180
174
  });
@@ -2,74 +2,51 @@ import { CompanyBE } from '../type';
2
2
  type PrismaClient = any;
3
3
  interface ListCompanyArgs {
4
4
  currentPage: number;
5
- include?: {
6
- [key: string]: any;
7
- };
8
- orderBy?: {
9
- [key: string]: any;
10
- };
5
+ orderByColumn?: string;
6
+ orderByDirection?: 'asc' | 'desc';
11
7
  pageLimit: number;
12
8
  prisma: PrismaClient;
13
- queryWhere?: {
14
- [key: string]: any;
15
- };
16
9
  }
17
10
  interface UnitCompanyByIdArgs {
18
- include?: {
19
- [key: string]: any;
20
- };
11
+ id: string;
21
12
  prisma: PrismaClient;
22
- queryWhere: {
23
- [key: string]: any;
24
- };
25
13
  }
26
14
  interface UpdateCompanyArgs {
27
15
  country: string;
28
16
  email: string;
29
- id?: string;
30
- include?: {
31
- [key: string]: any;
32
- };
17
+ id: string;
33
18
  name: string;
34
19
  phone: string;
35
20
  prisma: PrismaClient;
36
- queryWhere?: {
37
- [key: string]: any;
38
- };
39
21
  website?: string;
40
22
  }
41
23
  interface DeleteCompanyArgs {
42
- include?: {
43
- [key: string]: any;
44
- };
24
+ id: string;
45
25
  prisma: PrismaClient;
46
- queryWhere: {
47
- [key: string]: any;
48
- };
49
26
  }
50
27
  /**
51
28
  * Retrieves all companies from the database with pagination
52
29
  * @param {ListCompanyArgs} args - Object containing prisma client, pagination, and filter options
53
30
  * @returns {Promise<[number, Array<CompanyBE>]>} Tuple of [total count, array of companies]
54
31
  */
55
- export declare const listCompany: ({ currentPage, include, orderBy, pageLimit, prisma, queryWhere, }: ListCompanyArgs) => Promise<[number, Array<CompanyBE>]>;
32
+ export declare const listCompany: ({ currentPage, orderByColumn, orderByDirection, pageLimit, prisma, }: ListCompanyArgs) => Promise<[number, Array<CompanyBE>]>;
56
33
  /**
57
34
  * Retrieves a single company by ID
58
35
  * @param {UnitCompanyByIdArgs} args - Object containing prisma client and company id
59
36
  * @returns {Promise<CompanyBE | null>} Company if found, null otherwise
60
37
  */
61
- export declare const unitCompanyById: ({ include, prisma, queryWhere, }: UnitCompanyByIdArgs) => Promise<CompanyBE | null>;
38
+ export declare const unitCompanyById: ({ id, prisma, }: UnitCompanyByIdArgs) => Promise<CompanyBE | null>;
62
39
  /**
63
40
  * Creates a new company or updates an existing one
64
41
  * @param {UpdateCompanyArgs} args - Object containing prisma client and company data
65
42
  * @returns {Promise<CompanyBE>} Created or updated company
66
43
  */
67
- export declare const updateCompany: ({ country, email, id, include, name, phone, prisma, queryWhere, website, }: UpdateCompanyArgs) => Promise<CompanyBE>;
44
+ export declare const updateCompany: ({ country, email, id, name, phone, prisma, website, }: UpdateCompanyArgs) => Promise<CompanyBE>;
68
45
  /**
69
46
  * Deletes a company by ID
70
47
  * @param {DeleteCompanyArgs} args - Object containing prisma client and company id
71
48
  * @returns {Promise<CompanyBE>} Deleted company
72
49
  * @throws {Error} If company ID is not provided or company not found
73
50
  */
74
- export declare const deleteCompany: ({ include, prisma, queryWhere, }: DeleteCompanyArgs) => Promise<CompanyBE>;
51
+ export declare const deleteCompany: ({ id, prisma, }: DeleteCompanyArgs) => Promise<CompanyBE>;
75
52
  export {};