@xuda.io/xuda-worker-bundle-min 1.3.1523 → 1.3.1524
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 +1 -155
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -7753,7 +7753,7 @@ func.events.invoke = async function (event_id) {
|
|
|
7753
7753
|
};
|
|
7754
7754
|
func.expression = {};
|
|
7755
7755
|
|
|
7756
|
-
func.expression.
|
|
7756
|
+
func.expression.get = async function (SESSION_ID, valP, dsSessionP, sourceP, rowIdP, sourceActionP, secondPassP, calling_fieldIdP, fieldsP, debug_infoP, iterate_info, js_script_callback, jobNo, api_output_type) {
|
|
7757
7757
|
class xu_class {
|
|
7758
7758
|
async get() {
|
|
7759
7759
|
var ret;
|
|
@@ -8107,160 +8107,6 @@ func.expression.get_org = async function (SESSION_ID, valP, dsSessionP, sourceP,
|
|
|
8107
8107
|
return new_class.get();
|
|
8108
8108
|
};
|
|
8109
8109
|
|
|
8110
|
-
func.expression.get = async function (SESSION_ID, valP, dsSessionP, sourceP, rowIdP, sourceActionP, secondPassP, calling_fieldIdP, fieldsP = {}, debug_infoP, iterate_info, js_script_callback, jobNo, api_output_type) {
|
|
8111
|
-
class xu_class {
|
|
8112
|
-
async get() {
|
|
8113
|
-
let ret, error, warning, var_error_found;
|
|
8114
|
-
const fields = { ...fieldsP };
|
|
8115
|
-
const evalJson = (text) => eval(`(${text})`);
|
|
8116
|
-
|
|
8117
|
-
// Initial value processing
|
|
8118
|
-
ret = valP === null || typeof valP === 'undefined' ? '' : typeof valP === 'boolean' ? (valP ? 'Y' : 'N') : valP.toString();
|
|
8119
|
-
ret = ret.replace(/\&/g, '&').replace(func.utils.replace_studio_drive_url(SESSION_ID, ret));
|
|
8120
|
-
|
|
8121
|
-
const endResults = () => {
|
|
8122
|
-
if (['update', 'javascript'].includes(sourceP) && typeof ret === 'string') {
|
|
8123
|
-
for (const [key, val] of Object.entries(fields)) {
|
|
8124
|
-
if (typeof val === 'string') ret = ret.replace(`"${val}"`, val.replace(/"/g, ''));
|
|
8125
|
-
}
|
|
8126
|
-
}
|
|
8127
|
-
if (error && SESSION_OBJ[SESSION_ID]?.DS_GLB[dsSessionP]) {
|
|
8128
|
-
func.utils.debug.log(SESSION_ID, SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].nodeId, {
|
|
8129
|
-
module: 'expression',
|
|
8130
|
-
action: sourceP,
|
|
8131
|
-
source: calling_fieldIdP,
|
|
8132
|
-
prop: ret,
|
|
8133
|
-
details: ret,
|
|
8134
|
-
result: ret,
|
|
8135
|
-
error,
|
|
8136
|
-
warning,
|
|
8137
|
-
fields: null,
|
|
8138
|
-
type: 'exp',
|
|
8139
|
-
prog_id: SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP].prog_id,
|
|
8140
|
-
debug_info: debug_infoP,
|
|
8141
|
-
});
|
|
8142
|
-
}
|
|
8143
|
-
return { result: ret, fields, error, warning, req: valP, var_error_found };
|
|
8144
|
-
};
|
|
8145
|
-
|
|
8146
|
-
const handleNonVariable = async () => {
|
|
8147
|
-
try {
|
|
8148
|
-
if (sourceP !== 'arguments') {
|
|
8149
|
-
if (ret.startsWith('_DATE_')) ret = ret.slice(6);
|
|
8150
|
-
else if (/^\d{4}-\d{2}-\d{2}$/.test(ret) || ret === 'self') return endResults();
|
|
8151
|
-
else ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
|
|
8152
|
-
} else {
|
|
8153
|
-
ret = ret.replace(/_NULL/gi, '');
|
|
8154
|
-
}
|
|
8155
|
-
return endResults();
|
|
8156
|
-
} catch (err) {
|
|
8157
|
-
error = err.message;
|
|
8158
|
-
return endResults();
|
|
8159
|
-
}
|
|
8160
|
-
};
|
|
8161
|
-
|
|
8162
|
-
if (!func.expression.validate_variables(valP)) return await handleNonVariable();
|
|
8163
|
-
if (glb.emailRegex.test(await func.expression.secure_eval(SESSION_ID, sourceP, valP, jobNo, dsSessionP, js_script_callback))) {
|
|
8164
|
-
return await handleNonVariable();
|
|
8165
|
-
}
|
|
8166
|
-
|
|
8167
|
-
const var_Arr = await Promise.all(
|
|
8168
|
-
(func.expression.parse(ret) || []).map(async (val, key) => {
|
|
8169
|
-
const result = { value: val.value, fieldId: val.fieldId };
|
|
8170
|
-
if (!val.fieldId) return result;
|
|
8171
|
-
|
|
8172
|
-
if (val.fieldId.startsWith('_THIS') && calling_fieldIdP) {
|
|
8173
|
-
result.fieldId = val.fieldId.length === 5 ? calling_fieldIdP : calling_fieldIdP + val.fieldId.slice(5);
|
|
8174
|
-
}
|
|
8175
|
-
|
|
8176
|
-
const { ret: fetchedValue, fieldIdP } = await func.datasource.get_value(SESSION_ID, result.fieldId, dsSessionP, rowIdP);
|
|
8177
|
-
result.value = fetchedValue?.value ?? (sourceP === 'exp' ? fetchedValue?.value : '""');
|
|
8178
|
-
result.type = fetchedValue?.type;
|
|
8179
|
-
|
|
8180
|
-
if (iterate_info) {
|
|
8181
|
-
if (iterate_info.iterator_key === fieldIdP) result.value = iterate_info._key;
|
|
8182
|
-
if (iterate_info.iterator_val === fieldIdP) result.value = iterate_info._val;
|
|
8183
|
-
}
|
|
8184
|
-
|
|
8185
|
-
if (val.value.includes('[') || val.value.includes('.')) {
|
|
8186
|
-
const { property1, property2 } = await func.expression.get_property(val.value);
|
|
8187
|
-
const data = fetchedValue?.type === 'object' ? fetchedValue.value : fetchedValue?.prop;
|
|
8188
|
-
|
|
8189
|
-
if (key > 0 && val.value.includes(']') && !val.value.includes('[') && var_Arr[key - 1]?.value) {
|
|
8190
|
-
const prevData = var_Arr[key - 1].value;
|
|
8191
|
-
result.value = prevData[fieldIdP] ?? '';
|
|
8192
|
-
if (val.value.includes('.') && prevData[fieldIdP]) result.value = prevData[fieldIdP][property2] ?? '';
|
|
8193
|
-
} else if (data) {
|
|
8194
|
-
if (property1) result.value = data[property1] ?? '';
|
|
8195
|
-
if (property2) result.value = (property1 ? data[property1]?.[property2] : data[property2]) ?? '';
|
|
8196
|
-
}
|
|
8197
|
-
}
|
|
8198
|
-
fields[fieldIdP] = result.value;
|
|
8199
|
-
return result;
|
|
8200
|
-
}),
|
|
8201
|
-
);
|
|
8202
|
-
|
|
8203
|
-
try {
|
|
8204
|
-
const res = var_Arr.map((val, key) => {
|
|
8205
|
-
if (sourceP === 'UI Property EXP' || sourceP === 'UI Attr EXP') {
|
|
8206
|
-
const { changed, value } = func.utils.get_drive_url(SESSION_ID, val.value, sourceP === 'UI Property EXP' || var_Arr.length > 1);
|
|
8207
|
-
if (changed) return value;
|
|
8208
|
-
}
|
|
8209
|
-
|
|
8210
|
-
let value = val.value;
|
|
8211
|
-
if (var_Arr.length > 1) {
|
|
8212
|
-
if (!['DbQuery', 'alert', 'exp', 'api_rendered_output'].includes(sourceP) && ['string', 'date'].includes(val.type)) {
|
|
8213
|
-
value = `\`${value}\``;
|
|
8214
|
-
} else if (sourceP === 'api_rendered_output' && api_output_type === 'json' && ['string', 'date'].includes(val.type)) {
|
|
8215
|
-
value = `"${value}"`;
|
|
8216
|
-
}
|
|
8217
|
-
}
|
|
8218
|
-
|
|
8219
|
-
if (val.fieldId && typeof value === 'string') {
|
|
8220
|
-
if (['query', 'condition', 'range', 'sort', 'locate'].includes(sourceP)) value = value.replace(/↵|\r\n|\n|\r/g, '');
|
|
8221
|
-
if (['init', 'update', 'virtual'].includes(sourceP)) value = value.replace(/↵|\r\n|\n|\r/g, '\\n');
|
|
8222
|
-
if (typeof IS_PROCESS_SERVER !== 'undefined') value = value.replace(/↵|\r\n|\n|\r/g, '<br>');
|
|
8223
|
-
fields[val.fieldId] = value;
|
|
8224
|
-
}
|
|
8225
|
-
|
|
8226
|
-
if (typeof value === 'object' && var_Arr.length > 1) {
|
|
8227
|
-
value = Array.isArray(value) || var_Arr[key + 1]?.value?.includes('.') ? JSON.stringify(value) : `(${JSON.stringify(value)})`;
|
|
8228
|
-
}
|
|
8229
|
-
|
|
8230
|
-
if (val.type !== 'exp' && sourceP !== 'exp' && typeof value === 'string' && value.startsWith('@')) {
|
|
8231
|
-
warning = `Error encoding ${value}`;
|
|
8232
|
-
var_error_found = true;
|
|
8233
|
-
return '0';
|
|
8234
|
-
}
|
|
8235
|
-
return value;
|
|
8236
|
-
});
|
|
8237
|
-
|
|
8238
|
-
ret = res.length === 1 ? res[0] : res.join('');
|
|
8239
|
-
if (var_Arr.some((v) => v.type === 'exp') && sourceP !== 'exp' && !secondPassP) {
|
|
8240
|
-
const exp = await func.expression.get(SESSION_ID, ret, dsSessionP, sourceP, rowIdP, sourceActionP, true, calling_fieldIdP, fields, debug_infoP);
|
|
8241
|
-
ret = exp.res?.[0] ?? exp.result;
|
|
8242
|
-
Object.assign(fields, exp.fields);
|
|
8243
|
-
} else if (!secondPassP && !['arguments', 'api_rendered_output', 'DbQuery'].includes(sourceP)) {
|
|
8244
|
-
ret = await func.expression.secure_eval(SESSION_ID, sourceP, ret, jobNo, dsSessionP, js_script_callback);
|
|
8245
|
-
} else if (sourceP === 'DbQuery') {
|
|
8246
|
-
ret = JSON.stringify(evalJson(ret));
|
|
8247
|
-
}
|
|
8248
|
-
|
|
8249
|
-
if (typeof ret === 'string' && ret.startsWith('@')) {
|
|
8250
|
-
error = 'Error encoding @ var';
|
|
8251
|
-
var_error_found = true;
|
|
8252
|
-
}
|
|
8253
|
-
} catch (err) {
|
|
8254
|
-
error = err.message;
|
|
8255
|
-
}
|
|
8256
|
-
|
|
8257
|
-
return endResults();
|
|
8258
|
-
}
|
|
8259
|
-
}
|
|
8260
|
-
|
|
8261
|
-
return new xu_class().get();
|
|
8262
|
-
};
|
|
8263
|
-
|
|
8264
8110
|
func.expression.get_bad1 = async function (SESSION_ID, valP, dsSessionP, sourceP, rowIdP, sourceActionP, secondPassP, calling_fieldIdP, fieldsP = {}, debug_infoP, iterate_info, js_script_callback, jobNo, api_output_type) {
|
|
8265
8111
|
const evalJson = (text) => eval(`(${text})`);
|
|
8266
8112
|
const replaceQuotes = (str) => {
|