@navservice/core 1.83.0 → 1.86.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 +36 -0
- package/build/es/utils/_api.d.ts +17 -0
- package/build/es/utils/_data.d.ts +1 -0
- package/build/es/utils/index.d.ts +18 -0
- package/build/lib/index.cjs +45 -0
- package/build/lib/utils/_api.d.ts +17 -0
- package/build/lib/utils/_data.d.ts +1 -0
- package/build/lib/utils/index.d.ts +18 -0
- package/package.json +1 -1
package/build/es/index.js
CHANGED
|
@@ -183,6 +183,17 @@ const _api_api = class _api {
|
|
|
183
183
|
static async delete({ baseURLKey, url }) {
|
|
184
184
|
return await this.axios(baseURLKey).delete(url);
|
|
185
185
|
}
|
|
186
|
+
static async post_form({ baseURLKey, url, data, setToken = true }) {
|
|
187
|
+
const formData = new FormData();
|
|
188
|
+
Object.entries(data).forEach(([key, value])=>{
|
|
189
|
+
if (null != value) formData.append(key, value);
|
|
190
|
+
});
|
|
191
|
+
return await this.axios(baseURLKey).post(url, formData, {
|
|
192
|
+
headers: _api.headers_form({
|
|
193
|
+
setToken
|
|
194
|
+
}).headers
|
|
195
|
+
});
|
|
196
|
+
}
|
|
186
197
|
};
|
|
187
198
|
static headers({ setToken = true }) {
|
|
188
199
|
const get_auth_user = utils_session_storage.get_item_session_storage("auth_user");
|
|
@@ -198,6 +209,17 @@ const _api_api = class _api {
|
|
|
198
209
|
}
|
|
199
210
|
};
|
|
200
211
|
}
|
|
212
|
+
static headers_form({ setToken = true }) {
|
|
213
|
+
const get_auth_user = utils_session_storage.get_item_session_storage("auth_user");
|
|
214
|
+
if (true === setToken) return {
|
|
215
|
+
headers: {
|
|
216
|
+
Authorization: `Bearer ${get_auth_user?.data?.usuario?.token}`
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
return {
|
|
220
|
+
headers: {}
|
|
221
|
+
};
|
|
222
|
+
}
|
|
201
223
|
};
|
|
202
224
|
const utils_api = _api_api;
|
|
203
225
|
const _data = class {
|
|
@@ -282,6 +304,20 @@ const _data = class {
|
|
|
282
304
|
var diferencaEmDias = Math.floor(diferenca / 86400000);
|
|
283
305
|
return diferencaEmDias;
|
|
284
306
|
}
|
|
307
|
+
static SET_SECONDS_TO_DD_MM_YYYY_HH_MM(timestamp) {
|
|
308
|
+
const segundos = Number(timestamp);
|
|
309
|
+
if (!Number.isFinite(segundos)) return "-";
|
|
310
|
+
const data = new Date(1000 * segundos);
|
|
311
|
+
if (isNaN(data.getTime())) return "-";
|
|
312
|
+
return data.toLocaleString("pt-BR", {
|
|
313
|
+
timeZone: "America/Sao_Paulo",
|
|
314
|
+
day: "2-digit",
|
|
315
|
+
month: "2-digit",
|
|
316
|
+
year: "numeric",
|
|
317
|
+
hour: "2-digit",
|
|
318
|
+
minute: "2-digit"
|
|
319
|
+
});
|
|
320
|
+
}
|
|
285
321
|
};
|
|
286
322
|
const utils_data = _data;
|
|
287
323
|
class _form {
|
package/build/es/utils/_api.d.ts
CHANGED
|
@@ -28,6 +28,12 @@ declare const _api: {
|
|
|
28
28
|
url: string;
|
|
29
29
|
setToken?: boolean;
|
|
30
30
|
}): Promise<AxiosResponse<any, any, {}>>;
|
|
31
|
+
post_form({ baseURLKey, url, data, setToken }: {
|
|
32
|
+
baseURLKey: BaseUrl;
|
|
33
|
+
url: string;
|
|
34
|
+
data: any;
|
|
35
|
+
setToken?: boolean;
|
|
36
|
+
}): Promise<AxiosResponse<any, any, {}>>;
|
|
31
37
|
};
|
|
32
38
|
headers({ setToken }: {
|
|
33
39
|
setToken?: boolean;
|
|
@@ -42,5 +48,16 @@ declare const _api: {
|
|
|
42
48
|
Authorization?: undefined;
|
|
43
49
|
};
|
|
44
50
|
};
|
|
51
|
+
headers_form({ setToken }: {
|
|
52
|
+
setToken?: boolean;
|
|
53
|
+
}): {
|
|
54
|
+
headers: {
|
|
55
|
+
Authorization: string;
|
|
56
|
+
};
|
|
57
|
+
} | {
|
|
58
|
+
headers: {
|
|
59
|
+
Authorization?: undefined;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
45
62
|
};
|
|
46
63
|
export default _api;
|
|
@@ -28,6 +28,12 @@ declare const utils: {
|
|
|
28
28
|
url: string;
|
|
29
29
|
setToken?: boolean;
|
|
30
30
|
}): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
31
|
+
post_form({ baseURLKey, url, data, setToken }: {
|
|
32
|
+
baseURLKey: import("./_api").BaseUrl;
|
|
33
|
+
url: string;
|
|
34
|
+
data: any;
|
|
35
|
+
setToken?: boolean;
|
|
36
|
+
}): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
31
37
|
};
|
|
32
38
|
headers({ setToken }: {
|
|
33
39
|
setToken?: boolean;
|
|
@@ -42,6 +48,17 @@ declare const utils: {
|
|
|
42
48
|
Authorization?: undefined;
|
|
43
49
|
};
|
|
44
50
|
};
|
|
51
|
+
headers_form({ setToken }: {
|
|
52
|
+
setToken?: boolean;
|
|
53
|
+
}): {
|
|
54
|
+
headers: {
|
|
55
|
+
Authorization: string;
|
|
56
|
+
};
|
|
57
|
+
} | {
|
|
58
|
+
headers: {
|
|
59
|
+
Authorization?: undefined;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
45
62
|
};
|
|
46
63
|
data: {
|
|
47
64
|
new (): {};
|
|
@@ -52,6 +69,7 @@ declare const utils: {
|
|
|
52
69
|
YYYY_MM_DD(newData: string): string;
|
|
53
70
|
DIFERENCA_SEGUNDOS(data: string): number;
|
|
54
71
|
DIFERENCA_DIAS(data: string): number;
|
|
72
|
+
SET_SECONDS_TO_DD_MM_YYYY_HH_MM(timestamp: number | string): string;
|
|
55
73
|
};
|
|
56
74
|
form: typeof _form;
|
|
57
75
|
geral: {
|
package/build/lib/index.cjs
CHANGED
|
@@ -264,6 +264,19 @@ const _api_api = class _api {
|
|
|
264
264
|
static async delete({ baseURLKey, url }) {
|
|
265
265
|
return await this.axios(baseURLKey).delete(url);
|
|
266
266
|
}
|
|
267
|
+
static async post_form({ baseURLKey, url, data, setToken = true }) {
|
|
268
|
+
const formData = new FormData();
|
|
269
|
+
Object.entries(data).forEach(([key, value])=>{
|
|
270
|
+
if (value !== undefined && value !== null) {
|
|
271
|
+
formData.append(key, value);
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
return await this.axios(baseURLKey).post(url, formData, {
|
|
275
|
+
headers: _api.headers_form({
|
|
276
|
+
setToken
|
|
277
|
+
}).headers
|
|
278
|
+
});
|
|
279
|
+
}
|
|
267
280
|
};
|
|
268
281
|
static headers({ setToken = true }) {
|
|
269
282
|
const get_auth_user = utils_session_storage.get_item_session_storage("auth_user");
|
|
@@ -282,6 +295,20 @@ const _api_api = class _api {
|
|
|
282
295
|
};
|
|
283
296
|
}
|
|
284
297
|
}
|
|
298
|
+
static headers_form({ setToken = true }) {
|
|
299
|
+
const get_auth_user = utils_session_storage.get_item_session_storage("auth_user");
|
|
300
|
+
if (setToken === true) {
|
|
301
|
+
return {
|
|
302
|
+
headers: {
|
|
303
|
+
Authorization: `Bearer ${get_auth_user?.data?.usuario?.token}`
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
} else {
|
|
307
|
+
return {
|
|
308
|
+
headers: {}
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
}
|
|
285
312
|
};
|
|
286
313
|
/* export default */ const utils_api = (_api_api);
|
|
287
314
|
|
|
@@ -378,6 +405,24 @@ const _data = class _data {
|
|
|
378
405
|
var diferencaEmDias = Math.floor(diferenca / (1000 * 60 * 60 * 24)); // Calcula a diferença em dias
|
|
379
406
|
return diferencaEmDias;
|
|
380
407
|
}
|
|
408
|
+
static SET_SECONDS_TO_DD_MM_YYYY_HH_MM(timestamp) {
|
|
409
|
+
const segundos = Number(timestamp);
|
|
410
|
+
if (!Number.isFinite(segundos)) {
|
|
411
|
+
return "-";
|
|
412
|
+
}
|
|
413
|
+
const data = new Date(segundos * 1000);
|
|
414
|
+
if (isNaN(data.getTime())) {
|
|
415
|
+
return "-";
|
|
416
|
+
}
|
|
417
|
+
return data.toLocaleString("pt-BR", {
|
|
418
|
+
timeZone: "America/Sao_Paulo",
|
|
419
|
+
day: "2-digit",
|
|
420
|
+
month: "2-digit",
|
|
421
|
+
year: "numeric",
|
|
422
|
+
hour: "2-digit",
|
|
423
|
+
minute: "2-digit"
|
|
424
|
+
});
|
|
425
|
+
}
|
|
381
426
|
};
|
|
382
427
|
/* export default */ const utils_data = (_data);
|
|
383
428
|
|
|
@@ -28,6 +28,12 @@ declare const _api: {
|
|
|
28
28
|
url: string;
|
|
29
29
|
setToken?: boolean;
|
|
30
30
|
}): Promise<AxiosResponse<any, any, {}>>;
|
|
31
|
+
post_form({ baseURLKey, url, data, setToken }: {
|
|
32
|
+
baseURLKey: BaseUrl;
|
|
33
|
+
url: string;
|
|
34
|
+
data: any;
|
|
35
|
+
setToken?: boolean;
|
|
36
|
+
}): Promise<AxiosResponse<any, any, {}>>;
|
|
31
37
|
};
|
|
32
38
|
headers({ setToken }: {
|
|
33
39
|
setToken?: boolean;
|
|
@@ -42,5 +48,16 @@ declare const _api: {
|
|
|
42
48
|
Authorization?: undefined;
|
|
43
49
|
};
|
|
44
50
|
};
|
|
51
|
+
headers_form({ setToken }: {
|
|
52
|
+
setToken?: boolean;
|
|
53
|
+
}): {
|
|
54
|
+
headers: {
|
|
55
|
+
Authorization: string;
|
|
56
|
+
};
|
|
57
|
+
} | {
|
|
58
|
+
headers: {
|
|
59
|
+
Authorization?: undefined;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
45
62
|
};
|
|
46
63
|
export default _api;
|
|
@@ -28,6 +28,12 @@ declare const utils: {
|
|
|
28
28
|
url: string;
|
|
29
29
|
setToken?: boolean;
|
|
30
30
|
}): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
31
|
+
post_form({ baseURLKey, url, data, setToken }: {
|
|
32
|
+
baseURLKey: import("./_api").BaseUrl;
|
|
33
|
+
url: string;
|
|
34
|
+
data: any;
|
|
35
|
+
setToken?: boolean;
|
|
36
|
+
}): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
31
37
|
};
|
|
32
38
|
headers({ setToken }: {
|
|
33
39
|
setToken?: boolean;
|
|
@@ -42,6 +48,17 @@ declare const utils: {
|
|
|
42
48
|
Authorization?: undefined;
|
|
43
49
|
};
|
|
44
50
|
};
|
|
51
|
+
headers_form({ setToken }: {
|
|
52
|
+
setToken?: boolean;
|
|
53
|
+
}): {
|
|
54
|
+
headers: {
|
|
55
|
+
Authorization: string;
|
|
56
|
+
};
|
|
57
|
+
} | {
|
|
58
|
+
headers: {
|
|
59
|
+
Authorization?: undefined;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
45
62
|
};
|
|
46
63
|
data: {
|
|
47
64
|
new (): {};
|
|
@@ -52,6 +69,7 @@ declare const utils: {
|
|
|
52
69
|
YYYY_MM_DD(newData: string): string;
|
|
53
70
|
DIFERENCA_SEGUNDOS(data: string): number;
|
|
54
71
|
DIFERENCA_DIAS(data: string): number;
|
|
72
|
+
SET_SECONDS_TO_DD_MM_YYYY_HH_MM(timestamp: number | string): string;
|
|
55
73
|
};
|
|
56
74
|
form: typeof _form;
|
|
57
75
|
geral: {
|