vineanova-redux-artifacts 1.84.0 → 1.86.0

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.
package/CHANGELOG.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
- ## 1.84.0 (2022-10-16)
5
+ ## 1.86.0 (2022-10-17)
6
6
 
7
7
 
8
8
  ### Features
@@ -30,21 +30,25 @@ var ServiceConfigClass = /*#__PURE__*/function () {
30
30
  value: function initConfig(config) {
31
31
  this.config = config;
32
32
  }
33
+ }, {
34
+ key: "isTestEnv",
35
+ value: function isTestEnv() {
36
+ var isTest = (0, _get["default"])(this.config, 'environment.isTest', null);
37
+ var isLocalHost = (0, _get["default"])(this.config, 'environment.isLocalHost', null);
38
+ return isTest || isLocalHost;
39
+ }
33
40
  }, {
34
41
  key: "getBaseUri",
35
42
  value: function getBaseUri(serviceType) {
36
43
  _winstonLogger["default"].debug(this.config);
37
44
  var userEmail = (0, _get["default"])(this.config, 'user.email', null);
38
45
  var isDemoUser = userEmail === 'VineaNovaDemoAdmin.com' && serviceType !== 'login';
39
- var isTest = (0, _get["default"])(this.config, 'environment.isTest', null);
40
- var isLocalHost = (0, _get["default"])(this.config, 'environment.isLocalHost', null);
41
- isTest = isTest || isLocalHost;
42
46
  if (serviceType === 'mock' || isDemoUser) {
43
47
  apiUrl = mockApiUrl;
44
48
  } else if (serviceType === 'login') {
45
- apiUrl = isTest ? process.env.REACT_APP_COMMON_USER_API : process.env.REACT_APP_PROD_COMMON_USER_API;
49
+ apiUrl = this.isTestEnv() ? process.env.REACT_APP_COMMON_USER_API : process.env.REACT_APP_PROD_COMMON_USER_API;
46
50
  } else {
47
- apiUrl = isTest ? process.env.REACT_APP_CORE_API : process.env.REACT_APP_PROD_CORE_API;
51
+ apiUrl = this.isTestEnv() ? process.env.REACT_APP_CORE_API : process.env.REACT_APP_PROD_CORE_API;
48
52
  }
49
53
  return apiUrl;
50
54
  }
@@ -79,7 +83,7 @@ var ServiceConfigClass = /*#__PURE__*/function () {
79
83
  _winstonLogger["default"].debug("serviceType", {
80
84
  serviceType: serviceType
81
85
  });
82
- var isTest = (0, _get["default"])(this.config, 'environment.isTest', null);
86
+ var isTest = this.isTestEnv();
83
87
  var _this$config$user = this.config.user,
84
88
  accessToken = _this$config$user.accessToken,
85
89
  orgDetails = _this$config$user.orgDetails;
@@ -98,7 +102,13 @@ var ServiceConfigClass = /*#__PURE__*/function () {
98
102
  client.interceptors.request.use(function (config) {
99
103
  // Do something before request is sent
100
104
  var appCode = isTest ? process.env.REACT_APP_FUNCTION_CODE : process.env.REACT_APP_PROD_FUNCTION_CODE;
101
- config.params.code = appCode;
105
+ if (config.params) {
106
+ config.params.code = appCode;
107
+ } else {
108
+ config.params = {
109
+ code: appCode
110
+ };
111
+ }
102
112
  config.headers.Authorization = "Bearer ".concat(accessToken);
103
113
  config.headers["x-orgname"] = displayName;
104
114
  config.headers["x-tid"] = id;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vineanova-redux-artifacts",
3
- "version": "1.84.0",
3
+ "version": "1.86.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "browser": "lib/index.js",
@@ -20,23 +20,26 @@ class ServiceConfigClass {
20
20
  this.config = config;
21
21
  }
22
22
 
23
+ isTestEnv() {
24
+ const isTest = get(this.config, 'environment.isTest', null);
25
+ const isLocalHost = get(this.config, 'environment.isLocalHost', null);
26
+ return isTest || isLocalHost;
27
+ }
28
+
23
29
  getBaseUri(serviceType) {
24
30
  logger.debug(this.config);
25
31
  const userEmail = get(this.config, 'user.email', null);
26
32
  const isDemoUser =
27
33
  userEmail === 'VineaNovaDemoAdmin.com' && serviceType !== 'login';
28
- let isTest = get(this.config, 'environment.isTest', null);
29
- const isLocalHost = get(this.config, 'environment.isLocalHost', null);
30
- isTest = isTest || isLocalHost;
31
34
 
32
35
  if (serviceType === 'mock' || isDemoUser) {
33
36
  apiUrl = mockApiUrl;
34
37
  } else if (serviceType === 'login') {
35
- apiUrl = isTest
38
+ apiUrl = this.isTestEnv()
36
39
  ? process.env.REACT_APP_COMMON_USER_API
37
40
  : process.env.REACT_APP_PROD_COMMON_USER_API;
38
41
  } else {
39
- apiUrl = isTest
42
+ apiUrl = this.isTestEnv()
40
43
  ? process.env.REACT_APP_CORE_API
41
44
  : process.env.REACT_APP_PROD_CORE_API;
42
45
  }
@@ -66,7 +69,7 @@ class ServiceConfigClass {
66
69
  request(options, serviceType) {
67
70
  // logger.debug('currentConfig', this.config);
68
71
  logger.debug("serviceType", { serviceType });
69
- const isTest = get(this.config, 'environment.isTest', null);
72
+ const isTest = this.isTestEnv();
70
73
  const { accessToken, orgDetails } = this.config.user;
71
74
  if (isEmpty(accessToken) || isNil(accessToken) || isEmpty(orgDetails)) {
72
75
  throw new Error("serviceConfig -> No Access token available");
@@ -87,7 +90,13 @@ class ServiceConfigClass {
87
90
  const appCode = isTest
88
91
  ? process.env.REACT_APP_FUNCTION_CODE
89
92
  : process.env.REACT_APP_PROD_FUNCTION_CODE;
90
- config.params.code = appCode;
93
+ if (config.params) {
94
+ config.params.code = appCode;
95
+ } else {
96
+ config.params = {
97
+ code: appCode,
98
+ };
99
+ }
91
100
  config.headers.Authorization = `Bearer ${accessToken}`;
92
101
  config.headers["x-orgname"] = displayName;
93
102
  config.headers["x-tid"] = id;