@dynamatix/cat-shared 0.0.18 → 0.0.19

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.
@@ -0,0 +1,158 @@
1
+ import mongoose from 'mongoose';
2
+
3
+ const formfieldSchema = new mongoose.Schema({
4
+ fieldName: {
5
+ type: String,
6
+ required: true,
7
+ trim: true
8
+ },
9
+ isEditable:{
10
+ type: Boolean,
11
+ default: true
12
+ },
13
+ size: {
14
+ type: Number,
15
+ default: 6,
16
+ enum: [3,4,6,8,10,12],
17
+ },
18
+ layout:{
19
+ type: String,
20
+ enum: ['horizontal', 'vertical'],
21
+ },
22
+ label: {
23
+ type: String,
24
+ required: true,
25
+ trim: true
26
+ },
27
+ dataType: {
28
+ type: String,
29
+ required: true,
30
+ enum: ['string', 'number', 'boolean', 'date', 'array', 'object', 'select', 'radio', 'list'] // Added common form field types
31
+ },
32
+ isRequired: {
33
+ type: Boolean,
34
+ default: false
35
+ },
36
+ helpText: {
37
+ type: String,
38
+ default: null
39
+ },
40
+ requiredErrorMessage:{
41
+ type: String,
42
+ default: 'Field is required'
43
+ },
44
+ defaultValue: {
45
+ type: mongoose.Schema.Types.Mixed
46
+ },
47
+ validationRules: {
48
+ type: mongoose.Schema.Types.Mixed,
49
+ default: {}
50
+ },
51
+ visibilityCondition: {
52
+ type: mongoose.Schema.Types.Mixed,
53
+ default: null
54
+ },
55
+ options: {
56
+ type: [mongoose.Schema.Types.Mixed],
57
+ default: []
58
+ },
59
+ section: {
60
+ type: String,
61
+ default: null
62
+ },
63
+ list:{
64
+ type: {
65
+ name: {
66
+ type: String,
67
+ required: true
68
+ },
69
+ label: {
70
+ type: String,
71
+ required: true
72
+ },
73
+ value: {
74
+ type: String,
75
+ required: true
76
+ },
77
+ optionFilterLogic: {
78
+ type: mongoose.Schema.Types.Mixed,
79
+ default: null
80
+ }
81
+ },
82
+ default: null
83
+ },
84
+ isSyncEnabled: { // Fixed typo (was isSyncEnabed)
85
+ type: Boolean,
86
+ default: true
87
+ },
88
+ dataElement: { //<collectionName>.<fieldName>
89
+ type: String,
90
+ default: null
91
+ },
92
+ syncTargetDataElement: { //<collectionName>.<fieldName> of Apprivo
93
+ type: String,
94
+ default: null
95
+ },
96
+ order: {
97
+ type: Number,
98
+ default: 0
99
+ },
100
+ maxLength: {
101
+ type: Number,
102
+ default: null,
103
+ min: 0
104
+ }
105
+ }, { timestamps: true });
106
+
107
+ const formConfigurationSchema = new mongoose.Schema({
108
+ formName: {
109
+ type: String,
110
+ required: true,
111
+ trim: true,
112
+ unique: true // Consider making form names unique
113
+ },
114
+ apiPath: {
115
+ type: String,
116
+ required: true,
117
+ trim: true
118
+ },
119
+ visibilityCondition: {
120
+ type: mongoose.Schema.Types.Mixed,
121
+ default: null
122
+ },
123
+ sections: [{
124
+ sectionName: {
125
+ type: String,
126
+ required: true,
127
+ trim: true
128
+ },
129
+ sectionLabel: {
130
+ type: String,
131
+ required: true,
132
+ trim: true
133
+ },
134
+ fields: [{
135
+ type: [formfieldSchema]
136
+ }],
137
+ order: {
138
+ type: Number,
139
+ default: 0
140
+ },
141
+ visibilityCondition: { // Added section-level visibility
142
+ type: mongoose.Schema.Types.Mixed,
143
+ default: null
144
+ }
145
+ }],
146
+ isActive: { // Consider adding status flag
147
+ type: Boolean,
148
+ default: true
149
+ },
150
+ version: { // Consider adding versioning
151
+ type: Number,
152
+ default: 1
153
+ }
154
+ }, { timestamps: true });
155
+
156
+ const FormConfiguration = mongoose.model('FormConfiguration', formConfigurationSchema);
157
+
158
+ module.exports = FormConfiguration;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamatix/cat-shared",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -1,10 +1,10 @@
1
- import mongoose from 'mongoose';
1
+ import mongoose, { model } from 'mongoose';
2
2
  import dotenv from 'dotenv';
3
3
  import ValueReferenceMapModel from '../models/value-reference-map.model.js';
4
4
 
5
5
  dotenv.config();
6
6
 
7
- const MONGO_URI = process.env.MONGO_URI;
7
+ const MONGO_URI = 'mongodb+srv://qa-user:vw4sIy3lZpyTPoX0@gatehouse-testing.e08r2.mongodb.net/gatehouse-qa?retryWrites=true&w=majority';
8
8
 
9
9
  // Grouped definition (DRY)
10
10
  const groupedMappings = [
@@ -16,7 +16,12 @@ const groupedMappings = [
16
16
  {
17
17
  model: 'User',
18
18
  displayField: 'fullName',
19
- fields: ['createdBy', 'updatedBy', 'ownerId']
19
+ fields: ['createdBy', 'updatedBy', 'ownerId','documentOwnerId']
20
+ },
21
+ {
22
+ model: 'Applicant',
23
+ displayField: 'firstName',
24
+ fields: ['documentOwnerId']
20
25
  }
21
26
  ];
22
27
 
@@ -37,11 +42,15 @@ async function seed() {
37
42
 
38
43
  for (const mapping of referenceMappings) {
39
44
  const existing = await ValueReferenceMapModel.findOne({ field: mapping.field });
40
- if (!existing) {
41
- await ValueReferenceMapModel.create(mapping);
42
- console.log(`➕ Inserted mapping for '${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}'`);
43
51
  } else {
44
- console.log(`⚠️ Mapping for '${mapping.field}' already exists`);
52
+ await ValueReferenceMapModel.create(mapping);
53
+ console.log(`➕ Inserted mapping for '${mapping.field}'`);
45
54
  }
46
55
  }
47
56