@nocios/crudify-ui 4.0.6 → 4.0.9

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/dist/index.d.ts CHANGED
@@ -1,368 +1,13 @@
1
- import { CrudifyResponse } from '@nocios/crudify-browser';
2
1
  export * from '@nocios/crudify-browser';
3
2
  export { default as crudify } from '@nocios/crudify-browser';
4
- import React, { ReactNode } from 'react';
3
+ export { B as BoxScreenType, C as CrudifyLogin, d as CrudifyLoginConfig, e as CrudifyLoginProps, f as CrudifyLoginTranslations, L as LoginComponent, a as POLICY_ACTIONS, b as PREFERRED_POLICY_ORDER, P as Policies, c as PolicyAction, S as SessionStatus, g as UserLoginData, U as UserProfileDisplay } from './index-DxFMT2hN.js';
4
+ export { A as ApiError, C as CrudifyApiResponse, a as CrudifyTransactionResponse, F as ForgotPasswordRequest, J as JwtPayload, b as LoginRequest, L as LoginResponse, R as ResetPasswordRequest, T as TransactionResponseData, U as UserProfile, V as ValidateCodeRequest, c as ValidationError } from './api-Djqihi4n.js';
5
+ import { U as UseSessionOptions, T as TokenData, L as LoginResult } from './index-CjC4JwH9.js';
6
+ export { a as SessionConfig, S as SessionManager, d as SessionState, c as StorageType, b as TokenStorage, j as UseAuthReturn, l as UseDataReturn, g as UseUserDataOptions, f as UseUserDataReturn, h as UserData, i as useAuth, n as useCrudifyWithNotifications, k as useData, u as useSession, e as useUserData, m as useUserProfile } from './index-CjC4JwH9.js';
5
7
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
-
7
- type BoxScreenType = "login" | "signUp" | "forgotPassword" | "resetPassword" | "checkCode";
8
- interface CrudifyLoginConfig {
9
- publicApiKey?: string | null;
10
- env?: "dev" | "stg" | "api" | "prod";
11
- appName?: string;
12
- logo?: string;
13
- loginActions?: string[];
14
- }
15
- interface CrudifyLoginTranslations {
16
- [key: string]: string | CrudifyLoginTranslations;
17
- }
18
- interface UserLoginData {
19
- token: string;
20
- username?: string;
21
- email?: string;
22
- userId?: string;
23
- profile?: any;
24
- [key: string]: any;
25
- }
26
- interface CrudifyLoginProps {
27
- onScreenChange?: (screen: BoxScreenType, params?: Record<string, string>) => void;
28
- onExternalNavigate?: (path: string) => void;
29
- onLoginSuccess?: (userData: UserLoginData, redirectUrl?: string) => void;
30
- onError?: (error: string) => void;
31
- initialScreen?: BoxScreenType;
32
- redirectUrl?: string;
33
- autoReadFromCookies?: boolean;
34
- translations?: CrudifyLoginTranslations;
35
- translationsUrl?: string;
36
- language?: string;
37
- }
38
-
39
- declare const CrudifyLogin: React.FC<CrudifyLoginProps>;
40
-
41
- interface UserProfileDisplayProps {
42
- showExtendedData?: boolean;
43
- showProfileCard?: boolean;
44
- autoRefresh?: boolean;
45
- }
46
- declare const UserProfileDisplay: React.FC<UserProfileDisplayProps>;
47
-
48
- declare const POLICY_ACTIONS: readonly ["create", "read", "update", "delete"];
49
- type PolicyAction = typeof POLICY_ACTIONS[number];
50
- declare const PREFERRED_POLICY_ORDER: PolicyAction[];
51
-
52
- type Policy = {
53
- id: string;
54
- action: PolicyAction;
55
- fields?: {
56
- allow: string[];
57
- owner_allow: string[];
58
- deny: string[];
59
- };
60
- permission?: string;
61
- };
62
- type FieldErrorMap = string | ({
63
- _error?: string;
64
- } & Record<string, string | undefined>);
65
- interface PoliciesProps {
66
- policies: Policy[];
67
- onChange: (next: Policy[]) => void;
68
- availableFields: string[];
69
- errors?: FieldErrorMap;
70
- isSubmitting?: boolean;
71
- }
72
- declare const Policies: React.FC<PoliciesProps>;
73
-
74
- interface CrudifyApiResponse<T = unknown> {
75
- success: boolean;
76
- data?: T;
77
- errors?: string | Record<string, string[]> | string[];
78
- errorCode?: string;
79
- fieldsWarning?: Record<string, string[]>;
80
- }
81
- interface CrudifyTransactionResponse {
82
- success: boolean;
83
- data?: TransactionResponseData[];
84
- errors?: string | Record<string, string[]>;
85
- errorCode?: string;
86
- }
87
- interface TransactionResponseData {
88
- response?: {
89
- status: string;
90
- data?: unknown;
91
- message?: string;
92
- };
93
- errors?: string | Record<string, string[]>;
94
- }
95
- interface UserProfile {
96
- id: string | number;
97
- email: string;
98
- username?: string;
99
- firstName?: string;
100
- lastName?: string;
101
- fullName?: string;
102
- avatar?: string;
103
- role?: string;
104
- permissions?: string[];
105
- lastLogin?: string;
106
- isActive?: boolean;
107
- createdAt?: string;
108
- updatedAt?: string;
109
- [key: string]: unknown;
110
- }
111
- interface LoginResponse {
112
- token: string;
113
- user?: UserProfile;
114
- expiresIn?: number;
115
- refreshToken?: string;
116
- }
117
- interface LoginRequest {
118
- identifier: string;
119
- password: string;
120
- }
121
- interface ForgotPasswordRequest {
122
- email: string;
123
- }
124
- interface ResetPasswordRequest {
125
- email: string;
126
- code: string;
127
- newPassword: string;
128
- }
129
- interface ValidateCodeRequest {
130
- email: string;
131
- codePassword: string;
132
- }
133
- interface JwtPayload {
134
- sub?: string;
135
- email?: string;
136
- username?: string;
137
- iat?: number;
138
- exp?: number;
139
- iss?: string;
140
- aud?: string;
141
- [key: string]: unknown;
142
- }
143
- interface ApiError {
144
- code: string;
145
- message: string;
146
- field?: string;
147
- details?: Record<string, unknown>;
148
- }
149
- interface ValidationError {
150
- field: string;
151
- message: string;
152
- code: string;
153
- }
154
-
155
- type TokenData = {
156
- accessToken: string;
157
- refreshToken: string;
158
- expiresAt: number;
159
- refreshExpiresAt: number;
160
- };
161
- type StorageType = "localStorage" | "sessionStorage" | "none";
162
- declare class TokenStorage {
163
- private static readonly TOKEN_KEY;
164
- private static readonly ENCRYPTION_KEY_STORAGE;
165
- private static encryptionKey;
166
- private static storageType;
167
- /**
168
- * Configurar tipo de almacenamiento
169
- */
170
- static setStorageType(type: StorageType): void;
171
- /**
172
- * Generar clave de encriptación única y persistente
173
- */
174
- private static generateEncryptionKey;
175
- /**
176
- * Obtener o generar clave de encriptación
177
- */
178
- private static getEncryptionKey;
179
- /**
180
- * Verificar si el storage está disponible
181
- */
182
- private static isStorageAvailable;
183
- /**
184
- * Obtener instancia de storage
185
- */
186
- private static getStorage;
187
- /**
188
- * Encriptar datos sensibles
189
- */
190
- private static encrypt;
191
- /**
192
- * Desencriptar datos
193
- */
194
- private static decrypt;
195
- /**
196
- * Guardar tokens de forma segura
197
- */
198
- static saveTokens(tokens: TokenData): void;
199
- /**
200
- * Obtener tokens guardados
201
- */
202
- static getTokens(): TokenData | null;
203
- /**
204
- * Limpiar tokens almacenados
205
- */
206
- static clearTokens(): void;
207
- /**
208
- * Rotar clave de encriptación (limpia tokens existentes por seguridad)
209
- */
210
- static rotateEncryptionKey(): void;
211
- /**
212
- * Verificar si hay tokens válidos guardados
213
- */
214
- static hasValidTokens(): boolean;
215
- /**
216
- * Obtener información de expiración
217
- */
218
- static getExpirationInfo(): {
219
- accessExpired: boolean;
220
- refreshExpired: boolean;
221
- accessExpiresIn: number;
222
- refreshExpiresIn: number;
223
- } | null;
224
- /**
225
- * Actualizar solo el access token (después de refresh)
226
- */
227
- static updateAccessToken(newAccessToken: string, newExpiresAt: number): void;
228
- }
229
-
230
- type SessionConfig = {
231
- storageType?: StorageType;
232
- autoRestore?: boolean;
233
- enableLogging?: boolean;
234
- onSessionExpired?: () => void;
235
- onSessionRestored?: (tokens: TokenData) => void;
236
- onLoginSuccess?: (tokens: TokenData) => void;
237
- onLogout?: () => void;
238
- showNotification?: (message: string, severity?: "error" | "info" | "success" | "warning") => void;
239
- translateFn?: (key: string) => string;
240
- };
241
- type LoginResult = {
242
- success: boolean;
243
- tokens?: TokenData;
244
- data?: any;
245
- error?: string;
246
- rawResponse?: any;
247
- };
248
- declare class SessionManager {
249
- private static instance;
250
- private config;
251
- private initialized;
252
- private constructor();
253
- static getInstance(): SessionManager;
254
- /**
255
- * Inicializar el SessionManager
256
- */
257
- initialize(config?: SessionConfig): Promise<void>;
258
- /**
259
- * Login con persistencia automática
260
- */
261
- login(email: string, password: string): Promise<LoginResult>;
262
- /**
263
- * Logout con limpieza de tokens
264
- */
265
- logout(): Promise<void>;
266
- /**
267
- * Restaurar sesión desde storage
268
- */
269
- restoreSession(): Promise<boolean>;
270
- /**
271
- * Verificar si el usuario está autenticado
272
- */
273
- isAuthenticated(): boolean;
274
- /**
275
- * Obtener información de tokens actuales
276
- */
277
- getTokenInfo(): {
278
- isLoggedIn: boolean;
279
- crudifyTokens: {
280
- accessToken: string;
281
- refreshToken: string;
282
- expiresAt: number;
283
- refreshExpiresAt: number;
284
- isExpired: boolean;
285
- isRefreshExpired: boolean;
286
- };
287
- storageInfo: {
288
- accessExpired: boolean;
289
- refreshExpired: boolean;
290
- accessExpiresIn: number;
291
- refreshExpiresIn: number;
292
- } | null;
293
- hasValidTokens: boolean;
294
- };
295
- /**
296
- * Refrescar tokens manualmente
297
- */
298
- refreshTokens(): Promise<boolean>;
299
- /**
300
- * Configurar interceptor de respuesta para manejo automático de errores
301
- */
302
- setupResponseInterceptor(): void;
303
- /**
304
- * Detectar errores de autorización en todos los formatos posibles
305
- */
306
- private detectAuthorizationError;
307
- /**
308
- * Limpiar sesión completamente
309
- */
310
- clearSession(): void;
311
- /**
312
- * Obtener mensaje de sesión expirada traducido
313
- */
314
- private getSessionExpiredMessage;
315
- private log;
316
- private formatError;
317
- }
318
-
319
- type SessionState = {
320
- isAuthenticated: boolean;
321
- isLoading: boolean;
322
- isInitialized: boolean;
323
- tokens: TokenData | null;
324
- error: string | null;
325
- };
326
- type UseSessionOptions = {
327
- autoRestore?: boolean;
328
- enableLogging?: boolean;
329
- onSessionExpired?: () => void;
330
- onSessionRestored?: (tokens: TokenData) => void;
331
- showNotification?: (message: string, severity?: "error" | "info" | "success" | "warning") => void;
332
- translateFn?: (key: string) => string;
333
- };
334
- declare function useSession(options?: UseSessionOptions): {
335
- login: (email: string, password: string) => Promise<LoginResult>;
336
- logout: () => Promise<void>;
337
- refreshTokens: () => Promise<boolean>;
338
- clearError: () => void;
339
- getTokenInfo: () => {
340
- isLoggedIn: boolean;
341
- crudifyTokens: {
342
- accessToken: string;
343
- refreshToken: string;
344
- expiresAt: number;
345
- refreshExpiresAt: number;
346
- isExpired: boolean;
347
- isRefreshExpired: boolean;
348
- };
349
- storageInfo: {
350
- accessExpired: boolean;
351
- refreshExpired: boolean;
352
- accessExpiresIn: number;
353
- refreshExpiresIn: number;
354
- } | null;
355
- hasValidTokens: boolean;
356
- };
357
- isExpiringSoon: boolean;
358
- expiresIn: number;
359
- refreshExpiresIn: number;
360
- isAuthenticated: boolean;
361
- isLoading: boolean;
362
- isInitialized: boolean;
363
- tokens: TokenData | null;
364
- error: string | null;
365
- };
8
+ import { ReactNode } from 'react';
9
+ export { ERROR_CODES, ERROR_SEVERITY_MAP, ErrorCode, ErrorSeverity, ErrorTranslationConfig, ParsedError, createErrorTranslator, decodeJwtSafely, getCookie, getCurrentUserEmail, getErrorMessage, handleCrudifyError, isTokenExpired, parseApiError, parseJavaScriptError, parseTransactionError, secureLocalStorage, secureSessionStorage, translateError, translateErrorCode, translateErrorCodes } from './utils.js';
10
+ export { G as GlobalNotificationProvider, a as GlobalNotificationProviderProps, N as Notification, b as NotificationSeverity, u as useGlobalNotification } from './GlobalNotificationProvider-C3iWgM1z.js';
366
11
 
