@xuda.io/runtime-bundle 1.0.461 → 1.0.462
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/js/modules/xuda-actions-module.esm.js +111 -169
- package/js/modules/xuda-actions-module.esm.min.js +1 -1
- package/js/modules/xuda-studio-checker.min.mjs +1 -1
- package/js/modules/xuda-studio-checker.mjs +621 -982
- package/js/xuda-runtime-bundle.js +106 -170
- package/js/xuda-runtime-bundle.min.js +1 -1
- package/js/xuda-runtime-mini-bundle.js +98 -131
- package/js/xuda-runtime-slim.js +106 -170
- package/js/xuda-runtime-slim.min.es.js +106 -170
- package/js/xuda-runtime-slim.min.js +1 -1
- package/js/xuda-server-bundle.min.mjs +1 -1
- package/js/xuda-server-bundle.mjs +104 -137
- package/js/xuda-worker-bundle.js +104 -137
- package/js/xuda-worker-bundle.min.js +1 -1
- package/package.json +1 -1
|
@@ -8,45 +8,11 @@ var app_obj,
|
|
|
8
8
|
UglifyJS,
|
|
9
9
|
JSON5,
|
|
10
10
|
_conf,
|
|
11
|
-
PROTECTED_VARS = [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"_ROWNO",
|
|
17
|
-
"_ROWID",
|
|
18
|
-
"_ROWDOC",
|
|
19
|
-
"_KEY",
|
|
20
|
-
"_VAL",
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
const program_ref_triggers_arr = [
|
|
24
|
-
"call_page",
|
|
25
|
-
"call_modal",
|
|
26
|
-
"call_popover",
|
|
27
|
-
"get_data",
|
|
28
|
-
"set_data",
|
|
29
|
-
"batch",
|
|
30
|
-
"call_native_javascript",
|
|
31
|
-
"call_evaluate_javascript",
|
|
32
|
-
"call_alert",
|
|
33
|
-
"alter_ui_element",
|
|
34
|
-
"create_ui_element",
|
|
35
|
-
"update",
|
|
36
|
-
"raise_event",
|
|
37
|
-
];
|
|
38
|
-
|
|
39
|
-
export const init = function (
|
|
40
|
-
app_obj_in,
|
|
41
|
-
progs_obj_in,
|
|
42
|
-
_in,
|
|
43
|
-
_hide_not_in_use_check,
|
|
44
|
-
is_server_in,
|
|
45
|
-
deployments_in,
|
|
46
|
-
UglifyJS_in,
|
|
47
|
-
JSON5_in,
|
|
48
|
-
_conf_in
|
|
49
|
-
) {
|
|
11
|
+
PROTECTED_VARS = ['_NULL', '_THIS', '_FOR_KEY', '_FOR_VAL', '_ROWNO', '_ROWID', '_ROWDOC', '_KEY', '_VAL'];
|
|
12
|
+
|
|
13
|
+
const program_ref_triggers_arr = ['call_page', 'call_modal', 'call_popover', 'get_data', 'set_data', 'batch', 'call_native_javascript', 'call_evaluate_javascript', 'call_alert', 'alter_ui_element', 'create_ui_element', 'update', 'raise_event'];
|
|
14
|
+
|
|
15
|
+
export const init = function (app_obj_in, progs_obj_in, _in, _hide_not_in_use_check, is_server_in, deployments_in, UglifyJS_in, JSON5_in, _conf_in) {
|
|
50
16
|
app_obj = app_obj_in;
|
|
51
17
|
progs_obj = progs_obj_in;
|
|
52
18
|
progs_str = JSON.stringify(progs_obj);
|
|
@@ -82,8 +48,8 @@ export const check = function (doc) {
|
|
|
82
48
|
// },
|
|
83
49
|
// });
|
|
84
50
|
// } else {
|
|
85
|
-
if (doc.properties.menuType !==
|
|
86
|
-
if (doc.properties.menuType !==
|
|
51
|
+
if (doc.properties.menuType !== 'folder') {
|
|
52
|
+
if (doc.properties.menuType !== 'table') {
|
|
87
53
|
// if (doc._id === "1630415111085_1630391769418") debugger;
|
|
88
54
|
|
|
89
55
|
if (is_server) {
|
|
@@ -109,33 +75,15 @@ export const check = function (doc) {
|
|
|
109
75
|
return count !== arr.length;
|
|
110
76
|
};
|
|
111
77
|
if (!hide_not_in_use_check) {
|
|
112
|
-
const ret_prog_in_use = find_trigger_property_value_in_progs(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
!check_programs_are_active(ret_prog_in_use)
|
|
122
|
-
) {
|
|
123
|
-
const ret_panel_prog_in_use = find_panel_prog_in_progs(
|
|
124
|
-
doc,
|
|
125
|
-
doc._id
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
if (
|
|
129
|
-
!ret_panel_prog_in_use ||
|
|
130
|
-
!check_programs_are_active(ret_panel_prog_in_use)
|
|
131
|
-
) {
|
|
132
|
-
const ret_fieldValue_in_use =
|
|
133
|
-
find_prog_in_fieldset_fieldValue_progs(doc, doc._id);
|
|
134
|
-
|
|
135
|
-
if (
|
|
136
|
-
!ret_fieldValue_in_use ||
|
|
137
|
-
!check_programs_are_active(ret_fieldValue_in_use)
|
|
138
|
-
) {
|
|
78
|
+
const ret_prog_in_use = find_trigger_property_value_in_progs(doc, program_ref_triggers_arr, 'prog', doc._id);
|
|
79
|
+
|
|
80
|
+
if (!ret_prog_in_use || !check_programs_are_active(ret_prog_in_use)) {
|
|
81
|
+
const ret_panel_prog_in_use = find_panel_prog_in_progs(doc, doc._id);
|
|
82
|
+
|
|
83
|
+
if (!ret_panel_prog_in_use || !check_programs_are_active(ret_panel_prog_in_use)) {
|
|
84
|
+
const ret_fieldValue_in_use = find_prog_in_fieldset_fieldValue_progs(doc, doc._id);
|
|
85
|
+
|
|
86
|
+
if (!ret_fieldValue_in_use || !check_programs_are_active(ret_fieldValue_in_use)) {
|
|
139
87
|
doc.studio_meta.not_in_use = true;
|
|
140
88
|
|
|
141
89
|
// search in implementations
|
|
@@ -172,19 +120,9 @@ export const check = function (doc) {
|
|
|
172
120
|
ret = [...ret, ...check_prog_events(doc)];
|
|
173
121
|
// find program dependencies
|
|
174
122
|
|
|
175
|
-
dependency_progs =
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
program_ref_triggers_arr,
|
|
179
|
-
"prog",
|
|
180
|
-
null,
|
|
181
|
-
true
|
|
182
|
-
) || [];
|
|
183
|
-
|
|
184
|
-
dependency_progs = [
|
|
185
|
-
...dependency_progs,
|
|
186
|
-
...(find_panel_prog_in_progs(doc, null, true) || []),
|
|
187
|
-
];
|
|
123
|
+
dependency_progs = find_trigger_property_value_in_progs(doc, program_ref_triggers_arr, 'prog', null, true) || [];
|
|
124
|
+
|
|
125
|
+
dependency_progs = [...dependency_progs, ...(find_panel_prog_in_progs(doc, null, true) || [])];
|
|
188
126
|
} else {
|
|
189
127
|
if (!hide_not_in_use_check) {
|
|
190
128
|
// check use for table
|
|
@@ -214,43 +152,43 @@ export const check = function (doc) {
|
|
|
214
152
|
// }
|
|
215
153
|
|
|
216
154
|
switch (doc.properties.menuType) {
|
|
217
|
-
case
|
|
155
|
+
case 'globals':
|
|
218
156
|
ret = [...ret, ...check_globals(doc)];
|
|
219
157
|
break;
|
|
220
158
|
|
|
221
|
-
case
|
|
159
|
+
case 'table':
|
|
222
160
|
ret = [...ret, ...check_table(doc)];
|
|
223
161
|
break;
|
|
224
162
|
|
|
225
|
-
case
|
|
163
|
+
case 'component':
|
|
226
164
|
ret = [...ret, ...check_component(doc)];
|
|
227
165
|
break;
|
|
228
166
|
|
|
229
|
-
case
|
|
167
|
+
case 'javascript':
|
|
230
168
|
ret = [...ret, ...check_javascript(doc)];
|
|
231
169
|
break;
|
|
232
170
|
|
|
233
|
-
case
|
|
171
|
+
case 'get_data':
|
|
234
172
|
ret = [...ret, ...check_get_data(doc)];
|
|
235
173
|
break;
|
|
236
174
|
|
|
237
|
-
case
|
|
175
|
+
case 'set_data':
|
|
238
176
|
ret = [...ret, ...check_set_data(doc)];
|
|
239
177
|
break;
|
|
240
178
|
|
|
241
|
-
case
|
|
179
|
+
case 'batch':
|
|
242
180
|
ret = [...ret, ...check_batch(doc)];
|
|
243
181
|
break;
|
|
244
182
|
|
|
245
|
-
case
|
|
183
|
+
case 'api':
|
|
246
184
|
ret = [...ret, ...check_api(doc)];
|
|
247
185
|
break;
|
|
248
186
|
|
|
249
|
-
case
|
|
187
|
+
case 'alert':
|
|
250
188
|
ret = [...ret, ...check_alert(doc)];
|
|
251
189
|
break;
|
|
252
190
|
|
|
253
|
-
case
|
|
191
|
+
case 'route':
|
|
254
192
|
ret = [...ret, ...check_route(doc)];
|
|
255
193
|
break;
|
|
256
194
|
|
|
@@ -258,14 +196,14 @@ export const check = function (doc) {
|
|
|
258
196
|
// ret = [...ret, ...call_project_api(doc)];
|
|
259
197
|
// break;
|
|
260
198
|
|
|
261
|
-
case
|
|
199
|
+
case 'folder':
|
|
262
200
|
break;
|
|
263
201
|
|
|
264
202
|
default:
|
|
265
203
|
ret.push({
|
|
266
|
-
code:
|
|
204
|
+
code: 'CHK_MSG_GEN_050',
|
|
267
205
|
data: `invalid ${doc.properties.menuType} properties.menuType`,
|
|
268
|
-
type:
|
|
206
|
+
type: 'E',
|
|
269
207
|
category: `prog`,
|
|
270
208
|
ref: doc._id,
|
|
271
209
|
id: `${doc._id}`,
|
|
@@ -280,10 +218,10 @@ export const check = function (doc) {
|
|
|
280
218
|
dependency_progs,
|
|
281
219
|
};
|
|
282
220
|
for (let [key, val] of Object.entries(ret)) {
|
|
283
|
-
if (val.type ===
|
|
221
|
+
if (val.type === 'E') {
|
|
284
222
|
final_ret.check_errors.push(val);
|
|
285
223
|
}
|
|
286
|
-
if (val.type ===
|
|
224
|
+
if (val.type === 'W') {
|
|
287
225
|
final_ret.check_warnings.push(val);
|
|
288
226
|
}
|
|
289
227
|
}
|
|
@@ -295,7 +233,7 @@ export const check = function (doc) {
|
|
|
295
233
|
ret.push({
|
|
296
234
|
code,
|
|
297
235
|
data,
|
|
298
|
-
type:
|
|
236
|
+
type: 'E',
|
|
299
237
|
});
|
|
300
238
|
} else {
|
|
301
239
|
console.error(err);
|
|
@@ -311,18 +249,18 @@ const check_structure = function (doc) {
|
|
|
311
249
|
|
|
312
250
|
try {
|
|
313
251
|
if (!app_obj || !_.isObject(app_obj) || _.isEmpty(app_obj)) {
|
|
314
|
-
throw new Error(
|
|
252
|
+
throw new Error('', {
|
|
315
253
|
cause: {
|
|
316
|
-
code:
|
|
254
|
+
code: 'CHK_MSG_OBJ_GEN_002',
|
|
317
255
|
data: `invalid app_obj`,
|
|
318
256
|
},
|
|
319
257
|
});
|
|
320
258
|
}
|
|
321
259
|
|
|
322
260
|
if (!doc || !_.isObject(doc) || _.isEmpty(doc)) {
|
|
323
|
-
throw new Error(
|
|
261
|
+
throw new Error('', {
|
|
324
262
|
cause: {
|
|
325
|
-
code:
|
|
263
|
+
code: 'CHK_MSG_OBJ_GEN_004',
|
|
326
264
|
data: `invalid doc`,
|
|
327
265
|
},
|
|
328
266
|
});
|
|
@@ -331,27 +269,27 @@ const check_structure = function (doc) {
|
|
|
331
269
|
try {
|
|
332
270
|
JSON5.parse(JSON.stringify(doc));
|
|
333
271
|
} catch (err) {
|
|
334
|
-
throw new Error(
|
|
272
|
+
throw new Error('', {
|
|
335
273
|
cause: {
|
|
336
|
-
code:
|
|
274
|
+
code: 'CHK_MSG_OBJ_GEN_005',
|
|
337
275
|
data: `error parsing JSON doc`,
|
|
338
276
|
},
|
|
339
277
|
});
|
|
340
278
|
}
|
|
341
279
|
|
|
342
280
|
if (!doc._id) {
|
|
343
|
-
throw new Error(
|
|
281
|
+
throw new Error('', {
|
|
344
282
|
cause: {
|
|
345
|
-
code:
|
|
283
|
+
code: 'CHK_MSG_OBJ_GEN_050',
|
|
346
284
|
data: `missing _id value`,
|
|
347
285
|
},
|
|
348
286
|
});
|
|
349
287
|
}
|
|
350
288
|
if (!doc._rev) {
|
|
351
289
|
if (progs_obj[doc._id]) {
|
|
352
|
-
throw new Error(
|
|
290
|
+
throw new Error('', {
|
|
353
291
|
cause: {
|
|
354
|
-
code:
|
|
292
|
+
code: 'CHK_MSG_OBJ_GEN_052',
|
|
355
293
|
data: `found existing doc _id`,
|
|
356
294
|
},
|
|
357
295
|
});
|
|
@@ -360,59 +298,59 @@ const check_structure = function (doc) {
|
|
|
360
298
|
////////// properties ////////////////
|
|
361
299
|
|
|
362
300
|
if (!doc.properties) {
|
|
363
|
-
throw new Error(
|
|
301
|
+
throw new Error('', {
|
|
364
302
|
cause: {
|
|
365
|
-
code:
|
|
303
|
+
code: 'CHK_MSG_OBJ_GEN_100',
|
|
366
304
|
data: `missing properties object`,
|
|
367
305
|
},
|
|
368
306
|
});
|
|
369
307
|
}
|
|
370
308
|
if (!_.isObject(doc.properties)) {
|
|
371
|
-
throw new Error(
|
|
309
|
+
throw new Error('', {
|
|
372
310
|
cause: {
|
|
373
|
-
code:
|
|
311
|
+
code: 'CHK_MSG_OBJ_GEN_102',
|
|
374
312
|
data: `invalid properties object`,
|
|
375
313
|
},
|
|
376
314
|
});
|
|
377
315
|
}
|
|
378
316
|
|
|
379
317
|
if (!doc.properties.menuType) {
|
|
380
|
-
throw new Error(
|
|
318
|
+
throw new Error('', {
|
|
381
319
|
cause: {
|
|
382
|
-
code:
|
|
320
|
+
code: 'CHK_MSG_OBJ_GEN_104',
|
|
383
321
|
data: `missing properties.menuType`,
|
|
384
322
|
},
|
|
385
323
|
});
|
|
386
324
|
}
|
|
387
325
|
if (!doc.properties.menuName) {
|
|
388
|
-
throw new Error(
|
|
326
|
+
throw new Error('', {
|
|
389
327
|
cause: {
|
|
390
|
-
code:
|
|
328
|
+
code: 'CHK_MSG_OBJ_GEN_106',
|
|
391
329
|
data: `missing properties.menuName`,
|
|
392
330
|
},
|
|
393
331
|
});
|
|
394
332
|
}
|
|
395
333
|
////////// studio_meta ////////////////
|
|
396
334
|
if (!doc.studio_meta) {
|
|
397
|
-
throw new Error(
|
|
335
|
+
throw new Error('', {
|
|
398
336
|
cause: {
|
|
399
|
-
code:
|
|
337
|
+
code: 'CHK_MSG_OBJ_GEN_112',
|
|
400
338
|
data: `missing studio_meta property`,
|
|
401
339
|
},
|
|
402
340
|
});
|
|
403
341
|
}
|
|
404
342
|
if (!_.isObject(doc.studio_meta)) {
|
|
405
|
-
throw new Error(
|
|
343
|
+
throw new Error('', {
|
|
406
344
|
cause: {
|
|
407
|
-
code:
|
|
345
|
+
code: 'CHK_MSG_OBJ_GEN_114',
|
|
408
346
|
data: `invalid studio_meta object`,
|
|
409
347
|
},
|
|
410
348
|
});
|
|
411
349
|
}
|
|
412
350
|
if (!doc.studio_meta.parentId) {
|
|
413
|
-
throw new Error(
|
|
351
|
+
throw new Error('', {
|
|
414
352
|
cause: {
|
|
415
|
-
code:
|
|
353
|
+
code: 'CHK_MSG_OBJ_GEN_112',
|
|
416
354
|
data: `missing studio_meta.parentId value`,
|
|
417
355
|
},
|
|
418
356
|
});
|
|
@@ -422,9 +360,9 @@ const check_structure = function (doc) {
|
|
|
422
360
|
///////////// progFields
|
|
423
361
|
var ids = [];
|
|
424
362
|
if (!_.isArray(doc.progFields)) {
|
|
425
|
-
throw new Error(
|
|
363
|
+
throw new Error('', {
|
|
426
364
|
cause: {
|
|
427
|
-
code:
|
|
365
|
+
code: 'CHK_MSG_OBJ_GEN_402',
|
|
428
366
|
data: `invalid progFields Array property`,
|
|
429
367
|
},
|
|
430
368
|
});
|
|
@@ -432,75 +370,75 @@ const check_structure = function (doc) {
|
|
|
432
370
|
|
|
433
371
|
for (let val of doc.progFields) {
|
|
434
372
|
if (!_.isObject(val)) {
|
|
435
|
-
throw new Error(
|
|
373
|
+
throw new Error('', {
|
|
436
374
|
cause: {
|
|
437
|
-
code:
|
|
375
|
+
code: 'CHK_MSG_OBJ_GEN_404',
|
|
438
376
|
data: `invalid progFields object property`,
|
|
439
377
|
},
|
|
440
378
|
});
|
|
441
379
|
}
|
|
442
380
|
if (!val.id) {
|
|
443
|
-
throw new Error(
|
|
381
|
+
throw new Error('', {
|
|
444
382
|
cause: {
|
|
445
|
-
code:
|
|
383
|
+
code: 'CHK_MSG_OBJ_GEN_406',
|
|
446
384
|
data: `missing progFields.id property`,
|
|
447
385
|
},
|
|
448
386
|
});
|
|
449
387
|
}
|
|
450
388
|
if (ids.includes(val.id)) {
|
|
451
|
-
throw new Error(
|
|
389
|
+
throw new Error('', {
|
|
452
390
|
cause: {
|
|
453
|
-
code:
|
|
391
|
+
code: 'CHK_MSG_OBJ_GEN_408',
|
|
454
392
|
data: `${val.id} id must be unique in progFields property`,
|
|
455
393
|
},
|
|
456
394
|
});
|
|
457
395
|
}
|
|
458
396
|
ids.push(val.id);
|
|
459
397
|
if (!_.isObject(val.data)) {
|
|
460
|
-
throw new Error(
|
|
398
|
+
throw new Error('', {
|
|
461
399
|
cause: {
|
|
462
|
-
code:
|
|
400
|
+
code: 'CHK_MSG_OBJ_GEN_410',
|
|
463
401
|
data: `invalid progFields.data object property`,
|
|
464
402
|
},
|
|
465
403
|
});
|
|
466
404
|
}
|
|
467
405
|
|
|
468
406
|
if (!val.data.field_id) {
|
|
469
|
-
throw new Error(
|
|
407
|
+
throw new Error('', {
|
|
470
408
|
cause: {
|
|
471
|
-
code:
|
|
409
|
+
code: 'CHK_MSG_OBJ_GEN_412',
|
|
472
410
|
data: `invalid progFields.data.field_id property`,
|
|
473
411
|
},
|
|
474
412
|
});
|
|
475
413
|
}
|
|
476
414
|
if (!val.data.type) {
|
|
477
|
-
throw new Error(
|
|
415
|
+
throw new Error('', {
|
|
478
416
|
cause: {
|
|
479
|
-
code:
|
|
417
|
+
code: 'CHK_MSG_OBJ_GEN_414',
|
|
480
418
|
data: `invalid progFields.data.type property`,
|
|
481
419
|
},
|
|
482
420
|
});
|
|
483
421
|
}
|
|
484
422
|
if (!_.isObject(val.props)) {
|
|
485
|
-
throw new Error(
|
|
423
|
+
throw new Error('', {
|
|
486
424
|
cause: {
|
|
487
|
-
code:
|
|
425
|
+
code: 'CHK_MSG_OBJ_GEN_416',
|
|
488
426
|
data: `invalid progFields.props Object property`,
|
|
489
427
|
},
|
|
490
428
|
});
|
|
491
429
|
}
|
|
492
430
|
if (!val.props.fieldType) {
|
|
493
|
-
throw new Error(
|
|
431
|
+
throw new Error('', {
|
|
494
432
|
cause: {
|
|
495
|
-
code:
|
|
433
|
+
code: 'CHK_MSG_OBJ_GEN_418',
|
|
496
434
|
data: `invalid progFields.props.fieldType property`,
|
|
497
435
|
},
|
|
498
436
|
});
|
|
499
437
|
}
|
|
500
438
|
if (!_.isObject(val.props.propExpressions)) {
|
|
501
|
-
throw new Error(
|
|
439
|
+
throw new Error('', {
|
|
502
440
|
cause: {
|
|
503
|
-
code:
|
|
441
|
+
code: 'CHK_MSG_OBJ_GEN_4120',
|
|
504
442
|
data: `invalid al.props.propExpressions Object property`,
|
|
505
443
|
},
|
|
506
444
|
});
|
|
@@ -513,9 +451,9 @@ const check_structure = function (doc) {
|
|
|
513
451
|
///////////// progEvents
|
|
514
452
|
var ids = [];
|
|
515
453
|
if (!_.isArray(doc.progEvents)) {
|
|
516
|
-
throw new Error(
|
|
454
|
+
throw new Error('', {
|
|
517
455
|
cause: {
|
|
518
|
-
code:
|
|
456
|
+
code: 'CHK_MSG_OBJ_GEN_502',
|
|
519
457
|
data: `invalid progEvents Array property`,
|
|
520
458
|
},
|
|
521
459
|
});
|
|
@@ -523,85 +461,85 @@ const check_structure = function (doc) {
|
|
|
523
461
|
|
|
524
462
|
for (let val of doc.progEvents) {
|
|
525
463
|
if (!_.isObject(val)) {
|
|
526
|
-
throw new Error(
|
|
464
|
+
throw new Error('', {
|
|
527
465
|
cause: {
|
|
528
|
-
code:
|
|
466
|
+
code: 'CHK_MSG_OBJ_GEN_504',
|
|
529
467
|
data: `invalid progEvents object property`,
|
|
530
468
|
},
|
|
531
469
|
});
|
|
532
470
|
}
|
|
533
471
|
if (!val.id) {
|
|
534
|
-
throw new Error(
|
|
472
|
+
throw new Error('', {
|
|
535
473
|
cause: {
|
|
536
|
-
code:
|
|
474
|
+
code: 'CHK_MSG_OBJ_GEN_506',
|
|
537
475
|
data: `missing progEvents.id property`,
|
|
538
476
|
},
|
|
539
477
|
});
|
|
540
478
|
}
|
|
541
479
|
if (ids.includes(val.id)) {
|
|
542
|
-
throw new Error(
|
|
480
|
+
throw new Error('', {
|
|
543
481
|
cause: {
|
|
544
|
-
code:
|
|
482
|
+
code: 'CHK_MSG_OBJ_GEN_508',
|
|
545
483
|
data: `${val.id} id must be unique in progEvents property`,
|
|
546
484
|
},
|
|
547
485
|
});
|
|
548
486
|
}
|
|
549
487
|
ids.push(val.id);
|
|
550
488
|
if (!_.isObject(val.data)) {
|
|
551
|
-
throw new Error(
|
|
489
|
+
throw new Error('', {
|
|
552
490
|
cause: {
|
|
553
|
-
code:
|
|
491
|
+
code: 'CHK_MSG_OBJ_GEN_510',
|
|
554
492
|
data: `invalid progEvents.data object property`,
|
|
555
493
|
},
|
|
556
494
|
});
|
|
557
495
|
}
|
|
558
496
|
|
|
559
|
-
if (typeof val.data.condition ===
|
|
560
|
-
throw new Error(
|
|
497
|
+
if (typeof val.data.condition === 'undefined') {
|
|
498
|
+
throw new Error('', {
|
|
561
499
|
cause: {
|
|
562
|
-
code:
|
|
500
|
+
code: 'CHK_MSG_OBJ_GEN_512',
|
|
563
501
|
data: `undefined progEvents.data.condition string property`,
|
|
564
502
|
},
|
|
565
503
|
});
|
|
566
504
|
}
|
|
567
|
-
if (typeof val.data.event_name ===
|
|
568
|
-
throw new Error(
|
|
505
|
+
if (typeof val.data.event_name === 'undefined') {
|
|
506
|
+
throw new Error('', {
|
|
569
507
|
cause: {
|
|
570
|
-
code:
|
|
508
|
+
code: 'CHK_MSG_OBJ_GEN_514',
|
|
571
509
|
data: `undefined progEvents.data.event_name string property`,
|
|
572
510
|
},
|
|
573
511
|
});
|
|
574
512
|
}
|
|
575
|
-
if (typeof val.data.properties ===
|
|
576
|
-
throw new Error(
|
|
513
|
+
if (typeof val.data.properties === 'undefined') {
|
|
514
|
+
throw new Error('', {
|
|
577
515
|
cause: {
|
|
578
|
-
code:
|
|
516
|
+
code: 'CHK_MSG_OBJ_GEN_516',
|
|
579
517
|
data: `undefined progEvents.data.properties string property`,
|
|
580
518
|
},
|
|
581
519
|
});
|
|
582
520
|
}
|
|
583
|
-
if (typeof val.data.type ===
|
|
584
|
-
throw new Error(
|
|
521
|
+
if (typeof val.data.type === 'undefined') {
|
|
522
|
+
throw new Error('', {
|
|
585
523
|
cause: {
|
|
586
|
-
code:
|
|
524
|
+
code: 'CHK_MSG_OBJ_GEN_518',
|
|
587
525
|
data: `undefined progEvents.data.type string property`,
|
|
588
526
|
},
|
|
589
527
|
});
|
|
590
528
|
}
|
|
591
529
|
|
|
592
530
|
if (!_.isArray(val.data.parameters)) {
|
|
593
|
-
throw new Error(
|
|
531
|
+
throw new Error('', {
|
|
594
532
|
cause: {
|
|
595
|
-
code:
|
|
533
|
+
code: 'CHK_MSG_OBJ_GEN_522',
|
|
596
534
|
data: `invalid progEvents.data.parameters Array property`,
|
|
597
535
|
},
|
|
598
536
|
});
|
|
599
537
|
}
|
|
600
538
|
|
|
601
539
|
if (!_.isObject(val.props)) {
|
|
602
|
-
throw new Error(
|
|
540
|
+
throw new Error('', {
|
|
603
541
|
cause: {
|
|
604
|
-
code:
|
|
542
|
+
code: 'CHK_MSG_OBJ_GEN_522',
|
|
605
543
|
data: `invalid progEvents.props Object property`,
|
|
606
544
|
},
|
|
607
545
|
});
|
|
@@ -614,9 +552,9 @@ const check_structure = function (doc) {
|
|
|
614
552
|
if (!triggers) return;
|
|
615
553
|
var ids = [];
|
|
616
554
|
if (!_.isArray(triggers)) {
|
|
617
|
-
throw new Error(
|
|
555
|
+
throw new Error('', {
|
|
618
556
|
cause: {
|
|
619
|
-
code:
|
|
557
|
+
code: 'CHK_MSG_OBJ_GEN_850',
|
|
620
558
|
data: `invalid triggers Array property`,
|
|
621
559
|
},
|
|
622
560
|
});
|
|
@@ -624,26 +562,26 @@ const check_structure = function (doc) {
|
|
|
624
562
|
|
|
625
563
|
for (let val of triggers) {
|
|
626
564
|
if (!_.isObject(val)) {
|
|
627
|
-
throw new Error(
|
|
565
|
+
throw new Error('', {
|
|
628
566
|
cause: {
|
|
629
|
-
code:
|
|
567
|
+
code: 'CHK_MSG_OBJ_GEN_852',
|
|
630
568
|
data: `invalid triggers item object property`,
|
|
631
569
|
},
|
|
632
570
|
});
|
|
633
571
|
}
|
|
634
572
|
|
|
635
573
|
if (!val.id) {
|
|
636
|
-
throw new Error(
|
|
574
|
+
throw new Error('', {
|
|
637
575
|
cause: {
|
|
638
|
-
code:
|
|
576
|
+
code: 'CHK_MSG_OBJ_GEN_854',
|
|
639
577
|
data: `missing triggers.id property`,
|
|
640
578
|
},
|
|
641
579
|
});
|
|
642
580
|
}
|
|
643
581
|
if (ids.includes(val.id)) {
|
|
644
|
-
throw new Error(
|
|
582
|
+
throw new Error('', {
|
|
645
583
|
cause: {
|
|
646
|
-
code:
|
|
584
|
+
code: 'CHK_MSG_OBJ_GEN_856',
|
|
647
585
|
data: `${val.id} id must be unique in triggers property`,
|
|
648
586
|
},
|
|
649
587
|
});
|
|
@@ -651,18 +589,18 @@ const check_structure = function (doc) {
|
|
|
651
589
|
ids.push(val.id);
|
|
652
590
|
|
|
653
591
|
if (!_.isObject(val.data)) {
|
|
654
|
-
throw new Error(
|
|
592
|
+
throw new Error('', {
|
|
655
593
|
cause: {
|
|
656
|
-
code:
|
|
594
|
+
code: 'CHK_MSG_OBJ_GEN_858',
|
|
657
595
|
data: `invalid triggers.data Object property`,
|
|
658
596
|
},
|
|
659
597
|
});
|
|
660
598
|
}
|
|
661
599
|
|
|
662
600
|
if (!_.isObject(val.props)) {
|
|
663
|
-
throw new Error(
|
|
601
|
+
throw new Error('', {
|
|
664
602
|
cause: {
|
|
665
|
-
code:
|
|
603
|
+
code: 'CHK_MSG_OBJ_GEN_860',
|
|
666
604
|
data: `invalid triggers.props item object property`,
|
|
667
605
|
},
|
|
668
606
|
});
|
|
@@ -672,18 +610,18 @@ const check_structure = function (doc) {
|
|
|
672
610
|
const check_progDataSource = function () {
|
|
673
611
|
///////////// progDataSource
|
|
674
612
|
if (!_.isObject(doc.progDataSource)) {
|
|
675
|
-
throw new Error(
|
|
613
|
+
throw new Error('', {
|
|
676
614
|
cause: {
|
|
677
|
-
code:
|
|
615
|
+
code: 'CHK_MSG_OBJ_GEN_602',
|
|
678
616
|
data: `invalid progDataSource Object property`,
|
|
679
617
|
},
|
|
680
618
|
});
|
|
681
619
|
}
|
|
682
620
|
|
|
683
|
-
if (typeof doc.progDataSource.dataSourceType ===
|
|
684
|
-
throw new Error(
|
|
621
|
+
if (typeof doc.progDataSource.dataSourceType === 'undefined') {
|
|
622
|
+
throw new Error('', {
|
|
685
623
|
cause: {
|
|
686
|
-
code:
|
|
624
|
+
code: 'CHK_MSG_OBJ_GEN_604',
|
|
687
625
|
data: `undefined progDataSource.dataSourceType string property`,
|
|
688
626
|
},
|
|
689
627
|
});
|
|
@@ -692,9 +630,9 @@ const check_structure = function (doc) {
|
|
|
692
630
|
const check_progUi = function () {
|
|
693
631
|
///////////// progUi
|
|
694
632
|
if (!_.isArray(doc.progUi)) {
|
|
695
|
-
throw new Error(
|
|
633
|
+
throw new Error('', {
|
|
696
634
|
cause: {
|
|
697
|
-
code:
|
|
635
|
+
code: 'CHK_MSG_OBJ_GEN_702',
|
|
698
636
|
data: `invalid progUi Array property`,
|
|
699
637
|
},
|
|
700
638
|
});
|
|
@@ -704,52 +642,52 @@ const check_structure = function (doc) {
|
|
|
704
642
|
const run_tree = function (node) {
|
|
705
643
|
for (let item of node) {
|
|
706
644
|
if (!_.isObject(item)) {
|
|
707
|
-
throw new Error(
|
|
645
|
+
throw new Error('', {
|
|
708
646
|
cause: {
|
|
709
|
-
code:
|
|
647
|
+
code: 'CHK_MSG_OBJ_GEN_704',
|
|
710
648
|
data: `invalid progUi item Object property`,
|
|
711
649
|
},
|
|
712
650
|
});
|
|
713
651
|
}
|
|
714
652
|
|
|
715
653
|
if (!_.isObject(item.attributes)) {
|
|
716
|
-
throw new Error(
|
|
654
|
+
throw new Error('', {
|
|
717
655
|
cause: {
|
|
718
|
-
code:
|
|
656
|
+
code: 'CHK_MSG_OBJ_GEN_706',
|
|
719
657
|
data: `invalid progUi attributes item Object property`,
|
|
720
658
|
},
|
|
721
659
|
});
|
|
722
660
|
}
|
|
723
661
|
|
|
724
|
-
if (typeof item.type ===
|
|
725
|
-
throw new Error(
|
|
662
|
+
if (typeof item.type === 'undefined') {
|
|
663
|
+
throw new Error('', {
|
|
726
664
|
cause: {
|
|
727
|
-
code:
|
|
665
|
+
code: 'CHK_MSG_OBJ_GEN_708',
|
|
728
666
|
data: `undefined progUi type item string property`,
|
|
729
667
|
},
|
|
730
668
|
});
|
|
731
669
|
}
|
|
732
|
-
if (typeof item.tagName ===
|
|
733
|
-
throw new Error(
|
|
670
|
+
if (typeof item.tagName === 'undefined') {
|
|
671
|
+
throw new Error('', {
|
|
734
672
|
cause: {
|
|
735
|
-
code:
|
|
673
|
+
code: 'CHK_MSG_OBJ_GEN_710',
|
|
736
674
|
data: `undefined progUi tagName item string property`,
|
|
737
675
|
},
|
|
738
676
|
});
|
|
739
677
|
}
|
|
740
678
|
|
|
741
679
|
if (!item.id) {
|
|
742
|
-
throw new Error(
|
|
680
|
+
throw new Error('', {
|
|
743
681
|
cause: {
|
|
744
|
-
code:
|
|
682
|
+
code: 'CHK_MSG_OBJ_GEN_712',
|
|
745
683
|
data: `missing progUi id item property`,
|
|
746
684
|
},
|
|
747
685
|
});
|
|
748
686
|
}
|
|
749
687
|
if (ids.includes(item.id)) {
|
|
750
|
-
throw new Error(
|
|
688
|
+
throw new Error('', {
|
|
751
689
|
cause: {
|
|
752
|
-
code:
|
|
690
|
+
code: 'CHK_MSG_OBJ_GEN_714',
|
|
753
691
|
data: `${item.id} id must be unique in progUi property`,
|
|
754
692
|
},
|
|
755
693
|
});
|
|
@@ -767,20 +705,20 @@ const check_structure = function (doc) {
|
|
|
767
705
|
};
|
|
768
706
|
|
|
769
707
|
switch (doc.properties.menuType) {
|
|
770
|
-
case
|
|
708
|
+
case 'table':
|
|
771
709
|
if (!doc.tableFields) {
|
|
772
|
-
throw new Error(
|
|
710
|
+
throw new Error('', {
|
|
773
711
|
cause: {
|
|
774
|
-
code:
|
|
712
|
+
code: 'CHK_MSG_OBJ_GEN_200',
|
|
775
713
|
data: `missing tableFields property`,
|
|
776
714
|
},
|
|
777
715
|
});
|
|
778
716
|
}
|
|
779
717
|
///////////// tableFields
|
|
780
718
|
if (!_.isArray(doc.tableFields)) {
|
|
781
|
-
throw new Error(
|
|
719
|
+
throw new Error('', {
|
|
782
720
|
cause: {
|
|
783
|
-
code:
|
|
721
|
+
code: 'CHK_MSG_OBJ_GEN_202',
|
|
784
722
|
data: `invalid tableFields Array property`,
|
|
785
723
|
},
|
|
786
724
|
});
|
|
@@ -789,67 +727,67 @@ const check_structure = function (doc) {
|
|
|
789
727
|
|
|
790
728
|
for (let val of doc.tableFields) {
|
|
791
729
|
if (!_.isObject(val)) {
|
|
792
|
-
throw new Error(
|
|
730
|
+
throw new Error('', {
|
|
793
731
|
cause: {
|
|
794
|
-
code:
|
|
732
|
+
code: 'CHK_MSG_OBJ_GEN_204',
|
|
795
733
|
data: `invalid tableFields object property`,
|
|
796
734
|
},
|
|
797
735
|
});
|
|
798
736
|
}
|
|
799
737
|
if (!val.id) {
|
|
800
|
-
throw new Error(
|
|
738
|
+
throw new Error('', {
|
|
801
739
|
cause: {
|
|
802
|
-
code:
|
|
740
|
+
code: 'CHK_MSG_OBJ_GEN_206',
|
|
803
741
|
data: `missing tableFields.id property`,
|
|
804
742
|
},
|
|
805
743
|
});
|
|
806
744
|
}
|
|
807
745
|
if (ids.includes(val.id)) {
|
|
808
|
-
throw new Error(
|
|
746
|
+
throw new Error('', {
|
|
809
747
|
cause: {
|
|
810
|
-
code:
|
|
748
|
+
code: 'CHK_MSG_OBJ_GEN_208',
|
|
811
749
|
data: `${val.id} id must be unique in tableFields property`,
|
|
812
750
|
},
|
|
813
751
|
});
|
|
814
752
|
}
|
|
815
753
|
ids.push(val.id);
|
|
816
754
|
if (!_.isObject(val.data)) {
|
|
817
|
-
throw new Error(
|
|
755
|
+
throw new Error('', {
|
|
818
756
|
cause: {
|
|
819
|
-
code:
|
|
757
|
+
code: 'CHK_MSG_OBJ_GEN_210',
|
|
820
758
|
data: `invalid tableFields.data object property`,
|
|
821
759
|
},
|
|
822
760
|
});
|
|
823
761
|
}
|
|
824
762
|
if (!val.data.field_id) {
|
|
825
|
-
throw new Error(
|
|
763
|
+
throw new Error('', {
|
|
826
764
|
cause: {
|
|
827
|
-
code:
|
|
765
|
+
code: 'CHK_MSG_OBJ_GEN_212',
|
|
828
766
|
data: `invalid tableFields.data.field_id property`,
|
|
829
767
|
},
|
|
830
768
|
});
|
|
831
769
|
}
|
|
832
770
|
if (!_.isObject(val.props)) {
|
|
833
|
-
throw new Error(
|
|
771
|
+
throw new Error('', {
|
|
834
772
|
cause: {
|
|
835
|
-
code:
|
|
773
|
+
code: 'CHK_MSG_OBJ_GEN_214',
|
|
836
774
|
data: `invalid tableFields.props object property`,
|
|
837
775
|
},
|
|
838
776
|
});
|
|
839
777
|
}
|
|
840
778
|
if (!val.props.fieldType) {
|
|
841
|
-
throw new Error(
|
|
779
|
+
throw new Error('', {
|
|
842
780
|
cause: {
|
|
843
|
-
code:
|
|
781
|
+
code: 'CHK_MSG_OBJ_GEN_216',
|
|
844
782
|
data: `invalid tableFields.props.fieldType property`,
|
|
845
783
|
},
|
|
846
784
|
});
|
|
847
785
|
}
|
|
848
786
|
///////////// tableIndexes
|
|
849
787
|
if (!_.isArray(doc.tableIndexes)) {
|
|
850
|
-
throw new Error(
|
|
788
|
+
throw new Error('', {
|
|
851
789
|
cause: {
|
|
852
|
-
code:
|
|
790
|
+
code: 'CHK_MSG_OBJ_GEN_302',
|
|
853
791
|
data: `invalid tableIndexes Array property`,
|
|
854
792
|
},
|
|
855
793
|
});
|
|
@@ -857,50 +795,50 @@ const check_structure = function (doc) {
|
|
|
857
795
|
var index_ids = [];
|
|
858
796
|
for (let val of doc.tableIndexes) {
|
|
859
797
|
if (!_.isObject(val)) {
|
|
860
|
-
throw new Error(
|
|
798
|
+
throw new Error('', {
|
|
861
799
|
cause: {
|
|
862
|
-
code:
|
|
800
|
+
code: 'CHK_MSG_OBJ_GEN_304',
|
|
863
801
|
data: `invalid tableIndexes object property`,
|
|
864
802
|
},
|
|
865
803
|
});
|
|
866
804
|
}
|
|
867
805
|
if (!val.id) {
|
|
868
|
-
throw new Error(
|
|
806
|
+
throw new Error('', {
|
|
869
807
|
cause: {
|
|
870
|
-
code:
|
|
808
|
+
code: 'CHK_MSG_OBJ_GEN_306',
|
|
871
809
|
data: `missing tableIndexes.id property`,
|
|
872
810
|
},
|
|
873
811
|
});
|
|
874
812
|
}
|
|
875
813
|
if (index_ids.includes(val.id)) {
|
|
876
|
-
throw new Error(
|
|
814
|
+
throw new Error('', {
|
|
877
815
|
cause: {
|
|
878
|
-
code:
|
|
816
|
+
code: 'CHK_MSG_OBJ_GEN_308',
|
|
879
817
|
data: `${val.id} id must be unique in tableIndexes property`,
|
|
880
818
|
},
|
|
881
819
|
});
|
|
882
820
|
}
|
|
883
821
|
index_ids.push(val.id);
|
|
884
822
|
if (!_.isObject(val.data)) {
|
|
885
|
-
throw new Error(
|
|
823
|
+
throw new Error('', {
|
|
886
824
|
cause: {
|
|
887
|
-
code:
|
|
825
|
+
code: 'CHK_MSG_OBJ_GEN_310',
|
|
888
826
|
data: `invalid tableIndexes.data object property`,
|
|
889
827
|
},
|
|
890
828
|
});
|
|
891
829
|
}
|
|
892
830
|
if (!val.data.name) {
|
|
893
|
-
throw new Error(
|
|
831
|
+
throw new Error('', {
|
|
894
832
|
cause: {
|
|
895
|
-
code:
|
|
833
|
+
code: 'CHK_MSG_OBJ_GEN_312',
|
|
896
834
|
data: `invalid tableIndexes.data.name property`,
|
|
897
835
|
},
|
|
898
836
|
});
|
|
899
837
|
}
|
|
900
838
|
if (!_.isArray(val.data.keys)) {
|
|
901
|
-
throw new Error(
|
|
839
|
+
throw new Error('', {
|
|
902
840
|
cause: {
|
|
903
|
-
code:
|
|
841
|
+
code: 'CHK_MSG_OBJ_GEN_312',
|
|
904
842
|
data: `invalid tableIndexes.data.keys Array property`,
|
|
905
843
|
},
|
|
906
844
|
});
|
|
@@ -910,51 +848,51 @@ const check_structure = function (doc) {
|
|
|
910
848
|
|
|
911
849
|
break;
|
|
912
850
|
|
|
913
|
-
case
|
|
851
|
+
case 'globals':
|
|
914
852
|
check_progFields();
|
|
915
853
|
check_progEvents();
|
|
916
854
|
break;
|
|
917
855
|
|
|
918
|
-
case
|
|
919
|
-
case
|
|
920
|
-
case
|
|
921
|
-
case
|
|
856
|
+
case 'get_data':
|
|
857
|
+
case 'set_data':
|
|
858
|
+
case 'batch':
|
|
859
|
+
case 'api':
|
|
922
860
|
check_progFields();
|
|
923
861
|
check_progEvents();
|
|
924
862
|
check_progDataSource();
|
|
925
863
|
break;
|
|
926
864
|
|
|
927
|
-
case
|
|
865
|
+
case 'component':
|
|
928
866
|
check_progFields();
|
|
929
867
|
check_progEvents();
|
|
930
868
|
check_progDataSource();
|
|
931
869
|
check_progUi();
|
|
932
870
|
|
|
933
|
-
if (typeof doc.properties.uiFramework ===
|
|
934
|
-
throw new Error(
|
|
871
|
+
if (typeof doc.properties.uiFramework === 'undefined') {
|
|
872
|
+
throw new Error('', {
|
|
935
873
|
cause: {
|
|
936
|
-
code:
|
|
874
|
+
code: 'CHK_MSG_OBJ_GEN_120',
|
|
937
875
|
data: `undefined properties.uiFramework string property`,
|
|
938
876
|
},
|
|
939
877
|
});
|
|
940
878
|
}
|
|
941
|
-
if (typeof doc.properties.renderType ===
|
|
942
|
-
throw new Error(
|
|
879
|
+
if (typeof doc.properties.renderType === 'undefined') {
|
|
880
|
+
throw new Error('', {
|
|
943
881
|
cause: {
|
|
944
|
-
code:
|
|
882
|
+
code: 'CHK_MSG_OBJ_GEN_122',
|
|
945
883
|
data: `undefined properties.renderType string property`,
|
|
946
884
|
},
|
|
947
885
|
});
|
|
948
886
|
}
|
|
949
887
|
break;
|
|
950
888
|
|
|
951
|
-
case
|
|
889
|
+
case 'alert':
|
|
952
890
|
break;
|
|
953
891
|
|
|
954
|
-
case
|
|
892
|
+
case 'javascript':
|
|
955
893
|
break;
|
|
956
894
|
|
|
957
|
-
case
|
|
895
|
+
case 'folder':
|
|
958
896
|
break;
|
|
959
897
|
|
|
960
898
|
default:
|
|
@@ -966,8 +904,8 @@ const check_structure = function (doc) {
|
|
|
966
904
|
ret.push({
|
|
967
905
|
code,
|
|
968
906
|
data,
|
|
969
|
-
type:
|
|
970
|
-
category:
|
|
907
|
+
type: 'E',
|
|
908
|
+
category: 'document',
|
|
971
909
|
structure_error: true,
|
|
972
910
|
});
|
|
973
911
|
} else {
|
|
@@ -984,9 +922,9 @@ const check_table = function (doc) {
|
|
|
984
922
|
///////////// db socket ////////////////////
|
|
985
923
|
if (!doc.properties.databaseSocket) {
|
|
986
924
|
ret.push({
|
|
987
|
-
code:
|
|
988
|
-
data:
|
|
989
|
-
type: doc.studio_meta.not_in_use ?
|
|
925
|
+
code: 'CHK_MSG_TBL_GEN_010',
|
|
926
|
+
data: 'database socket not defined',
|
|
927
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
990
928
|
category: `table`,
|
|
991
929
|
ref: doc._id,
|
|
992
930
|
id: doc._id,
|
|
@@ -994,21 +932,19 @@ const check_table = function (doc) {
|
|
|
994
932
|
} else {
|
|
995
933
|
if (!app_obj?.app_plugins_purchased?.[doc.properties.databaseSocket]) {
|
|
996
934
|
ret.push({
|
|
997
|
-
code:
|
|
935
|
+
code: 'CHK_MSG_TBL_GEN_0020',
|
|
998
936
|
data: `invalid ${doc.properties.databaseSocket} database socket`,
|
|
999
|
-
type: doc.studio_meta.not_in_use ?
|
|
937
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1000
938
|
category: `table`,
|
|
1001
939
|
ref: doc._id,
|
|
1002
940
|
id: doc._id,
|
|
1003
941
|
});
|
|
1004
942
|
} else {
|
|
1005
|
-
if (
|
|
1006
|
-
!app_obj.app_plugins_purchased[doc.properties.databaseSocket].installed
|
|
1007
|
-
) {
|
|
943
|
+
if (!app_obj.app_plugins_purchased[doc.properties.databaseSocket].installed) {
|
|
1008
944
|
ret.push({
|
|
1009
|
-
code:
|
|
945
|
+
code: 'CHK_MSG_TBL_GEN_030',
|
|
1010
946
|
data: `${doc.properties.databaseSocket} database socket not installed`,
|
|
1011
|
-
type: doc.studio_meta.not_in_use ?
|
|
947
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1012
948
|
category: `table`,
|
|
1013
949
|
ref: doc._id,
|
|
1014
950
|
id: doc._id,
|
|
@@ -1020,9 +956,9 @@ const check_table = function (doc) {
|
|
|
1020
956
|
///////////// fields ////////////////////
|
|
1021
957
|
if (doc.tableIndexes?.length && !doc?.tableFields?.length) {
|
|
1022
958
|
ret.push({
|
|
1023
|
-
code:
|
|
959
|
+
code: 'CHK_MSG_TBL_FLD_090',
|
|
1024
960
|
data: `table has no fields`,
|
|
1025
|
-
type: doc.studio_meta.not_in_use ?
|
|
961
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1026
962
|
category: `table`,
|
|
1027
963
|
ref: doc._id,
|
|
1028
964
|
id: doc._id,
|
|
@@ -1033,9 +969,9 @@ const check_table = function (doc) {
|
|
|
1033
969
|
for (let field of doc.tableFields) {
|
|
1034
970
|
if (!field?.data?.field_id) {
|
|
1035
971
|
ret.push({
|
|
1036
|
-
code:
|
|
972
|
+
code: 'CHK_MSG_TBL_FLD_100',
|
|
1037
973
|
data: `missing field_id`,
|
|
1038
|
-
type: doc.studio_meta.not_in_use ?
|
|
974
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1039
975
|
category: `table`,
|
|
1040
976
|
ref: field.id,
|
|
1041
977
|
id: `${doc._id}-${field.id}`,
|
|
@@ -1043,9 +979,9 @@ const check_table = function (doc) {
|
|
|
1043
979
|
} else {
|
|
1044
980
|
if (!/^[A-Za-z]+[\w\-\:\.]*$/.test(field.data.field_id)) {
|
|
1045
981
|
ret.push({
|
|
1046
|
-
code:
|
|
982
|
+
code: 'CHK_MSG_TBL_FLD_020',
|
|
1047
983
|
data: `invalid field_id`,
|
|
1048
|
-
type: doc.studio_meta.not_in_use ?
|
|
984
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1049
985
|
category: `table`,
|
|
1050
986
|
ref: field.id,
|
|
1051
987
|
id: `${doc._id}-${field.id}`,
|
|
@@ -1060,9 +996,9 @@ const check_table = function (doc) {
|
|
|
1060
996
|
if (!hide_not_in_use_check) {
|
|
1061
997
|
if (!find_field_in_progs(doc, field.data.field_id)) {
|
|
1062
998
|
ret.push({
|
|
1063
|
-
code:
|
|
999
|
+
code: 'CHK_MSG_TBL_FLD_022',
|
|
1064
1000
|
data: `table field "${field.data.field_id}" not in use`,
|
|
1065
|
-
type:
|
|
1001
|
+
type: 'W',
|
|
1066
1002
|
category: `table`,
|
|
1067
1003
|
ref: doc._id,
|
|
1068
1004
|
not_in_use: true,
|
|
@@ -1076,9 +1012,9 @@ const check_table = function (doc) {
|
|
|
1076
1012
|
for (let [key, val] of Object.entries(name_counts_obj)) {
|
|
1077
1013
|
if (val > 1) {
|
|
1078
1014
|
ret.push({
|
|
1079
|
-
code:
|
|
1015
|
+
code: 'CHK_MSG_TBL_FLD_200',
|
|
1080
1016
|
data: `duplicate field id for ${key}`,
|
|
1081
|
-
type: doc.studio_meta.not_in_use ?
|
|
1017
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1082
1018
|
id: `${doc._id}-${key}`,
|
|
1083
1019
|
});
|
|
1084
1020
|
}
|
|
@@ -1086,11 +1022,11 @@ const check_table = function (doc) {
|
|
|
1086
1022
|
///////////// indexes ////////////////////
|
|
1087
1023
|
|
|
1088
1024
|
if (!doc.tableIndexes?.length) {
|
|
1089
|
-
if (doc.properties.databaseSocket !==
|
|
1025
|
+
if (doc.properties.databaseSocket !== '@xuda.io/xuda-dbs-plugin-xuda') {
|
|
1090
1026
|
ret.push({
|
|
1091
|
-
code:
|
|
1027
|
+
code: 'CHK_MSG_TBL_IDX_040',
|
|
1092
1028
|
data: `at least one index has to be defined`,
|
|
1093
|
-
type: doc.studio_meta.not_in_use ?
|
|
1029
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1094
1030
|
id: `${doc._id}`,
|
|
1095
1031
|
});
|
|
1096
1032
|
}
|
|
@@ -1102,30 +1038,26 @@ const check_table = function (doc) {
|
|
|
1102
1038
|
}
|
|
1103
1039
|
if (!index?.data?.name) {
|
|
1104
1040
|
ret.push({
|
|
1105
|
-
code:
|
|
1041
|
+
code: 'CHK_MSG_TBL_IDX_060',
|
|
1106
1042
|
data: `tableIndexes.data.name cannot be empty in "${index.id}" index`,
|
|
1107
|
-
type: doc.studio_meta.not_in_use ?
|
|
1043
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1108
1044
|
id: `${doc._id}`,
|
|
1109
1045
|
});
|
|
1110
1046
|
}
|
|
1111
1047
|
if (!index?.data?.keys?.length) {
|
|
1112
1048
|
ret.push({
|
|
1113
|
-
code:
|
|
1049
|
+
code: 'CHK_MSG_TBL_IDX_070',
|
|
1114
1050
|
data: `tableIndexes.data.keys cannot be empty in "${index.id}" index`,
|
|
1115
|
-
type: doc.studio_meta.not_in_use ?
|
|
1051
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1116
1052
|
id: `${doc._id}-${index.id}`,
|
|
1117
1053
|
});
|
|
1118
1054
|
} else {
|
|
1119
1055
|
for (let key of index.data.keys) {
|
|
1120
|
-
if (
|
|
1121
|
-
!doc.tableFields ||
|
|
1122
|
-
!_.isArray(doc.tableFields) ||
|
|
1123
|
-
!find_item_by_key(doc.tableFields, "field_id", key)
|
|
1124
|
-
) {
|
|
1056
|
+
if (!doc.tableFields || !_.isArray(doc.tableFields) || !find_item_by_key(doc.tableFields, 'field_id', key)) {
|
|
1125
1057
|
ret.push({
|
|
1126
|
-
code:
|
|
1058
|
+
code: 'CHK_MSG_TBL_IDX_080',
|
|
1127
1059
|
data: `invalid key ${key} in tableIndexes.data.keys for "${index.id}" index`,
|
|
1128
|
-
type: doc.studio_meta.not_in_use ?
|
|
1060
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1129
1061
|
id: `${doc._id}-${index.id}-${key}`,
|
|
1130
1062
|
});
|
|
1131
1063
|
}
|
|
@@ -1148,23 +1080,19 @@ const check_table = function (doc) {
|
|
|
1148
1080
|
///////////// fields ////////////////////
|
|
1149
1081
|
if (!doc?.tableFields?.length) {
|
|
1150
1082
|
ret.push({
|
|
1151
|
-
code:
|
|
1083
|
+
code: 'CHK_MSG_TBL_FLD_012',
|
|
1152
1084
|
data: `table has no fields`,
|
|
1153
|
-
type:
|
|
1085
|
+
type: 'W',
|
|
1154
1086
|
id: `${doc._id}`,
|
|
1155
1087
|
});
|
|
1156
1088
|
}
|
|
1157
1089
|
|
|
1158
1090
|
for (let field of doc.tableFields) {
|
|
1159
|
-
if (
|
|
1160
|
-
!["string", "number", "boolean", "object", "array"].includes(
|
|
1161
|
-
field?.props?.fieldType
|
|
1162
|
-
)
|
|
1163
|
-
) {
|
|
1091
|
+
if (!['string', 'number', 'boolean', 'object', 'array'].includes(field?.props?.fieldType)) {
|
|
1164
1092
|
ret.push({
|
|
1165
|
-
code:
|
|
1093
|
+
code: 'CHK_MSG_TBL_FLD_022',
|
|
1166
1094
|
data: `invalid fieldType for field ${field_id}`,
|
|
1167
|
-
type:
|
|
1095
|
+
type: 'E',
|
|
1168
1096
|
id: `${doc._id}-${field.id}`,
|
|
1169
1097
|
});
|
|
1170
1098
|
}
|
|
@@ -1185,9 +1113,9 @@ const check_component = function (doc) {
|
|
|
1185
1113
|
///////////// uiFramework ////////////////////
|
|
1186
1114
|
if (!doc.properties.uiFramework) {
|
|
1187
1115
|
ret.push({
|
|
1188
|
-
code:
|
|
1189
|
-
data:
|
|
1190
|
-
type: doc.studio_meta.not_in_use ?
|
|
1116
|
+
code: 'CHK_MSG_PRG_COM_010',
|
|
1117
|
+
data: 'component Ui Framework not defined',
|
|
1118
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1191
1119
|
category: `component`,
|
|
1192
1120
|
ref: doc._id,
|
|
1193
1121
|
id: `${doc._id}`,
|
|
@@ -1195,21 +1123,19 @@ const check_component = function (doc) {
|
|
|
1195
1123
|
} else {
|
|
1196
1124
|
if (!app_obj?.app_plugins_purchased?.[doc.properties.uiFramework]) {
|
|
1197
1125
|
ret.push({
|
|
1198
|
-
code:
|
|
1126
|
+
code: 'CHK_MSG_PRG_COM_020',
|
|
1199
1127
|
data: `invalid ${doc.properties.uiFramework} Ui Framework`,
|
|
1200
|
-
type: doc.studio_meta.not_in_use ?
|
|
1128
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1201
1129
|
category: `component`,
|
|
1202
1130
|
ref: doc._id,
|
|
1203
1131
|
id: `${doc._id}`,
|
|
1204
1132
|
});
|
|
1205
1133
|
} else {
|
|
1206
|
-
if (
|
|
1207
|
-
!app_obj.app_plugins_purchased[doc.properties.uiFramework].installed
|
|
1208
|
-
) {
|
|
1134
|
+
if (!app_obj.app_plugins_purchased[doc.properties.uiFramework].installed) {
|
|
1209
1135
|
ret.push({
|
|
1210
|
-
code:
|
|
1136
|
+
code: 'CHK_MSG_PRG_COM_030',
|
|
1211
1137
|
data: `${doc.properties.uiFramework} Ui Framework not installed`,
|
|
1212
|
-
type: doc.studio_meta.not_in_use ?
|
|
1138
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1213
1139
|
category: `component`,
|
|
1214
1140
|
ref: doc._id,
|
|
1215
1141
|
id: `${doc._id}`,
|
|
@@ -1241,28 +1167,25 @@ const check_component = function (doc) {
|
|
|
1241
1167
|
for (let [key, val] of Object.entries(item.attributes)) {
|
|
1242
1168
|
if (!key) {
|
|
1243
1169
|
ret.push({
|
|
1244
|
-
code:
|
|
1170
|
+
code: 'CHK_MSG_PRG_GUI_010',
|
|
1245
1171
|
data: `missing attribute in tree_id ${item.id}`,
|
|
1246
|
-
type: doc.studio_meta.not_in_use ?
|
|
1172
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1247
1173
|
category: `component_ui`,
|
|
1248
1174
|
ref: item.id,
|
|
1249
1175
|
id: `${doc._id}-${item.id}-${key}`,
|
|
1250
1176
|
});
|
|
1251
1177
|
} else {
|
|
1252
1178
|
// console.log(key);
|
|
1253
|
-
if (key.substr(0, 6) ===
|
|
1179
|
+
if (key.substr(0, 6) === 'xu-exp') {
|
|
1254
1180
|
// if (item.id === "node-c1adfbb7-17b4-4631-b17d-000db66cc88d")
|
|
1255
1181
|
|
|
1256
|
-
ret = [
|
|
1257
|
-
...ret,
|
|
1258
|
-
...check_prog_expression(doc, val, item.id, "ui_attribute"),
|
|
1259
|
-
];
|
|
1182
|
+
ret = [...ret, ...check_prog_expression(doc, val, item.id, 'ui_attribute')];
|
|
1260
1183
|
} else {
|
|
1261
1184
|
if (!/^[A-Za-z]+[\w\-\:\.]*$/.test(key)) {
|
|
1262
1185
|
ret.push({
|
|
1263
|
-
code:
|
|
1186
|
+
code: 'CHK_MSG_PRG_GUI_020',
|
|
1264
1187
|
data: `invalid attribute "${key}" in tag "${item.tagName}" "${item.id}"`,
|
|
1265
|
-
type: doc.studio_meta.not_in_use ?
|
|
1188
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1266
1189
|
category: `component_ui`,
|
|
1267
1190
|
ref: item.id,
|
|
1268
1191
|
id: `${doc._id}-${item.id}-${key}`,
|
|
@@ -1270,20 +1193,11 @@ const check_component = function (doc) {
|
|
|
1270
1193
|
}
|
|
1271
1194
|
}
|
|
1272
1195
|
|
|
1273
|
-
if (key.substr(0, 6) ===
|
|
1196
|
+
if (key.substr(0, 6) === 'xu-on:') {
|
|
1274
1197
|
if (!_.isEmpty(val)) {
|
|
1275
1198
|
for (let trigger_item of val) {
|
|
1276
1199
|
// try {
|
|
1277
|
-
ret = [
|
|
1278
|
-
...ret,
|
|
1279
|
-
...check_prog_triggers(
|
|
1280
|
-
doc,
|
|
1281
|
-
trigger_item.event,
|
|
1282
|
-
"ui_trigger",
|
|
1283
|
-
item.id,
|
|
1284
|
-
item.attributes.tree_id
|
|
1285
|
-
),
|
|
1286
|
-
];
|
|
1200
|
+
ret = [...ret, ...check_prog_triggers(doc, trigger_item.event, 'ui_trigger', item.id, item.attributes.tree_id)];
|
|
1287
1201
|
// } catch (err) {
|
|
1288
1202
|
// console.error("***********", err);
|
|
1289
1203
|
// debugger;
|
|
@@ -1303,9 +1217,9 @@ const check_component = function (doc) {
|
|
|
1303
1217
|
for (let [key, val] of Object.entries(name_counts_obj)) {
|
|
1304
1218
|
if (val > 1) {
|
|
1305
1219
|
ret.push({
|
|
1306
|
-
code:
|
|
1220
|
+
code: 'CHK_MSG_PRG_GUI_200',
|
|
1307
1221
|
data: `duplicate attribute id for ${key} in tree_id ${item.attribute.tree_id}`,
|
|
1308
|
-
type: doc.studio_meta.not_in_use ?
|
|
1222
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1309
1223
|
category: `component_ui`,
|
|
1310
1224
|
ref: doc._id,
|
|
1311
1225
|
id: `${doc._id}-${item.id}-${key}`,
|
|
@@ -1332,9 +1246,9 @@ const check_component = function (doc) {
|
|
|
1332
1246
|
for (let [key, val] of Object.entries(xu_tree_id_counts_obj)) {
|
|
1333
1247
|
if (val > 1) {
|
|
1334
1248
|
ret.push({
|
|
1335
|
-
code:
|
|
1249
|
+
code: 'CHK_MSG_PRG_GUI_250',
|
|
1336
1250
|
data: `duplicate tree_id "${key}"`,
|
|
1337
|
-
type:
|
|
1251
|
+
type: 'W',
|
|
1338
1252
|
category: `component_ui`,
|
|
1339
1253
|
ref: doc._id,
|
|
1340
1254
|
id: `${doc._id}-${key}`,
|
|
@@ -1388,9 +1302,9 @@ const check_alert = function (doc) {
|
|
|
1388
1302
|
|
|
1389
1303
|
if (_.isEmpty(doc.alertData)) {
|
|
1390
1304
|
ret.push({
|
|
1391
|
-
code:
|
|
1305
|
+
code: 'CHK_MSG_PRG_ART_010',
|
|
1392
1306
|
data: `no alert properties defined`,
|
|
1393
|
-
type: doc.studio_meta.not_in_use ?
|
|
1307
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1394
1308
|
category: `alert`,
|
|
1395
1309
|
ref: doc._id,
|
|
1396
1310
|
id: `${doc._id}`,
|
|
@@ -1398,9 +1312,9 @@ const check_alert = function (doc) {
|
|
|
1398
1312
|
} else {
|
|
1399
1313
|
if (!doc.alertData.alertType) {
|
|
1400
1314
|
ret.push({
|
|
1401
|
-
code:
|
|
1315
|
+
code: 'CHK_MSG_PRG_ART_020',
|
|
1402
1316
|
data: `missing alert type property`,
|
|
1403
|
-
type: doc.studio_meta.not_in_use ?
|
|
1317
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1404
1318
|
category: `alert`,
|
|
1405
1319
|
ref: doc._id,
|
|
1406
1320
|
id: `${doc._id}`,
|
|
@@ -1408,24 +1322,19 @@ const check_alert = function (doc) {
|
|
|
1408
1322
|
}
|
|
1409
1323
|
if (!doc.alertData.alertDisplay) {
|
|
1410
1324
|
ret.push({
|
|
1411
|
-
code:
|
|
1325
|
+
code: 'CHK_MSG_PRG_ART_030',
|
|
1412
1326
|
data: `missing alert display property`,
|
|
1413
|
-
type: doc.studio_meta.not_in_use ?
|
|
1327
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1414
1328
|
category: `alert`,
|
|
1415
1329
|
ref: doc._id,
|
|
1416
1330
|
id: `${doc._id}`,
|
|
1417
1331
|
});
|
|
1418
1332
|
}
|
|
1419
|
-
if (
|
|
1420
|
-
!doc.alertData.alertTitle &&
|
|
1421
|
-
!doc.alertData.alertTitleFx &&
|
|
1422
|
-
!doc.alertData.alertBody &&
|
|
1423
|
-
!doc.alertData.alertBodyFx
|
|
1424
|
-
) {
|
|
1333
|
+
if (!doc.alertData.alertTitle && !doc.alertData.alertTitleFx && !doc.alertData.alertBody && !doc.alertData.alertBodyFx) {
|
|
1425
1334
|
ret.push({
|
|
1426
|
-
code:
|
|
1335
|
+
code: 'CHK_MSG_PRG_ART_032',
|
|
1427
1336
|
data: `missing alert title and body value`,
|
|
1428
|
-
type:
|
|
1337
|
+
type: 'W',
|
|
1429
1338
|
category: `alert`,
|
|
1430
1339
|
ref: doc._id,
|
|
1431
1340
|
id: `${doc._id}`,
|
|
@@ -1449,9 +1358,9 @@ const check_route = function (doc) {
|
|
|
1449
1358
|
|
|
1450
1359
|
if (_.isEmpty(doc?.routeMenu?.menu)) {
|
|
1451
1360
|
ret.push({
|
|
1452
|
-
code:
|
|
1361
|
+
code: 'CHK_MSG_RTE_MNU_010',
|
|
1453
1362
|
data: `no route properties defined`,
|
|
1454
|
-
type: doc.studio_meta.not_in_use ?
|
|
1363
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1455
1364
|
category: `alert`,
|
|
1456
1365
|
ref: doc._id,
|
|
1457
1366
|
id: `${doc._id}`,
|
|
@@ -1464,9 +1373,9 @@ const check_route = function (doc) {
|
|
|
1464
1373
|
for (let item of items) {
|
|
1465
1374
|
if (!item.prog_id) {
|
|
1466
1375
|
ret.push({
|
|
1467
|
-
code:
|
|
1376
|
+
code: 'CHK_MSG_RTE_MNU_020',
|
|
1468
1377
|
data: `no program to call has been defined`,
|
|
1469
|
-
type: doc.studio_meta.not_in_use ?
|
|
1378
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1470
1379
|
category: `alert`,
|
|
1471
1380
|
ref: item.id,
|
|
1472
1381
|
id: `${doc._id}`,
|
|
@@ -1475,9 +1384,9 @@ const check_route = function (doc) {
|
|
|
1475
1384
|
}
|
|
1476
1385
|
if (!progs_obj[item.prog_id]) {
|
|
1477
1386
|
ret.push({
|
|
1478
|
-
code:
|
|
1387
|
+
code: 'CHK_MSG_RTE_MNU_030',
|
|
1479
1388
|
data: `program ${item.prog_id} not exist`,
|
|
1480
|
-
type: doc.studio_meta.not_in_use ?
|
|
1389
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1481
1390
|
category: `alert`,
|
|
1482
1391
|
ref: item.id,
|
|
1483
1392
|
id: `${doc._id}`,
|
|
@@ -1522,10 +1431,10 @@ const check_prog_fieldset = function (doc) {
|
|
|
1522
1431
|
if (!doc.progFields || _.isEmpty(doc.progFields)) {
|
|
1523
1432
|
if (doc.progDataSource.dataSourceTableId) {
|
|
1524
1433
|
ret.push({
|
|
1525
|
-
code:
|
|
1434
|
+
code: 'CHK_MSG_PRG_FLD_012',
|
|
1526
1435
|
data: `datasource table defined but fieldset is empty`,
|
|
1527
|
-
type:
|
|
1528
|
-
category:
|
|
1436
|
+
type: 'W',
|
|
1437
|
+
category: 'fieldset',
|
|
1529
1438
|
id: `${doc._id}`,
|
|
1530
1439
|
});
|
|
1531
1440
|
}
|
|
@@ -1535,23 +1444,20 @@ const check_prog_fieldset = function (doc) {
|
|
|
1535
1444
|
for (let field of doc.progFields) {
|
|
1536
1445
|
if (!field?.data?.field_id) {
|
|
1537
1446
|
ret.push({
|
|
1538
|
-
code:
|
|
1447
|
+
code: 'CHK_MSG_PRG_FLD_010',
|
|
1539
1448
|
data: `missing field_id`,
|
|
1540
|
-
type: doc.studio_meta.not_in_use ?
|
|
1541
|
-
category:
|
|
1449
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1450
|
+
category: 'fieldset',
|
|
1542
1451
|
ref: field.id,
|
|
1543
1452
|
id: `${doc._id}-${field.id}`,
|
|
1544
1453
|
});
|
|
1545
1454
|
} else {
|
|
1546
|
-
if (
|
|
1547
|
-
!/^[A-Za-z]+[\w\-\:\.]*$/.test(field.data.field_id) &&
|
|
1548
|
-
!PROTECTED_VARS.includes(field.data.field_id)
|
|
1549
|
-
) {
|
|
1455
|
+
if (!/^[A-Za-z]+[\w\-\:\.]*$/.test(field.data.field_id) && !PROTECTED_VARS.includes(field.data.field_id)) {
|
|
1550
1456
|
ret.push({
|
|
1551
|
-
code:
|
|
1457
|
+
code: 'CHK_MSG_PRG_FLD_020',
|
|
1552
1458
|
data: `invalid ${field.data.field_id} field_id`,
|
|
1553
|
-
type: doc.studio_meta.not_in_use ?
|
|
1554
|
-
category:
|
|
1459
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1460
|
+
category: 'fieldset',
|
|
1555
1461
|
ref: field.id,
|
|
1556
1462
|
id: `${doc._id}-${field.id}`,
|
|
1557
1463
|
});
|
|
@@ -1568,10 +1474,7 @@ const check_prog_fieldset = function (doc) {
|
|
|
1568
1474
|
var found_parameter_out_match;
|
|
1569
1475
|
if (!_.isEmpty(doc.properties.progParams)) {
|
|
1570
1476
|
for (let parameter_item of doc.properties.progParams) {
|
|
1571
|
-
if (
|
|
1572
|
-
parameter_item.data.dir === "out" &&
|
|
1573
|
-
parameter_item.data.parameter === field.data.field_id
|
|
1574
|
-
) {
|
|
1477
|
+
if (parameter_item.data.dir === 'out' && parameter_item.data.parameter === field.data.field_id) {
|
|
1575
1478
|
found_parameter_out_match = true;
|
|
1576
1479
|
break;
|
|
1577
1480
|
}
|
|
@@ -1579,10 +1482,10 @@ const check_prog_fieldset = function (doc) {
|
|
|
1579
1482
|
}
|
|
1580
1483
|
if (!found_parameter_out_match) {
|
|
1581
1484
|
ret.push({
|
|
1582
|
-
code:
|
|
1485
|
+
code: 'CHK_MSG_PRG_FLD_022',
|
|
1583
1486
|
data: `field "${field.data.field_id}" not in use`,
|
|
1584
|
-
type:
|
|
1585
|
-
category:
|
|
1487
|
+
type: 'W',
|
|
1488
|
+
category: 'fieldset',
|
|
1586
1489
|
ref: field.id,
|
|
1587
1490
|
not_in_use: true,
|
|
1588
1491
|
id: `${doc._id}-${field.id}`,
|
|
@@ -1594,59 +1497,51 @@ const check_prog_fieldset = function (doc) {
|
|
|
1594
1497
|
|
|
1595
1498
|
if (!field?.data?.type) {
|
|
1596
1499
|
ret.push({
|
|
1597
|
-
code:
|
|
1500
|
+
code: 'CHK_MSG_PRG_FLD_030',
|
|
1598
1501
|
data: `missing field type`,
|
|
1599
|
-
type: doc.studio_meta.not_in_use ?
|
|
1600
|
-
category:
|
|
1502
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1503
|
+
category: 'fieldset',
|
|
1601
1504
|
ref: field.id,
|
|
1602
1505
|
id: `${doc._id}-${field.id}`,
|
|
1603
1506
|
});
|
|
1604
1507
|
return ret;
|
|
1605
1508
|
} else {
|
|
1606
1509
|
switch (field.data.type) {
|
|
1607
|
-
case
|
|
1510
|
+
case 'virtual':
|
|
1608
1511
|
break;
|
|
1609
1512
|
|
|
1610
|
-
case
|
|
1611
|
-
if (
|
|
1612
|
-
!field?.props?.fieldValue ||
|
|
1613
|
-
!field?.props?.propExpressions?.fieldValue
|
|
1614
|
-
) {
|
|
1513
|
+
case 'exp':
|
|
1514
|
+
if (!field?.props?.fieldValue || !field?.props?.propExpressions?.fieldValue) {
|
|
1615
1515
|
ret.push({
|
|
1616
|
-
code:
|
|
1516
|
+
code: 'CHK_MSG_PRG_FLD_070',
|
|
1617
1517
|
data: `invalid value or value expression for ${field.data.field_id} field type Exp`,
|
|
1618
|
-
type: doc.studio_meta.not_in_use ?
|
|
1619
|
-
category:
|
|
1518
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1519
|
+
category: 'fieldset',
|
|
1620
1520
|
ref: field.id,
|
|
1621
1521
|
id: `${doc._id}-${field.id}`,
|
|
1622
1522
|
});
|
|
1623
1523
|
}
|
|
1624
1524
|
break;
|
|
1625
1525
|
|
|
1626
|
-
case
|
|
1627
|
-
if (doc.properties.menuType ===
|
|
1526
|
+
case 'table':
|
|
1527
|
+
if (doc.properties.menuType === 'globals') {
|
|
1628
1528
|
ret.push({
|
|
1629
|
-
code:
|
|
1529
|
+
code: 'CHK_MSG_PRG_FLD_040',
|
|
1630
1530
|
data: `invalid field type for ${field.data.field_id} in globals`,
|
|
1631
|
-
type: doc.studio_meta.not_in_use ?
|
|
1632
|
-
category:
|
|
1531
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1532
|
+
category: 'fieldset',
|
|
1633
1533
|
ref: field.id,
|
|
1634
1534
|
id: `${doc._id}-${field.id}`,
|
|
1635
1535
|
});
|
|
1636
1536
|
} else {
|
|
1637
1537
|
// check against table
|
|
1638
1538
|
|
|
1639
|
-
if (
|
|
1640
|
-
!doc.progDataSource ||
|
|
1641
|
-
_.isEmpty(doc.progDataSource) ||
|
|
1642
|
-
!doc.progDataSource.dataSourceType ||
|
|
1643
|
-
doc.progDataSource.dataSourceType === "none"
|
|
1644
|
-
) {
|
|
1539
|
+
if (!doc.progDataSource || _.isEmpty(doc.progDataSource) || !doc.progDataSource.dataSourceType || doc.progDataSource.dataSourceType === 'none') {
|
|
1645
1540
|
ret.push({
|
|
1646
|
-
code:
|
|
1541
|
+
code: 'CHK_MSG_PRG_FLD_300',
|
|
1647
1542
|
data: `undefined datasource for ${field.data.field_id} field`,
|
|
1648
|
-
type: doc.studio_meta.not_in_use ?
|
|
1649
|
-
category:
|
|
1543
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1544
|
+
category: 'fieldset',
|
|
1650
1545
|
ref: field.id,
|
|
1651
1546
|
id: `${doc._id}-${field.id}`,
|
|
1652
1547
|
});
|
|
@@ -1655,37 +1550,26 @@ const check_prog_fieldset = function (doc) {
|
|
|
1655
1550
|
var ret_dsc = check_prog_datasource(doc);
|
|
1656
1551
|
if (ret_dsc.length) return ret;
|
|
1657
1552
|
|
|
1658
|
-
var _datasource_table_arr =
|
|
1659
|
-
progs_obj?.[doc.progDataSource.dataSourceTableId]
|
|
1660
|
-
?.tableFields;
|
|
1553
|
+
var _datasource_table_arr = progs_obj?.[doc.progDataSource.dataSourceTableId]?.tableFields;
|
|
1661
1554
|
if (!_datasource_table_arr) {
|
|
1662
1555
|
ret.push({
|
|
1663
|
-
code:
|
|
1556
|
+
code: 'CHK_MSG_PRG_FLD_310',
|
|
1664
1557
|
data: `no fields found in datasource table ${doc.progDataSource.dataSourceTableId} `,
|
|
1665
|
-
type: doc.studio_meta.not_in_use ?
|
|
1666
|
-
category:
|
|
1558
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1559
|
+
category: 'fieldset',
|
|
1667
1560
|
ref: field.id,
|
|
1668
1561
|
id: `${doc._id}-${field.id}`,
|
|
1669
1562
|
});
|
|
1670
1563
|
return ret;
|
|
1671
1564
|
}
|
|
1672
1565
|
|
|
1673
|
-
if (
|
|
1674
|
-
!
|
|
1675
|
-
_datasource_table_arr,
|
|
1676
|
-
"field_id",
|
|
1677
|
-
field.data.field_id
|
|
1678
|
-
)
|
|
1679
|
-
) {
|
|
1680
|
-
if (
|
|
1681
|
-
!doc.progDataSource.dataSourceReduce ||
|
|
1682
|
-
field.data.field_id !== "REDUCE_VALUE"
|
|
1683
|
-
) {
|
|
1566
|
+
if (!find_item_by_key(_datasource_table_arr, 'field_id', field.data.field_id)) {
|
|
1567
|
+
if (!doc.progDataSource.dataSourceReduce || field.data.field_id !== 'REDUCE_VALUE') {
|
|
1684
1568
|
ret.push({
|
|
1685
|
-
code:
|
|
1569
|
+
code: 'CHK_MSG_PRG_FLD_320',
|
|
1686
1570
|
data: `invalid field ${field.data.field_id} in datasource table`,
|
|
1687
|
-
type: doc.studio_meta.not_in_use ?
|
|
1688
|
-
category:
|
|
1571
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1572
|
+
category: 'fieldset',
|
|
1689
1573
|
ref: field.id,
|
|
1690
1574
|
id: `${doc._id}-${field.id}`,
|
|
1691
1575
|
});
|
|
@@ -1698,10 +1582,10 @@ const check_prog_fieldset = function (doc) {
|
|
|
1698
1582
|
|
|
1699
1583
|
default:
|
|
1700
1584
|
ret.push({
|
|
1701
|
-
code:
|
|
1585
|
+
code: 'CHK_MSG_PRG_FLD_060',
|
|
1702
1586
|
data: `invalid field type for ${field.data.field_id}`,
|
|
1703
|
-
type: doc.studio_meta.not_in_use ?
|
|
1704
|
-
category:
|
|
1587
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1588
|
+
category: 'fieldset',
|
|
1705
1589
|
ref: field.id,
|
|
1706
1590
|
id: `${doc._id}-${field.id}`,
|
|
1707
1591
|
});
|
|
@@ -1710,31 +1594,25 @@ const check_prog_fieldset = function (doc) {
|
|
|
1710
1594
|
}
|
|
1711
1595
|
}
|
|
1712
1596
|
|
|
1713
|
-
if (
|
|
1714
|
-
!field?.props?.fieldType &&
|
|
1715
|
-
!field?.props?.propExpressions?.fieldType
|
|
1716
|
-
) {
|
|
1597
|
+
if (!field?.props?.fieldType && !field?.props?.propExpressions?.fieldType) {
|
|
1717
1598
|
ret.push({
|
|
1718
|
-
code:
|
|
1599
|
+
code: 'CHK_MSG_PRG_FLD_130',
|
|
1719
1600
|
data: `missing field fieldType`,
|
|
1720
|
-
type: doc.studio_meta.not_in_use ?
|
|
1721
|
-
category:
|
|
1601
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1602
|
+
category: 'fieldset',
|
|
1722
1603
|
ref: field.id,
|
|
1723
1604
|
id: `${doc._id}-${field.id}`,
|
|
1724
1605
|
});
|
|
1725
1606
|
return ret;
|
|
1726
1607
|
} else if (field.props.fieldType) {
|
|
1727
1608
|
switch (field.props.fieldType) {
|
|
1728
|
-
case
|
|
1729
|
-
if (
|
|
1730
|
-
field?.props?.fieldValue &&
|
|
1731
|
-
typeof field.props.fieldValue !== "string"
|
|
1732
|
-
) {
|
|
1609
|
+
case 'string':
|
|
1610
|
+
if (field?.props?.fieldValue && typeof field.props.fieldValue !== 'string') {
|
|
1733
1611
|
ret.push({
|
|
1734
|
-
code:
|
|
1612
|
+
code: 'CHK_MSG_PRG_FLD_200',
|
|
1735
1613
|
data: `invalid value type ${field.props.fieldType} for ${field.data.field_id} field`,
|
|
1736
|
-
type: doc.studio_meta.not_in_use ?
|
|
1737
|
-
category:
|
|
1614
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1615
|
+
category: 'fieldset',
|
|
1738
1616
|
ref: field.id,
|
|
1739
1617
|
id: `${doc._id}-${field.id}`,
|
|
1740
1618
|
});
|
|
@@ -1742,15 +1620,15 @@ const check_prog_fieldset = function (doc) {
|
|
|
1742
1620
|
|
|
1743
1621
|
break;
|
|
1744
1622
|
|
|
1745
|
-
case
|
|
1746
|
-
case
|
|
1623
|
+
case 'number':
|
|
1624
|
+
case 'boolean':
|
|
1747
1625
|
if (field?.props?.fieldValue) {
|
|
1748
1626
|
if (_.isNaN(_.toNumber(field?.props?.fieldValue))) {
|
|
1749
1627
|
ret.push({
|
|
1750
|
-
code:
|
|
1628
|
+
code: 'CHK_MSG_PRG_FLD_210',
|
|
1751
1629
|
data: `invalid value type ${field.props.fieldType} for ${field.data.field_id} field`,
|
|
1752
|
-
type:
|
|
1753
|
-
category:
|
|
1630
|
+
type: 'E',
|
|
1631
|
+
category: 'fieldset',
|
|
1754
1632
|
ref: field.id,
|
|
1755
1633
|
id: `${doc._id}-${field.id}`,
|
|
1756
1634
|
});
|
|
@@ -1759,17 +1637,17 @@ const check_prog_fieldset = function (doc) {
|
|
|
1759
1637
|
|
|
1760
1638
|
break;
|
|
1761
1639
|
|
|
1762
|
-
case
|
|
1763
|
-
case
|
|
1640
|
+
case 'object':
|
|
1641
|
+
case 'array':
|
|
1764
1642
|
if (field?.props?.fieldValue) {
|
|
1765
1643
|
try {
|
|
1766
1644
|
JSON5.parse(field.props.fieldValue);
|
|
1767
1645
|
} catch (err) {
|
|
1768
1646
|
ret.push({
|
|
1769
|
-
code:
|
|
1647
|
+
code: 'CHK_MSG_PRG_FLD_220',
|
|
1770
1648
|
data: `invalid value type "${field.props.fieldType}" for "${field.data.field_id}" field`,
|
|
1771
|
-
type: doc.studio_meta.not_in_use ?
|
|
1772
|
-
category:
|
|
1649
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1650
|
+
category: 'fieldset',
|
|
1773
1651
|
ref: field.id,
|
|
1774
1652
|
id: `${doc._id}-${field.id}`,
|
|
1775
1653
|
});
|
|
@@ -1779,10 +1657,10 @@ const check_prog_fieldset = function (doc) {
|
|
|
1779
1657
|
|
|
1780
1658
|
default:
|
|
1781
1659
|
ret.push({
|
|
1782
|
-
code:
|
|
1660
|
+
code: 'CHK_MSG_PRG_FLD_160',
|
|
1783
1661
|
data: `invalid field fieldType for ${field.data.field_id}`,
|
|
1784
|
-
type: doc.studio_meta.not_in_use ?
|
|
1785
|
-
category:
|
|
1662
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1663
|
+
category: 'fieldset',
|
|
1786
1664
|
ref: field.id,
|
|
1787
1665
|
id: `${doc._id}-${field.id}`,
|
|
1788
1666
|
});
|
|
@@ -1795,26 +1673,17 @@ const check_prog_fieldset = function (doc) {
|
|
|
1795
1673
|
// propExpressions
|
|
1796
1674
|
|
|
1797
1675
|
if (!_.isEmpty(field.triggers)) {
|
|
1798
|
-
ret = [
|
|
1799
|
-
...ret,
|
|
1800
|
-
...check_prog_triggers(
|
|
1801
|
-
doc,
|
|
1802
|
-
field.triggers,
|
|
1803
|
-
"field",
|
|
1804
|
-
field.id,
|
|
1805
|
-
field.data.field_id
|
|
1806
|
-
),
|
|
1807
|
-
];
|
|
1676
|
+
ret = [...ret, ...check_prog_triggers(doc, field.triggers, 'field', field.id, field.data.field_id)];
|
|
1808
1677
|
}
|
|
1809
1678
|
}
|
|
1810
1679
|
|
|
1811
1680
|
for (let [key, val] of Object.entries(name_counts_obj)) {
|
|
1812
1681
|
if (val > 1) {
|
|
1813
1682
|
ret.push({
|
|
1814
|
-
code:
|
|
1683
|
+
code: 'CHK_MSG_PRG_FLD_200',
|
|
1815
1684
|
data: `duplicate field id for ${key}`,
|
|
1816
|
-
type: doc.studio_meta.not_in_use ?
|
|
1817
|
-
category:
|
|
1685
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1686
|
+
category: 'fieldset',
|
|
1818
1687
|
id: `${doc._id}-${field.id}-${key}`,
|
|
1819
1688
|
});
|
|
1820
1689
|
}
|
|
@@ -1830,13 +1699,13 @@ const check_prog_events = function (doc) {
|
|
|
1830
1699
|
var name_counts_obj = {};
|
|
1831
1700
|
for (let event_item of doc.progEvents) {
|
|
1832
1701
|
switch (event_item?.data?.type) {
|
|
1833
|
-
case
|
|
1702
|
+
case 'user_defined':
|
|
1834
1703
|
if (!event_item.data.event_name) {
|
|
1835
1704
|
ret.push({
|
|
1836
|
-
code:
|
|
1705
|
+
code: 'CHK_MSG_PRG_EVT_010',
|
|
1837
1706
|
data: `missing event name for ${event_item.id}`,
|
|
1838
|
-
type:
|
|
1839
|
-
category:
|
|
1707
|
+
type: 'W',
|
|
1708
|
+
category: 'event',
|
|
1840
1709
|
ref: event_item.id,
|
|
1841
1710
|
id: `${doc._id}-${event_item.id}`,
|
|
1842
1711
|
});
|
|
@@ -1844,11 +1713,10 @@ const check_prog_events = function (doc) {
|
|
|
1844
1713
|
} else {
|
|
1845
1714
|
if (!/^[A-Za-z]+[\w\-\:\.]*$/.test(event_item.data.event_name)) {
|
|
1846
1715
|
ret.push({
|
|
1847
|
-
code:
|
|
1848
|
-
data: `invalid event name for event "${event_item.data.event_name || event_item.data.type
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
category: "event",
|
|
1716
|
+
code: 'CHK_MSG_PRG_EVT_020',
|
|
1717
|
+
data: `invalid event name for event "${event_item.data.event_name || event_item.data.type}"`,
|
|
1718
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1719
|
+
category: 'event',
|
|
1852
1720
|
ref: event_item.id,
|
|
1853
1721
|
id: `${doc._id}-${event_item.id}`,
|
|
1854
1722
|
});
|
|
@@ -1856,19 +1724,14 @@ const check_prog_events = function (doc) {
|
|
|
1856
1724
|
|
|
1857
1725
|
// search if in use
|
|
1858
1726
|
if (!hide_not_in_use_check) {
|
|
1859
|
-
const ret_event_id_use = find_trigger_property_value_in_progs(
|
|
1860
|
-
doc,
|
|
1861
|
-
["raise_event"],
|
|
1862
|
-
"event",
|
|
1863
|
-
event_item.data.event_name
|
|
1864
|
-
);
|
|
1727
|
+
const ret_event_id_use = find_trigger_property_value_in_progs(doc, ['raise_event'], 'event', event_item.data.event_name);
|
|
1865
1728
|
|
|
1866
1729
|
if (!ret_event_id_use?.length) {
|
|
1867
1730
|
ret.push({
|
|
1868
|
-
code:
|
|
1731
|
+
code: 'CHK_MSG_PRG_EVT_112',
|
|
1869
1732
|
data: `event "${event_item.data.event_name}" not in use`,
|
|
1870
|
-
type:
|
|
1871
|
-
category:
|
|
1733
|
+
type: 'W',
|
|
1734
|
+
category: 'event',
|
|
1872
1735
|
ref: event_item.id,
|
|
1873
1736
|
not_in_use: true,
|
|
1874
1737
|
id: `${doc._id}-${event_item.id}`,
|
|
@@ -1878,15 +1741,7 @@ const check_prog_events = function (doc) {
|
|
|
1878
1741
|
}
|
|
1879
1742
|
|
|
1880
1743
|
if (event_item.data.condition) {
|
|
1881
|
-
ret = [
|
|
1882
|
-
...ret,
|
|
1883
|
-
...check_prog_expression(
|
|
1884
|
-
doc,
|
|
1885
|
-
event_item.data.condition,
|
|
1886
|
-
event_item.id,
|
|
1887
|
-
"condition"
|
|
1888
|
-
),
|
|
1889
|
-
];
|
|
1744
|
+
ret = [...ret, ...check_prog_expression(doc, event_item.data.condition, event_item.id, 'condition')];
|
|
1890
1745
|
} else {
|
|
1891
1746
|
if (!name_counts_obj[event_item.id]) {
|
|
1892
1747
|
name_counts_obj[event_item.id] = 1;
|
|
@@ -1898,31 +1753,25 @@ const check_prog_events = function (doc) {
|
|
|
1898
1753
|
// validate parameters TBD
|
|
1899
1754
|
break;
|
|
1900
1755
|
|
|
1901
|
-
case
|
|
1902
|
-
case
|
|
1903
|
-
if (doc.properties.menuType !==
|
|
1756
|
+
case 'screen_ready':
|
|
1757
|
+
case 'client_interval':
|
|
1758
|
+
if (doc.properties.menuType !== 'component') {
|
|
1904
1759
|
ret.push({
|
|
1905
|
-
code:
|
|
1906
|
-
data: `event type "${event_item.data.type}" only allowed for "${doc.properties.menuType
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
type: doc.studio_meta.not_in_use ? "W" : "E",
|
|
1910
|
-
category: "event",
|
|
1760
|
+
code: 'CHK_MSG_PRG_EVT_030',
|
|
1761
|
+
data: `event type "${event_item.data.type}" only allowed for "${doc.properties.menuType}" in event "${event_item.data.event_name || event_item.data.type}"`,
|
|
1762
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1763
|
+
category: 'event',
|
|
1911
1764
|
ref: event_item.id,
|
|
1912
1765
|
id: `${doc._id}-${event_item.id}`,
|
|
1913
1766
|
});
|
|
1914
1767
|
}
|
|
1915
1768
|
|
|
1916
|
-
if (
|
|
1917
|
-
event_item.data.type === "client_interval" &&
|
|
1918
|
-
!event_item.data.properties
|
|
1919
|
-
) {
|
|
1769
|
+
if (event_item.data.type === 'client_interval' && !event_item.data.properties) {
|
|
1920
1770
|
ret.push({
|
|
1921
|
-
code:
|
|
1922
|
-
data: `empty interval property in event "${event_item.data.event_name || event_item.data.type
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
category: "event",
|
|
1771
|
+
code: 'CHK_MSG_PRG_EVT_035',
|
|
1772
|
+
data: `empty interval property in event "${event_item.data.event_name || event_item.data.type}"`,
|
|
1773
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1774
|
+
category: 'event',
|
|
1926
1775
|
ref: event_item.id,
|
|
1927
1776
|
id: `${doc._id}-${event_item.id}`,
|
|
1928
1777
|
});
|
|
@@ -1932,20 +1781,20 @@ const check_prog_events = function (doc) {
|
|
|
1932
1781
|
|
|
1933
1782
|
// case "after_init":
|
|
1934
1783
|
// case "before_close":
|
|
1935
|
-
case
|
|
1936
|
-
case
|
|
1937
|
-
case
|
|
1938
|
-
case
|
|
1939
|
-
case
|
|
1940
|
-
case
|
|
1784
|
+
case 'on_load':
|
|
1785
|
+
case 'on_exit':
|
|
1786
|
+
case 'before_record':
|
|
1787
|
+
case 'after_record':
|
|
1788
|
+
case 'record_not_found':
|
|
1789
|
+
case 'locate_not_found':
|
|
1941
1790
|
break;
|
|
1942
1791
|
|
|
1943
1792
|
default:
|
|
1944
1793
|
ret.push({
|
|
1945
|
-
code:
|
|
1794
|
+
code: 'CHK_MSG_PRG_EVT_018',
|
|
1946
1795
|
data: `invalid event type for ${event_item.id}`,
|
|
1947
|
-
type: doc.studio_meta.not_in_use ?
|
|
1948
|
-
category:
|
|
1796
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
1797
|
+
category: 'event',
|
|
1949
1798
|
ref: event_item.id,
|
|
1950
1799
|
id: `${doc._id}-${event_item.id}`,
|
|
1951
1800
|
});
|
|
@@ -1954,23 +1803,13 @@ const check_prog_events = function (doc) {
|
|
|
1954
1803
|
|
|
1955
1804
|
// check triggers
|
|
1956
1805
|
if (!_.isEmpty(event_item.triggers)) {
|
|
1957
|
-
ret = [
|
|
1958
|
-
...ret,
|
|
1959
|
-
...check_prog_triggers(
|
|
1960
|
-
doc,
|
|
1961
|
-
event_item.triggers,
|
|
1962
|
-
"event",
|
|
1963
|
-
event_item.id,
|
|
1964
|
-
event_item.data.event_name || event_item.data.type
|
|
1965
|
-
),
|
|
1966
|
-
];
|
|
1806
|
+
ret = [...ret, ...check_prog_triggers(doc, event_item.triggers, 'event', event_item.id, event_item.data.event_name || event_item.data.type)];
|
|
1967
1807
|
} else {
|
|
1968
1808
|
ret.push({
|
|
1969
|
-
code:
|
|
1970
|
-
data: `event "${event_item.data.event_name || event_item.data.type
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
category: "event",
|
|
1809
|
+
code: 'CHK_MSG_PRG_EVT_022',
|
|
1810
|
+
data: `event "${event_item.data.event_name || event_item.data.type}" is empty`,
|
|
1811
|
+
type: 'W',
|
|
1812
|
+
category: 'event',
|
|
1974
1813
|
ref: event_item.id,
|
|
1975
1814
|
id: `${doc._id}-${event_item.id}`,
|
|
1976
1815
|
});
|
|
@@ -1980,10 +1819,10 @@ const check_prog_events = function (doc) {
|
|
|
1980
1819
|
for (let [key, val] of Object.entries(name_counts_obj)) {
|
|
1981
1820
|
if (val > 1) {
|
|
1982
1821
|
ret.push({
|
|
1983
|
-
code:
|
|
1822
|
+
code: 'CHK_MSG_PRG_EVT_102',
|
|
1984
1823
|
data: `duplicate "${key}" event `,
|
|
1985
|
-
type:
|
|
1986
|
-
category:
|
|
1824
|
+
type: 'W',
|
|
1825
|
+
category: 'event',
|
|
1987
1826
|
id: `${doc._id}-${event_item.id}-${key}`,
|
|
1988
1827
|
});
|
|
1989
1828
|
}
|
|
@@ -1991,13 +1830,7 @@ const check_prog_events = function (doc) {
|
|
|
1991
1830
|
|
|
1992
1831
|
return ret;
|
|
1993
1832
|
};
|
|
1994
|
-
const check_prog_triggers = function (
|
|
1995
|
-
doc,
|
|
1996
|
-
triggers,
|
|
1997
|
-
source_type,
|
|
1998
|
-
source_id,
|
|
1999
|
-
source_name
|
|
2000
|
-
) {
|
|
1833
|
+
const check_prog_triggers = function (doc, triggers, source_type, source_id, source_name) {
|
|
2001
1834
|
var ret = [];
|
|
2002
1835
|
|
|
2003
1836
|
if (!triggers || _.isEmpty(triggers)) return ret;
|
|
@@ -2005,27 +1838,16 @@ const check_prog_triggers = function (
|
|
|
2005
1838
|
const check_target_program_parameters = function (trigger_item) {
|
|
2006
1839
|
if (!trigger_item.data.name.prog) return;
|
|
2007
1840
|
|
|
2008
|
-
const target_program_parameters_arr =
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
!_.isEmpty(trigger_item.data.name.parameters)
|
|
2014
|
-
) {
|
|
2015
|
-
for (let [key, val] of Object.entries(
|
|
2016
|
-
trigger_item.data.name.parameters
|
|
2017
|
-
)) {
|
|
2018
|
-
const param_ret = find_item_by_key(
|
|
2019
|
-
target_program_parameters_arr,
|
|
2020
|
-
"parameter",
|
|
2021
|
-
key
|
|
2022
|
-
);
|
|
1841
|
+
const target_program_parameters_arr = progs_obj?.[trigger_item.data.name.prog]?.properties?.progParams || [];
|
|
1842
|
+
|
|
1843
|
+
if (trigger_item?.data?.name?.parameters && !_.isEmpty(trigger_item.data.name.parameters)) {
|
|
1844
|
+
for (let [key, val] of Object.entries(trigger_item.data.name.parameters)) {
|
|
1845
|
+
const param_ret = find_item_by_key(target_program_parameters_arr, 'parameter', key);
|
|
2023
1846
|
if (_.isEmpty(param_ret)) {
|
|
2024
1847
|
ret.push({
|
|
2025
|
-
code:
|
|
2026
|
-
data: `parameter "${key}" not found in the target program "${progs_obj?.[trigger_item.data.name.prog].properties.menuName
|
|
2027
|
-
|
|
2028
|
-
type: "W",
|
|
1848
|
+
code: 'CHK_MSG_PRG_TRG_370',
|
|
1849
|
+
data: `parameter "${key}" not found in the target program "${progs_obj?.[trigger_item.data.name.prog].properties.menuName}" parameter list in ${source_type} "${source_name}" trigger`,
|
|
1850
|
+
type: 'W',
|
|
2029
1851
|
category: `${source_type}_trigger`,
|
|
2030
1852
|
ref: trigger_item.id,
|
|
2031
1853
|
source_id,
|
|
@@ -2033,23 +1855,15 @@ const check_prog_triggers = function (
|
|
|
2033
1855
|
});
|
|
2034
1856
|
return;
|
|
2035
1857
|
}
|
|
2036
|
-
if (param_ret.data.dir !==
|
|
2037
|
-
const ret_local_field = find_item_by_key(
|
|
2038
|
-
doc.progFields,
|
|
2039
|
-
"field_id",
|
|
2040
|
-
val.value
|
|
2041
|
-
);
|
|
1858
|
+
if (param_ret.data.dir !== 'in' && val.value) {
|
|
1859
|
+
const ret_local_field = find_item_by_key(doc.progFields, 'field_id', val.value);
|
|
2042
1860
|
|
|
2043
1861
|
if (!ret_local_field) {
|
|
2044
1862
|
let ret_parent_field;
|
|
2045
1863
|
const check_parent_program = function (prog_id) {
|
|
2046
1864
|
let parent_prog_id = progs_obj?.[prog_id]?.studio_meta?.parentId;
|
|
2047
1865
|
if (parent_prog_id && progs_obj?.[parent_prog_id]) {
|
|
2048
|
-
ret_parent_field = find_item_by_key(
|
|
2049
|
-
progs_obj?.[parent_prog_id]?.progFields || [],
|
|
2050
|
-
"field_id",
|
|
2051
|
-
val.value
|
|
2052
|
-
);
|
|
1866
|
+
ret_parent_field = find_item_by_key(progs_obj?.[parent_prog_id]?.progFields || [], 'field_id', val.value);
|
|
2053
1867
|
if (!ret_parent_field) {
|
|
2054
1868
|
return check_parent_program(parent_prog_id);
|
|
2055
1869
|
}
|
|
@@ -2057,17 +1871,13 @@ const check_prog_triggers = function (
|
|
|
2057
1871
|
};
|
|
2058
1872
|
check_parent_program(doc._id);
|
|
2059
1873
|
if (!ret_parent_field) {
|
|
2060
|
-
const ret_global_field = find_item_by_key(
|
|
2061
|
-
progs_obj?.[`global_${app_obj._id}`]?.progFields || [],
|
|
2062
|
-
"field_id",
|
|
2063
|
-
val.value
|
|
2064
|
-
);
|
|
1874
|
+
const ret_global_field = find_item_by_key(progs_obj?.[`global_${app_obj._id}`]?.progFields || [], 'field_id', val.value);
|
|
2065
1875
|
if (!ret_global_field) {
|
|
2066
1876
|
// not 100% warning field might found in a caller dataset, need to run all programs TBD
|
|
2067
1877
|
ret.push({
|
|
2068
|
-
code:
|
|
1878
|
+
code: 'CHK_MSG_PRG_TRG_372',
|
|
2069
1879
|
data: `"${val.value}" parameter "Out" not found in the program Dataset in ${source_type} "${source_name}" trigger`,
|
|
2070
|
-
type:
|
|
1880
|
+
type: 'W',
|
|
2071
1881
|
category: `${source_type}_trigger`,
|
|
2072
1882
|
ref: trigger_item.id,
|
|
2073
1883
|
source_id,
|
|
@@ -2092,10 +1902,9 @@ const check_prog_triggers = function (
|
|
|
2092
1902
|
// found parameters in the target program but empty in the calling program
|
|
2093
1903
|
if (target_program_parameters_arr.length) {
|
|
2094
1904
|
ret.push({
|
|
2095
|
-
code:
|
|
2096
|
-
data: `found parameters in "${progs_obj?.[trigger_item.data.name.prog].properties.menuName
|
|
2097
|
-
|
|
2098
|
-
type: "W",
|
|
1905
|
+
code: 'CHK_MSG_PRG_TRG_374',
|
|
1906
|
+
data: `found parameters in "${progs_obj?.[trigger_item.data.name.prog].properties.menuName}" but empty parameter to exchange in ${source_type} "${source_name}" trigger`,
|
|
1907
|
+
type: 'W',
|
|
2099
1908
|
category: `${source_type}_trigger`,
|
|
2100
1909
|
ref: trigger_item.id,
|
|
2101
1910
|
source_id,
|
|
@@ -2108,23 +1917,19 @@ const check_prog_triggers = function (
|
|
|
2108
1917
|
for (let trigger_item of triggers) {
|
|
2109
1918
|
const get_prog_id = function () {
|
|
2110
1919
|
let _prop = trigger_item.data?.name?.properties;
|
|
2111
|
-
let _prog_id = trigger_item.data.name.prog_id || _prop?.[
|
|
1920
|
+
let _prog_id = trigger_item.data.name.prog_id || _prop?.['xu-exp:prog'];
|
|
2112
1921
|
|
|
2113
1922
|
return _prog_id;
|
|
2114
1923
|
};
|
|
2115
1924
|
|
|
2116
|
-
const err_type = doc.studio_meta.not_in_use
|
|
2117
|
-
? "W"
|
|
2118
|
-
: trigger_item.data.enabled
|
|
2119
|
-
? "E"
|
|
2120
|
-
: "W";
|
|
1925
|
+
const err_type = doc.studio_meta.not_in_use ? 'W' : trigger_item.data.enabled ? 'E' : 'W';
|
|
2121
1926
|
switch (trigger_item?.data?.action) {
|
|
2122
|
-
case
|
|
1927
|
+
case 'comment':
|
|
2123
1928
|
break;
|
|
2124
|
-
case
|
|
1929
|
+
case 'update':
|
|
2125
1930
|
if (!trigger_item?.data?.name?.value) {
|
|
2126
1931
|
ret.push({
|
|
2127
|
-
code:
|
|
1932
|
+
code: 'CHK_MSG_PRG_TRG_020',
|
|
2128
1933
|
data: `no value to update in ${source_type} "${source_name}" trigger`,
|
|
2129
1934
|
type: err_type,
|
|
2130
1935
|
category: `${source_type}_trigger`,
|
|
@@ -2146,7 +1951,7 @@ const check_prog_triggers = function (
|
|
|
2146
1951
|
var viewFields = [];
|
|
2147
1952
|
try {
|
|
2148
1953
|
// parse json
|
|
2149
|
-
var json = JSON5.parse(exp.replace(/\n/gi,
|
|
1954
|
+
var json = JSON5.parse(exp.replace(/\n/gi, ''));
|
|
2150
1955
|
for (const [key, val] of Object.entries(json)) {
|
|
2151
1956
|
let id = key.substr(1, key.length - 1);
|
|
2152
1957
|
viewFields.push({
|
|
@@ -2159,13 +1964,12 @@ const check_prog_triggers = function (
|
|
|
2159
1964
|
if (!exp) {
|
|
2160
1965
|
return;
|
|
2161
1966
|
}
|
|
2162
|
-
if (exp.substr(exp.length - 1, 1) ===
|
|
2163
|
-
exp = exp.substr(0, exp.length - 1); // remove closing if exist;
|
|
1967
|
+
if (exp.substr(exp.length - 1, 1) === ';') exp = exp.substr(0, exp.length - 1); // remove closing if exist;
|
|
2164
1968
|
var exp_arr = exp.split(/;\s*(?=(?:[^"]|"[^"]*")*$)/g); // split ; outside quotes
|
|
2165
1969
|
if (exp_arr?.length) {
|
|
2166
1970
|
for (let val of exp_arr) {
|
|
2167
1971
|
// run view fields
|
|
2168
|
-
var pos = val.indexOf(
|
|
1972
|
+
var pos = val.indexOf(':');
|
|
2169
1973
|
var seg = [val.substring(0, pos), val.substring(pos + 1)];
|
|
2170
1974
|
if (seg && seg.length === 2) {
|
|
2171
1975
|
let id = seg[0].substr(1, seg[0].length);
|
|
@@ -2176,7 +1980,7 @@ const check_prog_triggers = function (
|
|
|
2176
1980
|
});
|
|
2177
1981
|
} else {
|
|
2178
1982
|
ret.push({
|
|
2179
|
-
code:
|
|
1983
|
+
code: 'CHK_MSG_PRG_TRG_040',
|
|
2180
1984
|
data: `invalid json; too many segments in${source_type} "${source_name}" trigger`,
|
|
2181
1985
|
type: err_type,
|
|
2182
1986
|
category: `${source_type}_trigger`,
|
|
@@ -2193,12 +1997,10 @@ const check_prog_triggers = function (
|
|
|
2193
1997
|
};
|
|
2194
1998
|
|
|
2195
1999
|
// check syntax
|
|
2196
|
-
const ret_update_fields_arr = validate_update_function(
|
|
2197
|
-
trigger_item.data.name.value
|
|
2198
|
-
);
|
|
2000
|
+
const ret_update_fields_arr = validate_update_function(trigger_item.data.name.value);
|
|
2199
2001
|
if (!ret_update_fields_arr.length) {
|
|
2200
2002
|
ret.push({
|
|
2201
|
-
code:
|
|
2003
|
+
code: 'CHK_MSG_PRG_TRG_050',
|
|
2202
2004
|
data: `no fields to update in ${source_type} "${source_name}" trigger`,
|
|
2203
2005
|
type: err_type,
|
|
2204
2006
|
category: `${source_type}_trigger`,
|
|
@@ -2211,7 +2013,7 @@ const check_prog_triggers = function (
|
|
|
2211
2013
|
const ret_fields = find_field_in_progs(doc, val.id);
|
|
2212
2014
|
if (!ret_fields) {
|
|
2213
2015
|
ret.push({
|
|
2214
|
-
code:
|
|
2016
|
+
code: 'CHK_MSG_PRG_TRG_060',
|
|
2215
2017
|
data: `field "${val.id}" not found in the project programs for update in ${source_type} "${source_name}" trigger`,
|
|
2216
2018
|
type: err_type,
|
|
2217
2019
|
category: `${source_type}_trigger`,
|
|
@@ -2226,14 +2028,11 @@ const check_prog_triggers = function (
|
|
|
2226
2028
|
|
|
2227
2029
|
break;
|
|
2228
2030
|
|
|
2229
|
-
case
|
|
2031
|
+
case 'raise_event':
|
|
2230
2032
|
// !trigger_item?.data?.name?.properties['xu-exp:event']
|
|
2231
|
-
if (
|
|
2232
|
-
!trigger_item?.data?.name?.event &&
|
|
2233
|
-
!trigger_item?.data?.name?.properties["xu-exp:event"]
|
|
2234
|
-
) {
|
|
2033
|
+
if (!trigger_item?.data?.name?.event && !trigger_item?.data?.name?.properties['xu-exp:event']) {
|
|
2235
2034
|
ret.push({
|
|
2236
|
-
code:
|
|
2035
|
+
code: 'CHK_MSG_PRG_TRG_100',
|
|
2237
2036
|
data: `invalid event name for "${trigger_item.data.action}" in ${source_type} "${source_name}" trigger`,
|
|
2238
2037
|
type: err_type,
|
|
2239
2038
|
category: `${source_type}_trigger`,
|
|
@@ -2244,7 +2043,7 @@ const check_prog_triggers = function (
|
|
|
2244
2043
|
} else if (trigger_item?.data?.name?.event) {
|
|
2245
2044
|
if (!/^[A-Za-z]+[\w\-\:\.]*$/.test(trigger_item.data.name.event)) {
|
|
2246
2045
|
ret.push({
|
|
2247
|
-
code:
|
|
2046
|
+
code: 'CHK_MSG_PRG_TRG_110',
|
|
2248
2047
|
data: `invalid event name ${trigger_item.data.name.event} in ${source_type} "${source_name}" trigger`,
|
|
2249
2048
|
type: err_type,
|
|
2250
2049
|
category: `${source_type}_trigger`,
|
|
@@ -2254,14 +2053,11 @@ const check_prog_triggers = function (
|
|
|
2254
2053
|
});
|
|
2255
2054
|
} else {
|
|
2256
2055
|
// check if event exist
|
|
2257
|
-
const ret_event_name = find_event_id_in_progs(
|
|
2258
|
-
doc,
|
|
2259
|
-
trigger_item.data.name.event
|
|
2260
|
-
);
|
|
2056
|
+
const ret_event_name = find_event_id_in_progs(doc, trigger_item.data.name.event);
|
|
2261
2057
|
|
|
2262
2058
|
if (!ret_event_name.length) {
|
|
2263
2059
|
ret.push({
|
|
2264
|
-
code:
|
|
2060
|
+
code: 'CHK_MSG_PRG_TRG_120',
|
|
2265
2061
|
data: `call performed to non exist event name called from "${trigger_item.data.name.event}" in ${source_type} "${source_name}" trigger`,
|
|
2266
2062
|
type: err_type,
|
|
2267
2063
|
category: `${source_type}_trigger`,
|
|
@@ -2271,27 +2067,14 @@ const check_prog_triggers = function (
|
|
|
2271
2067
|
});
|
|
2272
2068
|
} else {
|
|
2273
2069
|
// if exist check parameters
|
|
2274
|
-
if (
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
for (let [key, val] of Object.entries(
|
|
2279
|
-
trigger_item.data.name.parameters
|
|
2280
|
-
)) {
|
|
2281
|
-
if (
|
|
2282
|
-
_.isEmpty(progs_obj[ret_event_name[0].prog_id].progFields)
|
|
2283
|
-
) {
|
|
2284
|
-
if (
|
|
2285
|
-
!find_item_by_key(
|
|
2286
|
-
progs_obj[ret_event_name[0].prog_id].progFields,
|
|
2287
|
-
"field_id",
|
|
2288
|
-
key
|
|
2289
|
-
)
|
|
2290
|
-
) {
|
|
2070
|
+
if (ret_event_name.length === 1 && !_.isEmpty(trigger_item.data.name.parameters)) {
|
|
2071
|
+
for (let [key, val] of Object.entries(trigger_item.data.name.parameters)) {
|
|
2072
|
+
if (_.isEmpty(progs_obj[ret_event_name[0].prog_id].progFields)) {
|
|
2073
|
+
if (!find_item_by_key(progs_obj[ret_event_name[0].prog_id].progFields, 'field_id', key)) {
|
|
2291
2074
|
ret.push({
|
|
2292
|
-
code:
|
|
2075
|
+
code: 'CHK_MSG_PRG_TRG_130',
|
|
2293
2076
|
data: `parameter "${key}" not exist in the dataset of the target program called from event name "${trigger_item.data.name.event}" in ${source_type} "${source_name}" trigger`,
|
|
2294
|
-
type:
|
|
2077
|
+
type: 'W',
|
|
2295
2078
|
category: `${source_type}_trigger`,
|
|
2296
2079
|
ref: trigger_item.id,
|
|
2297
2080
|
source_id,
|
|
@@ -2306,13 +2089,13 @@ const check_prog_triggers = function (
|
|
|
2306
2089
|
}
|
|
2307
2090
|
break;
|
|
2308
2091
|
|
|
2309
|
-
case
|
|
2310
|
-
case
|
|
2311
|
-
case
|
|
2092
|
+
case 'call_page':
|
|
2093
|
+
case 'call_modal':
|
|
2094
|
+
case 'call_popover':
|
|
2312
2095
|
if (!trigger_item.data.name.prog) {
|
|
2313
|
-
if (!trigger_item.data?.name?.properties?.[
|
|
2096
|
+
if (!trigger_item.data?.name?.properties?.['xu-exp:prog']) {
|
|
2314
2097
|
ret.push({
|
|
2315
|
-
code:
|
|
2098
|
+
code: 'CHK_MSG_PRG_TRG_310',
|
|
2316
2099
|
data: `empty program to call in ${source_type} "${source_name}" trigger`,
|
|
2317
2100
|
type: err_type,
|
|
2318
2101
|
category: `${source_type}_trigger`,
|
|
@@ -2324,7 +2107,7 @@ const check_prog_triggers = function (
|
|
|
2324
2107
|
} else {
|
|
2325
2108
|
if (!progs_obj[trigger_item.data.name.prog]) {
|
|
2326
2109
|
ret.push({
|
|
2327
|
-
code:
|
|
2110
|
+
code: 'CHK_MSG_PRG_TRG_320',
|
|
2328
2111
|
data: `invalid program to call in ${source_type} "${source_name}" trigger`,
|
|
2329
2112
|
type: err_type,
|
|
2330
2113
|
category: `${source_type}_trigger`,
|
|
@@ -2334,12 +2117,9 @@ const check_prog_triggers = function (
|
|
|
2334
2117
|
});
|
|
2335
2118
|
} else {
|
|
2336
2119
|
// validate call to component
|
|
2337
|
-
if (
|
|
2338
|
-
progs_obj[trigger_item.data.name.prog].properties.menuType !==
|
|
2339
|
-
"component"
|
|
2340
|
-
) {
|
|
2120
|
+
if (progs_obj[trigger_item.data.name.prog].properties.menuType !== 'component') {
|
|
2341
2121
|
ret.push({
|
|
2342
|
-
code:
|
|
2122
|
+
code: 'CHK_MSG_PRG_TRG_334',
|
|
2343
2123
|
data: `invalid program type "${trigger_item.data.action}" to call in ${source_type} "${source_name}" trigger`,
|
|
2344
2124
|
type: err_type,
|
|
2345
2125
|
category: `${source_type}_trigger`,
|
|
@@ -2356,11 +2136,11 @@ const check_prog_triggers = function (
|
|
|
2356
2136
|
|
|
2357
2137
|
break;
|
|
2358
2138
|
|
|
2359
|
-
case
|
|
2139
|
+
case 'call_project_api':
|
|
2360
2140
|
if (!trigger_item.data.name.prog) {
|
|
2361
|
-
if (!trigger_item.data?.name?.properties?.[
|
|
2141
|
+
if (!trigger_item.data?.name?.properties?.['xu-exp:prog']) {
|
|
2362
2142
|
ret.push({
|
|
2363
|
-
code:
|
|
2143
|
+
code: 'CHK_MSG_PRG_TRG_310',
|
|
2364
2144
|
data: `empty program to call in ${source_type} "${source_name}" trigger`,
|
|
2365
2145
|
type: err_type,
|
|
2366
2146
|
category: `${source_type}_trigger`,
|
|
@@ -2372,7 +2152,7 @@ const check_prog_triggers = function (
|
|
|
2372
2152
|
} else {
|
|
2373
2153
|
if (!progs_obj[trigger_item.data.name.prog]) {
|
|
2374
2154
|
ret.push({
|
|
2375
|
-
code:
|
|
2155
|
+
code: 'CHK_MSG_PRG_TRG_320',
|
|
2376
2156
|
data: `invalid program to call in ${source_type} "${source_name}" trigger`,
|
|
2377
2157
|
type: err_type,
|
|
2378
2158
|
category: `${source_type}_trigger`,
|
|
@@ -2382,12 +2162,9 @@ const check_prog_triggers = function (
|
|
|
2382
2162
|
});
|
|
2383
2163
|
} else {
|
|
2384
2164
|
// validate call to component
|
|
2385
|
-
if (
|
|
2386
|
-
progs_obj[trigger_item.data.name.prog].properties.menuType !==
|
|
2387
|
-
"api"
|
|
2388
|
-
) {
|
|
2165
|
+
if (progs_obj[trigger_item.data.name.prog].properties.menuType !== 'api') {
|
|
2389
2166
|
ret.push({
|
|
2390
|
-
code:
|
|
2167
|
+
code: 'CHK_MSG_PRG_TRG_334',
|
|
2391
2168
|
data: `invalid program type "${trigger_item.data.action}" to call in ${source_type} "${source_name}" trigger`,
|
|
2392
2169
|
type: err_type,
|
|
2393
2170
|
category: `${source_type}_trigger`,
|
|
@@ -2418,11 +2195,11 @@ const check_prog_triggers = function (
|
|
|
2418
2195
|
|
|
2419
2196
|
break;
|
|
2420
2197
|
|
|
2421
|
-
case
|
|
2198
|
+
case 'call_system_api': {
|
|
2422
2199
|
const _api_method = trigger_item.data.name.api_method;
|
|
2423
2200
|
if (!_api_method) {
|
|
2424
2201
|
ret.push({
|
|
2425
|
-
code:
|
|
2202
|
+
code: 'CHK_MSG_PRG_TRG_380',
|
|
2426
2203
|
data: `api_method not defined in ${source_type} "${source_name}" trigger`,
|
|
2427
2204
|
type: err_type,
|
|
2428
2205
|
category: `${source_type}_trigger`,
|
|
@@ -2431,10 +2208,10 @@ const check_prog_triggers = function (
|
|
|
2431
2208
|
id: `${doc._id}-${source_id}-${trigger_item.id}`,
|
|
2432
2209
|
});
|
|
2433
2210
|
} else {
|
|
2434
|
-
if (typeof _conf !==
|
|
2211
|
+
if (typeof _conf !== 'undefined') {
|
|
2435
2212
|
if (!_conf.cpi_methods[_api_method]) {
|
|
2436
2213
|
ret.push({
|
|
2437
|
-
code:
|
|
2214
|
+
code: 'CHK_MSG_PRG_TRG_382',
|
|
2438
2215
|
data: `api method ${_api_method} unrecognized in ${source_type} "${source_name}" trigger`,
|
|
2439
2216
|
type: err_type,
|
|
2440
2217
|
category: `${source_type}_trigger`,
|
|
@@ -2445,7 +2222,7 @@ const check_prog_triggers = function (
|
|
|
2445
2222
|
} else {
|
|
2446
2223
|
if (_conf.cpi_methods[_api_method].private) {
|
|
2447
2224
|
return ret.push({
|
|
2448
|
-
code:
|
|
2225
|
+
code: 'CHK_MSG_PRG_TRG_384',
|
|
2449
2226
|
data: `api method ${_api_method} is private in ${source_type} "${source_name}" trigger`,
|
|
2450
2227
|
type: err_type,
|
|
2451
2228
|
category: `${source_type}_trigger`,
|
|
@@ -2455,15 +2232,10 @@ const check_prog_triggers = function (
|
|
|
2455
2232
|
});
|
|
2456
2233
|
}
|
|
2457
2234
|
if (_conf.cpi_methods[_api_method].fields) {
|
|
2458
|
-
for (let [key, val] of Object.entries(
|
|
2459
|
-
|
|
2460
|
-
)) {
|
|
2461
|
-
if (
|
|
2462
|
-
val.mandatory &&
|
|
2463
|
-
!trigger_item.data.name?.payload?.[key]
|
|
2464
|
-
) {
|
|
2235
|
+
for (let [key, val] of Object.entries(_conf.cpi_methods[_api_method].fields)) {
|
|
2236
|
+
if (val.mandatory && !trigger_item.data.name?.payload?.[key]) {
|
|
2465
2237
|
ret.push({
|
|
2466
|
-
code:
|
|
2238
|
+
code: 'CHK_MSG_PRG_TRG_386',
|
|
2467
2239
|
data: `field ${key} for api method ${_api_method} is mandatory field in ${source_type} "${source_name}" trigger`,
|
|
2468
2240
|
type: err_type,
|
|
2469
2241
|
category: `${source_type}_trigger`,
|
|
@@ -2480,10 +2252,10 @@ const check_prog_triggers = function (
|
|
|
2480
2252
|
break;
|
|
2481
2253
|
}
|
|
2482
2254
|
|
|
2483
|
-
case
|
|
2255
|
+
case 'call_external_api': {
|
|
2484
2256
|
if (!trigger_item.data.name.method) {
|
|
2485
2257
|
ret.push({
|
|
2486
|
-
code:
|
|
2258
|
+
code: 'CHK_MSG_PRG_TRG_388',
|
|
2487
2259
|
data: `method not defined in ${source_type} "${source_name}" trigger`,
|
|
2488
2260
|
type: err_type,
|
|
2489
2261
|
category: `${source_type}_trigger`,
|
|
@@ -2495,7 +2267,7 @@ const check_prog_triggers = function (
|
|
|
2495
2267
|
|
|
2496
2268
|
if (!trigger_item.data.name.url) {
|
|
2497
2269
|
ret.push({
|
|
2498
|
-
code:
|
|
2270
|
+
code: 'CHK_MSG_PRG_TRG_389',
|
|
2499
2271
|
data: `url not defined in ${source_type} "${source_name}" trigger`,
|
|
2500
2272
|
type: err_type,
|
|
2501
2273
|
category: `${source_type}_trigger`,
|
|
@@ -2507,17 +2279,17 @@ const check_prog_triggers = function (
|
|
|
2507
2279
|
break;
|
|
2508
2280
|
}
|
|
2509
2281
|
|
|
2510
|
-
case
|
|
2511
|
-
case
|
|
2512
|
-
case
|
|
2513
|
-
case
|
|
2514
|
-
case
|
|
2515
|
-
case
|
|
2282
|
+
case 'get_data':
|
|
2283
|
+
case 'set_data':
|
|
2284
|
+
case 'batch':
|
|
2285
|
+
case 'call_native_javascript':
|
|
2286
|
+
case 'call_evaluate_javascript':
|
|
2287
|
+
case 'call_alert':
|
|
2516
2288
|
// check program exist
|
|
2517
2289
|
if (!trigger_item.data.name.prog) {
|
|
2518
|
-
if (!trigger_item.data?.name?.properties?.[
|
|
2290
|
+
if (!trigger_item.data?.name?.properties?.['xu-exp:prog']) {
|
|
2519
2291
|
ret.push({
|
|
2520
|
-
code:
|
|
2292
|
+
code: 'CHK_MSG_PRG_TRG_310',
|
|
2521
2293
|
data: `empty program to call in ${source_type} "${source_name}" trigger`,
|
|
2522
2294
|
type: err_type,
|
|
2523
2295
|
category: `${source_type}_trigger`,
|
|
@@ -2529,7 +2301,7 @@ const check_prog_triggers = function (
|
|
|
2529
2301
|
} else {
|
|
2530
2302
|
if (!progs_obj[trigger_item.data.name.prog]) {
|
|
2531
2303
|
ret.push({
|
|
2532
|
-
code:
|
|
2304
|
+
code: 'CHK_MSG_PRG_TRG_320',
|
|
2533
2305
|
data: `invalid program to call in ${source_type} "${source_name}" trigger`,
|
|
2534
2306
|
type: err_type,
|
|
2535
2307
|
category: `${source_type}_trigger`,
|
|
@@ -2539,32 +2311,18 @@ const check_prog_triggers = function (
|
|
|
2539
2311
|
});
|
|
2540
2312
|
} else {
|
|
2541
2313
|
// validate call to the same menuType
|
|
2542
|
-
if (
|
|
2543
|
-
progs_obj[trigger_item.data.name.prog].properties.menuType
|
|
2544
|
-
trigger_item.data.action
|
|
2545
|
-
) {
|
|
2546
|
-
if (
|
|
2547
|
-
["call_native_javascript", "call_evaluate_javascript"].includes(
|
|
2548
|
-
trigger_item.data.action
|
|
2549
|
-
) &&
|
|
2550
|
-
progs_obj[trigger_item.data.name.prog].properties.menuType ===
|
|
2551
|
-
"javascript"
|
|
2552
|
-
) {
|
|
2314
|
+
if (progs_obj[trigger_item.data.name.prog].properties.menuType !== trigger_item.data.action) {
|
|
2315
|
+
if (['call_native_javascript', 'call_evaluate_javascript'].includes(trigger_item.data.action) && progs_obj[trigger_item.data.name.prog].properties.menuType === 'javascript') {
|
|
2553
2316
|
continue;
|
|
2554
2317
|
}
|
|
2555
2318
|
|
|
2556
|
-
if (
|
|
2557
|
-
["call_alert"].includes(trigger_item.data.action) &&
|
|
2558
|
-
progs_obj[trigger_item.data.name.prog].properties.menuType ===
|
|
2559
|
-
"alert"
|
|
2560
|
-
) {
|
|
2319
|
+
if (['call_alert'].includes(trigger_item.data.action) && progs_obj[trigger_item.data.name.prog].properties.menuType === 'alert') {
|
|
2561
2320
|
continue;
|
|
2562
2321
|
}
|
|
2563
2322
|
|
|
2564
2323
|
ret.push({
|
|
2565
|
-
code:
|
|
2566
|
-
data: `call set to "${trigger_item.data.action}" but found "${progs_obj[trigger_item.data.name.prog].properties.menuType
|
|
2567
|
-
}" instead in ${source_type} "${source_name}" trigger`,
|
|
2324
|
+
code: 'CHK_MSG_PRG_TRG_330',
|
|
2325
|
+
data: `call set to "${trigger_item.data.action}" but found "${progs_obj[trigger_item.data.name.prog].properties.menuType}" instead in ${source_type} "${source_name}" trigger`,
|
|
2568
2326
|
type: err_type,
|
|
2569
2327
|
category: `${source_type}_trigger`,
|
|
2570
2328
|
ref: trigger_item.id,
|
|
@@ -2580,23 +2338,18 @@ const check_prog_triggers = function (
|
|
|
2580
2338
|
|
|
2581
2339
|
break;
|
|
2582
2340
|
|
|
2583
|
-
case
|
|
2584
|
-
case
|
|
2341
|
+
case 'execute_native_javascript':
|
|
2342
|
+
case 'execute_evaluate_javascript':
|
|
2585
2343
|
// validate script
|
|
2586
2344
|
|
|
2587
|
-
check_prog_expression(
|
|
2588
|
-
doc,
|
|
2589
|
-
trigger_item.data.name.value,
|
|
2590
|
-
trigger_item.id,
|
|
2591
|
-
"script"
|
|
2592
|
-
);
|
|
2345
|
+
check_prog_expression(doc, trigger_item.data.name.value, trigger_item.id, 'script');
|
|
2593
2346
|
|
|
2594
2347
|
break;
|
|
2595
2348
|
|
|
2596
|
-
case
|
|
2349
|
+
case 'emit_event':
|
|
2597
2350
|
if (!trigger_item?.data?.name?.value) {
|
|
2598
2351
|
ret.push({
|
|
2599
|
-
code:
|
|
2352
|
+
code: 'CHK_MSG_PRG_TRG_800',
|
|
2600
2353
|
data: `no event defined for "emit_event" in ${source_type} "${source_name}" trigger`,
|
|
2601
2354
|
type: err_type,
|
|
2602
2355
|
category: `alert`,
|
|
@@ -2606,7 +2359,7 @@ const check_prog_triggers = function (
|
|
|
2606
2359
|
} else {
|
|
2607
2360
|
if (!/^[A-Za-z]+[\w\-\:\.]*$/.test(trigger_item.data.name.value)) {
|
|
2608
2361
|
ret.push({
|
|
2609
|
-
code:
|
|
2362
|
+
code: 'CHK_MSG_PRG_TRG_810',
|
|
2610
2363
|
data: `invalid event name ${trigger_item.data.name.value} in ${source_type} "${source_name}" trigger`,
|
|
2611
2364
|
type: err_type,
|
|
2612
2365
|
category: `${source_type}_trigger`,
|
|
@@ -2668,10 +2421,10 @@ const check_prog_triggers = function (
|
|
|
2668
2421
|
|
|
2669
2422
|
break;
|
|
2670
2423
|
|
|
2671
|
-
case
|
|
2424
|
+
case 'alert':
|
|
2672
2425
|
if (_.isEmpty(trigger_item.data.name)) {
|
|
2673
2426
|
ret.push({
|
|
2674
|
-
code:
|
|
2427
|
+
code: 'CHK_MSG_PRG_TRG_610',
|
|
2675
2428
|
data: `no alert properties defined`,
|
|
2676
2429
|
type: err_type,
|
|
2677
2430
|
category: `alert`,
|
|
@@ -2681,7 +2434,7 @@ const check_prog_triggers = function (
|
|
|
2681
2434
|
} else {
|
|
2682
2435
|
if (!trigger_item.data.name.alertType) {
|
|
2683
2436
|
ret.push({
|
|
2684
|
-
code:
|
|
2437
|
+
code: 'CHK_MSG_PRG_TRG_612',
|
|
2685
2438
|
data: `missing alert type property`,
|
|
2686
2439
|
type: err_type,
|
|
2687
2440
|
category: `alert`,
|
|
@@ -2691,7 +2444,7 @@ const check_prog_triggers = function (
|
|
|
2691
2444
|
}
|
|
2692
2445
|
if (!trigger_item.data.name.alertDisplay) {
|
|
2693
2446
|
ret.push({
|
|
2694
|
-
code:
|
|
2447
|
+
code: 'CHK_MSG_PRG_TRG_614',
|
|
2695
2448
|
data: `missing alert display property`,
|
|
2696
2449
|
type: err_type,
|
|
2697
2450
|
category: `alert`,
|
|
@@ -2701,9 +2454,9 @@ const check_prog_triggers = function (
|
|
|
2701
2454
|
}
|
|
2702
2455
|
if (!trigger_item.data.name.alertTitle) {
|
|
2703
2456
|
ret.push({
|
|
2704
|
-
code:
|
|
2457
|
+
code: 'CHK_MSG_PRG_TRG_616',
|
|
2705
2458
|
data: `missing alert title property`,
|
|
2706
|
-
type:
|
|
2459
|
+
type: 'W',
|
|
2707
2460
|
category: `alert`,
|
|
2708
2461
|
ref: doc._id,
|
|
2709
2462
|
id: `${doc._id}-${source_id}-${trigger_item.id}`,
|
|
@@ -2711,9 +2464,9 @@ const check_prog_triggers = function (
|
|
|
2711
2464
|
}
|
|
2712
2465
|
if (!trigger_item.data.name.alertBody) {
|
|
2713
2466
|
ret.push({
|
|
2714
|
-
code:
|
|
2467
|
+
code: 'CHK_MSG_PRG_TRG_618',
|
|
2715
2468
|
data: `missing alert body property`,
|
|
2716
|
-
type:
|
|
2469
|
+
type: 'W',
|
|
2717
2470
|
category: `alert`,
|
|
2718
2471
|
ref: doc._id,
|
|
2719
2472
|
id: `${doc._id}-${source_id}-${trigger_item.id}`,
|
|
@@ -2723,11 +2476,11 @@ const check_prog_triggers = function (
|
|
|
2723
2476
|
|
|
2724
2477
|
break;
|
|
2725
2478
|
|
|
2726
|
-
case
|
|
2727
|
-
case
|
|
2728
|
-
if (doc.properties.menuType !==
|
|
2479
|
+
case 'loader_on':
|
|
2480
|
+
case 'loader_off':
|
|
2481
|
+
if (doc.properties.menuType !== 'component') {
|
|
2729
2482
|
ret.push({
|
|
2730
|
-
code:
|
|
2483
|
+
code: 'CHK_MSG_PRG_TRG_400',
|
|
2731
2484
|
data: `"${trigger_item.data.action}" can only be executed by component in ${source_type} "${source_name}" trigger`,
|
|
2732
2485
|
type: err_type,
|
|
2733
2486
|
category: `${source_type}_trigger`,
|
|
@@ -2739,10 +2492,10 @@ const check_prog_triggers = function (
|
|
|
2739
2492
|
|
|
2740
2493
|
break;
|
|
2741
2494
|
|
|
2742
|
-
case
|
|
2743
|
-
if (doc.properties.menuType !==
|
|
2495
|
+
case 'invoke_action':
|
|
2496
|
+
if (doc.properties.menuType !== 'component') {
|
|
2744
2497
|
ret.push({
|
|
2745
|
-
code:
|
|
2498
|
+
code: 'CHK_MSG_PRG_TRG_400',
|
|
2746
2499
|
data: `"${trigger_item.data.action}" can only be executed by component in ${source_type} "${source_name}" trigger`,
|
|
2747
2500
|
type: err_type,
|
|
2748
2501
|
category: `${source_type}_trigger`,
|
|
@@ -2755,20 +2508,20 @@ const check_prog_triggers = function (
|
|
|
2755
2508
|
|
|
2756
2509
|
if (
|
|
2757
2510
|
![
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
"act_close",
|
|
2765
|
-
"act_back",
|
|
2766
|
-
|
|
2767
|
-
|
|
2511
|
+
'act_next',
|
|
2512
|
+
'act_prev',
|
|
2513
|
+
'act_first',
|
|
2514
|
+
'act_last',
|
|
2515
|
+
'act_reload',
|
|
2516
|
+
'act_refresh',
|
|
2517
|
+
// "act_close",
|
|
2518
|
+
// "act_back",
|
|
2519
|
+
'act_print',
|
|
2520
|
+
'act_save',
|
|
2768
2521
|
].includes(trigger_item.data.name.value)
|
|
2769
2522
|
) {
|
|
2770
2523
|
ret.push({
|
|
2771
|
-
code:
|
|
2524
|
+
code: 'CHK_MSG_PRG_TRG_400',
|
|
2772
2525
|
data: `invalid "${trigger_item.data.name.value}" for "${trigger_item.data.action}" in ${source_type} "${source_name}" trigger`,
|
|
2773
2526
|
type: err_type,
|
|
2774
2527
|
category: `${source_type}_trigger`,
|
|
@@ -2780,11 +2533,11 @@ const check_prog_triggers = function (
|
|
|
2780
2533
|
|
|
2781
2534
|
break;
|
|
2782
2535
|
|
|
2783
|
-
case
|
|
2536
|
+
case 'delay':
|
|
2784
2537
|
// validate time
|
|
2785
2538
|
if (!trigger_item?.data?.name?.value) {
|
|
2786
2539
|
ret.push({
|
|
2787
|
-
code:
|
|
2540
|
+
code: 'CHK_MSG_PRG_TRG_520',
|
|
2788
2541
|
data: `empty delay value in ${source_type} "${source_name}" trigger`,
|
|
2789
2542
|
type: err_type,
|
|
2790
2543
|
category: `${source_type}_trigger`,
|
|
@@ -2795,10 +2548,10 @@ const check_prog_triggers = function (
|
|
|
2795
2548
|
}
|
|
2796
2549
|
break;
|
|
2797
2550
|
|
|
2798
|
-
case
|
|
2551
|
+
case 'call_library':
|
|
2799
2552
|
if (!trigger_item?.data?.name?.plugin_name) {
|
|
2800
2553
|
ret.push({
|
|
2801
|
-
code:
|
|
2554
|
+
code: 'CHK_MSG_PRG_TRG_510',
|
|
2802
2555
|
data: `empty library value in ${source_type} "${source_name}" trigger`,
|
|
2803
2556
|
type: err_type,
|
|
2804
2557
|
category: `${source_type}_trigger`,
|
|
@@ -2809,7 +2562,7 @@ const check_prog_triggers = function (
|
|
|
2809
2562
|
} else {
|
|
2810
2563
|
if (!trigger_item?.data?.name?.library_method) {
|
|
2811
2564
|
ret.push({
|
|
2812
|
-
code:
|
|
2565
|
+
code: 'CHK_MSG_PRG_TRG_516',
|
|
2813
2566
|
data: `empty library ${trigger_item.data.name.plugin_name} method in ${source_type} "${source_name}" trigger`,
|
|
2814
2567
|
type: err_type,
|
|
2815
2568
|
category: `${source_type}_trigger`,
|
|
@@ -2819,13 +2572,9 @@ const check_prog_triggers = function (
|
|
|
2819
2572
|
});
|
|
2820
2573
|
}
|
|
2821
2574
|
|
|
2822
|
-
if (
|
|
2823
|
-
!app_obj?.app_plugins_purchased?.[
|
|
2824
|
-
trigger_item.data.name.plugin_name
|
|
2825
|
-
]
|
|
2826
|
-
) {
|
|
2575
|
+
if (!app_obj?.app_plugins_purchased?.[trigger_item.data.name.plugin_name]) {
|
|
2827
2576
|
ret.push({
|
|
2828
|
-
code:
|
|
2577
|
+
code: 'CHK_MSG_PRG_TRG_512',
|
|
2829
2578
|
data: `invalid library call ${trigger_item.data.name.plugin_name} in ${source_type} "${source_name}" trigger`,
|
|
2830
2579
|
type: err_type,
|
|
2831
2580
|
category: `${source_type}_trigger`,
|
|
@@ -2834,12 +2583,9 @@ const check_prog_triggers = function (
|
|
|
2834
2583
|
id: `${doc._id}-${source_id}-${trigger_item.id}`,
|
|
2835
2584
|
});
|
|
2836
2585
|
} else {
|
|
2837
|
-
if (
|
|
2838
|
-
!app_obj.app_plugins_purchased[trigger_item.data.name.plugin_name]
|
|
2839
|
-
.installed
|
|
2840
|
-
) {
|
|
2586
|
+
if (!app_obj.app_plugins_purchased[trigger_item.data.name.plugin_name].installed) {
|
|
2841
2587
|
ret.push({
|
|
2842
|
-
code:
|
|
2588
|
+
code: 'CHK_MSG_PRG_TRG_514',
|
|
2843
2589
|
data: ` library "${trigger_item.data.name.plugin_name}" not installed in ${source_type} "${source_name}" trigger`,
|
|
2844
2590
|
type: err_type,
|
|
2845
2591
|
category: `${source_type}_trigger`,
|
|
@@ -2853,15 +2599,15 @@ const check_prog_triggers = function (
|
|
|
2853
2599
|
|
|
2854
2600
|
break;
|
|
2855
2601
|
|
|
2856
|
-
case
|
|
2857
|
-
case
|
|
2858
|
-
case
|
|
2859
|
-
case
|
|
2860
|
-
case
|
|
2861
|
-
case
|
|
2862
|
-
case
|
|
2602
|
+
case 'alter_ui_element':
|
|
2603
|
+
case 'create_ui_element':
|
|
2604
|
+
case 'info_ui_element':
|
|
2605
|
+
case 'remove_ui_element':
|
|
2606
|
+
case 'empty_ui_element':
|
|
2607
|
+
case 'cache_ui_element':
|
|
2608
|
+
case 'load_ui_element':
|
|
2863
2609
|
ret.push({
|
|
2864
|
-
code:
|
|
2610
|
+
code: 'CHK_MSG_PRG_TRG_900',
|
|
2865
2611
|
data: `deprecated "${trigger_item?.data?.action}" action in ${source_type} "${source_name}" trigger`,
|
|
2866
2612
|
type: err_type,
|
|
2867
2613
|
category: `${source_type}_trigger`,
|
|
@@ -2873,7 +2619,7 @@ const check_prog_triggers = function (
|
|
|
2873
2619
|
|
|
2874
2620
|
default:
|
|
2875
2621
|
ret.push({
|
|
2876
|
-
code:
|
|
2622
|
+
code: 'CHK_MSG_PRG_TRG_008',
|
|
2877
2623
|
data: `invalid trigger type "${trigger_item.data.action}" for ${source_type} "${source_name}" trigger`,
|
|
2878
2624
|
type: err_type,
|
|
2879
2625
|
category: `${source_type}_trigger`,
|
|
@@ -2885,15 +2631,7 @@ const check_prog_triggers = function (
|
|
|
2885
2631
|
}
|
|
2886
2632
|
|
|
2887
2633
|
if (trigger_item.props.condition) {
|
|
2888
|
-
ret = [
|
|
2889
|
-
...ret,
|
|
2890
|
-
...check_prog_expression(
|
|
2891
|
-
doc,
|
|
2892
|
-
trigger_item.props.condition,
|
|
2893
|
-
trigger_item.id,
|
|
2894
|
-
"condition"
|
|
2895
|
-
),
|
|
2896
|
-
];
|
|
2634
|
+
ret = [...ret, ...check_prog_expression(doc, trigger_item.props.condition, trigger_item.id, 'condition')];
|
|
2897
2635
|
}
|
|
2898
2636
|
}
|
|
2899
2637
|
|
|
@@ -2902,37 +2640,26 @@ const check_prog_triggers = function (
|
|
|
2902
2640
|
const check_prog_datasource = function (doc) {
|
|
2903
2641
|
var ret = [];
|
|
2904
2642
|
|
|
2905
|
-
if (
|
|
2906
|
-
!doc.progDataSource ||
|
|
2907
|
-
_.isEmpty(doc.progDataSource) ||
|
|
2908
|
-
!doc.progDataSource.dataSourceType ||
|
|
2909
|
-
doc.progDataSource.dataSourceType === "none"
|
|
2910
|
-
) {
|
|
2643
|
+
if (!doc.progDataSource || _.isEmpty(doc.progDataSource) || !doc.progDataSource.dataSourceType || doc.progDataSource.dataSourceType === 'none') {
|
|
2911
2644
|
return ret;
|
|
2912
2645
|
}
|
|
2913
2646
|
|
|
2914
2647
|
switch (doc.progDataSource.dataSourceType) {
|
|
2915
|
-
case
|
|
2916
|
-
if (
|
|
2917
|
-
!doc.progDataSource.dataSourceTableId &&
|
|
2918
|
-
!doc?.progDataSource?.dataSourceTableIdExp
|
|
2919
|
-
) {
|
|
2648
|
+
case 'table':
|
|
2649
|
+
if (!doc.progDataSource.dataSourceTableId && !doc?.progDataSource?.dataSourceTableIdExp) {
|
|
2920
2650
|
ret.push({
|
|
2921
|
-
code:
|
|
2651
|
+
code: 'CHK_MSG_PRG_DSC_010',
|
|
2922
2652
|
data: `missing table id for datasource`,
|
|
2923
|
-
type:
|
|
2653
|
+
type: 'E',
|
|
2924
2654
|
id: `${doc._id}`,
|
|
2925
2655
|
});
|
|
2926
2656
|
return ret;
|
|
2927
2657
|
} else {
|
|
2928
|
-
if (
|
|
2929
|
-
doc.progDataSource.dataSourceTableId &&
|
|
2930
|
-
!progs_obj[doc.progDataSource.dataSourceTableId]
|
|
2931
|
-
) {
|
|
2658
|
+
if (doc.progDataSource.dataSourceTableId && !progs_obj[doc.progDataSource.dataSourceTableId]) {
|
|
2932
2659
|
ret.push({
|
|
2933
|
-
code:
|
|
2660
|
+
code: 'CHK_MSG_PRG_DSC_030',
|
|
2934
2661
|
data: `invalid table id ${doc.progDataSource.dataSourceTableId} for datasource`,
|
|
2935
|
-
type:
|
|
2662
|
+
type: 'E',
|
|
2936
2663
|
id: `${doc._id}`,
|
|
2937
2664
|
});
|
|
2938
2665
|
return ret;
|
|
@@ -2954,21 +2681,13 @@ const check_prog_datasource = function (doc) {
|
|
|
2954
2681
|
}
|
|
2955
2682
|
|
|
2956
2683
|
if (doc.progDataSource.dataSourceIndexesObj) {
|
|
2957
|
-
const table_indexes_arr =
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
doc.progDataSource.dataSourceIndexesObj
|
|
2961
|
-
)) {
|
|
2962
|
-
if (
|
|
2963
|
-
table_indexes_arr ||
|
|
2964
|
-
!find_item_by_id(table_indexes_arr, index_id)
|
|
2965
|
-
) {
|
|
2684
|
+
const table_indexes_arr = progs_obj?.[doc.progDataSource.dataSourceTableId]?.tableIndexes;
|
|
2685
|
+
for (let [index_id, index_data] of Object.entries(doc.progDataSource.dataSourceIndexesObj)) {
|
|
2686
|
+
if (table_indexes_arr || !find_item_by_id(table_indexes_arr, index_id)) {
|
|
2966
2687
|
ret.push({
|
|
2967
|
-
code:
|
|
2968
|
-
data: `find invalid index in table ${progs_obj?.[doc.progDataSource.dataSourceTableId]?.properties
|
|
2969
|
-
|
|
2970
|
-
} for index ${index_id} in dataSourceIndexesObj`,
|
|
2971
|
-
type: "E",
|
|
2688
|
+
code: 'CHK_MSG_PRG_DSC_032',
|
|
2689
|
+
data: `find invalid index in table ${progs_obj?.[doc.progDataSource.dataSourceTableId]?.properties?.menuName || doc.progDataSource.dataSourceTableId} for index ${index_id} in dataSourceIndexesObj`,
|
|
2690
|
+
type: 'E',
|
|
2972
2691
|
id: `${doc._id}`,
|
|
2973
2692
|
});
|
|
2974
2693
|
found_error = true;
|
|
@@ -2981,11 +2700,9 @@ const check_prog_datasource = function (doc) {
|
|
|
2981
2700
|
|
|
2982
2701
|
if (!arraysEqual(prog_keys, table_indexes_arr.keys)) {
|
|
2983
2702
|
ret.push({
|
|
2984
|
-
code:
|
|
2985
|
-
data: `find in-consist index keys in table ${progs_obj?.[doc.progDataSource.dataSourceTableId]?.properties
|
|
2986
|
-
|
|
2987
|
-
} for index ${index_id} in dataSourceIndexesObj`,
|
|
2988
|
-
type: "E",
|
|
2703
|
+
code: 'CHK_MSG_PRG_DSC_034',
|
|
2704
|
+
data: `find in-consist index keys in table ${progs_obj?.[doc.progDataSource.dataSourceTableId]?.properties?.menuName || doc.progDataSource.dataSourceTableId} for index ${index_id} in dataSourceIndexesObj`,
|
|
2705
|
+
type: 'E',
|
|
2989
2706
|
id: `${doc._id}`,
|
|
2990
2707
|
});
|
|
2991
2708
|
found_error = true;
|
|
@@ -2995,45 +2712,32 @@ const check_prog_datasource = function (doc) {
|
|
|
2995
2712
|
if (found_error) return ret;
|
|
2996
2713
|
}
|
|
2997
2714
|
}
|
|
2998
|
-
if (doc.properties.menuType !==
|
|
2715
|
+
if (doc.properties.menuType !== 'set_data') {
|
|
2999
2716
|
// check index
|
|
3000
|
-
if (
|
|
3001
|
-
!doc.progDataSource.dataSourceIndexId &&
|
|
3002
|
-
!doc.progDataSource.dataSourceIndexIdExp
|
|
3003
|
-
) {
|
|
2717
|
+
if (!doc.progDataSource.dataSourceIndexId && !doc.progDataSource.dataSourceIndexIdExp) {
|
|
3004
2718
|
ret.push({
|
|
3005
|
-
code:
|
|
2719
|
+
code: 'CHK_MSG_PRG_DSC_042',
|
|
3006
2720
|
data: `index not defined for the datasource table`,
|
|
3007
|
-
type:
|
|
2721
|
+
type: 'W',
|
|
3008
2722
|
id: `${doc._id}`,
|
|
3009
2723
|
});
|
|
3010
2724
|
} else if (doc.progDataSource.dataSourceIndexId) {
|
|
3011
|
-
if (
|
|
3012
|
-
!progs_obj?.[doc.progDataSource.dataSourceTableId]?.tableIndexes
|
|
3013
|
-
) {
|
|
2725
|
+
if (!progs_obj?.[doc.progDataSource.dataSourceTableId]?.tableIndexes) {
|
|
3014
2726
|
ret.push({
|
|
3015
|
-
code:
|
|
2727
|
+
code: 'CHK_MSG_PRG_DSC_030',
|
|
3016
2728
|
data: `invalid table id ${doc.progDataSource.dataSourceTableId} for datasource`,
|
|
3017
|
-
type:
|
|
2729
|
+
type: 'E',
|
|
3018
2730
|
id: `${doc._id}`,
|
|
3019
2731
|
});
|
|
3020
2732
|
return ret;
|
|
3021
2733
|
} else {
|
|
3022
|
-
const table_indexes_arr =
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
if (
|
|
3026
|
-
!find_item_by_id(
|
|
3027
|
-
table_indexes_arr,
|
|
3028
|
-
doc.progDataSource.dataSourceIndexId
|
|
3029
|
-
)
|
|
3030
|
-
) {
|
|
2734
|
+
const table_indexes_arr = progs_obj[doc.progDataSource.dataSourceTableId].tableIndexes;
|
|
2735
|
+
|
|
2736
|
+
if (!find_item_by_id(table_indexes_arr, doc.progDataSource.dataSourceIndexId)) {
|
|
3031
2737
|
ret.push({
|
|
3032
|
-
code:
|
|
3033
|
-
data: `invalid index in table ${progs_obj?.[doc.progDataSource.dataSourceTableId]?.properties
|
|
3034
|
-
|
|
3035
|
-
} for index ${doc.progDataSource.dataSourceIndexId}`,
|
|
3036
|
-
type: "E",
|
|
2738
|
+
code: 'CHK_MSG_PRG_DSC_040',
|
|
2739
|
+
data: `invalid index in table ${progs_obj?.[doc.progDataSource.dataSourceTableId]?.properties?.menuName || doc.progDataSource.dataSourceTableId} for index ${doc.progDataSource.dataSourceIndexId}`,
|
|
2740
|
+
type: 'E',
|
|
3037
2741
|
id: `${doc._id}`,
|
|
3038
2742
|
});
|
|
3039
2743
|
return ret;
|
|
@@ -3042,49 +2746,40 @@ const check_prog_datasource = function (doc) {
|
|
|
3042
2746
|
}
|
|
3043
2747
|
|
|
3044
2748
|
// check sort
|
|
3045
|
-
if (
|
|
3046
|
-
!doc.progDataSource.dataSourceSort &&
|
|
3047
|
-
!doc.progDataSource.dataSourceSortExp
|
|
3048
|
-
) {
|
|
2749
|
+
if (!doc.progDataSource.dataSourceSort && !doc.progDataSource.dataSourceSortExp) {
|
|
3049
2750
|
ret.push({
|
|
3050
|
-
code:
|
|
2751
|
+
code: 'CHK_MSG_PRG_DSC_200',
|
|
3051
2752
|
data: `missing sort value for datasource`,
|
|
3052
|
-
type:
|
|
2753
|
+
type: 'E',
|
|
3053
2754
|
id: `${doc._id}`,
|
|
3054
2755
|
});
|
|
3055
2756
|
} else if (doc.progDataSource.dataSourceSort) {
|
|
3056
|
-
if (![
|
|
2757
|
+
if (!['asc', 'des'].includes(doc.progDataSource.dataSourceSort)) {
|
|
3057
2758
|
ret.push({
|
|
3058
|
-
code:
|
|
2759
|
+
code: 'CHK_MSG_PRG_DSC_210',
|
|
3059
2760
|
data: `invalid sort value for datasource`,
|
|
3060
|
-
type:
|
|
2761
|
+
type: 'E',
|
|
3061
2762
|
id: `${doc._id}`,
|
|
3062
2763
|
});
|
|
3063
2764
|
}
|
|
3064
2765
|
}
|
|
3065
2766
|
|
|
3066
2767
|
// check skip
|
|
3067
|
-
if (
|
|
3068
|
-
doc.progDataSource.dataSourceSkip &&
|
|
3069
|
-
typeof doc.progDataSource.dataSourceSkip !== "number"
|
|
3070
|
-
) {
|
|
2768
|
+
if (doc.progDataSource.dataSourceSkip && typeof doc.progDataSource.dataSourceSkip !== 'number') {
|
|
3071
2769
|
ret.push({
|
|
3072
|
-
code:
|
|
2770
|
+
code: 'CHK_MSG_PRG_DSC_220',
|
|
3073
2771
|
data: `invalid skip value for datasource`,
|
|
3074
|
-
type:
|
|
2772
|
+
type: 'E',
|
|
3075
2773
|
id: `${doc._id}`,
|
|
3076
2774
|
});
|
|
3077
2775
|
}
|
|
3078
2776
|
|
|
3079
2777
|
// check limit
|
|
3080
|
-
if (
|
|
3081
|
-
doc.progDataSource.dataSourceLimit &&
|
|
3082
|
-
typeof doc.progDataSource.dataSourceLimit !== "number"
|
|
3083
|
-
) {
|
|
2778
|
+
if (doc.progDataSource.dataSourceLimit && typeof doc.progDataSource.dataSourceLimit !== 'number') {
|
|
3084
2779
|
ret.push({
|
|
3085
|
-
code:
|
|
2780
|
+
code: 'CHK_MSG_PRG_DSC_230',
|
|
3086
2781
|
data: `invalid limit value for datasource`,
|
|
3087
|
-
type:
|
|
2782
|
+
type: 'E',
|
|
3088
2783
|
id: `${doc._id}`,
|
|
3089
2784
|
});
|
|
3090
2785
|
}
|
|
@@ -3094,9 +2789,9 @@ const check_prog_datasource = function (doc) {
|
|
|
3094
2789
|
|
|
3095
2790
|
default:
|
|
3096
2791
|
ret.push({
|
|
3097
|
-
code:
|
|
2792
|
+
code: 'CHK_MSG_PRG_DSC_040',
|
|
3098
2793
|
data: `invalid datasource type ${doc.progDataSource.dataSourceType}`,
|
|
3099
|
-
type:
|
|
2794
|
+
type: 'E',
|
|
3100
2795
|
id: `${doc._id}`,
|
|
3101
2796
|
});
|
|
3102
2797
|
break;
|
|
@@ -3113,20 +2808,20 @@ const check_prog_parameters = function (doc) {
|
|
|
3113
2808
|
for (let parameter of doc.properties.progParams) {
|
|
3114
2809
|
if (!parameter?.data?.parameter) {
|
|
3115
2810
|
ret.push({
|
|
3116
|
-
code:
|
|
2811
|
+
code: 'CHK_MSG_PRG_PRM_010',
|
|
3117
2812
|
data: `missing parameter name`,
|
|
3118
|
-
type: doc.studio_meta.not_in_use ?
|
|
3119
|
-
category:
|
|
2813
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
2814
|
+
category: 'parameter',
|
|
3120
2815
|
ref: parameter.id,
|
|
3121
2816
|
id: `${doc._id}-${parameter.id}`,
|
|
3122
2817
|
});
|
|
3123
2818
|
} else {
|
|
3124
2819
|
if (!/^[A-Za-z]+[\w\-\:\.]*$/.test(parameter.data.parameter)) {
|
|
3125
2820
|
ret.push({
|
|
3126
|
-
code:
|
|
2821
|
+
code: 'CHK_MSG_PRG_PRM_020',
|
|
3127
2822
|
data: `invalid parameter name`,
|
|
3128
|
-
type: doc.studio_meta.not_in_use ?
|
|
3129
|
-
category:
|
|
2823
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
2824
|
+
category: 'parameter',
|
|
3130
2825
|
ref: parameter.id,
|
|
3131
2826
|
id: `${doc._id}-${parameter.id}`,
|
|
3132
2827
|
});
|
|
@@ -3138,13 +2833,13 @@ const check_prog_parameters = function (doc) {
|
|
|
3138
2833
|
name_counts_obj[parameter.data.parameter]++;
|
|
3139
2834
|
}
|
|
3140
2835
|
if (!hide_not_in_use_check) {
|
|
3141
|
-
if (parameter.data.dir ===
|
|
2836
|
+
if (parameter.data.dir === 'in') {
|
|
3142
2837
|
if (!find_field_in_progs(doc, parameter.data.parameter)) {
|
|
3143
2838
|
ret.push({
|
|
3144
|
-
code:
|
|
2839
|
+
code: 'CHK_MSG_PRG_PRM_022',
|
|
3145
2840
|
data: `parameter "${parameter.data.parameter}" not in use`,
|
|
3146
|
-
type:
|
|
3147
|
-
category:
|
|
2841
|
+
type: 'W',
|
|
2842
|
+
category: 'parameter',
|
|
3148
2843
|
ref: parameter.id,
|
|
3149
2844
|
not_in_use: true,
|
|
3150
2845
|
id: `${doc._id}-${parameter.id}`,
|
|
@@ -3156,35 +2851,35 @@ const check_prog_parameters = function (doc) {
|
|
|
3156
2851
|
|
|
3157
2852
|
if (!parameter?.data?.type) {
|
|
3158
2853
|
ret.push({
|
|
3159
|
-
code:
|
|
2854
|
+
code: 'CHK_MSG_PRG_PRM_030',
|
|
3160
2855
|
data: `missing parameter type for ${parameter.data.parameter}`,
|
|
3161
|
-
type: doc.studio_meta.not_in_use ?
|
|
3162
|
-
category:
|
|
2856
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
2857
|
+
category: 'parameter',
|
|
3163
2858
|
ref: parameter.id,
|
|
3164
2859
|
id: `${doc._id}-${parameter.id}`,
|
|
3165
2860
|
});
|
|
3166
2861
|
return ret;
|
|
3167
2862
|
} else {
|
|
3168
2863
|
switch (parameter.data.type) {
|
|
3169
|
-
case
|
|
2864
|
+
case 'string':
|
|
3170
2865
|
break;
|
|
3171
2866
|
|
|
3172
|
-
case
|
|
3173
|
-
case
|
|
2867
|
+
case 'number':
|
|
2868
|
+
case 'boolean':
|
|
3174
2869
|
break;
|
|
3175
2870
|
|
|
3176
|
-
case
|
|
2871
|
+
case 'object':
|
|
3177
2872
|
break;
|
|
3178
2873
|
|
|
3179
|
-
case
|
|
2874
|
+
case 'array':
|
|
3180
2875
|
break;
|
|
3181
2876
|
|
|
3182
2877
|
default:
|
|
3183
2878
|
ret.push({
|
|
3184
|
-
code:
|
|
2879
|
+
code: 'CHK_MSG_PRG_PRM_040',
|
|
3185
2880
|
data: `invalid parameter type "${parameter.data.type}" for ${parameter.data.parameter}`,
|
|
3186
|
-
type: doc.studio_meta.not_in_use ?
|
|
3187
|
-
category:
|
|
2881
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
2882
|
+
category: 'parameter',
|
|
3188
2883
|
ref: parameter.id,
|
|
3189
2884
|
id: `${doc._id}-${parameter.id}`,
|
|
3190
2885
|
});
|
|
@@ -3195,32 +2890,26 @@ const check_prog_parameters = function (doc) {
|
|
|
3195
2890
|
|
|
3196
2891
|
if (!parameter?.data?.dir) {
|
|
3197
2892
|
ret.push({
|
|
3198
|
-
code:
|
|
2893
|
+
code: 'CHK_MSG_PRG_PRM_080',
|
|
3199
2894
|
data: `missing parameter dir for ${parameter.data.parameter}`,
|
|
3200
|
-
type: doc.studio_meta.not_in_use ?
|
|
3201
|
-
category:
|
|
2895
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
2896
|
+
category: 'parameter',
|
|
3202
2897
|
ref: parameter.id,
|
|
3203
2898
|
id: `${doc._id}-${parameter.id}`,
|
|
3204
2899
|
});
|
|
3205
2900
|
return ret;
|
|
3206
2901
|
} else {
|
|
3207
2902
|
switch (parameter.data.dir) {
|
|
3208
|
-
case
|
|
2903
|
+
case 'in':
|
|
3209
2904
|
break;
|
|
3210
2905
|
|
|
3211
|
-
case
|
|
3212
|
-
if (
|
|
3213
|
-
!find_item_by_key(
|
|
3214
|
-
doc.progFields,
|
|
3215
|
-
"field_id",
|
|
3216
|
-
parameter.data.parameter
|
|
3217
|
-
)
|
|
3218
|
-
) {
|
|
2906
|
+
case 'out':
|
|
2907
|
+
if (!find_item_by_key(doc.progFields, 'field_id', parameter.data.parameter)) {
|
|
3219
2908
|
ret.push({
|
|
3220
|
-
code:
|
|
2909
|
+
code: 'CHK_MSG_PRG_PRM_100',
|
|
3221
2910
|
data: `missing parameter return in the fieldset for ${parameter.data.parameter}`,
|
|
3222
|
-
type: doc.studio_meta.not_in_use ?
|
|
3223
|
-
category:
|
|
2911
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
2912
|
+
category: 'parameter',
|
|
3224
2913
|
ref: parameter.id,
|
|
3225
2914
|
id: `${doc._id}-${parameter.id}`,
|
|
3226
2915
|
});
|
|
@@ -3229,10 +2918,10 @@ const check_prog_parameters = function (doc) {
|
|
|
3229
2918
|
|
|
3230
2919
|
default:
|
|
3231
2920
|
ret.push({
|
|
3232
|
-
code:
|
|
2921
|
+
code: 'CHK_MSG_PRG_PRM_090',
|
|
3233
2922
|
data: `invalid parameter dir for ${parameter.data.parameter}`,
|
|
3234
|
-
type: doc.studio_meta.not_in_use ?
|
|
3235
|
-
category:
|
|
2923
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
2924
|
+
category: 'parameter',
|
|
3236
2925
|
ref: parameter.id,
|
|
3237
2926
|
id: `${doc._id}-${parameter.id}`,
|
|
3238
2927
|
});
|
|
@@ -3245,10 +2934,10 @@ const check_prog_parameters = function (doc) {
|
|
|
3245
2934
|
for (let [key, val] of Object.entries(name_counts_obj)) {
|
|
3246
2935
|
if (val > 1) {
|
|
3247
2936
|
ret.push({
|
|
3248
|
-
code:
|
|
2937
|
+
code: 'CHK_MSG_PRG_PRM_050',
|
|
3249
2938
|
data: `duplicate parameter name for ${key}`,
|
|
3250
|
-
type: doc.studio_meta.not_in_use ?
|
|
3251
|
-
category:
|
|
2939
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
2940
|
+
category: 'parameter',
|
|
3252
2941
|
ref: parameter.id,
|
|
3253
2942
|
id: `${doc._id}-${parameter.id}-${key}`,
|
|
3254
2943
|
});
|
|
@@ -3262,9 +2951,9 @@ const check_javascript = function (doc) {
|
|
|
3262
2951
|
|
|
3263
2952
|
if (!doc?.scriptData?.value) {
|
|
3264
2953
|
ret.push({
|
|
3265
|
-
code:
|
|
3266
|
-
data:
|
|
3267
|
-
type:
|
|
2954
|
+
code: 'CHK_MSG_PRG_JVS_012',
|
|
2955
|
+
data: 'no script to run',
|
|
2956
|
+
type: 'W',
|
|
3268
2957
|
id: `${doc._id}`,
|
|
3269
2958
|
});
|
|
3270
2959
|
} else {
|
|
@@ -3341,12 +3030,9 @@ const check_prog_expression = function (doc, exp, path, category) {
|
|
|
3341
3030
|
const ret_field = find_field_in_progs(doc, field.substr(1));
|
|
3342
3031
|
if (!ret_field) {
|
|
3343
3032
|
ret.push({
|
|
3344
|
-
code:
|
|
3345
|
-
data: `field "${field}" not found in the project datasets using expression "${exp.substr(
|
|
3346
|
-
|
|
3347
|
-
20
|
|
3348
|
-
)}.." in ${path}`,
|
|
3349
|
-
type: "W",
|
|
3033
|
+
code: 'CHK_MSG_PRG_EXP_012',
|
|
3034
|
+
data: `field "${field}" not found in the project datasets using expression "${exp.substr(0, 20)}.." in ${path}`,
|
|
3035
|
+
type: 'W',
|
|
3350
3036
|
category,
|
|
3351
3037
|
source_id: path,
|
|
3352
3038
|
id: `${doc._id}-${path}-${field}`,
|
|
@@ -3380,12 +3066,9 @@ const check_prog_expression = function (doc, exp, path, category) {
|
|
|
3380
3066
|
var result = UglifyJS.minify(exp, options);
|
|
3381
3067
|
if (result.error) {
|
|
3382
3068
|
ret.push({
|
|
3383
|
-
code:
|
|
3384
|
-
data: `expression error ${result.error.message} in ${exp.substr(
|
|
3385
|
-
|
|
3386
|
-
20
|
|
3387
|
-
)}.. in ${path}`,
|
|
3388
|
-
type: doc.studio_meta.not_in_use ? "W" : "E",
|
|
3069
|
+
code: 'CHK_MSG_PRG_EXP_022',
|
|
3070
|
+
data: `expression error ${result.error.message} in ${exp.substr(0, 20)}.. in ${path}`,
|
|
3071
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
3389
3072
|
category,
|
|
3390
3073
|
details: result.error,
|
|
3391
3074
|
source_id: path,
|
|
@@ -3394,12 +3077,9 @@ const check_prog_expression = function (doc, exp, path, category) {
|
|
|
3394
3077
|
}
|
|
3395
3078
|
if (result.warnings) {
|
|
3396
3079
|
ret.push({
|
|
3397
|
-
code:
|
|
3398
|
-
data: `expression warning ${result.warnings[0]} in ${exp.substr(
|
|
3399
|
-
|
|
3400
|
-
20
|
|
3401
|
-
)}.. in ${path}`,
|
|
3402
|
-
type: "W",
|
|
3080
|
+
code: 'CHK_MSG_PRG_EXP_024',
|
|
3081
|
+
data: `expression warning ${result.warnings[0]} in ${exp.substr(0, 20)}.. in ${path}`,
|
|
3082
|
+
type: 'W',
|
|
3403
3083
|
category,
|
|
3404
3084
|
details: result.warnings,
|
|
3405
3085
|
source_id: path,
|
|
@@ -3408,7 +3088,7 @@ const check_prog_expression = function (doc, exp, path, category) {
|
|
|
3408
3088
|
}
|
|
3409
3089
|
} else {
|
|
3410
3090
|
var clean_exp = exp;
|
|
3411
|
-
var field_type =
|
|
3091
|
+
var field_type = 'string';
|
|
3412
3092
|
var skip_eval;
|
|
3413
3093
|
for (let [key, val] of Object.entries(field_matches)) {
|
|
3414
3094
|
if (val.length > 1) {
|
|
@@ -3420,13 +3100,11 @@ const check_prog_expression = function (doc, exp, path, category) {
|
|
|
3420
3100
|
}
|
|
3421
3101
|
}
|
|
3422
3102
|
|
|
3423
|
-
if (typeof field_ind_found_in_current_program ===
|
|
3103
|
+
if (typeof field_ind_found_in_current_program === 'undefined') {
|
|
3424
3104
|
skip_eval = true;
|
|
3425
3105
|
break; // skip check if field type cannot be determine
|
|
3426
3106
|
} else {
|
|
3427
|
-
field_type =
|
|
3428
|
-
val[field_ind_found_in_current_program]?.field_item?.props
|
|
3429
|
-
?.fieldType;
|
|
3107
|
+
field_type = val[field_ind_found_in_current_program]?.field_item?.props?.fieldType;
|
|
3430
3108
|
}
|
|
3431
3109
|
} else {
|
|
3432
3110
|
field_type = val[0]?.field_item?.props?.fieldType;
|
|
@@ -3434,19 +3112,19 @@ const check_prog_expression = function (doc, exp, path, category) {
|
|
|
3434
3112
|
|
|
3435
3113
|
// clean_exp = exp.replace(/@\w+/g, "''");
|
|
3436
3114
|
switch (field_type) {
|
|
3437
|
-
case
|
|
3115
|
+
case 'string':
|
|
3438
3116
|
clean_exp = clean_exp.replaceAll(key, "''");
|
|
3439
3117
|
break;
|
|
3440
|
-
case
|
|
3441
|
-
case
|
|
3442
|
-
case
|
|
3443
|
-
clean_exp = clean_exp.replaceAll(key,
|
|
3118
|
+
case 'number':
|
|
3119
|
+
case 'boolean':
|
|
3120
|
+
case 'bool':
|
|
3121
|
+
clean_exp = clean_exp.replaceAll(key, '0');
|
|
3444
3122
|
break;
|
|
3445
|
-
case
|
|
3446
|
-
clean_exp = clean_exp.replaceAll(key,
|
|
3123
|
+
case 'object':
|
|
3124
|
+
clean_exp = clean_exp.replaceAll(key, '{}');
|
|
3447
3125
|
break;
|
|
3448
|
-
case
|
|
3449
|
-
clean_exp = clean_exp.replaceAll(key,
|
|
3126
|
+
case 'array':
|
|
3127
|
+
clean_exp = clean_exp.replaceAll(key, '[]');
|
|
3450
3128
|
break;
|
|
3451
3129
|
|
|
3452
3130
|
default:
|
|
@@ -3470,12 +3148,9 @@ const check_prog_expression = function (doc, exp, path, category) {
|
|
|
3470
3148
|
|
|
3471
3149
|
if (result.error) {
|
|
3472
3150
|
ret.push({
|
|
3473
|
-
code:
|
|
3474
|
-
data: `expression error ${result.error.message} in ${exp.substr(
|
|
3475
|
-
|
|
3476
|
-
20
|
|
3477
|
-
)}.. in ${path}`,
|
|
3478
|
-
type: doc.studio_meta.not_in_use ? "W" : "E",
|
|
3151
|
+
code: 'CHK_MSG_PRG_EXP_026',
|
|
3152
|
+
data: `expression error ${result.error.message} in ${exp.substr(0, 20)}.. in ${path}`,
|
|
3153
|
+
type: doc.studio_meta.not_in_use ? 'W' : 'E',
|
|
3479
3154
|
category,
|
|
3480
3155
|
details: result.error,
|
|
3481
3156
|
source_id: path,
|
|
@@ -3484,12 +3159,9 @@ const check_prog_expression = function (doc, exp, path, category) {
|
|
|
3484
3159
|
}
|
|
3485
3160
|
if (result.warnings) {
|
|
3486
3161
|
ret.push({
|
|
3487
|
-
code:
|
|
3488
|
-
data: `expression warning ${result.warnings[0]} in ${exp.substr(
|
|
3489
|
-
|
|
3490
|
-
20
|
|
3491
|
-
)}.. in ${path}`,
|
|
3492
|
-
type: "W",
|
|
3162
|
+
code: 'CHK_MSG_PRG_EXP_028',
|
|
3163
|
+
data: `expression warning ${result.warnings[0]} in ${exp.substr(0, 20)}.. in ${path}`,
|
|
3164
|
+
type: 'W',
|
|
3493
3165
|
category,
|
|
3494
3166
|
details: result.warnings,
|
|
3495
3167
|
source_id: path,
|
|
@@ -3556,13 +3228,7 @@ const find_xu_tree_id_in_progs = function (doc, xu_tree_id) {
|
|
|
3556
3228
|
return ret;
|
|
3557
3229
|
};
|
|
3558
3230
|
|
|
3559
|
-
const find_trigger_property_value_in_progs = function (
|
|
3560
|
-
doc,
|
|
3561
|
-
triggers_arr,
|
|
3562
|
-
property,
|
|
3563
|
-
value,
|
|
3564
|
-
search_in_doc_prog_only
|
|
3565
|
-
) {
|
|
3231
|
+
const find_trigger_property_value_in_progs = function (doc, triggers_arr, property, value, search_in_doc_prog_only) {
|
|
3566
3232
|
var ret = [];
|
|
3567
3233
|
|
|
3568
3234
|
const find_in_triggers = function (prog, triggers) {
|
|
@@ -3577,11 +3243,7 @@ const find_trigger_property_value_in_progs = function (
|
|
|
3577
3243
|
// if (val.data.action === "alter_ui_element") {
|
|
3578
3244
|
// debugger;
|
|
3579
3245
|
// }
|
|
3580
|
-
if (
|
|
3581
|
-
value === null ||
|
|
3582
|
-
val?.data?.name?.[property] === value ||
|
|
3583
|
-
regex.test(str)
|
|
3584
|
-
) {
|
|
3246
|
+
if (value === null || val?.data?.name?.[property] === value || regex.test(str)) {
|
|
3585
3247
|
if (val?.data?.name?.[property]) {
|
|
3586
3248
|
ret.push({
|
|
3587
3249
|
prog_id: prog._id,
|
|
@@ -3632,7 +3294,7 @@ const find_trigger_property_value_in_progs = function (
|
|
|
3632
3294
|
for (let item of node) {
|
|
3633
3295
|
if (item.attributes) {
|
|
3634
3296
|
for (let [key, val] of Object.entries(item.attributes)) {
|
|
3635
|
-
if (key.substr(0, 6) ===
|
|
3297
|
+
if (key.substr(0, 6) === 'xu-on:') {
|
|
3636
3298
|
if (!_.isEmpty(val)) {
|
|
3637
3299
|
for (let trigger_item of val) {
|
|
3638
3300
|
find_in_triggers(prog, trigger_item.event);
|
|
@@ -3647,7 +3309,7 @@ const find_trigger_property_value_in_progs = function (
|
|
|
3647
3309
|
}
|
|
3648
3310
|
}
|
|
3649
3311
|
} catch (error) {
|
|
3650
|
-
console.error(
|
|
3312
|
+
console.error('find in ui triggers', error);
|
|
3651
3313
|
}
|
|
3652
3314
|
};
|
|
3653
3315
|
run_tree(prog.progUi);
|
|
@@ -3665,11 +3327,7 @@ const find_trigger_property_value_in_progs = function (
|
|
|
3665
3327
|
return ret;
|
|
3666
3328
|
};
|
|
3667
3329
|
|
|
3668
|
-
const find_panel_prog_in_progs = function (
|
|
3669
|
-
doc,
|
|
3670
|
-
prog_id,
|
|
3671
|
-
search_in_doc_prog_only
|
|
3672
|
-
) {
|
|
3330
|
+
const find_panel_prog_in_progs = function (doc, prog_id, search_in_doc_prog_only) {
|
|
3673
3331
|
var ret = [];
|
|
3674
3332
|
|
|
3675
3333
|
const find_in_prog = function (prog) {
|
|
@@ -3677,7 +3335,7 @@ const find_panel_prog_in_progs = function (
|
|
|
3677
3335
|
|
|
3678
3336
|
const run_tree = function (node) {
|
|
3679
3337
|
for (let item of node) {
|
|
3680
|
-
if (item.tagName ===
|
|
3338
|
+
if (item.tagName === 'xu-panel') {
|
|
3681
3339
|
const str = JSON.stringify(item);
|
|
3682
3340
|
const regex = new RegExp(`\\b${prog_id}\\b`);
|
|
3683
3341
|
// const regex = new RegExp(`@${prog_id}\\b`);
|
|
@@ -3685,11 +3343,7 @@ const find_panel_prog_in_progs = function (
|
|
|
3685
3343
|
// const exactLength = prog_id.length; // Change this to your desired exact length
|
|
3686
3344
|
// const regex = new RegExp(`^.{${exactLength}}$`);
|
|
3687
3345
|
|
|
3688
|
-
if (
|
|
3689
|
-
prog_id === null ||
|
|
3690
|
-
item?.attributes?.program?.prog === prog_id ||
|
|
3691
|
-
regex.test(str)
|
|
3692
|
-
) {
|
|
3346
|
+
if (prog_id === null || item?.attributes?.program?.prog === prog_id || regex.test(str)) {
|
|
3693
3347
|
if (item?.attributes?.program?.prog) {
|
|
3694
3348
|
ret.push({
|
|
3695
3349
|
prog_id: prog._id,
|
|
@@ -3746,18 +3400,11 @@ const find_table_in_progs = function (doc, table_id, search_in_doc_prog_only) {
|
|
|
3746
3400
|
// }
|
|
3747
3401
|
|
|
3748
3402
|
const find_in_prog = function (prog) {
|
|
3749
|
-
if (
|
|
3750
|
-
!prog.progDataSource ||
|
|
3751
|
-
_.isEmpty(prog.progDataSource) ||
|
|
3752
|
-
prog.progDataSource.dataSourceType !== "table"
|
|
3753
|
-
) {
|
|
3403
|
+
if (!prog.progDataSource || _.isEmpty(prog.progDataSource) || prog.progDataSource.dataSourceType !== 'table') {
|
|
3754
3404
|
return;
|
|
3755
3405
|
}
|
|
3756
3406
|
|
|
3757
|
-
if (
|
|
3758
|
-
prog.progDataSource.dataSourceTableId === table_id ||
|
|
3759
|
-
prog.progDataSource?.dataSourceTableIdExp?.includes(table_id)
|
|
3760
|
-
) {
|
|
3407
|
+
if (prog.progDataSource.dataSourceTableId === table_id || prog.progDataSource?.dataSourceTableIdExp?.includes(table_id)) {
|
|
3761
3408
|
ret.push({
|
|
3762
3409
|
prog_id: prog._id,
|
|
3763
3410
|
});
|
|
@@ -3776,11 +3423,7 @@ const find_table_in_progs = function (doc, table_id, search_in_doc_prog_only) {
|
|
|
3776
3423
|
return ret;
|
|
3777
3424
|
};
|
|
3778
3425
|
|
|
3779
|
-
const find_prog_in_fieldset_fieldValue_progs = function (
|
|
3780
|
-
doc,
|
|
3781
|
-
prog_id,
|
|
3782
|
-
search_in_doc_prog_only
|
|
3783
|
-
) {
|
|
3426
|
+
const find_prog_in_fieldset_fieldValue_progs = function (doc, prog_id, search_in_doc_prog_only) {
|
|
3784
3427
|
var ret = [];
|
|
3785
3428
|
|
|
3786
3429
|
const find_in_prog = function (prog) {
|
|
@@ -3790,11 +3433,7 @@ const find_prog_in_fieldset_fieldValue_progs = function (
|
|
|
3790
3433
|
|
|
3791
3434
|
const regex = new RegExp(`\\b${prog_id}\\b`);
|
|
3792
3435
|
|
|
3793
|
-
if (
|
|
3794
|
-
prog_id === null ||
|
|
3795
|
-
field_item?.props?.fieldValue === prog_id ||
|
|
3796
|
-
regex.test(str)
|
|
3797
|
-
) {
|
|
3436
|
+
if (prog_id === null || field_item?.props?.fieldValue === prog_id || regex.test(str)) {
|
|
3798
3437
|
if (field_item?.props?.fieldValue) {
|
|
3799
3438
|
ret.push({
|
|
3800
3439
|
prog_id: prog._id,
|