@dynamatix/gb-schemas 2.3.271 → 2.3.272
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 +308 -308
- package/dist/applicants/applicant-additional-income.model.d.ts.map +1 -1
- package/dist/applicants/applicant-additional-income.model.js +3 -0
- package/dist/applicants/applicant-commitment-creditCard.model.d.ts.map +1 -1
- package/dist/applicants/applicant-commitment-creditCard.model.js +3 -0
- package/dist/applicants/applicant-commitment-loan.model.d.ts.map +1 -1
- package/dist/applicants/applicant-commitment-loan.model.js +2 -0
- package/dist/applicants/applicant-commitment-mortgage.model.d.ts.map +1 -1
- package/dist/applicants/applicant-commitment-mortgage.model.js +3 -0
- package/dist/applicants/applicant-commitment-residence.model.d.ts.map +1 -1
- package/dist/applicants/applicant-commitment-residence.model.js +2 -0
- package/dist/applicants/applicant-commitment-secureLoan.model.d.ts.map +1 -1
- package/dist/applicants/applicant-commitment-secureLoan.model.js +3 -0
- package/dist/applicants/applicant-commitment-unsecuredLoan.model.d.ts.map +1 -1
- package/dist/applicants/applicant-commitment-unsecuredLoan.model.js +3 -0
- package/dist/applicants/applicant-credit-report.model.js +1 -0
- package/dist/applicants/applicant-employment-income.model.d.ts.map +1 -1
- package/dist/applicants/applicant-employment-income.model.js +3 -0
- package/dist/applicants/applicant-expenditure.model.d.ts.map +1 -1
- package/dist/applicants/applicant-expenditure.model.js +3 -0
- package/dist/applicants/applicant-income-settings.model.d.ts.map +1 -1
- package/dist/applicants/applicant-income-settings.model.js +1 -0
- package/dist/applicants/applicant-income-summary.model.d.ts.map +1 -1
- package/dist/applicants/applicant-income-summary.model.js +2 -0
- package/dist/applicants/applicant-pension-income.model.d.ts.map +1 -1
- package/dist/applicants/applicant-pension-income.model.js +2 -0
- package/dist/applicants/applicant-property-income.model.d.ts.map +1 -1
- package/dist/applicants/applicant-property-income.model.js +1 -0
- package/dist/applicants/applicant-self-employed-income.model.d.ts.map +1 -1
- package/dist/applicants/applicant-self-employed-income.model.js +1 -0
- package/dist/applicants/applicant-self-employment.model.d.ts.map +1 -1
- package/dist/applicants/applicant-self-employment.model.js +2 -0
- package/dist/applicants/applicant-sole-trader-income.model.d.ts.map +1 -1
- package/dist/applicants/applicant-sole-trader-income.model.js +1 -0
- package/dist/applicants/applicant-uk-tax-credits.model.d.ts.map +1 -1
- package/dist/applicants/applicant-uk-tax-credits.model.js +2 -0
- package/dist/applicants/applicant-welcome-call.model.d.ts.map +1 -1
- package/dist/applicants/applicant-welcome-call.model.js +4 -171
- package/dist/applicants/applicant.model.d.ts.map +1 -1
- package/dist/applicants/applicant.model.js +14 -0
- package/dist/applications/application-direct-debit.model.js +2 -0
- package/dist/applications/application-euc.model.d.ts.map +1 -1
- package/dist/applications/application-euc.model.js +2 -0
- package/dist/applications/application-mortgage.model.js +2 -0
- package/dist/applications/application-note.model.d.ts.map +1 -1
- package/dist/applications/application-note.model.js +18 -0
- package/dist/applications/application-product.model.d.ts.map +1 -1
- package/dist/applications/application-product.model.js +3 -0
- package/dist/applications/application.model.d.ts.map +1 -1
- package/dist/applications/application.model.js +11 -0
- package/dist/applications/applications-task.model.d.ts.map +1 -1
- package/dist/applications/applications-task.model.js +3 -0
- package/dist/product-catalogues/product-catalogue.model.d.ts.map +1 -1
- package/dist/product-catalogues/product-catalogue.model.js +1 -0
- package/dist/product-catalogues/product-variant.model.d.ts.map +1 -1
- package/dist/product-catalogues/product-variant.model.js +1 -0
- package/dist/properties/security.model.d.ts.map +1 -1
- package/dist/properties/security.model.js +4 -0
- package/dist/shared/api-log.model.d.ts +6 -0
- package/dist/shared/api-log.model.d.ts.map +1 -1
- package/dist/shared/api-log.model.js +4 -0
- package/dist/shared/apprivo-sync-journey.model.d.ts.map +1 -1
- package/dist/shared/apprivo-sync-journey.model.js +2 -0
- package/dist/shared/audit-log.model.d.ts +180 -0
- package/dist/shared/audit-log.model.d.ts.map +1 -0
- package/dist/shared/audit-log.model.js +43 -0
- package/dist/shared/checklist.model.d.ts.map +1 -1
- package/dist/shared/checklist.model.js +5 -0
- package/dist/shared/document.model.d.ts +180 -0
- package/dist/shared/document.model.d.ts.map +1 -0
- package/dist/shared/document.model.js +40 -0
- package/dist/shared/lookup-group.model.d.ts.map +1 -1
- package/dist/shared/lookup-group.model.js +3 -0
- package/dist/shared/lookup.model.d.ts.map +1 -1
- package/dist/shared/lookup.model.js +6 -0
- package/dist/shared/queue.model.d.ts +180 -0
- package/dist/shared/queue.model.d.ts.map +1 -0
- package/dist/shared/queue.model.js +42 -0
- package/dist/shared/webhook-event.model.d.ts.map +1 -1
- package/dist/shared/webhook-event.model.js +4 -0
- package/dist/users/auth-log.model.d.ts.map +1 -1
- package/dist/users/auth-log.model.js +3 -0
- package/dist/users/permission.model.d.ts.map +1 -1
- package/dist/users/permission.model.js +2 -0
- package/dist/users/role-group.model.d.ts.map +1 -1
- package/dist/users/role-group.model.js +3 -0
- package/dist/users/role.model.d.ts.map +1 -1
- package/dist/users/role.model.js +3 -0
- package/dist/users/user.model.d.ts.map +1 -1
- package/dist/users/user.model.js +10 -0
- package/package.json +86 -86
- package/dist/applicants/applicant-income-source.model.d.ts +0 -26
- package/dist/applicants/applicant-income-source.model.d.ts.map +0 -1
- package/dist/applicants/applicant-income.model.d.ts +0 -160
- package/dist/applicants/applicant-income.model.d.ts.map +0 -1
- package/dist/applicants/applicant-other-income.model.d.ts +0 -85
- package/dist/applicants/applicant-other-income.model.d.ts.map +0 -1
- package/dist/applications/application-document.model.d.ts +0 -158
- package/dist/applications/application-document.model.d.ts.map +0 -1
- package/dist/applications/document.model.d.ts +0 -158
- package/dist/applications/document.model.d.ts.map +0 -1
- package/dist/applications/productfeatures.model.d.ts +0 -368
- package/dist/applications/productfeatures.model.d.ts.map +0 -1
- package/dist/shared/document-type-model.d.ts +0 -48
- package/dist/shared/document-type-model.d.ts.map +0 -1
|
@@ -38,5 +38,8 @@ const applicationsTaskSchema = new mongoose.Schema({
|
|
|
38
38
|
applyAuditMiddleware(applicationsTaskSchema, "ApplicationsTask");
|
|
39
39
|
// Apply workflow plugin to the schema
|
|
40
40
|
applyWorkflowPlugin(applicationsTaskSchema, 'applicationstask');
|
|
41
|
+
// Indexes for query optimization
|
|
42
|
+
applicationsTaskSchema.index({ applicationId: 1, instanceId: 1 }); // Compound index for findByApplicationIdAndInstanceId queries
|
|
43
|
+
applicationsTaskSchema.index({ applicationId: 1, createdOn: -1 }); // Compound index for findAll with sort by createdOn descending
|
|
41
44
|
const ApplicationsTaskModel = mongoose.model("ApplicationsTask", applicationsTaskSchema);
|
|
42
45
|
export default ApplicationsTaskModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-catalogue.model.d.ts","sourceRoot":"","sources":["../../product-catalogues/product-catalogue.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"product-catalogue.model.d.ts","sourceRoot":"","sources":["../../product-catalogues/product-catalogue.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAyBhC,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA6D,CAAC;AACzF,eAAe,qBAAqB,CAAC"}
|
|
@@ -17,5 +17,6 @@ const productCatalogueSchema = new mongoose.Schema({
|
|
|
17
17
|
});
|
|
18
18
|
// Apply workflow plugin to the schema
|
|
19
19
|
applyWorkflowPlugin(productCatalogueSchema, 'productcatalogue');
|
|
20
|
+
productCatalogueSchema.index({ productCatalogueId: 1 });
|
|
20
21
|
const ProductCatalogueModel = mongoose.model('ProductCatalogue', productCatalogueSchema);
|
|
21
22
|
export default ProductCatalogueModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-variant.model.d.ts","sourceRoot":"","sources":["../../product-catalogues/product-variant.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"product-variant.model.d.ts","sourceRoot":"","sources":["../../product-catalogues/product-variant.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAoBhC,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAyD,CAAC;AACnF,eAAe,mBAAmB,CAAC"}
|
|
@@ -9,6 +9,7 @@ const productVariantSchema = new mongoose.Schema({
|
|
|
9
9
|
}, {
|
|
10
10
|
timestamps: true
|
|
11
11
|
});
|
|
12
|
+
productVariantSchema.index({ productCatalogueId: 1, variantid: 1 });
|
|
12
13
|
// Apply workflow plugin to the schema
|
|
13
14
|
applyWorkflowPlugin(productVariantSchema, 'productvariant');
|
|
14
15
|
const ProductVariantModel = mongoose.model('ProductVariant', productVariantSchema);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.model.d.ts","sourceRoot":"","sources":["../../properties/security.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,QAAQ,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"security.model.d.ts","sourceRoot":"","sources":["../../properties/security.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAsKhC,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA6C,CAAC;AACjE,eAAe,aAAa,CAAC"}
|
|
@@ -145,5 +145,9 @@ securitySchema.virtual('lendingType').get(function () {
|
|
|
145
145
|
});
|
|
146
146
|
// Apply workflow plugin to the schema
|
|
147
147
|
applyWorkflowPlugin(securitySchema, 'security');
|
|
148
|
+
// Indexes for query optimization
|
|
149
|
+
securitySchema.index({ applicationId: 1 });
|
|
150
|
+
securitySchema.index({ propertyTypeLid: 1 });
|
|
151
|
+
securitySchema.index({ propertyTenureLid: 1 });
|
|
148
152
|
const SecurityModel = mongoose.model("Security", securitySchema);
|
|
149
153
|
export default SecurityModel;
|
|
@@ -40,6 +40,7 @@ declare const ApiLogModel: mongoose.Model<{
|
|
|
40
40
|
statusCode: number;
|
|
41
41
|
loggedAt: NativeDate;
|
|
42
42
|
stackTrace: string[];
|
|
43
|
+
status?: string | null | undefined;
|
|
43
44
|
errorMessage?: string | null | undefined;
|
|
44
45
|
requestData?: any;
|
|
45
46
|
responseData?: any;
|
|
@@ -52,6 +53,7 @@ declare const ApiLogModel: mongoose.Model<{
|
|
|
52
53
|
statusCode: number;
|
|
53
54
|
loggedAt: NativeDate;
|
|
54
55
|
stackTrace: string[];
|
|
56
|
+
status?: string | null | undefined;
|
|
55
57
|
errorMessage?: string | null | undefined;
|
|
56
58
|
requestData?: any;
|
|
57
59
|
responseData?: any;
|
|
@@ -64,6 +66,7 @@ declare const ApiLogModel: mongoose.Model<{
|
|
|
64
66
|
statusCode: number;
|
|
65
67
|
loggedAt: NativeDate;
|
|
66
68
|
stackTrace: string[];
|
|
69
|
+
status?: string | null | undefined;
|
|
67
70
|
errorMessage?: string | null | undefined;
|
|
68
71
|
requestData?: any;
|
|
69
72
|
responseData?: any;
|
|
@@ -82,6 +85,7 @@ declare const ApiLogModel: mongoose.Model<{
|
|
|
82
85
|
statusCode: number;
|
|
83
86
|
loggedAt: NativeDate;
|
|
84
87
|
stackTrace: string[];
|
|
88
|
+
status?: string | null | undefined;
|
|
85
89
|
errorMessage?: string | null | undefined;
|
|
86
90
|
requestData?: any;
|
|
87
91
|
responseData?: any;
|
|
@@ -94,6 +98,7 @@ declare const ApiLogModel: mongoose.Model<{
|
|
|
94
98
|
statusCode: number;
|
|
95
99
|
loggedAt: NativeDate;
|
|
96
100
|
stackTrace: string[];
|
|
101
|
+
status?: string | null | undefined;
|
|
97
102
|
errorMessage?: string | null | undefined;
|
|
98
103
|
requestData?: any;
|
|
99
104
|
responseData?: any;
|
|
@@ -106,6 +111,7 @@ declare const ApiLogModel: mongoose.Model<{
|
|
|
106
111
|
statusCode: number;
|
|
107
112
|
loggedAt: NativeDate;
|
|
108
113
|
stackTrace: string[];
|
|
114
|
+
status?: string | null | undefined;
|
|
109
115
|
errorMessage?: string | null | undefined;
|
|
110
116
|
requestData?: any;
|
|
111
117
|
responseData?: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-log.model.d.ts","sourceRoot":"","sources":["../../shared/api-log.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"api-log.model.d.ts","sourceRoot":"","sources":["../../shared/api-log.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAyBhC;;;GAGG;AACH,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA0C,CAAC;AAE5D,eAAe,WAAW,CAAC"}
|
|
@@ -7,12 +7,16 @@ const apiLogSchema = new mongoose.Schema({
|
|
|
7
7
|
route: { type: String, required: true },
|
|
8
8
|
createdByUserId: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true, },
|
|
9
9
|
statusCode: { type: Number, required: true },
|
|
10
|
+
status: { type: String }, // For future filtering by status
|
|
10
11
|
errorMessage: { type: String },
|
|
11
12
|
loggedAt: { type: Date, default: Date.now },
|
|
12
13
|
stackTrace: [{ type: String }],
|
|
13
14
|
requestData: { type: mongoose.Schema.Types.Mixed }, // to store request payload
|
|
14
15
|
responseData: { type: mongoose.Schema.Types.Mixed }, // to store response payload
|
|
15
16
|
}, { timestamps: true });
|
|
17
|
+
// Indexes for date and status filtering
|
|
18
|
+
apiLogSchema.index({ createdAt: -1 }); // For date-based queries (newest first)
|
|
19
|
+
apiLogSchema.index({ status: 1, createdAt: -1 }); // Compound index for status + date queries
|
|
16
20
|
/**
|
|
17
21
|
* Mongoose model for API logs.
|
|
18
22
|
* @constant {Model}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apprivo-sync-journey.model.d.ts","sourceRoot":"","sources":["../../shared/apprivo-sync-journey.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"apprivo-sync-journey.model.d.ts","sourceRoot":"","sources":["../../shared/apprivo-sync-journey.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAoBhC,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAiE,CAAC;AAC/F,eAAe,uBAAuB,CAAC"}
|
|
@@ -13,5 +13,7 @@ const ApprivoSyncJourneySchema = new mongoose.Schema({
|
|
|
13
13
|
startTime: { type: Date, default: null },
|
|
14
14
|
endTime: { type: Date, default: null },
|
|
15
15
|
}, { timestamps: true });
|
|
16
|
+
// Add indexes that exist in database but missing from model
|
|
17
|
+
ApprivoSyncJourneySchema.index({ milestoneLid: 1, applicationId: 1 }); // Compound: milestone + application
|
|
16
18
|
const ApprivoSyncJourneyModel = mongoose.model('ApprivoSyncJourney', ApprivoSyncJourneySchema);
|
|
17
19
|
export default ApprivoSyncJourneyModel;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/// <reference path="../value-objects/pound.d.ts" />
|
|
2
|
+
/// <reference path="../value-objects/account-number.d.ts" />
|
|
3
|
+
/// <reference path="../value-objects/sort-code.d.ts" />
|
|
4
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
5
|
+
/// <reference types="mongoose/types/callback" />
|
|
6
|
+
/// <reference types="mongoose/types/collection" />
|
|
7
|
+
/// <reference types="mongoose/types/connection" />
|
|
8
|
+
/// <reference types="mongoose/types/cursor" />
|
|
9
|
+
/// <reference types="mongoose/types/document" />
|
|
10
|
+
/// <reference types="mongoose/types/error" />
|
|
11
|
+
/// <reference types="mongoose/types/expressions" />
|
|
12
|
+
/// <reference types="mongoose/types/helpers" />
|
|
13
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
14
|
+
/// <reference types="mongoose/types/indexes" />
|
|
15
|
+
/// <reference types="mongoose/types/models" />
|
|
16
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
17
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
18
|
+
/// <reference types="mongoose/types/populate" />
|
|
19
|
+
/// <reference types="mongoose/types/query" />
|
|
20
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
21
|
+
/// <reference types="mongoose/types/session" />
|
|
22
|
+
/// <reference types="mongoose/types/types" />
|
|
23
|
+
/// <reference types="mongoose/types/utility" />
|
|
24
|
+
/// <reference types="mongoose/types/validation" />
|
|
25
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
26
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
27
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
28
|
+
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
29
|
+
import mongoose from "mongoose";
|
|
30
|
+
declare const AuditLogModel: mongoose.Model<{
|
|
31
|
+
name: string;
|
|
32
|
+
action: "read" | "create" | "update" | "delete";
|
|
33
|
+
timestamp: NativeDate;
|
|
34
|
+
recordId: mongoose.Types.ObjectId;
|
|
35
|
+
isSystemGenerated: boolean;
|
|
36
|
+
metadata?: any;
|
|
37
|
+
source?: string | null | undefined;
|
|
38
|
+
oldValue?: any;
|
|
39
|
+
newValue?: any;
|
|
40
|
+
fieldName?: string | null | undefined;
|
|
41
|
+
userId?: mongoose.Types.ObjectId | null | undefined;
|
|
42
|
+
ipAddress?: string | null | undefined;
|
|
43
|
+
userAgent?: string | null | undefined;
|
|
44
|
+
sessionId?: string | null | undefined;
|
|
45
|
+
externalData?: {
|
|
46
|
+
apprivoAuditId?: string | null | undefined;
|
|
47
|
+
syncStatus?: "pending" | "synced" | "failed" | null | undefined;
|
|
48
|
+
syncedAt?: NativeDate | null | undefined;
|
|
49
|
+
externalSystemId?: string | null | undefined;
|
|
50
|
+
} | null | undefined;
|
|
51
|
+
severity?: "low" | "medium" | "high" | "critical" | null | undefined;
|
|
52
|
+
}, {}, {}, {}, mongoose.Document<unknown, {}, {
|
|
53
|
+
name: string;
|
|
54
|
+
action: "read" | "create" | "update" | "delete";
|
|
55
|
+
timestamp: NativeDate;
|
|
56
|
+
recordId: mongoose.Types.ObjectId;
|
|
57
|
+
isSystemGenerated: boolean;
|
|
58
|
+
metadata?: any;
|
|
59
|
+
source?: string | null | undefined;
|
|
60
|
+
oldValue?: any;
|
|
61
|
+
newValue?: any;
|
|
62
|
+
fieldName?: string | null | undefined;
|
|
63
|
+
userId?: mongoose.Types.ObjectId | null | undefined;
|
|
64
|
+
ipAddress?: string | null | undefined;
|
|
65
|
+
userAgent?: string | null | undefined;
|
|
66
|
+
sessionId?: string | null | undefined;
|
|
67
|
+
externalData?: {
|
|
68
|
+
apprivoAuditId?: string | null | undefined;
|
|
69
|
+
syncStatus?: "pending" | "synced" | "failed" | null | undefined;
|
|
70
|
+
syncedAt?: NativeDate | null | undefined;
|
|
71
|
+
externalSystemId?: string | null | undefined;
|
|
72
|
+
} | null | undefined;
|
|
73
|
+
severity?: "low" | "medium" | "high" | "critical" | null | undefined;
|
|
74
|
+
}, {}> & {
|
|
75
|
+
name: string;
|
|
76
|
+
action: "read" | "create" | "update" | "delete";
|
|
77
|
+
timestamp: NativeDate;
|
|
78
|
+
recordId: mongoose.Types.ObjectId;
|
|
79
|
+
isSystemGenerated: boolean;
|
|
80
|
+
metadata?: any;
|
|
81
|
+
source?: string | null | undefined;
|
|
82
|
+
oldValue?: any;
|
|
83
|
+
newValue?: any;
|
|
84
|
+
fieldName?: string | null | undefined;
|
|
85
|
+
userId?: mongoose.Types.ObjectId | null | undefined;
|
|
86
|
+
ipAddress?: string | null | undefined;
|
|
87
|
+
userAgent?: string | null | undefined;
|
|
88
|
+
sessionId?: string | null | undefined;
|
|
89
|
+
externalData?: {
|
|
90
|
+
apprivoAuditId?: string | null | undefined;
|
|
91
|
+
syncStatus?: "pending" | "synced" | "failed" | null | undefined;
|
|
92
|
+
syncedAt?: NativeDate | null | undefined;
|
|
93
|
+
externalSystemId?: string | null | undefined;
|
|
94
|
+
} | null | undefined;
|
|
95
|
+
severity?: "low" | "medium" | "high" | "critical" | null | undefined;
|
|
96
|
+
} & {
|
|
97
|
+
_id: mongoose.Types.ObjectId;
|
|
98
|
+
} & {
|
|
99
|
+
__v: number;
|
|
100
|
+
}, mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
101
|
+
timestamps: false;
|
|
102
|
+
toJSON: {
|
|
103
|
+
virtuals: true;
|
|
104
|
+
};
|
|
105
|
+
toObject: {
|
|
106
|
+
virtuals: true;
|
|
107
|
+
};
|
|
108
|
+
}, {
|
|
109
|
+
name: string;
|
|
110
|
+
action: "read" | "create" | "update" | "delete";
|
|
111
|
+
timestamp: NativeDate;
|
|
112
|
+
recordId: mongoose.Types.ObjectId;
|
|
113
|
+
isSystemGenerated: boolean;
|
|
114
|
+
metadata?: any;
|
|
115
|
+
source?: string | null | undefined;
|
|
116
|
+
oldValue?: any;
|
|
117
|
+
newValue?: any;
|
|
118
|
+
fieldName?: string | null | undefined;
|
|
119
|
+
userId?: mongoose.Types.ObjectId | null | undefined;
|
|
120
|
+
ipAddress?: string | null | undefined;
|
|
121
|
+
userAgent?: string | null | undefined;
|
|
122
|
+
sessionId?: string | null | undefined;
|
|
123
|
+
externalData?: {
|
|
124
|
+
apprivoAuditId?: string | null | undefined;
|
|
125
|
+
syncStatus?: "pending" | "synced" | "failed" | null | undefined;
|
|
126
|
+
syncedAt?: NativeDate | null | undefined;
|
|
127
|
+
externalSystemId?: string | null | undefined;
|
|
128
|
+
} | null | undefined;
|
|
129
|
+
severity?: "low" | "medium" | "high" | "critical" | null | undefined;
|
|
130
|
+
}, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
131
|
+
name: string;
|
|
132
|
+
action: "read" | "create" | "update" | "delete";
|
|
133
|
+
timestamp: NativeDate;
|
|
134
|
+
recordId: mongoose.Types.ObjectId;
|
|
135
|
+
isSystemGenerated: boolean;
|
|
136
|
+
metadata?: any;
|
|
137
|
+
source?: string | null | undefined;
|
|
138
|
+
oldValue?: any;
|
|
139
|
+
newValue?: any;
|
|
140
|
+
fieldName?: string | null | undefined;
|
|
141
|
+
userId?: mongoose.Types.ObjectId | null | undefined;
|
|
142
|
+
ipAddress?: string | null | undefined;
|
|
143
|
+
userAgent?: string | null | undefined;
|
|
144
|
+
sessionId?: string | null | undefined;
|
|
145
|
+
externalData?: {
|
|
146
|
+
apprivoAuditId?: string | null | undefined;
|
|
147
|
+
syncStatus?: "pending" | "synced" | "failed" | null | undefined;
|
|
148
|
+
syncedAt?: NativeDate | null | undefined;
|
|
149
|
+
externalSystemId?: string | null | undefined;
|
|
150
|
+
} | null | undefined;
|
|
151
|
+
severity?: "low" | "medium" | "high" | "critical" | null | undefined;
|
|
152
|
+
}>, {}> & mongoose.FlatRecord<{
|
|
153
|
+
name: string;
|
|
154
|
+
action: "read" | "create" | "update" | "delete";
|
|
155
|
+
timestamp: NativeDate;
|
|
156
|
+
recordId: mongoose.Types.ObjectId;
|
|
157
|
+
isSystemGenerated: boolean;
|
|
158
|
+
metadata?: any;
|
|
159
|
+
source?: string | null | undefined;
|
|
160
|
+
oldValue?: any;
|
|
161
|
+
newValue?: any;
|
|
162
|
+
fieldName?: string | null | undefined;
|
|
163
|
+
userId?: mongoose.Types.ObjectId | null | undefined;
|
|
164
|
+
ipAddress?: string | null | undefined;
|
|
165
|
+
userAgent?: string | null | undefined;
|
|
166
|
+
sessionId?: string | null | undefined;
|
|
167
|
+
externalData?: {
|
|
168
|
+
apprivoAuditId?: string | null | undefined;
|
|
169
|
+
syncStatus?: "pending" | "synced" | "failed" | null | undefined;
|
|
170
|
+
syncedAt?: NativeDate | null | undefined;
|
|
171
|
+
externalSystemId?: string | null | undefined;
|
|
172
|
+
} | null | undefined;
|
|
173
|
+
severity?: "low" | "medium" | "high" | "critical" | null | undefined;
|
|
174
|
+
}> & {
|
|
175
|
+
_id: mongoose.Types.ObjectId;
|
|
176
|
+
} & {
|
|
177
|
+
__v: number;
|
|
178
|
+
}>>;
|
|
179
|
+
export default AuditLogModel;
|
|
180
|
+
//# sourceMappingURL=audit-log.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-log.model.d.ts","sourceRoot":"","sources":["../../shared/audit-log.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AA6ChC,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA6C,CAAC;AACjE,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
const auditLogSchema = new mongoose.Schema({
|
|
3
|
+
name: { type: String, required: true }, // Collection/model name
|
|
4
|
+
recordId: { type: mongoose.Schema.Types.ObjectId, required: true }, // ID of the record being audited
|
|
5
|
+
action: { type: String, required: true, enum: ['create', 'update', 'delete', 'read'] },
|
|
6
|
+
userId: { type: mongoose.Schema.Types.ObjectId, ref: "User", required: false }, // User who performed the action
|
|
7
|
+
timestamp: { type: Date, default: Date.now, required: true },
|
|
8
|
+
oldValue: { type: mongoose.Schema.Types.Mixed, required: false }, // Previous value
|
|
9
|
+
newValue: { type: mongoose.Schema.Types.Mixed, required: false }, // New value
|
|
10
|
+
fieldName: { type: String, required: false }, // Specific field that changed
|
|
11
|
+
ipAddress: { type: String, required: false },
|
|
12
|
+
userAgent: { type: String, required: false },
|
|
13
|
+
sessionId: { type: String, required: false },
|
|
14
|
+
source: { type: String, required: false, default: 'application' }, // Source of the change
|
|
15
|
+
metadata: { type: mongoose.Schema.Types.Mixed, required: false },
|
|
16
|
+
externalData: {
|
|
17
|
+
apprivoAuditId: { type: String, required: false }, // External system audit ID
|
|
18
|
+
syncStatus: { type: String, required: false, enum: ['pending', 'synced', 'failed'] },
|
|
19
|
+
syncedAt: { type: Date, required: false },
|
|
20
|
+
externalSystemId: { type: String, required: false }
|
|
21
|
+
},
|
|
22
|
+
isSystemGenerated: { type: Boolean, default: false },
|
|
23
|
+
severity: { type: String, required: false, enum: ['low', 'medium', 'high', 'critical'], default: 'low' }
|
|
24
|
+
}, {
|
|
25
|
+
timestamps: false, // We use our own timestamp field
|
|
26
|
+
toJSON: { virtuals: true },
|
|
27
|
+
toObject: { virtuals: true }
|
|
28
|
+
});
|
|
29
|
+
// Virtual for formatted timestamp
|
|
30
|
+
auditLogSchema.virtual('formattedTimestamp').get(function () {
|
|
31
|
+
return this.timestamp ? this.timestamp.toISOString() : null;
|
|
32
|
+
});
|
|
33
|
+
// Add indexes to match database
|
|
34
|
+
auditLogSchema.index({ 'externalData.apprivoAuditId': 1 }); // External audit ID lookup
|
|
35
|
+
auditLogSchema.index({ name: 1, newValue: 1, recordId: 1, timestamp: -1 }); // Complex compound index
|
|
36
|
+
auditLogSchema.index({ name: 1, recordId: 1 }); // Filter by collection and record
|
|
37
|
+
auditLogSchema.index({ recordId: 1, timestamp: -1, _id: -1 }); // Record history with fallback sort
|
|
38
|
+
auditLogSchema.index({ timestamp: -1 }); // Sort by recent changes
|
|
39
|
+
auditLogSchema.index({ userId: 1, timestamp: -1 }); // User activity history
|
|
40
|
+
auditLogSchema.index({ action: 1, timestamp: -1 }); // Filter by action type
|
|
41
|
+
auditLogSchema.index({ name: 1, action: 1, timestamp: -1 }); // Collection-specific action history
|
|
42
|
+
const AuditLogModel = mongoose.model("AuditLog", auditLogSchema);
|
|
43
|
+
export default AuditLogModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checklist.model.d.ts","sourceRoot":"","sources":["../../shared/checklist.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"checklist.model.d.ts","sourceRoot":"","sources":["../../shared/checklist.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAuChC,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA+C,CAAC;AAEpE,eAAe,cAAc,CAAC"}
|
|
@@ -26,5 +26,10 @@ const checklistSchema = new mongoose.Schema({
|
|
|
26
26
|
}
|
|
27
27
|
}, { timestamps: true });
|
|
28
28
|
checklistSchema.index({ checkDescription: 'text', source: 'text' });
|
|
29
|
+
// Add recommended indexes for query optimization
|
|
30
|
+
checklistSchema.index({ applicationId: 1 }); // Filter by application
|
|
31
|
+
checklistSchema.index({ checkTypeLid: 1 }); // Filter by check type
|
|
32
|
+
checklistSchema.index({ checkStatusLid: 1 }); // Filter by check status
|
|
33
|
+
checklistSchema.index({ sourceId: 1 }); // Filter by source (applicant/property/application)
|
|
29
34
|
const CheckListModel = mongoose.model("CheckList", checklistSchema);
|
|
30
35
|
export default CheckListModel;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/// <reference path="../value-objects/pound.d.ts" />
|
|
2
|
+
/// <reference path="../value-objects/account-number.d.ts" />
|
|
3
|
+
/// <reference path="../value-objects/sort-code.d.ts" />
|
|
4
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
5
|
+
/// <reference types="mongoose/types/callback" />
|
|
6
|
+
/// <reference types="mongoose/types/collection" />
|
|
7
|
+
/// <reference types="mongoose/types/connection" />
|
|
8
|
+
/// <reference types="mongoose/types/cursor" />
|
|
9
|
+
/// <reference types="mongoose/types/document" />
|
|
10
|
+
/// <reference types="mongoose/types/error" />
|
|
11
|
+
/// <reference types="mongoose/types/expressions" />
|
|
12
|
+
/// <reference types="mongoose/types/helpers" />
|
|
13
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
14
|
+
/// <reference types="mongoose/types/indexes" />
|
|
15
|
+
/// <reference types="mongoose/types/models" />
|
|
16
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
17
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
18
|
+
/// <reference types="mongoose/types/populate" />
|
|
19
|
+
/// <reference types="mongoose/types/query" />
|
|
20
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
21
|
+
/// <reference types="mongoose/types/session" />
|
|
22
|
+
/// <reference types="mongoose/types/types" />
|
|
23
|
+
/// <reference types="mongoose/types/utility" />
|
|
24
|
+
/// <reference types="mongoose/types/validation" />
|
|
25
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
26
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
27
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
28
|
+
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
29
|
+
import mongoose from "mongoose";
|
|
30
|
+
declare const DocumentModel: mongoose.Model<{
|
|
31
|
+
createdAt: NativeDate;
|
|
32
|
+
updatedAt: NativeDate;
|
|
33
|
+
} & {
|
|
34
|
+
isActive: boolean;
|
|
35
|
+
applicationId: mongoose.Types.ObjectId;
|
|
36
|
+
status: "pending" | "uploaded" | "verified" | "rejected" | "archived";
|
|
37
|
+
category: string;
|
|
38
|
+
fileName: string;
|
|
39
|
+
originalName: string;
|
|
40
|
+
mimeType: string;
|
|
41
|
+
fileSize: number;
|
|
42
|
+
filePath: string;
|
|
43
|
+
uploadedBy: mongoose.Types.ObjectId;
|
|
44
|
+
tags: string[];
|
|
45
|
+
metadata?: any;
|
|
46
|
+
contextId?: mongoose.Types.ObjectId | null | undefined;
|
|
47
|
+
rejectionReason?: string | null | undefined;
|
|
48
|
+
subCategory?: string | null | undefined;
|
|
49
|
+
verifiedBy?: mongoose.Types.ObjectId | null | undefined;
|
|
50
|
+
verifiedAt?: NativeDate | null | undefined;
|
|
51
|
+
expiresAt?: NativeDate | null | undefined;
|
|
52
|
+
}, {}, {}, {}, mongoose.Document<unknown, {}, {
|
|
53
|
+
createdAt: NativeDate;
|
|
54
|
+
updatedAt: NativeDate;
|
|
55
|
+
} & {
|
|
56
|
+
isActive: boolean;
|
|
57
|
+
applicationId: mongoose.Types.ObjectId;
|
|
58
|
+
status: "pending" | "uploaded" | "verified" | "rejected" | "archived";
|
|
59
|
+
category: string;
|
|
60
|
+
fileName: string;
|
|
61
|
+
originalName: string;
|
|
62
|
+
mimeType: string;
|
|
63
|
+
fileSize: number;
|
|
64
|
+
filePath: string;
|
|
65
|
+
uploadedBy: mongoose.Types.ObjectId;
|
|
66
|
+
tags: string[];
|
|
67
|
+
metadata?: any;
|
|
68
|
+
contextId?: mongoose.Types.ObjectId | null | undefined;
|
|
69
|
+
rejectionReason?: string | null | undefined;
|
|
70
|
+
subCategory?: string | null | undefined;
|
|
71
|
+
verifiedBy?: mongoose.Types.ObjectId | null | undefined;
|
|
72
|
+
verifiedAt?: NativeDate | null | undefined;
|
|
73
|
+
expiresAt?: NativeDate | null | undefined;
|
|
74
|
+
}, {}> & {
|
|
75
|
+
createdAt: NativeDate;
|
|
76
|
+
updatedAt: NativeDate;
|
|
77
|
+
} & {
|
|
78
|
+
isActive: boolean;
|
|
79
|
+
applicationId: mongoose.Types.ObjectId;
|
|
80
|
+
status: "pending" | "uploaded" | "verified" | "rejected" | "archived";
|
|
81
|
+
category: string;
|
|
82
|
+
fileName: string;
|
|
83
|
+
originalName: string;
|
|
84
|
+
mimeType: string;
|
|
85
|
+
fileSize: number;
|
|
86
|
+
filePath: string;
|
|
87
|
+
uploadedBy: mongoose.Types.ObjectId;
|
|
88
|
+
tags: string[];
|
|
89
|
+
metadata?: any;
|
|
90
|
+
contextId?: mongoose.Types.ObjectId | null | undefined;
|
|
91
|
+
rejectionReason?: string | null | undefined;
|
|
92
|
+
subCategory?: string | null | undefined;
|
|
93
|
+
verifiedBy?: mongoose.Types.ObjectId | null | undefined;
|
|
94
|
+
verifiedAt?: NativeDate | null | undefined;
|
|
95
|
+
expiresAt?: NativeDate | null | undefined;
|
|
96
|
+
} & {
|
|
97
|
+
_id: mongoose.Types.ObjectId;
|
|
98
|
+
} & {
|
|
99
|
+
__v: number;
|
|
100
|
+
}, mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
101
|
+
timestamps: true;
|
|
102
|
+
toJSON: {
|
|
103
|
+
virtuals: true;
|
|
104
|
+
};
|
|
105
|
+
toObject: {
|
|
106
|
+
virtuals: true;
|
|
107
|
+
};
|
|
108
|
+
}, {
|
|
109
|
+
createdAt: NativeDate;
|
|
110
|
+
updatedAt: NativeDate;
|
|
111
|
+
} & {
|
|
112
|
+
isActive: boolean;
|
|
113
|
+
applicationId: mongoose.Types.ObjectId;
|
|
114
|
+
status: "pending" | "uploaded" | "verified" | "rejected" | "archived";
|
|
115
|
+
category: string;
|
|
116
|
+
fileName: string;
|
|
117
|
+
originalName: string;
|
|
118
|
+
mimeType: string;
|
|
119
|
+
fileSize: number;
|
|
120
|
+
filePath: string;
|
|
121
|
+
uploadedBy: mongoose.Types.ObjectId;
|
|
122
|
+
tags: string[];
|
|
123
|
+
metadata?: any;
|
|
124
|
+
contextId?: mongoose.Types.ObjectId | null | undefined;
|
|
125
|
+
rejectionReason?: string | null | undefined;
|
|
126
|
+
subCategory?: string | null | undefined;
|
|
127
|
+
verifiedBy?: mongoose.Types.ObjectId | null | undefined;
|
|
128
|
+
verifiedAt?: NativeDate | null | undefined;
|
|
129
|
+
expiresAt?: NativeDate | null | undefined;
|
|
130
|
+
}, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
131
|
+
createdAt: NativeDate;
|
|
132
|
+
updatedAt: NativeDate;
|
|
133
|
+
} & {
|
|
134
|
+
isActive: boolean;
|
|
135
|
+
applicationId: mongoose.Types.ObjectId;
|
|
136
|
+
status: "pending" | "uploaded" | "verified" | "rejected" | "archived";
|
|
137
|
+
category: string;
|
|
138
|
+
fileName: string;
|
|
139
|
+
originalName: string;
|
|
140
|
+
mimeType: string;
|
|
141
|
+
fileSize: number;
|
|
142
|
+
filePath: string;
|
|
143
|
+
uploadedBy: mongoose.Types.ObjectId;
|
|
144
|
+
tags: string[];
|
|
145
|
+
metadata?: any;
|
|
146
|
+
contextId?: mongoose.Types.ObjectId | null | undefined;
|
|
147
|
+
rejectionReason?: string | null | undefined;
|
|
148
|
+
subCategory?: string | null | undefined;
|
|
149
|
+
verifiedBy?: mongoose.Types.ObjectId | null | undefined;
|
|
150
|
+
verifiedAt?: NativeDate | null | undefined;
|
|
151
|
+
expiresAt?: NativeDate | null | undefined;
|
|
152
|
+
}>, {}> & mongoose.FlatRecord<{
|
|
153
|
+
createdAt: NativeDate;
|
|
154
|
+
updatedAt: NativeDate;
|
|
155
|
+
} & {
|
|
156
|
+
isActive: boolean;
|
|
157
|
+
applicationId: mongoose.Types.ObjectId;
|
|
158
|
+
status: "pending" | "uploaded" | "verified" | "rejected" | "archived";
|
|
159
|
+
category: string;
|
|
160
|
+
fileName: string;
|
|
161
|
+
originalName: string;
|
|
162
|
+
mimeType: string;
|
|
163
|
+
fileSize: number;
|
|
164
|
+
filePath: string;
|
|
165
|
+
uploadedBy: mongoose.Types.ObjectId;
|
|
166
|
+
tags: string[];
|
|
167
|
+
metadata?: any;
|
|
168
|
+
contextId?: mongoose.Types.ObjectId | null | undefined;
|
|
169
|
+
rejectionReason?: string | null | undefined;
|
|
170
|
+
subCategory?: string | null | undefined;
|
|
171
|
+
verifiedBy?: mongoose.Types.ObjectId | null | undefined;
|
|
172
|
+
verifiedAt?: NativeDate | null | undefined;
|
|
173
|
+
expiresAt?: NativeDate | null | undefined;
|
|
174
|
+
}> & {
|
|
175
|
+
_id: mongoose.Types.ObjectId;
|
|
176
|
+
} & {
|
|
177
|
+
__v: number;
|
|
178
|
+
}>>;
|
|
179
|
+
export default DocumentModel;
|
|
180
|
+
//# sourceMappingURL=document.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.model.d.ts","sourceRoot":"","sources":["../../shared/document.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AA0ChC,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA6C,CAAC;AACjE,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
import { applyAuditMiddleware } from "@dynamatix/cat-shared/middlewares";
|
|
3
|
+
import { applyWorkflowPlugin } from "./workflow.plugin";
|
|
4
|
+
const documentSchema = new mongoose.Schema({
|
|
5
|
+
applicationId: { type: mongoose.Schema.Types.ObjectId, ref: "Application", required: true },
|
|
6
|
+
contextId: { type: mongoose.Schema.Types.ObjectId, required: false },
|
|
7
|
+
status: { type: String, required: true, enum: ['pending', 'uploaded', 'verified', 'rejected', 'archived'] },
|
|
8
|
+
category: { type: String, required: true },
|
|
9
|
+
subCategory: { type: String, required: false },
|
|
10
|
+
fileName: { type: String, required: true },
|
|
11
|
+
originalName: { type: String, required: true },
|
|
12
|
+
mimeType: { type: String, required: true },
|
|
13
|
+
fileSize: { type: Number, required: true },
|
|
14
|
+
filePath: { type: String, required: true },
|
|
15
|
+
uploadedBy: { type: mongoose.Schema.Types.ObjectId, ref: "User", required: true },
|
|
16
|
+
verifiedBy: { type: mongoose.Schema.Types.ObjectId, ref: "User", required: false },
|
|
17
|
+
verifiedAt: { type: Date, required: false },
|
|
18
|
+
rejectionReason: { type: String, required: false },
|
|
19
|
+
metadata: { type: mongoose.Schema.Types.Mixed, required: false },
|
|
20
|
+
tags: [{ type: String }],
|
|
21
|
+
isActive: { type: Boolean, default: true },
|
|
22
|
+
expiresAt: { type: Date, required: false }
|
|
23
|
+
}, {
|
|
24
|
+
timestamps: true,
|
|
25
|
+
toJSON: { virtuals: true },
|
|
26
|
+
toObject: { virtuals: true }
|
|
27
|
+
});
|
|
28
|
+
applyAuditMiddleware(documentSchema, "Document");
|
|
29
|
+
applyWorkflowPlugin(documentSchema, 'document');
|
|
30
|
+
// Add indexes to match database
|
|
31
|
+
documentSchema.index({ applicationId: 1 }); // Filter by application
|
|
32
|
+
documentSchema.index({ contextId: 1 }); // Filter by context
|
|
33
|
+
documentSchema.index({ status: 1 }); // Filter by status
|
|
34
|
+
documentSchema.index({ category: 1 }); // Filter by category
|
|
35
|
+
documentSchema.index({ subCategory: 1 }); // Filter by subcategory
|
|
36
|
+
documentSchema.index({ applicationId: 1, status: 1 }); // Compound: application + status
|
|
37
|
+
documentSchema.index({ contextId: 1, status: 1 }); // Compound: context + status
|
|
38
|
+
documentSchema.index({ category: 1, status: 1 }); // Compound: category + status
|
|
39
|
+
const DocumentModel = mongoose.model("Document", documentSchema);
|
|
40
|
+
export default DocumentModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lookup-group.model.d.ts","sourceRoot":"","sources":["../../shared/lookup-group.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"lookup-group.model.d.ts","sourceRoot":"","sources":["../../shared/lookup-group.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAwBhC,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;GAAmD,CAAC;AAC1E,eAAe,gBAAgB,CAAC"}
|
|
@@ -15,5 +15,8 @@ const lookupGroupSchema = new mongoose.Schema({
|
|
|
15
15
|
});
|
|
16
16
|
// Apply workflow plugin to the schema
|
|
17
17
|
applyWorkflowPlugin(lookupGroupSchema, 'lookupgroup');
|
|
18
|
+
// Database indexes for performance optimization
|
|
19
|
+
// Single field indexes
|
|
20
|
+
lookupGroupSchema.index({ name: 1 }, { unique: true });
|
|
18
21
|
const LookupGroupModel = mongoose.model('LookupGroup', lookupGroupSchema);
|
|
19
22
|
export default LookupGroupModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lookup.model.d.ts","sourceRoot":"","sources":["../../shared/lookup.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"lookup.model.d.ts","sourceRoot":"","sources":["../../shared/lookup.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AA+BhC,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAyC,CAAC;AAC3D,eAAe,WAAW,CAAC"}
|
|
@@ -16,5 +16,11 @@ const lookupSchema = new mongoose.Schema({
|
|
|
16
16
|
type: String
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
+
lookupSchema.index({ lookupGroupId: 1 });
|
|
20
|
+
lookupSchema.index({ value: 1 });
|
|
21
|
+
// Case-insensitive index for name queries
|
|
22
|
+
lookupSchema.index({ name: 1 }, { collation: { locale: "en", strength: 2 } });
|
|
23
|
+
// Compound index for lookupGroupId + name queries
|
|
24
|
+
lookupSchema.index({ lookupGroupId: 1, name: 1 }, { collation: { locale: "en", strength: 2 } });
|
|
19
25
|
const LookupModel = mongoose.model('Lookup', lookupSchema);
|
|
20
26
|
export default LookupModel;
|