367
12
  type SessionData = {
368
13
  _id: string;
@@ -433,373 +78,4 @@ declare function ProtectedRoute({ children, fallback, redirectTo }: ProtectedRou
433
78
  */
434
79
  declare function SessionDebugInfo(): react_jsx_runtime.JSX.Element;
435
80
 
436
- declare function LoginComponent(): react_jsx_runtime.JSX.Element;
437
- /**
438
- * Componente simple de estado de sesión para mostrar en cualquier lugar
439
- */
440
- declare function SessionStatus(): react_jsx_runtime.JSX.Element;
441
-
442
- /**
443
- * Complete user data structure (compatible con legacy)
444
- */
445
- interface UserData {
446
- session: any | null;
447
- data: UserProfile | null;
448
- }
449
- /**
450
- * Return type compatible con useCrudifyUser legacy
451
- */
452
- interface UseUserDataReturn {
453
- user: UserData;
454
- loading: boolean;
455
- error: string | null;
456
- refreshProfile: () => Promise<void>;
457
- clearProfile: () => void;
458
- }
459
- /**
460
- * Options compatible con useCrudifyUser legacy
461
- */
462
- interface UseUserDataOptions {
463
- autoFetch?: boolean;
464
- retryOnError?: boolean;
465
- maxRetries?: number;
466
- }
467
- /**
468
- * useUserData - Hook completo que reemplaza useCrudifyUser del sistema legacy
469
- *
470
- * Funcionalidades completas:
471
- * - Auto-fetch de datos del usuario desde la base de datos
472
- * - Manejo inteligente de caché y deduplicación
473
- * - Mecanismo de retry para errores de red
474
- * - Sincronización cross-tab vía SessionProvider
475
- * - Formateo extendido de datos para display
476
- * - Limpieza apropiada y gestión de memoria
477
- * - Compatible 100% con API de useCrudifyUser legacy
478
- * - Usa el nuevo sistema de refresh tokens por debajo
479
- */
480
- declare const useUserData: (options?: UseUserDataOptions) => UseUserDataReturn;
481
-
482
- /**
483
- * Return type compatible con useCrudifyAuth legacy
484
- */
485
- interface UseAuthReturn {
486
- isAuthenticated: boolean;
487
- loading: boolean;
488
- error: string | null;
489
- token: string | null;
490
- user: any | null;
491
- tokenExpiration: Date | null;
492
- setToken: (token: string | null) => void;
493
- logout: () => Promise<void>;
494
- refreshToken: () => Promise<boolean>;
495
- login: (email: string, password: string) => Promise<any>;
496
- isExpiringSoon: boolean;
497
- expiresIn: number;
498
- refreshExpiresIn: number;
499
- getTokenInfo: () => any;
500
- clearError: () => void;
501
- }
502
- /**
503
- * useAuth - Hook de autenticación completo
504
- *
505
- * Este hook reemplaza completamente a useCrudifyAuth del sistema legacy
506
- * manteniendo 100% compatibilidad de API pero usando el nuevo SessionProvider
507
- * que incluye Refresh Token Pattern, almacenamiento seguro, y gestión automática
508
- * de expiración de tokens.
509
- *
510
- * Funcionalidades completas:
511
- * - Estado de autenticación en tiempo real
512
- * - Validación automática de tokens
513
- * - Sincronización cross-tab
514
- * - Acciones simples login/logout
515
- * - Acceso al payload JWT vía sessionData
516
- * - Refresh automático de tokens
517
- * - Gestión de expiración de sesiones
518
- * - Almacenamiento seguro y encriptado
519
- * - Compatibilidad 100% con API legacy
520
- *
521
- * @example
522
- * ```tsx
523
- * function LoginComponent() {
524
- * const { isAuthenticated, login, logout, user } = useAuth();
525
- *
526
- * if (isAuthenticated) {
527
- * return (
528
- * <div>
529
- * Welcome {user?.email}!
530
- * <button onClick={logout}>Logout</button>
531
- * </div>
532
- * );
533
- * }
534
- *
535
- * return <LoginForm onLogin={login} />;
536
- * }
537
- * ```
538
- */
539
- declare const useAuth: () => UseAuthReturn;
540
-
541
- /**
542
- * Return type compatible con useCrudifyData legacy
543
- */
544
- interface UseDataReturn {
545
- readItems: (moduleKey: string, filter?: object, options?: any) => Promise<CrudifyApiResponse>;
546
- readItem: (moduleKey: string, filter: object, options?: any) => Promise<CrudifyApiResponse>;
547
- createItem: (moduleKey: string, data: object, options?: any) => Promise<CrudifyApiResponse>;
548
- updateItem: (moduleKey: string, data: object, options?: any) => Promise<CrudifyApiResponse>;
549
- deleteItem: (moduleKey: string, id: string, options?: any) => Promise<CrudifyApiResponse>;
550
- transaction: (operations: any[], options?: any) => Promise<CrudifyApiResponse>;
551
- login: (email: string, password: string) => Promise<CrudifyApiResponse>;
552
- isInitialized: boolean;
553
- isInitializing: boolean;
554
- initializationError: string | null;
555
- isReady: () => boolean;
556
- waitForReady: () => Promise<void>;
557
- }
558
- /**
559
- * useData - Hook completo para operaciones de datos
560
- *
561
- * Este hook reemplaza completamente a useCrudifyData del sistema legacy
562
- * manteniendo 100% compatibilidad de API pero usando el nuevo SessionProvider
563
- * que proporciona mejor manejo de estados y errores.
564
- *
565
- * Funcionalidades completas:
566
- * - Verificación automática de inicialización
567
- * - Operaciones CRUD type-safe
568
- * - Soporte para transacciones
569
- * - Operaciones de login
570
- * - Gestión de estados ready
571
- * - Manejo apropiado de errores
572
- * - Compatible 100% con API legacy
573
- *
574
- * Todas las operaciones verifican que el sistema esté inicializado correctamente,
575
- * asegurando integridad de datos y previniendo fallas silenciosas.
576
- *
577
- * @example
578
- * ```tsx
579
- * function DataComponent() {
580
- * const {
581
- * readItems,
582
- * createItem,
583
- * isInitialized,
584
- * isReady
585
- * } = useData();
586
- *
587
- * const loadUsers = async () => {
588
- * if (!isReady()) {
589
- * console.warn("System not ready yet");
590
- * return;
591
- * }
592
- *
593
- * try {
594
- * const response = await readItems("users", { limit: 10 });
595
- * if (response.success) {
596
- * console.log("Users:", response.data);
597
- * }
598
- * } catch (error) {
599
- * console.error("Error loading users:", error);
600
- * }
601
- * };
602
- *
603
- * return (
604
- * <div>
605
- * <button onClick={loadUsers} disabled={!isInitialized}>
606
- * Load Users
607
- * </button>
608
- * </div>
609
- * );
610
- * }
611
- * ```
612
- */
613
- declare const useData: () => UseDataReturn;
614
-
615
- interface UseUserProfileOptions {
616
- autoFetch?: boolean;
617
- retryOnError?: boolean;
618
- maxRetries?: number;
619
- }
620
- interface UseUserProfileReturn {
621
- userProfile: UserProfile | null;
622
- loading: boolean;
623
- error: string | null;
624
- extendedData: Record<string, any>;
625
- refreshProfile: () => Promise<void>;
626
- clearProfile: () => void;
627
- }
628
- declare const useUserProfile: (options?: UseUserProfileOptions) => UseUserProfileReturn;
629
-
630
- interface JWTPayload extends JwtPayload {
631
- "cognito:username"?: string;
632
- }
633
- declare const decodeJwtSafely: (token: string) => JWTPayload | null;
634
- declare const getCurrentUserEmail: () => string | null;
635
- declare const isTokenExpired: (token: string) => boolean;
636
-
637
- declare const getCookie: (name: string) => string | null;
638
-
639
- declare class SecureStorage {
640
- private readonly encryptionKey;
641
- private readonly storage;
642
- constructor(storageType?: "localStorage" | "sessionStorage");
643
- private generateEncryptionKey;
644
- setItem(key: string, value: string, expiryMinutes?: number): void;
645
- getItem(key: string): string | null;
646
- removeItem(key: string): void;
647
- setToken(token: string): void;
648
- getToken(): string | null;
649
- }
650
- declare const secureSessionStorage: SecureStorage;
651
- declare const secureLocalStorage: SecureStorage;
652
-
653
- declare const ERROR_CODES: {
654
- readonly INVALID_CREDENTIALS: "INVALID_CREDENTIALS";
655
- readonly UNAUTHORIZED: "UNAUTHORIZED";
656
- readonly INVALID_API_KEY: "INVALID_API_KEY";
657
- readonly USER_NOT_FOUND: "USER_NOT_FOUND";
658
- readonly USER_NOT_ACTIVE: "USER_NOT_ACTIVE";
659
- readonly NO_PERMISSION: "NO_PERMISSION";
660
- readonly ITEM_NOT_FOUND: "ITEM_NOT_FOUND";
661
- readonly NOT_FOUND: "NOT_FOUND";
662
- readonly IN_USE: "IN_USE";
663
- readonly FIELD_ERROR: "FIELD_ERROR";
664
- readonly BAD_REQUEST: "BAD_REQUEST";
665
- readonly INVALID_EMAIL: "INVALID_EMAIL";
666
- readonly INVALID_CODE: "INVALID_CODE";
667
- readonly INTERNAL_SERVER_ERROR: "INTERNAL_SERVER_ERROR";
668
- readonly DATABASE_CONNECTION_ERROR: "DATABASE_CONNECTION_ERROR";
669
- readonly INVALID_CONFIGURATION: "INVALID_CONFIGURATION";
670
- readonly UNKNOWN_OPERATION: "UNKNOWN_OPERATION";
671
- readonly TOO_MANY_REQUESTS: "TOO_MANY_REQUESTS";
672
- readonly NETWORK_ERROR: "NETWORK_ERROR";
673
- readonly TIMEOUT_ERROR: "TIMEOUT_ERROR";
674
- };
675
- type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
676
- type ErrorSeverity = "info" | "warning" | "error" | "critical";
677
- declare const ERROR_SEVERITY_MAP: Record<ErrorCode, ErrorSeverity>;
678
- interface ParsedError {
679
- code: ErrorCode;
680
- message: string;
681
- severity: ErrorSeverity;
682
- field?: string;
683
- details?: Record<string, unknown>;
684
- }
685
- /**
686
- * Parse a Crudify API response and extract standardized error information
687
- */
688
- declare function parseApiError(response: unknown): ParsedError[];
689
- /**
690
- * Parse transaction response errors
691
- */
692
- declare function parseTransactionError(response: unknown): ParsedError[];
693
- /**
694
- * Get a human-readable error message for an error code
695
- */
696
- declare function getErrorMessage(code: ErrorCode): string;
697
- /**
698
- * Handle JavaScript/Network errors and convert to ParsedError
699
- */
700
- declare function parseJavaScriptError(error: unknown): ParsedError;
701
- /**
702
- * Universal error handler that can process any type of error from Crudify APIs
703
- */
704
- declare function handleCrudifyError(error: unknown): ParsedError[];
705
-
706
- /**
707
- * Utilidad robusta para traducir códigos de error con fallbacks inteligentes
708
- * Busca en múltiples namespaces y devuelve la traducción más específica disponible
709
- */
710
- interface ErrorTranslationConfig {
711
- /** Función de traducción de i18next */
712
- translateFn: (key: string) => string;
713
- /** Idioma actual (opcional, para logging) */
714
- currentLanguage?: string;
715
- /** Habilitar logs de debug */
716
- enableDebug?: boolean;
717
- }
718
- /**
719
- * Traduce un código de error usando jerarquía de fallbacks
720
- */
721
- declare function translateErrorCode(errorCode: string, config: ErrorTranslationConfig): string;
722
- /**
723
- * Traduce múltiples códigos de error
724
- */
725
- declare function translateErrorCodes(errorCodes: string[], config: ErrorTranslationConfig): string[];
726
- /**
727
- * Traduce un error completo (código + mensaje personalizado)
728
- */
729
- declare function translateError(error: {
730
- code: string;
731
- message?: string;
732
- field?: string;
733
- }, config: ErrorTranslationConfig): string;
734
- /**
735
- * Hook para usar en componentes React con i18next
736
- */
737
- declare function createErrorTranslator(translateFn: (key: string) => string, options?: {
738
- currentLanguage?: string;
739
- enableDebug?: boolean;
740
- }): {
741
- translateErrorCode: (code: string) => string;
742
- translateErrorCodes: (codes: string[]) => string[];
743
- translateError: (error: {
744
- code: string;
745
- message?: string;
746
- field?: string;
747
- }) => string;
748
- translateApiError: (apiResponse: any) => string;
749
- };
750
-
751
- type NotificationSeverity = "error" | "info" | "success" | "warning";
752
- interface Notification {
753
- id: string;
754
- message: string;
755
- severity: NotificationSeverity;
756
- autoHideDuration?: number;
757
- persistent?: boolean;
758
- allowHtml?: boolean;
759
- }
760
- interface GlobalNotificationContextValue {
761
- showNotification: (message: string, severity?: NotificationSeverity, options?: {
762
- autoHideDuration?: number;
763
- persistent?: boolean;
764
- allowHtml?: boolean;
765
- }) => string;
766
- hideNotification: (id: string) => void;
767
- clearAllNotifications: () => void;
768
- }
769
- interface GlobalNotificationProviderProps {
770
- children: React.ReactNode;
771
- maxNotifications?: number;
772
- defaultAutoHideDuration?: number;
773
- position?: {
774
- vertical: "top" | "bottom";
775
- horizontal: "left" | "center" | "right";
776
- };
777
- enabled?: boolean;
778
- allowHtml?: boolean;
779
- }
780
- declare const GlobalNotificationProvider: React.FC<GlobalNotificationProviderProps>;
781
- declare const useGlobalNotification: () => GlobalNotificationContextValue;
782
-
783
- interface CrudifyWithNotificationsOptions {
784
- showSuccessNotifications?: boolean;
785
- showErrorNotifications?: boolean;
786
- customErrorMessages?: Record<string, string>;
787
- defaultErrorMessage?: string;
788
- autoHideDuration?: number;
789
- appStructure?: any[];
790
- translateFn?: (key: string, options?: any) => string;
791
- }
792
- declare const useCrudifyWithNotifications: (options?: CrudifyWithNotificationsOptions) => {
793
- createItem: (moduleKey: string, data: object, options?: any) => Promise<CrudifyResponse>;
794
- updateItem: (moduleKey: string, data: object, options?: any) => Promise<CrudifyResponse>;
795
- deleteItem: (moduleKey: string, id: string, options?: any) => Promise<CrudifyResponse>;
796
- readItem: (moduleKey: string, filter: object, options?: any) => Promise<CrudifyResponse>;
797
- readItems: (moduleKey: string, filter: object, options?: any) => Promise<CrudifyResponse>;
798
- transaction: (data: any, options?: any) => Promise<CrudifyResponse>;
799
- handleResponse: (response: CrudifyResponse, successMessage?: string) => CrudifyResponse;
800
- getErrorMessage: (response: CrudifyResponse) => string;
801
- getErrorSeverity: (response: CrudifyResponse) => NotificationSeverity;
802
- shouldShowNotification: (response: CrudifyResponse) => boolean;
803
- };
804
-
805
- export { type ApiError, type BoxScreenType, type CrudifyApiResponse, CrudifyLogin, type CrudifyLoginConfig, type CrudifyLoginProps, type CrudifyLoginTranslations, type CrudifyTransactionResponse, ERROR_CODES, ERROR_SEVERITY_MAP, type ErrorCode, type ErrorSeverity, type ErrorTranslationConfig, type ForgotPasswordRequest, GlobalNotificationProvider, type GlobalNotificationProviderProps, type JwtPayload, LoginComponent, type LoginRequest, type LoginResponse, type LoginResult, type Notification, type NotificationOptions, type NotificationSeverity, POLICY_ACTIONS, PREFERRED_POLICY_ORDER, type ParsedError, Policies, type PolicyAction, ProtectedRoute, type ProtectedRouteProps, type ResetPasswordRequest, type SessionConfig, SessionDebugInfo, SessionManager, SessionProvider, type SessionProviderProps, type SessionState, SessionStatus, type StorageType, type TokenData, TokenStorage, type TransactionResponseData, type UseAuthReturn, type UseDataReturn, type UseSessionOptions, type UseUserDataOptions, type UseUserDataReturn, type UserData, type UserLoginData, type UserProfile, UserProfileDisplay, type ValidateCodeRequest, type ValidationError, createErrorTranslator, decodeJwtSafely, getCookie, getCurrentUserEmail, getErrorMessage, handleCrudifyError, isTokenExpired, parseApiError, parseJavaScriptError, parseTransactionError, secureLocalStorage, secureSessionStorage, translateError, translateErrorCode, translateErrorCodes, useAuth, useCrudifyWithNotifications, useData, useGlobalNotification, useSession, useSessionContext, useUserData, useUserProfile };
81
+ export { LoginResult, type NotificationOptions, ProtectedRoute, type ProtectedRouteProps, SessionDebugInfo, SessionProvider, type SessionProviderProps, TokenData, UseSessionOptions, useSessionContext };