@nocios/crudify-ui 3.0.18 → 3.0.22
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.mts +113 -2
- package/dist/index.d.ts +113 -2
- package/dist/index.js +1188 -483
- package/dist/index.mjs +1123 -425
- package/package.json +4 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CrudifyResponse } from '@nocios/crudify-browser';
|
|
1
2
|
export * from '@nocios/crudify-browser';
|
|
2
3
|
export { default as crudify } from '@nocios/crudify-browser';
|
|
3
4
|
import React, { ReactNode } from 'react';
|
|
@@ -230,7 +231,9 @@ type SessionConfig = {
|
|
|
230
231
|
type LoginResult = {
|
|
231
232
|
success: boolean;
|
|
232
233
|
tokens?: TokenData;
|
|
234
|
+
data?: any;
|
|
233
235
|
error?: string;
|
|
236
|
+
rawResponse?: any;
|
|
234
237
|
};
|
|
235
238
|
declare class SessionManager {
|
|
236
239
|
private static instance;
|
|
@@ -376,15 +379,27 @@ type SessionContextType = {
|
|
|
376
379
|
expiresIn: number;
|
|
377
380
|
refreshExpiresIn: number;
|
|
378
381
|
};
|
|
382
|
+
type NotificationOptions = {
|
|
383
|
+
enabled?: boolean;
|
|
384
|
+
maxNotifications?: number;
|
|
385
|
+
defaultAutoHideDuration?: number;
|
|
386
|
+
position?: {
|
|
387
|
+
vertical: "top" | "bottom";
|
|
388
|
+
horizontal: "left" | "center" | "right";
|
|
389
|
+
};
|
|
390
|
+
};
|
|
379
391
|
type SessionProviderProps = {
|
|
380
392
|
children: ReactNode;
|
|
381
393
|
options?: UseSessionOptions;
|
|
382
394
|
config?: CrudifyConfig;
|
|
395
|
+
showNotifications?: boolean;
|
|
396
|
+
notificationOptions?: NotificationOptions;
|
|
383
397
|
};
|
|
384
398
|
/**
|
|
385
399
|
* Provider de sesión para envolver la aplicación
|
|
386
400
|
*/
|
|
387
|
-
declare function SessionProvider({ children, options, config: propConfig
|
|
401
|
+
declare function SessionProvider({ children, options, config: propConfig, showNotifications, // ✅ Por defecto DESACTIVADO
|
|
402
|
+
notificationOptions, }: SessionProviderProps): react_jsx_runtime.JSX.Element;
|
|
388
403
|
/**
|
|
389
404
|
* Hook para usar el contexto de sesión
|
|
390
405
|
*/
|
|
@@ -673,4 +688,100 @@ declare function parseJavaScriptError(error: unknown): ParsedError;
|
|
|
673
688
|
*/
|
|
674
689
|
declare function handleCrudifyError(error: unknown): ParsedError[];
|
|
675
690
|
|
|
676
|
-
|
|
691
|
+
/**
|
|
692
|
+
* Utilidad robusta para traducir códigos de error con fallbacks inteligentes
|
|
693
|
+
* Busca en múltiples namespaces y devuelve la traducción más específica disponible
|
|
694
|
+
*/
|
|
695
|
+
interface ErrorTranslationConfig {
|
|
696
|
+
/** Función de traducción de i18next */
|
|
697
|
+
translateFn: (key: string) => string;
|
|
698
|
+
/** Idioma actual (opcional, para logging) */
|
|
699
|
+
currentLanguage?: string;
|
|
700
|
+
/** Habilitar logs de debug */
|
|
701
|
+
enableDebug?: boolean;
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* Traduce un código de error usando jerarquía de fallbacks
|
|
705
|
+
*/
|
|
706
|
+
declare function translateErrorCode(errorCode: string, config: ErrorTranslationConfig): string;
|
|
707
|
+
/**
|
|
708
|
+
* Traduce múltiples códigos de error
|
|
709
|
+
*/
|
|
710
|
+
declare function translateErrorCodes(errorCodes: string[], config: ErrorTranslationConfig): string[];
|
|
711
|
+
/**
|
|
712
|
+
* Traduce un error completo (código + mensaje personalizado)
|
|
713
|
+
*/
|
|
714
|
+
declare function translateError(error: {
|
|
715
|
+
code: string;
|
|
716
|
+
message?: string;
|
|
717
|
+
field?: string;
|
|
718
|
+
}, config: ErrorTranslationConfig): string;
|
|
719
|
+
/**
|
|
720
|
+
* Hook para usar en componentes React con i18next
|
|
721
|
+
*/
|
|
722
|
+
declare function createErrorTranslator(translateFn: (key: string) => string, options?: {
|
|
723
|
+
currentLanguage?: string;
|
|
724
|
+
enableDebug?: boolean;
|
|
725
|
+
}): {
|
|
726
|
+
translateErrorCode: (code: string) => string;
|
|
727
|
+
translateErrorCodes: (codes: string[]) => string[];
|
|
728
|
+
translateError: (error: {
|
|
729
|
+
code: string;
|
|
730
|
+
message?: string;
|
|
731
|
+
field?: string;
|
|
732
|
+
}) => string;
|
|
733
|
+
translateApiError: (apiResponse: any) => string;
|
|
734
|
+
};
|
|
735
|
+
|
|
736
|
+
type NotificationSeverity = "error" | "info" | "success" | "warning";
|
|
737
|
+
interface Notification {
|
|
738
|
+
id: string;
|
|
739
|
+
message: string;
|
|
740
|
+
severity: NotificationSeverity;
|
|
741
|
+
autoHideDuration?: number;
|
|
742
|
+
persistent?: boolean;
|
|
743
|
+
}
|
|
744
|
+
interface GlobalNotificationContextValue {
|
|
745
|
+
showNotification: (message: string, severity?: NotificationSeverity, options?: {
|
|
746
|
+
autoHideDuration?: number;
|
|
747
|
+
persistent?: boolean;
|
|
748
|
+
}) => string;
|
|
749
|
+
hideNotification: (id: string) => void;
|
|
750
|
+
clearAllNotifications: () => void;
|
|
751
|
+
}
|
|
752
|
+
interface GlobalNotificationProviderProps {
|
|
753
|
+
children: React.ReactNode;
|
|
754
|
+
maxNotifications?: number;
|
|
755
|
+
defaultAutoHideDuration?: number;
|
|
756
|
+
position?: {
|
|
757
|
+
vertical: "top" | "bottom";
|
|
758
|
+
horizontal: "left" | "center" | "right";
|
|
759
|
+
};
|
|
760
|
+
enabled?: boolean;
|
|
761
|
+
}
|
|
762
|
+
declare const GlobalNotificationProvider: React.FC<GlobalNotificationProviderProps>;
|
|
763
|
+
declare const useGlobalNotification: () => GlobalNotificationContextValue;
|
|
764
|
+
|
|
765
|
+
interface CrudifyWithNotificationsOptions {
|
|
766
|
+
showSuccessNotifications?: boolean;
|
|
767
|
+
showErrorNotifications?: boolean;
|
|
768
|
+
customErrorMessages?: Record<string, string>;
|
|
769
|
+
defaultErrorMessage?: string;
|
|
770
|
+
autoHideDuration?: number;
|
|
771
|
+
appStructure?: any[];
|
|
772
|
+
translateFn?: (key: string, options?: any) => string;
|
|
773
|
+
}
|
|
774
|
+
declare const useCrudifyWithNotifications: (options?: CrudifyWithNotificationsOptions) => {
|
|
775
|
+
createItem: (moduleKey: string, data: object, options?: any) => Promise<CrudifyResponse>;
|
|
776
|
+
updateItem: (moduleKey: string, data: object, options?: any) => Promise<CrudifyResponse>;
|
|
777
|
+
deleteItem: (moduleKey: string, id: string, options?: any) => Promise<CrudifyResponse>;
|
|
778
|
+
readItem: (moduleKey: string, filter: object, options?: any) => Promise<CrudifyResponse>;
|
|
779
|
+
readItems: (moduleKey: string, filter: object, options?: any) => Promise<CrudifyResponse>;
|
|
780
|
+
transaction: (data: any, options?: any) => Promise<CrudifyResponse>;
|
|
781
|
+
handleResponse: (response: CrudifyResponse, successMessage?: string) => CrudifyResponse;
|
|
782
|
+
getErrorMessage: (response: CrudifyResponse) => string;
|
|
783
|
+
getErrorSeverity: (response: CrudifyResponse) => NotificationSeverity;
|
|
784
|
+
shouldShowNotification: (response: CrudifyResponse) => boolean;
|
|
785
|
+
};
|
|
786
|
+
|
|
787
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CrudifyResponse } from '@nocios/crudify-browser';
|
|
1
2
|
export * from '@nocios/crudify-browser';
|
|
2
3
|
export { default as crudify } from '@nocios/crudify-browser';
|
|
3
4
|
import React, { ReactNode } from 'react';
|
|
@@ -230,7 +231,9 @@ type SessionConfig = {
|
|
|
230
231
|
type LoginResult = {
|
|
231
232
|
success: boolean;
|
|
232
233
|
tokens?: TokenData;
|
|
234
|
+
data?: any;
|
|
233
235
|
error?: string;
|
|
236
|
+
rawResponse?: any;
|
|
234
237
|
};
|
|
235
238
|
declare class SessionManager {
|
|
236
239
|
private static instance;
|
|
@@ -376,15 +379,27 @@ type SessionContextType = {
|
|
|
376
379
|
expiresIn: number;
|
|
377
380
|
refreshExpiresIn: number;
|
|
378
381
|
};
|
|
382
|
+
type NotificationOptions = {
|
|
383
|
+
enabled?: boolean;
|
|
384
|
+
maxNotifications?: number;
|
|
385
|
+
defaultAutoHideDuration?: number;
|
|
386
|
+
position?: {
|
|
387
|
+
vertical: "top" | "bottom";
|
|
388
|
+
horizontal: "left" | "center" | "right";
|
|
389
|
+
};
|
|
390
|
+
};
|
|
379
391
|
type SessionProviderProps = {
|
|
380
392
|
children: ReactNode;
|
|
381
393
|
options?: UseSessionOptions;
|
|
382
394
|
config?: CrudifyConfig;
|
|
395
|
+
showNotifications?: boolean;
|
|
396
|
+
notificationOptions?: NotificationOptions;
|
|
383
397
|
};
|
|
384
398
|
/**
|
|
385
399
|
* Provider de sesión para envolver la aplicación
|
|
386
400
|
*/
|
|
387
|
-
declare function SessionProvider({ children, options, config: propConfig
|
|
401
|
+
declare function SessionProvider({ children, options, config: propConfig, showNotifications, // ✅ Por defecto DESACTIVADO
|
|
402
|
+
notificationOptions, }: SessionProviderProps): react_jsx_runtime.JSX.Element;
|
|
388
403
|
/**
|
|
389
404
|
* Hook para usar el contexto de sesión
|
|
390
405
|
*/
|
|
@@ -673,4 +688,100 @@ declare function parseJavaScriptError(error: unknown): ParsedError;
|
|
|
673
688
|
*/
|
|
674
689
|
declare function handleCrudifyError(error: unknown): ParsedError[];
|
|
675
690
|
|
|
676
|
-
|
|
691
|
+
/**
|
|
692
|
+
* Utilidad robusta para traducir códigos de error con fallbacks inteligentes
|
|
693
|
+
* Busca en múltiples namespaces y devuelve la traducción más específica disponible
|
|
694
|
+
*/
|
|
695
|
+
interface ErrorTranslationConfig {
|
|
696
|
+
/** Función de traducción de i18next */
|
|
697
|
+
translateFn: (key: string) => string;
|
|
698
|
+
/** Idioma actual (opcional, para logging) */
|
|
699
|
+
currentLanguage?: string;
|
|
700
|
+
/** Habilitar logs de debug */
|
|
701
|
+
enableDebug?: boolean;
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* Traduce un código de error usando jerarquía de fallbacks
|
|
705
|
+
*/
|
|
706
|
+
declare function translateErrorCode(errorCode: string, config: ErrorTranslationConfig): string;
|
|
707
|
+
/**
|
|
708
|
+
* Traduce múltiples códigos de error
|
|
709
|
+
*/
|
|
710
|
+
declare function translateErrorCodes(errorCodes: string[], config: ErrorTranslationConfig): string[];
|
|
711
|
+
/**
|
|
712
|
+
* Traduce un error completo (código + mensaje personalizado)
|
|
713
|
+
*/
|
|
714
|
+
declare function translateError(error: {
|
|
715
|
+
code: string;
|
|
716
|
+
message?: string;
|
|
717
|
+
field?: string;
|
|
718
|
+
}, config: ErrorTranslationConfig): string;
|
|
719
|
+
/**
|
|
720
|
+
* Hook para usar en componentes React con i18next
|
|
721
|
+
*/
|
|
722
|
+
declare function createErrorTranslator(translateFn: (key: string) => string, options?: {
|
|
723
|
+
currentLanguage?: string;
|
|
724
|
+
enableDebug?: boolean;
|
|
725
|
+
}): {
|
|
726
|
+
translateErrorCode: (code: string) => string;
|
|
727
|
+
translateErrorCodes: (codes: string[]) => string[];
|
|
728
|
+
translateError: (error: {
|
|
729
|
+
code: string;
|
|
730
|
+
message?: string;
|
|
731
|
+
field?: string;
|
|
732
|
+
}) => string;
|
|
733
|
+
translateApiError: (apiResponse: any) => string;
|
|
734
|
+
};
|
|
735
|
+
|
|
736
|
+
type NotificationSeverity = "error" | "info" | "success" | "warning";
|
|
737
|
+
interface Notification {
|
|
738
|
+
id: string;
|
|
739
|
+
message: string;
|
|
740
|
+
severity: NotificationSeverity;
|
|
741
|
+
autoHideDuration?: number;
|
|
742
|
+
persistent?: boolean;
|
|
743
|
+
}
|
|
744
|
+
interface GlobalNotificationContextValue {
|
|
745
|
+
showNotification: (message: string, severity?: NotificationSeverity, options?: {
|
|
746
|
+
autoHideDuration?: number;
|
|
747
|
+
persistent?: boolean;
|
|
748
|
+
}) => string;
|
|
749
|
+
hideNotification: (id: string) => void;
|
|
750
|
+
clearAllNotifications: () => void;
|
|
751
|
+
}
|
|
752
|
+
interface GlobalNotificationProviderProps {
|
|
753
|
+
children: React.ReactNode;
|
|
754
|
+
maxNotifications?: number;
|
|
755
|
+
defaultAutoHideDuration?: number;
|
|
756
|
+
position?: {
|
|
757
|
+
vertical: "top" | "bottom";
|
|
758
|
+
horizontal: "left" | "center" | "right";
|
|
759
|
+
};
|
|
760
|
+
enabled?: boolean;
|
|
761
|
+
}
|
|
762
|
+
declare const GlobalNotificationProvider: React.FC<GlobalNotificationProviderProps>;
|
|
763
|
+
declare const useGlobalNotification: () => GlobalNotificationContextValue;
|
|
764
|
+
|
|
765
|
+
interface CrudifyWithNotificationsOptions {
|
|
766
|
+
showSuccessNotifications?: boolean;
|
|
767
|
+
showErrorNotifications?: boolean;
|
|
768
|
+
customErrorMessages?: Record<string, string>;
|
|
769
|
+
defaultErrorMessage?: string;
|
|
770
|
+
autoHideDuration?: number;
|
|
771
|
+
appStructure?: any[];
|
|
772
|
+
translateFn?: (key: string, options?: any) => string;
|
|
773
|
+
}
|
|
774
|
+
declare const useCrudifyWithNotifications: (options?: CrudifyWithNotificationsOptions) => {
|
|
775
|
+
createItem: (moduleKey: string, data: object, options?: any) => Promise<CrudifyResponse>;
|
|
776
|
+
updateItem: (moduleKey: string, data: object, options?: any) => Promise<CrudifyResponse>;
|
|
777
|
+
deleteItem: (moduleKey: string, id: string, options?: any) => Promise<CrudifyResponse>;
|
|
778
|
+
readItem: (moduleKey: string, filter: object, options?: any) => Promise<CrudifyResponse>;
|
|
779
|
+
readItems: (moduleKey: string, filter: object, options?: any) => Promise<CrudifyResponse>;
|
|
780
|
+
transaction: (data: any, options?: any) => Promise<CrudifyResponse>;
|
|
781
|
+
handleResponse: (response: CrudifyResponse, successMessage?: string) => CrudifyResponse;
|
|
782
|
+
getErrorMessage: (response: CrudifyResponse) => string;
|
|
783
|
+
getErrorSeverity: (response: CrudifyResponse) => NotificationSeverity;
|
|
784
|
+
shouldShowNotification: (response: CrudifyResponse) => boolean;
|
|
785
|
+
};
|
|
786
|
+
|
|
787
|
+
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 };
|