@navservice/usuario 1.53.0 → 1.56.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,220 @@
1
+ import { InferInsertModel, InferSelectModel } from 'drizzle-orm';
2
+ export declare const schema_usuario: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
3
+ name: "usuario";
4
+ schema: undefined;
5
+ columns: {
6
+ _id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
7
+ name: "_id";
8
+ tableName: "usuario";
9
+ dataType: "string";
10
+ columnType: "SQLiteText";
11
+ data: string;
12
+ driverParam: string;
13
+ notNull: true;
14
+ hasDefault: true;
15
+ isPrimaryKey: true;
16
+ isAutoincrement: false;
17
+ hasRuntimeDefault: true;
18
+ enumValues: [string, ...string[]];
19
+ baseColumn: never;
20
+ identity: undefined;
21
+ generated: undefined;
22
+ }, {}, {
23
+ length: number | undefined;
24
+ }>;
25
+ data_criacao: import("drizzle-orm/sqlite-core").SQLiteColumn<{
26
+ name: "data_criacao";
27
+ tableName: "usuario";
28
+ dataType: "number";
29
+ columnType: "SQLiteInteger";
30
+ data: number;
31
+ driverParam: number;
32
+ notNull: true;
33
+ hasDefault: false;
34
+ isPrimaryKey: false;
35
+ isAutoincrement: false;
36
+ hasRuntimeDefault: false;
37
+ enumValues: undefined;
38
+ baseColumn: never;
39
+ identity: undefined;
40
+ generated: undefined;
41
+ }, {}, {}>;
42
+ data_atualizacao: import("drizzle-orm/sqlite-core").SQLiteColumn<{
43
+ name: "data_atualizacao";
44
+ tableName: "usuario";
45
+ dataType: "number";
46
+ columnType: "SQLiteInteger";
47
+ data: number;
48
+ driverParam: number;
49
+ notNull: false;
50
+ hasDefault: false;
51
+ isPrimaryKey: false;
52
+ isAutoincrement: false;
53
+ hasRuntimeDefault: false;
54
+ enumValues: undefined;
55
+ baseColumn: never;
56
+ identity: undefined;
57
+ generated: undefined;
58
+ }, {}, {}>;
59
+ data_exclusao: import("drizzle-orm/sqlite-core").SQLiteColumn<{
60
+ name: "data_exclusao";
61
+ tableName: "usuario";
62
+ dataType: "number";
63
+ columnType: "SQLiteInteger";
64
+ data: number;
65
+ driverParam: number;
66
+ notNull: false;
67
+ hasDefault: false;
68
+ isPrimaryKey: false;
69
+ isAutoincrement: false;
70
+ hasRuntimeDefault: false;
71
+ enumValues: undefined;
72
+ baseColumn: never;
73
+ identity: undefined;
74
+ generated: undefined;
75
+ }, {}, {}>;
76
+ nome: import("drizzle-orm/sqlite-core").SQLiteColumn<{
77
+ name: "nome";
78
+ tableName: "usuario";
79
+ dataType: "string";
80
+ columnType: "SQLiteText";
81
+ data: string;
82
+ driverParam: string;
83
+ notNull: true;
84
+ hasDefault: false;
85
+ isPrimaryKey: false;
86
+ isAutoincrement: false;
87
+ hasRuntimeDefault: false;
88
+ enumValues: [string, ...string[]];
89
+ baseColumn: never;
90
+ identity: undefined;
91
+ generated: undefined;
92
+ }, {}, {
93
+ length: number | undefined;
94
+ }>;
95
+ email: import("drizzle-orm/sqlite-core").SQLiteColumn<{
96
+ name: "email";
97
+ tableName: "usuario";
98
+ dataType: "string";
99
+ columnType: "SQLiteText";
100
+ data: string;
101
+ driverParam: string;
102
+ notNull: true;
103
+ hasDefault: false;
104
+ isPrimaryKey: false;
105
+ isAutoincrement: false;
106
+ hasRuntimeDefault: false;
107
+ enumValues: [string, ...string[]];
108
+ baseColumn: never;
109
+ identity: undefined;
110
+ generated: undefined;
111
+ }, {}, {
112
+ length: number | undefined;
113
+ }>;
114
+ senha: import("drizzle-orm/sqlite-core").SQLiteColumn<{
115
+ name: "senha";
116
+ tableName: "usuario";
117
+ dataType: "string";
118
+ columnType: "SQLiteText";
119
+ data: string;
120
+ driverParam: string;
121
+ notNull: false;
122
+ hasDefault: false;
123
+ isPrimaryKey: false;
124
+ isAutoincrement: false;
125
+ hasRuntimeDefault: false;
126
+ enumValues: [string, ...string[]];
127
+ baseColumn: never;
128
+ identity: undefined;
129
+ generated: undefined;
130
+ }, {}, {
131
+ length: number | undefined;
132
+ }>;
133
+ imagem: import("drizzle-orm/sqlite-core").SQLiteColumn<{
134
+ name: "imagem";
135
+ tableName: "usuario";
136
+ dataType: "string";
137
+ columnType: "SQLiteText";
138
+ data: string;
139
+ driverParam: string;
140
+ notNull: false;
141
+ hasDefault: false;
142
+ isPrimaryKey: false;
143
+ isAutoincrement: false;
144
+ hasRuntimeDefault: false;
145
+ enumValues: [string, ...string[]];
146
+ baseColumn: never;
147
+ identity: undefined;
148
+ generated: undefined;
149
+ }, {}, {
150
+ length: number | undefined;
151
+ }>;
152
+ auth_google: import("drizzle-orm/sqlite-core").SQLiteColumn<{
153
+ name: "auth_google";
154
+ tableName: "usuario";
155
+ dataType: "number";
156
+ columnType: "SQLiteInteger";
157
+ data: 0 | 1;
158
+ driverParam: number;
159
+ notNull: true;
160
+ hasDefault: true;
161
+ isPrimaryKey: false;
162
+ isAutoincrement: false;
163
+ hasRuntimeDefault: false;
164
+ enumValues: undefined;
165
+ baseColumn: never;
166
+ identity: undefined;
167
+ generated: undefined;
168
+ }, {}, {
169
+ $type: 0 | 1;
170
+ }>;
171
+ excluido: import("drizzle-orm/sqlite-core").SQLiteColumn<{
172
+ name: "excluido";
173
+ tableName: "usuario";
174
+ dataType: "number";
175
+ columnType: "SQLiteInteger";
176
+ data: 0 | 1;
177
+ driverParam: number;
178
+ notNull: true;
179
+ hasDefault: true;
180
+ isPrimaryKey: false;
181
+ isAutoincrement: false;
182
+ hasRuntimeDefault: false;
183
+ enumValues: undefined;
184
+ baseColumn: never;
185
+ identity: undefined;
186
+ generated: undefined;
187
+ }, {}, {
188
+ $type: 0 | 1;
189
+ }>;
190
+ ativo: import("drizzle-orm/sqlite-core").SQLiteColumn<{
191
+ name: "ativo";
192
+ tableName: "usuario";
193
+ dataType: "number";
194
+ columnType: "SQLiteInteger";
195
+ data: 0 | 1;
196
+ driverParam: number;
197
+ notNull: true;
198
+ hasDefault: true;
199
+ isPrimaryKey: false;
200
+ isAutoincrement: false;
201
+ hasRuntimeDefault: false;
202
+ enumValues: undefined;
203
+ baseColumn: never;
204
+ identity: undefined;
205
+ generated: undefined;
206
+ }, {}, {
207
+ $type: 0 | 1;
208
+ }>;
209
+ };
210
+ dialect: "sqlite";
211
+ }>;
212
+ export type Base = InferSelectModel<typeof schema_usuario>;
213
+ export type Criar = InferInsertModel<typeof schema_usuario>;
214
+ export type BuscarPeloFiltro = Partial<Pick<InferSelectModel<typeof schema_usuario>, "_id" | "nome" | "email" | "ativo" | "excluido">> & {
215
+ pagina: number;
216
+ };
217
+ export type AtualizarPeloId = Pick<InferSelectModel<typeof schema_usuario>, "_id"> & Partial<Pick<InferSelectModel<typeof schema_usuario>, "nome" | "email" | "senha" | "imagem" | "auth_google" | "ativo" | "excluido" | "data_atualizacao">>;
218
+ export type BuscarPeloId = Pick<InferSelectModel<typeof schema_usuario>, "_id">;
219
+ export type DeletarPeloId = Pick<InferSelectModel<typeof schema_usuario>, "_id">;
220
+ export default schema_usuario;
@@ -3,5 +3,5 @@ interface TypeRefreshToken {
3
3
  app: TypesCore.Controller.Usuario.TokenPayload["app"];
4
4
  usuario_tipo: TypesCore.Controller.Usuario.TokenPayload["usuario_tipo"];
5
5
  }
