@xuda.io/xuda-studio-checker 1.0.122 → 1.0.124
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/index.mjs +78 -78
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -48,7 +48,7 @@ export const check = function (doc) {
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
// Early validation checks
|
|
51
|
-
if (
|
|
51
|
+
if (xu_isEmpty(doc)) {
|
|
52
52
|
addValidationError('CHK_MSG_OBJ_GEN_110', 'doc in empty');
|
|
53
53
|
return {
|
|
54
54
|
check_errors: ret,
|
|
@@ -219,13 +219,13 @@ export const check_structure = function (doc, critical_error) {
|
|
|
219
219
|
};
|
|
220
220
|
|
|
221
221
|
// Early exit conditions that prevent further validation
|
|
222
|
-
if (typeof app_obj !== 'undefined' && (!app_obj || !
|
|
222
|
+
if (typeof app_obj !== 'undefined' && (!app_obj || !(typeof app_obj === 'object' && app_obj !== null) || xu_isEmpty(app_obj))) {
|
|
223
223
|
addValidationError('CHK_MSG_OBJ_GEN_002', 'invalid app_obj');
|
|
224
224
|
critical_error = true;
|
|
225
225
|
return ret;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
if (!doc || !
|
|
228
|
+
if (!doc || !(typeof doc === 'object' && doc !== null) || xu_isEmpty(doc)) {
|
|
229
229
|
addValidationError('CHK_MSG_OBJ_GEN_004', 'doc is not a object');
|
|
230
230
|
critical_error = true;
|
|
231
231
|
return ret;
|
|
@@ -300,7 +300,7 @@ export const check_structure = function (doc, critical_error) {
|
|
|
300
300
|
if (!doc.properties) {
|
|
301
301
|
addValidationError('CHK_MSG_OBJ_GEN_100', 'missing properties object');
|
|
302
302
|
} else {
|
|
303
|
-
if (!
|
|
303
|
+
if (!(typeof doc.properties === 'object' && doc.properties !== null)) {
|
|
304
304
|
addValidationError('CHK_MSG_OBJ_GEN_102', 'invalid properties object');
|
|
305
305
|
} else {
|
|
306
306
|
if (!doc.properties.menuType) {
|
|
@@ -320,7 +320,7 @@ export const check_structure = function (doc, critical_error) {
|
|
|
320
320
|
if (!doc.studio_meta) {
|
|
321
321
|
addValidationError('CHK_MSG_OBJ_GEN_112', 'missing studio_meta property');
|
|
322
322
|
} else {
|
|
323
|
-
if (!
|
|
323
|
+
if (!(typeof doc.studio_meta === 'object' && doc.studio_meta !== null)) {
|
|
324
324
|
addValidationError('CHK_MSG_OBJ_GEN_112', 'invalid studio_meta object');
|
|
325
325
|
} else {
|
|
326
326
|
if (!doc.studio_meta.parentId) {
|
|
@@ -338,7 +338,7 @@ export const check_structure = function (doc, critical_error) {
|
|
|
338
338
|
if (!doc.progFields) return;
|
|
339
339
|
|
|
340
340
|
var ids = [];
|
|
341
|
-
if (!
|
|
341
|
+
if (!Array.isArray(doc.progFields)) {
|
|
342
342
|
addValidationError('CHK_MSG_OBJ_GEN_402', 'invalid progFields Array property');
|
|
343
343
|
return;
|
|
344
344
|
}
|
|
@@ -347,7 +347,7 @@ export const check_structure = function (doc, critical_error) {
|
|
|
347
347
|
const validFieldTypes = ['string', 'number', 'boolean', 'array', 'object'];
|
|
348
348
|
|
|
349
349
|
for (let val of doc.progFields) {
|
|
350
|
-
if (!
|
|
350
|
+
if (!(typeof val === 'object' && val !== null)) {
|
|
351
351
|
addValidationError('CHK_MSG_OBJ_GEN_404', `Invalid progFields object `);
|
|
352
352
|
continue;
|
|
353
353
|
}
|
|
@@ -363,7 +363,7 @@ export const check_structure = function (doc, critical_error) {
|
|
|
363
363
|
}
|
|
364
364
|
ids.push(val.id);
|
|
365
365
|
}
|
|
366
|
-
if (!
|
|
366
|
+
if (!(typeof val.data === 'object' && val.data !== null)) {
|
|
367
367
|
addValidationError('CHK_MSG_OBJ_GEN_410', `Invalid progFields data object ${fieldId}`);
|
|
368
368
|
} else {
|
|
369
369
|
if (!val.data.field_id) {
|
|
@@ -377,7 +377,7 @@ export const check_structure = function (doc, critical_error) {
|
|
|
377
377
|
}
|
|
378
378
|
}
|
|
379
379
|
|
|
380
|
-
if (!
|
|
380
|
+
if (!(typeof val.props === 'object' && val.props !== null)) {
|
|
381
381
|
addValidationError('CHK_MSG_OBJ_GEN_416', `Invalid progFields props object ${fieldId}`);
|
|
382
382
|
} else {
|
|
383
383
|
if (!val.props.fieldType) {
|
|
@@ -386,7 +386,7 @@ export const check_structure = function (doc, critical_error) {
|
|
|
386
386
|
addValidationError('CHK_MSG_OBJ_GEN_419', `Invalid progFields fieldType "${val.props.fieldType}" ${fieldId}. Must be one of: ${validFieldTypes.join(', ')}`);
|
|
387
387
|
}
|
|
388
388
|
|
|
389
|
-
if (!
|
|
389
|
+
if (!(typeof val.props.propExpressions === 'object' && val.props.propExpressions !== null)) {
|
|
390
390
|
addValidationError('CHK_MSG_OBJ_GEN_4120', `Invalid progFields propExpressions object ${fieldId}`);
|
|
391
391
|
} else {
|
|
392
392
|
// Validate propExpressions only contains allowed properties
|
|
@@ -408,13 +408,13 @@ export const check_structure = function (doc, critical_error) {
|
|
|
408
408
|
if (!doc.progEvents) return;
|
|
409
409
|
|
|
410
410
|
var ids = [];
|
|
411
|
-
if (!
|
|
411
|
+
if (!Array.isArray(doc.progEvents)) {
|
|
412
412
|
addValidationError('CHK_MSG_OBJ_GEN_502', 'invalid progEvents Array property');
|
|
413
413
|
return;
|
|
414
414
|
}
|
|
415
415
|
|
|
416
416
|
for (let val of doc.progEvents) {
|
|
417
|
-
if (!
|
|
417
|
+
if (!(typeof val === 'object' && val !== null)) {
|
|
418
418
|
addValidationError('CHK_MSG_OBJ_GEN_504', 'invalid progEvents object property');
|
|
419
419
|
continue;
|
|
420
420
|
}
|
|
@@ -430,7 +430,7 @@ export const check_structure = function (doc, critical_error) {
|
|
|
430
430
|
}
|
|
431
431
|
ids.push(val.id);
|
|
432
432
|
|
|
433
|
-
if (!
|
|
433
|
+
if (!(typeof val.data === 'object' && val.data !== null)) {
|
|
434
434
|
addValidationError('CHK_MSG_OBJ_GEN_510', 'invalid progEvents.data object property');
|
|
435
435
|
continue;
|
|
436
436
|
}
|
|
@@ -451,11 +451,11 @@ export const check_structure = function (doc, critical_error) {
|
|
|
451
451
|
addValidationError('CHK_MSG_OBJ_GEN_518', 'undefined progEvents.data.type string property');
|
|
452
452
|
}
|
|
453
453
|
|
|
454
|
-
if (!
|
|
454
|
+
if (!Array.isArray(val.data.parameters)) {
|
|
455
455
|
addValidationError('CHK_MSG_OBJ_GEN_522', 'invalid progEvents.data.parameters Array property');
|
|
456
456
|
}
|
|
457
457
|
|
|
458
|
-
if (!
|
|
458
|
+
if (!(typeof val.props === 'object' && val.props !== null)) {
|
|
459
459
|
addValidationError('CHK_MSG_OBJ_GEN_522', 'invalid progEvents.props Object property');
|
|
460
460
|
}
|
|
461
461
|
|
|
@@ -467,13 +467,13 @@ export const check_structure = function (doc, critical_error) {
|
|
|
467
467
|
if (!workflow) return;
|
|
468
468
|
|
|
469
469
|
var ids = [];
|
|
470
|
-
if (!
|
|
470
|
+
if (!Array.isArray(workflow)) {
|
|
471
471
|
addValidationError('CHK_MSG_OBJ_GEN_850', 'invalid workflow Array property');
|
|
472
472
|
return;
|
|
473
473
|
}
|
|
474
474
|
|
|
475
475
|
for (let val of workflow) {
|
|
476
|
-
if (!
|
|
476
|
+
if (!(typeof val === 'object' && val !== null)) {
|
|
477
477
|
addValidationError('CHK_MSG_OBJ_GEN_852', 'invalid workflow item object property');
|
|
478
478
|
continue;
|
|
479
479
|
}
|
|
@@ -489,11 +489,11 @@ export const check_structure = function (doc, critical_error) {
|
|
|
489
489
|
}
|
|
490
490
|
ids.push(val.id);
|
|
491
491
|
|
|
492
|
-
if (!
|
|
492
|
+
if (!(typeof val.data === 'object' && val.data !== null)) {
|
|
493
493
|
addValidationError('CHK_MSG_OBJ_GEN_858', 'invalid workflow.data Object property');
|
|
494
494
|
}
|
|
495
495
|
|
|
496
|
-
if (!
|
|
496
|
+
if (!(typeof val.props === 'object' && val.props !== null)) {
|
|
497
497
|
addValidationError('CHK_MSG_OBJ_GEN_860', 'invalid workflow.props item object property');
|
|
498
498
|
}
|
|
499
499
|
}
|
|
@@ -502,7 +502,7 @@ export const check_structure = function (doc, critical_error) {
|
|
|
502
502
|
const check_progDataSource = function () {
|
|
503
503
|
if (!doc.progDataSource) return;
|
|
504
504
|
|
|
505
|
-
if (!
|
|
505
|
+
if (!(typeof doc.progDataSource === 'object' && doc.progDataSource !== null)) {
|
|
506
506
|
addValidationError('CHK_MSG_OBJ_GEN_602', 'invalid progDataSource Object property');
|
|
507
507
|
return;
|
|
508
508
|
}
|
|
@@ -515,7 +515,7 @@ export const check_structure = function (doc, critical_error) {
|
|
|
515
515
|
const check_progUi = function () {
|
|
516
516
|
if (!doc.progUi) return;
|
|
517
517
|
|
|
518
|
-
if (!
|
|
518
|
+
if (!Array.isArray(doc.progUi)) {
|
|
519
519
|
addValidationError('CHK_MSG_OBJ_GEN_702', 'invalid progUi Array property');
|
|
520
520
|
return;
|
|
521
521
|
}
|
|
@@ -523,7 +523,7 @@ export const check_structure = function (doc, critical_error) {
|
|
|
523
523
|
var ids = [];
|
|
524
524
|
const run_tree = function (node) {
|
|
525
525
|
for (let item of node) {
|
|
526
|
-
if (!
|
|
526
|
+
if (!(typeof item === 'object' && item !== null)) {
|
|
527
527
|
addValidationError('CHK_MSG_OBJ_GEN_704', 'invalid progUi item Object property');
|
|
528
528
|
continue;
|
|
529
529
|
}
|
|
@@ -543,7 +543,7 @@ export const check_structure = function (doc, critical_error) {
|
|
|
543
543
|
continue;
|
|
544
544
|
}
|
|
545
545
|
|
|
546
|
-
if (item?.attributes && !
|
|
546
|
+
if (item?.attributes && !(typeof item.attributes === 'object' && item.attributes !== null)) {
|
|
547
547
|
addValidationError('CHK_MSG_OBJ_GEN_707', `Invalid progUi attributes object property (${item.id})`);
|
|
548
548
|
}
|
|
549
549
|
|
|
@@ -583,13 +583,13 @@ export const check_structure = function (doc, critical_error) {
|
|
|
583
583
|
if (!doc.tableFields) {
|
|
584
584
|
addValidationError('CHK_MSG_OBJ_GEN_200', 'missing tableFields property');
|
|
585
585
|
} else {
|
|
586
|
-
if (!
|
|
586
|
+
if (!Array.isArray(doc.tableFields)) {
|
|
587
587
|
addValidationError('CHK_MSG_OBJ_GEN_202', 'invalid tableFields Array property');
|
|
588
588
|
} else {
|
|
589
589
|
var ids = [];
|
|
590
590
|
|
|
591
591
|
for (let val of doc.tableFields) {
|
|
592
|
-
if (!
|
|
592
|
+
if (!(typeof val === 'object' && val !== null)) {
|
|
593
593
|
addValidationError('CHK_MSG_OBJ_GEN_204', 'invalid tableFields object property');
|
|
594
594
|
continue;
|
|
595
595
|
}
|
|
@@ -605,7 +605,7 @@ export const check_structure = function (doc, critical_error) {
|
|
|
605
605
|
}
|
|
606
606
|
ids.push(val.id);
|
|
607
607
|
|
|
608
|
-
if (!
|
|
608
|
+
if (!(typeof val.data === 'object' && val.data !== null)) {
|
|
609
609
|
addValidationError('CHK_MSG_OBJ_GEN_210', 'invalid tableFields.data object property');
|
|
610
610
|
continue;
|
|
611
611
|
}
|
|
@@ -614,7 +614,7 @@ export const check_structure = function (doc, critical_error) {
|
|
|
614
614
|
addValidationError('CHK_MSG_OBJ_GEN_212', 'invalid tableFields.data.field_id property');
|
|
615
615
|
}
|
|
616
616
|
|
|
617
|
-
if (!
|
|
617
|
+
if (!(typeof val.props === 'object' && val.props !== null)) {
|
|
618
618
|
addValidationError('CHK_MSG_OBJ_GEN_214', 'invalid tableFields.props object property');
|
|
619
619
|
continue;
|
|
620
620
|
}
|
|
@@ -629,12 +629,12 @@ export const check_structure = function (doc, critical_error) {
|
|
|
629
629
|
// tableIndexes validation
|
|
630
630
|
if (!doc.tableIndexes) {
|
|
631
631
|
addValidationError('CHK_MSG_OBJ_GEN_302', 'missing tableIndexes property');
|
|
632
|
-
} else if (!
|
|
632
|
+
} else if (!Array.isArray(doc.tableIndexes)) {
|
|
633
633
|
addValidationError('CHK_MSG_OBJ_GEN_302', 'invalid tableIndexes Array property');
|
|
634
634
|
} else {
|
|
635
635
|
var index_ids = [];
|
|
636
636
|
for (let val of doc.tableIndexes) {
|
|
637
|
-
if (!
|
|
637
|
+
if (!(typeof val === 'object' && val !== null)) {
|
|
638
638
|
addValidationError('CHK_MSG_OBJ_GEN_304', 'invalid tableIndexes object property');
|
|
639
639
|
continue;
|
|
640
640
|
}
|
|
@@ -650,7 +650,7 @@ export const check_structure = function (doc, critical_error) {
|
|
|
650
650
|
}
|
|
651
651
|
index_ids.push(val.id);
|
|
652
652
|
|
|
653
|
-
if (!
|
|
653
|
+
if (!(typeof val.data === 'object' && val.data !== null)) {
|
|
654
654
|
addValidationError('CHK_MSG_OBJ_GEN_310', 'invalid tableIndexes.data object property');
|
|
655
655
|
continue;
|
|
656
656
|
}
|
|
@@ -659,7 +659,7 @@ export const check_structure = function (doc, critical_error) {
|
|
|
659
659
|
addValidationError('CHK_MSG_OBJ_GEN_312', 'invalid tableIndexes.data.name property');
|
|
660
660
|
}
|
|
661
661
|
|
|
662
|
-
if (!
|
|
662
|
+
if (!Array.isArray(val.data.keys)) {
|
|
663
663
|
addValidationError('CHK_MSG_OBJ_GEN_312', 'invalid tableIndexes.data.keys Array property');
|
|
664
664
|
}
|
|
665
665
|
}
|
|
@@ -849,7 +849,7 @@ const check_table = function (doc) {
|
|
|
849
849
|
});
|
|
850
850
|
} else {
|
|
851
851
|
for (let key of index.data.keys) {
|
|
852
|
-
if (!doc.tableFields || !
|
|
852
|
+
if (!doc.tableFields || !Array.isArray(doc.tableFields) || !find_item_by_key(doc.tableFields, 'field_id', key)) {
|
|
853
853
|
ret.push({
|
|
854
854
|
code: 'CHK_MSG_TBL_IDX_080',
|
|
855
855
|
data: `invalid key ${key} in tableIndexes.data.keys for "${index.id}" index`,
|
|
@@ -992,7 +992,7 @@ const check_component = function (doc) {
|
|
|
992
992
|
}
|
|
993
993
|
|
|
994
994
|
if (key.substr(0, 6) === 'xu-on:') {
|
|
995
|
-
if (!
|
|
995
|
+
if (!xu_isEmpty(val)) {
|
|
996
996
|
for (let trigger_item of val) {
|
|
997
997
|
// try {
|
|
998
998
|
ret = [...ret, ...check_prog_triggers(doc, trigger_item.workflow, 'ui_trigger', item.id, item.attributes.tree_id)];
|
|
@@ -1026,7 +1026,7 @@ const check_component = function (doc) {
|
|
|
1026
1026
|
}
|
|
1027
1027
|
}
|
|
1028
1028
|
|
|
1029
|
-
// if (!
|
|
1029
|
+
// if (!xu_isEmpty(item.workflow)) {
|
|
1030
1030
|
// debugger;
|
|
1031
1031
|
// ret = [
|
|
1032
1032
|
// ...ret,
|
|
@@ -1098,7 +1098,7 @@ const check_set_data = function (doc) {
|
|
|
1098
1098
|
const check_alert = function (doc) {
|
|
1099
1099
|
var ret = [];
|
|
1100
1100
|
|
|
1101
|
-
if (
|
|
1101
|
+
if (xu_isEmpty(doc.alertData)) {
|
|
1102
1102
|
ret.push({
|
|
1103
1103
|
code: 'CHK_MSG_PRG_ART_010',
|
|
1104
1104
|
data: `no alert properties defined`,
|
|
@@ -1154,7 +1154,7 @@ const check_alert = function (doc) {
|
|
|
1154
1154
|
const check_route = function (doc) {
|
|
1155
1155
|
var ret = [];
|
|
1156
1156
|
|
|
1157
|
-
if (
|
|
1157
|
+
if (xu_isEmpty(doc?.routeMenu?.menu)) {
|
|
1158
1158
|
ret.push({
|
|
1159
1159
|
code: 'CHK_MSG_RTE_MNU_010',
|
|
1160
1160
|
data: `no route properties defined`,
|
|
@@ -1256,7 +1256,7 @@ const check_ai_agent = function (doc) {
|
|
|
1256
1256
|
for (const tool of doc?.agentConfig?.agent_tools || []) {
|
|
1257
1257
|
switch (tool.type) {
|
|
1258
1258
|
case 'file_search': {
|
|
1259
|
-
if (
|
|
1259
|
+
if (xu_isEmpty(tool.file)) {
|
|
1260
1260
|
ret.push({
|
|
1261
1261
|
code: 'CHK_MSG_PRG_AGN_100',
|
|
1262
1262
|
data: 'Ai Agent file_search set but could not find file configuration',
|
|
@@ -1266,7 +1266,7 @@ const check_ai_agent = function (doc) {
|
|
|
1266
1266
|
id: `${doc._id}`,
|
|
1267
1267
|
});
|
|
1268
1268
|
} else {
|
|
1269
|
-
if (
|
|
1269
|
+
if (xu_isEmpty(tool?.file?.access_link)) {
|
|
1270
1270
|
ret.push({
|
|
1271
1271
|
code: 'CHK_MSG_PRG_AGN_110',
|
|
1272
1272
|
data: 'Ai Agent file_search set but could not find file configuration',
|
|
@@ -1276,7 +1276,7 @@ const check_ai_agent = function (doc) {
|
|
|
1276
1276
|
id: `${doc._id}`,
|
|
1277
1277
|
});
|
|
1278
1278
|
} else {
|
|
1279
|
-
if (
|
|
1279
|
+
if (xu_isEmpty(tool?.file?.file_id)) {
|
|
1280
1280
|
ret.push({
|
|
1281
1281
|
code: 'CHK_MSG_PRG_AGN_120',
|
|
1282
1282
|
data: 'Ai Agent file_search set but could not find file uploaded',
|
|
@@ -1286,7 +1286,7 @@ const check_ai_agent = function (doc) {
|
|
|
1286
1286
|
id: `${doc._id}`,
|
|
1287
1287
|
});
|
|
1288
1288
|
} else {
|
|
1289
|
-
if (
|
|
1289
|
+
if (xu_isEmpty(tool?.file?.vector_file_id)) {
|
|
1290
1290
|
ret.push({
|
|
1291
1291
|
code: 'CHK_MSG_PRG_AGN_130',
|
|
1292
1292
|
data: 'Ai Agent file_search set but could not find vector_file uploaded',
|
|
@@ -1302,7 +1302,7 @@ const check_ai_agent = function (doc) {
|
|
|
1302
1302
|
break;
|
|
1303
1303
|
}
|
|
1304
1304
|
case 'youtube': {
|
|
1305
|
-
if (
|
|
1305
|
+
if (xu_isEmpty(tool?.youtube?.url)) {
|
|
1306
1306
|
ret.push({
|
|
1307
1307
|
code: 'CHK_MSG_PRG_AGN_200',
|
|
1308
1308
|
data: 'Ai Agent youtube set but could not find url',
|
|
@@ -1312,7 +1312,7 @@ const check_ai_agent = function (doc) {
|
|
|
1312
1312
|
id: `${doc._id}`,
|
|
1313
1313
|
});
|
|
1314
1314
|
} else {
|
|
1315
|
-
if (
|
|
1315
|
+
if (xu_isEmpty(tool?.youtube?.file_id)) {
|
|
1316
1316
|
ret.push({
|
|
1317
1317
|
code: 'CHK_MSG_PRG_AGN_210',
|
|
1318
1318
|
data: 'Ai Agent youtube set but could not find file uploaded',
|
|
@@ -1322,7 +1322,7 @@ const check_ai_agent = function (doc) {
|
|
|
1322
1322
|
id: `${doc._id}`,
|
|
1323
1323
|
});
|
|
1324
1324
|
} else {
|
|
1325
|
-
if (
|
|
1325
|
+
if (xu_isEmpty(tool?.youtube?.vector_store_id)) {
|
|
1326
1326
|
ret.push({
|
|
1327
1327
|
code: 'CHK_MSG_PRG_AGN_220',
|
|
1328
1328
|
data: 'Ai Agent youtube set but could not find vector_file uploaded',
|
|
@@ -1338,7 +1338,7 @@ const check_ai_agent = function (doc) {
|
|
|
1338
1338
|
}
|
|
1339
1339
|
|
|
1340
1340
|
case 'mcp': {
|
|
1341
|
-
if (
|
|
1341
|
+
if (xu_isEmpty(tool?.url)) {
|
|
1342
1342
|
ret.push({
|
|
1343
1343
|
code: 'CHK_MSG_PRG_AGN_310',
|
|
1344
1344
|
data: 'Ai Agent mcp tool set but could not find url',
|
|
@@ -1365,7 +1365,7 @@ const check_ai_agent = function (doc) {
|
|
|
1365
1365
|
break;
|
|
1366
1366
|
}
|
|
1367
1367
|
case 'table': {
|
|
1368
|
-
if (
|
|
1368
|
+
if (xu_isEmpty(tool?.prog_id)) {
|
|
1369
1369
|
ret.push({
|
|
1370
1370
|
code: 'CHK_MSG_PRG_AGN_410',
|
|
1371
1371
|
data: 'Ai Agent table tool set but could not find table id',
|
|
@@ -1381,7 +1381,7 @@ const check_ai_agent = function (doc) {
|
|
|
1381
1381
|
break;
|
|
1382
1382
|
}
|
|
1383
1383
|
case 'plugin': {
|
|
1384
|
-
if (
|
|
1384
|
+
if (xu_isEmpty(tool?.plugin_id)) {
|
|
1385
1385
|
ret.push({
|
|
1386
1386
|
code: 'CHK_MSG_PRG_AGN_510',
|
|
1387
1387
|
data: 'Ai Agent plugin tool set but could not find plugin id',
|
|
@@ -1391,7 +1391,7 @@ const check_ai_agent = function (doc) {
|
|
|
1391
1391
|
id: `${doc._id}`,
|
|
1392
1392
|
});
|
|
1393
1393
|
} else {
|
|
1394
|
-
if (
|
|
1394
|
+
if (xu_isEmpty(tool?.method)) {
|
|
1395
1395
|
ret.push({
|
|
1396
1396
|
code: 'CHK_MSG_PRG_AGN_520',
|
|
1397
1397
|
data: 'Ai Agent plugin tool set but could not find method property',
|
|
@@ -1405,7 +1405,7 @@ const check_ai_agent = function (doc) {
|
|
|
1405
1405
|
break;
|
|
1406
1406
|
}
|
|
1407
1407
|
case 'program': {
|
|
1408
|
-
if (
|
|
1408
|
+
if (xu_isEmpty(tool?.prog_id)) {
|
|
1409
1409
|
ret.push({
|
|
1410
1410
|
code: 'CHK_MSG_PRG_AGN_410',
|
|
1411
1411
|
data: 'Ai Agent program tool set but could not find program id',
|
|
@@ -1427,7 +1427,7 @@ const check_ai_agent = function (doc) {
|
|
|
1427
1427
|
// const call_project_api = function (doc) {
|
|
1428
1428
|
// var ret = [];
|
|
1429
1429
|
|
|
1430
|
-
// if (
|
|
1430
|
+
// if (xu_isEmpty(doc.alertData)) {
|
|
1431
1431
|
// ret.push({
|
|
1432
1432
|
// code: "CHK_MSG_PRG_ART_010",
|
|
1433
1433
|
// data: `no alert properties defined`,
|
|
@@ -1444,7 +1444,7 @@ const check_ai_agent = function (doc) {
|
|
|
1444
1444
|
const check_prog_fieldset = function (doc) {
|
|
1445
1445
|
var ret = [];
|
|
1446
1446
|
|
|
1447
|
-
if (!doc.progFields ||
|
|
1447
|
+
if (!doc.progFields || xu_isEmpty(doc.progFields)) {
|
|
1448
1448
|
if (doc.progDataSource.dataSourceTableId) {
|
|
1449
1449
|
ret.push({
|
|
1450
1450
|
code: 'CHK_MSG_PRG_FLD_012',
|
|
@@ -1488,7 +1488,7 @@ const check_prog_fieldset = function (doc) {
|
|
|
1488
1488
|
if (!find_field_in_progs(doc, field.data.field_id)) {
|
|
1489
1489
|
// find in Out parameters
|
|
1490
1490
|
var found_parameter_out_match;
|
|
1491
|
-
if (!
|
|
1491
|
+
if (!xu_isEmpty(doc.properties.progParams)) {
|
|
1492
1492
|
for (let parameter_item of doc.properties.progParams) {
|
|
1493
1493
|
if (parameter_item.data.dir === 'out' && parameter_item.data.parameter === field.data.field_id) {
|
|
1494
1494
|
found_parameter_out_match = true;
|
|
@@ -1552,7 +1552,7 @@ const check_prog_fieldset = function (doc) {
|
|
|
1552
1552
|
} else {
|
|
1553
1553
|
// check against table
|
|
1554
1554
|
|
|
1555
|
-
if (!doc.progDataSource ||
|
|
1555
|
+
if (!doc.progDataSource || xu_isEmpty(doc.progDataSource) || !doc.progDataSource.dataSourceType || doc.progDataSource.dataSourceType === 'none') {
|
|
1556
1556
|
ret.push({
|
|
1557
1557
|
code: 'CHK_MSG_PRG_FLD_300',
|
|
1558
1558
|
data: `undefined datasource for ${field.data.field_id} field`,
|
|
@@ -1639,7 +1639,7 @@ const check_prog_fieldset = function (doc) {
|
|
|
1639
1639
|
case 'number':
|
|
1640
1640
|
case 'boolean':
|
|
1641
1641
|
if (field?.props?.fieldValue) {
|
|
1642
|
-
if (
|
|
1642
|
+
if (Number.isNaN(Number(field?.props?.fieldValue))) {
|
|
1643
1643
|
ret.push({
|
|
1644
1644
|
code: 'CHK_MSG_PRG_FLD_210',
|
|
1645
1645
|
data: `invalid value type ${field.props.fieldType} for ${field.data.field_id} field`,
|
|
@@ -1685,10 +1685,10 @@ const check_prog_fieldset = function (doc) {
|
|
|
1685
1685
|
}
|
|
1686
1686
|
}
|
|
1687
1687
|
|
|
1688
|
-
// if (!
|
|
1688
|
+
// if (!xu_isEmpty(field.workflow)) {}
|
|
1689
1689
|
// propExpressions
|
|
1690
1690
|
|
|
1691
|
-
if (!
|
|
1691
|
+
if (!xu_isEmpty(field.workflow)) {
|
|
1692
1692
|
ret = [...ret, ...check_prog_triggers(doc, field.workflow, 'field', field.id, field.data.field_id)];
|
|
1693
1693
|
}
|
|
1694
1694
|
}
|
|
@@ -1711,7 +1711,7 @@ const check_prog_fieldset = function (doc) {
|
|
|
1711
1711
|
const check_prog_events = function (doc) {
|
|
1712
1712
|
var ret = [];
|
|
1713
1713
|
|
|
1714
|
-
if (!doc.progEvents ||
|
|
1714
|
+
if (!doc.progEvents || xu_isEmpty(doc.progEvents)) return ret;
|
|
1715
1715
|
var name_counts_obj = {};
|
|
1716
1716
|
for (let event_item of doc.progEvents) {
|
|
1717
1717
|
switch (event_item?.data?.type) {
|
|
@@ -1818,7 +1818,7 @@ const check_prog_events = function (doc) {
|
|
|
1818
1818
|
}
|
|
1819
1819
|
|
|
1820
1820
|
// check workflow
|
|
1821
|
-
if (!
|
|
1821
|
+
if (!xu_isEmpty(event_item.workflow)) {
|
|
1822
1822
|
ret = [...ret, ...check_prog_triggers(doc, event_item.workflow, 'event', event_item.id, event_item.data.event_name || event_item.data.type)];
|
|
1823
1823
|
} else {
|
|
1824
1824
|
ret.push({
|
|
@@ -1849,17 +1849,17 @@ const check_prog_events = function (doc) {
|
|
|
1849
1849
|
const check_prog_triggers = function (doc, workflow, source_type, source_id, source_name) {
|
|
1850
1850
|
var ret = [];
|
|
1851
1851
|
|
|
1852
|
-
if (!workflow ||
|
|
1852
|
+
if (!workflow || xu_isEmpty(workflow)) return ret;
|
|
1853
1853
|
|
|
1854
1854
|
const check_target_program_parameters = function (trigger_item) {
|
|
1855
1855
|
if (!trigger_item.data.name.prog) return;
|
|
1856
1856
|
|
|
1857
1857
|
const target_program_parameters_arr = progs_obj?.[trigger_item.data.name.prog]?.properties?.progParams || [];
|
|
1858
1858
|
|
|
1859
|
-
if (trigger_item?.data?.name?.parameters && !
|
|
1859
|
+
if (trigger_item?.data?.name?.parameters && !xu_isEmpty(trigger_item.data.name.parameters)) {
|
|
1860
1860
|
for (let [key, val] of Object.entries(trigger_item.data.name.parameters)) {
|
|
1861
1861
|
const param_ret = find_item_by_key(target_program_parameters_arr, 'parameter', key);
|
|
1862
|
-
if (
|
|
1862
|
+
if (xu_isEmpty(param_ret)) {
|
|
1863
1863
|
ret.push({
|
|
1864
1864
|
code: 'CHK_MSG_PRG_TRG_370',
|
|
1865
1865
|
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`,
|
|
@@ -2083,9 +2083,9 @@ const check_prog_triggers = function (doc, workflow, source_type, source_id, sou
|
|
|
2083
2083
|
});
|
|
2084
2084
|
} else {
|
|
2085
2085
|
// if exist check parameters
|
|
2086
|
-
if (ret_event_name.length === 1 && !
|
|
2086
|
+
if (ret_event_name.length === 1 && !xu_isEmpty(trigger_item.data.name.parameters)) {
|
|
2087
2087
|
for (let [key, val] of Object.entries(trigger_item.data.name.parameters)) {
|
|
2088
|
-
if (
|
|
2088
|
+
if (xu_isEmpty(progs_obj?.[ret_event_name[0].prog_id].progFields)) {
|
|
2089
2089
|
if (!find_item_by_key(progs_obj?.[ret_event_name[0].prog_id].progFields, 'field_id', key)) {
|
|
2090
2090
|
ret.push({
|
|
2091
2091
|
code: 'CHK_MSG_PRG_TRG_130',
|
|
@@ -2406,13 +2406,13 @@ const check_prog_triggers = function (doc, workflow, source_type, source_id, sou
|
|
|
2406
2406
|
// // // if exist check parameters
|
|
2407
2407
|
// // if (
|
|
2408
2408
|
// // ret_event_name.length === 1 &&
|
|
2409
|
-
// // !
|
|
2409
|
+
// // !xu_isEmpty(trigger_item.data.name.parameters)
|
|
2410
2410
|
// // ) {
|
|
2411
2411
|
// // for (let [key, val] of Object.entries(
|
|
2412
2412
|
// // trigger_item.data.name.parameters
|
|
2413
2413
|
// // )) {
|
|
2414
2414
|
// // if (
|
|
2415
|
-
// //
|
|
2415
|
+
// // xu_isEmpty(progs_obj[ret_event_name[0].prog_id].progFields)
|
|
2416
2416
|
// // ) {
|
|
2417
2417
|
// // if (
|
|
2418
2418
|
// // !find_item_by_key(
|
|
@@ -2439,7 +2439,7 @@ const check_prog_triggers = function (doc, workflow, source_type, source_id, sou
|
|
|
2439
2439
|
break;
|
|
2440
2440
|
|
|
2441
2441
|
case 'alert':
|
|
2442
|
-
if (
|
|
2442
|
+
if (xu_isEmpty(trigger_item.data.name)) {
|
|
2443
2443
|
ret.push({
|
|
2444
2444
|
code: 'CHK_MSG_PRG_TRG_610',
|
|
2445
2445
|
data: `no alert properties defined`,
|
|
@@ -2658,7 +2658,7 @@ const check_prog_triggers = function (doc, workflow, source_type, source_id, sou
|
|
|
2658
2658
|
const check_prog_datasource = function (doc) {
|
|
2659
2659
|
var ret = [];
|
|
2660
2660
|
|
|
2661
|
-
if (!doc.progDataSource ||
|
|
2661
|
+
if (!doc.progDataSource || xu_isEmpty(doc.progDataSource) || !doc.progDataSource.dataSourceType || doc.progDataSource.dataSourceType === 'none') {
|
|
2662
2662
|
return ret;
|
|
2663
2663
|
}
|
|
2664
2664
|
|
|
@@ -3014,7 +3014,7 @@ const find_field_in_progs = function (doc, field_id, prog_id) {
|
|
|
3014
3014
|
fields_arr = prog.progFields;
|
|
3015
3015
|
}
|
|
3016
3016
|
|
|
3017
|
-
if (
|
|
3017
|
+
if (xu_isEmpty(fields_arr)) {
|
|
3018
3018
|
continue;
|
|
3019
3019
|
}
|
|
3020
3020
|
|
|
@@ -3068,11 +3068,11 @@ const check_prog_expression = function (doc, exp, path, category) {
|
|
|
3068
3068
|
}
|
|
3069
3069
|
|
|
3070
3070
|
// error ocurred
|
|
3071
|
-
if (!
|
|
3071
|
+
if (!xu_isEmpty(ret)) {
|
|
3072
3072
|
return ret;
|
|
3073
3073
|
}
|
|
3074
3074
|
|
|
3075
|
-
if (
|
|
3075
|
+
if (xu_isEmpty(field_matches)) {
|
|
3076
3076
|
// try {
|
|
3077
3077
|
// eval(exp);
|
|
3078
3078
|
// } catch (err) {
|
|
@@ -3203,7 +3203,7 @@ const find_event_id_in_progs = function (doc, event_id) {
|
|
|
3203
3203
|
var ret = [];
|
|
3204
3204
|
|
|
3205
3205
|
for (let [key, prog] of Object.entries(progs_obj)) {
|
|
3206
|
-
if (!prog.progEvents ||
|
|
3206
|
+
if (!prog.progEvents || xu_isEmpty(prog.progEvents)) {
|
|
3207
3207
|
continue;
|
|
3208
3208
|
}
|
|
3209
3209
|
//&& prog._id !== doc._id
|
|
@@ -3224,7 +3224,7 @@ const find_xu_tree_id_in_progs = function (doc, xu_tree_id) {
|
|
|
3224
3224
|
var ret = [];
|
|
3225
3225
|
|
|
3226
3226
|
for (let [key, prog] of Object.entries(progs_obj)) {
|
|
3227
|
-
if (!prog.progUi ||
|
|
3227
|
+
if (!prog.progUi || xu_isEmpty(prog.progUi)) {
|
|
3228
3228
|
continue;
|
|
3229
3229
|
}
|
|
3230
3230
|
|
|
@@ -3291,7 +3291,7 @@ const find_trigger_property_value_in_progs = function (doc, triggers_arr, proper
|
|
|
3291
3291
|
|
|
3292
3292
|
const run_program_search = function (prog) {
|
|
3293
3293
|
// find in events
|
|
3294
|
-
if (prog?.progEvents && !
|
|
3294
|
+
if (prog?.progEvents && !xu_isEmpty(prog.progEvents)) {
|
|
3295
3295
|
for (let event_item of prog.progEvents) {
|
|
3296
3296
|
if (event_item.workflow) {
|
|
3297
3297
|
find_in_triggers(prog, event_item.workflow);
|
|
@@ -3300,7 +3300,7 @@ const find_trigger_property_value_in_progs = function (doc, triggers_arr, proper
|
|
|
3300
3300
|
}
|
|
3301
3301
|
|
|
3302
3302
|
// find in fields
|
|
3303
|
-
if (prog?.progFields && !
|
|
3303
|
+
if (prog?.progFields && !xu_isEmpty(prog.progFields)) {
|
|
3304
3304
|
for (let field_item of prog.progFields) {
|
|
3305
3305
|
if (field_item.workflow) {
|
|
3306
3306
|
find_in_triggers(prog, field_item.workflow);
|
|
@@ -3309,14 +3309,14 @@ const find_trigger_property_value_in_progs = function (doc, triggers_arr, proper
|
|
|
3309
3309
|
}
|
|
3310
3310
|
|
|
3311
3311
|
// find in ui workflow
|
|
3312
|
-
if (prog?.progUi && !
|
|
3312
|
+
if (prog?.progUi && !xu_isEmpty(prog.progUi)) {
|
|
3313
3313
|
const run_tree = function (node) {
|
|
3314
3314
|
try {
|
|
3315
3315
|
for (let item of node) {
|
|
3316
3316
|
if (item.attributes) {
|
|
3317
3317
|
for (let [key, val] of Object.entries(item.attributes)) {
|
|
3318
3318
|
if (key.substr(0, 6) === 'xu-on:') {
|
|
3319
|
-
if (!
|
|
3319
|
+
if (!xu_isEmpty(val)) {
|
|
3320
3320
|
for (let trigger_item of val) {
|
|
3321
3321
|
find_in_triggers(prog, trigger_item.workflow);
|
|
3322
3322
|
}
|
|
@@ -3352,7 +3352,7 @@ const find_panel_prog_in_progs = function (doc, prog_id, search_in_doc_prog_only
|
|
|
3352
3352
|
var ret = [];
|
|
3353
3353
|
|
|
3354
3354
|
const find_in_prog = function (prog) {
|
|
3355
|
-
if (
|
|
3355
|
+
if (xu_isEmpty(prog?.progUi)) return;
|
|
3356
3356
|
|
|
3357
3357
|
const run_tree = function (node) {
|
|
3358
3358
|
for (let item of node) {
|
|
@@ -3404,7 +3404,7 @@ const find_table_in_progs = function (doc, table_id, search_in_doc_prog_only) {
|
|
|
3404
3404
|
// for (let [key, prog] of Object.entries(progs_obj)) {
|
|
3405
3405
|
// if (
|
|
3406
3406
|
// !prog.progDataSource ||
|
|
3407
|
-
//
|
|
3407
|
+
// xu_isEmpty(prog.progDataSource) ||
|
|
3408
3408
|
// prog.progDataSource.dataSourceType !== "table"
|
|
3409
3409
|
// ) {
|
|
3410
3410
|
// continue;
|
|
@@ -3421,7 +3421,7 @@ const find_table_in_progs = function (doc, table_id, search_in_doc_prog_only) {
|
|
|
3421
3421
|
// }
|
|
3422
3422
|
|
|
3423
3423
|
const find_in_prog = function (prog) {
|
|
3424
|
-
if (!prog.progDataSource ||
|
|
3424
|
+
if (!prog.progDataSource || xu_isEmpty(prog.progDataSource) || prog.progDataSource.dataSourceType !== 'table') {
|
|
3425
3425
|
return;
|
|
3426
3426
|
}
|
|
3427
3427
|
|