@dynamatix/cat-shared 0.0.120 → 0.0.122

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,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.120",
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.122",
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();