@xuda.io/xuda-worker-bundle-min 1.3.417 → 1.3.418

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 +72 -76
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -266,34 +266,34 @@ func.common.db = async function (
266
266
 
267
267
  data.req_id = new Date().valueOf();
268
268
 
269
- const perform_rpi_request = async function (serviceP) {
270
- var url = func.common.get_url(SESSION_ID, "rpi", "");
269
+ // const perform_rpi_request = async function (serviceP) {
270
+ // var url = func.common.get_url(SESSION_ID, "rpi", "");
271
271
 
272
- if (
273
- APP_OBJ[app_id].is_deployment &&
274
- _session.rpi_http_methods?.includes(serviceP)
275
- ) {
276
- url = "https://" + _session.host + "/rpi/";
277
- }
278
-
279
- url += serviceP;
272
+ // if (
273
+ // APP_OBJ[app_id].is_deployment &&
274
+ // _session.rpi_http_methods?.includes(serviceP)
275
+ // ) {
276
+ // url = "https://" + _session.host + "/rpi/";
277
+ // }
280
278
 
281
- try {
282
- const response = await fetch(url, {
283
- method: opt.type ? opt.type : "POST",
284
- headers: {
285
- Accept: "application/json",
286
- "Content-Type": "application/json",
287
- },
288
- body: JSON.stringify(data),
289
- });
290
- if (!response.ok) throw "";
291
- const json = await response.json();
292
- return json.data;
293
- } catch (err) {
294
- console.error(err);
295
- }
296
- };
279
+ // url += serviceP;
280
+
281
+ // try {
282
+ // const response = await fetch(url, {
283
+ // method: opt.type ? opt.type : "POST",
284
+ // headers: {
285
+ // Accept: "application/json",
286
+ // "Content-Type": "application/json",
287
+ // },
288
+ // body: JSON.stringify(data),
289
+ // });
290
+ // if (!response.ok) throw "";
291
+ // const json = await response.json();
292
+ // return json.data;
293
+ // } catch (err) {
294
+ // console.error(err);
295
+ // }
296
+ // };
297
297
 
298
298
  // const perform_rpi_request_from_studio = async function (serviceP) {
299
299
  // return new Promise(function (resolve, reject) {
@@ -382,7 +382,7 @@ func.common.db = async function (
382
382
  }
383
383
 
384
384
  if (doc.stat < 3) {
385
- return await perform_rpi_request(serviceP);
385
+ return await func.common.perform_rpi_request(SESSION_ID, serviceP);
386
386
  }
387
387
  return await func.db.pouch[serviceP](SESSION_ID, dataP);
388
388
  } catch (err) {}
