@navservice/core 1.69.0 → 1.70.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.
@@ -1,3 +1,2 @@
1
- export { default as config_env_core } from "./config_env";
2
1
  export { default as TypesCore } from "./types";
3
2
  export { default as utils } from "./utils";
package/build/es/index.js CHANGED
@@ -1,16 +1,6 @@
1
1
  import v4 from "zod/v4";
2
2
  import axios from "axios";
3
3
  import { useLayoutEffect, useState } from "react";
4
- class config_env {
5
- static SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL;
6
- static init(config) {
7
- config_env.SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL = config.SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL;
8
- }
9
- static get PUBLIC_BASE_URL_BACKEND_PRINCIPAL() {
10
- return this.SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL?.trim();
11
- }
12
- }
13
- const src_config_env = config_env;
14
4
  (function(TypeControllerUsuario) {
15
5
  TypeControllerUsuario.AppEnum = [
16
6
  "service-usuario",
@@ -94,8 +84,8 @@ var _usuario_TypeControllerUsuario;
94
84
  c: v4.custom().optional()
95
85
  });
96
86
  })(TypeControllerResponse.C || (TypeControllerResponse.C = {}));
97
- (function(Error) {
98
- Error.InputSchema = v4.object({
87
+ (function(Error1) {
88
+ Error1.InputSchema = v4.object({
99
89
  message: v4.string().optional(),
100
90
  results: v4.union([
101
91
  v4.array(v4.unknown()),
@@ -164,9 +154,19 @@ const _api_api = class _api {
164
154
  static servidor_pricipal = class {
165
155
  static get #axios() {
166
156
  return axios.create({
167
- baseURL: src_config_env.PUBLIC_BASE_URL_BACKEND_PRINCIPAL
157
+ baseURL: this.resolve_base_url()
168
158
  });
169
159
  }
160
+ static resolve_base_url() {
161
+ if ("undefined" == typeof window) throw new Error("resolveApiBaseURL must run in browser");
162
+ const { hostname } = window.location;
163
+ if ("localhost" === hostname || hostname.startsWith("localhost")) return "http://localhost:8787";
164
+ const isNavSoftware = hostname.includes("navsoftware");
165
+ const isSandbox = hostname.includes("sandbox");
166
+ if (isNavSoftware && isSandbox) return "https://api-sandbox.navsoftware.com.br";
167
+ if (isNavSoftware) return "https://api.navsoftware.com.br";
168
+ throw new Error(`Ambiente não reconhecido: ${hostname}`);
169
+ }
170
170
  static async post({ url, data, setToken = true }) {
171
171
  return await this.#axios.post(url, data, _api.headers({
172
172
  setToken: setToken
@@ -636,4 +636,4 @@ const utils = {
636
636
  hooks: utils_hooks
637
637
  };
638
638
  const src_utils = utils;
639
- export { types as TypesCore, src_config_env as config_env_core, src_utils as utils };
639
+ export { types as TypesCore, src_utils as utils };
@@ -4,6 +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
8
  post({ url, data, setToken }: {
8
9
  url: string;
9
10
  data: any;
@@ -5,6 +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
9
  post({ url, data, setToken }: {
9
10
  url: string;
10
11
  data: any;
@@ -51,23 +51,10 @@ __webpack_require__.r(__webpack_exports__);
51
51
 
52
52
  // EXPORTS
53
53
  __webpack_require__.d(__webpack_exports__, {
54
- config_env_core: () => (/* reexport */ src_config_env),
55
54
  TypesCore: () => (/* reexport */ types),
56
55
  utils: () => (/* reexport */ src_utils)
57
56
  });
58
57
 
59
- ;// CONCATENATED MODULE: ./src/config_env/index.ts
60
- class config_env {
61
- static SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL;
62
- static init(config) {
63
- config_env.SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL = config.SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL;
64
- }
65
- static get PUBLIC_BASE_URL_BACKEND_PRINCIPAL() {
66
- return this.SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL?.trim();
67
- }
68
- }
69
- /* export default */ const src_config_env = (config_env);
70
-
71
58
  ;// CONCATENATED MODULE: external "zod/v4"
72
59
  const v4_namespaceObject = require("zod/v4");
73
60
  var v4_default = /*#__PURE__*/__webpack_require__.n(v4_namespaceObject);
@@ -240,14 +227,31 @@ const _session_storage = class _session_storage {
240
227
  ;// CONCATENATED MODULE: ./src/utils/_api.ts
241
228
 
242
229
 
243
-
244
230
  const _api_api = class _api {
245
231
  static servidor_pricipal = class servidor_pricipal {
246
232
  static get #axios() {
247
233
  return external_axios_default().create({
248
- baseURL: src_config_env.PUBLIC_BASE_URL_BACKEND_PRINCIPAL
234
+ baseURL: this.resolve_base_url()
249
235
  });
250
236
  }
237
+ 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
+ if (hostname === "localhost" || hostname.startsWith("localhost")) {
243
+ return "http://localhost:8787";
244
+ }
245
+ const isNavSoftware = hostname.includes("navsoftware");
246
+ const isSandbox = hostname.includes("sandbox");
247
+ if (isNavSoftware && isSandbox) {
248
+ return "https://api-sandbox.navsoftware.com.br";
249
+ }
250
+ if (isNavSoftware) {
251
+ return "https://api.navsoftware.com.br";
252
+ }
253
+ throw new Error(`Ambiente não reconhecido: ${hostname}`);
254
+ }
251
255
  static async post({ url, data, setToken = true }) {
252
256
  return await this.#axios.post(url, data, _api.headers({
253
257
  setToken: setToken
@@ -825,12 +829,10 @@ const utils = {
825
829
 
826
830
 
827
831
 
828
-
829
832
  exports.TypesCore = __webpack_exports__.TypesCore;
830
- exports.config_env_core = __webpack_exports__.config_env_core;
831
833
  exports.utils = __webpack_exports__.utils;
832
834
  for(var __rspack_i in __webpack_exports__) {
833
- if(["TypesCore","config_env_core","utils"].indexOf(__rspack_i) === -1) {
835
+ if(["TypesCore","utils"].indexOf(__rspack_i) === -1) {
834
836
  exports[__rspack_i] = __webpack_exports__[__rspack_i];
835
837
  }
836
838
  }
@@ -1,3 +1,2 @@
1
- export { default as config_env_core } from "./config_env";
2
1
  export { default as TypesCore } from "./types";
3
2
  export { default as utils } from "./utils";
@@ -4,6 +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
8
  post({ url, data, setToken }: {
8
9
  url: string;
9
10
  data: any;
@@ -5,6 +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
9
  post({ url, data, setToken }: {
9
10
  url: string;
10
11
  data: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navservice/core",
3
- "version": "1.69.0",
3
+ "version": "1.70.0",
4
4
  "description": "Service core de todos os micro serviços",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,9 +0,0 @@
1
- interface TypesConfigEnv {
2
- SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL: string;
3
- }
4
- declare class config_env {
5
- private static SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL;
6
- static init(config: TypesConfigEnv): void;
7
- static get PUBLIC_BASE_URL_BACKEND_PRINCIPAL(): string;
8
- }
9
- export default config_env;
@@ -1,9 +0,0 @@
1
- interface TypesConfigEnv {
2
- SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL: string;
3
- }
4
- declare class config_env {
5
- private static SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL;
6
- static init(config: TypesConfigEnv): void;
7
- static get PUBLIC_BASE_URL_BACKEND_PRINCIPAL(): string;
8
- }
9
- export default config_env;