ws-process 0.3.29 → 0.3.31

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 +32 -24
  2. package/package.json +4 -6
package/index.js CHANGED
@@ -1,9 +1,9 @@
1
+ /* eslint-disable import/no-unresolved */
1
2
  // ws-process.js
2
- import { tryit } from 'ui5-lib-rc';
3
- import randomize from 'randomatic';
4
3
  import axios from 'axios';
5
- import { cloneDeep } from 'lodash';
6
- import { defined } from '@bsgp/lib-core';
4
+ import {
5
+ defined, clone, makeid, tryit,
6
+ } from '@bsgp/lib-core';
7
7
  import { ref, Loading, getRef } from './Loading-esm';
8
8
  import {
9
9
  storeSplittedData,
@@ -24,9 +24,9 @@ import reducer, { initialState } from './reducer';
24
24
  import 'url-search-params-polyfill';
25
25
  import { cutStringByLength, createSplitPayload } from './lib/split-payload';
26
26
 
27
- const local = {
28
- processes: {},
29
- wsProcess: initialState,
27
+ const local = {
28
+ processes: {},
29
+ wsProcess: initialState,
30
30
  };
31
31
 
32
32
  local.dispatch = (action) => {
@@ -51,7 +51,7 @@ function isObject(obj) {
51
51
  }
52
52
 
53
53
  function getRandomID() {
54
- return randomize('a', 5);
54
+ return makeid(5);
55
55
  }
56
56
 
57
57
  function getUSP(url) {
@@ -118,7 +118,7 @@ function startBatchProcess(processID) {
118
118
  return (dispatch, getState) => new Promise((resolve, reject) => {
119
119
  dispatch(getWebSocket())
120
120
  .then(() => {
121
- const jsonMSG = cloneDeep(local.wsProcess.processes[processID]);
121
+ const jsonMSG = clone(local.wsProcess.processes[processID]);
122
122
  jsonMSG.action = 'batchprocess';
123
123
 
124
124
  const user = getState().user.currentUser;
@@ -377,12 +377,12 @@ function handleResponseHandler(res, getState, isLast = true, isFirst = true) {
377
377
  );
378
378
  const { resHandler, callback, requestTime } = cProcessItem;
379
379
 
380
- if(process.env.NODE_ENV === "test"){
380
+ if (process.env.NODE_ENV === 'test') {
381
381
  // pass
382
- }else{
383
- console.log('%cdistance:', 'color:orange', new Date() - new Date(requestTime), res.processID, prc.count, tryit(()=>res.headers["x-log-id"]));
382
+ } else {
383
+ console.log('%cdistance:', 'color:orange', new Date() - new Date(requestTime), res.processID, prc.count, tryit(() => res.headers['x-log-id']));
384
384
  }
385
-
385
+
386
386
  const result = resHandler
387
387
  ? local.store.dispatch(
388
388
  resHandler({
@@ -505,11 +505,11 @@ function asyncSend(msg) {
505
505
 
506
506
  const currentState = getState();
507
507
  const {
508
- AltDomain: altDomain
509
- } = tryit(() => currentState["api-Configuration"].merged.ui.result) || {};
510
- if(altDomain){
508
+ AltDomain: altDomain,
509
+ } = tryit(() => currentState['api-Configuration'].merged.ui.result) || {};
510
+ if (altDomain) {
511
511
  url = [altDomain, msg.url.replace(/^\/{0,}/, '')].join('/');
512
- }else{
512
+ } else {
513
513
  url = ['https://api.bsg.support', msg.url.replace(/^\/{0,}/, '')].join('/');
514
514
  }
515
515
  }
@@ -540,9 +540,9 @@ function asyncSend(msg) {
540
540
  validateStatus: () => true,
541
541
  });
542
542
 
543
- if(process.env.NODE_ENV === "test"){
543
+ if (process.env.NODE_ENV === 'test') {
544
544
  // pass
545
- }else{
545
+ } else {
546
546
  console.log('%csending message:', 'color:green', httpMSG, msg);
547
547
  }
548
548
 
@@ -559,6 +559,9 @@ function asyncSend(msg) {
559
559
  local.dispatch(updateWSCount(processID));
560
560
  reject(ex);
561
561
  }).then((data) => {
562
+ if (data === undefined) {
563
+ return data;
564
+ }
562
565
  const bodyUrl = tryit(() => data.data.getBodyFromUrl === true && data.data.url);
563
566
  if (bodyUrl) {
564
567
  return axios({
@@ -570,9 +573,13 @@ function asyncSend(msg) {
570
573
  }
571
574
  return data;
572
575
  }).then((data) => {
573
- if(process.env.NODE_ENV === "test"){
576
+ if (data === undefined) {
577
+ return data;
578
+ }
579
+
580
+ if (process.env.NODE_ENV === 'test') {
574
581
  // pass
575
- }else{
582
+ } else {
576
583
  console.log('%cHTTP.res:', 'color:red', data);
577
584
  }
578
585
  const processID = tryit(() => data.headers['process-id']) || tryit(() => data.config.headers['bsg-support-process-id']);
@@ -613,7 +620,7 @@ function asyncSend(msg) {
613
620
  data: newData,
614
621
  });
615
622
  }
616
- return;
623
+ return undefined;
617
624
  }
618
625
  }
619
626
 
@@ -621,10 +628,11 @@ function asyncSend(msg) {
621
628
  newData, getState,
622
629
  );
623
630
  if (terminate === true) {
624
- return;
631
+ return undefined;
625
632
  }
626
633
 
627
634
  resolve(newData);
635
+ return undefined;
628
636
  });
629
637
  }
630
638
 
@@ -1278,7 +1286,7 @@ function init({
1278
1286
  local.store = store;
1279
1287
  local.stage = stage;
1280
1288
  local.wsURL = wsURL;
1281
-
1289
+
1282
1290
  local.beforeEachProcess = beforeEachProcess || (() => {});
1283
1291
  local.afterEachProcess = afterEachProcess || (() => {});
1284
1292
  local.beforeAllProcesses = beforeAllProcesses || (() => {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ws-process",
3
- "version": "0.3.29",
3
+ "version": "0.3.31",
4
4
  "description": "Process Management for Web Socket Client",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -23,12 +23,10 @@
23
23
  "url": "https://github.com/bsgp/ws-process/issues"
24
24
  },
25
25
  "homepage": "https://github.com/bsgp/ws-process#readme",
26
- "dependencies": {
27
- "@bsgp/lib-core": "^0.2.195",
28
- "axios": "0.21.1",
26
+ "peerDependencies": {
27
+ "@bsgp/lib-core": "0.2.510",
28
+ "axios": "1.3.4",
29
29
  "immer": "3.1.3",
30
- "lodash": "4.17.19",
31
- "randomatic": "3.1.1",
32
30
  "react": "16.8.6",
33
31
  "react-dom": "16.8.6",
34
32
  "ui5-lib-rc": "0.8.3",