@xuda.io/xuda-worker-bundle-min 1.3.693 → 1.3.694

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 +192 -33
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -192,7 +192,8 @@ func.common.get_custom_icon = async function (
192
192
  const url = func.common.get_url(
193
193
  SESSION_ID,
194
194
  "studio-drive",
195
- `${app_obj.app_replicate ? app_obj.app_replicate : app_obj._id}/${tree_ret2.rPTH
195
+ `${app_obj.app_replicate ? app_obj.app_replicate : app_obj._id}/${
196
+ tree_ret2.rPTH
196
197
  }`
197
198
  );
198
199
  return url;
@@ -219,7 +220,7 @@ func.common.db = async function (
219
220
  const app_id = _session.app_id;
220
221
 
221
222
  if (_session.engine_mode === "live_preview") {
222
- console.log("request", dataP)
223
+ console.log("request", dataP);
223
224
  }
224
225
 
225
226
  var data = {
@@ -242,7 +243,7 @@ func.common.db = async function (
242
243
  ) {
243
244
  data.device_name = firebase.auth().currentUser.displayName;
244
245
  }
245
- } catch (error) { }
246
+ } catch (error) {}
246
247
 
247
248
  for (const [key, val] of Object.entries(dataP)) {
248
249
  data[key] = val;
@@ -263,7 +264,7 @@ func.common.db = async function (
263
264
  }
264
265
 
265
266
  if (_session.engine_mode === "live_preview") {
266
- console.log("response", ret)
267
+ console.log("response", ret);
267
268
  }
268
269
  resolve(ret, true);
269
270
  };
@@ -368,7 +369,7 @@ func.common.db = async function (
368
369
  });
369
370
  }
370
371
  func.db.pouch.set_db_replication_from_server(SESSION_ID);
371
- } catch (err) { }
372
+ } catch (err) {}
372
373
  }
373
374
  return json;
374
375
  }
@@ -809,8 +810,9 @@ func.common.getContrast_color = function (hexcolor) {
809
810
  };
810
811
 
811
812
  func.common.get_url = function (SESSION_ID, method, path) {
812
- return `https://${SESSION_OBJ[SESSION_ID].domain}/${method}${path ? "/" + path : "/"
813
- }`;
813
+ return `https://${SESSION_OBJ[SESSION_ID].domain}/${method}${
814
+ path ? "/" + path : "/"
815
+ }`;
814
816
  };
815
817
 
816
818
  var UI_FRAMEWORK_INSTALLED = null;
@@ -1029,7 +1031,7 @@ func.api.invoke_event = async function (event_id) {
1029
1031
 
1030
1032
  return await api_utils.invoke_event(event_id);
1031
1033
  };
1032
- func.api.call_api_program = async function (prog_id, params) {
1034
+ func.api.call_project_api = async function (prog_id, params) {
1033
1035
  const SESSION_ID = Object.keys(SESSION_OBJ)[0];
1034
1036
  const api_utils = await func.common.get_module(
1035
1037
  SESSION_ID,
@@ -1044,7 +1046,7 @@ func.api.call_api_program = async function (prog_id, params) {
1044
1046
  }
1045
1047
  );
1046
1048
 
1047
- return await api_utils.call_api_program(prog_id, params, null);
1049
+ return await api_utils.call_project_api(prog_id, params, null);
1048
1050
  };
1049
1051
  glb.rpi_request_queue_num = 0;
1050
1052
  func.common.perform_rpi_request = async function (
@@ -8665,57 +8667,214 @@ func.events.execute = async function (
8665
8667
  comment: async function () {
8666
8668
  if (jobNoP) func.events.delete_job(SESSION_ID, jobNoP);
8667
8669
  },
8668
- call_api: async function () {
8670
+ call_project_api: async function () {
8669
8671
  const params_obj = await get_params_obj();
8670
- let _prog_id = await get_prog_id();
8672
+ const _prog_id = await get_prog_id();
8671
8673
 
8672
8674
  if (!_prog_id) {
8673
8675
  func.utils.debug_report(
8674
8676
  SESSION_ID,
8675
8677
  "func.events.execute",
8676
- `${elementP} > ${triggerP} > ${functionP} > program is missing`,
8678
+ `${elementP} > ${triggerP} > ${functionP} > program not defined`,
8677
8679
  "E"
8678
8680
  );
8679
8681
  func.events.delete_job(SESSION_ID, jobNoP);
8680
8682
  return;
8681
8683
  }
8682
8684
 
8683
- let output_field = await get_args_property_value("outputField");
8685
+ const output_field = await get_args_property_value("outputField");
8684
8686
 
8685
- if (!output_field) {
8687
+ // if (!output_field) {
8688
+ // func.utils.debug_report(
8689
+ // SESSION_ID,
8690
+ // "func.events.execute",
8691
+ // `${elementP} >${triggerP} >${functionP} > Output field not defined`,
8692
+ // "E"
8693
+ // );
8694
+ // func.events.delete_job(SESSION_ID, jobNoP);
8695
+ // return;
8696
+ // }
8697
+
8698
+ const api_ret = await func.api.call_project_api(_prog_id, params_obj);
8699
+
8700
+ if (output_field) {
8701
+ let datasource_changes = {};
8702
+
8703
+ let ret_get_value = await func.datasource.get_value(
8704
+ SESSION_ID,
8705
+ output_field,
8706
+ dsSessionP
8707
+ );
8708
+ if (ret_get_value.found) {
8709
+ let _ds = _session.DS_GLB[ret_get_value.dsSessionP];
8710
+ if (!datasource_changes[_ds.dsSession]) {
8711
+ datasource_changes[_ds.dsSession] = {};
8712
+ }
8713
+ if (
8714
+ !datasource_changes[_ds.dsSession][ret_get_value.currentRecordId]
8715
+ ) {
8716
+ datasource_changes[_ds.dsSession][ret_get_value.currentRecordId] =
8717
+ {};
8718
+ }
8719
+ datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][
8720
+ output_field
8721
+ ] = api_ret;
8722
+ await func.datasource.update(SESSION_ID, datasource_changes);
8723
+ }
8724
+ }
8725
+ func.events.delete_job(SESSION_ID, jobNoP);
8726
+ },
8727
+ call_system_api: async function () {
8728
+ const api_method = await get_args_property_value("api_method");
8729
+
8730
+ if (!api_method) {
8686
8731
  func.utils.debug_report(
8687
8732
  SESSION_ID,
8688
8733
  "func.events.execute",
8689
- `${elementP} >${triggerP} >${functionP} > Output field is missing`,
8734
+ `${elementP} >${triggerP} >${functionP} > api_method not defined`,
8690
8735
  "E"
8691
8736
  );
8692
8737
  func.events.delete_job(SESSION_ID, jobNoP);
8693
8738
  return;
8694
8739
  }
8695
8740
 
8696
- const api_ret = await func.api.call_api_program(_prog_id, params_obj);
8741
+ const payload = await get_args_property_value("payload");
8697
8742
 
8698
- let datasource_changes = {};
8743
+ if (!payload) {
8744
+ func.utils.debug_report(
8745
+ SESSION_ID,
8746
+ "func.events.execute",
8747
+ `${elementP} >${triggerP} >${functionP} > payload not defined`,
8748
+ "E"
8749
+ );
8750
+ func.events.delete_job(SESSION_ID, jobNoP);
8751
+ return;
8752
+ }
8699
8753
 
8700
- let ret_get_value = await func.datasource.get_value(
8701
- SESSION_ID,
8702
- output_field,
8703
- dsSessionP
8704
- );
8705
- if (ret_get_value.found) {
8706
- let _ds = _session.DS_GLB[ret_get_value.dsSessionP];
8707
- if (!datasource_changes[_ds.dsSession]) {
8708
- datasource_changes[_ds.dsSession] = {};
8709
- }
8710
- if (!datasource_changes[_ds.dsSession][ret_get_value.currentRecordId]) {
8711
- datasource_changes[_ds.dsSession][ret_get_value.currentRecordId] = {};
8754
+ const output_field = await get_args_property_value("outputField");
8755
+
8756
+ // if (!output_field) {
8757
+ // func.utils.debug_report(
8758
+ // SESSION_ID,
8759
+ // "func.events.execute",
8760
+ // `${elementP} >${triggerP} >${functionP} > Output field not defined`,
8761
+ // "E"
8762
+ // );
8763
+ // func.events.delete_job(SESSION_ID, jobNoP);
8764
+ // return;
8765
+ // }
8766
+
8767
+ const api_ret = await func.api.call_system_api(api_method, payload);
8768
+ if (output_field) {
8769
+ let datasource_changes = {};
8770
+
8771
+ let ret_get_value = await func.datasource.get_value(
8772
+ SESSION_ID,
8773
+ output_field,
8774
+ dsSessionP
8775
+ );
8776
+ if (ret_get_value.found) {
8777
+ let _ds = _session.DS_GLB[ret_get_value.dsSessionP];
8778
+ if (!datasource_changes[_ds.dsSession]) {
8779
+ datasource_changes[_ds.dsSession] = {};
8780
+ }
8781
+ if (
8782
+ !datasource_changes[_ds.dsSession][ret_get_value.currentRecordId]
8783
+ ) {
8784
+ datasource_changes[_ds.dsSession][ret_get_value.currentRecordId] =
8785
+ {};
8786
+ }
8787
+ datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][
8788
+ output_field
8789
+ ] = api_ret;
8790
+ await func.datasource.update(SESSION_ID, datasource_changes);
8712
8791
  }
8713
- datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][
8714
- output_field
8715
- ] = api_ret;
8716
- await func.datasource.update(SESSION_ID, datasource_changes);
8717
8792
  }
8793
+ func.events.delete_job(SESSION_ID, jobNoP);
8794
+ },
8795
+ call_external_api: async function () {
8796
+ const method = await get_args_property_value("method");
8797
+
8798
+ if (!method) {
8799
+ func.utils.debug_report(
8800
+ SESSION_ID,
8801
+ "func.events.execute",
8802
+ `${elementP} >${triggerP} >${functionP} > method not defined`,
8803
+ "E"
8804
+ );
8805
+ func.events.delete_job(SESSION_ID, jobNoP);
8806
+ return;
8807
+ }
8808
+
8809
+ const api_url = await get_args_property_value("api_url");
8810
+
8811
+ if (!api_url) {
8812
+ func.utils.debug_report(
8813
+ SESSION_ID,
8814
+ "func.events.execute",
8815
+ `${elementP} >${triggerP} >${functionP} > api_url not defined`,
8816
+ "E"
8817
+ );
8818
+ func.events.delete_job(SESSION_ID, jobNoP);
8819
+ return;
8820
+ }
8821
+
8822
+ const payload = await get_args_property_value("payload");
8823
+
8824
+ if (!payload) {
8825
+ func.utils.debug_report(
8826
+ SESSION_ID,
8827
+ "func.events.execute",
8828
+ `${elementP} >${triggerP} >${functionP} > payload not defined`,
8829
+ "E"
8830
+ );
8831
+ func.events.delete_job(SESSION_ID, jobNoP);
8832
+ return;
8833
+ }
8834
+
8835
+ const output_field = await get_args_property_value("outputField");
8836
+
8837
+ // if (!output_field) {
8838
+ // func.utils.debug_report(
8839
+ // SESSION_ID,
8840
+ // "func.events.execute",
8841
+ // `${elementP} >${triggerP} >${functionP} > Output field not defined`,
8842
+ // "E"
8843
+ // );
8844
+ // func.events.delete_job(SESSION_ID, jobNoP);
8845
+ // return;
8846
+ // }
8847
+
8848
+ const api_ret = await func.api.call_external_api(
8849
+ method,
8850
+ api_url,
8851
+ payload
8852
+ );
8853
+ if (output_field) {
8854
+ let datasource_changes = {};
8718
8855
 
8856
+ let ret_get_value = await func.datasource.get_value(
8857
+ SESSION_ID,
8858
+ output_field,
8859
+ dsSessionP
8860
+ );
8861
+ if (ret_get_value.found) {
8862
+ let _ds = _session.DS_GLB[ret_get_value.dsSessionP];
8863
+ if (!datasource_changes[_ds.dsSession]) {
8864
+ datasource_changes[_ds.dsSession] = {};
8865
+ }
8866
+ if (
8867
+ !datasource_changes[_ds.dsSession][ret_get_value.currentRecordId]
8868
+ ) {
8869
+ datasource_changes[_ds.dsSession][ret_get_value.currentRecordId] =
8870
+ {};
8871
+ }
8872
+ datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][
8873
+ output_field
8874
+ ] = api_ret;
8875
+ await func.datasource.update(SESSION_ID, datasource_changes);
8876
+ }
8877
+ }
8719
8878
  func.events.delete_job(SESSION_ID, jobNoP);
8720
8879
  },
8721
8880
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/xuda-worker-bundle-min",
3
- "version": "1.3.693",
3
+ "version": "1.3.694",
4
4
  "description": "xuda framework min",
5
5
  "main": "index.js",
6
6
  "scripts": {