@navservice/usuario 1.6.0 → 1.9.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 +144 -46
- package/package.json +1 -1
package/build/es/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
2
|
import { create as external_zustand_create } from "zustand";
|
|
3
3
|
import { immer } from "zustand/middleware/immer";
|
|
4
|
-
import react, { createElement, forwardRef, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
5
4
|
import v4 from "zod/v4";
|
|
5
|
+
import react, { createElement, forwardRef, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { QRCodeSVG } from "qrcode.react";
|
|
8
8
|
import { GoogleLogin, GoogleOAuthProvider } from "@react-oauth/google";
|
|
@@ -2184,16 +2184,123 @@ axios.getAdapter = adapters_adapters.getAdapter;
|
|
|
2184
2184
|
axios.HttpStatusCode = helpers_HttpStatusCode;
|
|
2185
2185
|
axios.default = axios;
|
|
2186
2186
|
const lib_axios = axios;
|
|
2187
|
-
class
|
|
2187
|
+
class es_config_env {
|
|
2188
2188
|
static SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL;
|
|
2189
2189
|
static init(config) {
|
|
2190
|
-
|
|
2190
|
+
es_config_env.SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL = config.SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL;
|
|
2191
2191
|
}
|
|
2192
2192
|
static get PUBLIC_BASE_URL_BACKEND_PRINCIPAL() {
|
|
2193
|
-
return this.SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL;
|
|
2193
|
+
return this.SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL?.trim();
|
|
2194
2194
|
}
|
|
2195
2195
|
}
|
|
2196
|
-
const
|
|
2196
|
+
const es_src_config_env = es_config_env;
|
|
2197
|
+
(function(TypeControllerUsuario) {
|
|
2198
|
+
TypeControllerUsuario.AppEnum = [
|
|
2199
|
+
"service-usuario",
|
|
2200
|
+
"service-financeiro",
|
|
2201
|
+
"service-pages-ai"
|
|
2202
|
+
];
|
|
2203
|
+
TypeControllerUsuario.UsuarioTipoEnum = [
|
|
2204
|
+
"padrao"
|
|
2205
|
+
];
|
|
2206
|
+
v4["enum"]([
|
|
2207
|
+
"service-usuario",
|
|
2208
|
+
"service-financeiro",
|
|
2209
|
+
"service-pages-ai"
|
|
2210
|
+
]);
|
|
2211
|
+
v4["enum"](TypeControllerUsuario.UsuarioTipoEnum);
|
|
2212
|
+
})(_usuario_TypeControllerUsuario || (_usuario_TypeControllerUsuario = {}));
|
|
2213
|
+
const _usuario = _usuario_TypeControllerUsuario;
|
|
2214
|
+
var _usuario_TypeControllerUsuario;
|
|
2215
|
+
(function(TypeControllerResponse) {
|
|
2216
|
+
const StatusSchema = v4.union([
|
|
2217
|
+
v4.literal(200),
|
|
2218
|
+
v4.literal(201),
|
|
2219
|
+
v4.literal(202),
|
|
2220
|
+
v4.literal(204),
|
|
2221
|
+
v4.literal(400),
|
|
2222
|
+
v4.literal(401),
|
|
2223
|
+
v4.literal(403),
|
|
2224
|
+
v4.literal(404),
|
|
2225
|
+
v4.literal(409),
|
|
2226
|
+
v4.literal(422),
|
|
2227
|
+
v4.literal(500),
|
|
2228
|
+
v4.literal(428),
|
|
2229
|
+
v4.literal(405)
|
|
2230
|
+
]);
|
|
2231
|
+
const TypeSchema = v4.union([
|
|
2232
|
+
v4.literal("success"),
|
|
2233
|
+
v4.literal("warning"),
|
|
2234
|
+
v4.literal("error")
|
|
2235
|
+
]).default("success");
|
|
2236
|
+
const CodeSchema = v4.union([
|
|
2237
|
+
v4.literal("SUCCESS"),
|
|
2238
|
+
v4.literal("ACTION_REQUIRED"),
|
|
2239
|
+
v4.literal("CREATED"),
|
|
2240
|
+
v4.literal("WARNING"),
|
|
2241
|
+
v4.literal("AUTHORIZATION_ERROR"),
|
|
2242
|
+
v4.literal("SCHEMA_VALIDATION"),
|
|
2243
|
+
v4.literal("SERVER_ERROR"),
|
|
2244
|
+
v4.literal("UNAUTHORIZED"),
|
|
2245
|
+
v4.literal("INVALID_TOKEN"),
|
|
2246
|
+
v4.literal("NOT_FOUND"),
|
|
2247
|
+
v4.literal("SUCCESS_FILE"),
|
|
2248
|
+
v4.literal("DATABASE_ERROR")
|
|
2249
|
+
]);
|
|
2250
|
+
v4.object({
|
|
2251
|
+
status: StatusSchema,
|
|
2252
|
+
code: CodeSchema,
|
|
2253
|
+
type: TypeSchema,
|
|
2254
|
+
message: v4.string(),
|
|
2255
|
+
results: v4.unknown().optional(),
|
|
2256
|
+
error: v4.unknown().optional()
|
|
2257
|
+
});
|
|
2258
|
+
(function(C) {
|
|
2259
|
+
C.InputSchema = v4.object({
|
|
2260
|
+
status: StatusSchema,
|
|
2261
|
+
code: CodeSchema,
|
|
2262
|
+
type: TypeSchema.optional().default("success"),
|
|
2263
|
+
message: v4.string().optional(),
|
|
2264
|
+
results: v4.any(),
|
|
2265
|
+
c: v4.custom()
|
|
2266
|
+
});
|
|
2267
|
+
v4.object({
|
|
2268
|
+
status: StatusSchema,
|
|
2269
|
+
message: v4.string().optional(),
|
|
2270
|
+
file_buffer: v4.union([
|
|
2271
|
+
v4["instanceof"](Blob),
|
|
2272
|
+
v4["instanceof"](ArrayBuffer),
|
|
2273
|
+
v4["instanceof"](Uint8Array)
|
|
2274
|
+
]),
|
|
2275
|
+
content_type: v4.string(),
|
|
2276
|
+
filename: v4.string().optional(),
|
|
2277
|
+
c: v4.custom().optional()
|
|
2278
|
+
});
|
|
2279
|
+
})(TypeControllerResponse.C || (TypeControllerResponse.C = {}));
|
|
2280
|
+
(function(Error1) {
|
|
2281
|
+
Error1.InputSchema = v4.object({
|
|
2282
|
+
message: v4.string().optional(),
|
|
2283
|
+
results: v4.union([
|
|
2284
|
+
v4.array(v4.unknown()),
|
|
2285
|
+
v4.unknown()
|
|
2286
|
+
]).optional(),
|
|
2287
|
+
type: TypeSchema.optional().default("success"),
|
|
2288
|
+
code: CodeSchema,
|
|
2289
|
+
status: v4.number().optional().default(200)
|
|
2290
|
+
});
|
|
2291
|
+
})(TypeControllerResponse.Error || (TypeControllerResponse.Error = {}));
|
|
2292
|
+
})(_type_response_TypeControllerResponse || (_type_response_TypeControllerResponse = {}));
|
|
2293
|
+
const _type_response = _type_response_TypeControllerResponse;
|
|
2294
|
+
var _type_response_TypeControllerResponse;
|
|
2295
|
+
(function(t) {
|
|
2296
|
+
(function(Controller) {
|
|
2297
|
+
Controller.Usuario = _usuario;
|
|
2298
|
+
})(t.Controller || (t.Controller = {}));
|
|
2299
|
+
(function(Geral) {
|
|
2300
|
+
Geral.Response = _type_response;
|
|
2301
|
+
})(t.Geral || (t.Geral = {}));
|
|
2302
|
+
})(types_t || (types_t = {}));
|
|
2303
|
+
var types_t;
|
|
2197
2304
|
const _session_storage = class {
|
|
2198
2305
|
static adicionar_item_session_storage({ chave, novoItem }) {
|
|
2199
2306
|
try {
|
|
@@ -2236,10 +2343,10 @@ const _session_storage = class {
|
|
|
2236
2343
|
};
|
|
2237
2344
|
const utils_session_storage = _session_storage;
|
|
2238
2345
|
const _api_api = class _api {
|
|
2239
|
-
static
|
|
2346
|
+
static servidor_pricipal = class {
|
|
2240
2347
|
static get #axios() {
|
|
2241
2348
|
return lib_axios.create({
|
|
2242
|
-
baseURL:
|
|
2349
|
+
baseURL: es_src_config_env.PUBLIC_BASE_URL_BACKEND_PRINCIPAL
|
|
2243
2350
|
});
|
|
2244
2351
|
}
|
|
2245
2352
|
static async post({ url, data, setToken = true }) {
|
|
@@ -2250,12 +2357,7 @@ const _api_api = class _api {
|
|
|
2250
2357
|
static async get({ url, params, setToken = true }) {
|
|
2251
2358
|
const queryParams = new URLSearchParams();
|
|
2252
2359
|
if (params) Object.entries(params).forEach(([key, value1])=>{
|
|
2253
|
-
|
|
2254
|
-
if (null != value1) {
|
|
2255
|
-
console.log('14');
|
|
2256
|
-
queryParams.append(key, value1);
|
|
2257
|
-
console.log('15');
|
|
2258
|
-
}
|
|
2360
|
+
if (null != value1) queryParams.append(key, value1);
|
|
2259
2361
|
});
|
|
2260
2362
|
const queryString = queryParams.toString();
|
|
2261
2363
|
const fullUrl = queryString ? `${url}?${queryString}` : url;
|
|
@@ -2704,7 +2806,7 @@ class _hooks {
|
|
|
2704
2806
|
}
|
|
2705
2807
|
}
|
|
2706
2808
|
const utils_hooks = new _hooks;
|
|
2707
|
-
const
|
|
2809
|
+
const es_utils = {
|
|
2708
2810
|
api: utils_api,
|
|
2709
2811
|
data: utils_data,
|
|
2710
2812
|
form: utils_form,
|
|
@@ -2715,7 +2817,7 @@ const utils_utils = {
|
|
|
2715
2817
|
sistema: utils_sistema,
|
|
2716
2818
|
hooks: utils_hooks
|
|
2717
2819
|
};
|
|
2718
|
-
const src_utils =
|
|
2820
|
+
const src_utils = es_utils;
|
|
2719
2821
|
const type_controller_usuario_input = (meta)=>JSON.stringify(meta);
|
|
2720
2822
|
(function(TypeControllerUsuario) {
|
|
2721
2823
|
TypeControllerUsuario.AppEnum = [
|
|
@@ -3112,9 +3214,9 @@ var type_response_TypeControllerResponse;
|
|
|
3112
3214
|
(function(Geral) {
|
|
3113
3215
|
Geral.Response = type_response;
|
|
3114
3216
|
})(t.Geral || (t.Geral = {}));
|
|
3115
|
-
})(
|
|
3116
|
-
const
|
|
3117
|
-
var
|
|
3217
|
+
})(shared_types_t || (shared_types_t = {}));
|
|
3218
|
+
const shared_types = shared_types_t;
|
|
3219
|
+
var shared_types_t;
|
|
3118
3220
|
const store = external_zustand_create()(immer((set)=>({
|
|
3119
3221
|
states: {
|
|
3120
3222
|
user: src_utils.session_sorage.get_item_session_storage("auth_user"),
|
|
@@ -3127,10 +3229,9 @@ const contexto_usuario_contexto_usuario = class contexto_usuario {
|
|
|
3127
3229
|
static async register(props) {
|
|
3128
3230
|
try {
|
|
3129
3231
|
contexto_usuario.contexto.state.set_loading(true);
|
|
3130
|
-
const response = await src_utils.api.
|
|
3131
|
-
url:
|
|
3132
|
-
data: props
|
|
3133
|
-
setToken: false
|
|
3232
|
+
const response = await src_utils.api.servidor_pricipal.post({
|
|
3233
|
+
url: shared_types.Controller.Usuario.Register.route,
|
|
3234
|
+
data: props
|
|
3134
3235
|
});
|
|
3135
3236
|
if (response?.data?.results) contexto_usuario.contexto.state.set_user(response?.data?.results);
|
|
3136
3237
|
return response;
|
|
@@ -3143,10 +3244,9 @@ const contexto_usuario_contexto_usuario = class contexto_usuario {
|
|
|
3143
3244
|
static async login(props) {
|
|
3144
3245
|
try {
|
|
3145
3246
|
contexto_usuario.contexto.state.set_loading(true);
|
|
3146
|
-
const response = await src_utils.api.
|
|
3147
|
-
url:
|
|
3148
|
-
data: props
|
|
3149
|
-
setToken: false
|
|
3247
|
+
const response = await src_utils.api.servidor_pricipal.post({
|
|
3248
|
+
url: shared_types.Controller.Usuario.Login.route,
|
|
3249
|
+
data: props
|
|
3150
3250
|
});
|
|
3151
3251
|
if (response?.data?.status == 200) contexto_usuario.contexto.state.set_user(response?.data?.results);
|
|
3152
3252
|
return response;
|
|
@@ -3159,10 +3259,9 @@ const contexto_usuario_contexto_usuario = class contexto_usuario {
|
|
|
3159
3259
|
static async entrar_com_codigo_otp(props) {
|
|
3160
3260
|
try {
|
|
3161
3261
|
contexto_usuario.contexto.state.set_loading(true);
|
|
3162
|
-
const response = await src_utils.api.
|
|
3163
|
-
url:
|
|
3164
|
-
data: props
|
|
3165
|
-
setToken: false
|
|
3262
|
+
const response = await src_utils.api.servidor_pricipal.post({
|
|
3263
|
+
url: shared_types.Controller.CodigoOtp.EntrarComCodigoOtp.rota,
|
|
3264
|
+
data: props
|
|
3166
3265
|
});
|
|
3167
3266
|
response.config;
|
|
3168
3267
|
if (response?.data?.results) contexto_usuario.contexto.state.set_user(response?.data?.results);
|
|
@@ -3176,10 +3275,9 @@ const contexto_usuario_contexto_usuario = class contexto_usuario {
|
|
|
3176
3275
|
static async login_register_google(props) {
|
|
3177
3276
|
try {
|
|
3178
3277
|
contexto_usuario.contexto.state.set_loading(true);
|
|
3179
|
-
const response = await src_utils.api.
|
|
3180
|
-
url:
|
|
3181
|
-
data: props
|
|
3182
|
-
setToken: false
|
|
3278
|
+
const response = await src_utils.api.servidor_pricipal.post({
|
|
3279
|
+
url: shared_types.Controller.Usuario.RegisterLoginGoogle.route,
|
|
3280
|
+
data: props
|
|
3183
3281
|
});
|
|
3184
3282
|
if (response?.data?.results) contexto_usuario.contexto.state.set_user(response?.data?.results);
|
|
3185
3283
|
} catch (error) {
|
|
@@ -3642,8 +3740,8 @@ const AuthAtivarDesativarAuthenticator = ()=>{
|
|
|
3642
3740
|
async function buscar_authenticator() {
|
|
3643
3741
|
try {
|
|
3644
3742
|
setCarregando(true);
|
|
3645
|
-
const response = await src_utils.api.
|
|
3646
|
-
url:
|
|
3743
|
+
const response = await src_utils.api.servidor_pricipal.get({
|
|
3744
|
+
url: shared_types.Controller.Autheticator.BuscarAuthenticatorPeloId.route
|
|
3647
3745
|
});
|
|
3648
3746
|
if (response?.data?.type !== "success") return;
|
|
3649
3747
|
if (!response?.data?.results) return;
|
|
@@ -3654,8 +3752,8 @@ const AuthAtivarDesativarAuthenticator = ()=>{
|
|
|
3654
3752
|
}
|
|
3655
3753
|
async function desativarAuthenticator() {
|
|
3656
3754
|
setCarregando(true);
|
|
3657
|
-
await src_utils.api.
|
|
3658
|
-
url:
|
|
3755
|
+
await src_utils.api.servidor_pricipal.post({
|
|
3756
|
+
url: shared_types.Controller.Autheticator.DesativarAuthenticatorCode.route,
|
|
3659
3757
|
data: {}
|
|
3660
3758
|
});
|
|
3661
3759
|
await buscar_authenticator();
|
|
@@ -3672,8 +3770,8 @@ const AuthAtivarDesativarAuthenticator = ()=>{
|
|
|
3672
3770
|
}
|
|
3673
3771
|
}
|
|
3674
3772
|
};
|
|
3675
|
-
const resp = await src_utils.api.
|
|
3676
|
-
url:
|
|
3773
|
+
const resp = await src_utils.api.servidor_pricipal.post({
|
|
3774
|
+
url: shared_types.Controller.Autheticator.GerarAutheticatorCode.route,
|
|
3677
3775
|
data,
|
|
3678
3776
|
setToken: true
|
|
3679
3777
|
});
|
|
@@ -3704,7 +3802,7 @@ const AuthAtivarDesativarAuthenticator = ()=>{
|
|
|
3704
3802
|
}
|
|
3705
3803
|
}
|
|
3706
3804
|
};
|
|
3707
|
-
const resp = await src_utils.api.
|
|
3805
|
+
const resp = await src_utils.api.servidor_pricipal.post({
|
|
3708
3806
|
url: "/usuario/auth/ativar_autheticator_code",
|
|
3709
3807
|
data,
|
|
3710
3808
|
setToken: true
|
|
@@ -4013,8 +4111,8 @@ function EsqueciMinhaSenha({ email: emailProp }) {
|
|
|
4013
4111
|
const ate = new Date(Date.now() + 1000 * TEMPO_COOLDOWN);
|
|
4014
4112
|
sessionStorage.setItem(CHAVE_LS, ate.toISOString());
|
|
4015
4113
|
iniciarContagem(TEMPO_COOLDOWN);
|
|
4016
|
-
await src_utils.api.
|
|
4017
|
-
url:
|
|
4114
|
+
await src_utils.api.servidor_pricipal.post({
|
|
4115
|
+
url: shared_types.Controller.CodigoOtp.EnviarCodigoOtp.rota,
|
|
4018
4116
|
data: dadosBody
|
|
4019
4117
|
});
|
|
4020
4118
|
setMostrarOtp(true);
|
|
@@ -5813,7 +5911,7 @@ function zod_a(o, a, u) {
|
|
|
5813
5911
|
]
|
|
5814
5912
|
];
|
|
5815
5913
|
const LoaderCircle = createLucideIcon("loader-circle", loader_circle_iconNode);
|
|
5816
|
-
const LoginSchema =
|
|
5914
|
+
const LoginSchema = shared_types.Controller.Usuario.Login.InputSchema.shape.data.shape.usuario;
|
|
5817
5915
|
function AuthLogin() {
|
|
5818
5916
|
const navigate = useNavigate();
|
|
5819
5917
|
const loading_auth = contexto_contexto_usuario.contexto.jsx.get_loading();
|
|
@@ -5970,7 +6068,7 @@ function AuthLogin() {
|
|
|
5970
6068
|
})
|
|
5971
6069
|
});
|
|
5972
6070
|
}
|
|
5973
|
-
const RegisterSchema =
|
|
6071
|
+
const RegisterSchema = shared_types.Controller.Usuario.Register.InputSchema.shape.data.shape.usuario;
|
|
5974
6072
|
function AuthRegister() {
|
|
5975
6073
|
const navigate = useNavigate();
|
|
5976
6074
|
const loading_auth = contexto_contexto_usuario.contexto.jsx.get_loading();
|
|
@@ -6869,4 +6967,4 @@ function LayoutPublic() {
|
|
|
6869
6967
|
]
|
|
6870
6968
|
});
|
|
6871
6969
|
}
|
|
6872
|
-
export { AuthAtivarDesativarAuthenticator, AuthGoogle, AuthLogin, AuthRegister, EsqueciMinhaSenha, Layout, LayoutPublic,
|
|
6970
|
+
export { AuthAtivarDesativarAuthenticator, AuthGoogle, AuthLogin, AuthRegister, EsqueciMinhaSenha, Layout, LayoutPublic, shared_types as TypesUsuario, VerificarAuthenticator, src_config_env as config_env_usuario, contexto_contexto_layout as contexto_layout, contexto_contexto_usuario as contexto_usuario };
|