@navservice/core 1.70.0 → 1.72.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/build/es/index.js CHANGED
@@ -150,6 +150,15 @@ const _session_storage = class {
150
150
  }
151
151
  };
152
152
  const utils_session_storage = _session_storage;
153
+ const _environment = class {
154
+ static set(props) {
155
+ window.sessionStorage.setItem("ENVIRONMENT", props);
156
+ }
157
+ static get get() {
158
+ return window.sessionStorage.get("ENVIRONMENT");
159
+ }
160
+ };
161
+ const utils_environment = _environment;
153
162
  const _api_api = class _api {
154
163
  static servidor_pricipal = class {
155
164
  static get #axios() {
@@ -160,6 +169,10 @@ const _api_api = class _api {
160
169
  static resolve_base_url() {
161
170
  if ("undefined" == typeof window) throw new Error("resolveApiBaseURL must run in browser");
162
171
  const { hostname } = window.location;
172
+ const apiOverride = utils_environment.get;
173
+ if ("SANDBOX" === apiOverride) return "https://api-sandbox.navsoftware.com.br";
174
+ if ("PRODUCAO" === apiOverride) return "https://api.navsoftware.com.br";
175
+ if ("LOCALHOST" === apiOverride) return "http://localhost:8787";
163
176
  if ("localhost" === hostname || hostname.startsWith("localhost")) return "http://localhost:8787";
164
177
  const isNavSoftware = hostname.includes("navsoftware");
165
178
  const isSandbox = hostname.includes("sandbox");
@@ -633,7 +646,8 @@ const utils = {
633
646
  update_context: utils_update_context,
634
647
  session_sorage: utils_session_storage,
635
648
  sistema: utils_sistema,
636
- hooks: utils_hooks
649
+ hooks: utils_hooks,
650
+ environment: utils_environment
637
651
  };
638
652
  const src_utils = utils;
639
653
  export { types as TypesCore, src_utils as utils };
@@ -0,0 +1,7 @@
1
+ type Envronment = "LOCALHOST" | "PRODUCAO" | "SANDBOX";
2
+ declare const _environment: {
3
+ new (): {};
4
+ set(props: Envronment): void;
5
+ get get(): Envronment;
6
+ };
7
+ export default _environment;
@@ -153,5 +153,10 @@ declare const utils: {
153
153
  use_is_mobile(): boolean;
154
154
  use_dark_mode(): void;
155
155
  };
156
+ environment: {
157
+ new (): {};
158
+ set(props: "PRODUCAO" | "SANDBOX" | "LOCALHOST"): void;
159
+ get get(): "PRODUCAO" | "SANDBOX" | "LOCALHOST";
160
+ };
156
161
  };
157
162
  export default utils;
@@ -224,9 +224,26 @@ const _session_storage = class _session_storage {
224
224
  };
225
225
  /* export default */ const utils_session_storage = (_session_storage);
226
226
 
227
+ ;// CONCATENATED MODULE: ./src/utils/_environment.ts
228
+ //BIBLIOTECAS
229
+ //HELPERS
230
+ //BANCO DE DADOS
231
+ //SERVICES
232
+ const _environment = class _environment {
233
+ static set(props) {
234
+ window.sessionStorage.setItem("ENVIRONMENT", props);
235
+ return;
236
+ }
237
+ static get get() {
238
+ return window.sessionStorage.get("ENVIRONMENT");
239
+ }
240
+ };
241
+ /* export default */ const utils_environment = (_environment);
242
+
227
243
  ;// CONCATENATED MODULE: ./src/utils/_api.ts
228
244
 
229
245
 
246
+
230
247
  const _api_api = class _api {
231
248
  static servidor_pricipal = class servidor_pricipal {
232
249
  static get #axios() {
@@ -239,6 +256,16 @@ const _api_api = class _api {
239
256
  throw new Error("resolveApiBaseURL must run in browser");
240
257
  }
241
258
  const { hostname } = window.location;
259
+ const apiOverride = utils_environment.get;
260
+ if (apiOverride === "SANDBOX") {
261
+ return "https://api-sandbox.navsoftware.com.br";
262
+ }
263
+ if (apiOverride === "PRODUCAO") {
264
+ return "https://api.navsoftware.com.br";
265
+ }
266
+ if (apiOverride === "LOCALHOST") {
267
+ return "http://localhost:8787";
268
+ }
242
269
  if (hostname === "localhost" || hostname.startsWith("localhost")) {
243
270
  return "http://localhost:8787";
244
271
  }
@@ -812,6 +839,7 @@ class _hooks {
812
839
 
813
840
 
814
841
 
842
+
815
843
  const utils = {
816
844
  api: utils_api,
817
845
  data: utils_data,
@@ -821,7 +849,8 @@ const utils = {
821
849
  update_context: utils_update_context,
822
850
  session_sorage: utils_session_storage,
823
851
  sistema: utils_sistema,
824
- hooks: utils_hooks
852
+ hooks: utils_hooks,
853
+ environment: utils_environment
825
854
  };
826
855
  /* export default */ const src_utils = (utils);
827
856
 
@@ -0,0 +1,7 @@
1
+ type Envronment = "LOCALHOST" | "PRODUCAO" | "SANDBOX";
2
+ declare const _environment: {
3
+ new (): {};
4
+ set(props: Envronment): void;
5
+ get get(): Envronment;
6
+ };
7
+ export default _environment;
@@ -153,5 +153,10 @@ declare const utils: {
153
153
  use_is_mobile(): boolean;
154
154
  use_dark_mode(): void;
155
155
  };
156
+ environment: {
157
+ new (): {};
158
+ set(props: "PRODUCAO" | "SANDBOX" | "LOCALHOST"): void;
159
+ get get(): "PRODUCAO" | "SANDBOX" | "LOCALHOST";
160
+ };
156
161
  };
157
162
  export default utils;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navservice/core",
3
- "version": "1.70.0",
3
+ "version": "1.72.0",
4
4
  "description": "Service core de todos os micro serviços",
5
5
  "type": "module",
6
6
  "exports": {