@navservice/core 1.61.0 → 1.63.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.browser.d.ts +1 -0
- package/build/es/index.browser.js +520 -1
- package/build/es/utils.js +214 -106
- package/build/lib/index.browser.cjs +717 -42
- package/build/lib/index.browser.d.ts +1 -0
- package/build/lib/utils.cjs +219 -47
- package/package.json +1 -1
package/build/es/utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
|
+
import v4 from "zod/v4";
|
|
2
3
|
import { useLayoutEffect, useState } from "react";
|
|
3
4
|
class config_env {
|
|
4
5
|
static SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL;
|
|
@@ -10,96 +11,114 @@ class config_env {
|
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
const src_config_env = config_env;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
14
|
+
(function(TypeControllerUsuario) {
|
|
15
|
+
TypeControllerUsuario.AppEnum = [
|
|
16
|
+
"service-usuario",
|
|
17
|
+
"service-financeiro",
|
|
18
|
+
"service-pages-ai"
|
|
19
|
+
];
|
|
20
|
+
TypeControllerUsuario.UsuarioTipoEnum = [
|
|
21
|
+
"padrao"
|
|
22
|
+
];
|
|
23
|
+
v4["enum"]([
|
|
24
|
+
"service-usuario",
|
|
25
|
+
"service-financeiro",
|
|
26
|
+
"service-pages-ai"
|
|
27
|
+
]);
|
|
28
|
+
v4["enum"](TypeControllerUsuario.UsuarioTipoEnum);
|
|
29
|
+
})(_usuario_TypeControllerUsuario || (_usuario_TypeControllerUsuario = {}));
|
|
30
|
+
const _usuario = _usuario_TypeControllerUsuario;
|
|
31
|
+
var _usuario_TypeControllerUsuario;
|
|
32
|
+
(function(TypeControllerResponse) {
|
|
33
|
+
const StatusSchema = v4.union([
|
|
34
|
+
v4.literal(200),
|
|
35
|
+
v4.literal(201),
|
|
36
|
+
v4.literal(202),
|
|
37
|
+
v4.literal(204),
|
|
38
|
+
v4.literal(400),
|
|
39
|
+
v4.literal(401),
|
|
40
|
+
v4.literal(403),
|
|
41
|
+
v4.literal(404),
|
|
42
|
+
v4.literal(409),
|
|
43
|
+
v4.literal(422),
|
|
44
|
+
v4.literal(500),
|
|
45
|
+
v4.literal(428),
|
|
46
|
+
v4.literal(405)
|
|
47
|
+
]);
|
|
48
|
+
const TypeSchema = v4.union([
|
|
49
|
+
v4.literal("success"),
|
|
50
|
+
v4.literal("warning"),
|
|
51
|
+
v4.literal("error")
|
|
52
|
+
]).default("success");
|
|
53
|
+
const CodeSchema = v4.union([
|
|
54
|
+
v4.literal("SUCCESS"),
|
|
55
|
+
v4.literal("ACTION_REQUIRED"),
|
|
56
|
+
v4.literal("CREATED"),
|
|
57
|
+
v4.literal("WARNING"),
|
|
58
|
+
v4.literal("AUTHORIZATION_ERROR"),
|
|
59
|
+
v4.literal("SCHEMA_VALIDATION"),
|
|
60
|
+
v4.literal("SERVER_ERROR"),
|
|
61
|
+
v4.literal("UNAUTHORIZED"),
|
|
62
|
+
v4.literal("INVALID_TOKEN"),
|
|
63
|
+
v4.literal("NOT_FOUND"),
|
|
64
|
+
v4.literal("SUCCESS_FILE"),
|
|
65
|
+
v4.literal("DATABASE_ERROR")
|
|
66
|
+
]);
|
|
67
|
+
v4.object({
|
|
68
|
+
status: StatusSchema,
|
|
69
|
+
code: CodeSchema,
|
|
70
|
+
type: TypeSchema,
|
|
71
|
+
message: v4.string(),
|
|
72
|
+
results: v4.unknown().optional(),
|
|
73
|
+
error: v4.unknown().optional()
|
|
74
|
+
});
|
|
75
|
+
(function(C) {
|
|
76
|
+
C.InputSchema = v4.object({
|
|
77
|
+
status: StatusSchema,
|
|
78
|
+
code: CodeSchema,
|
|
79
|
+
type: TypeSchema.optional().default("success"),
|
|
80
|
+
message: v4.string().optional(),
|
|
81
|
+
results: v4.any(),
|
|
82
|
+
c: v4.custom()
|
|
83
|
+
});
|
|
84
|
+
v4.object({
|
|
85
|
+
status: StatusSchema,
|
|
86
|
+
message: v4.string().optional(),
|
|
87
|
+
file_buffer: v4.union([
|
|
88
|
+
v4["instanceof"](Blob),
|
|
89
|
+
v4["instanceof"](ArrayBuffer),
|
|
90
|
+
v4["instanceof"](Uint8Array)
|
|
91
|
+
]),
|
|
92
|
+
content_type: v4.string(),
|
|
93
|
+
filename: v4.string().optional(),
|
|
94
|
+
c: v4.custom().optional()
|
|
95
|
+
});
|
|
96
|
+
})(TypeControllerResponse.C || (TypeControllerResponse.C = {}));
|
|
97
|
+
(function(Error) {
|
|
98
|
+
Error.InputSchema = v4.object({
|
|
99
|
+
message: v4.string().optional(),
|
|
100
|
+
results: v4.union([
|
|
101
|
+
v4.array(v4.unknown()),
|
|
102
|
+
v4.unknown()
|
|
103
|
+
]).optional(),
|
|
104
|
+
type: TypeSchema.optional().default("success"),
|
|
105
|
+
code: CodeSchema,
|
|
106
|
+
status: v4.number().optional().default(200)
|
|
107
|
+
});
|
|
108
|
+
})(TypeControllerResponse.Error || (TypeControllerResponse.Error = {}));
|
|
109
|
+
})(_type_response_TypeControllerResponse || (_type_response_TypeControllerResponse = {}));
|
|
110
|
+
const _type_response = _type_response_TypeControllerResponse;
|
|
111
|
+
var _type_response_TypeControllerResponse;
|
|
112
|
+
(function(t) {
|
|
113
|
+
(function(Controller) {
|
|
114
|
+
Controller.Usuario = _usuario;
|
|
115
|
+
})(t.Controller || (t.Controller = {}));
|
|
116
|
+
(function(Geral) {
|
|
117
|
+
Geral.Response = _type_response;
|
|
118
|
+
})(t.Geral || (t.Geral = {}));
|
|
119
|
+
})(types_t || (types_t = {}));
|
|
120
|
+
var types_t;
|
|
121
|
+
const _data_data = class {
|
|
103
122
|
static YYYY_MM_DD_00_00_00(newData) {
|
|
104
123
|
let dataAtual = new Date();
|
|
105
124
|
if (newData) dataAtual = new Date(newData);
|
|
@@ -182,8 +201,8 @@ const _data = class {
|
|
|
182
201
|
return diferencaEmDias;
|
|
183
202
|
}
|
|
184
203
|
};
|
|
185
|
-
const utils_data =
|
|
186
|
-
class
|
|
204
|
+
const utils_data = _data_data;
|
|
205
|
+
class _form_form {
|
|
187
206
|
static regex_cpf_cnpj(value) {
|
|
188
207
|
let tempValue = value.replace(/\D/g, "");
|
|
189
208
|
if (tempValue.length > 14) tempValue = tempValue.slice(0, 14);
|
|
@@ -284,7 +303,7 @@ class _form {
|
|
|
284
303
|
}).format(Number(num) / 100);
|
|
285
304
|
}
|
|
286
305
|
}
|
|
287
|
-
const utils_form =
|
|
306
|
+
const utils_form = _form_form;
|
|
288
307
|
const geral = class {
|
|
289
308
|
static slice_file_name(filename, maxLength = 30) {
|
|
290
309
|
if (!filename || "string" != typeof filename) return "";
|
|
@@ -315,8 +334,8 @@ const geral = class {
|
|
|
315
334
|
return finalResult.substring(0, length);
|
|
316
335
|
};
|
|
317
336
|
};
|
|
318
|
-
const
|
|
319
|
-
const
|
|
337
|
+
const utils_geral = geral;
|
|
338
|
+
const _local_storage_local_storage = class {
|
|
320
339
|
static adicionar_item_local_storage(chave, novoItem) {
|
|
321
340
|
try {
|
|
322
341
|
const valorAtual = window.localStorage.getItem(chave);
|
|
@@ -356,8 +375,8 @@ const _local_storage = class {
|
|
|
356
375
|
}
|
|
357
376
|
}
|
|
358
377
|
};
|
|
359
|
-
const utils_local_storage =
|
|
360
|
-
const
|
|
378
|
+
const utils_local_storage = _local_storage_local_storage;
|
|
379
|
+
const _update_context_update_context = class {
|
|
361
380
|
static set_new_item_end = ({ oldArray = [], newItem = [], key = "_id" })=>{
|
|
362
381
|
try {
|
|
363
382
|
const hasValidIds = Array.isArray(newItem) ? newItem.every((item)=>item?.[key]) : newItem?.[key];
|
|
@@ -443,8 +462,49 @@ const _update_context = class {
|
|
|
443
462
|
];
|
|
444
463
|
}
|
|
445
464
|
};
|
|
446
|
-
const utils_update_context =
|
|
447
|
-
const
|
|
465
|
+
const utils_update_context = _update_context_update_context;
|
|
466
|
+
const _session_storage_session_storage = class {
|
|
467
|
+
static adicionar_item_session_storage({ chave, novoItem }) {
|
|
468
|
+
try {
|
|
469
|
+
const valorAtual = window.sessionStorage.getItem(chave);
|
|
470
|
+
const listaAtual = valorAtual ? JSON.parse(valorAtual) : [];
|
|
471
|
+
const newDataItem = {
|
|
472
|
+
...listaAtual,
|
|
473
|
+
...novoItem
|
|
474
|
+
};
|
|
475
|
+
window.sessionStorage.setItem(chave, JSON.stringify(newDataItem));
|
|
476
|
+
} catch (error) {
|
|
477
|
+
console.error(error);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
static set_session_storage_sem_incremento({ chave, novoItem }) {
|
|
481
|
+
try {
|
|
482
|
+
window.sessionStorage.setItem(chave, JSON.stringify(novoItem));
|
|
483
|
+
} catch (error) {
|
|
484
|
+
console.error(error);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
static get_item_session_storage(chave) {
|
|
488
|
+
try {
|
|
489
|
+
if ("undefined" != typeof window) {
|
|
490
|
+
const valorAtual = window.sessionStorage.getItem(chave);
|
|
491
|
+
return valorAtual ? JSON.parse(valorAtual) : valorAtual;
|
|
492
|
+
}
|
|
493
|
+
return;
|
|
494
|
+
} catch (error) {
|
|
495
|
+
console.error(error);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
static remover_item_session_storage(chave) {
|
|
499
|
+
try {
|
|
500
|
+
window.sessionStorage.removeItem(chave);
|
|
501
|
+
} catch (error) {
|
|
502
|
+
console.error(error);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
const utils_session_storage = _session_storage_session_storage;
|
|
507
|
+
const _sistema_sistema = {
|
|
448
508
|
empresa: {
|
|
449
509
|
nome: "Nav Software",
|
|
450
510
|
email_suporte: "suporte@navsoftware.com.br",
|
|
@@ -492,8 +552,8 @@ const _sistema = {
|
|
|
492
552
|
}
|
|
493
553
|
}
|
|
494
554
|
};
|
|
495
|
-
const utils_sistema =
|
|
496
|
-
class
|
|
555
|
+
const utils_sistema = _sistema_sistema;
|
|
556
|
+
class _hooks_hooks {
|
|
497
557
|
use_is_mobile() {
|
|
498
558
|
const [isMobile, setIsMobile] = useState(false);
|
|
499
559
|
useLayoutEffect(()=>{
|
|
@@ -514,17 +574,65 @@ class _hooks {
|
|
|
514
574
|
}
|
|
515
575
|
}
|
|
516
576
|
}
|
|
517
|
-
const utils_hooks = new
|
|
518
|
-
const
|
|
577
|
+
const utils_hooks = new _hooks_hooks;
|
|
578
|
+
const _api_api = class _api {
|
|
579
|
+
static servidor_pricipal = class {
|
|
580
|
+
static get #axios() {
|
|
581
|
+
return axios.create({
|
|
582
|
+
baseURL: src_config_env.PUBLIC_BASE_URL_BACKEND_PRINCIPAL
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
static async post({ url, data, setToken = true }) {
|
|
586
|
+
return await this.#axios.post(url, data, _api.headers({
|
|
587
|
+
setToken: setToken
|
|
588
|
+
}));
|
|
589
|
+
}
|
|
590
|
+
static async get({ url, params, setToken = true }) {
|
|
591
|
+
const queryParams = new URLSearchParams();
|
|
592
|
+
if (params) Object.entries(params).forEach(([key, value])=>{
|
|
593
|
+
if (null != value) queryParams.append(key, value);
|
|
594
|
+
});
|
|
595
|
+
const queryString = queryParams.toString();
|
|
596
|
+
const fullUrl = queryString ? `${url}?${queryString}` : url;
|
|
597
|
+
return await this.#axios.get(fullUrl, _api.headers({
|
|
598
|
+
setToken: setToken
|
|
599
|
+
}));
|
|
600
|
+
}
|
|
601
|
+
static async patch({ url, data, setToken = true }) {
|
|
602
|
+
return await this.#axios.patch(url, data, _api.headers({
|
|
603
|
+
setToken: setToken
|
|
604
|
+
}));
|
|
605
|
+
}
|
|
606
|
+
static async delete({ url }) {
|
|
607
|
+
return await this.#axios.delete(url);
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
static headers({ setToken = true }) {
|
|
611
|
+
const get_auth_user = utils_session_storage.get_item_session_storage("auth_user");
|
|
612
|
+
if (true === setToken) return {
|
|
613
|
+
headers: {
|
|
614
|
+
Authorization: `Bearer ${get_auth_user?.data?.usuario?.token}`,
|
|
615
|
+
"Content-type": "application/json"
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
return {
|
|
619
|
+
headers: {
|
|
620
|
+
"Content-type": "application/json"
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
const utils_api = _api_api;
|
|
626
|
+
const utils_utils = {
|
|
519
627
|
api: utils_api,
|
|
520
628
|
data: utils_data,
|
|
521
629
|
form: utils_form,
|
|
522
|
-
geral:
|
|
630
|
+
geral: utils_geral,
|
|
523
631
|
local_storage: utils_local_storage,
|
|
524
632
|
update_context: utils_update_context,
|
|
525
633
|
session_sorage: utils_session_storage,
|
|
526
634
|
sistema: utils_sistema,
|
|
527
635
|
hooks: utils_hooks
|
|
528
636
|
};
|
|
529
|
-
const
|
|
530
|
-
export {
|
|
637
|
+
const src_utils_0 = utils_utils;
|
|
638
|
+
export { src_utils_0 as default };
|