data-primals-engine 1.3.3 → 1.3.4
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/client/package-lock.json +7 -6
- package/client/package.json +1 -1
- package/client/src/App.scss +35 -0
- package/client/src/DataLayout.jsx +38 -9
- package/client/src/Dialog.scss +0 -3
- package/client/src/Field.jsx +75 -2
- package/client/src/ModelCreator.jsx +23 -1
- package/client/src/ModelList.jsx +19 -1
- package/client/src/contexts/UIContext.jsx +19 -10
- package/client/src/translations.js +24 -0
- package/package.json +2 -1
- package/server.js +1 -0
- package/src/core.js +9 -0
- package/src/defaultModels.js +52 -0
- package/src/filter.js +260 -256
- package/src/i18n.js +2 -2
- package/src/modules/data/data.js +1 -1
- package/src/modules/data/data.routes.js +1 -1
- package/src/modules/workflow.js +1818 -1817
package/src/filter.js
CHANGED
|
@@ -1,257 +1,261 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* @param {object}
|
|
5
|
-
* @param {object}
|
|
6
|
-
* @param {object
|
|
7
|
-
* @param {object}
|
|
8
|
-
* @
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
let
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
case '$
|
|
144
|
-
case '$
|
|
145
|
-
case '$
|
|
146
|
-
case '$
|
|
147
|
-
case '$
|
|
148
|
-
case '$
|
|
149
|
-
|
|
150
|
-
if (typeof
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
case '$
|
|
201
|
-
return
|
|
202
|
-
case '$
|
|
203
|
-
return Array.isArray(operands) &&
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
case '$
|
|
207
|
-
return Array.isArray(operands) && operands
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
case '$
|
|
211
|
-
return Array.isArray(operands) &&
|
|
212
|
-
case '$
|
|
213
|
-
return Array.isArray(operands) &&
|
|
214
|
-
case '$
|
|
215
|
-
return Array.isArray(operands) && operands[
|
|
216
|
-
case '$
|
|
217
|
-
return Array.isArray(operands) && operands[
|
|
218
|
-
case '$
|
|
219
|
-
return Array.isArray(operands) && operands[0]
|
|
220
|
-
case '$
|
|
221
|
-
return Array.isArray(operands) && operands[0]
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
return
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if (condition.$
|
|
236
|
-
if (condition.$
|
|
237
|
-
return condition.$
|
|
238
|
-
}
|
|
239
|
-
if (condition.$
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
return !
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
1
|
+
import safeRegex from 'safe-regex';
|
|
2
|
+
/**
|
|
3
|
+
* Evaluates a single condition against form data.
|
|
4
|
+
* @param {object} currentModelDef - The definition of the current model.
|
|
5
|
+
* @param {object} condition - The condition to evaluate.
|
|
6
|
+
* @param {object} formData - The form data.
|
|
7
|
+
* @param {object[]} allModels - An array of all model definitions.
|
|
8
|
+
* @param {object} user - The current user.
|
|
9
|
+
* @returns {boolean} - True if the condition is met, false otherwise.
|
|
10
|
+
*/
|
|
11
|
+
const evaluateSingleCondition = (currentModelDef, condition, formData, allModels, user) => {
|
|
12
|
+
// Condition est directement un filtre MongoDB, donc on l'applique
|
|
13
|
+
// en utilisant les opérateurs et les valeurs qu'il contient.
|
|
14
|
+
|
|
15
|
+
if (!condition || typeof condition !== 'object') {
|
|
16
|
+
console.warn("[Client Eval] Condition is not an object:", condition);
|
|
17
|
+
return true; // Permissive default
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Si la condition est de la forme {field: value}, on la transforme en {$eq: value}
|
|
21
|
+
if (!Object.keys(condition)[0].startsWith('$') && typeof condition[Object.keys(condition)[0]] !== 'object') {
|
|
22
|
+
const fieldName = Object.keys(condition)[0];
|
|
23
|
+
const value = condition[fieldName];
|
|
24
|
+
return evaluateSingleCondition(currentModelDef, {[fieldName]: {$eq: value}}, formData, allModels, user);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Gestion des opérateurs d'agrégation (commencent par $)
|
|
28
|
+
const operator = Object.keys(condition)[0];
|
|
29
|
+
if (operator === '$eq' && Array.isArray(condition[operator])) {
|
|
30
|
+
// Cas spécial pour {$eq: ['$field', value]}
|
|
31
|
+
const [fieldPath, expectedValue] = condition[operator];
|
|
32
|
+
if (typeof fieldPath === 'string' && fieldPath.startsWith('$')) {
|
|
33
|
+
const fieldName = fieldPath.substring(1); // Enlève le $ devant
|
|
34
|
+
return formData[fieldName] == expectedValue;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Si la condition contient des opérateurs logiques, on les gère ici
|
|
39
|
+
if (condition.$and || condition.$or || condition.$not || condition.$nor) {
|
|
40
|
+
console.warn("[Client Eval] Condition logique détectée dans evaluateSingleCondition, ce n'est pas attendu. Devrait être géré par isConditionMet.");
|
|
41
|
+
return true; // Permissive default
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (condition.$find) {
|
|
45
|
+
const fieldName = Object.keys(condition)[0];
|
|
46
|
+
const fieldValue = formData[fieldName];
|
|
47
|
+
const findCondition = condition.$find;
|
|
48
|
+
|
|
49
|
+
if (!Array.isArray(fieldValue)) return false;
|
|
50
|
+
|
|
51
|
+
return fieldValue.some(item => {
|
|
52
|
+
// Gestion spéciale pour la syntaxe $eq: ["$$this.field", value]
|
|
53
|
+
if (findCondition.$eq && Array.isArray(findCondition.$eq)) {
|
|
54
|
+
const [fieldPath, value] = findCondition.$eq;
|
|
55
|
+
if (fieldPath.startsWith("$$this.")) {
|
|
56
|
+
const fieldToCheck = fieldPath.replace("$$this.", "");
|
|
57
|
+
return item[fieldToCheck] == value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Sinon, évaluation normale
|
|
62
|
+
const tempData = { ...item };
|
|
63
|
+
return evaluateSingleCondition(currentModelDef, findCondition, tempData, allModels, user);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Si la condition contient un opérateur $exists, on le gère ici
|
|
68
|
+
if (condition.$exists !== undefined) {
|
|
69
|
+
const fieldName = Object.keys(condition)[0]; // Récupérer le nom du champ
|
|
70
|
+
const shouldExist = condition.$exists; // Récupérer la valeur de $exists (true ou false)
|
|
71
|
+
const exists = Object.prototype.hasOwnProperty.call(formData, fieldName) && formData[fieldName] !== undefined && formData[fieldName] !== null;
|
|
72
|
+
return exists === shouldExist;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Si la condition contient un opérateur $find, on le gère ici
|
|
76
|
+
if (condition.$find) {
|
|
77
|
+
// Récupérer le nom du champ
|
|
78
|
+
const fieldName = Object.keys(condition)[0];
|
|
79
|
+
const fieldValue = formData[fieldName];
|
|
80
|
+
try {
|
|
81
|
+
// Assuming evaluateSingleCondition handles $find
|
|
82
|
+
return evaluateSingleCondition(currentModelDef, condition.$find, formData, allModels, user);
|
|
83
|
+
} catch (error) {
|
|
84
|
+
console.error("Error evaluating $find condition:", condition, error);
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Récupérer le nom du champ et la condition
|
|
90
|
+
const fieldName = Object.keys(condition)[0];
|
|
91
|
+
const fieldValue = condition[fieldName];
|
|
92
|
+
|
|
93
|
+
// Récupérer la définition du champ
|
|
94
|
+
const fieldDef = currentModelDef?.fields.find(f => f.name === fieldName);
|
|
95
|
+
|
|
96
|
+
// Si la définition du champ n'est pas trouvée, on retourne true
|
|
97
|
+
if (!fieldDef) {
|
|
98
|
+
console.warn(`[Client Eval] Field definition not found for field: ${fieldName}`);
|
|
99
|
+
return true; // Permissive default
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
let targetValue = formData[fieldName];
|
|
103
|
+
let processedConditionValue = fieldValue;
|
|
104
|
+
|
|
105
|
+
// 1. Handle $exists (on the first field)
|
|
106
|
+
// 2. Convert condition value based on operator's expected input type
|
|
107
|
+
const fieldType = fieldDef?.type; // Type of the first field
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
processedConditionValue = convertValueType(fieldValue, fieldType);
|
|
111
|
+
} catch (e) {
|
|
112
|
+
logClientEvalWarning(`Error converting value type: ${e.message}`, condition);
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return evaluateComparison(fieldValue, targetValue, processedConditionValue, condition);
|
|
117
|
+
|
|
118
|
+
function logClientEvalWarning(message, details) {
|
|
119
|
+
console.warn(`[Client Eval] ${message}:`, details);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function convertValueType(value, inputType) {
|
|
123
|
+
switch (inputType) {
|
|
124
|
+
case 'number':
|
|
125
|
+
const numValue = parseFloat(value);
|
|
126
|
+
if (isNaN(numValue)) {
|
|
127
|
+
throw new Error(`Invalid number value: ${value}`);
|
|
128
|
+
}
|
|
129
|
+
return numValue;
|
|
130
|
+
case 'boolean':
|
|
131
|
+
return String(value).toLowerCase() === 'true';
|
|
132
|
+
case 'csv':
|
|
133
|
+
return String(value).split(',').map(item => item.trim()).filter(Boolean);
|
|
134
|
+
case 'text':
|
|
135
|
+
default:
|
|
136
|
+
return String(value);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function evaluateComparison(operator, targetValue, processedConditionValue, condition) {
|
|
141
|
+
try {
|
|
142
|
+
switch (typeof operator === 'object' ? Object.keys(operator)[0] : null) {
|
|
143
|
+
case '$eq': return targetValue === processedConditionValue;
|
|
144
|
+
case '$ne': return targetValue !== processedConditionValue;
|
|
145
|
+
case '$gt': return targetValue > processedConditionValue;
|
|
146
|
+
case '$lt': return targetValue < processedConditionValue;
|
|
147
|
+
case '$gte': return targetValue >= processedConditionValue;
|
|
148
|
+
case '$lte': return targetValue <= processedConditionValue;
|
|
149
|
+
case '$regex':
|
|
150
|
+
if (typeof targetValue !== 'string') return false;
|
|
151
|
+
if (typeof processedConditionValue !== 'string') return false;
|
|
152
|
+
try {
|
|
153
|
+
if( safeRegex(processedConditionValue)) {
|
|
154
|
+
const regex = new RegExp(processedConditionValue, 'i');
|
|
155
|
+
return regex.test(targetValue);
|
|
156
|
+
}
|
|
157
|
+
return false;
|
|
158
|
+
} catch (e) {
|
|
159
|
+
logClientEvalWarning(`Invalid regex pattern: ${processedConditionValue}`, condition);
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
case '$in':
|
|
163
|
+
return Array.isArray(processedConditionValue) && processedConditionValue.includes(String(targetValue));
|
|
164
|
+
case '$nin':
|
|
165
|
+
return !Array.isArray(processedConditionValue) || !processedConditionValue.includes(String(targetValue));
|
|
166
|
+
default:
|
|
167
|
+
logClientEvalWarning(`Unhandled operator in client evaluation logic: ${operator}`, condition);
|
|
168
|
+
return true; // Permissive default
|
|
169
|
+
}
|
|
170
|
+
} catch (evalError) {
|
|
171
|
+
logClientEvalWarning(`Error during client condition evaluation: ${operator}, targetValue=${targetValue}, processedConditionValue=${processedConditionValue}`, condition);
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export const isConditionMet = (model, cond, formData, allModels, user) => {
|
|
178
|
+
const condition = cond;
|
|
179
|
+
|
|
180
|
+
if (!condition) return true;
|
|
181
|
+
|
|
182
|
+
if (typeof condition !== 'object' || condition === null) {
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Cas spécial: Évaluation sans modèle (ex: pour les webhooks où la condition est déjà résolue)
|
|
187
|
+
// Dans ce mode, la condition doit être un objet avec un seul opérateur.
|
|
188
|
+
if (!model) {
|
|
189
|
+
const keys = Object.keys(condition);
|
|
190
|
+
if (keys.length !== 1 || !keys[0].startsWith('$')) {
|
|
191
|
+
console.warn('[isConditionMet] Condition invalide pour une évaluation sans modèle. Attendu : { "$opérateur": [...] }. Reçu :', condition);
|
|
192
|
+
return false; // Plus sûr que true pour éviter les faux positifs
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const operator = keys[0];
|
|
196
|
+
const operands = condition[operator];
|
|
197
|
+
|
|
198
|
+
switch (operator) {
|
|
199
|
+
// Opérateurs logiques (récursifs)
|
|
200
|
+
case '$and':
|
|
201
|
+
return Array.isArray(operands) && operands.every(sub => isConditionMet(null, sub, formData, allModels, user));
|
|
202
|
+
case '$or':
|
|
203
|
+
return Array.isArray(operands) && operands.some(sub => isConditionMet(null, sub, formData, allModels, user));
|
|
204
|
+
case '$not':
|
|
205
|
+
return !isConditionMet(null, operands, formData, allModels, user);
|
|
206
|
+
case '$nor':
|
|
207
|
+
return Array.isArray(operands) && !operands.some(sub => isConditionMet(null, sub, formData, allModels, user));
|
|
208
|
+
|
|
209
|
+
// Opérateurs de comparaison (terminaux)
|
|
210
|
+
case '$eq':
|
|
211
|
+
return Array.isArray(operands) && operands[0] === operands[1];
|
|
212
|
+
case '$ne':
|
|
213
|
+
return Array.isArray(operands) && operands[0] !== operands[1];
|
|
214
|
+
case '$in':
|
|
215
|
+
return Array.isArray(operands) && Array.isArray(operands[1]) && operands[1].includes(operands[0]);
|
|
216
|
+
case '$nin':
|
|
217
|
+
return Array.isArray(operands) && Array.isArray(operands[1]) && !operands[1].includes(operands[0]);
|
|
218
|
+
case '$gt':
|
|
219
|
+
return Array.isArray(operands) && operands[0] > operands[1];
|
|
220
|
+
case '$gte':
|
|
221
|
+
return Array.isArray(operands) && operands[0] >= operands[1];
|
|
222
|
+
case '$lt':
|
|
223
|
+
return Array.isArray(operands) && operands[0] < operands[1];
|
|
224
|
+
case '$lte':
|
|
225
|
+
return Array.isArray(operands) && operands[0] <= operands[1];
|
|
226
|
+
|
|
227
|
+
default:
|
|
228
|
+
console.warn(`[isConditionMet] Opérateur non supporté '${operator}' pour une évaluation sans modèle.`);
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// --- Logique existante pour l'évaluation AVEC modèle ---
|
|
234
|
+
|
|
235
|
+
if (condition.$and && Array.isArray(condition.$and)) {
|
|
236
|
+
if (condition.$and.length === 0) return true;
|
|
237
|
+
return condition.$and.every(sub => isConditionMet(model, sub, formData, allModels, user));
|
|
238
|
+
}
|
|
239
|
+
if (condition.$or && Array.isArray(condition.$or)) {
|
|
240
|
+
if (condition.$or.length === 0) return false;
|
|
241
|
+
return condition.$or.some(sub => isConditionMet(model, sub, formData, allModels, user));
|
|
242
|
+
}
|
|
243
|
+
if (condition.$not) {
|
|
244
|
+
return !isConditionMet(model, condition.$not, formData, allModels, user);
|
|
245
|
+
}
|
|
246
|
+
if (condition.$nor && Array.isArray(condition.$nor)) {
|
|
247
|
+
if (condition.$nor.length === 0) return true;
|
|
248
|
+
return !condition.$nor.some(sub => isConditionMet(model, sub, formData, allModels, user));
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Cas 3: Syntaxe d'agrégation {$eq: ['$field', value]}
|
|
252
|
+
if (Object.keys(condition).length === 1) {
|
|
253
|
+
const operator = Object.keys(condition)[0];
|
|
254
|
+
if (operator.startsWith('$') && operator !== '$find' &&
|
|
255
|
+
Array.isArray(condition[operator])) {
|
|
256
|
+
return evaluateSingleCondition(model, condition, formData, allModels, user);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return evaluateSingleCondition(model, condition, formData, allModels, user);
|
|
257
261
|
};
|
package/src/i18n.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import i18n from "i18next";
|
|
2
|
-
import {Trans, useTranslation, initReactI18next} from "react-i18next";
|
|
2
|
+
import {Trans, useTranslation,I18nextProvider, initReactI18next} from "react-i18next";
|
|
3
3
|
import LanguageDetector from "i18next-browser-languagedetector";
|
|
4
4
|
|
|
5
5
|
export const translations = {
|
|
@@ -12441,5 +12441,5 @@ i18n
|
|
|
12441
12441
|
}
|
|
12442
12442
|
});
|
|
12443
12443
|
|
|
12444
|
-
export {Trans, useTranslation};
|
|
12444
|
+
export {Trans, useTranslation, I18nextProvider};
|
|
12445
12445
|
export default i18n;
|
package/src/modules/data/data.js
CHANGED
|
@@ -1279,7 +1279,7 @@ export async function onInit(defaultEngine) {
|
|
|
1279
1279
|
|
|
1280
1280
|
const objectKeys = Object.keys(modelStructure);
|
|
1281
1281
|
|
|
1282
|
-
if( objectKeys.find(o => !["name", "_user", "history", "locked", "_id", "description", "maxRequestData", "fields"].includes(o)) ){
|
|
1282
|
+
if( objectKeys.find(o => !["name", "_user", "icon", "history", "locked", "_id", "description", "maxRequestData", "fields"].includes(o)) ){
|
|
1283
1283
|
throw new Error(i18n.t('api.model.invalidStructure'));
|
|
1284
1284
|
}
|
|
1285
1285
|
|
|
@@ -873,7 +873,7 @@ export async function registerRoutes(engine){
|
|
|
873
873
|
await cancelAlerts(req.me);
|
|
874
874
|
|
|
875
875
|
await getPromise();
|
|
876
|
-
await Event.Trigger('
|
|
876
|
+
await Event.Trigger('OnDemoUserAdded', req.me.username);
|
|
877
877
|
}else{
|
|
878
878
|
await getPromise();
|
|
879
879
|
}
|