@navservice/core 1.69.0 → 1.71.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.d.ts +0 -1
- package/build/es/index.js +29 -15
- package/build/es/utils/_api.d.ts +1 -0
- package/build/es/utils/_environment.d.ts +6 -0
- package/build/es/utils/index.d.ts +6 -0
- package/build/lib/index.cjs +49 -19
- package/build/lib/index.d.ts +0 -1
- package/build/lib/utils/_api.d.ts +1 -0
- package/build/lib/utils/_environment.d.ts +6 -0
- package/build/lib/utils/index.d.ts +6 -0
- package/package.json +1 -1
- package/build/es/config_env/index.d.ts +0 -9
- package/build/lib/config_env/index.d.ts +0 -9
package/build/es/index.d.ts
CHANGED
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(
|
|
98
|
-
|
|
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,23 @@ const _api_api = class _api {
|
|
|
164
154
|
static servidor_pricipal = class {
|
|
165
155
|
static get #axios() {
|
|
166
156
|
return axios.create({
|
|
167
|
-
baseURL:
|
|
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
|
+
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}`);
|
|
173
|
+
}
|
|
170
174
|
static async post({ url, data, setToken = true }) {
|
|
171
175
|
return await this.#axios.post(url, data, _api.headers({
|
|
172
176
|
setToken: setToken
|
|
@@ -624,6 +628,15 @@ class _hooks {
|
|
|
624
628
|
}
|
|
625
629
|
}
|
|
626
630
|
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;
|
|
627
640
|
const utils = {
|
|
628
641
|
api: utils_api,
|
|
629
642
|
data: utils_data,
|
|
@@ -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
|
-
export { types as TypesCore,
|
|
653
|
+
export { types as TypesCore, src_utils as utils };
|
package/build/es/utils/_api.d.ts
CHANGED
|
@@ -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;
|
|
@@ -152,5 +153,10 @@ declare const utils: {
|
|
|
152
153
|
use_is_mobile(): boolean;
|
|
153
154
|
use_dark_mode(): void;
|
|
154
155
|
};
|
|
156
|
+
environment: {
|
|
157
|
+
new (): {};
|
|
158
|
+
set(props: "LOCALHOST" | "PRODUCAO" | "SANDBOX"): void;
|
|
159
|
+
get get(): any;
|
|
160
|
+
};
|
|
155
161
|
};
|
|
156
162
|
export default utils;
|
package/build/lib/index.cjs
CHANGED
|
@@ -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,41 @@ 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:
|
|
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
|
+
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";
|
|
262
|
+
}
|
|
263
|
+
throw new Error(`Ambiente não reconhecido: ${hostname}`);
|
|
264
|
+
}
|
|
251
265
|
static async post({ url, data, setToken = true }) {
|
|
252
266
|
return await this.#axios.post(url, data, _api.headers({
|
|
253
267
|
setToken: setToken
|
|
@@ -798,6 +812,22 @@ class _hooks {
|
|
|
798
812
|
}
|
|
799
813
|
/* export default */ const utils_hooks = (new _hooks);
|
|
800
814
|
|
|
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
|
+
|
|
801
831
|
;// CONCATENATED MODULE: ./src/utils/index.ts
|
|
802
832
|
|
|
803
833
|
|
|
@@ -808,6 +838,7 @@ class _hooks {
|
|
|
808
838
|
|
|
809
839
|
|
|
810
840
|
|
|
841
|
+
|
|
811
842
|
const utils = {
|
|
812
843
|
api: utils_api,
|
|
813
844
|
data: utils_data,
|
|
@@ -817,7 +848,8 @@ const utils = {
|
|
|
817
848
|
update_context: utils_update_context,
|
|
818
849
|
session_sorage: utils_session_storage,
|
|
819
850
|
sistema: utils_sistema,
|
|
820
|
-
hooks: utils_hooks
|
|
851
|
+
hooks: utils_hooks,
|
|
852
|
+
environment: utils_environment
|
|
821
853
|
};
|
|
822
854
|
/* export default */ const src_utils = (utils);
|
|
823
855
|
|
|
@@ -825,12 +857,10 @@ const utils = {
|
|
|
825
857
|
|
|
826
858
|
|
|
827
859
|
|
|
828
|
-
|
|
829
860
|
exports.TypesCore = __webpack_exports__.TypesCore;
|
|
830
|
-
exports.config_env_core = __webpack_exports__.config_env_core;
|
|
831
861
|
exports.utils = __webpack_exports__.utils;
|
|
832
862
|
for(var __rspack_i in __webpack_exports__) {
|
|
833
|
-
if(["TypesCore","
|
|
863
|
+
if(["TypesCore","utils"].indexOf(__rspack_i) === -1) {
|
|
834
864
|
exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
835
865
|
}
|
|
836
866
|
}
|
package/build/lib/index.d.ts
CHANGED
|
@@ -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;
|
|
@@ -152,5 +153,10 @@ declare const utils: {
|
|
|
152
153
|
use_is_mobile(): boolean;
|
|
153
154
|
use_dark_mode(): void;
|
|
154
155
|
};
|
|
156
|
+
environment: {
|
|
157
|
+
new (): {};
|
|
158
|
+
set(props: "LOCALHOST" | "PRODUCAO" | "SANDBOX"): void;
|
|
159
|
+
get get(): any;
|
|
160
|
+
};
|
|
155
161
|
};
|
|
156
162
|
export default utils;
|
package/package.json
CHANGED
|
@@ -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;
|