@dynamatix/cat-shared 0.0.105 → 0.0.106

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,59 +1,59 @@
1
- const mongoose = require('mongoose');
2
- const { Schema, model } = mongoose;
3
-
4
- const alertSchema = new Schema({
5
- contextId: {
6
- type: Schema.Types.ObjectId,
7
- required: true
8
- },
9
- source: {
10
- type: String,
11
- required: true,
12
- index: true
13
- },
14
- sourceId: {
15
- type: 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
-
36
- type: String,
37
- required: true,
38
- enum: ['raised', 'satisfied'],
39
- index: true
40
- },
41
- rationaleMessage: { type: String },
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
- const WorkflowAlertModel = model('WorkflowAlert', alertSchema);
58
-
59
- module.exports = WorkflowAlertModel;
1
+ const mongoose = require('mongoose');
2
+ const { Schema, model } = mongoose;
3
+
4
+ const alertSchema = new Schema({
5
+ contextId: {
6
+ type: Schema.Types.ObjectId,
7
+ required: true
8
+ },
9
+ source: {
10
+ type: String,
11
+ required: true,
12
+ index: true
13
+ },
14
+ sourceId: {
15
+ type: 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
+
36
+ type: String,
37
+ required: true,
38
+ enum: ['raised', 'satisfied'],
39
+ index: true
40
+ },
41
+ rationaleMessage: { type: String },
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
+ const WorkflowAlertModel = model('WorkflowAlert', alertSchema);
58
+
59
+ export default WorkflowAlertModel;
@@ -1,32 +1,32 @@
1
- const mongoose = require('mongoose');
2
- const { Schema, model } = mongoose;
3
-
4
- const workflowConfigSchema = new Schema({
5
- id: {
6
- type: String,
7
- required: true,
8
- unique: true
9
- },
10
- name: {
11
- type: String,
12
- required: true
13
- },
14
- tasks: {
15
- type: [Schema.Types.Mixed],
16
- required: true
17
- },
18
- trigger: {
19
- type: String,
20
- required: true
21
- },
22
- validations: {
23
- type: [Schema.Types.Mixed],
24
- required: true
25
- }
26
- }, {
27
- timestamps: true
28
- });
29
-
30
- const WorkflowConfigModel = model('WorkflowConfig', workflowConfigSchema);
31
-
32
- module.exports = WorkflowConfigModel;
1
+ const mongoose = require('mongoose');
2
+ const { Schema, model } = mongoose;
3
+
4
+ const workflowConfigSchema = new Schema({
5
+ id: {
6
+ type: String,
7
+ required: true,
8
+ unique: true
9
+ },
10
+ name: {
11
+ type: String,
12
+ required: true
13
+ },
14
+ tasks: {
15
+ type: [Schema.Types.Mixed],
16
+ required: true
17
+ },
18
+ trigger: {
19
+ type: String,
20
+ required: true
21
+ },
22
+ validations: {
23
+ type: [Schema.Types.Mixed],
24
+ required: true
25
+ }
26
+ }, {
27
+ timestamps: true
28
+ });
29
+
30
+ const WorkflowConfigModel = model('WorkflowConfig', workflowConfigSchema);
31
+
32
+ export default WorkflowConfigModel;
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
- {
2
- "name": "@dynamatix/cat-shared",
3
- "version": "0.0.105",
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
- "./models": "./models/index.js",
14
- "./middlewares": "./middlewares/index.js",
15
- "./services": "./services/index.js"
16
- },
17
- "dependencies": {
18
- "dotenv": "^16.4.7",
19
- "mongoose": "^8.13.1"
20
- }
21
- }
1
+ {
2
+ "name": "@dynamatix/cat-shared",
3
+ "version": "0.0.106",
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
+ "./models": "./models/index.js",
14
+ "./middlewares": "./middlewares/index.js",
15
+ "./services": "./services/index.js"
16
+ },
17
+ "dependencies": {
18
+ "dotenv": "^16.4.7",
19
+ "mongoose": "^8.13.1"
20
+ }
21
+ }
@@ -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();