@dynamatix/cat-shared 0.0.102 → 0.0.104

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.
@@ -1,2 +1,2 @@
1
- export {default as applyAuditMiddleware} from './audit.middleware.js';
2
- export { registerAuditHook } from './audit.middleware.js';
1
+ export {default as applyAuditMiddleware} from './audit.middleware.js';
2
+ export { registerAuditHook } from './audit.middleware.js';
@@ -1,15 +1,15 @@
1
- import mongoose from 'mongoose';
2
-
3
- const auditConfigSchema = new mongoose.Schema({
4
- collectionName: String,
5
- fields: [String],
6
- trackCreation: { type: Boolean, default: false },
7
- trackDeletion: { type: Boolean, default: false },
8
- descriptionResolutorForExternalData: { type: String, default: null },
9
- descriptionResolutorForDeletion: { type: String, default: null },
10
- });
11
-
12
- const AuditConfigModel = mongoose.models.AuditConfig || mongoose.model('AuditConfig', auditConfigSchema);
13
-
14
-
15
- export default AuditConfigModel;
1
+ import mongoose from 'mongoose';
2
+
3
+ const auditConfigSchema = new mongoose.Schema({
4
+ collectionName: String,
5
+ fields: [String],
6
+ trackCreation: { type: Boolean, default: false },
7
+ trackDeletion: { type: Boolean, default: false },
8
+ descriptionResolutorForExternalData: { type: String, default: null },
9
+ descriptionResolutorForDeletion: { type: String, default: null },
10
+ });
11
+
12
+ const AuditConfigModel = mongoose.models.AuditConfig || mongoose.model('AuditConfig', auditConfigSchema);
13
+
14
+
15
+ export default AuditConfigModel;
@@ -1,16 +1,16 @@
1
- import mongoose from 'mongoose';
2
-
3
- const auditSchema = new mongoose.Schema({
4
- name: String,
5
- recordId: mongoose.Schema.Types.ObjectId,
6
- contextId: mongoose.Schema.Types.ObjectId,
7
- oldValue: mongoose.Schema.Types.Mixed,
8
- newValue: mongoose.Schema.Types.Mixed,
9
- timestamp: { type: Date, default: Date.now },
10
- createdBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
11
- externalData: mongoose.Schema.Types.Mixed
12
- });
13
-
14
- const AuditLog = mongoose.models.AuditLog || mongoose.model('AuditLog', auditSchema);
15
-
16
- export default AuditLog;
1
+ import mongoose from 'mongoose';
2
+
3
+ const auditSchema = new mongoose.Schema({
4
+ name: { type: String, default: null },
5
+ recordId: { type: mongoose.Schema.Types.ObjectId, default: null },
6
+ contextId: { type: mongoose.Schema.Types.ObjectId, default: null },
7
+ oldValue: { type: mongoose.Schema.Types.Mixed, default: null },
8
+ newValue: { type: mongoose.Schema.Types.Mixed, default: null },
9
+ timestamp: { type: Date, default: Date.now },
10
+ createdBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User', default: null },
11
+ externalData: { type: mongoose.Schema.Types.Mixed, default: null }
12
+ });
13
+
14
+ const AuditLog = mongoose.models.AuditLog || mongoose.model('AuditLog', auditSchema);
15
+
16
+ export default AuditLog;
@@ -0,0 +1,26 @@
1
+ import mongoose from "mongoose";
2
+
3
+ const documentTypeSchema = new mongoose.Schema({
4
+ name: { type: String, required: true },
5
+ label: { type: String },
6
+ linkedDocTypes: {
7
+ type: [String], // Array of strings
8
+ default: []
9
+ },
10
+ source: { type: String, enum: ['Applicant', 'Application'], default: null },
11
+ parentDocumentTypeId: { type: mongoose.Schema.Types.ObjectId, ref: 'DocumentType', default: null },
12
+ categoryDescription: { // description only for document categories and not doc types
13
+ type: String,
14
+ required: false,
15
+ default: null
16
+ },
17
+ isForBroker: { // there are some doc types are not to be shown to broker
18
+ type: Boolean,
19
+ default: false
20
+ },
21
+ matchRules: { type: mongoose.Schema.Types.Mixed }
22
+ });
23
+
24
+ const DocumentTypeModel = mongoose.model('DocumentType', documentTypeSchema);
25
+
26
+ export default DocumentTypeModel;
@@ -0,0 +1,60 @@
1
+ import mongoose from "mongoose";
2
+
3
+ const documentSchema = new mongoose.Schema({
4
+ contextId: { // can be application or applicant
5
+ type: mongoose.Schema.Types.ObjectId,
6
+ required: false
7
+ },
8
+ externalDocumentId: { // docId by Apprivo
9
+ type: String,
10
+ required: true
11
+ },
12
+ filename: { // doc name to be shown in UI
13
+ type: String,
14
+ required: false
15
+ },
16
+ docName: { // doc name of uploaded file to be shown in UI
17
+ type: String,
18
+ required: false
19
+ },
20
+ contentType: {
21
+ type: String,
22
+ required: false
23
+ },
24
+ documentTypeId: {
25
+ type: mongoose.Schema.Types.ObjectId,
26
+ ref: "DocumentType",
27
+ required: false
28
+ },
29
+ documentUrl: { // uploaded doc url
30
+ type: String,
31
+ required: false
32
+ },
33
+ status: { // doc status (pending, approved, rejected, ...)
34
+ type: String,
35
+ required: false
36
+ },
37
+ fileSize: {
38
+ type: String,
39
+ required: false
40
+ },
41
+ createdOn: {
42
+ type: Date,
43
+ required: false
44
+ },
45
+ createdBy: {
46
+ type: String,
47
+ required: false
48
+ },
49
+ externalData: {
50
+ type: {
51
+ ownerName: { type: String, required: false }
52
+ },
53
+ required: false
54
+ }
55
+ }, {
56
+ timestamps: true
57
+ });
58
+
59
+ const DocumentModel = mongoose.model("Document", documentSchema);
60
+ export default DocumentModel;