@navservice/core 1.77.0 → 1.80.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 +21 -36
- package/build/es/utils/_api.d.ts +10 -6
- package/build/es/utils/index.d.ts +9 -6
- package/build/lib/index.cjs +28 -54
- package/build/lib/utils/_api.d.ts +10 -6
- package/build/lib/utils/index.d.ts +9 -6
- package/package.json +1 -1
package/build/es/index.js
CHANGED
|
@@ -150,62 +150,38 @@ 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.getItem("ENVIRONMENT");
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
const utils_environment = _environment;
|
|
162
153
|
const _api_api = class _api {
|
|
163
154
|
static servidor_pricipal = class {
|
|
164
|
-
static
|
|
155
|
+
static axios(key) {
|
|
156
|
+
const baseURL = sessionStorage.getItem(key);
|
|
157
|
+
if (!baseURL) throw new Error("API não inicializada no service core");
|
|
165
158
|
return axios.create({
|
|
166
|
-
baseURL
|
|
159
|
+
baseURL
|
|
167
160
|
});
|
|
168
161
|
}
|
|
169
|
-
static
|
|
170
|
-
|
|
171
|
-
if ("undefined" == typeof window) throw new Error("resolveApiBaseURL must run in browser");
|
|
172
|
-
const { origin, hostname } = window.location;
|
|
173
|
-
if (hostname.includes("navsoftware")) {
|
|
174
|
-
const apiOrigin = origin.replace(/^https?:\/\/app/, (match)=>match.replace("app", "api"));
|
|
175
|
-
return apiOrigin;
|
|
176
|
-
}
|
|
177
|
-
const apiOverride = utils_environment.get;
|
|
178
|
-
if ("SANDBOX" === apiOverride) return "https://api-sandbox.navsoftware.com.br";
|
|
179
|
-
if ("PRODUCAO" === apiOverride) return "https://api.navsoftware.com.br";
|
|
180
|
-
if ("LOCALHOST" === apiOverride) return "http://localhost:8787";
|
|
181
|
-
if ("localhost" === hostname || hostname.startsWith("localhost")) return "http://localhost:8787";
|
|
182
|
-
} catch (error) {
|
|
183
|
-
throw new Error(`Ambiente não reconhecido: ${error}`);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
static async post({ url, data, setToken = true }) {
|
|
187
|
-
return await this.#axios.post(url, data, _api.headers({
|
|
162
|
+
static async post({ baseURLKey, url, data, setToken = true }) {
|
|
163
|
+
return await this.axios(baseURLKey).post(url, data, _api.headers({
|
|
188
164
|
setToken: setToken
|
|
189
165
|
}));
|
|
190
166
|
}
|
|
191
|
-
static async get({ url, params, setToken = true }) {
|
|
167
|
+
static async get({ baseURLKey, url, params, setToken = true }) {
|
|
192
168
|
const queryParams = new URLSearchParams();
|
|
193
169
|
if (params) Object.entries(params).forEach(([key, value])=>{
|
|
194
170
|
if (null != value) queryParams.append(key, value);
|
|
195
171
|
});
|
|
196
172
|
const queryString = queryParams.toString();
|
|
197
173
|
const fullUrl = queryString ? `${url}?${queryString}` : url;
|
|
198
|
-
return await this
|
|
174
|
+
return await this.axios(baseURLKey).get(fullUrl, _api.headers({
|
|
199
175
|
setToken: setToken
|
|
200
176
|
}));
|
|
201
177
|
}
|
|
202
|
-
static async patch({ url, data, setToken = true }) {
|
|
203
|
-
return await this
|
|
178
|
+
static async patch({ baseURLKey, url, data, setToken = true }) {
|
|
179
|
+
return await this.axios(baseURLKey).patch(url, data, _api.headers({
|
|
204
180
|
setToken: setToken
|
|
205
181
|
}));
|
|
206
182
|
}
|
|
207
|
-
static async delete({ url }) {
|
|
208
|
-
return await this
|
|
183
|
+
static async delete({ baseURLKey, url }) {
|
|
184
|
+
return await this.axios(baseURLKey).delete(url);
|
|
209
185
|
}
|
|
210
186
|
};
|
|
211
187
|
static headers({ setToken = true }) {
|
|
@@ -640,6 +616,15 @@ class _hooks {
|
|
|
640
616
|
}
|
|
641
617
|
}
|
|
642
618
|
const utils_hooks = new _hooks;
|
|
619
|
+
const _environment = class {
|
|
620
|
+
static set(props) {
|
|
621
|
+
window.sessionStorage.setItem("ENVIRONMENT", props);
|
|
622
|
+
}
|
|
623
|
+
static get get() {
|
|
624
|
+
return window.sessionStorage.getItem("ENVIRONMENT");
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
const utils_environment = _environment;
|
|
643
628
|
const utils = {
|
|
644
629
|
api: utils_api,
|
|
645
630
|
data: utils_data,
|
package/build/es/utils/_api.d.ts
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
import { AxiosResponse } from "axios";
|
|
2
|
+
type BaseUrl = "PUBLIC_BASE_URL_FINANCEIRO" | "PUBLIC_BASE_URL_USUARIO" | "PUBLIC_BASE_URL_BUCKET";
|
|
2
3
|
declare const _api: {
|
|
3
4
|
new (): {};
|
|
4
5
|
servidor_pricipal: {
|
|
5
6
|
new (): {};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
axios(key: BaseUrl): import("axios").AxiosInstance;
|
|
8
|
+
post({ baseURLKey, url, data, setToken }: {
|
|
9
|
+
baseURLKey: BaseUrl;
|
|
9
10
|
url: string;
|
|
10
11
|
data: any;
|
|
11
12
|
setToken?: boolean;
|
|
12
13
|
}): Promise<AxiosResponse<any, any, {}>>;
|
|
13
|
-
get({ url, params, setToken }: {
|
|
14
|
+
get({ baseURLKey, url, params, setToken }: {
|
|
15
|
+
baseURLKey: BaseUrl;
|
|
14
16
|
url: string;
|
|
15
17
|
params?: any;
|
|
16
18
|
setToken?: boolean;
|
|
17
19
|
}): Promise<AxiosResponse<any, any, {}>>;
|
|
18
|
-
patch({ url, data, setToken }: {
|
|
20
|
+
patch({ baseURLKey, url, data, setToken }: {
|
|
21
|
+
baseURLKey: BaseUrl;
|
|
19
22
|
url: string;
|
|
20
23
|
data: any;
|
|
21
24
|
setToken?: boolean;
|
|
22
25
|
}): Promise<AxiosResponse<any, any, {}>>;
|
|
23
|
-
delete({ url }: {
|
|
26
|
+
delete({ baseURLKey, url }: {
|
|
27
|
+
baseURLKey: BaseUrl;
|
|
24
28
|
url: string;
|
|
25
29
|
setToken?: boolean;
|
|
26
30
|
}): Promise<AxiosResponse<any, any, {}>>;
|
|
@@ -4,24 +4,27 @@ declare const utils: {
|
|
|
4
4
|
new (): {};
|
|
5
5
|
servidor_pricipal: {
|
|
6
6
|
new (): {};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
axios(key: "PUBLIC_BASE_URL_FINANCEIRO" | "PUBLIC_BASE_URL_USUARIO" | "PUBLIC_BASE_URL_BUCKET"): import("axios").AxiosInstance;
|
|
8
|
+
post({ baseURLKey, url, data, setToken }: {
|
|
9
|
+
baseURLKey: "PUBLIC_BASE_URL_FINANCEIRO" | "PUBLIC_BASE_URL_USUARIO" | "PUBLIC_BASE_URL_BUCKET";
|
|
10
10
|
url: string;
|
|
11
11
|
data: any;
|
|
12
12
|
setToken?: boolean;
|
|
13
13
|
}): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
14
|
-
get({ url, params, setToken }: {
|
|
14
|
+
get({ baseURLKey, url, params, setToken }: {
|
|
15
|
+
baseURLKey: "PUBLIC_BASE_URL_FINANCEIRO" | "PUBLIC_BASE_URL_USUARIO" | "PUBLIC_BASE_URL_BUCKET";
|
|
15
16
|
url: string;
|
|
16
17
|
params?: any;
|
|
17
18
|
setToken?: boolean;
|
|
18
19
|
}): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
19
|
-
patch({ url, data, setToken }: {
|
|
20
|
+
patch({ baseURLKey, url, data, setToken }: {
|
|
21
|
+
baseURLKey: "PUBLIC_BASE_URL_FINANCEIRO" | "PUBLIC_BASE_URL_USUARIO" | "PUBLIC_BASE_URL_BUCKET";
|
|
20
22
|
url: string;
|
|
21
23
|
data: any;
|
|
22
24
|
setToken?: boolean;
|
|
23
25
|
}): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
24
|
-
delete({ url }: {
|
|
26
|
+
delete({ baseURLKey, url }: {
|
|
27
|
+
baseURLKey: "PUBLIC_BASE_URL_FINANCEIRO" | "PUBLIC_BASE_URL_USUARIO" | "PUBLIC_BASE_URL_BUCKET";
|
|
25
28
|
url: string;
|
|
26
29
|
setToken?: boolean;
|
|
27
30
|
}): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
package/build/lib/index.cjs
CHANGED
|
@@ -224,66 +224,24 @@ 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.getItem("ENVIRONMENT");
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
/* export default */ const utils_environment = (_environment);
|
|
242
|
-
|
|
243
227
|
;// CONCATENATED MODULE: ./src/utils/_api.ts
|
|
244
228
|
|
|
245
229
|
|
|
246
|
-
|
|
247
230
|
const _api_api = class _api {
|
|
248
231
|
static servidor_pricipal = class servidor_pricipal {
|
|
249
|
-
static
|
|
232
|
+
static axios(key) {
|
|
233
|
+
const baseURL = sessionStorage.getItem(key);
|
|
234
|
+
if (!baseURL) throw new Error("API não inicializada no service core");
|
|
250
235
|
return external_axios_default().create({
|
|
251
|
-
baseURL
|
|
236
|
+
baseURL
|
|
252
237
|
});
|
|
253
238
|
}
|
|
254
|
-
static
|
|
255
|
-
|
|
256
|
-
if (typeof window === "undefined") {
|
|
257
|
-
throw new Error("resolveApiBaseURL must run in browser");
|
|
258
|
-
}
|
|
259
|
-
const { origin, hostname } = window.location;
|
|
260
|
-
if (hostname.includes("navsoftware")) {
|
|
261
|
-
const apiOrigin = origin.replace(/^https?:\/\/app/, (match)=>match.replace("app", "api"));
|
|
262
|
-
return apiOrigin;
|
|
263
|
-
}
|
|
264
|
-
const apiOverride = utils_environment.get;
|
|
265
|
-
if (apiOverride === "SANDBOX") {
|
|
266
|
-
return "https://api-sandbox.navsoftware.com.br";
|
|
267
|
-
}
|
|
268
|
-
if (apiOverride === "PRODUCAO") {
|
|
269
|
-
return "https://api.navsoftware.com.br";
|
|
270
|
-
}
|
|
271
|
-
if (apiOverride === "LOCALHOST") {
|
|
272
|
-
return "http://localhost:8787";
|
|
273
|
-
}
|
|
274
|
-
if (hostname === "localhost" || hostname.startsWith("localhost")) {
|
|
275
|
-
return "http://localhost:8787";
|
|
276
|
-
}
|
|
277
|
-
} catch (error) {
|
|
278
|
-
throw new Error(`Ambiente não reconhecido: ${error}`);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
static async post({ url, data, setToken = true }) {
|
|
282
|
-
return await this.#axios.post(url, data, _api.headers({
|
|
239
|
+
static async post({ baseURLKey, url, data, setToken = true }) {
|
|
240
|
+
return await this.axios(baseURLKey).post(url, data, _api.headers({
|
|
283
241
|
setToken: setToken
|
|
284
242
|
}));
|
|
285
243
|
}
|
|
286
|
-
static async get({ url, params, setToken = true }) {
|
|
244
|
+
static async get({ baseURLKey, url, params, setToken = true }) {
|
|
287
245
|
const queryParams = new URLSearchParams();
|
|
288
246
|
if (params) {
|
|
289
247
|
Object.entries(params).forEach(([key, value])=>{
|
|
@@ -294,17 +252,17 @@ const _api_api = class _api {
|
|
|
294
252
|
}
|
|
295
253
|
const queryString = queryParams.toString();
|
|
296
254
|
const fullUrl = queryString ? `${url}?${queryString}` : url;
|
|
297
|
-
return await this
|
|
255
|
+
return await this.axios(baseURLKey).get(fullUrl, _api.headers({
|
|
298
256
|
setToken: setToken
|
|
299
257
|
}));
|
|
300
258
|
}
|
|
301
|
-
static async patch({ url, data, setToken = true }) {
|
|
302
|
-
return await this
|
|
259
|
+
static async patch({ baseURLKey, url, data, setToken = true }) {
|
|
260
|
+
return await this.axios(baseURLKey).patch(url, data, _api.headers({
|
|
303
261
|
setToken: setToken
|
|
304
262
|
}));
|
|
305
263
|
}
|
|
306
|
-
static async delete({ url }) {
|
|
307
|
-
return await this
|
|
264
|
+
static async delete({ baseURLKey, url }) {
|
|
265
|
+
return await this.axios(baseURLKey).delete(url);
|
|
308
266
|
}
|
|
309
267
|
};
|
|
310
268
|
static headers({ setToken = true }) {
|
|
@@ -828,6 +786,22 @@ class _hooks {
|
|
|
828
786
|
}
|
|
829
787
|
/* export default */ const utils_hooks = (new _hooks);
|
|
830
788
|
|
|
789
|
+
;// CONCATENATED MODULE: ./src/utils/_environment.ts
|
|
790
|
+
//BIBLIOTECAS
|
|
791
|
+
//HELPERS
|
|
792
|
+
//BANCO DE DADOS
|
|
793
|
+
//SERVICES
|
|
794
|
+
const _environment = class _environment {
|
|
795
|
+
static set(props) {
|
|
796
|
+
window.sessionStorage.setItem("ENVIRONMENT", props);
|
|
797
|
+
return;
|
|
798
|
+
}
|
|
799
|
+
static get get() {
|
|
800
|
+
return window.sessionStorage.getItem("ENVIRONMENT");
|
|
801
|
+
}
|
|
802
|
+
};
|
|
803
|
+
/* export default */ const utils_environment = (_environment);
|
|
804
|
+
|
|
831
805
|
;// CONCATENATED MODULE: ./src/utils/index.ts
|
|
832
806
|
|
|
833
807
|
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
import { AxiosResponse } from "axios";
|
|
2
|
+
type BaseUrl = "PUBLIC_BASE_URL_FINANCEIRO" | "PUBLIC_BASE_URL_USUARIO" | "PUBLIC_BASE_URL_BUCKET";
|
|
2
3
|
declare const _api: {
|
|
3
4
|
new (): {};
|
|
4
5
|
servidor_pricipal: {
|
|
5
6
|
new (): {};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
axios(key: BaseUrl): import("axios").AxiosInstance;
|
|
8
|
+
post({ baseURLKey, url, data, setToken }: {
|
|
9
|
+
baseURLKey: BaseUrl;
|
|
9
10
|
url: string;
|
|
10
11
|
data: any;
|
|
11
12
|
setToken?: boolean;
|
|
12
13
|
}): Promise<AxiosResponse<any, any, {}>>;
|
|
13
|
-
get({ url, params, setToken }: {
|
|
14
|
+
get({ baseURLKey, url, params, setToken }: {
|
|
15
|
+
baseURLKey: BaseUrl;
|
|
14
16
|
url: string;
|
|
15
17
|
params?: any;
|
|
16
18
|
setToken?: boolean;
|
|
17
19
|
}): Promise<AxiosResponse<any, any, {}>>;
|
|
18
|
-
patch({ url, data, setToken }: {
|
|
20
|
+
patch({ baseURLKey, url, data, setToken }: {
|
|
21
|
+
baseURLKey: BaseUrl;
|
|
19
22
|
url: string;
|
|
20
23
|
data: any;
|
|
21
24
|
setToken?: boolean;
|
|
22
25
|
}): Promise<AxiosResponse<any, any, {}>>;
|
|
23
|
-
delete({ url }: {
|
|
26
|
+
delete({ baseURLKey, url }: {
|
|
27
|
+
baseURLKey: BaseUrl;
|
|
24
28
|
url: string;
|
|
25
29
|
setToken?: boolean;
|
|
26
30
|
}): Promise<AxiosResponse<any, any, {}>>;
|
|
@@ -4,24 +4,27 @@ declare const utils: {
|
|
|
4
4
|
new (): {};
|
|
5
5
|
servidor_pricipal: {
|
|
6
6
|
new (): {};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
axios(key: "PUBLIC_BASE_URL_FINANCEIRO" | "PUBLIC_BASE_URL_USUARIO" | "PUBLIC_BASE_URL_BUCKET"): import("axios").AxiosInstance;
|
|
8
|
+
post({ baseURLKey, url, data, setToken }: {
|
|
9
|
+
baseURLKey: "PUBLIC_BASE_URL_FINANCEIRO" | "PUBLIC_BASE_URL_USUARIO" | "PUBLIC_BASE_URL_BUCKET";
|
|
10
10
|
url: string;
|
|
11
11
|
data: any;
|
|
12
12
|
setToken?: boolean;
|
|
13
13
|
}): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
14
|
-
get({ url, params, setToken }: {
|
|
14
|
+
get({ baseURLKey, url, params, setToken }: {
|
|
15
|
+
baseURLKey: "PUBLIC_BASE_URL_FINANCEIRO" | "PUBLIC_BASE_URL_USUARIO" | "PUBLIC_BASE_URL_BUCKET";
|
|
15
16
|
url: string;
|
|
16
17
|
params?: any;
|
|
17
18
|
setToken?: boolean;
|
|
18
19
|
}): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
19
|
-
patch({ url, data, setToken }: {
|
|
20
|
+
patch({ baseURLKey, url, data, setToken }: {
|
|
21
|
+
baseURLKey: "PUBLIC_BASE_URL_FINANCEIRO" | "PUBLIC_BASE_URL_USUARIO" | "PUBLIC_BASE_URL_BUCKET";
|
|
20
22
|
url: string;
|
|
21
23
|
data: any;
|
|
22
24
|
setToken?: boolean;
|
|
23
25
|
}): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
24
|
-
delete({ url }: {
|
|
26
|
+
delete({ baseURLKey, url }: {
|
|
27
|
+
baseURLKey: "PUBLIC_BASE_URL_FINANCEIRO" | "PUBLIC_BASE_URL_USUARIO" | "PUBLIC_BASE_URL_BUCKET";
|
|
25
28
|
url: string;
|
|
26
29
|
setToken?: boolean;
|
|
27
30
|
}): Promise<import("axios").AxiosResponse<any, any, {}>>;
|