@dynamatix/cat-shared 0.0.133 ā 0.0.134
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 +226 -226
- package/index.js +2 -2
- package/middlewares/audit.middleware.js +425 -425
- package/middlewares/index.js +2 -2
- package/models/audit-config.model.js +15 -15
- package/models/audit.model.js +16 -16
- package/models/document-history.model.js +51 -51
- package/models/document-type.model.js +25 -25
- package/models/document.model.js +73 -73
- package/models/form-configuration.model.js +286 -286
- package/models/index.js +10 -10
- package/models/meta.model.js +9 -9
- package/models/property-metadata.model.js +57 -57
- package/models/value-reference-map.model.js +16 -16
- package/models/workflow-alert.model.js +61 -61
- 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,57 +1,57 @@
|
|
|
1
|
-
import mongoose from "mongoose";
|
|
2
|
-
import applyAuditMiddleware from "../middlewares/audit.middleware";
|
|
3
|
-
|
|
4
|
-
const propertyMetadataSchema = new mongoose.Schema({
|
|
5
|
-
collectionName: {
|
|
6
|
-
type: String,
|
|
7
|
-
required: true,
|
|
8
|
-
index: true
|
|
9
|
-
},
|
|
10
|
-
propertyName: {
|
|
11
|
-
type: String,
|
|
12
|
-
required: true,
|
|
13
|
-
index: true
|
|
14
|
-
},
|
|
15
|
-
type: {
|
|
16
|
-
type: String,
|
|
17
|
-
required: true,
|
|
18
|
-
enum: ['String', 'Number', 'Boolean', 'Date', 'ObjectId', 'Array', 'Object', 'Mixed'],
|
|
19
|
-
index: true
|
|
20
|
-
},
|
|
21
|
-
aliasName: {
|
|
22
|
-
type: String,
|
|
23
|
-
required: false,
|
|
24
|
-
default: ""
|
|
25
|
-
},
|
|
26
|
-
referenceCollection: {
|
|
27
|
-
type: String,
|
|
28
|
-
required: false,
|
|
29
|
-
default: null
|
|
30
|
-
},
|
|
31
|
-
// Additional recommended fields
|
|
32
|
-
description: {
|
|
33
|
-
type: String,
|
|
34
|
-
required: false,
|
|
35
|
-
default: ""
|
|
36
|
-
},
|
|
37
|
-
isRequired: {
|
|
38
|
-
type: Boolean,
|
|
39
|
-
required: true,
|
|
40
|
-
default: false,
|
|
41
|
-
index: true
|
|
42
|
-
}
|
|
43
|
-
}, {
|
|
44
|
-
timestamps: true
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
// Compound indexes for efficient querying
|
|
48
|
-
propertyMetadataSchema.index({ collectionName: 1, propertyName: 1 }, { unique: true });
|
|
49
|
-
propertyMetadataSchema.index({ collectionName: 1, isActive: 1 });
|
|
50
|
-
propertyMetadataSchema.index({ type: 1, isActive: 1 });
|
|
51
|
-
propertyMetadataSchema.index({ category: 1, isActive: 1 });
|
|
52
|
-
|
|
53
|
-
// Apply audit middleware
|
|
54
|
-
applyAuditMiddleware(propertyMetadataSchema, "PropertyMetaData");
|
|
55
|
-
|
|
56
|
-
const PropertyMetaDataModel = mongoose.models.PropertyMetaData || mongoose.model('PropertyMetaData', propertyMetadataSchema);
|
|
57
|
-
export default PropertyMetaDataModel;
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
import applyAuditMiddleware from "../middlewares/audit.middleware";
|
|
3
|
+
|
|
4
|
+
const propertyMetadataSchema = new mongoose.Schema({
|
|
5
|
+
collectionName: {
|
|
6
|
+
type: String,
|
|
7
|
+
required: true,
|
|
8
|
+
index: true
|
|
9
|
+
},
|
|
10
|
+
propertyName: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: true,
|
|
13
|
+
index: true
|
|
14
|
+
},
|
|
15
|
+
type: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: true,
|
|
18
|
+
enum: ['String', 'Number', 'Boolean', 'Date', 'ObjectId', 'Array', 'Object', 'Mixed'],
|
|
19
|
+
index: true
|
|
20
|
+
},
|
|
21
|
+
aliasName: {
|
|
22
|
+
type: String,
|
|
23
|
+
required: false,
|
|
24
|
+
default: ""
|
|
25
|
+
},
|
|
26
|
+
referenceCollection: {
|
|
27
|
+
type: String,
|
|
28
|
+
required: false,
|
|
29
|
+
default: null
|
|
30
|
+
},
|
|
31
|
+
// Additional recommended fields
|
|
32
|
+
description: {
|
|
33
|
+
type: String,
|
|
34
|
+
required: false,
|
|
35
|
+
default: ""
|
|
36
|
+
},
|
|
37
|
+
isRequired: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
required: true,
|
|
40
|
+
default: false,
|
|
41
|
+
index: true
|
|
42
|
+
}
|
|
43
|
+
}, {
|
|
44
|
+
timestamps: true
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Compound indexes for efficient querying
|
|
48
|
+
propertyMetadataSchema.index({ collectionName: 1, propertyName: 1 }, { unique: true });
|
|
49
|
+
propertyMetadataSchema.index({ collectionName: 1, isActive: 1 });
|
|
50
|
+
propertyMetadataSchema.index({ type: 1, isActive: 1 });
|
|
51
|
+
propertyMetadataSchema.index({ category: 1, isActive: 1 });
|
|
52
|
+
|
|
53
|
+
// Apply audit middleware
|
|
54
|
+
applyAuditMiddleware(propertyMetadataSchema, "PropertyMetaData");
|
|
55
|
+
|
|
56
|
+
const PropertyMetaDataModel = mongoose.models.PropertyMetaData || mongoose.model('PropertyMetaData', propertyMetadataSchema);
|
|
57
|
+
export default PropertyMetaDataModel;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import mongoose from 'mongoose';
|
|
2
|
-
|
|
3
|
-
const valueReferenceMapSchema = new mongoose.Schema({
|
|
4
|
-
field: String, // e.g. 'documentTypeId', 'createdBy', 'status'
|
|
5
|
-
model: String, // e.g. 'DocumentType', 'User', 'ApplicationStatus'
|
|
6
|
-
displayField: String, // e.g. 'name', 'fullName', 'label'
|
|
7
|
-
descriptionResolverType: { type: String, enum: ['direct', 'lookup', 'composite', 'custom'], default: 'direct' },
|
|
8
|
-
descriptionField: String, // for direct/lookup
|
|
9
|
-
descriptionFields: [String], // for composite
|
|
10
|
-
descriptionFunction: String // for custom
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
valueReferenceMapSchema.index({ field: 1 }, { unique: true });
|
|
14
|
-
|
|
15
|
-
const ValueReferenceMapModel = mongoose.models.ValueReferenceMap || mongoose.model('ValueReferenceMap', valueReferenceMapSchema);
|
|
16
|
-
export default ValueReferenceMapModel;
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
|
|
3
|
+
const valueReferenceMapSchema = new mongoose.Schema({
|
|
4
|
+
field: String, // e.g. 'documentTypeId', 'createdBy', 'status'
|
|
5
|
+
model: String, // e.g. 'DocumentType', 'User', 'ApplicationStatus'
|
|
6
|
+
displayField: String, // e.g. 'name', 'fullName', 'label'
|
|
7
|
+
descriptionResolverType: { type: String, enum: ['direct', 'lookup', 'composite', 'custom'], default: 'direct' },
|
|
8
|
+
descriptionField: String, // for direct/lookup
|
|
9
|
+
descriptionFields: [String], // for composite
|
|
10
|
+
descriptionFunction: String // for custom
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
valueReferenceMapSchema.index({ field: 1 }, { unique: true });
|
|
14
|
+
|
|
15
|
+
const ValueReferenceMapModel = mongoose.models.ValueReferenceMap || mongoose.model('ValueReferenceMap', valueReferenceMapSchema);
|
|
16
|
+
export default ValueReferenceMapModel;
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import mongoose from "mongoose";
|
|
2
|
-
import applyAuditMiddleware from "../middlewares/audit.middleware";
|
|
3
|
-
|
|
4
|
-
const alertSchema = new mongoose.Schema({
|
|
5
|
-
contextId: {
|
|
6
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
7
|
-
required: true
|
|
8
|
-
},
|
|
9
|
-
source: {
|
|
10
|
-
type: String,
|
|
11
|
-
required: true,
|
|
12
|
-
index: true
|
|
13
|
-
},
|
|
14
|
-
sourceId: {
|
|
15
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
16
|
-
required: true,
|
|
17
|
-
index: true
|
|
18
|
-
},
|
|
19
|
-
alertMessage: {
|
|
20
|
-
type: String,
|
|
21
|
-
required: false
|
|
22
|
-
},
|
|
23
|
-
category: {
|
|
24
|
-
type: String,
|
|
25
|
-
required: false,
|
|
26
|
-
index: true
|
|
27
|
-
},
|
|
28
|
-
isActive: {
|
|
29
|
-
type: Boolean,
|
|
30
|
-
required: true,
|
|
31
|
-
default: true,
|
|
32
|
-
index: true
|
|
33
|
-
},
|
|
34
|
-
status: {
|
|
35
|
-
type: String,
|
|
36
|
-
required: true,
|
|
37
|
-
enum: ['Raised', 'Satisfied'],
|
|
38
|
-
index: true
|
|
39
|
-
},
|
|
40
|
-
rationaleMessage: { type: String },
|
|
41
|
-
isRationalized: { type: Boolean, default: false },
|
|
42
|
-
formName: { type: Array },
|
|
43
|
-
timestamp: {
|
|
44
|
-
type: Date,
|
|
45
|
-
required: true,
|
|
46
|
-
default: Date.now,
|
|
47
|
-
index: true
|
|
48
|
-
}
|
|
49
|
-
}, {
|
|
50
|
-
timestamps: true
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// Compound index for efficient querying
|
|
54
|
-
alertSchema.index({ source: 1, sourceId: 1 });
|
|
55
|
-
alertSchema.index({ status: 1, isActive: 1 });
|
|
56
|
-
|
|
57
|
-
applyAuditMiddleware(alertSchema, "WorkflowAlert");
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const WorkflowAlertModel = mongoose.models.WorkflowAlert || mongoose.model('WorkflowAlert', alertSchema);
|
|
61
|
-
export default WorkflowAlertModel;
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
import applyAuditMiddleware from "../middlewares/audit.middleware";
|
|
3
|
+
|
|
4
|
+
const alertSchema = new mongoose.Schema({
|
|
5
|
+
contextId: {
|
|
6
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
7
|
+
required: true
|
|
8
|
+
},
|
|
9
|
+
source: {
|
|
10
|
+
type: String,
|
|
11
|
+
required: true,
|
|
12
|
+
index: true
|
|
13
|
+
},
|
|
14
|
+
sourceId: {
|
|
15
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
16
|
+
required: true,
|
|
17
|
+
index: true
|
|
18
|
+
},
|
|
19
|
+
alertMessage: {
|
|
20
|
+
type: String,
|
|
21
|
+
required: false
|
|
22
|
+
},
|
|
23
|
+
category: {
|
|
24
|
+
type: String,
|
|
25
|
+
required: false,
|
|
26
|
+
index: true
|
|
27
|
+
},
|
|
28
|
+
isActive: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
required: true,
|
|
31
|
+
default: true,
|
|
32
|
+
index: true
|
|
33
|
+
},
|
|
34
|
+
status: {
|
|
35
|
+
type: String,
|
|
36
|
+
required: true,
|
|
37
|
+
enum: ['Raised', 'Satisfied'],
|
|
38
|
+
index: true
|
|
39
|
+
},
|
|
40
|
+
rationaleMessage: { type: String },
|
|
41
|
+
isRationalized: { type: Boolean, default: false },
|
|
42
|
+
formName: { type: Array },
|
|
43
|
+
timestamp: {
|
|
44
|
+
type: Date,
|
|
45
|
+
required: true,
|
|
46
|
+
default: Date.now,
|
|
47
|
+
index: true
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
50
|
+
timestamps: true
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Compound index for efficient querying
|
|
54
|
+
alertSchema.index({ source: 1, sourceId: 1 });
|
|
55
|
+
alertSchema.index({ status: 1, isActive: 1 });
|
|
56
|
+
|
|
57
|
+
applyAuditMiddleware(alertSchema, "WorkflowAlert");
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
const WorkflowAlertModel = mongoose.models.WorkflowAlert || mongoose.model('WorkflowAlert', alertSchema);
|
|
61
|
+
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.134",
|
|
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();
|