6
- export declare function RefreshToken(props: TypeRefreshToken): import("react/jsx-runtime").JSX.Element;
6
+ export declare function RefreshToken({ app, usuario_tipo }: TypeRefreshToken): import("react/jsx-runtime").JSX.Element;
7
7
  export {};
package/build/es/index.js CHANGED
@@ -2196,13 +2196,15 @@ const lib_axios = axios;
2196
2196
  "FREE",
2197
2197
  "ESSENTIAL",
2198
2198
  "BUSINESS",
2199
- "ULTIMATE"
2199
+ "ENTERPRISE"
2200
2200
  ];
2201
2201
  TypeControllerUsuario.AppEnum = [
2202
2202
  "service-usuario",
2203
2203
  "service-pages",
2204
2204
  "service-assinatura",
2205
- "service-bucket"
2205
+ "service-bucket",
2206
+ "service-galio",
2207
+ "service-oraculo"
2206
2208
  ];
2207
2209
  TypeControllerUsuario.AssinaturaStatusEnum = [
2208
2210
  "active",
@@ -2227,6 +2229,12 @@ const lib_axios = axios;
2227
2229
  "service-pages": [
2228
2230
  "padrao"
2229
2231
  ],
2232
+ "service-galio": [
2233
+ "padrao"
2234
+ ],
2235
+ "service-oraculo": [
2236
+ "padrao"
2237
+ ],
2230
2238
  "service-bucket": [
2231
2239
  "padrao"
2232
2240
  ]
@@ -2271,7 +2279,11 @@ var _usuario_TypeControllerUsuario;
2271
2279
  v4.literal("INVALID_TOKEN"),
2272
2280
  v4.literal("NOT_FOUND"),
2273
2281
  v4.literal("SUCCESS_FILE"),
2274
- v4.literal("DATABASE_ERROR")
2282
+ v4.literal("DATABASE_ERROR"),
2283
+ v4.literal("BUSINESS_RULE_VIOLATION"),
2284
+ v4.literal("PLAN_FORBIDDEN"),
2285
+ v4.literal("INTEGRATION_ERROR"),
2286
+ v4.literal("TOKEN_AUTH_USER")
2275
2287
  ]);
