@xuda.io/runtime-bundle 1.0.1424 → 1.0.1426

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.
@@ -35083,10 +35083,11 @@ func.runtime.render.bind_xu_event = function (options) {
35083
35083
  evt[val.event_modifiers]();
35084
35084
  }
35085
35085
 
35086
- if (val.workflow) {
35087
- const workflow_keys = Object.keys(val.workflow);
35086
+ const workflow = val.workflow || val.event;
35087
+ if (workflow) {
35088
+ const workflow_keys = Object.keys(workflow);
35088
35089
  for (let workflow_index = 0; workflow_index < workflow_keys.length; workflow_index++) {
35089
- const val2 = val.workflow[workflow_keys[workflow_index]];
35090
+ const val2 = workflow[workflow_keys[workflow_index]];
35090
35091
  if (!val2.data.enabled) continue;
35091
35092
 
35092
35093
  func.events.add_to_queue(
@@ -35798,7 +35799,7 @@ func.runtime.render.normalize_node_attributes = function (nodeP) {
35798
35799
  {
35799
35800
  handler: 'custom',
35800
35801
  props: {},
35801
- event: [
35802
+ workflow: [
35802
35803
  {
35803
35804
  id: Date.now(),
35804
35805
  data: {
@@ -39952,56 +39953,149 @@ func.datasource.get_viewFields_for_update_function = function (SESSION_ID, calli
39952
39953
  if (!exp) {
39953
39954
  return viewFields;
39954
39955
  }
39955
- try {
39956
- // parse json
39957
- var json = JSON5.parse(exp.replace(/\n/gi, ''));
39958
- for (const [key, val] of Object.entries(json)) {
39959
- let id = key.substr(1, key.length - 1);
39960
- if (!id) continue;
39961
- viewFields.push({
39962
- val,
39963
- id,
39964
- });
39956
+ const trim_wrapping_braces = function (value) {
39957
+ const trimmed = value.trim();
39958
+ if (trimmed.startsWith('{') && trimmed.endsWith('}')) {
39959
+ return trimmed.substring(1, trimmed.length - 1);
39960
+ }
39961
+ return trimmed;
39962
+ };
39963
+ const strip_wrapping_quotes = function (value) {
39964
+ const trimmed = value.trim();
39965
+ const first = trimmed.substring(0, 1);
39966
+ const last = trimmed.substring(trimmed.length - 1);
39967
+ if ((first === "'" || first === '"' || first === '`') && last === first) {
39968
+ return trimmed.substring(1, trimmed.length - 1);
39969
+ }
39970
+ return trimmed;
39971
+ };
39972
+ const split_top_level = function (value) {
39973
+ const parts = [];
39974
+ let current = '';
39975
+ let quote = null;
39976
+ let escape = false;
39977
+ let paren_depth = 0;
39978
+ let bracket_depth = 0;
39979
+ let brace_depth = 0;
39980
+
39981
+ for (let index = 0; index < value.length; index++) {
39982
+ const char = value[index];
39983
+
39984
+ if (escape) {
39985
+ current += char;
39986
+ escape = false;
39987
+ continue;
39988
+ }
39989
+
39990
+ if (quote) {
39991
+ current += char;
39992
+ if (char === '\\') {
39993
+ escape = true;
39994
+ } else if (char === quote) {
39995
+ quote = null;
39996
+ }
39997
+ continue;
39998
+ }
39999
+
40000
+ if (char === "'" || char === '"' || char === '`') {
40001
+ quote = char;
40002
+ current += char;
40003
+ continue;
40004
+ }
40005
+
40006
+ if (char === '(') paren_depth++;
40007
+ if (char === ')') paren_depth = Math.max(0, paren_depth - 1);
40008
+ if (char === '[') bracket_depth++;
40009
+ if (char === ']') bracket_depth = Math.max(0, bracket_depth - 1);
40010
+ if (char === '{') brace_depth++;
40011
+ if (char === '}') brace_depth = Math.max(0, brace_depth - 1);
40012
+
40013
+ if ((char === ',' || char === ';') && !paren_depth && !bracket_depth && !brace_depth) {
40014
+ if (current.trim()) {
40015
+ parts.push(current.trim());
40016
+ }
40017
+ current = '';
40018
+ continue;
40019
+ }
40020
+
40021
+ current += char;
39965
40022
  }
39966
- return viewFields;
39967
- } catch (e) {
39968
- if (!exp) {
39969
- return;
40023
+
40024
+ if (current.trim()) {
40025
+ parts.push(current.trim());
39970
40026
  }
39971
- if (exp.substr(exp.length - 1, 1) === ';') exp = exp.substr(0, exp.length - 1); // remove closing if exist;
39972
- var exp_arr = exp.split(/;\s*(?=(?:[^"]|"[^"]*")*$)/g); // split ; outside quotes
39973
- if (exp_arr?.length) {
39974
- for (let val of exp_arr) {
39975
- // run view fields
39976
- var pos = val.indexOf(':');
39977
- var seg = [val.substring(0, pos), val.substring(pos + 1)];
39978
- if (seg && seg.length === 2) {
39979
- let id = seg[0].substr(1, seg[0].length);
39980
- if (!id) continue;
39981
- viewFields.push({
39982
- id,
39983
- val: seg[1],
39984
- // , props: {},
39985
- });
39986
- } else {
39987
- func.utils.debug.log(SESSION_ID, _ds.prog_id, {
39988
- module: _ds.viewModule,
39989
- action: 'set',
39990
- prop: 'parse update exp',
39991
- details: exp,
39992
- result: '',
39993
- error: 'Invalid json; too many segments',
39994
- source: _ds.viewSourceDesc,
39995
- json: '',
39996
- fields: '',
39997
- dsSession: dsSessionP,
39998
- });
40027
+
40028
+ return parts;
40029
+ };
40030
+ const find_top_level_colon = function (value) {
40031
+ let quote = null;
40032
+ let escape = false;
40033
+ let paren_depth = 0;
40034
+ let bracket_depth = 0;
40035
+ let brace_depth = 0;
40036
+
40037
+ for (let index = 0; index < value.length; index++) {
40038
+ const char = value[index];
40039
+
40040
+ if (escape) {
40041
+ escape = false;
40042
+ continue;
40043
+ }
40044
+
40045
+ if (quote) {
40046
+ if (char === '\\') {
40047
+ escape = true;
40048
+ } else if (char === quote) {
40049
+ quote = null;
39999
40050
  }
40051
+ continue;
40052
+ }
40053
+
40054
+ if (char === "'" || char === '"' || char === '`') {
40055
+ quote = char;
40056
+ continue;
40057
+ }
40058
+
40059
+ if (char === '(') paren_depth++;
40060
+ if (char === ')') paren_depth = Math.max(0, paren_depth - 1);
40061
+ if (char === '[') bracket_depth++;
40062
+ if (char === ']') bracket_depth = Math.max(0, bracket_depth - 1);
40063
+ if (char === '{') brace_depth++;
40064
+ if (char === '}') brace_depth = Math.max(0, brace_depth - 1);
40065
+
40066
+ if (char === ':' && !paren_depth && !bracket_depth && !brace_depth) {
40067
+ return index;
40000
40068
  }
40001
40069
  }
40002
40070
 
40003
- return viewFields;
40071
+ return -1;
40072
+ };
40073
+
40074
+ exp = trim_wrapping_braces(exp.replace(/\n/gi, ''));
40075
+ const exp_arr = split_top_level(exp);
40076
+ for (let index = 0; index < exp_arr.length; index++) {
40077
+ const segment = exp_arr[index];
40078
+ const pos = find_top_level_colon(segment);
40079
+ if (pos === -1) {
40080
+ continue;
40081
+ }
40082
+
40083
+ let id = strip_wrapping_quotes(segment.substring(0, pos));
40084
+ const val = segment.substring(pos + 1).trim();
40085
+ if (id.substring(0, 1) === '@') {
40086
+ id = id.substring(1);
40087
+ }
40088
+ if (!id || !val) {
40089
+ continue;
40090
+ }
40091
+
40092
+ viewFields.push({
40093
+ id,
40094
+ val,
40095
+ });
40004
40096
  }
40097
+
40098
+ return viewFields;
40005
40099
  };
40006
40100
  func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, rowIdP, org_dsSessionP) {
40007
40101
  const return_value = async (field_id, value) => {