@navservice/core 1.71.0 → 1.73.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() {
@@ -158,18 +167,21 @@ const _api_api = class _api {
158
167
  });
159
168
  }
160
169
  static resolve_base_url() {
161
- if ("undefined" == typeof window) throw new Error("resolveApiBaseURL must run in browser");
162
- const { hostname } = window.location;
163
- const apiOverride = window.sessionStorage.get("API_TARGET");
164
- if ("sandbox" === apiOverride) return "https://api-sandbox.navsoftware.com.br";
165
- if ("prod" === apiOverride) return "https://api.navsoftware.com.br";
166
- if ("local" === apiOverride) return "http://localhost:8787";
167
- if ("localhost" === hostname || hostname.startsWith("localhost")) return "http://localhost:8787";
168
- const isNavSoftware = hostname.includes("navsoftware");
169
- const isSandbox = hostname.includes("sandbox");
170
- if (isNavSoftware && isSandbox) return "https://api-sandbox.navsoftware.com.br";
171
- if (isNavSoftware) return "https://api.navsoftware.com.br";
172
- throw new Error(`Ambiente não reconhecido: ${hostname}`);
170
+ try {
171
+ if ("undefined" == typeof window) throw new Error("resolveApiBaseURL must run in browser");
172
+ const { hostname } = window.location;
173
+ const apiOverride = utils_environment.get;
174
+ if ("SANDBOX" === apiOverride) return "https://api-sandbox.navsoftware.com.br";
175
+ if ("PRODUCAO" === apiOverride) return "https://api.navsoftware.com.br";
176
+ if ("LOCALHOST" === apiOverride) return "http://localhost:8787";
177
+ if ("localhost" === hostname || hostname.startsWith("localhost")) return "http://localhost:8787";
178
+ const isNavSoftware = hostname.includes("navsoftware");
179
+ const isSandbox = hostname.includes("sandbox");
180
+ if (isNavSoftware && isSandbox) return "https://api-sandbox.navsoftware.com.br";
181
+ if (isNavSoftware) return "https://api.navsoftware.com.br";
182
+ } catch (error) {
183
+ throw new Error(`Ambiente não reconhecido: ${error}`);
184
+ }
173
185
  }
174
186
  static async post({ url, data, setToken = true }) {
175
187
  return await this.#axios.post(url, data, _api.headers({
@@ -628,15 +640,6 @@ class _hooks {
628
640
  }
629
641
  }
630
642
  const utils_hooks = new _hooks;
