@dynamatix/gb-schemas 2.3.294 → 2.3.298
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-welcome-call.model.js +9 -9
- package/dist/applications/application-company-model.d.ts +6 -0
- package/dist/applications/application-company-model.d.ts.map +1 -1
- package/dist/applications/application-company-model.js +1 -0
- package/dist/shared/api-performance.model.d.ts +120 -0
- package/dist/shared/api-performance.model.d.ts.map +1 -0
- package/dist/shared/api-performance.model.js +22 -0
- package/dist/shared/api-performance.type.d.ts +177 -0
- package/dist/shared/api-performance.type.d.ts.map +1 -0
- package/dist/shared/api-performance.type.js +1 -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/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/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/package.json +87 -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
|
@@ -433,6 +433,7 @@ declare const ApplicationCompanyModel: mongoose.Model<{
|
|
|
433
433
|
businessTypeLid?: unknown;
|
|
434
434
|
registeredNumber?: unknown;
|
|
435
435
|
isRegisteredNumber?: unknown;
|
|
436
|
+
companyHouseLink?: unknown;
|
|
436
437
|
taxJurisdictionLid?: unknown;
|
|
437
438
|
natureOfBusiness?: unknown;
|
|
438
439
|
addressPostCode?: unknown;
|
|
@@ -864,6 +865,7 @@ declare const ApplicationCompanyModel: mongoose.Model<{
|
|
|
864
865
|
businessTypeLid?: unknown;
|
|
865
866
|
registeredNumber?: unknown;
|
|
866
867
|
isRegisteredNumber?: unknown;
|
|
868
|
+
companyHouseLink?: unknown;
|
|
867
869
|
taxJurisdictionLid?: unknown;
|
|
868
870
|
natureOfBusiness?: unknown;
|
|
869
871
|
addressPostCode?: unknown;
|
|
@@ -1295,6 +1297,7 @@ declare const ApplicationCompanyModel: mongoose.Model<{
|
|
|
1295
1297
|
businessTypeLid?: unknown;
|
|
1296
1298
|
registeredNumber?: unknown;
|
|
1297
1299
|
isRegisteredNumber?: unknown;
|
|
1300
|
+
companyHouseLink?: unknown;
|
|
1298
1301
|
taxJurisdictionLid?: unknown;
|
|
1299
1302
|
natureOfBusiness?: unknown;
|
|
1300
1303
|
addressPostCode?: unknown;
|
|
@@ -1373,6 +1376,7 @@ declare const ApplicationCompanyModel: mongoose.Model<{
|
|
|
1373
1376
|
businessTypeLid?: unknown;
|
|
1374
1377
|
registeredNumber?: unknown;
|
|
1375
1378
|
isRegisteredNumber?: unknown;
|
|
1379
|
+
companyHouseLink?: unknown;
|
|
1376
1380
|
taxJurisdictionLid?: unknown;
|
|
1377
1381
|
natureOfBusiness?: unknown;
|
|
1378
1382
|
addressPostCode?: unknown;
|
|
@@ -1437,6 +1441,7 @@ declare const ApplicationCompanyModel: mongoose.Model<{
|
|
|
1437
1441
|
businessTypeLid?: unknown;
|
|
1438
1442
|
registeredNumber?: unknown;
|
|
1439
1443
|
isRegisteredNumber?: unknown;
|
|
1444
|
+
companyHouseLink?: unknown;
|
|
1440
1445
|
taxJurisdictionLid?: unknown;
|
|
1441
1446
|
natureOfBusiness?: unknown;
|
|
1442
1447
|
addressPostCode?: unknown;
|
|
@@ -1501,6 +1506,7 @@ declare const ApplicationCompanyModel: mongoose.Model<{
|
|
|
1501
1506
|
businessTypeLid?: unknown;
|
|
1502
1507
|
registeredNumber?: unknown;
|
|
1503
1508
|
isRegisteredNumber?: unknown;
|
|
1509
|
+
companyHouseLink?: unknown;
|
|
1504
1510
|
taxJurisdictionLid?: unknown;
|
|
1505
1511
|
natureOfBusiness?: unknown;
|
|
1506
1512
|
addressPostCode?: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application-company-model.d.ts","sourceRoot":"","sources":["../../applications/application-company-model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,KAAK,EAAe,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"application-company-model.d.ts","sourceRoot":"","sources":["../../applications/application-company-model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,KAAK,EAAe,MAAM,0BAA0B,CAAA;AAmJ7D,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAsD,CAAC;AACpF,eAAe,uBAAuB,CAAC"}
|
|
@@ -18,6 +18,7 @@ const companySchema = new mongoose.Schema({
|
|
|
18
18
|
businessTypeLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true }, // form
|
|
19
19
|
registeredNumber: { type: AccountNumber, max: 99999999, default: 0 }, // form
|
|
20
20
|
isRegisteredNumber: { type: Boolean, default: false, }, // form
|
|
21
|
+
companyHouseLink: { type: String, default: '' }, // form
|
|
21
22
|
taxJurisdictionLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true }, // form
|
|
22
23
|
tradingSince: { type: String, default: null }, // form
|
|
23
24
|
natureOfBusiness: { type: String, maxlength: 100, default: '' }, // form
|
|
@@ -0,0 +1,120 @@
|
|
|
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 ApiPerformanceLogModel: mongoose.Model<{
|
|
31
|
+
createdAt: NativeDate;
|
|
32
|
+
updatedAt: NativeDate;
|
|
33
|
+
} & {
|
|
34
|
+
method: "POST" | "GET" | "PUT" | "PATCH" | "DELETE";
|
|
35
|
+
endpoint: string;
|
|
36
|
+
performanceStatus: "Optimal" | "Acceptable" | "Degraded" | "Severe" | "Critical";
|
|
37
|
+
responseTime: number;
|
|
38
|
+
responseSize: number;
|
|
39
|
+
requestSize: number;
|
|
40
|
+
requestedAt: NativeDate;
|
|
41
|
+
averageResponseCount: number;
|
|
42
|
+
label?: string | null | undefined;
|
|
43
|
+
}, {}, {}, {}, mongoose.Document<unknown, {}, {
|
|
44
|
+
createdAt: NativeDate;
|
|
45
|
+
updatedAt: NativeDate;
|
|
46
|
+
} & {
|
|
47
|
+
method: "POST" | "GET" | "PUT" | "PATCH" | "DELETE";
|
|
48
|
+
endpoint: string;
|
|
49
|
+
performanceStatus: "Optimal" | "Acceptable" | "Degraded" | "Severe" | "Critical";
|
|
50
|
+
responseTime: number;
|
|
51
|
+
responseSize: number;
|
|
52
|
+
requestSize: number;
|
|
53
|
+
requestedAt: NativeDate;
|
|
54
|
+
averageResponseCount: number;
|
|
55
|
+
label?: string | null | undefined;
|
|
56
|
+
}, {}> & {
|
|
57
|
+
createdAt: NativeDate;
|
|
58
|
+
updatedAt: NativeDate;
|
|
59
|
+
} & {
|
|
60
|
+
method: "POST" | "GET" | "PUT" | "PATCH" | "DELETE";
|
|
61
|
+
endpoint: string;
|
|
62
|
+
performanceStatus: "Optimal" | "Acceptable" | "Degraded" | "Severe" | "Critical";
|
|
63
|
+
responseTime: number;
|
|
64
|
+
responseSize: number;
|
|
65
|
+
requestSize: number;
|
|
66
|
+
requestedAt: NativeDate;
|
|
67
|
+
averageResponseCount: number;
|
|
68
|
+
label?: string | null | undefined;
|
|
69
|
+
} & {
|
|
70
|
+
_id: mongoose.Types.ObjectId;
|
|
71
|
+
} & {
|
|
72
|
+
__v: number;
|
|
73
|
+
}, mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
74
|
+
timestamps: true;
|
|
75
|
+
}, {
|
|
76
|
+
createdAt: NativeDate;
|
|
77
|
+
updatedAt: NativeDate;
|
|
78
|
+
} & {
|
|
79
|
+
method: "POST" | "GET" | "PUT" | "PATCH" | "DELETE";
|
|
80
|
+
endpoint: string;
|
|
81
|
+
performanceStatus: "Optimal" | "Acceptable" | "Degraded" | "Severe" | "Critical";
|
|
82
|
+
responseTime: number;
|
|
83
|
+
responseSize: number;
|
|
84
|
+
requestSize: number;
|
|
85
|
+
requestedAt: NativeDate;
|
|
86
|
+
averageResponseCount: number;
|
|
87
|
+
label?: string | null | undefined;
|
|
88
|
+
}, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
89
|
+
createdAt: NativeDate;
|
|
90
|
+
updatedAt: NativeDate;
|
|
91
|
+
} & {
|
|
92
|
+
method: "POST" | "GET" | "PUT" | "PATCH" | "DELETE";
|
|
93
|
+
endpoint: string;
|
|
94
|
+
performanceStatus: "Optimal" | "Acceptable" | "Degraded" | "Severe" | "Critical";
|
|
95
|
+
responseTime: number;
|
|
96
|
+
responseSize: number;
|
|
97
|
+
requestSize: number;
|
|
98
|
+
requestedAt: NativeDate;
|
|
99
|
+
averageResponseCount: number;
|
|
100
|
+
label?: string | null | undefined;
|
|
101
|
+
}>, {}> & mongoose.FlatRecord<{
|
|
102
|
+
createdAt: NativeDate;
|
|
103
|
+
updatedAt: NativeDate;
|
|
104
|
+
} & {
|
|
105
|
+
method: "POST" | "GET" | "PUT" | "PATCH" | "DELETE";
|
|
106
|
+
endpoint: string;
|
|
107
|
+
performanceStatus: "Optimal" | "Acceptable" | "Degraded" | "Severe" | "Critical";
|
|
108
|
+
responseTime: number;
|
|
109
|
+
responseSize: number;
|
|
110
|
+
requestSize: number;
|
|
111
|
+
requestedAt: NativeDate;
|
|
112
|
+
averageResponseCount: number;
|
|
113
|
+
label?: string | null | undefined;
|
|
114
|
+
}> & {
|
|
115
|
+
_id: mongoose.Types.ObjectId;
|
|
116
|
+
} & {
|
|
117
|
+
__v: number;
|
|
118
|
+
}>>;
|
|
119
|
+
export default ApiPerformanceLogModel;
|
|
120
|
+
//# sourceMappingURL=api-performance.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-performance.model.d.ts","sourceRoot":"","sources":["../../shared/api-performance.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAyBhC,QAAA,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA+D,CAAC;AAC5F,eAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
const apiPerformanceLogSchema = new mongoose.Schema({
|
|
3
|
+
label: { type: String },
|
|
4
|
+
endpoint: { type: String, required: true },
|
|
5
|
+
performanceStatus: {
|
|
6
|
+
type: String,
|
|
7
|
+
enum: ["Optimal", "Acceptable", "Degraded", "Severe", "Critical"],
|
|
8
|
+
required: true
|
|
9
|
+
},
|
|
10
|
+
responseTime: { type: Number, required: true }, // in milliseconds
|
|
11
|
+
responseSize: { type: Number, default: 0 }, // in bytes
|
|
12
|
+
requestSize: { type: Number, default: 0 }, // in bytes
|
|
13
|
+
requestedAt: { type: Date, required: true, default: Date.now },
|
|
14
|
+
method: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: true,
|
|
17
|
+
enum: ["GET", "POST", "PUT", "PATCH", "DELETE"]
|
|
18
|
+
},
|
|
19
|
+
averageResponseCount: { type: Number, default: 0 },
|
|
20
|
+
}, { timestamps: true });
|
|
21
|
+
const ApiPerformanceLogModel = mongoose.model("ApiPerformanceLog", apiPerformanceLogSchema);
|
|
22
|
+
export default ApiPerformanceLogModel;
|
|
@@ -0,0 +1,177 @@
|
|
|
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 { Document } from "mongoose";
|
|
30
|
+
/**
|
|
31
|
+
* HTTP methods supported by the API performance tracking system.
|
|
32
|
+
*/
|
|
33
|
+
export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
34
|
+
/**
|
|
35
|
+
* Performance status levels based on response time.
|
|
36
|
+
* Automatically set by the model's pre-save middleware.
|
|
37
|
+
*/
|
|
38
|
+
export type PerformanceStatus = "Optimal" | "Acceptable" | "Degraded" | "Severe" | "Critical";
|
|
39
|
+
/**
|
|
40
|
+
* Interface representing an API performance log entry.
|
|
41
|
+
* This matches the Mongoose schema structure for API performance tracking.
|
|
42
|
+
*/
|
|
43
|
+
export interface IApiPerformance {
|
|
44
|
+
/**
|
|
45
|
+
* Optional label for the API performance log entry
|
|
46
|
+
*/
|
|
47
|
+
label?: string;
|
|
48
|
+
/**
|
|
49
|
+
* API endpoint or route (e.g., /api/users)
|
|
50
|
+
*/
|
|
51
|
+
endpoint: string;
|
|
52
|
+
/**
|
|
53
|
+
* Performance status automatically calculated based on response time
|
|
54
|
+
* @default calculated by pre-save middleware
|
|
55
|
+
*/
|
|
56
|
+
performanceStatus: PerformanceStatus;
|
|
57
|
+
/**
|
|
58
|
+
* Response time in milliseconds
|
|
59
|
+
*/
|
|
60
|
+
responseTime: number;
|
|
61
|
+
/**
|
|
62
|
+
* Size of the response payload in bytes
|
|
63
|
+
* @default 0
|
|
64
|
+
*/
|
|
65
|
+
responseSize?: number;
|
|
66
|
+
/**
|
|
67
|
+
* Size of the request payload in bytes
|
|
68
|
+
* @default 0
|
|
69
|
+
*/
|
|
70
|
+
requestSize?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Timestamp when the API call was made
|
|
73
|
+
* @default Date.now
|
|
74
|
+
*/
|
|
75
|
+
requestedAt: Date;
|
|
76
|
+
/**
|
|
77
|
+
* HTTP method used in the request
|
|
78
|
+
*/
|
|
79
|
+
method: HttpMethod;
|
|
80
|
+
/**
|
|
81
|
+
* Average response count for analytics
|
|
82
|
+
* @default 0
|
|
83
|
+
*/
|
|
84
|
+
averageResponseCount?: number;
|
|
85
|
+
/**
|
|
86
|
+
* Automatically added by Mongoose timestamps
|
|
87
|
+
*/
|
|
88
|
+
createdAt?: Date;
|
|
89
|
+
updatedAt?: Date;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Mongoose document type for API performance logs.
|
|
93
|
+
* Extends the base interface with Mongoose document methods.
|
|
94
|
+
*/
|
|
95
|
+
export interface IApiPerformanceDocument extends IApiPerformance, Document {
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Input type for creating a new API performance log entry.
|
|
99
|
+
* Excludes auto-generated fields like timestamps, _id, and performanceStatus.
|
|
100
|
+
*/
|
|
101
|
+
export interface ICreateApiPerformanceInput {
|
|
102
|
+
endpoint: string;
|
|
103
|
+
method: HttpMethod;
|
|
104
|
+
responseTime: number;
|
|
105
|
+
label?: string;
|
|
106
|
+
requestSize?: number;
|
|
107
|
+
responseSize?: number;
|
|
108
|
+
requestedAt?: Date;
|
|
109
|
+
averageResponseCount?: number;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Update type for modifying an existing API performance log entry.
|
|
113
|
+
* All fields are optional for partial updates.
|
|
114
|
+
* Note: performanceStatus is automatically calculated and should not be manually set.
|
|
115
|
+
*/
|
|
116
|
+
export interface IUpdateApiPerformanceInput {
|
|
117
|
+
endpoint?: string;
|
|
118
|
+
method?: HttpMethod;
|
|
119
|
+
responseTime?: number;
|
|
120
|
+
label?: string;
|
|
121
|
+
requestSize?: number;
|
|
122
|
+
responseSize?: number;
|
|
123
|
+
requestedAt?: Date;
|
|
124
|
+
averageResponseCount?: number;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Query filters for searching API performance logs.
|
|
128
|
+
* Supports filtering by various criteria.
|
|
129
|
+
*/
|
|
130
|
+
export interface IApiPerformanceFilters {
|
|
131
|
+
endpoint?: string | RegExp;
|
|
132
|
+
method?: HttpMethod;
|
|
133
|
+
performanceStatus?: PerformanceStatus;
|
|
134
|
+
responseTime?: {
|
|
135
|
+
$gte?: number;
|
|
136
|
+
$lte?: number;
|
|
137
|
+
};
|
|
138
|
+
label?: string | RegExp;
|
|
139
|
+
requestedAt?: {
|
|
140
|
+
$gte?: Date;
|
|
141
|
+
$lte?: Date;
|
|
142
|
+
};
|
|
143
|
+
averageResponseCount?: {
|
|
144
|
+
$gte?: number;
|
|
145
|
+
$lte?: number;
|
|
146
|
+
};
|
|
147
|
+
createdAt?: {
|
|
148
|
+
$gte?: Date;
|
|
149
|
+
$lte?: Date;
|
|
150
|
+
};
|
|
151
|
+
updatedAt?: {
|
|
152
|
+
$gte?: Date;
|
|
153
|
+
$lte?: Date;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Aggregation result for API performance analytics.
|
|
158
|
+
* Used for performance metrics and reporting.
|
|
159
|
+
*/
|
|
160
|
+
export interface IApiPerformanceAnalytics {
|
|
161
|
+
_id?: {
|
|
162
|
+
endpoint?: string;
|
|
163
|
+
method?: HttpMethod;
|
|
164
|
+
performanceStatus?: PerformanceStatus;
|
|
165
|
+
};
|
|
166
|
+
count: number;
|
|
167
|
+
avgResponseTime: number;
|
|
168
|
+
minResponseTime: number;
|
|
169
|
+
maxResponseTime: number;
|
|
170
|
+
totalRequestSize: number;
|
|
171
|
+
totalResponseSize: number;
|
|
172
|
+
avgResponseCount: number;
|
|
173
|
+
performanceStatusDistribution?: {
|
|
174
|
+
[key in PerformanceStatus]?: number;
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=api-performance.type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-performance.type.d.ts","sourceRoot":"","sources":["../../shared/api-performance.type.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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;
|