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