@xuda.io/xuda-worker-bundle-min 1.3.896 → 1.3.898

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 +45 -20
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -7117,6 +7117,22 @@ func.utils.connect_pouchdb = async function (SESSION_ID) {
7117
7117
  return new PouchDB("xuda_rt_" + app_id);
7118
7118
  };
7119
7119
 
7120
+ func.utils.validate_pouchdb = async function (SESSION_ID) {
7121
+ const app_id = SESSION_OBJ[SESSION_ID].app_id;
7122
+ const db = new PouchDB("xuda_rt_" + app_id);
7123
+ db.info()
7124
+ .then((info) => {
7125
+ console.log("Database exists", info);
7126
+ })
7127
+ .catch((error) => {
7128
+ if (error.status === 404) {
7129
+ throw new Error("Database does not exist");
7130
+ } else {
7131
+ throw new Error("Error accessing database", error);
7132
+ }
7133
+ });
7134
+ };
7135
+
7120
7136
  func.utils.call_plugin_api = function (SESSION_ID, plugin_nameP, dataP) {
7121
7137
  var _session = SESSION_OBJ[SESSION_ID];
7122
7138
 
@@ -9792,28 +9808,37 @@ func.expression.secure_eval = async function (
9792
9808
  }
9793
9809
  } else {
9794
9810
  try {
9795
- let vm = new VM.VM({
9796
- sandbox: {
9797
- xu,
9798
- func,
9799
- SESSION_ID,
9800
- SESSION_OBJ: { [`${SESSION_ID}`]: SESSION_OBJ[SESSION_ID] },
9801
- callback: js_script_callback,
9802
- job_id,
9803
- },
9804
- timeout: 1000,
9805
- allowAsync: false,
9806
- });
9807
- let ret = val;
9808
- if (typeof val === "string") {
9809
- ret = await vm.run(val);
9811
+ try {
9812
+ let vm = new VM.VM({
9813
+ sandbox: {
9814
+ xu,
9815
+ func,
9816
+ SESSION_ID,
9817
+ SESSION_OBJ: { [`${SESSION_ID}`]: SESSION_OBJ[SESSION_ID] },
9818
+ callback: js_script_callback,
9819
+ job_id,
9820
+ },
9821
+ timeout: 1000,
9822
+ allowAsync: false,
9823
+ });
9824
+ let ret = val;
9825
+ if (typeof val === "string") {
9826
+ ret = await vm.run(val);
9827
+ }
9828
+ return ret;
9829
+ // return vm.run(val);
9830
+ } catch (err) {
9831
+ // console.warn("Failed to execute VM script:", val, err);
9832
+ // return val;
9833
+ throw "";
9810
9834
  }
9811
- return ret;
9812
- // return vm.run(val);
9813
9835
  } catch (err) {
9814
- // console.warn("Failed to execute VM script:", val, err);
9815
- // return val;
9816
- throw "";
9836
+ try {
9837
+ return JSON5.parse(val);
9838
+ } catch (err) {
9839
+ // console.error(err);
9840
+ return val;
9841
+ }
9817
9842
  }
9818
9843
  }
9819
9844
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/xuda-worker-bundle-min",
3
- "version": "1.3.896",
3
+ "version": "1.3.898",
4
4
  "description": "xuda framework min",
5
5
  "main": "index.js",
6
6
  "scripts": {