2276
2288
  v4.object({
2277
2289
  status: StatusSchema,
@@ -2293,6 +2305,7 @@ var _usuario_TypeControllerUsuario;
2293
2305
  v4.object({
2294
2306
  status: StatusSchema,
2295
2307
  message: v4.string().optional(),
2308
+ fn: v4.string(),
2296
2309
  file_buffer: v4.union([
2297
2310
  v4["instanceof"](Blob),
2298
2311
  v4["instanceof"](ArrayBuffer),
@@ -2884,6 +2897,39 @@ class _hooks {
2884
2897
  localStorage.setItem("theme", "light");
2885
2898
  }
2886
2899
  }
2900
+ use_set_show_component() {
2901
+ function aplicarVisibilidadeElemento(el) {
2902
+ const valor = el.getAttribute("set-show-component");
2903
+ if ("ocultar" === valor) el.style.display = "none";
2904
+ else if ("exibir" === valor) el.style.display = "";
2905
+ }
2906
+ function aplicarVisibilidade(node = document) {
2907
+ const elementos = node.querySelectorAll("[set-show-component]");
2908
+ elementos.forEach(aplicarVisibilidadeElemento);
2909
+ }
2910
+ document.addEventListener("DOMContentLoaded", ()=>{
2911
+ aplicarVisibilidade();
2912
+ const observer = new MutationObserver((mutations)=>{
2913
+ mutations.forEach((mutation)=>{
2914
+ mutation.addedNodes.forEach((node)=>{
2915
+ if (node instanceof HTMLElement) {
2916
+ if (node.hasAttribute("set-show-component")) aplicarVisibilidadeElemento(node);
2917
+ aplicarVisibilidade(node);
2918
+ }
2919
+ });
2920
+ if ("attributes" === mutation.type && mutation.target instanceof HTMLElement && "set-show-component" === mutation.attributeName) aplicarVisibilidadeElemento(mutation.target);
2921
+ });
2922
+ });
2923
+ observer.observe(document.body, {
2924
+ childList: true,
2925
+ subtree: true,
2926
+ attributes: true,
2927
+ attributeFilter: [
2928
+ "set-show-component"
2929
+ ]
2930
+ });
2931
+ });
2932
+ }
2887
2933
  }
2888
2934
  const utils_hooks = new _hooks;
2889
2935
  const _environment = class {
@@ -2931,7 +2977,8 @@ const type_controller_usuario_input = (meta)=>JSON.stringify(meta);
2931
2977
  ativo: v4.union([
2932
2978
  v4.literal(0),
2933
2979
  v4.literal(1)
2934
- ])
2980
+ ]),
2981
+ imagem: v4.string()
2935
2982
  });
2936
2983
  (function(Register) {
2937
2984
  Register.route = "/api/usuario/auth/register";
@@ -3154,7 +3201,7 @@ var type_controller_authenticator_TypeControlerAutheticator;
3154
3201
  })
3155
3202
  });
