@nocios/crudify-ui 4.0.8 → 4.0.92
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/README.md +12 -0
- package/dist/GlobalNotificationProvider-C3iWgM1z.d.mts +35 -0
- package/dist/GlobalNotificationProvider-C3iWgM1z.d.ts +35 -0
- package/dist/api-Djqihi4n.d.mts +82 -0
- package/dist/api-Djqihi4n.d.ts +82 -0
- package/dist/chunk-2IJSKTGW.js +1 -0
- package/dist/chunk-6EBMA4HZ.js +1 -0
- package/dist/chunk-BJ6PIVZR.mjs +1 -0
- package/dist/chunk-EP4KANK7.js +1 -0
- package/dist/chunk-JFXC3E4B.mjs +1 -0
- package/dist/chunk-NNY4A73V.js +1 -0
- package/dist/chunk-PVQVPSNT.mjs +1 -0
- package/dist/chunk-T2CPA46I.mjs +1 -0
- package/dist/chunk-TKYA4Q4U.mjs +1 -0
- package/dist/chunk-YIIUEOXC.js +1 -0
- package/dist/chunk-YS3C7YG5.mjs +1 -0
- package/dist/chunk-YZZ6A6CR.js +1 -0
- package/dist/components.d.mts +4 -0
- package/dist/components.d.ts +4 -0
- package/dist/components.js +1 -0
- package/dist/components.mjs +1 -0
- package/dist/hooks.d.mts +5 -0
- package/dist/hooks.d.ts +5 -0
- package/dist/hooks.js +1 -0
- package/dist/hooks.mjs +1 -0
- package/dist/index-B2ZtMz3v.d.ts +433 -0
- package/dist/index-CY6Qkw3q.d.mts +78 -0
- package/dist/index-CoCUhX7W.d.mts +433 -0
- package/dist/index-DxFMT2hN.d.ts +78 -0
- package/dist/index.d.mts +8 -732
- package/dist/index.d.ts +8 -732
- package/dist/index.js +1 -4906
- package/dist/index.mjs +1 -4890
- package/dist/utils.d.mts +124 -0
- package/dist/utils.d.ts +124 -0
- package/dist/utils.js +1 -0
- package/dist/utils.mjs +1 -0
- package/package.json +24 -14
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
import { U as UserProfile, C as CrudifyApiResponse } from './api-Djqihi4n.js';
|
|
2
|
+
import { b as NotificationSeverity } from './GlobalNotificationProvider-C3iWgM1z.js';
|
|
3
|
+
import { CrudifyResponse } from '@nocios/crudify-browser';
|
|
4
|
+
|
|
5
|
+
type TokenData = {
|
|
6
|
+
accessToken: string;
|
|
7
|
+
refreshToken: string;
|
|
8
|
+
expiresAt: number;
|
|
9
|
+
refreshExpiresAt: number;
|
|
10
|
+
};
|
|
11
|
+
type StorageType = "localStorage" | "sessionStorage" | "none";
|
|
12
|
+
declare class TokenStorage {
|
|
13
|
+
private static readonly TOKEN_KEY;
|
|
14
|
+
private static readonly ENCRYPTION_KEY_STORAGE;
|
|
15
|
+
private static encryptionKey;
|
|
16
|
+
private static storageType;
|
|
17
|
+
/**
|
|
18
|
+
* Configurar tipo de almacenamiento
|
|
19
|
+
*/
|
|
20
|
+
static setStorageType(type: StorageType): void;
|
|
21
|
+
/**
|
|
22
|
+
* Generar clave de encriptación única y persistente
|
|
23
|
+
*/
|
|
24
|
+
private static generateEncryptionKey;
|
|
25
|
+
/**
|
|
26
|
+
* Obtener o generar clave de encriptación
|
|
27
|
+
*/
|
|
28
|
+
private static getEncryptionKey;
|
|
29
|
+
/**
|
|
30
|
+
* Verificar si el storage está disponible
|
|
31
|
+
*/
|
|
32
|
+
private static isStorageAvailable;
|
|
33
|
+
/**
|
|
34
|
+
* Obtener instancia de storage
|
|
35
|
+
*/
|
|
36
|
+
private static getStorage;
|
|
37
|
+
/**
|
|
38
|
+
* Encriptar datos sensibles
|
|
39
|
+
*/
|
|
40
|
+
private static encrypt;
|
|
41
|
+
/**
|
|
42
|
+
* Desencriptar datos
|
|
43
|
+
*/
|
|
44
|
+
private static decrypt;
|
|
45
|
+
/**
|
|
46
|
+
* Guardar tokens de forma segura
|
|
47
|
+
*/
|
|
48
|
+
static saveTokens(tokens: TokenData): void;
|
|
49
|
+
/**
|
|
50
|
+
* Obtener tokens guardados
|
|
51
|
+
*/
|
|
52
|
+
static getTokens(): TokenData | null;
|
|
53
|
+
/**
|
|
54
|
+
* Limpiar tokens almacenados
|
|
55
|
+
*/
|
|
56
|
+
static clearTokens(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Rotar clave de encriptación (limpia tokens existentes por seguridad)
|
|
59
|
+
*/
|
|
60
|
+
static rotateEncryptionKey(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Verificar si hay tokens válidos guardados
|
|
63
|
+
*/
|
|
64
|
+
static hasValidTokens(): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Obtener información de expiración
|
|
67
|
+
*/
|
|
68
|
+
static getExpirationInfo(): {
|
|
69
|
+
accessExpired: boolean;
|
|
70
|
+
refreshExpired: boolean;
|
|
71
|
+
accessExpiresIn: number;
|
|
72
|
+
refreshExpiresIn: number;
|
|
73
|
+
} | null;
|
|
74
|
+
/**
|
|
75
|
+
* Actualizar solo el access token (después de refresh)
|
|
76
|
+
*/
|
|
77
|
+
static updateAccessToken(newAccessToken: string, newExpiresAt: number): void;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
type SessionConfig = {
|
|
81
|
+
storageType?: StorageType;
|
|
82
|
+
autoRestore?: boolean;
|
|
83
|
+
enableLogging?: boolean;
|
|
84
|
+
onSessionExpired?: () => void;
|
|
85
|
+
onSessionRestored?: (tokens: TokenData) => void;
|
|
86
|
+
onLoginSuccess?: (tokens: TokenData) => void;
|
|
87
|
+
onLogout?: () => void;
|
|
88
|
+
showNotification?: (message: string, severity?: "error" | "info" | "success" | "warning") => void;
|
|
89
|
+
translateFn?: (key: string) => string;
|
|
90
|
+
};
|
|
91
|
+
type LoginResult = {
|
|
92
|
+
success: boolean;
|
|
93
|
+
tokens?: TokenData;
|
|
94
|
+
data?: any;
|
|
95
|
+
error?: string;
|
|
96
|
+
rawResponse?: any;
|
|
97
|
+
};
|
|
98
|
+
declare class SessionManager {
|
|
99
|
+
private static instance;
|
|
100
|
+
private config;
|
|
101
|
+
private initialized;
|
|
102
|
+
private constructor();
|
|
103
|
+
static getInstance(): SessionManager;
|
|
104
|
+
/**
|
|
105
|
+
* Inicializar el SessionManager
|
|
106
|
+
*/
|
|
107
|
+
initialize(config?: SessionConfig): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Login con persistencia automática
|
|
110
|
+
*/
|
|
111
|
+
login(email: string, password: string): Promise<LoginResult>;
|
|
112
|
+
/**
|
|
113
|
+
* Logout con limpieza de tokens
|
|
114
|
+
*/
|
|
115
|
+
logout(): Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* ✅ MEJORADO: Restaurar sesión desde storage con validación robusta
|
|
118
|
+
*/
|
|
119
|
+
restoreSession(): Promise<boolean>;
|
|
120
|
+
/**
|
|
121
|
+
* Verificar si el usuario está autenticado
|
|
122
|
+
*/
|
|
123
|
+
isAuthenticated(): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Obtener información de tokens actuales
|
|
126
|
+
*/
|
|
127
|
+
getTokenInfo(): {
|
|
128
|
+
isLoggedIn: boolean;
|
|
129
|
+
crudifyTokens: {
|
|
130
|
+
accessToken: string;
|
|
131
|
+
refreshToken: string;
|
|
132
|
+
expiresAt: number;
|
|
133
|
+
refreshExpiresAt: number;
|
|
134
|
+
isExpired: boolean;
|
|
135
|
+
isRefreshExpired: boolean;
|
|
136
|
+
isValid: boolean;
|
|
137
|
+
expiresIn: number;
|
|
138
|
+
willExpireSoon: boolean;
|
|
139
|
+
};
|
|
140
|
+
storageInfo: {
|
|
141
|
+
accessExpired: boolean;
|
|
142
|
+
refreshExpired: boolean;
|
|
143
|
+
accessExpiresIn: number;
|
|
144
|
+
refreshExpiresIn: number;
|
|
145
|
+
} | null;
|
|
146
|
+
hasValidTokens: boolean;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Refrescar tokens manualmente
|
|
150
|
+
*/
|
|
151
|
+
refreshTokens(): Promise<boolean>;
|
|
152
|
+
/**
|
|
153
|
+
* Configurar interceptor de respuesta para manejo automático de errores
|
|
154
|
+
*/
|
|
155
|
+
setupResponseInterceptor(): void;
|
|
156
|
+
/**
|
|
157
|
+
* Detectar errores de autorización en todos los formatos posibles
|
|
158
|
+
*/
|
|
159
|
+
private detectAuthorizationError;
|
|
160
|
+
/**
|
|
161
|
+
* Limpiar sesión completamente
|
|
162
|
+
*/
|
|
163
|
+
clearSession(): void;
|
|
164
|
+
/**
|
|
165
|
+
* Obtener mensaje de sesión expirada traducido
|
|
166
|
+
*/
|
|
167
|
+
private getSessionExpiredMessage;
|
|
168
|
+
private log;
|
|
169
|
+
private formatError;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
type SessionState = {
|
|
173
|
+
isAuthenticated: boolean;
|
|
174
|
+
isLoading: boolean;
|
|
175
|
+
isInitialized: boolean;
|
|
176
|
+
tokens: TokenData | null;
|
|
177
|
+
error: string | null;
|
|
178
|
+
};
|
|
179
|
+
type UseSessionOptions = {
|
|
180
|
+
autoRestore?: boolean;
|
|
181
|
+
enableLogging?: boolean;
|
|
182
|
+
onSessionExpired?: () => void;
|
|
183
|
+
onSessionRestored?: (tokens: TokenData) => void;
|
|
184
|
+
showNotification?: (message: string, severity?: "error" | "info" | "success" | "warning") => void;
|
|
185
|
+
translateFn?: (key: string) => string;
|
|
186
|
+
};
|
|
187
|
+
declare function useSession(options?: UseSessionOptions): {
|
|
188
|
+
login: (email: string, password: string) => Promise<LoginResult>;
|
|
189
|
+
logout: () => Promise<void>;
|
|
190
|
+
refreshTokens: () => Promise<boolean>;
|
|
191
|
+
clearError: () => void;
|
|
192
|
+
getTokenInfo: () => {
|
|
193
|
+
isLoggedIn: boolean;
|
|
194
|
+
crudifyTokens: {
|
|
195
|
+
accessToken: string;
|
|
196
|
+
refreshToken: string;
|
|
197
|
+
expiresAt: number;
|
|
198
|
+
refreshExpiresAt: number;
|
|
199
|
+
isExpired: boolean;
|
|
200
|
+
isRefreshExpired: boolean;
|
|
201
|
+
isValid: boolean;
|
|
202
|
+
expiresIn: number;
|
|
203
|
+
willExpireSoon: boolean;
|
|
204
|
+
};
|
|
205
|
+
storageInfo: {
|
|
206
|
+
accessExpired: boolean;
|
|
207
|
+
refreshExpired: boolean;
|
|
208
|
+
accessExpiresIn: number;
|
|
209
|
+
refreshExpiresIn: number;
|
|
210
|
+
} | null;
|
|
211
|
+
hasValidTokens: boolean;
|
|
212
|
+
};
|
|
213
|
+
isExpiringSoon: boolean;
|
|
214
|
+
expiresIn: number;
|
|
215
|
+
refreshExpiresIn: number;
|
|
216
|
+
isAuthenticated: boolean;
|
|
217
|
+
isLoading: boolean;
|
|
218
|
+
isInitialized: boolean;
|
|
219
|
+
tokens: TokenData | null;
|
|
220
|
+
error: string | null;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Complete user data structure (compatible con legacy)
|
|
225
|
+
*/
|
|
226
|
+
interface UserData {
|
|
227
|
+
session: any | null;
|
|
228
|
+
data: UserProfile | null;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Return type compatible con useCrudifyUser legacy
|
|
232
|
+
*/
|
|
233
|
+
interface UseUserDataReturn {
|
|
234
|
+
user: UserData;
|
|
235
|
+
loading: boolean;
|
|
236
|
+
error: string | null;
|
|
237
|
+
refreshProfile: () => Promise<void>;
|
|
238
|
+
clearProfile: () => void;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Options compatible con useCrudifyUser legacy
|
|
242
|
+
*/
|
|
243
|
+
interface UseUserDataOptions {
|
|
244
|
+
autoFetch?: boolean;
|
|
245
|
+
retryOnError?: boolean;
|
|
246
|
+
maxRetries?: number;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* useUserData - Hook completo que reemplaza useCrudifyUser del sistema legacy
|
|
250
|
+
*
|
|
251
|
+
* Funcionalidades completas:
|
|
252
|
+
* - Auto-fetch de datos del usuario desde la base de datos
|
|
253
|
+
* - Manejo inteligente de caché y deduplicación
|
|
254
|
+
* - Mecanismo de retry para errores de red
|
|
255
|
+
* - Sincronización cross-tab vía SessionProvider
|
|
256
|
+
* - Formateo extendido de datos para display
|
|
257
|
+
* - Limpieza apropiada y gestión de memoria
|
|
258
|
+
* - Compatible 100% con API de useCrudifyUser legacy
|
|
259
|
+
* - Usa el nuevo sistema de refresh tokens por debajo
|
|
260
|
+
*/
|
|
261
|
+
declare const useUserData: (options?: UseUserDataOptions) => UseUserDataReturn;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Return type compatible con useCrudifyAuth legacy
|
|
265
|
+
*/
|
|
266
|
+
interface UseAuthReturn {
|
|
267
|
+
isAuthenticated: boolean;
|
|
268
|
+
loading: boolean;
|
|
269
|
+
error: string | null;
|
|
270
|
+
token: string | null;
|
|
271
|
+
user: any | null;
|
|
272
|
+
tokenExpiration: Date | null;
|
|
273
|
+
setToken: (token: string | null) => void;
|
|
274
|
+
logout: () => Promise<void>;
|
|
275
|
+
refreshToken: () => Promise<boolean>;
|
|
276
|
+
login: (email: string, password: string) => Promise<any>;
|
|
277
|
+
isExpiringSoon: boolean;
|
|
278
|
+
expiresIn: number;
|
|
279
|
+
refreshExpiresIn: number;
|
|
280
|
+
getTokenInfo: () => any;
|
|
281
|
+
clearError: () => void;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* useAuth - Hook de autenticación completo
|
|
285
|
+
*
|
|
286
|
+
* Este hook reemplaza completamente a useCrudifyAuth del sistema legacy
|
|
287
|
+
* manteniendo 100% compatibilidad de API pero usando el nuevo SessionProvider
|
|
288
|
+
* que incluye Refresh Token Pattern, almacenamiento seguro, y gestión automática
|
|
289
|
+
* de expiración de tokens.
|
|
290
|
+
*
|
|
291
|
+
* Funcionalidades completas:
|
|
292
|
+
* - Estado de autenticación en tiempo real
|
|
293
|
+
* - Validación automática de tokens
|
|
294
|
+
* - Sincronización cross-tab
|
|
295
|
+
* - Acciones simples login/logout
|
|
296
|
+
* - Acceso al payload JWT vía sessionData
|
|
297
|
+
* - Refresh automático de tokens
|
|
298
|
+
* - Gestión de expiración de sesiones
|
|
299
|
+
* - Almacenamiento seguro y encriptado
|
|
300
|
+
* - Compatibilidad 100% con API legacy
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```tsx
|
|
304
|
+
* function LoginComponent() {
|
|
305
|
+
* const { isAuthenticated, login, logout, user } = useAuth();
|
|
306
|
+
*
|
|
307
|
+
* if (isAuthenticated) {
|
|
308
|
+
* return (
|
|
309
|
+
* <div>
|
|
310
|
+
* Welcome {user?.email}!
|
|
311
|
+
* <button onClick={logout}>Logout</button>
|
|
312
|
+
* </div>
|
|
313
|
+
* );
|
|
314
|
+
* }
|
|
315
|
+
*
|
|
316
|
+
* return <LoginForm onLogin={login} />;
|
|
317
|
+
* }
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
320
|
+
declare const useAuth: () => UseAuthReturn;
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Return type compatible con useCrudifyData legacy
|
|
324
|
+
*/
|
|
325
|
+
interface UseDataReturn {
|
|
326
|
+
readItems: (moduleKey: string, filter?: object, options?: any) => Promise<CrudifyApiResponse>;
|
|
327
|
+
readItem: (moduleKey: string, filter: object, options?: any) => Promise<CrudifyApiResponse>;
|
|
328
|
+
createItem: (moduleKey: string, data: object, options?: any) => Promise<CrudifyApiResponse>;
|
|
329
|
+
updateItem: (moduleKey: string, data: object, options?: any) => Promise<CrudifyApiResponse>;
|
|
330
|
+
deleteItem: (moduleKey: string, id: string, options?: any) => Promise<CrudifyApiResponse>;
|
|
331
|
+
transaction: (operations: any[], options?: any) => Promise<CrudifyApiResponse>;
|
|
332
|
+
login: (email: string, password: string) => Promise<CrudifyApiResponse>;
|
|
333
|
+
isInitialized: boolean;
|
|
334
|
+
isInitializing: boolean;
|
|
335
|
+
initializationError: string | null;
|
|
336
|
+
isReady: () => boolean;
|
|
337
|
+
waitForReady: () => Promise<void>;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* useData - Hook completo para operaciones de datos
|
|
341
|
+
*
|
|
342
|
+
* Este hook reemplaza completamente a useCrudifyData del sistema legacy
|
|
343
|
+
* manteniendo 100% compatibilidad de API pero usando el nuevo SessionProvider
|
|
344
|
+
* que proporciona mejor manejo de estados y errores.
|
|
345
|
+
*
|
|
346
|
+
* Funcionalidades completas:
|
|
347
|
+
* - Verificación automática de inicialización
|
|
348
|
+
* - Operaciones CRUD type-safe
|
|
349
|
+
* - Soporte para transacciones
|
|
350
|
+
* - Operaciones de login
|
|
351
|
+
* - Gestión de estados ready
|
|
352
|
+
* - Manejo apropiado de errores
|
|
353
|
+
* - Compatible 100% con API legacy
|
|
354
|
+
*
|
|
355
|
+
* Todas las operaciones verifican que el sistema esté inicializado correctamente,
|
|
356
|
+
* asegurando integridad de datos y previniendo fallas silenciosas.
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* ```tsx
|
|
360
|
+
* function DataComponent() {
|
|
361
|
+
* const {
|
|
362
|
+
* readItems,
|
|
363
|
+
* createItem,
|
|
364
|
+
* isInitialized,
|
|
365
|
+
* isReady
|
|
366
|
+
* } = useData();
|
|
367
|
+
*
|
|
368
|
+
* const loadUsers = async () => {
|
|
369
|
+
* if (!isReady()) {
|
|
370
|
+
* console.warn("System not ready yet");
|
|
371
|
+
* return;
|
|
372
|
+
* }
|
|
373
|
+
*
|
|
374
|
+
* try {
|
|
375
|
+
* const response = await readItems("users", { limit: 10 });
|
|
376
|
+
* if (response.success) {
|
|
377
|
+
* console.log("Users:", response.data);
|
|
378
|
+
* }
|
|
379
|
+
* } catch (error) {
|
|
380
|
+
* console.error("Error loading users:", error);
|
|
381
|
+
* }
|
|
382
|
+
* };
|
|
383
|
+
*
|
|
384
|
+
* return (
|
|
385
|
+
* <div>
|
|
386
|
+
* <button onClick={loadUsers} disabled={!isInitialized}>
|
|
387
|
+
* Load Users
|
|
388
|
+
* </button>
|
|
389
|
+
* </div>
|
|
390
|
+
* );
|
|
391
|
+
* }
|
|
392
|
+
* ```
|
|
393
|
+
*/
|
|
394
|
+
declare const useData: () => UseDataReturn;
|
|
395
|
+
|
|
396
|
+
interface UseUserProfileOptions {
|
|
397
|
+
autoFetch?: boolean;
|
|
398
|
+
retryOnError?: boolean;
|
|
399
|
+
maxRetries?: number;
|
|
400
|
+
}
|
|
401
|
+
interface UseUserProfileReturn {
|
|
402
|
+
userProfile: UserProfile | null;
|
|
403
|
+
loading: boolean;
|
|
404
|
+
error: string | null;
|
|
405
|
+
extendedData: Record<string, any>;
|
|
406
|
+
refreshProfile: () => Promise<void>;
|
|
407
|
+
clearProfile: () => void;
|
|
408
|
+
}
|
|
409
|
+
declare const useUserProfile: (options?: UseUserProfileOptions) => UseUserProfileReturn;
|
|
410
|
+
|
|
411
|
+
interface CrudifyWithNotificationsOptions {
|
|
412
|
+
showSuccessNotifications?: boolean;
|
|
413
|
+
showErrorNotifications?: boolean;
|
|
414
|
+
customErrorMessages?: Record<string, string>;
|
|
415
|
+
defaultErrorMessage?: string;
|
|
416
|
+
autoHideDuration?: number;
|
|
417
|
+
appStructure?: any[];
|
|
418
|
+
translateFn?: (key: string, options?: any) => string;
|
|
419
|
+
}
|
|
420
|
+
declare const useCrudifyWithNotifications: (options?: CrudifyWithNotificationsOptions) => {
|
|
421
|
+
createItem: (moduleKey: string, data: object, options?: any) => Promise<CrudifyResponse>;
|
|
422
|
+
updateItem: (moduleKey: string, data: object, options?: any) => Promise<CrudifyResponse>;
|
|
423
|
+
deleteItem: (moduleKey: string, id: string, options?: any) => Promise<CrudifyResponse>;
|
|
424
|
+
readItem: (moduleKey: string, filter: object, options?: any) => Promise<CrudifyResponse>;
|
|
425
|
+
readItems: (moduleKey: string, filter: object, options?: any) => Promise<CrudifyResponse>;
|
|
426
|
+
transaction: (data: any, options?: any) => Promise<CrudifyResponse>;
|
|
427
|
+
handleResponse: (response: CrudifyResponse, successMessage?: string) => CrudifyResponse;
|
|
428
|
+
getErrorMessage: (response: CrudifyResponse) => string;
|
|
429
|
+
getErrorSeverity: (response: CrudifyResponse) => NotificationSeverity;
|
|
430
|
+
shouldShowNotification: (response: CrudifyResponse) => boolean;
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
export { type LoginResult as L, SessionManager as S, type TokenData as T, type UseSessionOptions as U, type SessionConfig as a, TokenStorage as b, type StorageType as c, type SessionState as d, useUserData as e, type UseUserDataReturn as f, type UseUserDataOptions as g, type UserData as h, useAuth as i, type UseAuthReturn as j, useData as k, type UseDataReturn as l, useUserProfile as m, useCrudifyWithNotifications as n, useSession as u };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './GlobalNotificationProvider-C3iWgM1z.mjs';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
type BoxScreenType = "login" | "signUp" | "forgotPassword" | "resetPassword" | "checkCode";
|
|
6
|
+
interface CrudifyLoginConfig {
|
|
7
|
+
publicApiKey?: string | null;
|
|
8
|
+
env?: "dev" | "stg" | "api" | "prod";
|
|
9
|
+
appName?: string;
|
|
10
|
+
logo?: string;
|
|
11
|
+
loginActions?: string[];
|
|
12
|
+
}
|
|
13
|
+
interface CrudifyLoginTranslations {
|
|
14
|
+
[key: string]: string | CrudifyLoginTranslations;
|
|
15
|
+
}
|
|
16
|
+
interface UserLoginData {
|
|
17
|
+
token: string;
|
|
18
|
+
username?: string;
|
|
19
|
+
email?: string;
|
|
20
|
+
userId?: string;
|
|
21
|
+
profile?: any;
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}
|
|
24
|
+
interface CrudifyLoginProps {
|
|
25
|
+
onScreenChange?: (screen: BoxScreenType, params?: Record<string, string>) => void;
|
|
26
|
+
onExternalNavigate?: (path: string) => void;
|
|
27
|
+
onLoginSuccess?: (userData: UserLoginData, redirectUrl?: string) => void;
|
|
28
|
+
onError?: (error: string) => void;
|
|
29
|
+
initialScreen?: BoxScreenType;
|
|
30
|
+
redirectUrl?: string;
|
|
31
|
+
autoReadFromCookies?: boolean;
|
|
32
|
+
translations?: CrudifyLoginTranslations;
|
|
33
|
+
translationsUrl?: string;
|
|
34
|
+
language?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare const CrudifyLogin: React.FC<CrudifyLoginProps>;
|
|
38
|
+
|
|
39
|
+
interface UserProfileDisplayProps {
|
|
40
|
+
showExtendedData?: boolean;
|
|
41
|
+
showProfileCard?: boolean;
|
|
42
|
+
autoRefresh?: boolean;
|
|
43
|
+
}
|
|
44
|
+
declare const UserProfileDisplay: React.FC<UserProfileDisplayProps>;
|
|
45
|
+
|
|
46
|
+
declare const POLICY_ACTIONS: readonly ["create", "read", "update", "delete"];
|
|
47
|
+
type PolicyAction = typeof POLICY_ACTIONS[number];
|
|
48
|
+
declare const PREFERRED_POLICY_ORDER: PolicyAction[];
|
|
49
|
+
|
|
50
|
+
type Policy = {
|
|
51
|
+
id: string;
|
|
52
|
+
action: PolicyAction;
|
|
53
|
+
fields?: {
|
|
54
|
+
allow: string[];
|
|
55
|
+
owner_allow: string[];
|
|
56
|
+
deny: string[];
|
|
57
|
+
};
|
|
58
|
+
permission?: string;
|
|
59
|
+
};
|
|
60
|
+
type FieldErrorMap = string | ({
|
|
61
|
+
_error?: string;
|
|
62
|
+
} & Record<string, string | undefined>);
|
|
63
|
+
interface PoliciesProps {
|
|
64
|
+
policies: Policy[];
|
|
65
|
+
onChange: (next: Policy[]) => void;
|
|
66
|
+
availableFields: string[];
|
|
67
|
+
errors?: FieldErrorMap;
|
|
68
|
+
isSubmitting?: boolean;
|
|
69
|
+
}
|
|
70
|
+
declare const Policies: React.FC<PoliciesProps>;
|
|
71
|
+
|
|
72
|
+
declare function LoginComponent(): react_jsx_runtime.JSX.Element;
|
|
73
|
+
/**
|
|
74
|
+
* Componente simple de estado de sesión para mostrar en cualquier lugar
|
|
75
|
+
*/
|
|
76
|
+
declare function SessionStatus(): react_jsx_runtime.JSX.Element;
|
|
77
|
+
|
|
78
|
+
export { type BoxScreenType as B, CrudifyLogin as C, LoginComponent as L, Policies as P, SessionStatus as S, UserProfileDisplay as U, POLICY_ACTIONS as a, PREFERRED_POLICY_ORDER as b, type PolicyAction as c, type CrudifyLoginConfig as d, type CrudifyLoginProps as e, type CrudifyLoginTranslations as f, type UserLoginData as g };
|