gemcap-be-common 1.4.3 → 1.4.5
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/db/availability.db.d.ts +29 -2
- package/db/availability.db.js +1 -72
- package/db/availability.db.ts +1 -75
- package/models/AccountPayableItem.model.d.ts +3 -3
- package/models/AvailabilitySigns.model.d.ts +13 -0
- package/models/AvailabilitySigns.model.ts +15 -0
- package/models/BBCSheet.model.d.ts +4 -4
- package/models/BBCSheet.model.js +1 -2
- package/models/BBCSheet.model.ts +2 -3
- package/models/BorrowerCompliance.model.d.ts +3 -3
- package/models/BorrowerCompliance.model.js +1 -2
- package/models/BorrowerCompliance.model.ts +1 -2
- package/models/Globals.model.d.ts +4 -4
- package/models/Globals.model.js +1 -2
- package/models/Globals.model.ts +2 -3
- package/models/InventoryItem.model.d.ts +3 -3
- package/models/LoanStatementTransaction.model.d.ts +10 -10
- package/models/LoanStatementTransaction.model.js +1 -2
- package/models/LoanStatementTransaction.model.ts +2 -3
- package/models/LoanTransaction.model.d.ts +1 -1
- package/models/LoanTransaction.model.js +1 -2
- package/models/LoanTransaction.model.ts +2 -3
- package/models/MicroserviceTask.model.d.ts +4 -4
- package/models/MicroserviceTask.model.js +1 -2
- package/models/MicroserviceTask.model.ts +2 -3
- package/models/QueryResult.model.d.ts +1 -1
- package/models/QueryResult.model.js +1 -2
- package/models/QueryResult.model.ts +2 -3
- package/models/ReceivableAvailability.model.d.ts +34 -34
- package/models/ReceivableAvailability.model.js +1 -2
- package/models/ReceivableAvailability.model.ts +2 -3
- package/models/TransactionAttachedFile.Model.d.ts +7 -7
- package/models/TransactionAttachedFile.Model.js +1 -2
- package/models/TransactionAttachedFile.Model.ts +2 -3
- package/models/Underwriter.model.d.ts +1 -1
- package/models/Underwriter.model.js +1 -2
- package/models/Underwriter.model.ts +2 -3
- package/models/UploadedFile.model.d.ts +4 -4
- package/models/UploadedFile.model.js +1 -2
- package/models/UploadedFile.model.ts +2 -3
- package/models/UserLog.model.d.ts +1 -1
- package/models/UserLog.model.js +1 -2
- package/models/UserLog.model.ts +2 -3
- package/package.json +1 -1
- package/services/attached-files.service.js +1 -1
- package/services/attached-files.service.ts +1 -1
- package/services/availability.service.js +3 -4
- package/services/availability.service.ts +3 -4
- package/services/brokers.service.d.ts +2 -2
- package/services/compliance-borrowers.service.d.ts +2 -2
- package/services/compliance-borrowers.service.js +4 -4
- package/services/compliance-borrowers.service.ts +5 -5
- package/services/loan-payments.service.js +4 -4
- package/services/loan-payments.service.ts +4 -4
- package/services/loan-statement.service.d.ts +1 -1
- package/services/loan-transactions.service.d.ts +1 -1
- package/services/loan-transactions.service.js +2 -2
- package/services/loan-transactions.service.ts +2 -2
- package/services/signs.service.d.ts +1 -0
- package/services/signs.service.js +19 -16
- package/services/signs.service.ts +20 -16
- package/services/uploads.service.js +1 -1
- package/services/uploads.service.ts +1 -1
- package/services/users.service.d.ts +7 -7
- package/services/users.service.js +1 -2
- package/services/users.service.ts +7 -8
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -46,9 +46,9 @@ export declare class BrokersService {
|
|
|
46
46
|
getAllProductBrokers(): Promise<(import("mongoose").FlattenMaps<import("../models/ProductBroker.model").IProductBrokerDoc> & {
|
|
47
47
|
_id: import("mongoose").Types.ObjectId;
|
|
48
48
|
})[]>;
|
|
49
|
-
getBorrowerBrokers(borrowerId: string): Promise<
|
|
49
|
+
getBorrowerBrokers(borrowerId: string): Promise<(import("mongoose").FlattenMaps<import("../models/ProductBroker.model").IProductBrokerDoc> & {
|
|
50
50
|
_id: import("mongoose").Types.ObjectId;
|
|
51
|
-
})[]>;
|
|
51
|
+
})[] | BrokerView[]>;
|
|
52
52
|
getProductBrokers(productId: string): Promise<import("../models/ProductBroker.model").IProductBrokerDocWithBroker[]>;
|
|
53
53
|
getTotalShares(borrowerId: string, brokers: IProductBrokerView[], replaceNames?: boolean): Promise<ProductTotal>;
|
|
54
54
|
getTotals(borrowerId: string): Promise<BrokerTotalView[]>;
|
|
@@ -44,8 +44,8 @@ export declare class ComplianceBorrowersService {
|
|
|
44
44
|
tooltip: string;
|
|
45
45
|
};
|
|
46
46
|
};
|
|
47
|
-
getFullComplianceBorrowerById(complianceBorrowerId:
|
|
48
|
-
getAllBorrowersShortened(userAccess: any): Promise<(Pick<IComplianceBorrowerDocument, "
|
|
47
|
+
getFullComplianceBorrowerById(complianceBorrowerId: string): Promise<any>;
|
|
48
|
+
getAllBorrowersShortened(userAccess: any): Promise<(Pick<IComplianceBorrowerDocument, "borrower" | "fundingStatus" | "items"> | {
|
|
49
49
|
items: {
|
|
50
50
|
instances: any[];
|
|
51
51
|
item: import("../models/ComplianceItem.model").IComplianceItemDocument;
|
|
@@ -75,10 +75,10 @@ class ComplianceBorrowersService {
|
|
|
75
75
|
path: 'items',
|
|
76
76
|
populate: { path: 'item', model: 'complianceItems' },
|
|
77
77
|
})
|
|
78
|
-
.populate({
|
|
79
|
-
path: 'items',
|
|
80
|
-
populate: { path: 'instances.files.uploadedBy', model:
|
|
81
|
-
|
|
78
|
+
// .populate({
|
|
79
|
+
// path: 'items',
|
|
80
|
+
// populate: { path: 'instances.files.uploadedBy', model: MODEL_NAMES.users },
|
|
81
|
+
// }) // TODO remove this when we have a better way to handle users
|
|
82
82
|
.transform((borrower) => ({ ...borrower, plaidAccessToken: borrower?.plaidAccessToken ?? false }))
|
|
83
83
|
.lean();
|
|
84
84
|
if (!ourBorrower.borrower) {
|
|
@@ -76,7 +76,7 @@ export class ComplianceBorrowersService {
|
|
|
76
76
|
return { progress, score };
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
async getFullComplianceBorrowerById(complianceBorrowerId): Promise<any> {
|
|
79
|
+
async getFullComplianceBorrowerById(complianceBorrowerId: string): Promise<any> {
|
|
80
80
|
if (!complianceBorrowerId) {
|
|
81
81
|
return null;
|
|
82
82
|
}
|
|
@@ -87,10 +87,10 @@ export class ComplianceBorrowersService {
|
|
|
87
87
|
path: 'items',
|
|
88
88
|
populate: { path: 'item', model: 'complianceItems' },
|
|
89
89
|
})
|
|
90
|
-
.populate({
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
})
|
|
90
|
+
// .populate({
|
|
91
|
+
// path: 'items',
|
|
92
|
+
// populate: { path: 'instances.files.uploadedBy', model: MODEL_NAMES.users },
|
|
93
|
+
// }) // TODO remove this when we have a better way to handle users
|
|
94
94
|
.transform((borrower) => ({ ...borrower, plaidAccessToken: borrower?.plaidAccessToken ?? false }))
|
|
95
95
|
.lean() as IComplianceBorrowerDocumentFull;
|
|
96
96
|
if (!ourBorrower.borrower) {
|
|
@@ -214,7 +214,7 @@ class LoanPaymentsService {
|
|
|
214
214
|
productId: new mongoose_1.default.Types.ObjectId(productId),
|
|
215
215
|
reference: `${borrower.code} - STATEMENT PAID`,
|
|
216
216
|
transactionType: LoanTransaction_model_1.ELoanTransactionTypes.COLLECTION,
|
|
217
|
-
userId
|
|
217
|
+
userId,
|
|
218
218
|
};
|
|
219
219
|
transaction.effectiveDate = await this.loanTransactionsService.calculateEffectiveDate(transaction);
|
|
220
220
|
const newTransaction = await this.loanTransactionsService.createLoanTransaction(transaction);
|
|
@@ -355,7 +355,7 @@ class LoanPaymentsService {
|
|
|
355
355
|
productId: revolverProduct._id,
|
|
356
356
|
reference: `${product.type} STATEMENT ADDED TO LOAN`,
|
|
357
357
|
transactionType: LoanTransaction_model_1.ELoanTransactionTypes.DISBURSEMENT,
|
|
358
|
-
userId
|
|
358
|
+
userId,
|
|
359
359
|
};
|
|
360
360
|
newTransactions.effectiveDate = await this.loanTransactionsService.calculateEffectiveDate(newTransactions);
|
|
361
361
|
await this.loanTransactionsService.createLoanTransaction(newTransactions);
|
|
@@ -373,7 +373,7 @@ class LoanPaymentsService {
|
|
|
373
373
|
productId: revolverProduct._id,
|
|
374
374
|
reference: `OVERPAYMENT OF STATEMENT`,
|
|
375
375
|
transactionType: LoanTransaction_model_1.ELoanTransactionTypes.COLLECTION,
|
|
376
|
-
userId
|
|
376
|
+
userId,
|
|
377
377
|
};
|
|
378
378
|
newTransactions.effectiveDate = await this.loanTransactionsService.calculateEffectiveDate(newTransactions);
|
|
379
379
|
await this.loanTransactionsService.createLoanTransaction(newTransactions);
|
|
@@ -388,7 +388,7 @@ class LoanPaymentsService {
|
|
|
388
388
|
productId: new mongoose_1.default.Types.ObjectId(p.productId),
|
|
389
389
|
reference: `EXTRA PAYMENT REF`,
|
|
390
390
|
transactionType: LoanTransaction_model_1.ELoanTransactionTypes.COLLECTION,
|
|
391
|
-
userId
|
|
391
|
+
userId,
|
|
392
392
|
};
|
|
393
393
|
newTransactions.effectiveDate = await this.loanTransactionsService.calculateEffectiveDate(newTransactions);
|
|
394
394
|
await this.loanTransactionsService.createLoanTransaction(newTransactions);
|
|
@@ -249,7 +249,7 @@ export class LoanPaymentsService {
|
|
|
249
249
|
productId: new mongoose.Types.ObjectId(productId),
|
|
250
250
|
reference: `${borrower.code} - STATEMENT PAID`,
|
|
251
251
|
transactionType: ELoanTransactionTypes.COLLECTION,
|
|
252
|
-
userId
|
|
252
|
+
userId,
|
|
253
253
|
};
|
|
254
254
|
transaction.effectiveDate = await this.loanTransactionsService.calculateEffectiveDate(transaction);
|
|
255
255
|
const newTransaction = await this.loanTransactionsService.createLoanTransaction(transaction);
|
|
@@ -399,7 +399,7 @@ export class LoanPaymentsService {
|
|
|
399
399
|
productId: revolverProduct._id,
|
|
400
400
|
reference: `${product.type} STATEMENT ADDED TO LOAN`,
|
|
401
401
|
transactionType: ELoanTransactionTypes.DISBURSEMENT,
|
|
402
|
-
userId
|
|
402
|
+
userId,
|
|
403
403
|
};
|
|
404
404
|
newTransactions.effectiveDate = await this.loanTransactionsService.calculateEffectiveDate(newTransactions);
|
|
405
405
|
await this.loanTransactionsService.createLoanTransaction(newTransactions);
|
|
@@ -418,7 +418,7 @@ export class LoanPaymentsService {
|
|
|
418
418
|
productId: revolverProduct._id,
|
|
419
419
|
reference: `OVERPAYMENT OF STATEMENT`,
|
|
420
420
|
transactionType: ELoanTransactionTypes.COLLECTION,
|
|
421
|
-
userId
|
|
421
|
+
userId,
|
|
422
422
|
};
|
|
423
423
|
newTransactions.effectiveDate = await this.loanTransactionsService.calculateEffectiveDate(newTransactions);
|
|
424
424
|
await this.loanTransactionsService.createLoanTransaction(newTransactions);
|
|
@@ -434,7 +434,7 @@ export class LoanPaymentsService {
|
|
|
434
434
|
productId: new mongoose.Types.ObjectId(p.productId),
|
|
435
435
|
reference: `EXTRA PAYMENT REF`,
|
|
436
436
|
transactionType: ELoanTransactionTypes.COLLECTION,
|
|
437
|
-
userId
|
|
437
|
+
userId,
|
|
438
438
|
};
|
|
439
439
|
newTransactions.effectiveDate = await this.loanTransactionsService.calculateEffectiveDate(newTransactions);
|
|
440
440
|
await this.loanTransactionsService.createLoanTransaction(newTransactions);
|
|
@@ -155,7 +155,7 @@ export declare class LoanTransactionsService {
|
|
|
155
155
|
getTransactionReport(transactionIds: string[], borrowerId: string, effectiveDate: Date): Promise<{
|
|
156
156
|
transactionIdsToMark: any[];
|
|
157
157
|
transactions: {
|
|
158
|
-
[x: string]: (string | number |
|
|
158
|
+
[x: string]: (string | number | string[] | Date)[];
|
|
159
159
|
}[];
|
|
160
160
|
}>;
|
|
161
161
|
getBorrowerIdsForFile(transactionFileId: string): Promise<{
|
|
@@ -215,7 +215,7 @@ class LoanTransactionsService {
|
|
|
215
215
|
balance: 0,
|
|
216
216
|
floatedBalance: 0,
|
|
217
217
|
effectiveDate: await this.calculateEffectiveDate(item),
|
|
218
|
-
userId
|
|
218
|
+
userId,
|
|
219
219
|
};
|
|
220
220
|
const newLoanTransaction = new LoanTransaction_model_1.LoanTransaction({
|
|
221
221
|
order: item.order,
|
|
@@ -283,7 +283,7 @@ class LoanTransactionsService {
|
|
|
283
283
|
transaction.amount = new decimal_js_1.default(transaction.amount).abs().neg().toNumber();
|
|
284
284
|
break;
|
|
285
285
|
}
|
|
286
|
-
transaction.userId =
|
|
286
|
+
transaction.userId = userId;
|
|
287
287
|
return transaction;
|
|
288
288
|
}
|
|
289
289
|
async createLoanTransaction(transaction) {
|
|
@@ -264,7 +264,7 @@ export class LoanTransactionsService {
|
|
|
264
264
|
balance: 0,
|
|
265
265
|
floatedBalance: 0,
|
|
266
266
|
effectiveDate: await this.calculateEffectiveDate(item),
|
|
267
|
-
userId
|
|
267
|
+
userId,
|
|
268
268
|
};
|
|
269
269
|
const newLoanTransaction = new LoanTransaction({
|
|
270
270
|
order: item.order,
|
|
@@ -337,7 +337,7 @@ export class LoanTransactionsService {
|
|
|
337
337
|
transaction.amount = new Decimal(transaction.amount).abs().neg().toNumber();
|
|
338
338
|
break;
|
|
339
339
|
}
|
|
340
|
-
transaction.userId =
|
|
340
|
+
transaction.userId = userId;
|
|
341
341
|
return transaction;
|
|
342
342
|
}
|
|
343
343
|
|
|
@@ -51,6 +51,7 @@ export declare class SignsService {
|
|
|
51
51
|
users: IUser[];
|
|
52
52
|
fulfillUserList(): Promise<void>;
|
|
53
53
|
clearUserList(): void;
|
|
54
|
+
getAvailabilitiesSigns(bbcDateIds: string[]): Promise<IAvailabilitySignView[]>;
|
|
54
55
|
getAvailabilitySigns(bbcDateId: string): Promise<IAvailabilitySignView>;
|
|
55
56
|
revokeAvailability(bbcDateId: string, userId: string, userIdRevoked: string): Promise<void>;
|
|
56
57
|
signAvailability(bbcDateId: string, user: IUser): Promise<IResult>;
|
|
@@ -39,8 +39,25 @@ class SignsService {
|
|
|
39
39
|
clearUserList() {
|
|
40
40
|
this.users = null;
|
|
41
41
|
}
|
|
42
|
+
async getAvailabilitiesSigns(bbcDateIds) {
|
|
43
|
+
const availabilitySigns = await (0, availability_db_1.getAvailabilitySigns)(bbcDateIds);
|
|
44
|
+
const users = await this.usersService.getUserList();
|
|
45
|
+
const usersMap = users.reduce((acc, user) => {
|
|
46
|
+
return { ...acc, [user.id]: user };
|
|
47
|
+
}, {});
|
|
48
|
+
return availabilitySigns.map((availabilitySign) => {
|
|
49
|
+
return {
|
|
50
|
+
...availabilitySign,
|
|
51
|
+
signs: availabilitySign.signs.map((sign) => ({
|
|
52
|
+
...sign,
|
|
53
|
+
userSigned: usersMap[sign.userSignedId],
|
|
54
|
+
userRevoked: usersMap[sign.userRevokedId],
|
|
55
|
+
}))
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
}
|
|
42
59
|
async getAvailabilitySigns(bbcDateId) {
|
|
43
|
-
const availabilitiesSigns = await
|
|
60
|
+
const availabilitiesSigns = await this.getAvailabilitiesSigns([bbcDateId]);
|
|
44
61
|
if (!availabilitiesSigns.length) {
|
|
45
62
|
return {
|
|
46
63
|
_id: null,
|
|
@@ -50,26 +67,12 @@ class SignsService {
|
|
|
50
67
|
};
|
|
51
68
|
}
|
|
52
69
|
const availabilitySigns = availabilitiesSigns[0];
|
|
53
|
-
let keyCloakUsers = this.users;
|
|
54
|
-
if (!keyCloakUsers) {
|
|
55
|
-
keyCloakUsers = await this.usersService.getUserList();
|
|
56
|
-
}
|
|
57
70
|
availabilitySigns.signs = availabilitySigns.signs.reduce((acc, userSign) => {
|
|
58
71
|
if (!userSign.userSigned) {
|
|
59
72
|
return acc;
|
|
60
73
|
}
|
|
61
|
-
const foundUserSigned = keyCloakUsers.find((user) => user.id === userSign.userSigned.id);
|
|
62
|
-
if (foundUserSigned) {
|
|
63
|
-
userSign.userSigned.firstName = foundUserSigned.firstName;
|
|
64
|
-
userSign.userSigned.lastName = foundUserSigned.lastName;
|
|
65
|
-
}
|
|
66
74
|
userSign.userSigned = (lodash_1.default.pick(userSign.userSigned, ['_id', 'firstName', 'lastName']));
|
|
67
75
|
if (userSign.userRevoked) {
|
|
68
|
-
const foundUserRevoked = keyCloakUsers.find((user) => user.id === userSign.userRevoked.id);
|
|
69
|
-
if (foundUserRevoked) {
|
|
70
|
-
userSign.userRevoked.firstName = foundUserRevoked.firstName;
|
|
71
|
-
userSign.userRevoked.lastName = foundUserRevoked.lastName;
|
|
72
|
-
}
|
|
73
76
|
userSign.userRevoked = (lodash_1.default.pick(userSign.userRevoked, ['_id', 'firstName', 'lastName']));
|
|
74
77
|
}
|
|
75
78
|
return [...acc, lodash_1.default.pick(userSign, ['userSigned', 'signedAt', 'userRevoked', 'revokedAt'])];
|
|
@@ -202,7 +205,7 @@ class SignsService {
|
|
|
202
205
|
},
|
|
203
206
|
...(0, collaterals_db_1.ITEMS_PAGINATION)(paginatorOptions),
|
|
204
207
|
]);
|
|
205
|
-
const availabilitiesSigns = await
|
|
208
|
+
const availabilitiesSigns = await this.getAvailabilitiesSigns(BBCDates.map((bbcDate) => bbcDate._id.toString()));
|
|
206
209
|
await Promise.all(BBCDates.slice().map(async (bbcDate) => {
|
|
207
210
|
const foundAvailabilitySigns = availabilitiesSigns.find((aSigns) => aSigns.bbcDateId.toString() === bbcDate._id.toString());
|
|
208
211
|
if (!foundAvailabilitySigns) {
|
|
@@ -60,8 +60,26 @@ export class SignsService {
|
|
|
60
60
|
this.users = null;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
async getAvailabilitiesSigns(bbcDateIds: string[]): Promise<IAvailabilitySignView[]> {
|
|
64
|
+
const availabilitySigns = await getAvailabilitySigns(bbcDateIds);
|
|
65
|
+
const users = await this.usersService.getUserList();
|
|
66
|
+
const usersMap = users.reduce((acc, user) => {
|
|
67
|
+
return { ...acc, [user.id]: user };
|
|
68
|
+
}, <Record<string, IUser>>{});
|
|
69
|
+
return availabilitySigns.map((availabilitySign) => {
|
|
70
|
+
return {
|
|
71
|
+
...availabilitySign,
|
|
72
|
+
signs: availabilitySign.signs.map((sign) => ({
|
|
73
|
+
...sign,
|
|
74
|
+
userSigned: usersMap[sign.userSignedId],
|
|
75
|
+
userRevoked: usersMap[sign.userRevokedId],
|
|
76
|
+
}))
|
|
77
|
+
}
|
|
78
|
+
}) as unknown as IAvailabilitySignView[];
|
|
79
|
+
}
|
|
80
|
+
|
|
63
81
|
async getAvailabilitySigns(bbcDateId: string): Promise<IAvailabilitySignView> {
|
|
64
|
-
const availabilitiesSigns = await
|
|
82
|
+
const availabilitiesSigns = await this.getAvailabilitiesSigns([bbcDateId]);
|
|
65
83
|
if (!availabilitiesSigns.length) {
|
|
66
84
|
return <IAvailabilitySignView>{
|
|
67
85
|
_id: null,
|
|
@@ -71,26 +89,12 @@ export class SignsService {
|
|
|
71
89
|
};
|
|
72
90
|
}
|
|
73
91
|
const availabilitySigns = availabilitiesSigns[0];
|
|
74
|
-
let keyCloakUsers = this.users;
|
|
75
|
-
if (!keyCloakUsers) {
|
|
76
|
-
keyCloakUsers = await this.usersService.getUserList();
|
|
77
|
-
}
|
|
78
92
|
availabilitySigns.signs = availabilitySigns.signs.reduce((acc, userSign) => {
|
|
79
93
|
if (!userSign.userSigned) {
|
|
80
94
|
return acc;
|
|
81
95
|
}
|
|
82
|
-
const foundUserSigned = keyCloakUsers.find((user) => user.id === userSign.userSigned.id);
|
|
83
|
-
if (foundUserSigned) {
|
|
84
|
-
userSign.userSigned.firstName = foundUserSigned.firstName;
|
|
85
|
-
userSign.userSigned.lastName = foundUserSigned.lastName;
|
|
86
|
-
}
|
|
87
96
|
userSign.userSigned = (_.pick(userSign.userSigned, ['_id', 'firstName', 'lastName'])) as IUser;
|
|
88
97
|
if (userSign.userRevoked) {
|
|
89
|
-
const foundUserRevoked = keyCloakUsers.find((user) => user.id === userSign.userRevoked.id);
|
|
90
|
-
if (foundUserRevoked) {
|
|
91
|
-
userSign.userRevoked.firstName = foundUserRevoked.firstName;
|
|
92
|
-
userSign.userRevoked.lastName = foundUserRevoked.lastName;
|
|
93
|
-
}
|
|
94
98
|
userSign.userRevoked = (_.pick(userSign.userRevoked, ['_id', 'firstName', 'lastName'])) as IUser;
|
|
95
99
|
}
|
|
96
100
|
return [...acc, _.pick(userSign, ['userSigned', 'signedAt', 'userRevoked', 'revokedAt'])];
|
|
@@ -233,7 +237,7 @@ export class SignsService {
|
|
|
233
237
|
...ITEMS_PAGINATION(paginatorOptions),
|
|
234
238
|
]);
|
|
235
239
|
|
|
236
|
-
const availabilitiesSigns = await
|
|
240
|
+
const availabilitiesSigns = await this.getAvailabilitiesSigns(BBCDates.map((bbcDate) => bbcDate._id.toString()));
|
|
237
241
|
await Promise.all(BBCDates.slice().map(async (bbcDate) => {
|
|
238
242
|
const foundAvailabilitySigns = availabilitiesSigns.find((aSigns) => aSigns.bbcDateId.toString() ===bbcDate._id.toString());
|
|
239
243
|
if (!foundAvailabilitySigns) {
|
|
@@ -118,7 +118,7 @@ class UploadsService {
|
|
|
118
118
|
borrowerId: borrowerIdToWrite,
|
|
119
119
|
filename: file.filename,
|
|
120
120
|
originalName: file.originalname,
|
|
121
|
-
userId
|
|
121
|
+
userId,
|
|
122
122
|
type: uploadType,
|
|
123
123
|
};
|
|
124
124
|
return await UploadedFile_model_1.default.create(newFile);
|
|
@@ -139,7 +139,7 @@ export class UploadsService {
|
|
|
139
139
|
borrowerId: borrowerIdToWrite,
|
|
140
140
|
filename: file.filename,
|
|
141
141
|
originalName: file.originalname,
|
|
142
|
-
userId
|
|
142
|
+
userId,
|
|
143
143
|
type: uploadType,
|
|
144
144
|
};
|
|
145
145
|
return await UploadedFile.create(newFile);
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
/// <reference types="mongoose/types/utility" />
|
|
22
22
|
/// <reference types="mongoose/types/validation" />
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose" />
|
|
24
25
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
26
|
import express from 'express';
|
|
26
|
-
import mongoose from 'mongoose';
|
|
27
27
|
import { IRole, IUser } from '../interfaces/auth-user.interface';
|
|
28
28
|
interface IKeycloakConfig {
|
|
29
29
|
keycloakHost: string;
|
|
@@ -36,10 +36,10 @@ export declare class UsersService {
|
|
|
36
36
|
private readonly config;
|
|
37
37
|
constructor(config: IKeycloakConfig);
|
|
38
38
|
getUserAccessByRequest(req: express.Request): Promise<IUser | null>;
|
|
39
|
-
getUserById(userId: string): Promise<IUser
|
|
40
|
-
getUserByUsername(username: string): Promise<IUser
|
|
41
|
-
getUserByToken(req: express.Request): Promise<IUser
|
|
42
|
-
getUserIdByToken(req: express.Request): Promise<string
|
|
39
|
+
getUserById(userId: string): Promise<IUser>;
|
|
40
|
+
getUserByUsername(username: string): Promise<IUser>;
|
|
41
|
+
getUserByToken(req: express.Request): Promise<IUser>;
|
|
42
|
+
getUserIdByToken(req: express.Request): Promise<string>;
|
|
43
43
|
getUserList(): Promise<IUser[]>;
|
|
44
44
|
getAllRoles(): Promise<IRole[]>;
|
|
45
45
|
getUserRoles(userId: string): Promise<string[]>;
|
|
@@ -54,8 +54,8 @@ export declare class UsersService {
|
|
|
54
54
|
}[];
|
|
55
55
|
}>;
|
|
56
56
|
createUserLoginLog(): Promise<void>;
|
|
57
|
-
getUserLogByDate(userId: string, date: Date): Promise<mongoose.FlattenMaps<import("../models/UserLog.model").IUserLog> & Required<{
|
|
58
|
-
_id: mongoose.Types.ObjectId;
|
|
57
|
+
getUserLogByDate(userId: string, date: Date): Promise<import("mongoose").FlattenMaps<import("../models/UserLog.model").IUserLog> & Required<{
|
|
58
|
+
_id: import("mongoose").Types.ObjectId;
|
|
59
59
|
}>>;
|
|
60
60
|
}
|
|
61
61
|
export {};
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.UsersService = void 0;
|
|
7
7
|
const jwt_decode_1 = require("jwt-decode");
|
|
8
8
|
const axios_1 = __importDefault(require("axios"));
|
|
9
|
-
const mongoose_1 = __importDefault(require("mongoose"));
|
|
10
9
|
const BorrowerCompliance_model_1 = require("../models/BorrowerCompliance.model");
|
|
11
10
|
const UserMobileAccess_model_1 = require("../models/UserMobileAccess.model");
|
|
12
11
|
const UserLog_model_1 = require("../models/UserLog.model");
|
|
@@ -129,7 +128,7 @@ class UsersService {
|
|
|
129
128
|
// }
|
|
130
129
|
}
|
|
131
130
|
async getUserLogByDate(userId, date) {
|
|
132
|
-
return UserLog_model_1.UserLog.findOne({ userId
|
|
131
|
+
return UserLog_model_1.UserLog.findOne({ userId, timestamp: date }).lean();
|
|
133
132
|
}
|
|
134
133
|
}
|
|
135
134
|
exports.UsersService = UsersService;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jwtDecode } from 'jwt-decode';
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import axios from 'axios';
|
|
4
|
-
import mongoose from 'mongoose';
|
|
5
4
|
|
|
6
5
|
import { BorrowerCompliance } from '../models/BorrowerCompliance.model';
|
|
7
6
|
import { UserMobileAccess } from '../models/UserMobileAccess.model';
|
|
@@ -36,17 +35,17 @@ export class UsersService {
|
|
|
36
35
|
return user;
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
async getUserById(userId: string)
|
|
40
|
-
const { data } = await axios.get(`${this.config.baseUrl}/users/by-id/${userId}`);
|
|
38
|
+
async getUserById(userId: string) {
|
|
39
|
+
const { data } = await axios.get<IUser>(`${this.config.baseUrl}/users/by-id/${userId}`);
|
|
41
40
|
return data ?? null;
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
async getUserByUsername(username: string)
|
|
45
|
-
const { data } = await axios.get(`${this.config.baseUrl}/users/by-username/${username}`);
|
|
43
|
+
async getUserByUsername(username: string) {
|
|
44
|
+
const { data } = await axios.get<IUser>(`${this.config.baseUrl}/users/by-username/${username}`);
|
|
46
45
|
return data ?? null;
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
async getUserByToken(req: express.Request)
|
|
48
|
+
async getUserByToken(req: express.Request) {
|
|
50
49
|
const authorization = req.get('Authorization');
|
|
51
50
|
if (!authorization) {
|
|
52
51
|
return null;
|
|
@@ -55,7 +54,7 @@ export class UsersService {
|
|
|
55
54
|
return this.getUserById(keycloakUserId);
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
async getUserIdByToken(req: express.Request)
|
|
57
|
+
async getUserIdByToken(req: express.Request) {
|
|
59
58
|
const user = await this.getUserByToken(req);
|
|
60
59
|
if (user) {
|
|
61
60
|
return user.id;
|
|
@@ -149,6 +148,6 @@ export class UsersService {
|
|
|
149
148
|
}
|
|
150
149
|
|
|
151
150
|
async getUserLogByDate(userId: string, date: Date) {
|
|
152
|
-
return UserLog.findOne({ userId
|
|
151
|
+
return UserLog.findOne({ userId, timestamp: date }).lean();
|
|
153
152
|
}
|
|
154
153
|
}
|