@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.
@@ -6225,56 +6225,149 @@ func.datasource.get_viewFields_for_update_function = function (SESSION_ID, calli
6225
6225
  if (!exp) {
6226
6226
  return viewFields;
6227
6227
  }
6228
- try {
6229
- // parse json
6230
- var json = JSON5.parse(exp.replace(/\n/gi, ''));
6231
- for (const [key, val] of Object.entries(json)) {
6232
- let id = key.substr(1, key.length - 1);
6233
- if (!id) continue;
6234
- viewFields.push({
6235
- val,
6236
- id,
6237
- });
6228
+ const trim_wrapping_braces = function (value) {
6229
+ const trimmed = value.trim();
6230
+ if (trimmed.startsWith('{') && trimmed.endsWith('}')) {
6231
+ return trimmed.substring(1, trimmed.length - 1);
6232
+ }
6233
+ return trimmed;
6234
+ };
6235
+ const strip_wrapping_quotes = function (value) {
6236
+ const trimmed = value.trim();
6237
+ const first = trimmed.substring(0, 1);
6238
+ const last = trimmed.substring(trimmed.length - 1);
6239
+ if ((first === "'" || first === '"' || first === '`') && last === first) {
6240
+ return trimmed.substring(1, trimmed.length - 1);
6241
+ }
6242
+ return trimmed;
6243
+ };
6244
+ const split_top_level = function (value) {
6245
+ const parts = [];
6246
+ let current = '';
6247
+ let quote = null;
6248
+ let escape = false;
6249
+ let paren_depth = 0;
6250
+ let bracket_depth = 0;
6251
+ let brace_depth = 0;
6252
+
6253
+ for (let index = 0; index < value.length; index++) {
6254
+ const char = value[index];
6255
+
6256
+ if (escape) {
6257
+ current += char;
6258
+ escape = false;
6259
+ continue;
6260
+ }
6261
+
6262
+ if (quote) {
6263
+ current += char;
6264
+ if (char === '\\') {
6265
+ escape = true;
6266
+ } else if (char === quote) {
6267
+ quote = null;
6268
+ }
6269
+ continue;
6270
+ }
6271
+
6272
+ if (char === "'" || char === '"' || char === '`') {
6273
+ quote = char;
6274
+ current += char;
6275
+ continue;
6276
+ }
6277
+
6278
+ if (char === '(') paren_depth++;
6279
+ if (char === ')') paren_depth = Math.max(0, paren_depth - 1);
6280
+ if (char === '[') bracket_depth++;
6281
+ if (char === ']') bracket_depth = Math.max(0, bracket_depth - 1);
6282
+ if (char === '{') brace_depth++;
6283
+ if (char === '}') brace_depth = Math.max(0, brace_depth - 1);
6284
+
6285
+ if ((char === ',' || char === ';') && !paren_depth && !bracket_depth && !brace_depth) {
6286
+ if (current.trim()) {
6287
+ parts.push(current.trim());
6288
+ }
6289
+ current = '';
6290
+ continue;
6291
+ }
6292
+
6293
+ current += char;
6238
6294
  }
6239
- return viewFields;
6240
- } catch (e) {
6241
- if (!exp) {
6242
- return;
6295
+
6296
+ if (current.trim()) {
6297
+ parts.push(current.trim());
6243
6298
  }
6244
- if (exp.substr(exp.length - 1, 1) === ';') exp = exp.substr(0, exp.length - 1); // remove closing if exist;
6245
- var exp_arr = exp.split(/;\s*(?=(?:[^"]|"[^"]*")*$)/g); // split ; outside quotes
6246
- if (exp_arr?.length) {
6247
- for (let val of exp_arr) {
6248
- // run view fields
6249
- var pos = val.indexOf(':');
6250
- var seg = [val.substring(0, pos), val.substring(pos + 1)];
6251
- if (seg && seg.length === 2) {
6252
- let id = seg[0].substr(1, seg[0].length);
6253
- if (!id) continue;
6254
- viewFields.push({
6255
- id,
6256
- val: seg[1],
6257
- // , props: {},
6258
- });
6259
- } else {
6260
- func.utils.debug.log(SESSION_ID, _ds.prog_id, {
6261
- module: _ds.viewModule,
6262
- action: 'set',
6263
- prop: 'parse update exp',
6264
- details: exp,
6265
- result: '',
6266
- error: 'Invalid json; too many segments',
6267
- source: _ds.viewSourceDesc,
6268
- json: '',
6269
- fields: '',
6270
- dsSession: dsSessionP,
6271
- });
6299
+
6300
+ return parts;
6301
+ };
6302
+ const find_top_level_colon = function (value) {
6303
+ let quote = null;
6304
+ let escape = false;
6305
+ let paren_depth = 0;
6306
+ let bracket_depth = 0;
6307
+ let brace_depth = 0;
6308
+
6309
+ for (let index = 0; index < value.length; index++) {
6310
+ const char = value[index];
6311
+
6312
+ if (escape) {
6313
+ escape = false;
6314
+ continue;
6315
+ }
6316
+
6317
+ if (quote) {
6318
+ if (char === '\\') {
6319
+ escape = true;
6320
+ } else if (char === quote) {
6321
+ quote = null;
6272
6322
  }
6323
+ continue;
6324
+ }
6325
+
6326
+ if (char === "'" || char === '"' || char === '`') {
6327
+ quote = char;
6328
+ continue;
6329
+ }
6330
+
6331
+ if (char === '(') paren_depth++;
6332
+ if (char === ')') paren_depth = Math.max(0, paren_depth - 1);
6333
+ if (char === '[') bracket_depth++;
6334
+ if (char === ']') bracket_depth = Math.max(0, bracket_depth - 1);
6335
+ if (char === '{') brace_depth++;
6336
+ if (char === '}') brace_depth = Math.max(0, brace_depth - 1);
6337
+
6338
+ if (char === ':' && !paren_depth && !bracket_depth && !brace_depth) {
6339
+ return index;
6273
6340
  }
6274
6341
  }
6275
6342
 
6276
- return viewFields;
6343
+ return -1;
6344
+ };
6345
+
6346
+ exp = trim_wrapping_braces(exp.replace(/\n/gi, ''));
6347
+ const exp_arr = split_top_level(exp);
6348
+ for (let index = 0; index < exp_arr.length; index++) {
6349
+ const segment = exp_arr[index];
6350
+ const pos = find_top_level_colon(segment);
6351
+ if (pos === -1) {
6352
+ continue;
6353
+ }
6354
+
6355
+ let id = strip_wrapping_quotes(segment.substring(0, pos));
6356
+ const val = segment.substring(pos + 1).trim();
6357
+ if (id.substring(0, 1) === '@') {
6358
+ id = id.substring(1);
6359
+ }
6360
+ if (!id || !val) {
6361
+ continue;
6362
+ }
6363
+
6364
+ viewFields.push({
6365
+ id,
6366
+ val,
6367
+ });
6277
6368
  }
6369
+
6370
+ return viewFields;
6278
6371
  };
6279
6372
  func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, rowIdP, org_dsSessionP) {
6280
6373
  const return_value = async (field_id, value) => {
@@ -16053,10 +16146,11 @@ func.runtime.render.bind_xu_event = function (options) {
16053
16146
  evt[val.event_modifiers]();
16054
16147
  }
16055
16148
 
16056
- if (val.workflow) {
16057
- const workflow_keys = Object.keys(val.workflow);
16149
+ const workflow = val.workflow || val.event;
16150
+ if (workflow) {
16151
+ const workflow_keys = Object.keys(workflow);
16058
16152
  for (let workflow_index = 0; workflow_index < workflow_keys.length; workflow_index++) {
16059
- const val2 = val.workflow[workflow_keys[workflow_index]];
16153
+ const val2 = workflow[workflow_keys[workflow_index]];
16060
16154
  if (!val2.data.enabled) continue;
16061
16155
 
16062
16156
  func.events.add_to_queue(
@@ -16768,7 +16862,7 @@ func.runtime.render.normalize_node_attributes = function (nodeP) {
16768
16862
  {
16769
16863
  handler: 'custom',
16770
16864
  props: {},
16771
- event: [
16865
+ workflow: [
16772
16866
  {
16773
16867
  id: Date.now(),
16774
16868
  data: {
@@ -6151,56 +6151,149 @@ func.datasource.get_viewFields_for_update_function = function (SESSION_ID, calli
6151
6151
  if (!exp) {
6152
6152
  return viewFields;
6153
6153
  }
6154
- try {
6155
- // parse json
6156
- var json = JSON5.parse(exp.replace(/\n/gi, ''));
6157
- for (const [key, val] of Object.entries(json)) {
6158
- let id = key.substr(1, key.length - 1);
6159
- if (!id) continue;
6160
- viewFields.push({
6161
- val,
6162
- id,
6163
- });
6154
+ const trim_wrapping_braces = function (value) {
6155
+ const trimmed = value.trim();
6156
+ if (trimmed.startsWith('{') && trimmed.endsWith('}')) {
6157
+ return trimmed.substring(1, trimmed.length - 1);
6158
+ }
6159
+ return trimmed;
6160
+ };
6161
+ const strip_wrapping_quotes = function (value) {
6162
+ const trimmed = value.trim();
6163
+ const first = trimmed.substring(0, 1);
6164
+ const last = trimmed.substring(trimmed.length - 1);
6165
+ if ((first === "'" || first === '"' || first === '`') && last === first) {
6166
+ return trimmed.substring(1, trimmed.length - 1);
6167
+ }
6168
+ return trimmed;
6169
+ };
6170
+ const split_top_level = function (value) {
6171
+ const parts = [];
6172
+ let current = '';
6173
+ let quote = null;
6174
+ let escape = false;
6175
+ let paren_depth = 0;
6176
+ let bracket_depth = 0;
6177
+ let brace_depth = 0;
6178
+
6179
+ for (let index = 0; index < value.length; index++) {
6180
+ const char = value[index];
6181
+
6182
+ if (escape) {
6183
+ current += char;
6184
+ escape = false;
6185
+ continue;
6186
+ }
6187
+
6188
+ if (quote) {
6189
+ current += char;
6190
+ if (char === '\\') {
6191
+ escape = true;
6192
+ } else if (char === quote) {
6193
+ quote = null;
6194
+ }
6195
+ continue;
6196
+ }
6197
+
6198
+ if (char === "'" || char === '"' || char === '`') {
6199
+ quote = char;
6200
+ current += char;
6201
+ continue;
6202
+ }
6203
+
6204
+ if (char === '(') paren_depth++;
6205
+ if (char === ')') paren_depth = Math.max(0, paren_depth - 1);
6206
+ if (char === '[') bracket_depth++;
6207
+ if (char === ']') bracket_depth = Math.max(0, bracket_depth - 1);
6208
+ if (char === '{') brace_depth++;
6209
+ if (char === '}') brace_depth = Math.max(0, brace_depth - 1);
6210
+
6211
+ if ((char === ',' || char === ';') && !paren_depth && !bracket_depth && !brace_depth) {
6212
+ if (current.trim()) {
6213
+ parts.push(current.trim());
6214
+ }
6215
+ current = '';
6216
+ continue;
6217
+ }
6218
+
6219
+ current += char;
6164
6220
  }
6165
- return viewFields;
6166
- } catch (e) {
6167
- if (!exp) {
6168
- return;
6221
+
6222
+ if (current.trim()) {
6223
+ parts.push(current.trim());
6169
6224
  }
6170
- if (exp.substr(exp.length - 1, 1) === ';') exp = exp.substr(0, exp.length - 1); // remove closing if exist;
6171
- var exp_arr = exp.split(/;\s*(?=(?:[^"]|"[^"]*")*$)/g); // split ; outside quotes
6172
- if (exp_arr?.length) {
6173
- for (let val of exp_arr) {
6174
- // run view fields
6175
- var pos = val.indexOf(':');
6176
- var seg = [val.substring(0, pos), val.substring(pos + 1)];
6177
- if (seg && seg.length === 2) {
6178
- let id = seg[0].substr(1, seg[0].length);
6179
- if (!id) continue;
6180
- viewFields.push({
6181
- id,
6182
- val: seg[1],
6183
- // , props: {},
6184
- });
6185
- } else {
6186
- func.utils.debug.log(SESSION_ID, _ds.prog_id, {
6187
- module: _ds.viewModule,
6188
- action: 'set',
6189
- prop: 'parse update exp',
6190
- details: exp,
6191
- result: '',
6192
- error: 'Invalid json; too many segments',
6193
- source: _ds.viewSourceDesc,
6194
- json: '',
6195
- fields: '',
6196
- dsSession: dsSessionP,
6197
- });
6225
+
6226
+ return parts;
6227
+ };
6228
+ const find_top_level_colon = function (value) {
6229
+ let quote = null;
6230
+ let escape = false;
6231
+ let paren_depth = 0;
6232
+ let bracket_depth = 0;
6233
+ let brace_depth = 0;
6234
+
6235
+ for (let index = 0; index < value.length; index++) {
6236
+ const char = value[index];
6237
+
6238
+ if (escape) {
6239
+ escape = false;
6240
+ continue;
6241
+ }
6242
+
6243
+ if (quote) {
6244
+ if (char === '\\') {
6245
+ escape = true;
6246
+ } else if (char === quote) {
6247
+ quote = null;
6198
6248
  }
6249
+ continue;
6250
+ }
6251
+
6252
+ if (char === "'" || char === '"' || char === '`') {
6253
+ quote = char;
6254
+ continue;
6255
+ }
6256
+
6257
+ if (char === '(') paren_depth++;
6258
+ if (char === ')') paren_depth = Math.max(0, paren_depth - 1);
6259
+ if (char === '[') bracket_depth++;
6260
+ if (char === ']') bracket_depth = Math.max(0, bracket_depth - 1);
6261
+ if (char === '{') brace_depth++;
6262
+ if (char === '}') brace_depth = Math.max(0, brace_depth - 1);
6263
+
6264
+ if (char === ':' && !paren_depth && !bracket_depth && !brace_depth) {
6265
+ return index;
6199
6266
  }
6200
6267
  }
6201
6268
 
6202
- return viewFields;
6269
+ return -1;
6270
+ };
6271
+
6272
+ exp = trim_wrapping_braces(exp.replace(/\n/gi, ''));
6273
+ const exp_arr = split_top_level(exp);
6274
+ for (let index = 0; index < exp_arr.length; index++) {
6275
+ const segment = exp_arr[index];
6276
+ const pos = find_top_level_colon(segment);
6277
+ if (pos === -1) {
6278
+ continue;
6279
+ }
6280
+
6281
+ let id = strip_wrapping_quotes(segment.substring(0, pos));
6282
+ const val = segment.substring(pos + 1).trim();
6283
+ if (id.substring(0, 1) === '@') {
6284
+ id = id.substring(1);
6285
+ }
6286
+ if (!id || !val) {
6287
+ continue;
6288
+ }
6289
+
6290
+ viewFields.push({
6291
+ id,
6292
+ val,
6293
+ });
6203
6294
  }
6295
+
6296
+ return viewFields;
6204
6297
  };
6205
6298
  func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, rowIdP, org_dsSessionP) {
6206
6299
  const return_value = async (field_id, value) => {
@@ -15979,10 +16072,11 @@ func.runtime.render.bind_xu_event = function (options) {
15979
16072
  evt[val.event_modifiers]();
15980
16073
  }
15981
16074
 
15982
- if (val.workflow) {
15983
- const workflow_keys = Object.keys(val.workflow);
16075
+ const workflow = val.workflow || val.event;
16076
+ if (workflow) {
16077
+ const workflow_keys = Object.keys(workflow);
15984
16078
  for (let workflow_index = 0; workflow_index < workflow_keys.length; workflow_index++) {
15985
- const val2 = val.workflow[workflow_keys[workflow_index]];
16079
+ const val2 = workflow[workflow_keys[workflow_index]];
15986
16080
  if (!val2.data.enabled) continue;
15987
16081
 
15988
16082
  func.events.add_to_queue(
@@ -16694,7 +16788,7 @@ func.runtime.render.normalize_node_attributes = function (nodeP) {
16694
16788
  {
16695
16789
  handler: 'custom',
16696
16790
  props: {},
16697
- event: [
16791
+ workflow: [
16698
16792
  {
16699
16793
  id: Date.now(),
16700
16794
  data: {