631
- const _environment = class {
632
- static set(props) {
633
- window.sessionStorage.setItem("ENVIRONMENT", props);
634
- }
635
- static get get() {
636
- return window.sessionStorage.get("ENVIRONMENT");
637
- }
638
- };
639
- const utils_environment = _environment;
640
643
  const utils = {
641
644
  api: utils_api,
642
645
  data: utils_data,
@@ -4,7 +4,7 @@ declare const _api: {
4
4
  servidor_pricipal: {
5
5
  new (): {};
6
6
  get "__#private@#axios"(): import("axios").AxiosInstance;
7
- resolve_base_url(): string;
7
+ resolve_base_url(): string | any;
8
8
  post({ url, data, setToken }: {
9
9
  url: string;
10
10
  data: any;
@@ -1,6 +1,7 @@
1
+ type Envronment = "LOCALHOST" | "PRODUCAO" | "SANDBOX";
1
2
  declare const _environment: {
2
3
  new (): {};
3
- set(props: "LOCALHOST" | "PRODUCAO" | "SANDBOX"): void;
4
- get get(): any;
4
+ set(props: Envronment): void;
5
+ get get(): Envronment;
5
6
  };
6
7
  export default _environment;
@@ -5,7 +5,7 @@ declare const utils: {
5
5
  servidor_pricipal: {
6
6
  new (): {};
7
7
  get "__#private@#axios"(): import("axios").AxiosInstance;
8
- resolve_base_url(): string;
8
+ resolve_base_url(): string | any;
9
9
  post({ url, data, setToken }: {
10
10
  url: string;
11
11
  data: any;
@@ -155,8 +155,8 @@ declare const utils: {
155
155
  };
156
156
  environment: {
157
157
  new (): {};
158
- set(props: "LOCALHOST" | "PRODUCAO" | "SANDBOX"): void;
159
- get get(): any;
158
+ set(props: "PRODUCAO" | "SANDBOX" | "LOCALHOST"): void;
159
+ get get(): "PRODUCAO" | "SANDBOX" | "LOCALHOST";
160
160
  };
161
161
  };
162
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() {
@@ -235,32 +252,35 @@ const _api_api = class _api {
235
252
  });
236
253
  }
237
254
  static resolve_base_url() {
238
- if (typeof window === "undefined") {
239
- throw new Error("resolveApiBaseURL must run in browser");
240
- }
241
- const { hostname } = window.location;
242
- const apiOverride = window.sessionStorage.get("API_TARGET");
243
- if (apiOverride === "sandbox") {
244
- return "https://api-sandbox.navsoftware.com.br";
245
- }
246
- if (apiOverride === "prod") {
247
- return "https://api.navsoftware.com.br";
248
- }
249
- if (apiOverride === "local") {
250
- return "http://localhost:8787";
251
- }
252
- if (hostname === "localhost" || hostname.startsWith("localhost")) {
253
- return "http://localhost:8787";
254
- }
255
- const isNavSoftware = hostname.includes("navsoftware");
256
- const isSandbox = hostname.includes("sandbox");
257
- if (isNavSoftware && isSandbox) {
258
- return "https://api-sandbox.navsoftware.com.br";
259
- }
260
- if (isNavSoftware) {
261
- return "https://api.navsoftware.com.br";
255
+ try {
256
+ if (typeof window === "undefined") {
257
+ throw new Error("resolveApiBaseURL must run in browser");
258
+ }
259
+ const { hostname } = window.location;
260
+ const apiOverride = utils_environment.get;
261
+ if (apiOverride === "SANDBOX") {
262
+ return "https://api-sandbox.navsoftware.com.br";
263
+ }
264
+ if (apiOverride === "PRODUCAO") {
265
+ return "https://api.navsoftware.com.br";
266
+ }
267
+ if (apiOverride === "LOCALHOST") {
268
+ return "http://localhost:8787";
269
+ }
270
+ if (hostname === "localhost" || hostname.startsWith("localhost")) {
271
+ return "http://localhost:8787";
272
+ }
273
+ const isNavSoftware = hostname.includes("navsoftware");
274
+ const isSandbox = hostname.includes("sandbox");
275
+ if (isNavSoftware && isSandbox) {
276
+ return "https://api-sandbox.navsoftware.com.br";
277
+ }
278
+ if (isNavSoftware) {
279
+ return "https://api.navsoftware.com.br";
280
+ }
281
+ } catch (error) {
282
+ throw new Error(`Ambiente não reconhecido: ${error}`);
262
283
  }
263
- throw new Error(`Ambiente não reconhecido: ${hostname}`);
264
284
  }
265
285
  static async post({ url, data, setToken = true }) {
266
286
  return await this.#axios.post(url, data, _api.headers({
@@ -812,22 +832,6 @@ class _hooks {
812
832
  }
813
833
  /* export default */ const utils_hooks = (new _hooks);
814
834
 
815
- ;// CONCATENATED MODULE: ./src/utils/_environment.ts
816
- //BIBLIOTECAS
817
- //HELPERS
818
- //BANCO DE DADOS
819
- //SERVICES
820
- const _environment = class _environment {
821
- static set(props) {
822
- window.sessionStorage.setItem("ENVIRONMENT", props);
823
- return;
824
- }
825
- static get get() {
826
- return window.sessionStorage.get("ENVIRONMENT");
827
- }
828
- };
829
- /* export default */ const utils_environment = (_environment);
830
-
831
835
  ;// CONCATENATED MODULE: ./src/utils/index.ts
832
836
 
833
837
 
@@ -4,7 +4,7 @@ declare const _api: {
4
4
  servidor_pricipal: {
5
5
  new (): {};
6
6
  get "__#private@#axios"(): import("axios").AxiosInstance;
7
- resolve_base_url(): string;
7
+ resolve_base_url(): string | any;
8
8
  post({ url, data, setToken }: {
9
9
  url: string;
10
10
  data: any;
@@ -1,6 +1,7 @@
1
+ type Envronment = "LOCALHOST" | "PRODUCAO" | "SANDBOX";
1
2
  declare const _environment: {
2
3
  new (): {};
3
- set(props: "LOCALHOST" | "PRODUCAO" | "SANDBOX"): void;
4
- get get(): any;
4
+ set(props: Envronment): void;
5
+ get get(): Envronment;
5
6
  };
6
7
  export default _environment;
@@ -5,7 +5,7 @@ declare const utils: {
5
5
  servidor_pricipal: {
6
6
  new (): {};
7
7
  get "__#private@#axios"(): import("axios").AxiosInstance;
8
- resolve_base_url(): string;
8
+ resolve_base_url(): string | any;
9
9
  post({ url, data, setToken }: {
10
10
  url: string;
11
11
  data: any;
@@ -155,8 +155,8 @@ declare const utils: {
155
155
  };
156
156
  environment: {
157
157
  new (): {};
158
- set(props: "LOCALHOST" | "PRODUCAO" | "SANDBOX"): void;
159
- get get(): any;
158
+ set(props: "PRODUCAO" | "SANDBOX" | "LOCALHOST"): void;
159
+ get get(): "PRODUCAO" | "SANDBOX" | "LOCALHOST";
160
160
  };
161
161
  };
162
162
  export default utils;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navservice/core",
3
- "version": "1.71.0",
3
+ "version": "1.73.0",
4
4
  "description": "Service core de todos os micro serviços",
5
5
  "type": "module",
6
6
  "exports": {