@dynamatix/cat-shared 0.0.113 ā 0.0.114
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 +6 -6
- package/index.js +2 -2
- package/middlewares/audit.middleware.js +340 -340
- package/middlewares/index.js +2 -2
- package/models/audit-config.model.js +15 -15
- package/models/audit.model.js +16 -16
- package/models/document-type.model.js +25 -25
- package/models/document.model.js +59 -59
- package/models/form-configuration.model.js +269 -269
- package/models/index.js +7 -7
- package/models/value-reference-map.model.js +16 -16
- package/models/workflow-alert.model.js +56 -56
- package/models/workflow-config.model.js +29 -29
- package/package.json +22 -22
- package/seeders/value-reference-map.seeder.js +66 -66
- package/services/audit-log.hook.js +2 -2
- package/services/index.js +1 -1
- package/services/request-context.service.js +8 -8
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import mongoose from "mongoose";
|
|
2
|
-
|
|
3
|
-
const alertSchema = new mongoose.Schema({
|
|
4
|
-
contextId: {
|
|
5
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
-
required: true
|
|
7
|
-
},
|
|
8
|
-
source: {
|
|
9
|
-
type: String,
|
|
10
|
-
required: true,
|
|
11
|
-
index: true
|
|
12
|
-
},
|
|
13
|
-
sourceId: {
|
|
14
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
15
|
-
required: true,
|
|
16
|
-
index: true
|
|
17
|
-
},
|
|
18
|
-
alertMessage: {
|
|
19
|
-
type: String,
|
|
20
|
-
required: false
|
|
21
|
-
},
|
|
22
|
-
category: {
|
|
23
|
-
type: String,
|
|
24
|
-
required: false,
|
|
25
|
-
index: true
|
|
26
|
-
},
|
|
27
|
-
isActive: {
|
|
28
|
-
type: Boolean,
|
|
29
|
-
required: true,
|
|
30
|
-
default: true,
|
|
31
|
-
index: true
|
|
32
|
-
},
|
|
33
|
-
status: {
|
|
34
|
-
type: String,
|
|
35
|
-
required: true,
|
|
36
|
-
enum: ['
|
|
37
|
-
index: true
|
|
38
|
-
},
|
|
39
|
-
rationaleMessage: { type: String },
|
|
40
|
-
formName: { type: Array },
|
|
41
|
-
timestamp: {
|
|
42
|
-
type: Date,
|
|
43
|
-
required: true,
|
|
44
|
-
default: Date.now,
|
|
45
|
-
index: true
|
|
46
|
-
}
|
|
47
|
-
}, {
|
|
48
|
-
timestamps: true
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// Compound index for efficient querying
|
|
52
|
-
alertSchema.index({ source: 1, sourceId: 1 });
|
|
53
|
-
alertSchema.index({ status: 1, isActive: 1 });
|
|
54
|
-
|
|
55
|
-
const WorkflowAlertModel = mongoose.
|
|
56
|
-
export default WorkflowAlertModel;
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
|
|
3
|
+
const alertSchema = new mongoose.Schema({
|
|
4
|
+
contextId: {
|
|
5
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
+
required: true
|
|
7
|
+
},
|
|
8
|
+
source: {
|
|
9
|
+
type: String,
|
|
10
|
+
required: true,
|
|
11
|
+
index: true
|
|
12
|
+
},
|
|
13
|
+
sourceId: {
|
|
14
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
15
|
+
required: true,
|
|
16
|
+
index: true
|
|
17
|
+
},
|
|
18
|
+
alertMessage: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: false
|
|
21
|
+
},
|
|
22
|
+
category: {
|
|
23
|
+
type: String,
|
|
24
|
+
required: false,
|
|
25
|
+
index: true
|
|
26
|
+
},
|
|
27
|
+
isActive: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
required: true,
|
|
30
|
+
default: true,
|
|
31
|
+
index: true
|
|
32
|
+
},
|
|
33
|
+
status: {
|
|
34
|
+
type: String,
|
|
35
|
+
required: true,
|
|
36
|
+
enum: ['Raised', 'Satisfied'],
|
|
37
|
+
index: true
|
|
38
|
+
},
|
|
39
|
+
rationaleMessage: { type: String },
|
|
40
|
+
formName: { type: Array },
|
|
41
|
+
timestamp: {
|
|
42
|
+
type: Date,
|
|
43
|
+
required: true,
|
|
44
|
+
default: Date.now,
|
|
45
|
+
index: true
|
|
46
|
+
}
|
|
47
|
+
}, {
|
|
48
|
+
timestamps: true
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Compound index for efficient querying
|
|
52
|
+
alertSchema.index({ source: 1, sourceId: 1 });
|
|
53
|
+
alertSchema.index({ status: 1, isActive: 1 });
|
|
54
|
+
|
|
55
|
+
const WorkflowAlertModel = mongoose.model('WorkflowAlert', alertSchema);
|
|
56
|
+
export default WorkflowAlertModel;
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import mongoose from 'mongoose';
|
|
2
|
-
|
|
3
|
-
const workflowConfigSchema = new mongoose.Schema({
|
|
4
|
-
id: {
|
|
5
|
-
type: String,
|
|
6
|
-
required: true,
|
|
7
|
-
unique: true
|
|
8
|
-
},
|
|
9
|
-
name: {
|
|
10
|
-
type: String,
|
|
11
|
-
required: true
|
|
12
|
-
},
|
|
13
|
-
tasks: {
|
|
14
|
-
type: [mongoose.Schema.Types.Mixed],
|
|
15
|
-
required: true
|
|
16
|
-
},
|
|
17
|
-
trigger: {
|
|
18
|
-
type: String,
|
|
19
|
-
required: true
|
|
20
|
-
},
|
|
21
|
-
validations: {
|
|
22
|
-
type: [mongoose.Schema.Types.Mixed],
|
|
23
|
-
required: true
|
|
24
|
-
}
|
|
25
|
-
}, {
|
|
26
|
-
timestamps: true
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const WorkflowConfigModel = mongoose.models.WorkflowConfig || mongoose.model('WorkflowConfig', workflowConfigSchema);
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
|
|
3
|
+
const workflowConfigSchema = new mongoose.Schema({
|
|
4
|
+
id: {
|
|
5
|
+
type: String,
|
|
6
|
+
required: true,
|
|
7
|
+
unique: true
|
|
8
|
+
},
|
|
9
|
+
name: {
|
|
10
|
+
type: String,
|
|
11
|
+
required: true
|
|
12
|
+
},
|
|
13
|
+
tasks: {
|
|
14
|
+
type: [mongoose.Schema.Types.Mixed],
|
|
15
|
+
required: true
|
|
16
|
+
},
|
|
17
|
+
trigger: {
|
|
18
|
+
type: String,
|
|
19
|
+
required: true
|
|
20
|
+
},
|
|
21
|
+
validations: {
|
|
22
|
+
type: [mongoose.Schema.Types.Mixed],
|
|
23
|
+
required: true
|
|
24
|
+
}
|
|
25
|
+
}, {
|
|
26
|
+
timestamps: true
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const WorkflowConfigModel = mongoose.models.WorkflowConfig || mongoose.model('WorkflowConfig', workflowConfigSchema);
|
|
30
30
|
export default WorkflowConfigModel;
|
package/package.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@dynamatix/cat-shared",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"main": "index.js",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
-
},
|
|
8
|
-
"author": "",
|
|
9
|
-
"license": "ISC",
|
|
10
|
-
"type": "module",
|
|
11
|
-
"description": "",
|
|
12
|
-
"exports": {
|
|
13
|
-
".": "./index.js",
|
|
14
|
-
"./models": "./models/index.js",
|
|
15
|
-
"./middlewares": "./middlewares/index.js",
|
|
16
|
-
"./services": "./services/index.js"
|
|
17
|
-
},
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"dotenv": "^16.4.7",
|
|
20
|
-
"mongoose": "^8.13.1"
|
|
21
|
-
}
|
|
22
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@dynamatix/cat-shared",
|
|
3
|
+
"version": "0.0.114",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
+
},
|
|
8
|
+
"author": "",
|
|
9
|
+
"license": "ISC",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"description": "",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./index.js",
|
|
14
|
+
"./models": "./models/index.js",
|
|
15
|
+
"./middlewares": "./middlewares/index.js",
|
|
16
|
+
"./services": "./services/index.js"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"dotenv": "^16.4.7",
|
|
20
|
+
"mongoose": "^8.13.1"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import mongoose, { model } from 'mongoose';
|
|
2
|
-
import dotenv from 'dotenv';
|
|
3
|
-
import ValueReferenceMapModel from '../models/value-reference-map.model.js';
|
|
4
|
-
|
|
5
|
-
dotenv.config();
|
|
6
|
-
|
|
7
|
-
const MONGO_URI = 'mongodb+srv://qa-user:vw4sIy3lZpyTPoX0@gatehouse-testing.e08r2.mongodb.net/gatehouse-qa?retryWrites=true&w=majority';
|
|
8
|
-
|
|
9
|
-
// Grouped definition (DRY)
|
|
10
|
-
const groupedMappings = [
|
|
11
|
-
{
|
|
12
|
-
model: 'DocumentType',
|
|
13
|
-
displayField: 'name',
|
|
14
|
-
fields: ['documentTypeId']
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
model: 'User',
|
|
18
|
-
displayField: 'fullName',
|
|
19
|
-
fields: ['createdBy', 'updatedBy', 'ownerId','documentOwnerId']
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
model: 'Applicant',
|
|
23
|
-
displayField: 'firstName',
|
|
24
|
-
fields: ['documentOwnerId', 'applicantId']
|
|
25
|
-
}
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
// Flatten the mappings
|
|
29
|
-
const referenceMappings = groupedMappings.flatMap(group =>
|
|
30
|
-
group.fields.map(field => ({
|
|
31
|
-
field,
|
|
32
|
-
model: group.model,
|
|
33
|
-
displayField: group.displayField
|
|
34
|
-
}))
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
async function seed() {
|
|
38
|
-
try {
|
|
39
|
-
console.log(MONGO_URI);
|
|
40
|
-
await mongoose.connect(MONGO_URI);
|
|
41
|
-
console.log('ā
Connected to MongoDB');
|
|
42
|
-
|
|
43
|
-
for (const mapping of referenceMappings) {
|
|
44
|
-
const existing = await ValueReferenceMapModel.findOne({ field: mapping.field });
|
|
45
|
-
if (existing) {
|
|
46
|
-
await ValueReferenceMapModel.updateOne(
|
|
47
|
-
{ field: mapping.field },
|
|
48
|
-
{ $set: mapping }
|
|
49
|
-
);
|
|
50
|
-
console.log(`š Updated mapping for '${mapping.field}'`);
|
|
51
|
-
} else {
|
|
52
|
-
await ValueReferenceMapModel.create(mapping);
|
|
53
|
-
console.log(`ā Inserted mapping for '${mapping.field}'`);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
console.log('\nš± Seeding complete ā
');
|
|
58
|
-
} catch (err) {
|
|
59
|
-
console.error('ā Seeding failed', err);
|
|
60
|
-
} finally {
|
|
61
|
-
await mongoose.disconnect();
|
|
62
|
-
process.exit();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
seed();
|
|
1
|
+
import mongoose, { model } from 'mongoose';
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
import ValueReferenceMapModel from '../models/value-reference-map.model.js';
|
|
4
|
+
|
|
5
|
+
dotenv.config();
|
|
6
|
+
|
|
7
|
+
const MONGO_URI = 'mongodb+srv://qa-user:vw4sIy3lZpyTPoX0@gatehouse-testing.e08r2.mongodb.net/gatehouse-qa?retryWrites=true&w=majority';
|
|
8
|
+
|
|
9
|
+
// Grouped definition (DRY)
|
|
10
|
+
const groupedMappings = [
|
|
11
|
+
{
|
|
12
|
+
model: 'DocumentType',
|
|
13
|
+
displayField: 'name',
|
|
14
|
+
fields: ['documentTypeId']
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
model: 'User',
|
|
18
|
+
displayField: 'fullName',
|
|
19
|
+
fields: ['createdBy', 'updatedBy', 'ownerId','documentOwnerId']
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
model: 'Applicant',
|
|
23
|
+
displayField: 'firstName',
|
|
24
|
+
fields: ['documentOwnerId', 'applicantId']
|
|
25
|
+
}
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
// Flatten the mappings
|
|
29
|
+
const referenceMappings = groupedMappings.flatMap(group =>
|
|
30
|
+
group.fields.map(field => ({
|
|
31
|
+
field,
|
|
32
|
+
model: group.model,
|
|
33
|
+
displayField: group.displayField
|
|
34
|
+
}))
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
async function seed() {
|
|
38
|
+
try {
|
|
39
|
+
console.log(MONGO_URI);
|
|
40
|
+
await mongoose.connect(MONGO_URI);
|
|
41
|
+
console.log('ā
Connected to MongoDB');
|
|
42
|
+
|
|
43
|
+
for (const mapping of referenceMappings) {
|
|
44
|
+
const existing = await ValueReferenceMapModel.findOne({ field: mapping.field });
|
|
45
|
+
if (existing) {
|
|
46
|
+
await ValueReferenceMapModel.updateOne(
|
|
47
|
+
{ field: mapping.field },
|
|
48
|
+
{ $set: mapping }
|
|
49
|
+
);
|
|
50
|
+
console.log(`š Updated mapping for '${mapping.field}'`);
|
|
51
|
+
} else {
|
|
52
|
+
await ValueReferenceMapModel.create(mapping);
|
|
53
|
+
console.log(`ā Inserted mapping for '${mapping.field}'`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
console.log('\nš± Seeding complete ā
');
|
|
58
|
+
} catch (err) {
|
|
59
|
+
console.error('ā Seeding failed', err);
|
|
60
|
+
} finally {
|
|
61
|
+
await mongoose.disconnect();
|
|
62
|
+
process.exit();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
seed();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
|
|
2
|
+
|
package/services/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { getContext, setContext } from './request-context.service.js';
|
|
1
|
+
export { getContext, setContext } from './request-context.service.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// utils/request-context.js
|
|
2
|
-
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
3
|
-
|
|
4
|
-
const asyncLocalStorage = new AsyncLocalStorage();
|
|
5
|
-
|
|
6
|
-
export const setContext = (data) => asyncLocalStorage.enterWith(data);
|
|
7
|
-
|
|
8
|
-
export const getContext = () => asyncLocalStorage.getStore();
|
|
1
|
+
// utils/request-context.js
|
|
2
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
3
|
+
|
|
4
|
+
const asyncLocalStorage = new AsyncLocalStorage();
|
|
5
|
+
|
|
6
|
+
export const setContext = (data) => asyncLocalStorage.enterWith(data);
|
|
7
|
+
|
|
8
|
+
export const getContext = () => asyncLocalStorage.getStore();
|