@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 +24 -21
- package/build/es/utils/_api.d.ts +1 -1
- package/build/es/utils/_environment.d.ts +3 -2
- package/build/es/utils/index.d.ts +3 -3
- package/build/lib/index.cjs +45 -41
- package/build/lib/utils/_api.d.ts +1 -1
- package/build/lib/utils/_environment.d.ts +3 -2
- package/build/lib/utils/index.d.ts +3 -3
- package/package.json +1 -1
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
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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,
|
package/build/es/utils/_api.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
type Envronment = "LOCALHOST" | "PRODUCAO" | "SANDBOX";
|
|
1
2
|
declare const _environment: {
|
|
2
3
|
new (): {};
|
|
3
|
-
set(props:
|
|
4
|
-
get get():
|
|
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: "
|
|
159
|
-
get get():
|
|
158
|
+
set(props: "PRODUCAO" | "SANDBOX" | "LOCALHOST"): void;
|
|
159
|
+
get get(): "PRODUCAO" | "SANDBOX" | "LOCALHOST";
|
|
160
160
|
};
|
|
161
161
|
};
|
|
162
162
|
export default utils;
|
package/build/lib/index.cjs
CHANGED
|
@@ -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
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
type Envronment = "LOCALHOST" | "PRODUCAO" | "SANDBOX";
|
|
1
2
|
declare const _environment: {
|
|
2
3
|
new (): {};
|
|
3
|
-
set(props:
|
|
4
|
-
get get():
|
|
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: "
|
|
159
|
-
get get():
|
|
158
|
+
set(props: "PRODUCAO" | "SANDBOX" | "LOCALHOST"): void;
|
|
159
|
+
get get(): "PRODUCAO" | "SANDBOX" | "LOCALHOST";
|
|
160
160
|
};
|
|
161
161
|
};
|
|
162
162
|
export default utils;
|