@xuda.io/xuda-worker-bundle-min 1.3.144 → 1.3.145
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.js +812 -384
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -8287,434 +8287,862 @@ func.expression.get = async function (
|
|
|
8287
8287
|
js_script_callback,
|
|
8288
8288
|
jobNo
|
|
8289
8289
|
) {
|
|
8290
|
-
|
|
8291
|
-
|
|
8292
|
-
|
|
8293
|
-
|
|
8294
|
-
|
|
8295
|
-
|
|
8296
|
-
return eval("(" + text + ")");
|
|
8297
|
-
}
|
|
8298
|
-
|
|
8299
|
-
//==============================
|
|
8300
|
-
// check if str and convert
|
|
8290
|
+
class xu_class {
|
|
8291
|
+
async get() {
|
|
8292
|
+
var ret;
|
|
8293
|
+
var fields = {};
|
|
8294
|
+
var error;
|
|
8295
|
+
var warning;
|
|
8301
8296
|
|
|
8302
|
-
|
|
8303
|
-
|
|
8304
|
-
|
|
8305
|
-
// ret = valP.toString(); //_.toString(valP);
|
|
8306
|
-
// }
|
|
8307
|
-
|
|
8308
|
-
if (valP === null) {
|
|
8309
|
-
ret = "";
|
|
8310
|
-
} else {
|
|
8311
|
-
switch (typeof valP) {
|
|
8312
|
-
case "string":
|
|
8313
|
-
ret = valP;
|
|
8314
|
-
break;
|
|
8297
|
+
function evalJson(text) {
|
|
8298
|
+
return eval("(" + text + ")");
|
|
8299
|
+
}
|
|
8315
8300
|
|
|
8316
|
-
|
|
8301
|
+
if (valP === null) {
|
|
8317
8302
|
ret = "";
|
|
8318
|
-
|
|
8303
|
+
} else {
|
|
8304
|
+
switch (typeof valP) {
|
|
8305
|
+
case "string":
|
|
8306
|
+
ret = valP;
|
|
8307
|
+
break;
|
|
8319
8308
|
|
|
8320
|
-
|
|
8321
|
-
|
|
8322
|
-
|
|
8309
|
+
case "undefined":
|
|
8310
|
+
ret = "";
|
|
8311
|
+
break;
|
|
8323
8312
|
|
|
8324
|
-
|
|
8325
|
-
|
|
8326
|
-
|
|
8327
|
-
}
|
|
8328
|
-
}
|
|
8313
|
+
case "boolean":
|
|
8314
|
+
ret = valP ? "Y" : "N";
|
|
8315
|
+
break;
|
|
8329
8316
|
|
|
8330
|
-
|
|
8331
|
-
|
|
8332
|
-
|
|
8333
|
-
for (const [key, val] of Object.entries(fields)) {
|
|
8334
|
-
if (typeof val === "string")
|
|
8335
|
-
ret = ret.replace('"' + val + '"', val.replace(/"/gi, ""));
|
|
8336
|
-
}
|
|
8337
|
-
return ret;
|
|
8338
|
-
};
|
|
8339
|
-
if (sourceP === "update" || sourceP === "javascript") {
|
|
8340
|
-
if (typeof ret === "string") ret = replace_quotes(ret);
|
|
8341
|
-
}
|
|
8342
|
-
const log_error = function () {
|
|
8343
|
-
if (SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP]) {
|
|
8344
|
-
func.utils.debug.log(
|
|
8345
|
-
SESSION_ID,
|
|
8346
|
-
SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].nodeId,
|
|
8347
|
-
{
|
|
8348
|
-
module: "expression",
|
|
8349
|
-
action: sourceP,
|
|
8350
|
-
source: calling_fieldIdP,
|
|
8351
|
-
prop: ret,
|
|
8352
|
-
details: ret,
|
|
8353
|
-
result: ret,
|
|
8354
|
-
error: error,
|
|
8355
|
-
warning: warning,
|
|
8356
|
-
fields: null,
|
|
8357
|
-
type: "exp",
|
|
8358
|
-
prog_id: SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].prog_id,
|
|
8359
|
-
debug_info: debug_infoP,
|
|
8360
|
-
}
|
|
8361
|
-
);
|
|
8362
|
-
}
|
|
8363
|
-
};
|
|
8364
|
-
if (error) log_error();
|
|
8365
|
-
// if (error || warning) log_error();
|
|
8366
|
-
return {
|
|
8367
|
-
result: ret,
|
|
8368
|
-
fields: fields,
|
|
8369
|
-
res: res,
|
|
8370
|
-
explain: result,
|
|
8371
|
-
error: error,
|
|
8372
|
-
warning: warning,
|
|
8373
|
-
req: valP,
|
|
8374
|
-
var_error_found: var_error_found,
|
|
8375
|
-
};
|
|
8376
|
-
};
|
|
8377
|
-
const variable_not_exist = async function () {
|
|
8378
|
-
try {
|
|
8379
|
-
if (sourceP !== "arguments") {
|
|
8380
|
-
if (ret && ret.substr(0, 6) === "_DATE_") {
|
|
8381
|
-
ret = ret.substr(6);
|
|
8382
|
-
} else if (
|
|
8383
|
-
(ret &&
|
|
8384
|
-
ret.length === 10 &&
|
|
8385
|
-
ret.substr(4, 1) === "-" &&
|
|
8386
|
-
ret.substr(7, 1) === "-") ||
|
|
8387
|
-
ret === "self" // bypass eval for date 2017-03-22
|
|
8388
|
-
) {
|
|
8389
|
-
ret = ret;
|
|
8390
|
-
} else {
|
|
8391
|
-
// ret = secure_eval(ret); //eval(ret);
|
|
8392
|
-
ret = await func.expression.secure_eval(
|
|
8393
|
-
SESSION_ID,
|
|
8394
|
-
sourceP,
|
|
8395
|
-
ret,
|
|
8396
|
-
jobNo,
|
|
8397
|
-
dsSessionP,
|
|
8398
|
-
js_script_callback
|
|
8399
|
-
);
|
|
8400
|
-
}
|
|
8401
|
-
// console.log("AFTER OK", ret)
|
|
8402
|
-
return end_results();
|
|
8403
|
-
} else {
|
|
8404
|
-
// do eval for arithmetic vals
|
|
8405
|
-
ret = ret.replace(/_NULL/gi, "");
|
|
8406
|
-
return end_results();
|
|
8407
|
-
}
|
|
8408
|
-
} catch (err) {
|
|
8409
|
-
// console.error(err);
|
|
8410
|
-
return end_results();
|
|
8411
|
-
}
|
|
8412
|
-
};
|
|
8413
|
-
if (!func.expression.validate_variables(valP)) {
|
|
8414
|
-
return await variable_not_exist();
|
|
8415
|
-
}
|
|
8416
|
-
var split = [];
|
|
8417
|
-
var var_Arr = [];
|
|
8418
|
-
split = func.expression.parse(ret);
|
|
8419
|
-
for await (const [arr_key, val] of Object.entries(split)) {
|
|
8420
|
-
// run each field
|
|
8421
|
-
const key = Number(arr_key);
|
|
8422
|
-
var_Arr[key] = {};
|
|
8423
|
-
var_Arr[key].value = val.value;
|
|
8424
|
-
//--------------
|
|
8425
|
-
const replace_value_in_string = function (retP, fieldIdP) {
|
|
8426
|
-
if (
|
|
8427
|
-
iterate_info?.iterator_key === fieldIdP ||
|
|
8428
|
-
iterate_info?.iterator_val === fieldIdP
|
|
8429
|
-
) {
|
|
8430
|
-
if (iterate_info.iterator_key === fieldIdP) {
|
|
8431
|
-
retP.value = iterate_info._key;
|
|
8432
|
-
}
|
|
8433
|
-
if (iterate_info.iterator_val === fieldIdP) {
|
|
8434
|
-
retP.value = iterate_info._val;
|
|
8317
|
+
default:
|
|
8318
|
+
ret = valP.toString();
|
|
8319
|
+
break;
|
|
8435
8320
|
}
|
|
8436
8321
|
}
|
|
8437
8322
|
|
|
8438
|
-
|
|
8439
|
-
|
|
8440
|
-
|
|
8441
|
-
|
|
8442
|
-
|
|
8443
|
-
|
|
8444
|
-
|
|
8445
|
-
|
|
8323
|
+
ret = ret.replace(/\&/g, "&");
|
|
8324
|
+
const end_results = function () {
|
|
8325
|
+
const replace_quotes = function (ret) {
|
|
8326
|
+
for (const [key, val] of Object.entries(fields)) {
|
|
8327
|
+
if (typeof val === "string")
|
|
8328
|
+
ret = ret.replace('"' + val + '"', val.replace(/"/gi, ""));
|
|
8329
|
+
}
|
|
8330
|
+
return ret;
|
|
8331
|
+
};
|
|
8332
|
+
if (sourceP === "update" || sourceP === "javascript") {
|
|
8333
|
+
if (typeof ret === "string") ret = replace_quotes(ret);
|
|
8334
|
+
}
|
|
8335
|
+
const log_error = function () {
|
|
8336
|
+
if (SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP]) {
|
|
8337
|
+
func.utils.debug.log(
|
|
8338
|
+
SESSION_ID,
|
|
8339
|
+
SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].nodeId,
|
|
8340
|
+
{
|
|
8341
|
+
module: "expression",
|
|
8342
|
+
action: sourceP,
|
|
8343
|
+
source: calling_fieldIdP,
|
|
8344
|
+
prop: ret,
|
|
8345
|
+
details: ret,
|
|
8346
|
+
result: ret,
|
|
8347
|
+
error: error,
|
|
8348
|
+
warning: warning,
|
|
8349
|
+
fields: null,
|
|
8350
|
+
type: "exp",
|
|
8351
|
+
prog_id: SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].prog_id,
|
|
8352
|
+
debug_info: debug_infoP,
|
|
8353
|
+
}
|
|
8354
|
+
);
|
|
8355
|
+
}
|
|
8356
|
+
};
|
|
8357
|
+
if (error) log_error();
|
|
8358
|
+
// if (error || warning) log_error();
|
|
8359
|
+
return {
|
|
8360
|
+
result: ret,
|
|
8361
|
+
fields: fields,
|
|
8362
|
+
res: res,
|
|
8363
|
+
explain: result,
|
|
8364
|
+
error: error,
|
|
8365
|
+
warning: warning,
|
|
8366
|
+
req: valP,
|
|
8367
|
+
var_error_found: var_error_found,
|
|
8368
|
+
};
|
|
8369
|
+
};
|
|
8370
|
+
const variable_not_exist = async function () {
|
|
8371
|
+
try {
|
|
8372
|
+
if (sourceP !== "arguments") {
|
|
8373
|
+
if (ret && ret.substr(0, 6) === "_DATE_") {
|
|
8374
|
+
ret = ret.substr(6);
|
|
8375
|
+
} else if (
|
|
8376
|
+
(ret &&
|
|
8377
|
+
ret.length === 10 &&
|
|
8378
|
+
ret.substr(4, 1) === "-" &&
|
|
8379
|
+
ret.substr(7, 1) === "-") ||
|
|
8380
|
+
ret === "self" // bypass eval for date 2017-03-22
|
|
8381
|
+
) {
|
|
8382
|
+
ret = ret;
|
|
8383
|
+
} else {
|
|
8384
|
+
// ret = secure_eval(ret); //eval(ret);
|
|
8385
|
+
ret = await func.expression.secure_eval(
|
|
8386
|
+
SESSION_ID,
|
|
8387
|
+
sourceP,
|
|
8388
|
+
ret,
|
|
8389
|
+
jobNo,
|
|
8390
|
+
dsSessionP,
|
|
8391
|
+
js_script_callback
|
|
8392
|
+
);
|
|
8393
|
+
}
|
|
8394
|
+
// console.log("AFTER OK", ret)
|
|
8395
|
+
return end_results();
|
|
8396
|
+
} else {
|
|
8397
|
+
// do eval for arithmetic vals
|
|
8398
|
+
ret = ret.replace(/_NULL/gi, "");
|
|
8399
|
+
return end_results();
|
|
8446
8400
|
}
|
|
8401
|
+
} catch (err) {
|
|
8402
|
+
// console.error(err);
|
|
8403
|
+
return end_results();
|
|
8447
8404
|
}
|
|
8448
8405
|
};
|
|
8449
|
-
|
|
8450
|
-
|
|
8451
|
-
|
|
8452
|
-
|
|
8453
|
-
|
|
8454
|
-
|
|
8455
|
-
|
|
8456
|
-
|
|
8457
|
-
|
|
8458
|
-
|
|
8459
|
-
|
|
8460
|
-
|
|
8461
|
-
|
|
8462
|
-
//check for split situation: @objB[@var].property 1: @objB[ 2:@var].property
|
|
8406
|
+
if (!func.expression.validate_variables(valP)) {
|
|
8407
|
+
return await variable_not_exist();
|
|
8408
|
+
}
|
|
8409
|
+
var split = [];
|
|
8410
|
+
var var_Arr = [];
|
|
8411
|
+
split = func.expression.parse(ret);
|
|
8412
|
+
for await (const [arr_key, val] of Object.entries(split)) {
|
|
8413
|
+
// run each field
|
|
8414
|
+
const key = Number(arr_key);
|
|
8415
|
+
var_Arr[key] = {};
|
|
8416
|
+
var_Arr[key].value = val.value;
|
|
8417
|
+
//--------------
|
|
8418
|
+
const replace_value_in_string = function (retP, fieldIdP) {
|
|
8463
8419
|
if (
|
|
8464
|
-
|
|
8465
|
-
|
|
8466
|
-
val.value.substr(0, 1) === "@"
|
|
8420
|
+
iterate_info?.iterator_key === fieldIdP ||
|
|
8421
|
+
iterate_info?.iterator_val === fieldIdP
|
|
8467
8422
|
) {
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
var_Arr[key].value = prevData[data]; // @objB[@var]
|
|
8471
|
-
if (val.value.indexOf(".") > -1) {
|
|
8472
|
-
property2 = func.expression.get_property(val.value).property2; //val.value.substr(val.value.indexOf(".") + 1, val.value.length); // get .
|
|
8473
|
-
if (prevData[data]) set_value(prevData[data][property2]);
|
|
8474
|
-
// var_Arr[key].value = prevData[data][property2]; //@objB[@var].property
|
|
8423
|
+
if (iterate_info.iterator_key === fieldIdP) {
|
|
8424
|
+
retP.value = iterate_info._key;
|
|
8475
8425
|
}
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
8426
|
+
if (iterate_info.iterator_val === fieldIdP) {
|
|
8427
|
+
retP.value = iterate_info._val;
|
|
8428
|
+
}
|
|
8429
|
+
}
|
|
8430
|
+
|
|
8431
|
+
const set_value = function (valP) {
|
|
8432
|
+
if (typeof valP !== "undefined") {
|
|
8433
|
+
var_Arr[key].value = valP;
|
|
8434
|
+
if (typeof valP === "string") var_Arr[key].type = "string";
|
|
8435
|
+
} else {
|
|
8436
|
+
if (retP.type === "object") {
|
|
8437
|
+
var_Arr[key].value = "";
|
|
8438
|
+
var_Arr[key].type = "string";
|
|
8484
8439
|
}
|
|
8485
8440
|
}
|
|
8486
|
-
|
|
8441
|
+
};
|
|
8442
|
+
|
|
8443
|
+
if (sourceP === "exp" && retP.type !== "exp") {
|
|
8444
|
+
var_Arr[key].type = retP.type;
|
|
8445
|
+
return;
|
|
8446
|
+
}
|
|
8447
|
+
if (typeof retP.value !== "undefined") {
|
|
8448
|
+
var_Arr[key].type = retP.type;
|
|
8449
|
+
var_Arr[key].value = retP.value;
|
|
8450
|
+
if ((val.value.indexOf("[") > -1) | (val.value.indexOf(".") > -1)) {
|
|
8451
|
+
//get values from array '@var==="sss" && @var_B==="sss" && @obj.property===5 && @objA["value"]===123 | @objB["value"].property===1234'
|
|
8452
|
+
var data = retP.prop;
|
|
8453
|
+
if (retP.type === "object") data = retP.value;
|
|
8454
|
+
var property1, property2;
|
|
8455
|
+
//check for split situation: @objB[@var].property 1: @objB[ 2:@var].property
|
|
8487
8456
|
if (
|
|
8488
|
-
|
|
8457
|
+
val.value.indexOf("[") === -1 &&
|
|
8458
|
+
val.value.indexOf("]") > -1 &&
|
|
8459
|
+
val.value.substr(0, 1) === "@"
|
|
8489
8460
|
) {
|
|
8490
|
-
|
|
8461
|
+
//check situation 2
|
|
8462
|
+
var prevData = var_Arr[key - 1].value;
|
|
8463
|
+
var_Arr[key].value = prevData[data]; // @objB[@var]
|
|
8464
|
+
if (val.value.indexOf(".") > -1) {
|
|
8465
|
+
property2 = func.expression.get_property(val.value).property2; //val.value.substr(val.value.indexOf(".") + 1, val.value.length); // get .
|
|
8466
|
+
if (prevData[data]) set_value(prevData[data][property2]);
|
|
8467
|
+
// var_Arr[key].value = prevData[data][property2]; //@objB[@var].property
|
|
8468
|
+
}
|
|
8469
|
+
delete var_Arr[key - 1];
|
|
8470
|
+
} else {
|
|
8471
|
+
property1 = func.expression.get_property(val.value).property1;
|
|
8472
|
+
property2 = func.expression.get_property(val.value).property2;
|
|
8473
|
+
if (property1) {
|
|
8474
|
+
var_Arr[key].value = data[property1]; // @var["value"] or @var.property
|
|
8475
|
+
if (property2) {
|
|
8476
|
+
if (data[property1]) set_value(data[property1][property2]);
|
|
8477
|
+
}
|
|
8478
|
+
}
|
|
8479
|
+
if (property2 && !property1) {
|
|
8480
|
+
if (
|
|
8481
|
+
data //data[property2]
|
|
8482
|
+
) {
|
|
8483
|
+
set_value(data[property2]);
|
|
8484
|
+
}
|
|
8485
|
+
}
|
|
8491
8486
|
}
|
|
8487
|
+
fields[fieldIdP] = var_Arr[key].value; // added 051017 to allow @SYS_GLOBAL_OBJ_WIDGET_INFO.doc_id
|
|
8488
|
+
var_Arr[key].fieldId = fieldIdP;
|
|
8489
|
+
} else {
|
|
8490
|
+
fields[fieldIdP] = var_Arr[key].value; // update flat no warpers
|
|
8491
|
+
var_Arr[key].fieldId = fieldIdP;
|
|
8492
8492
|
}
|
|
8493
8493
|
}
|
|
8494
|
-
|
|
8495
|
-
|
|
8496
|
-
|
|
8497
|
-
|
|
8498
|
-
|
|
8499
|
-
|
|
8500
|
-
|
|
8501
|
-
|
|
8502
|
-
|
|
8503
|
-
|
|
8504
|
-
|
|
8505
|
-
|
|
8506
|
-
|
|
8507
|
-
|
|
8508
|
-
|
|
8509
|
-
|
|
8510
|
-
|
|
8511
|
-
|
|
8512
|
-
|
|
8513
|
-
|
|
8514
|
-
|
|
8515
|
-
|
|
8516
|
-
val.fieldId =
|
|
8517
|
-
calling_fieldIdP + val.fieldId(5, val.fieldId.length - 1);
|
|
8518
|
-
}
|
|
8519
|
-
if (!sourceP === "exp") {
|
|
8520
|
-
var_Arr[key].value = '""';
|
|
8521
|
-
} // put default
|
|
8522
|
-
fields[val.fieldId] = var_Arr[key].value;
|
|
8523
|
-
|
|
8524
|
-
const ret = await func.datasource.get_value(
|
|
8525
|
-
SESSION_ID,
|
|
8526
|
-
val.fieldId,
|
|
8527
|
-
dsSessionP,
|
|
8494
|
+
};
|
|
8495
|
+
//>>>>>>>>>>>>>>>>>>
|
|
8496
|
+
//>>>> start here >>
|
|
8497
|
+
//>>>>>>>>>>>>>>>>>>
|
|
8498
|
+
if (val.fieldId) {
|
|
8499
|
+
// @_THIS
|
|
8500
|
+
if (
|
|
8501
|
+
val.fieldId &&
|
|
8502
|
+
val.fieldId.substr(0, 5) === "_THIS" &&
|
|
8503
|
+
calling_fieldIdP &&
|
|
8504
|
+
(val.fieldId.length === 5 ||
|
|
8505
|
+
(val.fieldId.length > 5 && val.fieldId.substr(5, 1) === "."))
|
|
8506
|
+
) {
|
|
8507
|
+
if (val.fieldId.length === 5) val.fieldId = calling_fieldIdP;
|
|
8508
|
+
else
|
|
8509
|
+
val.fieldId =
|
|
8510
|
+
calling_fieldIdP + val.fieldId(5, val.fieldId.length - 1);
|
|
8511
|
+
}
|
|
8512
|
+
if (!sourceP === "exp") {
|
|
8513
|
+
var_Arr[key].value = '""';
|
|
8514
|
+
} // put default
|
|
8515
|
+
fields[val.fieldId] = var_Arr[key].value;
|
|
8528
8516
|
|
|
8529
|
-
|
|
8530
|
-
|
|
8517
|
+
const ret = await func.datasource.get_value(
|
|
8518
|
+
SESSION_ID,
|
|
8519
|
+
val.fieldId,
|
|
8520
|
+
dsSessionP,
|
|
8531
8521
|
|
|
8532
|
-
|
|
8533
|
-
|
|
8534
|
-
}
|
|
8535
|
-
try {
|
|
8536
|
-
// eval the expression
|
|
8537
|
-
var res = [];
|
|
8538
|
-
var exp_exist;
|
|
8539
|
-
var var_error_found;
|
|
8540
|
-
// merge arr values
|
|
8541
|
-
_.forEach(var_Arr, function (val, key) {
|
|
8542
|
-
if (sourceP === "UI Property EXP") {
|
|
8543
|
-
let ret = func.utils.get_drive_url(SESSION_ID, val.value, true);
|
|
8544
|
-
if (ret.changed) {
|
|
8545
|
-
res[key] = ret.value;
|
|
8546
|
-
return true;
|
|
8547
|
-
}
|
|
8548
|
-
}
|
|
8522
|
+
rowIdP
|
|
8523
|
+
); // find field in dataSources
|
|
8549
8524
|
|
|
8550
|
-
|
|
8551
|
-
let ret = func.utils.get_drive_url(
|
|
8552
|
-
SESSION_ID,
|
|
8553
|
-
val.value,
|
|
8554
|
-
var_Arr.length == 1 ? false : true
|
|
8555
|
-
);
|
|
8556
|
-
if (ret.changed) {
|
|
8557
|
-
res[key] = ret.value;
|
|
8558
|
-
return true;
|
|
8525
|
+
replace_value_in_string(ret.ret, ret.fieldIdP);
|
|
8559
8526
|
}
|
|
8560
8527
|
}
|
|
8561
|
-
|
|
8562
|
-
|
|
8563
|
-
|
|
8564
|
-
|
|
8565
|
-
|
|
8566
|
-
|
|
8567
|
-
|
|
8568
|
-
|
|
8569
|
-
|
|
8570
|
-
|
|
8571
|
-
|
|
8572
|
-
|
|
8573
|
-
|
|
8574
|
-
res[key] = "`" + val.value + "`"; //res[key] = "'" + val.value + "'"; //
|
|
8575
|
-
}
|
|
8576
|
-
if (val.fieldId && val.value && typeof val.value === "string") {
|
|
8577
|
-
if (
|
|
8578
|
-
sourceP === "query" ||
|
|
8579
|
-
sourceP === "condition" ||
|
|
8580
|
-
sourceP === "range" ||
|
|
8581
|
-
sourceP === "sort" ||
|
|
8582
|
-
sourceP === "locate"
|
|
8583
|
-
) {
|
|
8584
|
-
if (val.value.indexOf("↵") > -1) {
|
|
8585
|
-
res[key] = val.value.split("↵").join("");
|
|
8528
|
+
try {
|
|
8529
|
+
// eval the expression
|
|
8530
|
+
var res = [];
|
|
8531
|
+
var exp_exist;
|
|
8532
|
+
var var_error_found;
|
|
8533
|
+
// merge arr values
|
|
8534
|
+
_.forEach(var_Arr, function (val, key) {
|
|
8535
|
+
if (sourceP === "UI Property EXP") {
|
|
8536
|
+
let ret = func.utils.get_drive_url(SESSION_ID, val.value, true);
|
|
8537
|
+
if (ret.changed) {
|
|
8538
|
+
res[key] = ret.value;
|
|
8539
|
+
return true;
|
|
8540
|
+
}
|
|
8586
8541
|
}
|
|
8587
|
-
res[key] = res[key].replace(/(\r\n|\n|\r)/gm, ""); //.replace(/"/g,'\"');//.replace(/'/g,"");
|
|
8588
|
-
}
|
|
8589
8542
|
|
|
8590
|
-
|
|
8591
|
-
|
|
8592
|
-
|
|
8593
|
-
|
|
8594
|
-
|
|
8595
|
-
|
|
8596
|
-
|
|
8597
|
-
|
|
8598
|
-
|
|
8543
|
+
if (sourceP === "UI Attr EXP") {
|
|
8544
|
+
let ret = func.utils.get_drive_url(
|
|
8545
|
+
SESSION_ID,
|
|
8546
|
+
val.value,
|
|
8547
|
+
var_Arr.length == 1 ? false : true
|
|
8548
|
+
);
|
|
8549
|
+
if (ret.changed) {
|
|
8550
|
+
res[key] = ret.value;
|
|
8551
|
+
return true;
|
|
8552
|
+
}
|
|
8553
|
+
}
|
|
8599
8554
|
|
|
8600
|
-
|
|
8601
|
-
|
|
8602
|
-
|
|
8555
|
+
if (val.type === "exp") {
|
|
8556
|
+
exp_exist = true;
|
|
8557
|
+
}
|
|
8558
|
+
res[key] = val.value;
|
|
8559
|
+
if (
|
|
8560
|
+
sourceP !== "DbQuery" &&
|
|
8561
|
+
sourceP !== "alert" &&
|
|
8562
|
+
sourceP !== "exp" &&
|
|
8563
|
+
sourceP !== "api_rendered_output" &&
|
|
8564
|
+
(val.type === "string" ||
|
|
8565
|
+
val.type === "date" ||
|
|
8566
|
+
val.type === "time") &&
|
|
8567
|
+
var_Arr.length > 1
|
|
8568
|
+
) {
|
|
8569
|
+
res[key] = "`" + val.value + "`"; //res[key] = "'" + val.value + "'"; //
|
|
8570
|
+
}
|
|
8571
|
+
if (val.fieldId && val.value && typeof val.value === "string") {
|
|
8572
|
+
if (
|
|
8573
|
+
sourceP === "query" ||
|
|
8574
|
+
sourceP === "condition" ||
|
|
8575
|
+
sourceP === "range" ||
|
|
8576
|
+
sourceP === "sort" ||
|
|
8577
|
+
sourceP === "locate"
|
|
8578
|
+
) {
|
|
8579
|
+
if (val.value.indexOf("↵") > -1) {
|
|
8580
|
+
res[key] = val.value.split("↵").join("");
|
|
8581
|
+
}
|
|
8582
|
+
res[key] = res[key].replace(/(\r\n|\n|\r)/gm, ""); //.replace(/"/g,'\"');//.replace(/'/g,"");
|
|
8583
|
+
}
|
|
8603
8584
|
|
|
8604
|
-
|
|
8605
|
-
|
|
8606
|
-
|
|
8607
|
-
|
|
8608
|
-
|
|
8609
|
-
|
|
8610
|
-
|
|
8611
|
-
|
|
8612
|
-
|
|
8613
|
-
res[key] = "(" + JSON.stringify(val.value) + ")";
|
|
8614
|
-
} else {
|
|
8615
|
-
res[key] = JSON.stringify(val.value);
|
|
8616
|
-
}
|
|
8617
|
-
}
|
|
8585
|
+
if (
|
|
8586
|
+
sourceP === "init" ||
|
|
8587
|
+
sourceP === "update" ||
|
|
8588
|
+
sourceP === "virtual"
|
|
8589
|
+
) {
|
|
8590
|
+
if (val.value.indexOf("↵") > -1)
|
|
8591
|
+
res[key] = val.value.split("↵").join("\n");
|
|
8592
|
+
res[key] = res[key].replace(/(\r\n|\n|\r)/gm, "\\n");
|
|
8593
|
+
}
|
|
8618
8594
|
|
|
8619
|
-
|
|
8620
|
-
|
|
8621
|
-
|
|
8622
|
-
val.value &&
|
|
8623
|
-
typeof val.value === "string" &&
|
|
8624
|
-
val.value.substr(0, 1) === "@"
|
|
8625
|
-
) {
|
|
8626
|
-
warning = "Error encoding " + val.value;
|
|
8627
|
-
var_error_found = true;
|
|
8628
|
-
res[key] = 0;
|
|
8629
|
-
}
|
|
8630
|
-
});
|
|
8631
|
-
var join = function (arrP) {
|
|
8632
|
-
return arrP.join("");
|
|
8633
|
-
};
|
|
8634
|
-
var exp = undefined;
|
|
8635
|
-
if (exp_exist && sourceP !== "exp") {
|
|
8636
|
-
exp = await func.expression.get(
|
|
8637
|
-
SESSION_ID,
|
|
8638
|
-
join(res),
|
|
8639
|
-
dsSessionP,
|
|
8640
|
-
sourceP,
|
|
8641
|
-
rowIdP,
|
|
8642
|
-
sourceActionP,
|
|
8643
|
-
true,
|
|
8644
|
-
calling_fieldIdP,
|
|
8645
|
-
fields,
|
|
8646
|
-
debug_infoP
|
|
8647
|
-
);
|
|
8648
|
-
if (exp.res) res = exp.res;
|
|
8649
|
-
// do second pass when exp exist
|
|
8650
|
-
else res = [exp.result];
|
|
8651
|
-
fields = _.assignIn(exp.fields, fieldsP);
|
|
8652
|
-
}
|
|
8653
|
-
var result = join(res); //res.join("");
|
|
8595
|
+
if (typeof IS_PROCESS_SERVER !== "undefined") {
|
|
8596
|
+
res[key] = res[key].replace(/(\r\n|\n|\r)/gm, "<br>");
|
|
8597
|
+
}
|
|
8654
8598
|
|
|
8655
|
-
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
|
|
8599
|
+
fields[val.fieldId] = res[key];
|
|
8600
|
+
}
|
|
8601
|
+
// extract object
|
|
8602
|
+
if (typeof val.value === "object" && var_Arr.length > 1) {
|
|
8603
|
+
if (
|
|
8604
|
+
!Array.isArray(val.value) &&
|
|
8605
|
+
!var_Arr[key + 1].value?.includes(".")
|
|
8606
|
+
) {
|
|
8607
|
+
// prevent cast on single value expression
|
|
8608
|
+
res[key] = "(" + JSON.stringify(val.value) + ")";
|
|
8609
|
+
} else {
|
|
8610
|
+
res[key] = JSON.stringify(val.value);
|
|
8611
|
+
}
|
|
8612
|
+
}
|
|
8659
8613
|
|
|
8660
|
-
|
|
8661
|
-
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
|
|
8666
|
-
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
-
|
|
8674
|
-
|
|
8675
|
-
|
|
8676
|
-
|
|
8677
|
-
|
|
8678
|
-
sourceP !== "arguments" &&
|
|
8679
|
-
sourceP !== "alert" &&
|
|
8680
|
-
sourceP !== "api_rendered_output" &&
|
|
8681
|
-
sourceP !== "DbQuery"
|
|
8682
|
-
) {
|
|
8683
|
-
// ret = secure_eval(result); // eval(result);
|
|
8684
|
-
ret = await func.expression.secure_eval(
|
|
8614
|
+
if (
|
|
8615
|
+
!exp_exist &&
|
|
8616
|
+
sourceP !== "exp" &&
|
|
8617
|
+
val.value &&
|
|
8618
|
+
typeof val.value === "string" &&
|
|
8619
|
+
val.value.substr(0, 1) === "@"
|
|
8620
|
+
) {
|
|
8621
|
+
warning = "Error encoding " + val.value;
|
|
8622
|
+
var_error_found = true;
|
|
8623
|
+
res[key] = 0;
|
|
8624
|
+
}
|
|
8625
|
+
});
|
|
8626
|
+
var join = function (arrP) {
|
|
8627
|
+
return arrP.join("");
|
|
8628
|
+
};
|
|
8629
|
+
var exp = undefined;
|
|
8630
|
+
if (exp_exist && sourceP !== "exp") {
|
|
8631
|
+
exp = await func.expression.get(
|
|
8685
8632
|
SESSION_ID,
|
|
8686
|
-
|
|
8687
|
-
result,
|
|
8688
|
-
jobNo,
|
|
8633
|
+
join(res),
|
|
8689
8634
|
dsSessionP,
|
|
8690
|
-
|
|
8635
|
+
sourceP,
|
|
8636
|
+
rowIdP,
|
|
8637
|
+
sourceActionP,
|
|
8638
|
+
true,
|
|
8639
|
+
calling_fieldIdP,
|
|
8640
|
+
fields,
|
|
8641
|
+
debug_infoP
|
|
8691
8642
|
);
|
|
8692
|
-
|
|
8693
|
-
|
|
8694
|
-
|
|
8643
|
+
if (exp.res) res = exp.res;
|
|
8644
|
+
// do second pass when exp exist
|
|
8645
|
+
else res = [exp.result];
|
|
8646
|
+
fields = _.assignIn(exp.fields, fieldsP);
|
|
8647
|
+
}
|
|
8648
|
+
var result = join(res); //res.join("");
|
|
8649
|
+
|
|
8650
|
+
if (res.length === 1) {
|
|
8651
|
+
// bypass join for single value expression
|
|
8652
|
+
result = res[0];
|
|
8653
|
+
}
|
|
8654
|
+
|
|
8655
|
+
if (secondPassP) {
|
|
8656
|
+
ret = result;
|
|
8657
|
+
} else if (sourceP !== "exp") {
|
|
8658
|
+
// no eval for second pass
|
|
8659
|
+
// return single value
|
|
8660
|
+
if (
|
|
8661
|
+
res.length === 1 &&
|
|
8662
|
+
typeof res[0] === "string" &&
|
|
8663
|
+
typeof res[0] !== "object"
|
|
8664
|
+
) {
|
|
8665
|
+
// avoid eval when query leading zeros problem
|
|
8666
|
+
ret = join(res); // res.join("");
|
|
8667
|
+
if (ret && ret.substr(0, 1) === "@") {
|
|
8668
|
+
error = "Error encoding @ var";
|
|
8669
|
+
var_error_found = true;
|
|
8670
|
+
}
|
|
8695
8671
|
} else {
|
|
8696
|
-
|
|
8697
|
-
|
|
8672
|
+
if (
|
|
8673
|
+
sourceP !== "arguments" &&
|
|
8674
|
+
sourceP !== "alert" &&
|
|
8675
|
+
sourceP !== "api_rendered_output" &&
|
|
8676
|
+
sourceP !== "DbQuery"
|
|
8677
|
+
) {
|
|
8678
|
+
// ret = secure_eval(result); // eval(result);
|
|
8679
|
+
ret = await func.expression.secure_eval(
|
|
8680
|
+
SESSION_ID,
|
|
8681
|
+
sourceP,
|
|
8682
|
+
result,
|
|
8683
|
+
jobNo,
|
|
8684
|
+
dsSessionP,
|
|
8685
|
+
js_script_callback
|
|
8686
|
+
);
|
|
8687
|
+
} else {
|
|
8688
|
+
if (sourceP === "DbQuery") {
|
|
8689
|
+
ret = JSON.stringify(evalJson(result));
|
|
8690
|
+
} else {
|
|
8691
|
+
// try eval
|
|
8692
|
+
ret = result;
|
|
8693
|
+
}
|
|
8694
|
+
}
|
|
8698
8695
|
}
|
|
8699
8696
|
}
|
|
8697
|
+
// console.log("AAAA")
|
|
8698
|
+
return end_results();
|
|
8699
|
+
} catch (err) {
|
|
8700
|
+
ret = result; // skip eval on error
|
|
8701
|
+
error = err.message;
|
|
8702
|
+
|
|
8703
|
+
return end_results();
|
|
8700
8704
|
}
|
|
8701
8705
|
}
|
|
8702
|
-
// console.log("AAAA")
|
|
8703
|
-
return end_results();
|
|
8704
|
-
} catch (err) {
|
|
8705
|
-
ret = result; // skip eval on error
|
|
8706
|
-
error = err.message;
|
|
8707
|
-
|
|
8708
|
-
return end_results();
|
|
8709
8706
|
}
|
|
8710
|
-
|
|
8711
|
-
|
|
8712
|
-
|
|
8713
|
-
// //===========================
|
|
8714
|
-
// // variable not exist
|
|
8715
|
-
// }
|
|
8716
|
-
// >>>> return results <<<<<<<<<
|
|
8707
|
+
|
|
8708
|
+
const new_class = new xu_class();
|
|
8709
|
+
return new_class.get();
|
|
8717
8710
|
};
|
|
8711
|
+
|
|
8712
|
+
// func.expression.get = async function (
|
|
8713
|
+
// SESSION_ID,
|
|
8714
|
+
// valP,
|
|
8715
|
+
// dsSessionP,
|
|
8716
|
+
// sourceP,
|
|
8717
|
+
// rowIdP,
|
|
8718
|
+
// sourceActionP,
|
|
8719
|
+
// secondPassP,
|
|
8720
|
+
// calling_fieldIdP,
|
|
8721
|
+
// fieldsP,
|
|
8722
|
+
// debug_infoP,
|
|
8723
|
+
// iterate_info,
|
|
8724
|
+
// js_script_callback,
|
|
8725
|
+
// jobNo
|
|
8726
|
+
// ) {
|
|
8727
|
+
// var ret;
|
|
8728
|
+
// var fields = {};
|
|
8729
|
+
// var error;
|
|
8730
|
+
// var warning;
|
|
8731
|
+
|
|
8732
|
+
// function evalJson(text) {
|
|
8733
|
+
// return eval("(" + text + ")");
|
|
8734
|
+
// }
|
|
8735
|
+
|
|
8736
|
+
// if (valP === null) {
|
|
8737
|
+
// ret = "";
|
|
8738
|
+
// } else {
|
|
8739
|
+
// switch (typeof valP) {
|
|
8740
|
+
// case "string":
|
|
8741
|
+
// ret = valP;
|
|
8742
|
+
// break;
|
|
8743
|
+
|
|
8744
|
+
// case "undefined":
|
|
8745
|
+
// ret = "";
|
|
8746
|
+
// break;
|
|
8747
|
+
|
|
8748
|
+
// case "boolean":
|
|
8749
|
+
// ret = valP ? "Y" : "N";
|
|
8750
|
+
// break;
|
|
8751
|
+
|
|
8752
|
+
// default:
|
|
8753
|
+
// ret = valP.toString();
|
|
8754
|
+
// break;
|
|
8755
|
+
// }
|
|
8756
|
+
// }
|
|
8757
|
+
|
|
8758
|
+
// ret = ret.replace(/\&/g, "&");
|
|
8759
|
+
// const end_results = function () {
|
|
8760
|
+
// const replace_quotes = function (ret) {
|
|
8761
|
+
// for (const [key, val] of Object.entries(fields)) {
|
|
8762
|
+
// if (typeof val === "string")
|
|
8763
|
+
// ret = ret.replace('"' + val + '"', val.replace(/"/gi, ""));
|
|
8764
|
+
// }
|
|
8765
|
+
// return ret;
|
|
8766
|
+
// };
|
|
8767
|
+
// if (sourceP === "update" || sourceP === "javascript") {
|
|
8768
|
+
// if (typeof ret === "string") ret = replace_quotes(ret);
|
|
8769
|
+
// }
|
|
8770
|
+
// const log_error = function () {
|
|
8771
|
+
// if (SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP]) {
|
|
8772
|
+
// func.utils.debug.log(
|
|
8773
|
+
// SESSION_ID,
|
|
8774
|
+
// SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].nodeId,
|
|
8775
|
+
// {
|
|
8776
|
+
// module: "expression",
|
|
8777
|
+
// action: sourceP,
|
|
8778
|
+
// source: calling_fieldIdP,
|
|
8779
|
+
// prop: ret,
|
|
8780
|
+
// details: ret,
|
|
8781
|
+
// result: ret,
|
|
8782
|
+
// error: error,
|
|
8783
|
+
// warning: warning,
|
|
8784
|
+
// fields: null,
|
|
8785
|
+
// type: "exp",
|
|
8786
|
+
// prog_id: SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].prog_id,
|
|
8787
|
+
// debug_info: debug_infoP,
|
|
8788
|
+
// }
|
|
8789
|
+
// );
|
|
8790
|
+
// }
|
|
8791
|
+
// };
|
|
8792
|
+
// if (error) log_error();
|
|
8793
|
+
// // if (error || warning) log_error();
|
|
8794
|
+
// return {
|
|
8795
|
+
// result: ret,
|
|
8796
|
+
// fields: fields,
|
|
8797
|
+
// res: res,
|
|
8798
|
+
// explain: result,
|
|
8799
|
+
// error: error,
|
|
8800
|
+
// warning: warning,
|
|
8801
|
+
// req: valP,
|
|
8802
|
+
// var_error_found: var_error_found,
|
|
8803
|
+
// };
|
|
8804
|
+
// };
|
|
8805
|
+
// const variable_not_exist = async function () {
|
|
8806
|
+
// try {
|
|
8807
|
+
// if (sourceP !== "arguments") {
|
|
8808
|
+
// if (ret && ret.substr(0, 6) === "_DATE_") {
|
|
8809
|
+
// ret = ret.substr(6);
|
|
8810
|
+
// } else if (
|
|
8811
|
+
// (ret &&
|
|
8812
|
+
// ret.length === 10 &&
|
|
8813
|
+
// ret.substr(4, 1) === "-" &&
|
|
8814
|
+
// ret.substr(7, 1) === "-") ||
|
|
8815
|
+
// ret === "self" // bypass eval for date 2017-03-22
|
|
8816
|
+
// ) {
|
|
8817
|
+
// ret = ret;
|
|
8818
|
+
// } else {
|
|
8819
|
+
// // ret = secure_eval(ret); //eval(ret);
|
|
8820
|
+
// ret = await func.expression.secure_eval(
|
|
8821
|
+
// SESSION_ID,
|
|
8822
|
+
// sourceP,
|
|
8823
|
+
// ret,
|
|
8824
|
+
// jobNo,
|
|
8825
|
+
// dsSessionP,
|
|
8826
|
+
// js_script_callback
|
|
8827
|
+
// );
|
|
8828
|
+
// }
|
|
8829
|
+
// // console.log("AFTER OK", ret)
|
|
8830
|
+
// return end_results();
|
|
8831
|
+
// } else {
|
|
8832
|
+
// // do eval for arithmetic vals
|
|
8833
|
+
// ret = ret.replace(/_NULL/gi, "");
|
|
8834
|
+
// return end_results();
|
|
8835
|
+
// }
|
|
8836
|
+
// } catch (err) {
|
|
8837
|
+
// // console.error(err);
|
|
8838
|
+
// return end_results();
|
|
8839
|
+
// }
|
|
8840
|
+
// };
|
|
8841
|
+
// if (!func.expression.validate_variables(valP)) {
|
|
8842
|
+
// return await variable_not_exist();
|
|
8843
|
+
// }
|
|
8844
|
+
// var split = [];
|
|
8845
|
+
// var var_Arr = [];
|
|
8846
|
+
// split = func.expression.parse(ret);
|
|
8847
|
+
// for await (const [arr_key, val] of Object.entries(split)) {
|
|
8848
|
+
// // run each field
|
|
8849
|
+
// const key = Number(arr_key);
|
|
8850
|
+
// var_Arr[key] = {};
|
|
8851
|
+
// var_Arr[key].value = val.value;
|
|
8852
|
+
// //--------------
|
|
8853
|
+
// const replace_value_in_string = function (retP, fieldIdP) {
|
|
8854
|
+
// if (
|
|
8855
|
+
// iterate_info?.iterator_key === fieldIdP ||
|
|
8856
|
+
// iterate_info?.iterator_val === fieldIdP
|
|
8857
|
+
// ) {
|
|
8858
|
+
// if (iterate_info.iterator_key === fieldIdP) {
|
|
8859
|
+
// retP.value = iterate_info._key;
|
|
8860
|
+
// }
|
|
8861
|
+
// if (iterate_info.iterator_val === fieldIdP) {
|
|
8862
|
+
// retP.value = iterate_info._val;
|
|
8863
|
+
// }
|
|
8864
|
+
// }
|
|
8865
|
+
|
|
8866
|
+
// const set_value = function (valP) {
|
|
8867
|
+
// if (typeof valP !== "undefined") {
|
|
8868
|
+
// var_Arr[key].value = valP;
|
|
8869
|
+
// if (typeof valP === "string") var_Arr[key].type = "string";
|
|
8870
|
+
// } else {
|
|
8871
|
+
// if (retP.type === "object") {
|
|
8872
|
+
// var_Arr[key].value = "";
|
|
8873
|
+
// var_Arr[key].type = "string";
|
|
8874
|
+
// }
|
|
8875
|
+
// }
|
|
8876
|
+
// };
|
|
8877
|
+
|
|
8878
|
+
// if (sourceP === "exp" && retP.type !== "exp") {
|
|
8879
|
+
// var_Arr[key].type = retP.type;
|
|
8880
|
+
// return;
|
|
8881
|
+
// }
|
|
8882
|
+
// if (typeof retP.value !== "undefined") {
|
|
8883
|
+
// var_Arr[key].type = retP.type;
|
|
8884
|
+
// var_Arr[key].value = retP.value;
|
|
8885
|
+
// if ((val.value.indexOf("[") > -1) | (val.value.indexOf(".") > -1)) {
|
|
8886
|
+
// //get values from array '@var==="sss" && @var_B==="sss" && @obj.property===5 && @objA["value"]===123 | @objB["value"].property===1234'
|
|
8887
|
+
// var data = retP.prop;
|
|
8888
|
+
// if (retP.type === "object") data = retP.value;
|
|
8889
|
+
// var property1, property2;
|
|
8890
|
+
// //check for split situation: @objB[@var].property 1: @objB[ 2:@var].property
|
|
8891
|
+
// if (
|
|
8892
|
+
// val.value.indexOf("[") === -1 &&
|
|
8893
|
+
// val.value.indexOf("]") > -1 &&
|
|
8894
|
+
// val.value.substr(0, 1) === "@"
|
|
8895
|
+
// ) {
|
|
8896
|
+
// //check situation 2
|
|
8897
|
+
// var prevData = var_Arr[key - 1].value;
|
|
8898
|
+
// var_Arr[key].value = prevData[data]; // @objB[@var]
|
|
8899
|
+
// if (val.value.indexOf(".") > -1) {
|
|
8900
|
+
// property2 = func.expression.get_property(val.value).property2; //val.value.substr(val.value.indexOf(".") + 1, val.value.length); // get .
|
|
8901
|
+
// if (prevData[data]) set_value(prevData[data][property2]);
|
|
8902
|
+
// // var_Arr[key].value = prevData[data][property2]; //@objB[@var].property
|
|
8903
|
+
// }
|
|
8904
|
+
// delete var_Arr[key - 1];
|
|
8905
|
+
// } else {
|
|
8906
|
+
// property1 = func.expression.get_property(val.value).property1;
|
|
8907
|
+
// property2 = func.expression.get_property(val.value).property2;
|
|
8908
|
+
// if (property1) {
|
|
8909
|
+
// var_Arr[key].value = data[property1]; // @var["value"] or @var.property
|
|
8910
|
+
// if (property2) {
|
|
8911
|
+
// if (data[property1]) set_value(data[property1][property2]);
|
|
8912
|
+
// }
|
|
8913
|
+
// }
|
|
8914
|
+
// if (property2 && !property1) {
|
|
8915
|
+
// if (
|
|
8916
|
+
// data //data[property2]
|
|
8917
|
+
// ) {
|
|
8918
|
+
// set_value(data[property2]);
|
|
8919
|
+
// }
|
|
8920
|
+
// }
|
|
8921
|
+
// }
|
|
8922
|
+
// fields[fieldIdP] = var_Arr[key].value; // added 051017 to allow @SYS_GLOBAL_OBJ_WIDGET_INFO.doc_id
|
|
8923
|
+
// var_Arr[key].fieldId = fieldIdP;
|
|
8924
|
+
// } else {
|
|
8925
|
+
// fields[fieldIdP] = var_Arr[key].value; // update flat no warpers
|
|
8926
|
+
// var_Arr[key].fieldId = fieldIdP;
|
|
8927
|
+
// }
|
|
8928
|
+
// }
|
|
8929
|
+
// };
|
|
8930
|
+
// //>>>>>>>>>>>>>>>>>>
|
|
8931
|
+
// //>>>> start here >>
|
|
8932
|
+
// //>>>>>>>>>>>>>>>>>>
|
|
8933
|
+
// if (val.fieldId) {
|
|
8934
|
+
// // @_THIS
|
|
8935
|
+
// if (
|
|
8936
|
+
// val.fieldId &&
|
|
8937
|
+
// val.fieldId.substr(0, 5) === "_THIS" &&
|
|
8938
|
+
// calling_fieldIdP &&
|
|
8939
|
+
// (val.fieldId.length === 5 ||
|
|
8940
|
+
// (val.fieldId.length > 5 && val.fieldId.substr(5, 1) === "."))
|
|
8941
|
+
// ) {
|
|
8942
|
+
// if (val.fieldId.length === 5) val.fieldId = calling_fieldIdP;
|
|
8943
|
+
// else
|
|
8944
|
+
// val.fieldId =
|
|
8945
|
+
// calling_fieldIdP + val.fieldId(5, val.fieldId.length - 1);
|
|
8946
|
+
// }
|
|
8947
|
+
// if (!sourceP === "exp") {
|
|
8948
|
+
// var_Arr[key].value = '""';
|
|
8949
|
+
// } // put default
|
|
8950
|
+
// fields[val.fieldId] = var_Arr[key].value;
|
|
8951
|
+
|
|
8952
|
+
// const ret = await func.datasource.get_value(
|
|
8953
|
+
// SESSION_ID,
|
|
8954
|
+
// val.fieldId,
|
|
8955
|
+
// dsSessionP,
|
|
8956
|
+
|
|
8957
|
+
// rowIdP
|
|
8958
|
+
// ); // find field in dataSources
|
|
8959
|
+
|
|
8960
|
+
// replace_value_in_string(ret.ret, ret.fieldIdP);
|
|
8961
|
+
// }
|
|
8962
|
+
// }
|
|
8963
|
+
// try {
|
|
8964
|
+
// // eval the expression
|
|
8965
|
+
// var res = [];
|
|
8966
|
+
// var exp_exist;
|
|
8967
|
+
// var var_error_found;
|
|
8968
|
+
// // merge arr values
|
|
8969
|
+
// _.forEach(var_Arr, function (val, key) {
|
|
8970
|
+
// if (sourceP === "UI Property EXP") {
|
|
8971
|
+
// let ret = func.utils.get_drive_url(SESSION_ID, val.value, true);
|
|
8972
|
+
// if (ret.changed) {
|
|
8973
|
+
// res[key] = ret.value;
|
|
8974
|
+
// return true;
|
|
8975
|
+
// }
|
|
8976
|
+
// }
|
|
8977
|
+
|
|
8978
|
+
// if (sourceP === "UI Attr EXP") {
|
|
8979
|
+
// let ret = func.utils.get_drive_url(
|
|
8980
|
+
// SESSION_ID,
|
|
8981
|
+
// val.value,
|
|
8982
|
+
// var_Arr.length == 1 ? false : true
|
|
8983
|
+
// );
|
|
8984
|
+
// if (ret.changed) {
|
|
8985
|
+
// res[key] = ret.value;
|
|
8986
|
+
// return true;
|
|
8987
|
+
// }
|
|
8988
|
+
// }
|
|
8989
|
+
|
|
8990
|
+
// if (val.type === "exp") {
|
|
8991
|
+
// exp_exist = true;
|
|
8992
|
+
// }
|
|
8993
|
+
// res[key] = val.value;
|
|
8994
|
+
// if (
|
|
8995
|
+
// sourceP !== "DbQuery" &&
|
|
8996
|
+
// sourceP !== "alert" &&
|
|
8997
|
+
// sourceP !== "exp" &&
|
|
8998
|
+
// sourceP !== "api_rendered_output" &&
|
|
8999
|
+
// (val.type === "string" || val.type === "date" || val.type === "time") &&
|
|
9000
|
+
// var_Arr.length > 1
|
|
9001
|
+
// ) {
|
|
9002
|
+
// res[key] = "`" + val.value + "`"; //res[key] = "'" + val.value + "'"; //
|
|
9003
|
+
// }
|
|
9004
|
+
// if (val.fieldId && val.value && typeof val.value === "string") {
|
|
9005
|
+
// if (
|
|
9006
|
+
// sourceP === "query" ||
|
|
9007
|
+
// sourceP === "condition" ||
|
|
9008
|
+
// sourceP === "range" ||
|
|
9009
|
+
// sourceP === "sort" ||
|
|
9010
|
+
// sourceP === "locate"
|
|
9011
|
+
// ) {
|
|
9012
|
+
// if (val.value.indexOf("↵") > -1) {
|
|
9013
|
+
// res[key] = val.value.split("↵").join("");
|
|
9014
|
+
// }
|
|
9015
|
+
// res[key] = res[key].replace(/(\r\n|\n|\r)/gm, ""); //.replace(/"/g,'\"');//.replace(/'/g,"");
|
|
9016
|
+
// }
|
|
9017
|
+
|
|
9018
|
+
// if (
|
|
9019
|
+
// sourceP === "init" ||
|
|
9020
|
+
// sourceP === "update" ||
|
|
9021
|
+
// sourceP === "virtual"
|
|
9022
|
+
// ) {
|
|
9023
|
+
// if (val.value.indexOf("↵") > -1)
|
|
9024
|
+
// res[key] = val.value.split("↵").join("\n");
|
|
9025
|
+
// res[key] = res[key].replace(/(\r\n|\n|\r)/gm, "\\n");
|
|
9026
|
+
// }
|
|
9027
|
+
|
|
9028
|
+
// if (typeof IS_PROCESS_SERVER !== "undefined") {
|
|
9029
|
+
// res[key] = res[key].replace(/(\r\n|\n|\r)/gm, "<br>");
|
|
9030
|
+
// }
|
|
9031
|
+
|
|
9032
|
+
// fields[val.fieldId] = res[key];
|
|
9033
|
+
// }
|
|
9034
|
+
// // extract object
|
|
9035
|
+
// if (typeof val.value === "object" && var_Arr.length > 1) {
|
|
9036
|
+
// if (
|
|
9037
|
+
// !Array.isArray(val.value) &&
|
|
9038
|
+
// !var_Arr[key + 1].value?.includes(".")
|
|
9039
|
+
// ) {
|
|
9040
|
+
// // prevent cast on single value expression
|
|
9041
|
+
// res[key] = "(" + JSON.stringify(val.value) + ")";
|
|
9042
|
+
// } else {
|
|
9043
|
+
// res[key] = JSON.stringify(val.value);
|
|
9044
|
+
// }
|
|
9045
|
+
// }
|
|
9046
|
+
|
|
9047
|
+
// if (
|
|
9048
|
+
// !exp_exist &&
|
|
9049
|
+
// sourceP !== "exp" &&
|
|
9050
|
+
// val.value &&
|
|
9051
|
+
// typeof val.value === "string" &&
|
|
9052
|
+
// val.value.substr(0, 1) === "@"
|
|
9053
|
+
// ) {
|
|
9054
|
+
// warning = "Error encoding " + val.value;
|
|
9055
|
+
// var_error_found = true;
|
|
9056
|
+
// res[key] = 0;
|
|
9057
|
+
// }
|
|
9058
|
+
// });
|
|
9059
|
+
// var join = function (arrP) {
|
|
9060
|
+
// return arrP.join("");
|
|
9061
|
+
// };
|
|
9062
|
+
// var exp = undefined;
|
|
9063
|
+
// if (exp_exist && sourceP !== "exp") {
|
|
9064
|
+
// exp = await func.expression.get(
|
|
9065
|
+
// SESSION_ID,
|
|
9066
|
+
// join(res),
|
|
9067
|
+
// dsSessionP,
|
|
9068
|
+
// sourceP,
|
|
9069
|
+
// rowIdP,
|
|
9070
|
+
// sourceActionP,
|
|
9071
|
+
// true,
|
|
9072
|
+
// calling_fieldIdP,
|
|
9073
|
+
// fields,
|
|
9074
|
+
// debug_infoP
|
|
9075
|
+
// );
|
|
9076
|
+
// if (exp.res) res = exp.res;
|
|
9077
|
+
// // do second pass when exp exist
|
|
9078
|
+
// else res = [exp.result];
|
|
9079
|
+
// fields = _.assignIn(exp.fields, fieldsP);
|
|
9080
|
+
// }
|
|
9081
|
+
// var result = join(res); //res.join("");
|
|
9082
|
+
|
|
9083
|
+
// if (res.length === 1) {
|
|
9084
|
+
// // bypass join for single value expression
|
|
9085
|
+
// result = res[0];
|
|
9086
|
+
// }
|
|
9087
|
+
|
|
9088
|
+
// if (secondPassP) {
|
|
9089
|
+
// ret = result;
|
|
9090
|
+
// } else if (sourceP !== "exp") {
|
|
9091
|
+
// // no eval for second pass
|
|
9092
|
+
// // return single value
|
|
9093
|
+
// if (
|
|
9094
|
+
// res.length === 1 &&
|
|
9095
|
+
// typeof res[0] === "string" &&
|
|
9096
|
+
// typeof res[0] !== "object"
|
|
9097
|
+
// ) {
|
|
9098
|
+
// // avoid eval when query leading zeros problem
|
|
9099
|
+
// ret = join(res); // res.join("");
|
|
9100
|
+
// if (ret && ret.substr(0, 1) === "@") {
|
|
9101
|
+
// error = "Error encoding @ var";
|
|
9102
|
+
// var_error_found = true;
|
|
9103
|
+
// }
|
|
9104
|
+
// } else {
|
|
9105
|
+
// if (
|
|
9106
|
+
// sourceP !== "arguments" &&
|
|
9107
|
+
// sourceP !== "alert" &&
|
|
9108
|
+
// sourceP !== "api_rendered_output" &&
|
|
9109
|
+
// sourceP !== "DbQuery"
|
|
9110
|
+
// ) {
|
|
9111
|
+
// // ret = secure_eval(result); // eval(result);
|
|
9112
|
+
// ret = await func.expression.secure_eval(
|
|
9113
|
+
// SESSION_ID,
|
|
9114
|
+
// sourceP,
|
|
9115
|
+
// result,
|
|
9116
|
+
// jobNo,
|
|
9117
|
+
// dsSessionP,
|
|
9118
|
+
// js_script_callback
|
|
9119
|
+
// );
|
|
9120
|
+
// } else {
|
|
9121
|
+
// if (sourceP === "DbQuery") {
|
|
9122
|
+
// ret = JSON.stringify(evalJson(result));
|
|
9123
|
+
// } else {
|
|
9124
|
+
// // try eval
|
|
9125
|
+
// ret = result;
|
|
9126
|
+
// }
|
|
9127
|
+
// }
|
|
9128
|
+
// }
|
|
9129
|
+
// }
|
|
9130
|
+
// // console.log("AAAA")
|
|
9131
|
+
// return end_results();
|
|
9132
|
+
// } catch (err) {
|
|
9133
|
+
// ret = result; // skip eval on error
|
|
9134
|
+
// error = err.message;
|
|
9135
|
+
|
|
9136
|
+
// return end_results();
|
|
9137
|
+
// }
|
|
9138
|
+
// // }
|
|
9139
|
+
// // else {
|
|
9140
|
+
// // return variable_not_exist();
|
|
9141
|
+
// // //===========================
|
|
9142
|
+
// // // variable not exist
|
|
9143
|
+
// // }
|
|
9144
|
+
// // >>>> return results <<<<<<<<<
|
|
9145
|
+
// };
|
|
8718
9146
|
func.expression.parse = function (strP) {
|
|
8719
9147
|
var extract_str = function (strP, posP) {
|
|
8720
9148
|
if (!posP) posP = 0;
|