@dynamatix/cat-shared 0.0.18 → 0.0.20
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,161 @@
|
|
|
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
|
+
uiHint: {
|
|
64
|
+
type: String
|
|
65
|
+
},
|
|
66
|
+
list:{
|
|
67
|
+
type: {
|
|
68
|
+
name: {
|
|
69
|
+
type: String,
|
|
70
|
+
required: true
|
|
71
|
+
},
|
|
72
|
+
label: {
|
|
73
|
+
type: String,
|
|
74
|
+
required: true
|
|
75
|
+
},
|
|
76
|
+
value: {
|
|
77
|
+
type: String,
|
|
78
|
+
required: true
|
|
79
|
+
},
|
|
80
|
+
optionFilterLogic: {
|
|
81
|
+
type: mongoose.Schema.Types.Mixed,
|
|
82
|
+
default: null
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
default: null
|
|
86
|
+
},
|
|
87
|
+
isSyncEnabled: { // Fixed typo (was isSyncEnabed)
|
|
88
|
+
type: Boolean,
|
|
89
|
+
default: true
|
|
90
|
+
},
|
|
91
|
+
dataElement: { //<collectionName>.<fieldName>
|
|
92
|
+
type: String,
|
|
93
|
+
default: null
|
|
94
|
+
},
|
|
95
|
+
syncTargetDataElement: { //<collectionName>.<fieldName> of Apprivo
|
|
96
|
+
type: String,
|
|
97
|
+
default: null
|
|
98
|
+
},
|
|
99
|
+
order: {
|
|
100
|
+
type: Number,
|
|
101
|
+
default: 0
|
|
102
|
+
},
|
|
103
|
+
maxLength: {
|
|
104
|
+
type: Number,
|
|
105
|
+
default: null,
|
|
106
|
+
min: 0
|
|
107
|
+
}
|
|
108
|
+
}, { timestamps: true });
|
|
109
|
+
|
|
110
|
+
const formConfigurationSchema = new mongoose.Schema({
|
|
111
|
+
formName: {
|
|
112
|
+
type: String,
|
|
113
|
+
required: true,
|
|
114
|
+
trim: true,
|
|
115
|
+
unique: true // Consider making form names unique
|
|
116
|
+
},
|
|
117
|
+
apiPath: {
|
|
118
|
+
type: String,
|
|
119
|
+
required: true,
|
|
120
|
+
trim: true
|
|
121
|
+
},
|
|
122
|
+
visibilityCondition: {
|
|
123
|
+
type: mongoose.Schema.Types.Mixed,
|
|
124
|
+
default: null
|
|
125
|
+
},
|
|
126
|
+
sections: [{
|
|
127
|
+
sectionName: {
|
|
128
|
+
type: String,
|
|
129
|
+
required: true,
|
|
130
|
+
trim: true
|
|
131
|
+
},
|
|
132
|
+
sectionLabel: {
|
|
133
|
+
type: String,
|
|
134
|
+
required: true,
|
|
135
|
+
trim: true
|
|
136
|
+
},
|
|
137
|
+
fields: [{
|
|
138
|
+
type: [formfieldSchema]
|
|
139
|
+
}],
|
|
140
|
+
order: {
|
|
141
|
+
type: Number,
|
|
142
|
+
default: 0
|
|
143
|
+
},
|
|
144
|
+
visibilityCondition: { // Added section-level visibility
|
|
145
|
+
type: mongoose.Schema.Types.Mixed,
|
|
146
|
+
default: null
|
|
147
|
+
}
|
|
148
|
+
}],
|
|
149
|
+
isActive: { // Consider adding status flag
|
|
150
|
+
type: Boolean,
|
|
151
|
+
default: true
|
|
152
|
+
},
|
|
153
|
+
version: { // Consider adding versioning
|
|
154
|
+
type: Number,
|
|
155
|
+
default: 1
|
|
156
|
+
}
|
|
157
|
+
}, { timestamps: true });
|
|
158
|
+
|
|
159
|
+
const FormConfigurationModel = mongoose.model('FormConfiguration', formConfigurationSchema);
|
|
160
|
+
|
|
161
|
+
export default FormConfigurationModel;
|
package/models/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { default as AuditConfigModel } from './audit-config.model.js';
|
|
2
2
|
export { default as AuditModel } from './audit.model.js';
|
|
3
|
-
export { default as ValueReferenceMapModel } from './value-reference-map.model.js';
|
|
3
|
+
export { default as ValueReferenceMapModel } from './value-reference-map.model.js';
|
|
4
|
+
export { default as FormConfigurationModel } from './forms/form-configuration.model.js'
|
package/package.json
CHANGED
|
@@ -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 =
|
|
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 (
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
52
|
+
await ValueReferenceMapModel.create(mapping);
|
|
53
|
+
console.log(`➕ Inserted mapping for '${mapping.field}'`);
|
|
45
54
|
}
|
|
46
55
|
}
|
|
47
56
|
|