@@ -396,7 +396,10 @@ func.common.db = async function (
396
396
 
397
397
  return json;
398
398
  } catch (err) {
399
- const json = await perform_rpi_request(serviceP);
399
+ const json = await func.common.perform_rpi_request(
400
+ SESSION_ID,
401
+ serviceP
402
+ );
400
403
  if (json.opt) {
401
404
  try {
402
405
  try {
@@ -425,7 +428,7 @@ func.common.db = async function (
425
428
  await db.get(dataP.row_id);
426
429
  return await func.db.pouch[serviceP](SESSION_ID, dataP);
427
430
  } catch (err) {
428
- return await perform_rpi_request(serviceP);
431
+ return await func.common.perform_rpi_request(SESSION_ID, serviceP);
429
432
  }
430
433
  };
431
434
  const create_dbs_pouch = async function (db) {
@@ -433,7 +436,7 @@ func.common.db = async function (
433
436
  try {
434
437
  return await func.db.pouch[serviceP](SESSION_ID, dataP);
435
438
  } catch (err) {
436
- return await perform_rpi_request(serviceP);
439
+ return await func.common.perform_rpi_request(SESSION_ID, serviceP);
437
440
  }
438
441
  };
439
442
 
@@ -484,66 +487,28 @@ func.common.db = async function (
484
487
 
485
488
  default:
486
489
  try {
487
- const json = await perform_rpi_request(serviceP);
490
+ const json = await func.common.perform_rpi_request(
491
+ SESSION_ID,
492
+ serviceP
493
+ );
488
494
  return success_callback(json, true);
489
495
  } catch (err) {
490
496
  return error_callback(err);
491
497
  }
492
498
  break;
493
499
  }
494
-
495
- // if (
496
- // SESSION_OBJ[SESSION_ID].engine_mode === "live_preview" &&
497
- // ["dbs_read", "dbs_update", "dbs_delete", "dbs_create"].includes(
498
- // serviceP
499
- // )
500
- // ) {
501
- // try {
502
- // const ret = {
503
- // code: 1,
504
- // data: await perform_rpi_request_from_pouch(serviceP),
505
- // };
506
- // return success_callback(ret);
507
- // } catch (err) {
508
- // return error_callback(err);
509
- // }
510
-
511
- // // const ret = {
512
- // // code: 1,
513
- // // data: await perform_rpi_request_from_pouch(serviceP),
514
- // // };
515
- // // return success_callback(ret);
516
- // }
517
500
  }
518
501
  try {
519
- const json = await perform_rpi_request(serviceP);
502
+ const json = await func.common.perform_rpi_request(
503
+ SESSION_ID,
504
+ serviceP
505
+ );
520
506
  return success_callback(json, true);
521
507
  } catch (err) {
522
508
  return error_callback(err);
523
509
  }
524
- // return perform_rpi_request(serviceP);
525
510
  }
526
511
 
527
- // if (
528
- // (typeof IS_DOCKER === "undefined" &&
529
- // typeof IS_PROCESS_SERVER === "undefined") ||
530
- // !SESSION_OBJ?.[SESSION_ID]?.rpi_http_methods?.includes(serviceP)
531
- // ) {
532
- // if (
533
- // SESSION_OBJ[SESSION_ID].engine_mode === "live_preview" &&
534
- // ["dbs_read", "dbs_update", "dbs_delete", "dbs_restore"].includes(
535
- // serviceP
536
- // )
537
- // ) {
538
- // const ret = {
539
- // code: 1,
540
- // data: await perform_rpi_request_from_studio(serviceP),
541
- // };
542
- // return success_callback(ret);
543
- // }
544
- // return perform_rpi_request(serviceP);
545
- // }
546
-
547
512
  // DOCKER // PROCESS_SERVER
548
513
 
549
514
  const response = function (res, ret) {
@@ -1072,6 +1037,37 @@ func.api.call_api_program = async function (prog_id, params) {
1072
1037
 
1073
1038
  return await api_utils.call_api_program(prog_id, params, null);
1074
1039
  };
1040
+
1041
+ func.common.perform_rpi_request = async function (SESSION_ID, serviceP) {
1042
+ var url = func.common.get_url(SESSION_ID, "rpi", "");
1043
+ var _session = SESSION_OBJ[SESSION_ID];
1044
+ const app_id = _session.APP_ID;
1045
+
1046
+ if (
1047
+ APP_OBJ[app_id].is_deployment &&
1048
+ _session.rpi_http_methods?.includes(serviceP)
1049
+ ) {
1050
+ url = "https://" + _session.host + "/rpi/";
1051
+ }
1052
+
1053
+ url += serviceP;
1054
+
1055
+ try {
1056
+ const response = await fetch(url, {
1057
+ method: opt.type ? opt.type : "POST",
1058
+ headers: {
1059
+ Accept: "application/json",
1060
+ "Content-Type": "application/json",
1061
+ },
1062
+ body: JSON.stringify(data),
1063
+ });
1064
+ if (!response.ok) throw "";
1065
+ const json = await response.json();
1066
+ return json.data;
1067
+ } catch (err) {
1068
+ console.error(err);
1069
+ }
1070
+ };
1075
1071
  glb.DEBUG_INFO_OBJ = {};
1076
1072
  // var CONNECTION_ATTEMPTS = 0;
1077
1073
  glb.APP_INFO = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/xuda-worker-bundle-min",
3
- "version": "1.3.417",
3
+ "version": "1.3.418",
4
4
  "description": "xuda framework min",
5
5
  "main": "index.js",
6
6
  "scripts": {