ws-process 0.3.29 → 0.3.30

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 +21 -22
  2. package/package.json +3 -5
package/index.js CHANGED
@@ -1,9 +1,8 @@
1
1
  // ws-process.js
2
- import { tryit } from 'ui5-lib-rc';
3
- import randomize from 'randomatic';
4
2
  import axios from 'axios';
5
- import { cloneDeep } from 'lodash';
6
- import { defined } from '@bsgp/lib-core';
3
+ import {
4
+ defined, clone, makeid, tryit,
5
+ } from '@bsgp/lib-core';
7
6
  import { ref, Loading, getRef } from './Loading-esm';
8
7
  import {
9
8
  storeSplittedData,
@@ -24,9 +23,9 @@ import reducer, { initialState } from './reducer';
24
23
  import 'url-search-params-polyfill';
25
24
  import { cutStringByLength, createSplitPayload } from './lib/split-payload';
26
25
 
27
- const local = {
28
- processes: {},
29
- wsProcess: initialState,
26
+ const local = {
27
+ processes: {},
28
+ wsProcess: initialState,
30
29
  };
31
30
 
32
31
  local.dispatch = (action) => {
@@ -51,7 +50,7 @@ function isObject(obj) {
51
50
  }
52
51
 
53
52
  function getRandomID() {
54
- return randomize('a', 5);
53
+ return makeid(5);
55
54
  }
56
55
 
57
56
  function getUSP(url) {
@@ -118,7 +117,7 @@ function startBatchProcess(processID) {
118
117
  return (dispatch, getState) => new Promise((resolve, reject) => {
119
118
  dispatch(getWebSocket())
120
119
  .then(() => {
121
- const jsonMSG = cloneDeep(local.wsProcess.processes[processID]);
120
+ const jsonMSG = clone(local.wsProcess.processes[processID]);
122
121
  jsonMSG.action = 'batchprocess';
123
122
 
124
123
  const user = getState().user.currentUser;
@@ -377,12 +376,12 @@ function handleResponseHandler(res, getState, isLast = true, isFirst = true) {
377
376
  );
378
377
  const { resHandler, callback, requestTime } = cProcessItem;
379
378
 
380
- if(process.env.NODE_ENV === "test"){
379
+ if (process.env.NODE_ENV === 'test') {
381
380
  // pass
382
- }else{
383
- console.log('%cdistance:', 'color:orange', new Date() - new Date(requestTime), res.processID, prc.count, tryit(()=>res.headers["x-log-id"]));
381
+ } else {
382
+ console.log('%cdistance:', 'color:orange', new Date() - new Date(requestTime), res.processID, prc.count, tryit(() => res.headers['x-log-id']));
384
383
  }
385
-
384
+
386
385
  const result = resHandler
387
386
  ? local.store.dispatch(
388
387
  resHandler({
@@ -505,11 +504,11 @@ function asyncSend(msg) {
505
504
 
506
505
  const currentState = getState();
507
506
  const {
508
- AltDomain: altDomain
509
- } = tryit(() => currentState["api-Configuration"].merged.ui.result) || {};
510
- if(altDomain){
507
+ AltDomain: altDomain,
508
+ } = tryit(() => currentState['api-Configuration'].merged.ui.result) || {};
509
+ if (altDomain) {
511
510
  url = [altDomain, msg.url.replace(/^\/{0,}/, '')].join('/');
512
- }else{
511
+ } else {
513
512
  url = ['https://api.bsg.support', msg.url.replace(/^\/{0,}/, '')].join('/');
514
513
  }
515
514
  }
@@ -540,9 +539,9 @@ function asyncSend(msg) {
540
539
  validateStatus: () => true,
541
540
  });
542
541
 
543
- if(process.env.NODE_ENV === "test"){
542
+ if (process.env.NODE_ENV === 'test') {
544
543
  // pass
545
- }else{
544
+ } else {
546
545
  console.log('%csending message:', 'color:green', httpMSG, msg);
547
546
  }
548
547
 
@@ -570,9 +569,9 @@ function asyncSend(msg) {
570
569
  }
571
570
  return data;
572
571
  }).then((data) => {
573
- if(process.env.NODE_ENV === "test"){
572
+ if (process.env.NODE_ENV === 'test') {
574
573
  // pass
575
- }else{
574
+ } else {
576
575
  console.log('%cHTTP.res:', 'color:red', data);
577
576
  }
578
577
  const processID = tryit(() => data.headers['process-id']) || tryit(() => data.config.headers['bsg-support-process-id']);
@@ -1278,7 +1277,7 @@ function init({
1278
1277
  local.store = store;
1279
1278
  local.stage = stage;
1280
1279
  local.wsURL = wsURL;
1281
-
1280
+
1282
1281
  local.beforeEachProcess = beforeEachProcess || (() => {});
1283
1282
  local.afterEachProcess = afterEachProcess || (() => {});
1284
1283
  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.30",
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",
26
+ "peerDependencies": {
27
+ "@bsgp/lib-core": "0.2.510",
28
28
  "axios": "0.21.1",
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",