@navservice/core 1.25.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.
@@ -0,0 +1,341 @@
1
+ import v4 from "zod/v4";
2
+ import { SignJWT, jwtVerify } from "jose";
3
+ import { randomBytes, scrypt, timingSafeEqual } from "node:crypto";
4
+ import { promisify } from "node:util";
5
+ const set_response = class {
6
+ static c = class {
7
+ static SUCCESS({ message, results, c }) {
8
+ const payload = {
9
+ status: 200,
10
+ code: "SUCCESS",
11
+ type: "success",
12
+ message: message || "Realizado com sucesso!",
13
+ results: results || []
14
+ };
15
+ if (c) return c.json(payload, {
16
+ status: 200
17
+ });
18
+ return payload;
19
+ }
20
+ static ACTION_REQUIRED({ message, results, c }) {
21
+ const payload = {
22
+ status: 428,
23
+ code: "ACTION_REQUIRED",
24
+ type: "warning",
25
+ message: message || "Ação adicional necessária!",
26
+ results: results || []
27
+ };
28
+ if (c) return c.json(payload, {
29
+ status: 428
30
+ });
31
+ return payload;
32
+ }
33
+ static CREATED({ message, results, c }) {
34
+ const payload = {
35
+ status: 201,
36
+ code: "CREATED",
37
+ type: "success",
38
+ message: message || "Criado com sucesso!",
39
+ results: results || []
40
+ };
41
+ return c ? c.json(payload, {
42
+ status: 201
43
+ }) : payload;
44
+ }
45
+ static WARNING({ message, results, c }) {
46
+ const payload = {
47
+ status: 400,
48
+ code: "WARNING",
49
+ type: "warning",
50
+ message: message || "Aviso!",
51
+ results: results || []
52
+ };
53
+ if (c) c.json(payload, {
54
+ status: 400
55
+ });
56
+ throw payload;
57
+ }
58
+ static AUTHORIZATION_ERROR({ message, results, c }) {
59
+ const payload = {
60
+ status: 405,
61
+ code: "WARNING",
62
+ type: "warning",
63
+ message: message || "Aviso!",
64
+ results: results || []
65
+ };
66
+ if (c) c.json(payload, {
67
+ status: 405
68
+ });
69
+ throw payload;
70
+ }
71
+ static DATABASE_ERROR({ message, results, c }) {
72
+ const payload = {
73
+ status: 500,
74
+ code: "DATABASE_ERROR",
75
+ type: "error",
76
+ message: message || "Erro no banco de dados!",
77
+ results: results || []
78
+ };
79
+ return c ? c.json(payload, {
80
+ status: 500
81
+ }) : payload;
82
+ }
83
+ static SERVER_ERROR({ error, c }) {
84
+ if (error instanceof v4.ZodError) {
85
+ const payload = {
86
+ status: 500,
87
+ code: "SCHEMA_VALIDATION",
88
+ type: "warning",
89
+ message: "Erro ao validar dados!",
90
+ results: v4.treeifyError(error)
91
+ };
92
+ return c.json(payload, {
93
+ status: 500
94
+ });
95
+ }
96
+ const payload = {
97
+ status: error?.status || 500,
98
+ code: error?.code || "SERVER_ERROR",
99
+ type: error?.type || "error",
100
+ message: error?.message || "Erro interno no servidor!",
101
+ results: error?.results || []
102
+ };
103
+ return c.json(payload, {
104
+ status: error?.status || error?.status || 500
105
+ });
106
+ }
107
+ static UNAUTHORIZED({ message, c }) {
108
+ const payload = {
109
+ status: 401,
110
+ code: "UNAUTHORIZED",
111
+ type: "error",
112
+ message: message || "Não autorizado!",
113
+ results: []
114
+ };
115
+ return c ? c.json(payload, {
116
+ status: 401
117
+ }) : payload;
118
+ }
119
+ static INVALID_TOKEN({ message, c }) {
120
+ const payload = {
121
+ status: 401,
122
+ code: "INVALID_TOKEN",
123
+ type: "warning",
124
+ message: message || "Token inválido!",
125
+ results: []
126
+ };
127
+ return c ? c.json(payload, {
128
+ status: 401
129
+ }) : payload;
130
+ }
131
+ static NOT_FOUND({ message, c }) {
132
+ const payload = {
133
+ status: 404,
134
+ code: "NOT_FOUND",
135
+ type: "error",
136
+ message: message || "Recurso não encontrado!",
137
+ results: []
138
+ };
139
+ return c ? c.json(payload, {
140
+ status: 404
141
+ }) : payload;
142
+ }
143
+ static async SUCCESS_FILE({ message, file_buffer, content_type, filename, c }) {
144
+ if (c && content_type) {
145
+ const headers = {
146
+ "Content-Type": content_type,
147
+ "Content-Disposition": filename ? `inline; filename="${filename}"` : "inline"
148
+ };
149
+ return new Response(file_buffer, {
150
+ status: 200,
151
+ headers
152
+ });
153
+ }
154
+ const payload = {
155
+ status: 200,
156
+ code: "SUCCESS_FILE",
157
+ type: "success",
158
+ message: message || "Erro ao retornar arquivo!",
159
+ results: []
160
+ };
161
+ return c ? c.json(payload, {
162
+ status: 200
163
+ }) : payload;
164
+ }
165
+ };
166
+ static error = class {
167
+ static ACTION_REQUIRED({ message, results }) {
168
+ const payload = {
169
+ status: 428,
170
+ code: "ACTION_REQUIRED",
171
+ type: "warning",
172
+ message: message || "Ação adicional necessária!",
173
+ results: results || []
174
+ };
175
+ throw payload;
176
+ }
177
+ static WARNING({ message, results }) {
178
+ const payload = {
179
+ status: 400,
180
+ code: "WARNING",
181
+ type: "warning",
182
+ message: message || "Aviso!",
183
+ results: results || []
184
+ };
185
+ throw payload;
186
+ }
187
+ static AUTHORIZATION_ERROR({ message, results }) {
188
+ const payload = {
189
+ status: 400,
190
+ code: "WARNING",
191
+ type: "warning",
192
+ message: message || "Aviso!",
193
+ results: results || []
194
+ };
195
+ throw payload;
196
+ }
197
+ static DATABASE_ERROR({ message, results }) {
198
+ const payload = {
199
+ status: 405,
200
+ code: "DATABASE_ERROR",
201
+ type: "error",
202
+ message: message || "Erro no banco de dados!",
203
+ results: results || []
204
+ };
205
+ throw payload;
206
+ }
207
+ static SCHEMA_VALIDATION({ results }) {
208
+ const payload = {
209
+ status: 500,
210
+ code: "SCHEMA_VALIDATION",
211
+ type: "error",
212
+ message: "Erro ao validar dados!",
213
+ results: results || []
214
+ };
215
+ throw payload;
216
+ }
217
+ static UNAUTHORIZED({ message }) {
218
+ const payload = {
219
+ status: 401,
220
+ code: "UNAUTHORIZED",
221
+ type: "error",
222
+ message: message || "Não autorizado!"
223
+ };
224
+ throw payload;
225
+ }
226
+ static INVALID_TOKEN({ message }) {
227
+ const payload = {
228
+ status: 401,
229
+ code: "INVALID_TOKEN",
230
+ type: "warning",
231
+ message: message || "Token inválido!",
232
+ results: []
233
+ };
234
+ throw payload;
235
+ }
236
+ static NOT_FOUND({ message }) {
237
+ const payload = {
238
+ status: 404,
239
+ code: "NOT_FOUND",
240
+ type: "error",
241
+ message: message || "Recurso não encontrado!"
242
+ };
243
+ throw payload;
244
+ }
245
+ };
246
+ };
247
+ const _set_response = set_response;
248
+ const _token = class {
249
+ static async verificar_token(c, next) {
250
+ try {
251
+ const authHeader = c.req.header("Authorization");
252
+ if (!authHeader) return src_helpers.set_response.c.INVALID_TOKEN({
253
+ message: 'token não enviado!!!',
254
+ c: c,
255
+ results: []
256
+ });
257
+ const token = authHeader.split(" ")[1];
258
+ if (!token) return src_helpers.set_response.c.INVALID_TOKEN({
259
+ message: 'Acesso negado!!!',
260
+ c: c,
261
+ results: []
262
+ });
263
+ const secret = new TextEncoder().encode(c.env.JSON_WEB_TOKEN_AUTH_USER);
264
+ const { payload } = await jwtVerify(token, secret);
265
+ if (!payload._id || !payload.email) return src_helpers.set_response.c.INVALID_TOKEN({
266
+ message: 'Token inválido!!!!',
267
+ c: c,
268
+ results: []
269
+ });
270
+ const setar_token = {
271
+ _id: payload._id,
272
+ email: payload.email,
273
+ ativo: payload.ativo,
274
+ data_criacao: payload.data_criacao,
275
+ nome: payload.nome,
276
+ app: payload.app,
277
+ usuario_tipo: payload.usuario_tipo
278
+ };
279
+ c.set("usuario_auth", setar_token);
280
+ return await next();
281
+ } catch (error) {
282
+ return src_helpers.set_response.c.INVALID_TOKEN({
283
+ message: 'Token inválido!!!',
284
+ c: c,
285
+ results: []
286
+ });
287
+ }
288
+ }
289
+ static async criar_token_login_usuario({ _id, email, app, usuario_tipo, ativo, data_criacao, nome, c }) {
290
+ if (!c.env.JSON_WEB_TOKEN_AUTH_USER) return src_helpers.set_response.error.WARNING({
291
+ message: "Erro ao gerar token!!",
292
+ results: []
293
+ });
294
+ const token = await new SignJWT({
295
+ _id: _id,
296
+ email: email,
297
+ app: app,
298
+ usuario_tipo: usuario_tipo,
299
+ ativo: ativo,
300
+ data_criacao: data_criacao,
301
+ nome: nome
302
+ }).setProtectedHeader({
303
+ alg: "HS256"
304
+ }).setIssuedAt().sign(new TextEncoder().encode(c.env.JSON_WEB_TOKEN_AUTH_USER)).catch((error)=>src_helpers.set_response.error.WARNING({
305
+ message: "Erro ao gerar token!",
306
+ results: error?.message
307
+ }));
308
+ return token;
309
+ }
310
+ };
311
+ const helpers_token = _token;
312
+ const scryptAsync = promisify(scrypt);
313
+ class _secret {
314
+ static SALT_LENGTH = 22;
315
+ static KEY_LENGTH = 35;
316
+ static async gerar_hash_senha(password) {
317
+ const salt = randomBytes(this.SALT_LENGTH);
318
+ const derivedKey = await scryptAsync(password, salt, this.KEY_LENGTH);
319
+ return salt.toString('base64') + '.' + derivedKey.toString('base64');
320
+ }
321
+ static async verify({ password, dashed_senha }) {
322
+ try {
323
+ const [saltBase64, hashBase64] = dashed_senha.split('.');
324
+ if (!saltBase64 || !hashBase64) return false;
325
+ const salt = Buffer.from(saltBase64, 'base64');
326
+ const storedHash = Buffer.from(hashBase64, 'base64');
327
+ const derivedKey = await scryptAsync(password, salt, this.KEY_LENGTH);
328
+ return timingSafeEqual(storedHash, derivedKey);
329
+ } catch {
330
+ return false;
331
+ }
332
+ }
333
+ }
334
+ const helpers_secret = _secret;
335
+ class helpers {
336
+ static set_response = _set_response;
337
+ static token = helpers_token;
338
+ static secret = helpers_secret;
339
+ }
340
+ const src_helpers = helpers;
341
+ export { src_helpers as helpers };
@@ -0,0 +1,54 @@
1
+ import t from ".";
2
+ import z4 from "zod/v4";
3
+ declare namespace TypeControllerResponse {
4
+ const BaseResponseSchema: z4.ZodObject<{
5
+ status: z4.ZodUnion<readonly [z4.ZodLiteral<200>, z4.ZodLiteral<201>, z4.ZodLiteral<202>, z4.ZodLiteral<204>, z4.ZodLiteral<400>, z4.ZodLiteral<401>, z4.ZodLiteral<403>, z4.ZodLiteral<404>, z4.ZodLiteral<409>, z4.ZodLiteral<422>, z4.ZodLiteral<500>, z4.ZodLiteral<428>, z4.ZodLiteral<405>]>;
6
+ code: z4.ZodUnion<readonly [z4.ZodLiteral<"SUCCESS">, z4.ZodLiteral<"ACTION_REQUIRED">, z4.ZodLiteral<"CREATED">, z4.ZodLiteral<"WARNING">, z4.ZodLiteral<"AUTHORIZATION_ERROR">, z4.ZodLiteral<"SCHEMA_VALIDATION">, z4.ZodLiteral<"SERVER_ERROR">, z4.ZodLiteral<"UNAUTHORIZED">, z4.ZodLiteral<"INVALID_TOKEN">, z4.ZodLiteral<"NOT_FOUND">, z4.ZodLiteral<"SUCCESS_FILE">, z4.ZodLiteral<"DATABASE_ERROR">]>;
7
+ type: z4.ZodDefault<z4.ZodUnion<readonly [z4.ZodLiteral<"success">, z4.ZodLiteral<"warning">, z4.ZodLiteral<"error">]>>;
8
+ message: z4.ZodString;
9
+ results: z4.ZodOptional<z4.ZodUnknown>;
10
+ error: z4.ZodOptional<z4.ZodUnknown>;
11
+ }, z4.core.$strip>;
12
+ type BaseResponse<T = unknown> = z4.infer<typeof BaseResponseSchema> & {
13
+ results?: T;
14
+ };
15
+ export namespace C {
16
+ export const InputSchema: z4.ZodObject<{
17
+ status: z4.ZodUnion<readonly [z4.ZodLiteral<200>, z4.ZodLiteral<201>, z4.ZodLiteral<202>, z4.ZodLiteral<204>, z4.ZodLiteral<400>, z4.ZodLiteral<401>, z4.ZodLiteral<403>, z4.ZodLiteral<404>, z4.ZodLiteral<409>, z4.ZodLiteral<422>, z4.ZodLiteral<500>, z4.ZodLiteral<428>, z4.ZodLiteral<405>]>;
18
+ code: z4.ZodUnion<readonly [z4.ZodLiteral<"SUCCESS">, z4.ZodLiteral<"ACTION_REQUIRED">, z4.ZodLiteral<"CREATED">, z4.ZodLiteral<"WARNING">, z4.ZodLiteral<"AUTHORIZATION_ERROR">, z4.ZodLiteral<"SCHEMA_VALIDATION">, z4.ZodLiteral<"SERVER_ERROR">, z4.ZodLiteral<"UNAUTHORIZED">, z4.ZodLiteral<"INVALID_TOKEN">, z4.ZodLiteral<"NOT_FOUND">, z4.ZodLiteral<"SUCCESS_FILE">, z4.ZodLiteral<"DATABASE_ERROR">]>;
19
+ type: z4.ZodDefault<z4.ZodOptional<z4.ZodDefault<z4.ZodUnion<readonly [z4.ZodLiteral<"success">, z4.ZodLiteral<"warning">, z4.ZodLiteral<"error">]>>>>;
20
+ message: z4.ZodOptional<z4.ZodString>;
21
+ results: z4.ZodAny;
22
+ c: z4.ZodCustom<t.Context, t.Context>;
23
+ }, z4.core.$strip>;
24
+ export type Input<T = unknown> = z4.infer<typeof InputSchema> & {
25
+ results?: T;
26
+ };
27
+ export type Output<T = unknown> = BaseResponse<T>;
28
+ const FileResponseParamsSchema: z4.ZodObject<{
29
+ status: z4.ZodUnion<readonly [z4.ZodLiteral<200>, z4.ZodLiteral<201>, z4.ZodLiteral<202>, z4.ZodLiteral<204>, z4.ZodLiteral<400>, z4.ZodLiteral<401>, z4.ZodLiteral<403>, z4.ZodLiteral<404>, z4.ZodLiteral<409>, z4.ZodLiteral<422>, z4.ZodLiteral<500>, z4.ZodLiteral<428>, z4.ZodLiteral<405>]>;
30
+ message: z4.ZodOptional<z4.ZodString>;
31
+ file_buffer: z4.ZodUnion<readonly [z4.ZodCustom<Blob, Blob>, z4.ZodCustom<ArrayBuffer, ArrayBuffer>, z4.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>]>;
32
+ content_type: z4.ZodString;
33
+ filename: z4.ZodOptional<z4.ZodString>;
34
+ c: z4.ZodOptional<z4.ZodCustom<t.Context, t.Context>>;
35
+ }, z4.core.$strip>;
36
+ export type FileResponseParams = z4.infer<typeof FileResponseParamsSchema>;
37
+ export {};
38
+ }
39
+ export namespace Error {
40
+ const InputSchema: z4.ZodObject<{
41
+ message: z4.ZodOptional<z4.ZodString>;
42
+ results: z4.ZodOptional<z4.ZodUnion<readonly [z4.ZodArray<z4.ZodUnknown>, z4.ZodUnknown]>>;
43
+ type: z4.ZodDefault<z4.ZodOptional<z4.ZodDefault<z4.ZodUnion<readonly [z4.ZodLiteral<"success">, z4.ZodLiteral<"warning">, z4.ZodLiteral<"error">]>>>>;
44
+ code: z4.ZodUnion<readonly [z4.ZodLiteral<"SUCCESS">, z4.ZodLiteral<"ACTION_REQUIRED">, z4.ZodLiteral<"CREATED">, z4.ZodLiteral<"WARNING">, z4.ZodLiteral<"AUTHORIZATION_ERROR">, z4.ZodLiteral<"SCHEMA_VALIDATION">, z4.ZodLiteral<"SERVER_ERROR">, z4.ZodLiteral<"UNAUTHORIZED">, z4.ZodLiteral<"INVALID_TOKEN">, z4.ZodLiteral<"NOT_FOUND">, z4.ZodLiteral<"SUCCESS_FILE">, z4.ZodLiteral<"DATABASE_ERROR">]>;
45
+ status: z4.ZodDefault<z4.ZodOptional<z4.ZodNumber>>;
46
+ }, z4.core.$strip>;
47
+ type Input<T = unknown> = z4.infer<typeof InputSchema> & {
48
+ results?: T;
49
+ };
50
+ type Output<T = unknown> = BaseResponse<T>;
51
+ }
52
+ export {};
53
+ }
54
+ export default TypeControllerResponse;
@@ -0,0 +1,39 @@
1
+ import z4 from "zod/v4";
2
+ declare namespace TypeControllerUsuario {
3
+ export const AppEnum: readonly ["service-usuario", "service-financeiro", "service-pages-ai"];
4
+ export const UsuarioTipoEnum: readonly ["padrao"];
5
+ const AppEnumZod: z4.ZodEnum<{
6
+ "service-usuario": "service-usuario";
7
+ "service-financeiro": "service-financeiro";
8
+ "service-pages-ai": "service-pages-ai";
9
+ }>;
10
+ const UsuarioTipoEnumZod: z4.ZodEnum<{
11
+ padrao: "padrao";
12
+ }>;
13
+ type App = z4.infer<typeof AppEnumZod>;
14
+ type UsuarioTipo = z4.infer<typeof UsuarioTipoEnumZod>;
15
+ export interface Auth {
16
+ data: {
17
+ usuario: {
18
+ _id: string;
19
+ email: string;
20
+ nome?: string;
21
+ imagem?: string;
22
+ token?: string;
23
+ data_criacao?: number;
24
+ ativo?: 0 | 1;
25
+ };
26
+ };
27
+ }
28
+ export interface TokenPayload {
29
+ _id: string;
30
+ email: string;
31
+ nome: string;
32
+ data_criacao: number;
33
+ ativo: 1 | 0;
34
+ app: App;
35
+ usuario_tipo: UsuarioTipo;
36
+ }
37
+ export {};
38
+ }
39
+ export default TypeControllerUsuario;
@@ -0,0 +1,20 @@
1
+ import { Context as HonoContext } from "hono";
2
+ import TypeControllerUsuario from "./_usuario";
3
+ import TypeControllerResponse from "./_type_response";
4
+ declare namespace t {
5
+ namespace Controller {
6
+ export import Usuario = TypeControllerUsuario;
7
+ }
8
+ namespace Geral {
9
+ export import Response = TypeControllerResponse;
10
+ }
11
+ interface Context extends HonoContext {
12
+ env: {
13
+ AMBIENTE: "PRODUCAO" | "SANDBOX";
14
+ JSON_WEB_TOKEN_AUTH_USER: string;
15
+ };
16
+ set(key: "usuario_auth", params: TypeControllerUsuario.TokenPayload): TypeControllerUsuario.TokenPayload;
17
+ get(key: "usuario_auth"): TypeControllerUsuario.TokenPayload;
18
+ }
19
+ }
20
+ export default t;
@@ -0,0 +1,41 @@
1
+ import { AxiosResponse } from "axios";
2
+ declare const _api: {
3
+ new (): {};
4
+ servidor_service_usuario: {
5
+ new (): {};
6
+ get "__#private@#axios"(): import("axios").AxiosInstance;
7
+ post({ url, data, setToken }: {
8
+ url: string;
9
+ data: any;
10
+ setToken?: boolean;
11
+ }): Promise<AxiosResponse<any, any, {}>>;
12
+ get({ url, params, setToken }: {
13
+ url: string;
14
+ params?: any;
15
+ setToken?: boolean;
16
+ }): Promise<AxiosResponse<any, any, {}>>;
17
+ patch({ url, data, setToken }: {
18
+ url: string;
19
+ data: any;
20
+ setToken?: boolean;
21
+ }): Promise<AxiosResponse<any, any, {}>>;
22
+ delete({ url }: {
23
+ url: string;
24
+ setToken?: boolean;
25
+ }): Promise<AxiosResponse<any, any, {}>>;
26
+ };
27
+ headers({ setToken }: {
28
+ setToken?: boolean;
29
+ }): {
30
+ headers: {
31
+ Authorization: string;
32
+ "Content-type": string;
33
+ };
34
+ } | {
35
+ headers: {
36
+ "Content-type": string;
37
+ Authorization?: undefined;
38
+ };
39
+ };
40
+ };
41
+ export default _api;
@@ -0,0 +1,11 @@
1
+ declare const _data: {
2
+ new (): {};
3
+ YYYY_MM_DD_00_00_00(newData: string): string;
4
+ DD_MM_YYYY_00_00_00(newData: string): string;
5
+ DD_MM_YYYY_00_00(newData: string): string;
6
+ DD_MM_YYYY(newData: string): string;
7
+ YYYY_MM_DD(newData: string): string;
8
+ DIFERENCA_SEGUNDOS(data: string): number;
9
+ DIFERENCA_DIAS(data: string): number;
10
+ };
11
+ export default _data;
@@ -0,0 +1,11 @@
1
+ declare class _form {
2
+ static regex_cpf_cnpj(value: string): string;
3
+ static formatar_cpf(value: string): string;
4
+ static formatar_cnpj(value: string): string;
5
+ static formatar_cep(value: string): string;
6
+ static formatar_telefone_fixo(value: string): string;
7
+ static formatar_celular(value: string): string;
8
+ static formatar_nome(name: string): string;
9
+ static formatar_reais_br(value: string): string;
10
+ }
11
+ export default _form;
@@ -0,0 +1,9 @@
1
+ declare const geral: {
2
+ new (): {};
3
+ slice_file_name(filename: string, maxLength?: number): string;
4
+ extrair_id(array_enviado: Array<{
5
+ _id?: string;
6
+ }>): string[];
7
+ gerar_id: (length?: number) => string;
8
+ };
9
+ export default geral;
@@ -0,0 +1,8 @@
1
+ declare const _local_storage: {
2
+ new (): {};
3
+ adicionar_item_local_storage(chave: string, novoItem: any): void;
4
+ set_local_storage_sem_incremento(chave: string, novoItem: any): void;
5
+ get_item_local_storage(chave: string): any;
6
+ remover_item_local_storage(chave: string): void;
7
+ };
8
+ export default _local_storage;
@@ -0,0 +1,14 @@
1
+ declare const _session_storage: {
2
+ new (): {};
3
+ adicionar_item_session_storage({ chave, novoItem }: {
4
+ chave: string;
5
+ novoItem: any;
6
+ }): void;
7
+ set_session_storage_sem_incremento({ chave, novoItem }: {
8
+ chave: string;
9
+ novoItem: any;
10
+ }): void;
11
+ get_item_session_storage(chave: string): any;
12
+ remover_item_session_storage(chave: string): void;
13
+ };
14
+ export default _session_storage;
@@ -0,0 +1,21 @@
1
+ type ParamsPadrao = {
2
+ oldArray: any[];
3
+ newItem: any;
4
+ key?: string | "_id" | "id";
5
+ };
6
+ type RemoveArrayItems = {
7
+ oldArray: any[];
8
+ itemsToRemove: any[];
9
+ key?: string | "_id" | "id";
10
+ };
11
+ declare const _update_context: {
12
+ new (): {};
13
+ set_new_item_end: ({ oldArray, newItem, key }: ParamsPadrao) => any;
14
+ update_array_itens: ({ oldArray, newItem, key }: ParamsPadrao) => any;
15
+ remove_array_items: ({ oldArray, itemsToRemove, key }: RemoveArrayItems) => any[];
16
+ compare_arrays({ arrayAntigo, arrayNovo }: {
17
+ arrayAntigo: any;
18
+ arrayNovo: any;
19
+ }): any[];
20
+ };
21
+ export default _update_context;
@@ -0,0 +1,105 @@
1
+ import _form from "./_form";
2
+ declare const utils: {
3
+ new (): {};
4
+ api: {
5
+ new (): {};
6
+ servidor_service_usuario: {
7
+ new (): {};
8
+ get "__#private@#axios"(): import("axios").AxiosInstance;
9
+ post({ url, data, setToken }: {
10
+ url: string;
11
+ data: any;
12
+ setToken?: boolean;
13
+ }): Promise<import("axios").AxiosResponse<any, any, {}>>;
14
+ get({ url, params, setToken }: {
15
+ url: string;
16
+ params?: any;
17
+ setToken?: boolean;
18
+ }): Promise<import("axios").AxiosResponse<any, any, {}>>;
19
+ patch({ url, data, setToken }: {
20
+ url: string;
21
+ data: any;
22
+ setToken?: boolean;
23
+ }): Promise<import("axios").AxiosResponse<any, any, {}>>;
24
+ delete({ url }: {
25
+ url: string;
26
+ setToken?: boolean;
27
+ }): Promise<import("axios").AxiosResponse<any, any, {}>>;
28
+ };
29
+ headers({ setToken }: {
30
+ setToken?: boolean;
31
+ }): {
32
+ headers: {
33
+ Authorization: string;
34
+ "Content-type": string;
35
+ };
36
+ } | {
37
+ headers: {
38
+ "Content-type": string;
39
+ Authorization?: undefined;
40
+ };
41
+ };
42
+ };
43
+ data: {
44
+ new (): {};
45
+ YYYY_MM_DD_00_00_00(newData: string): string;
46
+ DD_MM_YYYY_00_00_00(newData: string): string;
47
+ DD_MM_YYYY_00_00(newData: string): string;
48
+ DD_MM_YYYY(newData: string): string;
49
+ YYYY_MM_DD(newData: string): string;
50
+ DIFERENCA_SEGUNDOS(data: string): number;
51
+ DIFERENCA_DIAS(data: string): number;
52
+ };
53
+ form: typeof _form;
54
+ geral: {
55
+ new (): {};
56
+ slice_file_name(filename: string, maxLength?: number): string;
57
+ extrair_id(array_enviado: Array<{
58
+ _id?: string;
59
+ }>): string[];
60
+ gerar_id: (length?: number) => string;
61
+ };
62
+ local_storage: {
63
+ new (): {};
64
+ adicionar_item_local_storage(chave: string, novoItem: any): void;
65
+ set_local_storage_sem_incremento(chave: string, novoItem: any): void;
66
+ get_item_local_storage(chave: string): any;
67
+ remover_item_local_storage(chave: string): void;
68
+ };
69
+ update_context: {
70
+ new (): {};
71
+ set_new_item_end: ({ oldArray, newItem, key }: {
72
+ oldArray: any[];
73
+ newItem: any;
74
+ key?: string | "_id" | "id";
75
+ }) => any;
76
+ update_array_itens: ({ oldArray, newItem, key }: {
77
+ oldArray: any[];
78
+ newItem: any;
79
+ key?: string | "_id" | "id";
80
+ }) => any;
81
+ remove_array_items: ({ oldArray, itemsToRemove, key }: {
82
+ oldArray: any[];
83
+ itemsToRemove: any[];
84
+ key?: string | "_id" | "id";
85
+ }) => any[];
86
+ compare_arrays({ arrayAntigo, arrayNovo }: {
87
+ arrayAntigo: any;
88
+ arrayNovo: any;
89
+ }): any[];
90
+ };
91
+ session_sorage: {
92
+ new (): {};
93
+ adicionar_item_session_storage({ chave, novoItem }: {
94
+ chave: string;
95
+ novoItem: any;
96
+ }): void;
97
+ set_session_storage_sem_incremento({ chave, novoItem }: {
98
+ chave: string;
99
+ novoItem: any;
100
+ }): void;
101
+ get_item_session_storage(chave: string): any;
102
+ remover_item_session_storage(chave: string): void;
103
+ };
104
+ };
105
+ export default utils;