@xuda.io/xuda-worker-bundle 1.3.1276 → 1.3.1278

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.
Files changed (2) hide show
  1. package/index.js +68 -20
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -3215,8 +3215,15 @@ func.datasource.run_events_functions = async function (
3215
3215
  dataSourceSession,
3216
3216
  event_id,
3217
3217
  calling_job,
3218
- async_event
3218
+ async_event,
3219
+ event_parameters
3219
3220
  ) {
3221
+
3222
+ if (typeof dataSourceSession === "undefined" || dataSourceSession === null) {
3223
+ console.warn(`Event ${event_id} not exist or not found`)
3224
+ return
3225
+ }
3226
+
3220
3227
  // return new Promise(async (resolve, reject) => {
3221
3228
  var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
3222
3229
  var args = _ds.args;
@@ -3236,7 +3243,7 @@ func.datasource.run_events_functions = async function (
3236
3243
  dataSourceSession,
3237
3244
  val.data.event_name,
3238
3245
  args.callingSourceP,
3239
- val.data.parameters
3246
+ event_parameters// val.data.parameters
3240
3247
  );
3241
3248
 
3242
3249
  if (calling_job || async_event) continue
@@ -3262,20 +3269,7 @@ func.datasource.run_events_functions = async function (
3262
3269
  if (job_promises.length) {
3263
3270
  await Promise.all(job_promises)
3264
3271
  }
3265
- // console.log(job_promises)
3266
- // resolve()
3267
-
3268
- // if (job_promises.length) {
3269
- // Promise.all(job_promises)
3270
- // .then((e) => {
3271
- // resolve()
3272
- // });
3273
-
3274
- // } else {
3275
- // resolve()
3276
- // }
3277
3272
 
3278
- // })
3279
3273
 
3280
3274
  };
3281
3275
 
@@ -8094,7 +8088,39 @@ func.events.validate = async function (
8094
8088
  const set_arguments = async function () {
8095
8089
  var args = argumentsP || {};
8096
8090
 
8097
- for await (let [key, fieldId] of Object.entries(
8091
+ // for await (let [key, fieldId] of Object.entries(
8092
+ // val.data.parameters
8093
+ // )) {
8094
+ // const field_info = func.common.find_item_by_key(
8095
+ // _view_obj.progFields,
8096
+ // "field_id",
8097
+ // fieldId
8098
+ // );
8099
+
8100
+ // var value = await func.common.get_cast_val(
8101
+ // SESSION_ID,
8102
+ // "events",
8103
+ // fieldId,
8104
+ // field_info.props.fieldType,
8105
+ // args[fieldId]
8106
+ // );
8107
+
8108
+ // const ret = await func.datasource.get_value(
8109
+ // SESSION_ID,
8110
+ // fieldId,
8111
+ // dsSessionP,
8112
+ // _ds.currentRecordId
8113
+ // );
8114
+
8115
+ // const datasource_changes = {
8116
+ // [ret.dsSessionP]: {
8117
+ // [ret.currentRecordId]: { [fieldId]: value },
8118
+ // },
8119
+ // };
8120
+ // await func.datasource.update(SESSION_ID, datasource_changes);
8121
+ // }
8122
+
8123
+ for await (let [fieldId, val_obj] of Object.entries(
8098
8124
  val.data.parameters
8099
8125
  )) {
8100
8126
  const field_info = func.common.find_item_by_key(
@@ -8103,14 +8129,34 @@ func.events.validate = async function (
8103
8129
  fieldId
8104
8130
  );
8105
8131
 
8106
- var value = await func.common.get_cast_val(
8132
+ if (field_info?.data?.type !== "virtual") {
8133
+ console.warn("parameter field must be virtual, update ignored");
8134
+ continue;
8135
+ }
8136
+
8137
+ if (!args[fieldId]) continue
8138
+
8139
+
8140
+
8141
+ let value = await func.common.get_cast_val(
8107
8142
  SESSION_ID,
8108
8143
  "events",
8109
8144
  fieldId,
8110
8145
  field_info.props.fieldType,
8111
- args[fieldId]
8146
+ args[fieldId].value
8112
8147
  );
8113
8148
 
8149
+ if (!_.isEmpty(args[fieldId].fx)) {
8150
+ value = (
8151
+ await func.expression.get(
8152
+ SESSION_ID,
8153
+ args[fieldId].fx,
8154
+ dsSessionP,
8155
+ "update"
8156
+ )
8157
+ ).result;
8158
+ }
8159
+ // find the target field in the program dataset
8114
8160
  const ret = await func.datasource.get_value(
8115
8161
  SESSION_ID,
8116
8162
  fieldId,
@@ -9061,7 +9107,8 @@ func.events.execute = async function (
9061
9107
  dsP,
9062
9108
  event_name,
9063
9109
  jobNoP,
9064
- null
9110
+ null,
9111
+ calling_trigger_prop?.data?.name?.parameters || {}
9065
9112
  );
9066
9113
  }
9067
9114
  // done_execution(event_name);
@@ -9091,7 +9138,8 @@ func.events.execute = async function (
9091
9138
  dsP,
9092
9139
  event_name,
9093
9140
  jobNoP,
9094
- calling_trigger_prop?.props?.async
9141
+ calling_trigger_prop?.props?.async,
9142
+ calling_trigger_prop?.data?.name?.parameters || {}
9095
9143
  );
9096
9144
  // done_execution(event_name);
9097
9145
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/xuda-worker-bundle",
3
- "version": "1.3.1276",
3
+ "version": "1.3.1278",
4
4
  "description": "xuda framework",
5
5
  "main": "index.js",
6
6
  "scripts": {