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

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 +83 -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,11 @@ 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(
386
+ SESSION_ID,
387
+ serviceP,
388
+ opt
389
+ );
386
390
  }
387
391
  return await func.db.pouch[serviceP](SESSION_ID, dataP);
388
392
  } catch (err) {}
@@ -396,7 +400,11 @@ func.common.db = async function (
396
400
 
397
401
  return json;
398
402
  } catch (err) {
399
- const json = await perform_rpi_request(serviceP);
403
+ const json = await func.common.perform_rpi_request(
404
+ SESSION_ID,
405
+ serviceP,
406
+ opt
407
+ );
400
408
  if (json.opt) {
401
409
  try {
402
410
  try {
@@ -425,7 +433,7 @@ func.common.db = async function (
425
433
  await db.get(dataP.row_id);
426
434
  return await func.db.pouch[serviceP](SESSION_ID, dataP);
427
435
  } catch (err) {
428
- return await perform_rpi_request(serviceP);
436
+ return await func.common.perform_rpi_request(SESSION_ID, serviceP, opt);
429
437
  }
430
438
  };
431
439
  const create_dbs_pouch = async function (db) {
@@ -433,7 +441,7 @@ func.common.db = async function (
433
441
  try {
434
442
  return await func.db.pouch[serviceP](SESSION_ID, dataP);
435
443
  } catch (err) {
436
- return await perform_rpi_request(serviceP);
444
+ return await func.common.perform_rpi_request(SESSION_ID, serviceP, opt);
437
445
  }
438
446
  };
439
447
 
@@ -484,66 +492,30 @@ func.common.db = async function (
484
492
 
485
493
  default:
486
494
  try {
487
- const json = await perform_rpi_request(serviceP);
495
+ const json = await func.common.perform_rpi_request(
496
+ SESSION_ID,
497
+ serviceP,
498
+ opt
499
+ );
488
500
  return success_callback(json, true);
489
501
  } catch (err) {
490
502
  return error_callback(err);
491
503
  }
492
504
  break;
493
505
  }
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
506
  }
518
507
  try {
519
- const json = await perform_rpi_request(serviceP);
508
+ const json = await func.common.perform_rpi_request(
509
+ SESSION_ID,
510
+ serviceP,
511
+ opt
512
+ );
520
513
  return success_callback(json, true);
521
514
  } catch (err) {
522
515
  return error_callback(err);
523
516
  }
524
- // return perform_rpi_request(serviceP);
525
517
  }
526
518
 
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
519
  // DOCKER // PROCESS_SERVER
548
520
 
549
521
  const response = function (res, ret) {
@@ -1072,6 +1044,41 @@ func.api.call_api_program = async function (prog_id, params) {
1072
1044
 
1073
1045
  return await api_utils.call_api_program(prog_id, params, null);
1074
1046
  };
1047
+
1048
+ func.common.perform_rpi_request = async function (
1049
+ SESSION_ID,
1050
+ serviceP,
1051
+ opt = {}
1052
+ ) {
1053
+ var url = func.common.get_url(SESSION_ID, "rpi", "");
1054
+ var _session = SESSION_OBJ[SESSION_ID];
1055
+ const app_id = _session.APP_ID;
1056
+
1057
+ if (
1058
+ APP_OBJ[app_id].is_deployment &&
1059
+ _session.rpi_http_methods?.includes(serviceP)
1060
+ ) {
1061
+ url = "https://" + _session.host + "/rpi/";
1062
+ }
1063
+
1064
+ url += serviceP;
1065
+
1066
+ try {
1067
+ const response = await fetch(url, {
1068
+ method: opt.type ? opt.type : "POST",
1069
+ headers: {
1070
+ Accept: "application/json",
1071
+ "Content-Type": "application/json",
1072
+ },
1073
+ body: JSON.stringify(data),
1074
+ });
1075
+ if (!response.ok) throw "";
1076
+ const json = await response.json();
1077
+ return json.data;
1078
+ } catch (err) {
1079
+ console.error(err);
1080
+ }
1081
+ };
1075
1082
  glb.DEBUG_INFO_OBJ = {};
1076
1083
  // var CONNECTION_ATTEMPTS = 0;
1077
1084
  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.419",
4
4
  "description": "xuda framework min",
5
5
  "main": "index.js",
6
6
  "scripts": {