3156
3203
  (function(EnviarCodigoOtp) {
3157
- EnviarCodigoOtp.route = "/usuario/auth/enviar_codigo_verificacao_otp";
3204
+ EnviarCodigoOtp.route = "/api/usuario/auth/enviar_codigo_verificacao_otp";
3158
3205
  EnviarCodigoOtp.InputSchema = v4.object({
3159
3206
  data: v4.object({
3160
3207
  codigo_verificacao_otp: v4.object({
@@ -3179,7 +3226,7 @@ var type_controller_authenticator_TypeControlerAutheticator;
3179
3226
  });
3180
3227
  })(TypeControllerCodigoOtp.EnviarCodigoOtp || (TypeControllerCodigoOtp.EnviarCodigoOtp = {}));
3181
3228
  (function(EntrarComCodigoOtp) {
3182
- EntrarComCodigoOtp.route = "/usuario/auth/entrar_com_codigo_otp";
3229
+ EntrarComCodigoOtp.route = "/api/usuario/auth/entrar_com_codigo_otp";
3183
3230
  EntrarComCodigoOtp.InputSchema = v4.object({
3184
3231
  data: v4.object({
3185
3232
  codigo_verificacao_otp: v4.object({
@@ -7891,63 +7938,31 @@ const VerificarAuthenticator = ()=>{
7891
7938
  });
7892
7939
  };
7893
7940
  const REFRESH_INTERVAL = 3300000;
7894
- const REFRESH_STORAGE_KEY = "last_refresh_token_at";
7895
- const REFRESH_LOCK_KEY = "refresh_token_lock";
7896
- const LOCK_DURATION = 10000;
7897
- function RefreshToken_RefreshToken(props) {
7941
+ function RefreshToken_RefreshToken({ app, usuario_tipo }) {
7898
7942
  const isRefreshingRef = useRef(false);
7899
- const intervalRef = useRef(null);
7900
- function getSafeTimestamp(key) {
7901
- const value1 = src_utils.session_sorage.get_item_session_storage(key);
7902
- return value1 && !isNaN(Number(value1)) ? Number(value1) : 0;
7903
- }
7904
- function setSafeTimestamp(key, value1) {
7905
- src_utils.session_sorage.set_session_storage_sem_incremento({
7906
- chave: key,
7907
- novoItem: value1.toString()
7908
- });
7909
- }
7910
- function checkAuthentication() {
7911
- const usuario = src_utils.session_sorage.usuario_auth;
7912
- if (!usuario?.data?.usuario?._id || !usuario?.data?.usuario?.refresh_token) {
7913
- contexto_contexto_usuario.contexto.state.set_signout();
7914
- return false;
7915
- }
7916
- return true;
7917
- }
7918
7943
  async function handleRefreshToken() {
7919
- if (!checkAuthentication() || isRefreshingRef.current) return;
7944
+ if (isRefreshingRef.current) return;
7945
+ const usuario = src_utils.session_sorage.usuario_auth?.data?.usuario;
7946
+ if (!usuario?._id || !usuario?.refresh_token) return void contexto_contexto_usuario.contexto.state.set_signout();
7947
+ isRefreshingRef.current = true;
7920
7948
  try {
7921
- const usuario = src_utils.session_sorage.usuario_auth?.data?.usuario;
7922
- const now = Date.now();
7923
- const lastRefresh = getSafeTimestamp(REFRESH_STORAGE_KEY);
7924
- const lock = getSafeTimestamp(REFRESH_LOCK_KEY);
7925
- if (lastRefresh && now - lastRefresh < REFRESH_INTERVAL) return;
7926
- if (lock && now - lock < LOCK_DURATION) return;
7927
- setSafeTimestamp(REFRESH_LOCK_KEY, now);
7928
- isRefreshingRef.current = true;
7929
- const response = await contexto_contexto_usuario.api.refresh_token({
7949
+ await contexto_contexto_usuario.api.refresh_token({
7930
7950
  data: {
7931
7951
  usuario: {
7932
- app: props.app,
7933
- usuario_tipo: props.usuario_tipo,
7952
+ app,
7953
+ usuario_tipo,
7934
7954
  refresh_token: usuario.refresh_token
7935
7955
  }
7936
7956
  }
7937
7957
  });
7938
- if (response?.data?.status === 200) setSafeTimestamp(REFRESH_STORAGE_KEY, now);
7939
7958
  } finally{
7940
7959
  isRefreshingRef.current = false;
7941
- setSafeTimestamp(REFRESH_LOCK_KEY, 0);
7942
7960
  }
7943
7961
  }
7944
7962
  useEffect(()=>{
7945
- if (!checkAuthentication()) return;
7946
7963
  handleRefreshToken();
7947
- intervalRef.current = setInterval(handleRefreshToken, REFRESH_INTERVAL);
7948
- return ()=>{
7949
- if (intervalRef.current) clearInterval(intervalRef.current);
7950
- };
7964
+ const interval = setInterval(handleRefreshToken, REFRESH_INTERVAL);
7965
+ return ()=>clearInterval(interval);
7951
7966
  }, []);
7952
7967
  return /*#__PURE__*/ jsx(Fragment, {});
7953
7968
  }
@@ -10,7 +10,7 @@ declare namespace TypeControllerCodigoOtp {
10
10
  codigo: z4.ZodString;
11
11
  }, z4.core.$strip>;
12
12
  namespace EnviarCodigoOtp {
13
- const route: "/usuario/auth/enviar_codigo_verificacao_otp";
13
+ const route: "/api/usuario/auth/enviar_codigo_verificacao_otp";
14
14
  const InputSchema: z4.ZodObject<{
15
15
  data: z4.ZodObject<{
16
16
  codigo_verificacao_otp: z4.ZodObject<{
@@ -35,7 +35,7 @@ declare namespace TypeControllerCodigoOtp {
35
35
  type Response = AxiosResponse<t.Geral.Response.C.Output<Output>>;
36
36
  }
37
37
  namespace EntrarComCodigoOtp {
38
- const route: "/usuario/auth/entrar_com_codigo_otp";
38
+ const route: "/api/usuario/auth/entrar_com_codigo_otp";
39
39
  const InputSchema: z4.ZodObject<{
40
40
  data: z4.ZodObject<{
41
41
  codigo_verificacao_otp: z4.ZodObject<{
@@ -49,6 +49,8 @@ declare namespace TypeControllerCodigoOtp {
49
49
  "service-pages": "service-pages";
50
50
  "service-assinatura": "service-assinatura";
51
51
  "service-bucket": "service-bucket";
52
+ "service-galio": "service-galio";
53
+ "service-oraculo": "service-oraculo";
52
54
  }>;
53
55
  }, z4.core.$strip>;
54
56
  }, z4.core.$strip>;
@@ -15,6 +15,7 @@ declare namespace TypeControllerUsuario {
15
15
  auth_google: z4.ZodUnion<readonly [z4.ZodLiteral<0>, z4.ZodLiteral<1>]>;
16
16
  excluido: z4.ZodUnion<readonly [z4.ZodLiteral<0>, z4.ZodLiteral<1>]>;
17
17
  ativo: z4.ZodUnion<readonly [z4.ZodLiteral<0>, z4.ZodLiteral<1>]>;
18
+ imagem: z4.ZodString;
18
19
  }, z4.core.$strip>;
19
20
  type UsuarioBase = z4.infer<typeof UsuarioBaseSchema>;
20
21
  export namespace Register {
@@ -35,6 +36,8 @@ declare namespace TypeControllerUsuario {
35
36
  "service-pages": "service-pages";
36
37
  "service-assinatura": "service-assinatura";
37
38
  "service-bucket": "service-bucket";
39
+ "service-galio": "service-galio";
40
+ "service-oraculo": "service-oraculo";
38
41
  }>;
39
42
  }, z4.core.$strip>;
40
43
  }, z4.core.$strip>;
@@ -57,6 +60,8 @@ declare namespace TypeControllerUsuario {
57
60
  "service-pages": "service-pages";
58
61
  "service-assinatura": "service-assinatura";
59
62
  "service-bucket": "service-bucket";
63
+ "service-galio": "service-galio";
64
+ "service-oraculo": "service-oraculo";
60
65
  }>;
61
66
  codigo_temporario: z4.ZodOptional<z4.ZodNullable<z4.ZodString>>;
62
67
  }, z4.core.$strip>;
@@ -82,6 +87,8 @@ declare namespace TypeControllerUsuario {
82
87
  "service-pages": "service-pages";
83
88
  "service-assinatura": "service-assinatura";
84
89
  "service-bucket": "service-bucket";
90
+ "service-galio": "service-galio";
91
+ "service-oraculo": "service-oraculo";
85
92
  }>;
86
93
  }, z4.core.$strip>;
87
94
  }, z4.core.$strip>;
@@ -104,6 +111,8 @@ declare namespace TypeControllerUsuario {
104
111
  "service-pages": "service-pages";
105
112
  "service-assinatura": "service-assinatura";
106
113
  "service-bucket": "service-bucket";
114
+ "service-galio": "service-galio";
115
+ "service-oraculo": "service-oraculo";
107
116
  }>;
108
117
  }, z4.core.$strip>;
109
118
  }, z4.core.$strip>;
@@ -44,6 +44,7 @@ declare namespace t {
44
44
  };
45
45
  Variables: {
46
46
  usuario_auth: TypesCore.Controller.Usuario.TokenPayload;
47
+ token: string;
47
48
  };
48
49
  };
49
50
  type Context = HonoContext<Env>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navservice/usuario",
3
- "version": "1.53.0",
3
+ "version": "1.56.0",
4
4
  "description": "Service de autenticação de usuários unificado",
5
5
  "type": "module",
6
6
  "main": "./build/lib/index.js",