@nocios/crudify-ui 4.4.72 → 4.4.76
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/{CrudiaMarkdownField-Bs940oF4.d.ts → CrudiaMarkdownField-C30enyF9.d.ts} +2 -2
- package/dist/{CrudiaMarkdownField-CKPdr2JL.d.mts → CrudiaMarkdownField-D-VooBtq.d.mts} +2 -2
- package/dist/{api-Djqihi4n.d.mts → api-RK-xY1Ah.d.mts} +22 -2
- package/dist/{api-Djqihi4n.d.ts → api-RK-xY1Ah.d.ts} +22 -2
- package/dist/chunk-2G33BADS.mjs +1 -0
- package/dist/{chunk-ZANWILS7.mjs → chunk-7J5RTLCS.mjs} +1 -1
- package/dist/chunk-AEHAZP5F.js +1 -0
- package/dist/{chunk-4LSVF26Q.js → chunk-D3NBX3SM.js} +1 -1
- package/dist/chunk-GCH3QGKL.mjs +1 -0
- package/dist/chunk-GNGIFVA4.js +1 -0
- package/dist/{chunk-L454VIXN.js → chunk-HDNGW5H5.js} +1 -1
- package/dist/chunk-IYTXJHKO.js +1 -0
- package/dist/{chunk-Q5EJLSB4.mjs → chunk-NZIH26GS.mjs} +1 -1
- package/dist/chunk-ZKWTILQT.mjs +1 -0
- package/dist/components.d.mts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +1 -1
- package/dist/components.mjs +1 -1
- package/dist/{errorTranslation-BuEEtVg4.d.mts → errorTranslation-B4wcHzD3.d.mts} +1 -1
- package/dist/{errorTranslation-BIyBYuGF.d.ts → errorTranslation-CCC5IWoN.d.ts} +1 -1
- package/dist/hooks.d.mts +4 -3
- package/dist/hooks.d.ts +4 -3
- package/dist/hooks.js +1 -1
- package/dist/hooks.mjs +1 -1
- package/dist/{index-CQnAzvOE.d.mts → index-DEnlzdtV.d.mts} +90 -16
- package/dist/{index-BVT7flO5.d.ts → index-pQmuVg3q.d.ts} +90 -16
- package/dist/index.d.mts +101 -70
- package/dist/index.d.ts +101 -70
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/utils.d.mts +11 -4
- package/dist/utils.d.ts +11 -4
- package/dist/utils.js +1 -1
- package/dist/utils.mjs +1 -1
- package/package.json +3 -3
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/configResolver.ts.html +0 -499
- package/coverage/coverage-final.json +0 -2
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -116
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -210
- package/dist/chunk-JCMHUFYK.mjs +0 -1
- package/dist/chunk-LPC6P3Z7.mjs +0 -1
- package/dist/chunk-SEDLJT7G.js +0 -1
- package/dist/chunk-UJD6SL66.mjs +0 -1
- package/dist/chunk-X3JFRSEA.js +0 -1
- package/dist/chunk-YLKGZV2N.js +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import crudify__default from '@nocios/crudify-browser';
|
|
2
2
|
export * from '@nocios/crudify-browser';
|
|
3
3
|
export { default as crudify } from '@nocios/crudify-browser';
|
|
4
|
-
import { d as CrudifyLoginConfig } from './CrudiaMarkdownField-
|
|
5
|
-
export { B as BoxScreenType, a as CrudiaAutoGenerate, i as CrudiaAutoGenerateProps, b as CrudiaFileField, j as CrudiaFileFieldProps, c as CrudiaMarkdownField, k as CrudiaMarkdownFieldProps, C as CrudifyLogin, e as CrudifyLoginProps, f as CrudifyLoginTranslations, L as LoginComponent, l as POLICY_ACTIONS, m as PREFERRED_POLICY_ORDER, P as Policies, h as PolicyAction, S as SessionStatus, g as UserLoginData, U as UserProfileDisplay } from './CrudiaMarkdownField-
|
|
4
|
+
import { d as CrudifyLoginConfig } from './CrudiaMarkdownField-D-VooBtq.mjs';
|
|
5
|
+
export { B as BoxScreenType, a as CrudiaAutoGenerate, i as CrudiaAutoGenerateProps, b as CrudiaFileField, j as CrudiaFileFieldProps, c as CrudiaMarkdownField, k as CrudiaMarkdownFieldProps, C as CrudifyLogin, e as CrudifyLoginProps, f as CrudifyLoginTranslations, L as LoginComponent, l as POLICY_ACTIONS, m as PREFERRED_POLICY_ORDER, P as Policies, h as PolicyAction, S as SessionStatus, g as UserLoginData, U as UserProfileDisplay } from './CrudiaMarkdownField-D-VooBtq.mjs';
|
|
6
6
|
import React, { ReactNode } from 'react';
|
|
7
|
-
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-
|
|
8
|
-
|
|
9
|
-
export { F as FileItem, q as FileStatus, a as SessionConfig, S as SessionManager, d as SessionState, c as StorageType, b as TokenStorage, j as UseAuthReturn, l as UseDataReturn, o as UseFileUploadOptions, p as UseFileUploadReturn, g as UseUserDataOptions, f as UseUserDataReturn, h as UserData, i as useAuth, r as useCrudifyWithNotifications, k as useData, n as useFileUpload, u as useSession, e as useUserData, m as useUserProfile } from './index-CQnAzvOE.mjs';
|
|
7
|
+
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-RK-xY1Ah.mjs';
|
|
8
|
+
export { F as FileItem, v as FileStatus, L as LoginResult, N as NotificationOptions, a as SessionConfig, g as SessionDebugInfo, S as SessionManager, e as SessionProvider, h as SessionProviderProps, d as SessionState, c as StorageType, b as TokenData, T as TokenStorage, n as UseAuthReturn, p as UseDataReturn, s as UseFileUploadOptions, t as UseFileUploadReturn, U as UseSessionOptions, k as UseUserDataOptions, j as UseUserDataReturn, l as UserData, m as useAuth, w as useCrudifyWithNotifications, o as useData, r as useFileUpload, u as useSession, f as useSessionContext, i as useUserData, q as useUserProfile } from './index-DEnlzdtV.mjs';
|
|
10
9
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
11
10
|
import { ThemeOptions } from '@mui/material';
|
|
12
11
|
export { A as AutoGenerateConfig, G as GlobalNotificationProvider, a as GlobalNotificationProviderProps, N as Notification, b as NotificationSeverity, d as UseAutoGenerateOptions, U as UseAutoGenerateReturn, c as useAutoGenerate, u as useGlobalNotification } from './GlobalNotificationProvider-Zq18OkpI.mjs';
|
|
13
|
-
export { E as ERROR_CODES, j as ERROR_SEVERITY_MAP, n as ErrorCode, o as ErrorSeverity, q as ErrorTranslationConfig, P as ParsedError, m as createErrorTranslator, d as decodeJwtSafely, a as getCookie, g as getCurrentUserEmail, f as getErrorMessage, h as handleCrudifyError, i as isTokenExpired, p as parseApiError, e as parseJavaScriptError, c as parseTransactionError, b as secureLocalStorage, s as secureSessionStorage, l as translateError, t as translateErrorCode, k as translateErrorCodes } from './errorTranslation-
|
|
12
|
+
export { E as ERROR_CODES, j as ERROR_SEVERITY_MAP, n as ErrorCode, o as ErrorSeverity, q as ErrorTranslationConfig, P as ParsedError, m as createErrorTranslator, d as decodeJwtSafely, a as getCookie, g as getCurrentUserEmail, f as getErrorMessage, h as handleCrudifyError, i as isTokenExpired, p as parseApiError, e as parseJavaScriptError, c as parseTransactionError, b as secureLocalStorage, s as secureSessionStorage, l as translateError, t as translateErrorCode, k as translateErrorCodes } from './errorTranslation-B4wcHzD3.mjs';
|
|
14
13
|
import { ApiResponse, IModule, ModuleCreateInput, ModuleEditInput, ActionListFilters, IAction, ActionCreateInput, ActionEditInput, UpdateActionsProfilesInput, UpdateActionsProfilesResponse } from '@nocios/crudify-admin';
|
|
15
14
|
export { ActionCreateInput, ActionEditInput, ActionListFilters, ApiResponse, IAction, IModule, ModuleCreateInput, ModuleEditInput, UpdateActionsProfilesInput, UpdateActionsProfilesResponse } from '@nocios/crudify-admin';
|
|
16
15
|
|
|
@@ -31,67 +30,6 @@ interface CrudifyProviderProps {
|
|
|
31
30
|
declare const CrudifyProvider: React.FC<CrudifyProviderProps>;
|
|
32
31
|
declare const useCrudify: () => CrudifyContextValue;
|
|
33
32
|
|
|
34
|
-
type SessionData = {
|
|
35
|
-
_id: string;
|
|
36
|
-
email: string;
|
|
37
|
-
subscriberKey: string;
|
|
38
|
-
[key: string]: any;
|
|
39
|
-
} | null;
|
|
40
|
-
type CrudifyConfig = {
|
|
41
|
-
publicApiKey?: string;
|
|
42
|
-
env?: "dev" | "stg" | "api" | "prod";
|
|
43
|
-
appName?: string;
|
|
44
|
-
loginActions?: string[];
|
|
45
|
-
logo?: string;
|
|
46
|
-
};
|
|
47
|
-
type SessionContextType = {
|
|
48
|
-
isAuthenticated: boolean;
|
|
49
|
-
isLoading: boolean;
|
|
50
|
-
isInitialized: boolean;
|
|
51
|
-
tokens: TokenData | null;
|
|
52
|
-
error: string | null;
|
|
53
|
-
sessionData: SessionData;
|
|
54
|
-
config: CrudifyConfig;
|
|
55
|
-
login: (email: string, password: string) => Promise<LoginResult>;
|
|
56
|
-
logout: () => Promise<void>;
|
|
57
|
-
refreshTokens: () => Promise<boolean>;
|
|
58
|
-
clearError: () => void;
|
|
59
|
-
getTokenInfo: () => any;
|
|
60
|
-
isExpiringSoon: boolean;
|
|
61
|
-
expiresIn: number;
|
|
62
|
-
refreshExpiresIn: number;
|
|
63
|
-
};
|
|
64
|
-
type NotificationOptions = {
|
|
65
|
-
enabled?: boolean;
|
|
66
|
-
maxNotifications?: number;
|
|
67
|
-
defaultAutoHideDuration?: number;
|
|
68
|
-
position?: {
|
|
69
|
-
vertical: "top" | "bottom";
|
|
70
|
-
horizontal: "left" | "center" | "right";
|
|
71
|
-
};
|
|
72
|
-
allowHtml?: boolean;
|
|
73
|
-
};
|
|
74
|
-
type SessionProviderProps = {
|
|
75
|
-
children: ReactNode;
|
|
76
|
-
options?: UseSessionOptions;
|
|
77
|
-
config?: CrudifyConfig;
|
|
78
|
-
showNotifications?: boolean;
|
|
79
|
-
notificationOptions?: NotificationOptions;
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Main session provider to wrap the application.
|
|
83
|
-
* Auto-initializes internal CrudifyProvider if config.publicApiKey is provided.
|
|
84
|
-
*/
|
|
85
|
-
declare function SessionProvider(props: SessionProviderProps): react_jsx_runtime.JSX.Element;
|
|
86
|
-
/**
|
|
87
|
-
* Hook para usar el contexto de sesión
|
|
88
|
-
*/
|
|
89
|
-
declare function useSessionContext(): SessionContextType;
|
|
90
|
-
/**
|
|
91
|
-
* Componente para mostrar información de la sesión (debug)
|
|
92
|
-
*/
|
|
93
|
-
declare function SessionDebugInfo(): react_jsx_runtime.JSX.Element;
|
|
94
|
-
|
|
95
33
|
type CrudifyThemeProviderProps = {
|
|
96
34
|
children: ReactNode;
|
|
97
35
|
defaultTheme?: ThemeOptions;
|
|
@@ -117,6 +55,97 @@ type CrudifyThemeProviderProps = {
|
|
|
117
55
|
*/
|
|
118
56
|
declare function CrudifyThemeProvider({ children, defaultTheme, disableCssBaseline }: CrudifyThemeProviderProps): react_jsx_runtime.JSX.Element;
|
|
119
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Unified Logger for Crudify Projects
|
|
60
|
+
*
|
|
61
|
+
* Environment-based logging:
|
|
62
|
+
* - dev/stg: All logs (error, warn, info, debug)
|
|
63
|
+
* - prod: Only errors (default)
|
|
64
|
+
*
|
|
65
|
+
* AUTO-DETECTION:
|
|
66
|
+
* The logger will automatically detect the environment from:
|
|
67
|
+
* 1. Explicit setEnvironment() call (highest priority)
|
|
68
|
+
* 2. Cookie named 'environment' (for production with Lambda@Edge)
|
|
69
|
+
* 3. window.__CRUDIFY_ENV__ global variable
|
|
70
|
+
* 4. Default to "prod" for safety
|
|
71
|
+
*
|
|
72
|
+
* Usage:
|
|
73
|
+
* import { logger } from './logger';
|
|
74
|
+
*
|
|
75
|
+
* // Option 1: Explicit configuration (recommended for apps)
|
|
76
|
+
* logger.setEnvironment('dev'); // or 'stg', 'prod'
|
|
77
|
+
*
|
|
78
|
+
* // Option 2: Auto-detection (reads cookie or global)
|
|
79
|
+
* // Just use the logger - it will auto-detect
|
|
80
|
+
*
|
|
81
|
+
* logger.error('Something failed', { userId: '123' });
|
|
82
|
+
* logger.warn('Deprecated feature used');
|
|
83
|
+
* logger.info('User logged in', { email: 'user@example.com' });
|
|
84
|
+
* logger.debug('Processing request', { payload: data });
|
|
85
|
+
*/
|
|
86
|
+
type LogLevel = "error" | "warn" | "info" | "debug";
|
|
87
|
+
interface LogContext {
|
|
88
|
+
[key: string]: unknown;
|
|
89
|
+
}
|
|
90
|
+
declare class Logger {
|
|
91
|
+
private explicitEnv;
|
|
92
|
+
private prefix;
|
|
93
|
+
constructor();
|
|
94
|
+
/**
|
|
95
|
+
* Get current effective environment
|
|
96
|
+
* Priority: explicit setEnvironment() > auto-detection
|
|
97
|
+
*/
|
|
98
|
+
private getEffectiveEnv;
|
|
99
|
+
/**
|
|
100
|
+
* Sanitize sensitive data from strings
|
|
101
|
+
*/
|
|
102
|
+
private sanitize;
|
|
103
|
+
/**
|
|
104
|
+
* Sanitize context object
|
|
105
|
+
*/
|
|
106
|
+
private sanitizeContext;
|
|
107
|
+
/**
|
|
108
|
+
* Check if a log level should be displayed based on environment
|
|
109
|
+
* - dev/stg: show all logs
|
|
110
|
+
* - prod: show only errors
|
|
111
|
+
*/
|
|
112
|
+
private shouldLog;
|
|
113
|
+
/**
|
|
114
|
+
* Format and output log entry
|
|
115
|
+
*/
|
|
116
|
+
private log;
|
|
117
|
+
/**
|
|
118
|
+
* Log an error - Always logged in all environments
|
|
119
|
+
*/
|
|
120
|
+
error(message: string, context?: LogContext | Error): void;
|
|
121
|
+
/**
|
|
122
|
+
* Log a warning - Only in dev/stg
|
|
123
|
+
*/
|
|
124
|
+
warn(message: string, context?: LogContext): void;
|
|
125
|
+
/**
|
|
126
|
+
* Log info - Only in dev/stg
|
|
127
|
+
*/
|
|
128
|
+
info(message: string, context?: LogContext): void;
|
|
129
|
+
/**
|
|
130
|
+
* Log debug information - Only in dev/stg
|
|
131
|
+
*/
|
|
132
|
+
debug(message: string, context?: LogContext): void;
|
|
133
|
+
/**
|
|
134
|
+
* Get current effective environment
|
|
135
|
+
*/
|
|
136
|
+
getEnvironment(): string;
|
|
137
|
+
/**
|
|
138
|
+
* Manually set environment (useful for libraries that receive env from parent app)
|
|
139
|
+
* This takes priority over auto-detection
|
|
140
|
+
*/
|
|
141
|
+
setEnvironment(env: string): void;
|
|
142
|
+
/**
|
|
143
|
+
* Check if environment was explicitly set or auto-detected
|
|
144
|
+
*/
|
|
145
|
+
isExplicitlyConfigured(): boolean;
|
|
146
|
+
}
|
|
147
|
+
declare const logger: Logger;
|
|
148
|
+
|
|
120
149
|
interface ProtectedRouteProps {
|
|
121
150
|
children: ReactNode;
|
|
122
151
|
/**
|
|
@@ -485,12 +514,14 @@ interface TranslationsProviderProps {
|
|
|
485
514
|
enableDebug?: boolean;
|
|
486
515
|
skipAutoInit?: boolean;
|
|
487
516
|
autoSyncI18n?: boolean;
|
|
488
|
-
i18nInstance?:
|
|
517
|
+
i18nInstance?: {
|
|
518
|
+
addResourceBundle: (lang: string, ns: string, resources: Record<string, string>, deep?: boolean, overwrite?: boolean) => void;
|
|
519
|
+
};
|
|
489
520
|
loadingFallback?: React.ReactNode;
|
|
490
521
|
waitForInitialLoad?: boolean;
|
|
491
522
|
}
|
|
492
523
|
interface TranslationsContextValue {
|
|
493
|
-
t: (key: string, variables?: Record<string,
|
|
524
|
+
t: (key: string, variables?: Record<string, string | number>) => string;
|
|
494
525
|
language: string;
|
|
495
526
|
availableLanguages: string[];
|
|
496
527
|
translations: Record<string, Record<string, string>>;
|
|
@@ -947,4 +978,4 @@ declare const crudifyAdmin: {
|
|
|
947
978
|
updateActionsProfiles: (data: UpdateActionsProfilesInput) => Promise<ApiResponse<UpdateActionsProfilesResponse>>;
|
|
948
979
|
};
|
|
949
980
|
|
|
950
|
-
export { AuthRoute, type AuthRouteProps, CRITICAL_TRANSLATIONS, type CriticalTranslationKey, CrudifyInitializationManager, CrudifyInitializer, type CrudifyInitializerConfig, type CrudifyInitializerProps, CrudifyLoginConfig, CrudifyProvider, CrudifyThemeProvider, type CrudifyThemeProviderProps, type FetchTranslationsOptions, type InitializationPriority, type InitializationRequest, type InitializationStatus,
|
|
981
|
+
export { AuthRoute, type AuthRouteProps, CRITICAL_TRANSLATIONS, type CriticalTranslationKey, CrudifyInitializationManager, CrudifyInitializer, type CrudifyInitializerConfig, type CrudifyInitializerProps, CrudifyLoginConfig, CrudifyProvider, CrudifyThemeProvider, type CrudifyThemeProviderProps, type FetchTranslationsOptions, type InitializationPriority, type InitializationRequest, type InitializationStatus, type LogContext, type LogLevel, ProtectedRoute, type ProtectedRouteProps, SessionLoadingScreen, type SessionLoadingScreenProps, type SupportedLanguage, type TranslationResponse, TranslationService, type TranslationsContextValue, TranslationsProvider, type TranslationsProviderProps, crudifyAdmin, crudifyInitManager, extractSafeRedirectFromUrl, getCriticalLanguages, getCriticalTranslations, logger, translationService, useCrudify, useCrudifyInitializer, useTranslations, validateInternalRedirect };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import crudify__default from '@nocios/crudify-browser';
|
|
2
2
|
export * from '@nocios/crudify-browser';
|
|
3
3
|
export { default as crudify } from '@nocios/crudify-browser';
|
|
4
|
-
import { d as CrudifyLoginConfig } from './CrudiaMarkdownField-
|
|
5
|
-
export { B as BoxScreenType, a as CrudiaAutoGenerate, i as CrudiaAutoGenerateProps, b as CrudiaFileField, j as CrudiaFileFieldProps, c as CrudiaMarkdownField, k as CrudiaMarkdownFieldProps, C as CrudifyLogin, e as CrudifyLoginProps, f as CrudifyLoginTranslations, L as LoginComponent, l as POLICY_ACTIONS, m as PREFERRED_POLICY_ORDER, P as Policies, h as PolicyAction, S as SessionStatus, g as UserLoginData, U as UserProfileDisplay } from './CrudiaMarkdownField-
|
|
4
|
+
import { d as CrudifyLoginConfig } from './CrudiaMarkdownField-C30enyF9.js';
|
|
5
|
+
export { B as BoxScreenType, a as CrudiaAutoGenerate, i as CrudiaAutoGenerateProps, b as CrudiaFileField, j as CrudiaFileFieldProps, c as CrudiaMarkdownField, k as CrudiaMarkdownFieldProps, C as CrudifyLogin, e as CrudifyLoginProps, f as CrudifyLoginTranslations, L as LoginComponent, l as POLICY_ACTIONS, m as PREFERRED_POLICY_ORDER, P as Policies, h as PolicyAction, S as SessionStatus, g as UserLoginData, U as UserProfileDisplay } from './CrudiaMarkdownField-C30enyF9.js';
|
|
6
6
|
import React, { ReactNode } from 'react';
|
|
7
|
-
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-
|
|
8
|
-
|
|
9
|
-
export { F as FileItem, q as FileStatus, a as SessionConfig, S as SessionManager, d as SessionState, c as StorageType, b as TokenStorage, j as UseAuthReturn, l as UseDataReturn, o as UseFileUploadOptions, p as UseFileUploadReturn, g as UseUserDataOptions, f as UseUserDataReturn, h as UserData, i as useAuth, r as useCrudifyWithNotifications, k as useData, n as useFileUpload, u as useSession, e as useUserData, m as useUserProfile } from './index-BVT7flO5.js';
|
|
7
|
+
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-RK-xY1Ah.js';
|
|
8
|
+
export { F as FileItem, v as FileStatus, L as LoginResult, N as NotificationOptions, a as SessionConfig, g as SessionDebugInfo, S as SessionManager, e as SessionProvider, h as SessionProviderProps, d as SessionState, c as StorageType, b as TokenData, T as TokenStorage, n as UseAuthReturn, p as UseDataReturn, s as UseFileUploadOptions, t as UseFileUploadReturn, U as UseSessionOptions, k as UseUserDataOptions, j as UseUserDataReturn, l as UserData, m as useAuth, w as useCrudifyWithNotifications, o as useData, r as useFileUpload, u as useSession, f as useSessionContext, i as useUserData, q as useUserProfile } from './index-pQmuVg3q.js';
|
|
10
9
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
11
10
|
import { ThemeOptions } from '@mui/material';
|
|
12
11
|
export { A as AutoGenerateConfig, G as GlobalNotificationProvider, a as GlobalNotificationProviderProps, N as Notification, b as NotificationSeverity, d as UseAutoGenerateOptions, U as UseAutoGenerateReturn, c as useAutoGenerate, u as useGlobalNotification } from './GlobalNotificationProvider-Zq18OkpI.js';
|
|
13
|
-
export { E as ERROR_CODES, j as ERROR_SEVERITY_MAP, n as ErrorCode, o as ErrorSeverity, q as ErrorTranslationConfig, P as ParsedError, m as createErrorTranslator, d as decodeJwtSafely, a as getCookie, g as getCurrentUserEmail, f as getErrorMessage, h as handleCrudifyError, i as isTokenExpired, p as parseApiError, e as parseJavaScriptError, c as parseTransactionError, b as secureLocalStorage, s as secureSessionStorage, l as translateError, t as translateErrorCode, k as translateErrorCodes } from './errorTranslation-
|
|
12
|
+
export { E as ERROR_CODES, j as ERROR_SEVERITY_MAP, n as ErrorCode, o as ErrorSeverity, q as ErrorTranslationConfig, P as ParsedError, m as createErrorTranslator, d as decodeJwtSafely, a as getCookie, g as getCurrentUserEmail, f as getErrorMessage, h as handleCrudifyError, i as isTokenExpired, p as parseApiError, e as parseJavaScriptError, c as parseTransactionError, b as secureLocalStorage, s as secureSessionStorage, l as translateError, t as translateErrorCode, k as translateErrorCodes } from './errorTranslation-CCC5IWoN.js';
|
|
14
13
|
import { ApiResponse, IModule, ModuleCreateInput, ModuleEditInput, ActionListFilters, IAction, ActionCreateInput, ActionEditInput, UpdateActionsProfilesInput, UpdateActionsProfilesResponse } from '@nocios/crudify-admin';
|
|
15
14
|
export { ActionCreateInput, ActionEditInput, ActionListFilters, ApiResponse, IAction, IModule, ModuleCreateInput, ModuleEditInput, UpdateActionsProfilesInput, UpdateActionsProfilesResponse } from '@nocios/crudify-admin';
|
|
16
15
|
|
|
@@ -31,67 +30,6 @@ interface CrudifyProviderProps {
|
|
|
31
30
|
declare const CrudifyProvider: React.FC<CrudifyProviderProps>;
|
|
32
31
|
declare const useCrudify: () => CrudifyContextValue;
|
|
33
32
|
|
|
34
|
-
type SessionData = {
|
|
35
|
-
_id: string;
|
|
36
|
-
email: string;
|
|
37
|
-
subscriberKey: string;
|
|
38
|
-
[key: string]: any;
|
|
39
|
-
} | null;
|
|
40
|
-
type CrudifyConfig = {
|
|
41
|
-
publicApiKey?: string;
|
|
42
|
-
env?: "dev" | "stg" | "api" | "prod";
|
|
43
|
-
appName?: string;
|
|
44
|
-
loginActions?: string[];
|
|
45
|
-
logo?: string;
|
|
46
|
-
};
|
|
47
|
-
type SessionContextType = {
|
|
48
|
-
isAuthenticated: boolean;
|
|
49
|
-
isLoading: boolean;
|
|
50
|
-
isInitialized: boolean;
|
|
51
|
-
tokens: TokenData | null;
|
|
52
|
-
error: string | null;
|
|
53
|
-
sessionData: SessionData;
|
|
54
|
-
config: CrudifyConfig;
|
|
55
|
-
login: (email: string, password: string) => Promise<LoginResult>;
|
|
56
|
-
logout: () => Promise<void>;
|
|
57
|
-
refreshTokens: () => Promise<boolean>;
|
|
58
|
-
clearError: () => void;
|
|
59
|
-
getTokenInfo: () => any;
|
|
60
|
-
isExpiringSoon: boolean;
|
|
61
|
-
expiresIn: number;
|
|
62
|
-
refreshExpiresIn: number;
|
|
63
|
-
};
|
|
64
|
-
type NotificationOptions = {
|
|
65
|
-
enabled?: boolean;
|
|
66
|
-
maxNotifications?: number;
|
|
67
|
-
defaultAutoHideDuration?: number;
|
|
68
|
-
position?: {
|
|
69
|
-
vertical: "top" | "bottom";
|
|
70
|
-
horizontal: "left" | "center" | "right";
|
|
71
|
-
};
|
|
72
|
-
allowHtml?: boolean;
|
|
73
|
-
};
|
|
74
|
-
type SessionProviderProps = {
|
|
75
|
-
children: ReactNode;
|
|
76
|
-
options?: UseSessionOptions;
|
|
77
|
-
config?: CrudifyConfig;
|
|
78
|
-
showNotifications?: boolean;
|
|
79
|
-
notificationOptions?: NotificationOptions;
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Main session provider to wrap the application.
|
|
83
|
-
* Auto-initializes internal CrudifyProvider if config.publicApiKey is provided.
|
|
84
|
-
*/
|
|
85
|
-
declare function SessionProvider(props: SessionProviderProps): react_jsx_runtime.JSX.Element;
|
|
86
|
-
/**
|
|
87
|
-
* Hook para usar el contexto de sesión
|
|
88
|
-
*/
|
|
89
|
-
declare function useSessionContext(): SessionContextType;
|
|
90
|
-
/**
|
|
91
|
-
* Componente para mostrar información de la sesión (debug)
|
|
92
|
-
*/
|
|
93
|
-
declare function SessionDebugInfo(): react_jsx_runtime.JSX.Element;
|
|
94
|
-
|
|
95
33
|
type CrudifyThemeProviderProps = {
|
|
96
34
|
children: ReactNode;
|
|
97
35
|
defaultTheme?: ThemeOptions;
|
|
@@ -117,6 +55,97 @@ type CrudifyThemeProviderProps = {
|
|
|
117
55
|
*/
|
|
118
56
|
declare function CrudifyThemeProvider({ children, defaultTheme, disableCssBaseline }: CrudifyThemeProviderProps): react_jsx_runtime.JSX.Element;
|
|
119
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Unified Logger for Crudify Projects
|
|
60
|
+
*
|
|
61
|
+
* Environment-based logging:
|
|
62
|
+
* - dev/stg: All logs (error, warn, info, debug)
|
|
63
|
+
* - prod: Only errors (default)
|
|
64
|
+
*
|
|
65
|
+
* AUTO-DETECTION:
|
|
66
|
+
* The logger will automatically detect the environment from:
|
|
67
|
+
* 1. Explicit setEnvironment() call (highest priority)
|
|
68
|
+
* 2. Cookie named 'environment' (for production with Lambda@Edge)
|
|
69
|
+
* 3. window.__CRUDIFY_ENV__ global variable
|
|
70
|
+
* 4. Default to "prod" for safety
|
|
71
|
+
*
|
|
72
|
+
* Usage:
|
|
73
|
+
* import { logger } from './logger';
|
|
74
|
+
*
|
|
75
|
+
* // Option 1: Explicit configuration (recommended for apps)
|
|
76
|
+
* logger.setEnvironment('dev'); // or 'stg', 'prod'
|
|
77
|
+
*
|
|
78
|
+
* // Option 2: Auto-detection (reads cookie or global)
|
|
79
|
+
* // Just use the logger - it will auto-detect
|
|
80
|
+
*
|
|
81
|
+
* logger.error('Something failed', { userId: '123' });
|
|
82
|
+
* logger.warn('Deprecated feature used');
|
|
83
|
+
* logger.info('User logged in', { email: 'user@example.com' });
|
|
84
|
+
* logger.debug('Processing request', { payload: data });
|
|
85
|
+
*/
|
|
86
|
+
type LogLevel = "error" | "warn" | "info" | "debug";
|
|
87
|
+
interface LogContext {
|
|
88
|
+
[key: string]: unknown;
|
|
89
|
+
}
|
|
90
|
+
declare class Logger {
|
|
91
|
+
private explicitEnv;
|
|
92
|
+
private prefix;
|
|
93
|
+
constructor();
|
|
94
|
+
/**
|
|
95
|
+
* Get current effective environment
|
|
96
|
+
* Priority: explicit setEnvironment() > auto-detection
|
|
97
|
+
*/
|
|
98
|
+
private getEffectiveEnv;
|
|
99
|
+
/**
|
|
100
|
+
* Sanitize sensitive data from strings
|
|
101
|
+
*/
|
|
102
|
+
private sanitize;
|
|
103
|
+
/**
|
|
104
|
+
* Sanitize context object
|
|
105
|
+
*/
|
|
106
|
+
private sanitizeContext;
|
|
107
|
+
/**
|
|
108
|
+
* Check if a log level should be displayed based on environment
|
|
109
|
+
* - dev/stg: show all logs
|
|
110
|
+
* - prod: show only errors
|
|
111
|
+
*/
|
|
112
|
+
private shouldLog;
|
|
113
|
+
/**
|
|
114
|
+
* Format and output log entry
|
|
115
|
+
*/
|
|
116
|
+
private log;
|
|
117
|
+
/**
|
|
118
|
+
* Log an error - Always logged in all environments
|
|
119
|
+
*/
|
|
120
|
+
error(message: string, context?: LogContext | Error): void;
|
|
121
|
+
/**
|
|
122
|
+
* Log a warning - Only in dev/stg
|
|
123
|
+
*/
|
|
124
|
+
warn(message: string, context?: LogContext): void;
|
|
125
|
+
/**
|
|
126
|
+
* Log info - Only in dev/stg
|
|
127
|
+
*/
|
|
128
|
+
info(message: string, context?: LogContext): void;
|
|
129
|
+
/**
|
|
130
|
+
* Log debug information - Only in dev/stg
|
|
131
|
+
*/
|
|
132
|
+
debug(message: string, context?: LogContext): void;
|
|
133
|
+
/**
|
|
134
|
+
* Get current effective environment
|
|
135
|
+
*/
|
|
136
|
+
getEnvironment(): string;
|
|
137
|
+
/**
|
|
138
|
+
* Manually set environment (useful for libraries that receive env from parent app)
|
|
139
|
+
* This takes priority over auto-detection
|
|
140
|
+
*/
|
|
141
|
+
setEnvironment(env: string): void;
|
|
142
|
+
/**
|
|
143
|
+
* Check if environment was explicitly set or auto-detected
|
|
144
|
+
*/
|
|
145
|
+
isExplicitlyConfigured(): boolean;
|
|
146
|
+
}
|
|
147
|
+
declare const logger: Logger;
|
|
148
|
+
|
|
120
149
|
interface ProtectedRouteProps {
|
|
121
150
|
children: ReactNode;
|
|
122
151
|
/**
|
|
@@ -485,12 +514,14 @@ interface TranslationsProviderProps {
|
|
|
485
514
|
enableDebug?: boolean;
|
|
486
515
|
skipAutoInit?: boolean;
|
|
487
516
|
autoSyncI18n?: boolean;
|
|
488
|
-
i18nInstance?:
|
|
517
|
+
i18nInstance?: {
|
|
518
|
+
addResourceBundle: (lang: string, ns: string, resources: Record<string, string>, deep?: boolean, overwrite?: boolean) => void;
|
|
519
|
+
};
|
|
489
520
|
loadingFallback?: React.ReactNode;
|
|
490
521
|
waitForInitialLoad?: boolean;
|
|
491
522
|
}
|
|
492
523
|
interface TranslationsContextValue {
|
|
493
|
-
t: (key: string, variables?: Record<string,
|
|
524
|
+
t: (key: string, variables?: Record<string, string | number>) => string;
|
|
494
525
|
language: string;
|
|
495
526
|
availableLanguages: string[];
|
|
496
527
|
translations: Record<string, Record<string, string>>;
|
|
@@ -947,4 +978,4 @@ declare const crudifyAdmin: {
|
|
|
947
978
|
updateActionsProfiles: (data: UpdateActionsProfilesInput) => Promise<ApiResponse<UpdateActionsProfilesResponse>>;
|
|
948
979
|
};
|
|
949
980
|
|
|
950
|
-
export { AuthRoute, type AuthRouteProps, CRITICAL_TRANSLATIONS, type CriticalTranslationKey, CrudifyInitializationManager, CrudifyInitializer, type CrudifyInitializerConfig, type CrudifyInitializerProps, CrudifyLoginConfig, CrudifyProvider, CrudifyThemeProvider, type CrudifyThemeProviderProps, type FetchTranslationsOptions, type InitializationPriority, type InitializationRequest, type InitializationStatus,
|
|
981
|
+
export { AuthRoute, type AuthRouteProps, CRITICAL_TRANSLATIONS, type CriticalTranslationKey, CrudifyInitializationManager, CrudifyInitializer, type CrudifyInitializerConfig, type CrudifyInitializerProps, CrudifyLoginConfig, CrudifyProvider, CrudifyThemeProvider, type CrudifyThemeProviderProps, type FetchTranslationsOptions, type InitializationPriority, type InitializationRequest, type InitializationStatus, type LogContext, type LogLevel, ProtectedRoute, type ProtectedRouteProps, SessionLoadingScreen, type SessionLoadingScreenProps, type SupportedLanguage, type TranslationResponse, TranslationService, type TranslationsContextValue, TranslationsProvider, type TranslationsProviderProps, crudifyAdmin, crudifyInitManager, extractSafeRedirectFromUrl, getCriticalLanguages, getCriticalTranslations, logger, translationService, useCrudify, useCrudifyInitializer, useTranslations, validateInternalRedirect };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkHDNGW5H5js = require('./chunk-HDNGW5H5.js');var _chunkAEHAZP5Fjs = require('./chunk-AEHAZP5F.js');var _chunkIYTXJHKOjs = require('./chunk-IYTXJHKO.js');var _chunkD3NBX3SMjs = require('./chunk-D3NBX3SM.js');var _chunkYIIUEOXCjs = require('./chunk-YIIUEOXC.js');var _chunkGNGIFVA4js = require('./chunk-GNGIFVA4.js');var _crudifybrowser = require('@nocios/crudify-browser'); var _crudifybrowser2 = _interopRequireDefault(_crudifybrowser); _createStarExport(_crudifybrowser);var _react = require('react');var _material = require('@mui/material');var _jsxruntime = require('react/jsx-runtime');var Ke=(e={})=>{try{let r=_chunkGNGIFVA4js.b.call(void 0, "theme");if(r){let o=JSON.parse(decodeURIComponent(r));return{...e,...o}}}catch(r){_chunkGNGIFVA4js.a.warn("Error parsing theme from cookie",r instanceof Error?{errorMessage:r.message}:{message:String(r)})}return e};function Ve({children:e,defaultTheme:r={},disableCssBaseline:o=!1}){let t=_react.useMemo.call(void 0, ()=>{let s=Ke(r);return _material.createTheme.call(void 0, s)},[r]);return _jsxruntime.jsxs.call(void 0, _material.ThemeProvider,{theme:t,children:[!o&&_jsxruntime.jsx.call(void 0, _material.CssBaseline,{}),e]})}var _reactrouterdom = require('react-router-dom');var He={border:"5px solid rgba(0, 0, 0, 0.1)",borderTopColor:"#3B82F6",borderRadius:"50%",width:"50px",height:"50px",animation:"spin 1s linear infinite"},qe=()=>_jsxruntime.jsx.call(void 0, "style",{children:`
|
|
2
2
|
@keyframes spin {
|
|
3
3
|
0% { transform: rotate(0deg); }
|
|
4
4
|
100% { transform: rotate(360deg); }
|
|
5
5
|
}
|
|
6
|
-
`});function T({stage:e="loading",message:r}){let t=r||{initializing:"Initializing application...","validating-session":"Validating session...",loading:"Loading..."}[e];return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, qe,{}),_jsxruntime.jsxs.call(void 0, "div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",width:"100vw",backgroundColor:"#f0f2f5",fontFamily:'"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',color:"#333",textAlign:"center",boxSizing:"border-box",padding:"20px",background:"#fff"},children:[_jsxruntime.jsx.call(void 0, "div",{style:He}),_jsxruntime.jsx.call(void 0, "p",{style:{fontSize:"1.25em",fontWeight:"500",marginTop:"24px",color:"#1f2937"},children:t})]})]})}var Je=/^[a-zA-Z0-9\-_./\?=&%#]+$/,$e=[/^https?:\/\//i,/^ftp:\/\//i,/^\/\//,/javascript:/i,/data:/i,/vbscript:/i,/about:/i,/\.\.\//,/\.\.\\/,/%2e%2e%2f/i,/%2e%2e%5c/i,/%2f%2f/i,/%5c%5c/i,/[\x00-\x1f\x7f-\x9f]/,/\\/],h= exports.validateInternalRedirect =(e,r="/")=>{if(!e||typeof e!="string")return r;let o=e.trim();if(!o)return r;if(!o.startsWith("/"))return _chunkX3JFRSEAjs.a.warn("Open redirect blocked (relative path)",{path:e}),r;if(!Je.test(o))return _chunkX3JFRSEAjs.a.warn("Open redirect blocked (invalid characters)",{path:e}),r;let t=o.toLowerCase();for(let p of $e)if(p.test(t))return _chunkX3JFRSEAjs.a.warn("Open redirect blocked (dangerous pattern)",{path:e}),r;let s=o.split("?")[0].split("/").filter(Boolean);if(s.length===0)return o;for(let p of s)if(p===".."||p.includes(":")||p.length>100)return _chunkX3JFRSEAjs.a.warn("Open redirect blocked (suspicious path part)",{part:p}),r;return o},E= exports.extractSafeRedirectFromUrl =(e,r="/")=>{try{let t=(typeof e=="string"?new URLSearchParams(e):e).get("redirect");if(!t)return r;let s=decodeURIComponent(t);return h(s,r)}catch(o){return _chunkX3JFRSEAjs.a.warn("Error parsing redirect parameter",o instanceof Error?{errorMessage:o.message}:{message:String(o)}),r}};function L({children:e,loadingComponent:r,loginPath:o="/login"}){let{isAuthenticated:t,isLoading:s,isInitialized:p,tokens:d,error:y}=_chunkSEDLJT7Gjs.j.call(void 0, ),u=_reactrouterdom.useLocation.call(void 0, );if(!p||s)return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:r||_jsxruntime.jsx.call(void 0, T,{stage:"validating-session"})});let l=t&&_optionalChain([d, 'optionalAccess', _2 => _2.accessToken])&&d.accessToken.length>0;if(y||!t||!l){d&&(!d.accessToken||d.accessToken.length===0)&&localStorage.removeItem("crudify_tokens");let A=u.pathname+u.search,x=h(A),C=encodeURIComponent(x);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:`${o}?redirect=${C}`,replace:!0})}return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e})}function F({children:e,redirectTo:r="/"}){let{isAuthenticated:o}=_chunkSEDLJT7Gjs.j.call(void 0, ),t=_reactrouterdom.useLocation.call(void 0, );if(o){let s=new URLSearchParams(t.search),p=E(s,r);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:p,replace:!0})}return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e})}var D=_react.createContext.call(void 0, void 0),tr= exports.CrudifyInitializer =({config:e,children:r,fallback:o=null,onInitialized:t,onError:s})=>{let[p,d]=_react.useState.call(void 0, !1),[y,u]=_react.useState.call(void 0, !1),[l,A]=_react.useState.call(void 0, null),x=_react.useRef.call(void 0, !1),C=_react.useRef.call(void 0, !1);_react.useEffect.call(void 0, ()=>{x.current||(_chunkSEDLJT7Gjs.o.registerHighPriorityInitializer(),x.current=!0),C.current||(C.current=!0,(async()=>{u(!0),A(null);try{let c=_chunkX3JFRSEAjs.c.call(void 0, {publicApiKey:_optionalChain([e, 'optionalAccess', _3 => _3.publicApiKey]),env:_optionalChain([e, 'optionalAccess', _4 => _4.env]),enableDebug:_optionalChain([e, 'optionalAccess', _5 => _5.enableLogging])});if(!c.publicApiKey)throw new Error("Crudify configuration missing. Please provide publicApiKey via props or ensure cookies are set by Lambda.");let P=c.env||"prod";_chunkX3JFRSEAjs.a.setEnvironment(P),await _chunkSEDLJT7Gjs.o.initialize({priority:"HIGH",publicApiKey:c.publicApiKey,env:c.env||"prod",enableLogging:_optionalChain([e, 'optionalAccess', _6 => _6.enableLogging]),requestedBy:"CrudifyInitializer"}),d(!0),u(!1),t&&t()}catch(c){let P=c instanceof Error?c:new Error(String(c));A(P),u(!1),s&&s(P)}})())},[_optionalChain([e, 'optionalAccess', _7 => _7.publicApiKey]),_optionalChain([e, 'optionalAccess', _8 => _8.env]),_optionalChain([e, 'optionalAccess', _9 => _9.enableLogging]),t,s]);let K={isInitialized:p,isInitializing:y,error:l};return y&&o?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:o}):(l&&_chunkX3JFRSEAjs.a.error("[CrudifyInitializer] Initialization failed",l),_jsxruntime.jsx.call(void 0, D.Provider,{value:K,children:r}))},ir= exports.useCrudifyInitializer =()=>{let e=_react.useContext.call(void 0, D);if(!e)throw new Error("useCrudifyInitializer must be used within CrudifyInitializer");return e};var _crudifyadmin = require('@nocios/crudify-admin'); var _crudifyadmin2 = _interopRequireDefault(_crudifyadmin);var G=!1,g=null;async function sr(){let r=_chunkSEDLJT7Gjs.e.getInstance().getTokenInfo(),o=_optionalChain([r, 'optionalAccess', _10 => _10.apiEndpointAdmin]),t=_optionalChain([r, 'optionalAccess', _11 => _11.apiKeyEndpointAdmin]);return o&&t?{apiUrl:o,apiKey:t}:_chunkSEDLJT7Gjs.a.waitForCredentials()}async function ar(){if(!G)return g||(g=(async()=>{try{let e=_chunkSEDLJT7Gjs.e.getInstance(),{apiUrl:r,apiKey:o}=await sr();_crudifyadmin2.default.init({url:r,apiKey:o,getAdditionalHeaders:()=>{let t=e.getTokenInfo();return _optionalChain([t, 'optionalAccess', _12 => _12.crudifyTokens, 'optionalAccess', _13 => _13.accessToken])?{Authorization:`Bearer ${t.crudifyTokens.accessToken}`}:{}}}),G=!0}catch(e){throw g=null,_chunkX3JFRSEAjs.a.error("[crudifyAdminWrapper] Initialization failed",e instanceof Error?e:{message:String(e)}),e}})(),g)}async function n(e){try{await ar();let r=await e();return!r.success&&_optionalChain([r, 'access', _14 => _14.errors, 'optionalAccess', _15 => _15.includes, 'call', _16 => _16("401")])?await _chunkSEDLJT7Gjs.e.getInstance().refreshTokens()?await e():(_chunkX3JFRSEAjs.a.error("[crudifyAdmin] Token refresh failed"),typeof window<"u"&&(window.location.href="/login"),r):r}catch(r){return _chunkX3JFRSEAjs.a.error("[crudifyAdmin] Operation error",r instanceof Error?r:{message:String(r)}),{success:!1,errors:r instanceof Error?r.message:"Unknown error"}}}var pr={listModules:()=>n(()=>_crudifyadmin2.default.listModules()),getModule:e=>n(()=>_crudifyadmin2.default.getModule(e)),createModule:e=>n(()=>_crudifyadmin2.default.createModule(e)),editModule:(e,r)=>n(()=>_crudifyadmin2.default.editModule(e,r)),deleteModule:e=>n(()=>_crudifyadmin2.default.deleteModule(e)),activateModule:e=>n(()=>_crudifyadmin2.default.activateModule(e)),deactivateModule:e=>n(()=>_crudifyadmin2.default.deactivateModule(e)),getModuleVersions:e=>n(()=>_crudifyadmin2.default.getModuleVersions(e)),listActions:e=>n(()=>_crudifyadmin2.default.listActions(e)),getAction:e=>n(()=>_crudifyadmin2.default.getAction(e)),createAction:e=>n(()=>_crudifyadmin2.default.createAction(e)),editAction:(e,r)=>n(()=>_crudifyadmin2.default.editAction(e,r)),deleteAction:e=>n(()=>_crudifyadmin2.default.deleteAction(e)),activateAction:e=>n(()=>_crudifyadmin2.default.activateAction(e)),deactivateAction:e=>n(()=>_crudifyadmin2.default.deactivateAction(e)),getActionVersions:e=>n(()=>_crudifyadmin2.default.getActionVersions(e)),getActionsByProfile:e=>n(()=>_crudifyadmin2.default.getActionsByProfile(e)),updateActionsProfiles:e=>n(()=>_crudifyadmin2.default.updateActionsProfiles(e))};exports.AuthRoute = F; exports.CRITICAL_TRANSLATIONS = _chunkL454VIXNjs.a; exports.CrudiaAutoGenerate = _chunkL454VIXNjs.o; exports.CrudiaFileField = _chunkL454VIXNjs.p; exports.CrudiaMarkdownField = _chunkL454VIXNjs.q; exports.CrudifyInitializationManager = _chunkSEDLJT7Gjs.n; exports.CrudifyInitializer = tr; exports.CrudifyLogin = _chunkL454VIXNjs.h; exports.CrudifyProvider = _chunkSEDLJT7Gjs.b; exports.CrudifyThemeProvider = Ve; exports.ERROR_CODES = _chunkYIIUEOXCjs.a; exports.ERROR_SEVERITY_MAP = _chunkYIIUEOXCjs.b; exports.GlobalNotificationProvider = _chunkSEDLJT7Gjs.g; exports.LoginComponent = _chunkL454VIXNjs.m; exports.POLICY_ACTIONS = _chunkL454VIXNjs.j; exports.PREFERRED_POLICY_ORDER = _chunkL454VIXNjs.k; exports.Policies = _chunkL454VIXNjs.l; exports.ProtectedRoute = L; exports.SessionDebugInfo = _chunkSEDLJT7Gjs.k; exports.SessionLoadingScreen = T; exports.SessionManager = _chunkSEDLJT7Gjs.e; exports.SessionProvider = _chunkSEDLJT7Gjs.i; exports.SessionStatus = _chunkL454VIXNjs.n; exports.TokenStorage = _chunkSEDLJT7Gjs.d; exports.TranslationService = _chunkL454VIXNjs.d; exports.TranslationsProvider = _chunkL454VIXNjs.f; exports.UserProfileDisplay = _chunkL454VIXNjs.i; exports.createErrorTranslator = _chunkX3JFRSEAjs.h; exports.crudify = _crudifybrowser2.default; exports.crudifyAdmin = pr; exports.crudifyInitManager = _chunkSEDLJT7Gjs.o; exports.decodeJwtSafely = _chunkX3JFRSEAjs.k; exports.extractSafeRedirectFromUrl = E; exports.getCookie = _chunkX3JFRSEAjs.b; exports.getCriticalLanguages = _chunkL454VIXNjs.b; exports.getCriticalTranslations = _chunkL454VIXNjs.c; exports.getCurrentUserEmail = _chunkX3JFRSEAjs.l; exports.getErrorMessage = _chunkYIIUEOXCjs.e; exports.handleCrudifyError = _chunkYIIUEOXCjs.g; exports.isTokenExpired = _chunkX3JFRSEAjs.m; exports.parseApiError = _chunkYIIUEOXCjs.c; exports.parseJavaScriptError = _chunkYIIUEOXCjs.f; exports.parseTransactionError = _chunkYIIUEOXCjs.d; exports.secureLocalStorage = _chunk4LSVF26Qjs.b; exports.secureSessionStorage = _chunk4LSVF26Qjs.a; exports.translateError = _chunkX3JFRSEAjs.g; exports.translateErrorCode = _chunkX3JFRSEAjs.e; exports.translateErrorCodes = _chunkX3JFRSEAjs.f; exports.translationService = _chunkL454VIXNjs.e; exports.useAuth = _chunkYLKGZV2Njs.b; exports.useAutoGenerate = _chunkSEDLJT7Gjs.m; exports.useCrudify = _chunkSEDLJT7Gjs.c; exports.useCrudifyInitializer = ir; exports.useCrudifyWithNotifications = _chunkYLKGZV2Njs.d; exports.useData = _chunkYLKGZV2Njs.c; exports.useFileUpload = _chunkSEDLJT7Gjs.p; exports.useGlobalNotification = _chunkSEDLJT7Gjs.h; exports.useSession = _chunkSEDLJT7Gjs.f; exports.useSessionContext = _chunkSEDLJT7Gjs.j; exports.useTranslations = _chunkL454VIXNjs.g; exports.useUserData = _chunkYLKGZV2Njs.a; exports.useUserProfile = _chunkSEDLJT7Gjs.l; exports.validateInternalRedirect = h;
|
|
6
|
+
`});function T({stage:e="loading",message:r}){let t=r||{initializing:"Initializing application...","validating-session":"Validating session...",loading:"Loading..."}[e];return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, qe,{}),_jsxruntime.jsxs.call(void 0, "div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",width:"100vw",backgroundColor:"#f0f2f5",fontFamily:'"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',color:"#333",textAlign:"center",boxSizing:"border-box",padding:"20px",background:"#fff"},children:[_jsxruntime.jsx.call(void 0, "div",{style:He}),_jsxruntime.jsx.call(void 0, "p",{style:{fontSize:"1.25em",fontWeight:"500",marginTop:"24px",color:"#1f2937"},children:t})]})]})}var Je=/^[a-zA-Z0-9\-_./\?=&%#]+$/,$e=[/^https?:\/\//i,/^ftp:\/\//i,/^\/\//,/javascript:/i,/data:/i,/vbscript:/i,/about:/i,/\.\.\//,/\.\.\\/,/%2e%2e%2f/i,/%2e%2e%5c/i,/%2f%2f/i,/%5c%5c/i,/[\x00-\x1f\x7f-\x9f]/,/\\/],h= exports.validateInternalRedirect =(e,r="/")=>{if(!e||typeof e!="string")return r;let o=e.trim();if(!o)return r;if(!o.startsWith("/"))return _chunkGNGIFVA4js.a.warn("Open redirect blocked (relative path)",{path:e}),r;if(!Je.test(o))return _chunkGNGIFVA4js.a.warn("Open redirect blocked (invalid characters)",{path:e}),r;let t=o.toLowerCase();for(let p of $e)if(p.test(t))return _chunkGNGIFVA4js.a.warn("Open redirect blocked (dangerous pattern)",{path:e}),r;let s=o.split("?")[0].split("/").filter(Boolean);if(s.length===0)return o;for(let p of s)if(p===".."||p.includes(":")||p.length>100)return _chunkGNGIFVA4js.a.warn("Open redirect blocked (suspicious path part)",{part:p}),r;return o},E= exports.extractSafeRedirectFromUrl =(e,r="/")=>{try{let t=(typeof e=="string"?new URLSearchParams(e):e).get("redirect");if(!t)return r;let s=decodeURIComponent(t);return h(s,r)}catch(o){return _chunkGNGIFVA4js.a.warn("Error parsing redirect parameter",o instanceof Error?{errorMessage:o.message}:{message:String(o)}),r}};function w({children:e,loadingComponent:r,loginPath:o="/login"}){let{isAuthenticated:t,isLoading:s,isInitialized:p,tokens:d,error:y}=_chunkIYTXJHKOjs.j.call(void 0, ),u=_reactrouterdom.useLocation.call(void 0, );if(!p||s)return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:r||_jsxruntime.jsx.call(void 0, T,{stage:"validating-session"})});let l=t&&_optionalChain([d, 'optionalAccess', _2 => _2.accessToken])&&d.accessToken.length>0;if(y||!t||!l){d&&(!d.accessToken||d.accessToken.length===0)&&localStorage.removeItem("crudify_tokens");let A=u.pathname+u.search,x=h(A),C=encodeURIComponent(x);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:`${o}?redirect=${C}`,replace:!0})}return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e})}function F({children:e,redirectTo:r="/"}){let{isAuthenticated:o}=_chunkIYTXJHKOjs.j.call(void 0, ),t=_reactrouterdom.useLocation.call(void 0, );if(o){let s=new URLSearchParams(t.search),p=E(s,r);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:p,replace:!0})}return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e})}var D=_react.createContext.call(void 0, void 0),tr= exports.CrudifyInitializer =({config:e,children:r,fallback:o=null,onInitialized:t,onError:s})=>{let[p,d]=_react.useState.call(void 0, !1),[y,u]=_react.useState.call(void 0, !1),[l,A]=_react.useState.call(void 0, null),x=_react.useRef.call(void 0, !1),C=_react.useRef.call(void 0, !1);_react.useEffect.call(void 0, ()=>{x.current||(_chunkIYTXJHKOjs.o.registerHighPriorityInitializer(),x.current=!0),C.current||(C.current=!0,(async()=>{u(!0),A(null);try{let c=_chunkGNGIFVA4js.c.call(void 0, {publicApiKey:_optionalChain([e, 'optionalAccess', _3 => _3.publicApiKey]),env:_optionalChain([e, 'optionalAccess', _4 => _4.env]),enableDebug:_optionalChain([e, 'optionalAccess', _5 => _5.enableLogging])});if(!c.publicApiKey)throw new Error("Crudify configuration missing. Please provide publicApiKey via props or ensure cookies are set by Lambda.");let P=c.env||"prod";_chunkGNGIFVA4js.a.setEnvironment(P),await _chunkIYTXJHKOjs.o.initialize({priority:"HIGH",publicApiKey:c.publicApiKey,env:c.env||"prod",enableLogging:_optionalChain([e, 'optionalAccess', _6 => _6.enableLogging]),requestedBy:"CrudifyInitializer"}),d(!0),u(!1),t&&t()}catch(c){let P=c instanceof Error?c:new Error(String(c));A(P),u(!1),s&&s(P)}})())},[_optionalChain([e, 'optionalAccess', _7 => _7.publicApiKey]),_optionalChain([e, 'optionalAccess', _8 => _8.env]),_optionalChain([e, 'optionalAccess', _9 => _9.enableLogging]),t,s]);let K={isInitialized:p,isInitializing:y,error:l};return y&&o?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:o}):(l&&_chunkGNGIFVA4js.a.error("[CrudifyInitializer] Initialization failed",l),_jsxruntime.jsx.call(void 0, D.Provider,{value:K,children:r}))},ir= exports.useCrudifyInitializer =()=>{let e=_react.useContext.call(void 0, D);if(!e)throw new Error("useCrudifyInitializer must be used within CrudifyInitializer");return e};var _crudifyadmin = require('@nocios/crudify-admin'); var _crudifyadmin2 = _interopRequireDefault(_crudifyadmin);var G=!1,g=null;async function sr(){let r=_chunkIYTXJHKOjs.e.getInstance().getTokenInfo(),o=_optionalChain([r, 'optionalAccess', _10 => _10.apiEndpointAdmin]),t=_optionalChain([r, 'optionalAccess', _11 => _11.apiKeyEndpointAdmin]);return o&&t?{apiUrl:o,apiKey:t}:_chunkIYTXJHKOjs.a.waitForCredentials()}async function ar(){if(!G)return g||(g=(async()=>{try{let e=_chunkIYTXJHKOjs.e.getInstance(),{apiUrl:r,apiKey:o}=await sr();_crudifyadmin2.default.init({url:r,apiKey:o,getAdditionalHeaders:()=>{let t=e.getTokenInfo();return _optionalChain([t, 'optionalAccess', _12 => _12.crudifyTokens, 'optionalAccess', _13 => _13.accessToken])?{Authorization:`Bearer ${t.crudifyTokens.accessToken}`}:{}}}),G=!0}catch(e){throw g=null,_chunkGNGIFVA4js.a.error("[crudifyAdminWrapper] Initialization failed",e instanceof Error?e:{message:String(e)}),e}})(),g)}async function n(e){try{await ar();let r=await e(),o=r.errors&&(typeof r.errors=="string"&&r.errors.includes("401")||Array.isArray(r.errors)&&r.errors.some(t=>typeof t=="string"&&t.includes("401")));return!r.success&&o?await _chunkIYTXJHKOjs.e.getInstance().refreshTokens()?await e():(_chunkGNGIFVA4js.a.error("[crudifyAdmin] Token refresh failed"),typeof window<"u"&&(window.location.href="/login"),r):r}catch(r){return _chunkGNGIFVA4js.a.error("[crudifyAdmin] Operation error",r instanceof Error?r:{message:String(r)}),{success:!1,errors:r instanceof Error?r.message:"Unknown error"}}}var pr={listModules:()=>n(()=>_crudifyadmin2.default.listModules()),getModule:e=>n(()=>_crudifyadmin2.default.getModule(e)),createModule:e=>n(()=>_crudifyadmin2.default.createModule(e)),editModule:(e,r)=>n(()=>_crudifyadmin2.default.editModule(e,r)),deleteModule:e=>n(()=>_crudifyadmin2.default.deleteModule(e)),activateModule:e=>n(()=>_crudifyadmin2.default.activateModule(e)),deactivateModule:e=>n(()=>_crudifyadmin2.default.deactivateModule(e)),getModuleVersions:e=>n(()=>_crudifyadmin2.default.getModuleVersions(e)),listActions:e=>n(()=>_crudifyadmin2.default.listActions(e)),getAction:e=>n(()=>_crudifyadmin2.default.getAction(e)),createAction:e=>n(()=>_crudifyadmin2.default.createAction(e)),editAction:(e,r)=>n(()=>_crudifyadmin2.default.editAction(e,r)),deleteAction:e=>n(()=>_crudifyadmin2.default.deleteAction(e)),activateAction:e=>n(()=>_crudifyadmin2.default.activateAction(e)),deactivateAction:e=>n(()=>_crudifyadmin2.default.deactivateAction(e)),getActionVersions:e=>n(()=>_crudifyadmin2.default.getActionVersions(e)),getActionsByProfile:e=>n(()=>_crudifyadmin2.default.getActionsByProfile(e)),updateActionsProfiles:e=>n(()=>_crudifyadmin2.default.updateActionsProfiles(e))};exports.AuthRoute = F; exports.CRITICAL_TRANSLATIONS = _chunkHDNGW5H5js.a; exports.CrudiaAutoGenerate = _chunkHDNGW5H5js.o; exports.CrudiaFileField = _chunkHDNGW5H5js.p; exports.CrudiaMarkdownField = _chunkHDNGW5H5js.q; exports.CrudifyInitializationManager = _chunkIYTXJHKOjs.n; exports.CrudifyInitializer = tr; exports.CrudifyLogin = _chunkHDNGW5H5js.h; exports.CrudifyProvider = _chunkIYTXJHKOjs.b; exports.CrudifyThemeProvider = Ve; exports.ERROR_CODES = _chunkYIIUEOXCjs.a; exports.ERROR_SEVERITY_MAP = _chunkYIIUEOXCjs.b; exports.GlobalNotificationProvider = _chunkIYTXJHKOjs.g; exports.LoginComponent = _chunkHDNGW5H5js.m; exports.POLICY_ACTIONS = _chunkHDNGW5H5js.j; exports.PREFERRED_POLICY_ORDER = _chunkHDNGW5H5js.k; exports.Policies = _chunkHDNGW5H5js.l; exports.ProtectedRoute = w; exports.SessionDebugInfo = _chunkIYTXJHKOjs.k; exports.SessionLoadingScreen = T; exports.SessionManager = _chunkIYTXJHKOjs.e; exports.SessionProvider = _chunkIYTXJHKOjs.i; exports.SessionStatus = _chunkHDNGW5H5js.n; exports.TokenStorage = _chunkIYTXJHKOjs.d; exports.TranslationService = _chunkHDNGW5H5js.d; exports.TranslationsProvider = _chunkHDNGW5H5js.f; exports.UserProfileDisplay = _chunkHDNGW5H5js.i; exports.createErrorTranslator = _chunkGNGIFVA4js.h; exports.crudify = _crudifybrowser2.default; exports.crudifyAdmin = pr; exports.crudifyInitManager = _chunkIYTXJHKOjs.o; exports.decodeJwtSafely = _chunkGNGIFVA4js.k; exports.extractSafeRedirectFromUrl = E; exports.getCookie = _chunkGNGIFVA4js.b; exports.getCriticalLanguages = _chunkHDNGW5H5js.b; exports.getCriticalTranslations = _chunkHDNGW5H5js.c; exports.getCurrentUserEmail = _chunkGNGIFVA4js.l; exports.getErrorMessage = _chunkYIIUEOXCjs.e; exports.handleCrudifyError = _chunkYIIUEOXCjs.g; exports.isTokenExpired = _chunkGNGIFVA4js.m; exports.logger = _chunkGNGIFVA4js.a; exports.parseApiError = _chunkYIIUEOXCjs.c; exports.parseJavaScriptError = _chunkYIIUEOXCjs.f; exports.parseTransactionError = _chunkYIIUEOXCjs.d; exports.secureLocalStorage = _chunkD3NBX3SMjs.b; exports.secureSessionStorage = _chunkD3NBX3SMjs.a; exports.translateError = _chunkGNGIFVA4js.g; exports.translateErrorCode = _chunkGNGIFVA4js.e; exports.translateErrorCodes = _chunkGNGIFVA4js.f; exports.translationService = _chunkHDNGW5H5js.e; exports.useAuth = _chunkAEHAZP5Fjs.b; exports.useAutoGenerate = _chunkIYTXJHKOjs.m; exports.useCrudify = _chunkIYTXJHKOjs.c; exports.useCrudifyInitializer = ir; exports.useCrudifyWithNotifications = _chunkAEHAZP5Fjs.d; exports.useData = _chunkAEHAZP5Fjs.c; exports.useFileUpload = _chunkIYTXJHKOjs.p; exports.useGlobalNotification = _chunkIYTXJHKOjs.h; exports.useSession = _chunkIYTXJHKOjs.f; exports.useSessionContext = _chunkIYTXJHKOjs.j; exports.useTranslations = _chunkHDNGW5H5js.g; exports.useUserData = _chunkAEHAZP5Fjs.a; exports.useUserProfile = _chunkIYTXJHKOjs.l; exports.validateInternalRedirect = h;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{a as V,b as _,c as B,d as H,e as q,f as W,g as J,h as ye,i as xe,j as Ce,k as Pe,l as Re,m as Ie,n as he,o as ve,p as Me,q as ze}from"./chunk-
|
|
1
|
+
import{a as V,b as _,c as B,d as H,e as q,f as W,g as J,h as ye,i as xe,j as Ce,k as Pe,l as Re,m as Ie,n as he,o as ve,p as Me,q as ze}from"./chunk-NZIH26GS.mjs";import{a as ke,b as Le,c as be,d as Fe}from"./chunk-ZKWTILQT.mjs";import{a as k,b as $,c as Y,d as Z,e as f,f as re,g as ne,h as se,i as ae,j as m,k as pe,l as Ae,m as Se,n as Te,o as R,p as Ee}from"./chunk-2G33BADS.mjs";import{a as we,b as Ue}from"./chunk-7J5RTLCS.mjs";import{a as ce,b as de,c as ue,d as le,e as fe,f as me,g as ge}from"./chunk-BJ6PIVZR.mjs";import{a,b as v,c as z,e as Q,f as X,g as j,h as ee,k as oe,l as te,m as ie}from"./chunk-GCH3QGKL.mjs";import{default as Zr}from"@nocios/crudify-browser";export*from"@nocios/crudify-browser";import{useMemo as Oe}from"react";import{ThemeProvider as Ne,createTheme as De,CssBaseline as Ge}from"@mui/material";import{jsx as _e,jsxs as Be}from"react/jsx-runtime";var Ke=(e={})=>{try{let r=v("theme");if(r){let o=JSON.parse(decodeURIComponent(r));return{...e,...o}}}catch(r){a.warn("Error parsing theme from cookie",r instanceof Error?{errorMessage:r.message}:{message:String(r)})}return e};function Ve({children:e,defaultTheme:r={},disableCssBaseline:o=!1}){let t=Oe(()=>{let s=Ke(r);return De(s)},[r]);return Be(Ne,{theme:t,children:[!o&&_e(Ge,{}),e]})}import{Navigate as Ye,useLocation as Ze}from"react-router-dom";import{Fragment as We,jsx as I,jsxs as L}from"react/jsx-runtime";var He={border:"5px solid rgba(0, 0, 0, 0.1)",borderTopColor:"#3B82F6",borderRadius:"50%",width:"50px",height:"50px",animation:"spin 1s linear infinite"},qe=()=>I("style",{children:`
|
|
2
2
|
@keyframes spin {
|
|
3
3
|
0% { transform: rotate(0deg); }
|
|
4
4
|
100% { transform: rotate(360deg); }
|
|
5
5
|
}
|
|
6
|
-
`});function T({stage:e="loading",message:r}){let t=r||{initializing:"Initializing application...","validating-session":"Validating session...",loading:"Loading..."}[e];return
|
|
6
|
+
`});function T({stage:e="loading",message:r}){let t=r||{initializing:"Initializing application...","validating-session":"Validating session...",loading:"Loading..."}[e];return L(We,{children:[I(qe,{}),L("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",width:"100vw",backgroundColor:"#f0f2f5",fontFamily:'"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',color:"#333",textAlign:"center",boxSizing:"border-box",padding:"20px",background:"#fff"},children:[I("div",{style:He}),I("p",{style:{fontSize:"1.25em",fontWeight:"500",marginTop:"24px",color:"#1f2937"},children:t})]})]})}var Je=/^[a-zA-Z0-9\-_./\?=&%#]+$/,$e=[/^https?:\/\//i,/^ftp:\/\//i,/^\/\//,/javascript:/i,/data:/i,/vbscript:/i,/about:/i,/\.\.\//,/\.\.\\/,/%2e%2e%2f/i,/%2e%2e%5c/i,/%2f%2f/i,/%5c%5c/i,/[\x00-\x1f\x7f-\x9f]/,/\\/],h=(e,r="/")=>{if(!e||typeof e!="string")return r;let o=e.trim();if(!o)return r;if(!o.startsWith("/"))return a.warn("Open redirect blocked (relative path)",{path:e}),r;if(!Je.test(o))return a.warn("Open redirect blocked (invalid characters)",{path:e}),r;let t=o.toLowerCase();for(let p of $e)if(p.test(t))return a.warn("Open redirect blocked (dangerous pattern)",{path:e}),r;let s=o.split("?")[0].split("/").filter(Boolean);if(s.length===0)return o;for(let p of s)if(p===".."||p.includes(":")||p.length>100)return a.warn("Open redirect blocked (suspicious path part)",{part:p}),r;return o},E=(e,r="/")=>{try{let t=(typeof e=="string"?new URLSearchParams(e):e).get("redirect");if(!t)return r;let s=decodeURIComponent(t);return h(s,r)}catch(o){return a.warn("Error parsing redirect parameter",o instanceof Error?{errorMessage:o.message}:{message:String(o)}),r}};import{Fragment as b,jsx as S}from"react/jsx-runtime";function w({children:e,loadingComponent:r,loginPath:o="/login"}){let{isAuthenticated:t,isLoading:s,isInitialized:p,tokens:d,error:y}=m(),u=Ze();if(!p||s)return S(b,{children:r||S(T,{stage:"validating-session"})});let l=t&&d?.accessToken&&d.accessToken.length>0;if(y||!t||!l){d&&(!d.accessToken||d.accessToken.length===0)&&localStorage.removeItem("crudify_tokens");let A=u.pathname+u.search,x=h(A),C=encodeURIComponent(x);return S(Ye,{to:`${o}?redirect=${C}`,replace:!0})}return S(b,{children:e})}import{Navigate as Qe,useLocation as Xe}from"react-router-dom";import{Fragment as je,jsx as U}from"react/jsx-runtime";function F({children:e,redirectTo:r="/"}){let{isAuthenticated:o}=m(),t=Xe();if(o){let s=new URLSearchParams(t.search),p=E(s,r);return U(Qe,{to:p,replace:!0})}return U(je,{children:e})}import{createContext as er,useContext as rr,useEffect as or,useRef as O,useState as M}from"react";import{Fragment as nr,jsx as N}from"react/jsx-runtime";var D=er(void 0),tr=({config:e,children:r,fallback:o=null,onInitialized:t,onError:s})=>{let[p,d]=M(!1),[y,u]=M(!1),[l,A]=M(null),x=O(!1),C=O(!1);or(()=>{x.current||(R.registerHighPriorityInitializer(),x.current=!0),C.current||(C.current=!0,(async()=>{u(!0),A(null);try{let c=z({publicApiKey:e?.publicApiKey,env:e?.env,enableDebug:e?.enableLogging});if(!c.publicApiKey)throw new Error("Crudify configuration missing. Please provide publicApiKey via props or ensure cookies are set by Lambda.");let P=c.env||"prod";a.setEnvironment(P),await R.initialize({priority:"HIGH",publicApiKey:c.publicApiKey,env:c.env||"prod",enableLogging:e?.enableLogging,requestedBy:"CrudifyInitializer"}),d(!0),u(!1),t&&t()}catch(c){let P=c instanceof Error?c:new Error(String(c));A(P),u(!1),s&&s(P)}})())},[e?.publicApiKey,e?.env,e?.enableLogging,t,s]);let K={isInitialized:p,isInitializing:y,error:l};return y&&o?N(nr,{children:o}):(l&&a.error("[CrudifyInitializer] Initialization failed",l),N(D.Provider,{value:K,children:r}))},ir=()=>{let e=rr(D);if(!e)throw new Error("useCrudifyInitializer must be used within CrudifyInitializer");return e};import i from"@nocios/crudify-admin";var G=!1,g=null;async function sr(){let r=f.getInstance().getTokenInfo(),o=r?.apiEndpointAdmin,t=r?.apiKeyEndpointAdmin;return o&&t?{apiUrl:o,apiKey:t}:k.waitForCredentials()}async function ar(){if(!G)return g||(g=(async()=>{try{let e=f.getInstance(),{apiUrl:r,apiKey:o}=await sr();i.init({url:r,apiKey:o,getAdditionalHeaders:()=>{let t=e.getTokenInfo();return t?.crudifyTokens?.accessToken?{Authorization:`Bearer ${t.crudifyTokens.accessToken}`}:{}}}),G=!0}catch(e){throw g=null,a.error("[crudifyAdminWrapper] Initialization failed",e instanceof Error?e:{message:String(e)}),e}})(),g)}async function n(e){try{await ar();let r=await e(),o=r.errors&&(typeof r.errors=="string"&&r.errors.includes("401")||Array.isArray(r.errors)&&r.errors.some(t=>typeof t=="string"&&t.includes("401")));return!r.success&&o?await f.getInstance().refreshTokens()?await e():(a.error("[crudifyAdmin] Token refresh failed"),typeof window<"u"&&(window.location.href="/login"),r):r}catch(r){return a.error("[crudifyAdmin] Operation error",r instanceof Error?r:{message:String(r)}),{success:!1,errors:r instanceof Error?r.message:"Unknown error"}}}var pr={listModules:()=>n(()=>i.listModules()),getModule:e=>n(()=>i.getModule(e)),createModule:e=>n(()=>i.createModule(e)),editModule:(e,r)=>n(()=>i.editModule(e,r)),deleteModule:e=>n(()=>i.deleteModule(e)),activateModule:e=>n(()=>i.activateModule(e)),deactivateModule:e=>n(()=>i.deactivateModule(e)),getModuleVersions:e=>n(()=>i.getModuleVersions(e)),listActions:e=>n(()=>i.listActions(e)),getAction:e=>n(()=>i.getAction(e)),createAction:e=>n(()=>i.createAction(e)),editAction:(e,r)=>n(()=>i.editAction(e,r)),deleteAction:e=>n(()=>i.deleteAction(e)),activateAction:e=>n(()=>i.activateAction(e)),deactivateAction:e=>n(()=>i.deactivateAction(e)),getActionVersions:e=>n(()=>i.getActionVersions(e)),getActionsByProfile:e=>n(()=>i.getActionsByProfile(e)),updateActionsProfiles:e=>n(()=>i.updateActionsProfiles(e))};export{F as AuthRoute,V as CRITICAL_TRANSLATIONS,ve as CrudiaAutoGenerate,Me as CrudiaFileField,ze as CrudiaMarkdownField,Te as CrudifyInitializationManager,tr as CrudifyInitializer,ye as CrudifyLogin,$ as CrudifyProvider,Ve as CrudifyThemeProvider,ce as ERROR_CODES,de as ERROR_SEVERITY_MAP,ne as GlobalNotificationProvider,Ie as LoginComponent,Ce as POLICY_ACTIONS,Pe as PREFERRED_POLICY_ORDER,Re as Policies,w as ProtectedRoute,pe as SessionDebugInfo,T as SessionLoadingScreen,f as SessionManager,ae as SessionProvider,he as SessionStatus,Z as TokenStorage,H as TranslationService,W as TranslationsProvider,xe as UserProfileDisplay,ee as createErrorTranslator,Zr as crudify,pr as crudifyAdmin,R as crudifyInitManager,oe as decodeJwtSafely,E as extractSafeRedirectFromUrl,v as getCookie,_ as getCriticalLanguages,B as getCriticalTranslations,te as getCurrentUserEmail,fe as getErrorMessage,ge as handleCrudifyError,ie as isTokenExpired,a as logger,ue as parseApiError,me as parseJavaScriptError,le as parseTransactionError,Ue as secureLocalStorage,we as secureSessionStorage,j as translateError,Q as translateErrorCode,X as translateErrorCodes,q as translationService,Le as useAuth,Se as useAutoGenerate,Y as useCrudify,ir as useCrudifyInitializer,Fe as useCrudifyWithNotifications,be as useData,Ee as useFileUpload,se as useGlobalNotification,re as useSession,m as useSessionContext,J as useTranslations,ke as useUserData,Ae as useUserProfile,h as validateInternalRedirect};
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
export { E as ERROR_CODES, j as ERROR_SEVERITY_MAP, n as ErrorCode, o as ErrorSeverity, q as ErrorTranslationConfig, P as ParsedError, m as createErrorTranslator, d as decodeJwtSafely, a as getCookie, g as getCurrentUserEmail, f as getErrorMessage, h as handleCrudifyError, i as isTokenExpired, p as parseApiError, e as parseJavaScriptError, c as parseTransactionError, b as secureLocalStorage, s as secureSessionStorage, l as translateError, t as translateErrorCode, k as translateErrorCodes } from './errorTranslation-
|
|
2
|
-
import './api-
|
|
1
|
+
export { E as ERROR_CODES, j as ERROR_SEVERITY_MAP, n as ErrorCode, o as ErrorSeverity, q as ErrorTranslationConfig, P as ParsedError, m as createErrorTranslator, d as decodeJwtSafely, a as getCookie, g as getCurrentUserEmail, f as getErrorMessage, h as handleCrudifyError, i as isTokenExpired, p as parseApiError, e as parseJavaScriptError, c as parseTransactionError, b as secureLocalStorage, s as secureSessionStorage, l as translateError, t as translateErrorCode, k as translateErrorCodes } from './errorTranslation-B4wcHzD3.mjs';
|
|
2
|
+
import './api-RK-xY1Ah.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Sistema centralizado de resolución de configuración para npm-crudify-ui
|
|
6
|
-
*
|
|
6
|
+
*
|
|
7
|
+
* Prioridad:
|
|
8
|
+
* 1. Cookies (producción con Lambda@Edge multitenancy) - MAYOR PRIORIDAD
|
|
9
|
+
* 2. Props explícitas (desarrollo local con .env) - FALLBACK
|
|
10
|
+
* 3. Error (ninguna configuración disponible)
|
|
11
|
+
*
|
|
12
|
+
* En producción, Lambda@Edge inyecta cookies con la configuración del tenant.
|
|
13
|
+
* En desarrollo local, no hay cookies y se usan las variables de .env como fallback.
|
|
7
14
|
*/
|
|
8
15
|
type CrudifyEnvironment = "dev" | "stg" | "api" | "prod";
|
|
9
16
|
interface ResolvedConfig {
|
|
@@ -52,7 +59,7 @@ declare function useResolvedConfig(options?: ConfigResolverOptions): ResolvedCon
|
|
|
52
59
|
type AuthEventType = "SESSION_EXPIRED" | "TOKEN_REFRESH_FAILED" | "UNAUTHORIZED" | "TOKEN_EXPIRED";
|
|
53
60
|
type AuthEventDetails = {
|
|
54
61
|
message?: string;
|
|
55
|
-
error?:
|
|
62
|
+
error?: unknown;
|
|
56
63
|
source?: string;
|
|
57
64
|
};
|
|
58
65
|
type AuthEvent = {
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
export { E as ERROR_CODES, j as ERROR_SEVERITY_MAP, n as ErrorCode, o as ErrorSeverity, q as ErrorTranslationConfig, P as ParsedError, m as createErrorTranslator, d as decodeJwtSafely, a as getCookie, g as getCurrentUserEmail, f as getErrorMessage, h as handleCrudifyError, i as isTokenExpired, p as parseApiError, e as parseJavaScriptError, c as parseTransactionError, b as secureLocalStorage, s as secureSessionStorage, l as translateError, t as translateErrorCode, k as translateErrorCodes } from './errorTranslation-
|
|
2
|
-
import './api-
|
|
1
|
+
export { E as ERROR_CODES, j as ERROR_SEVERITY_MAP, n as ErrorCode, o as ErrorSeverity, q as ErrorTranslationConfig, P as ParsedError, m as createErrorTranslator, d as decodeJwtSafely, a as getCookie, g as getCurrentUserEmail, f as getErrorMessage, h as handleCrudifyError, i as isTokenExpired, p as parseApiError, e as parseJavaScriptError, c as parseTransactionError, b as secureLocalStorage, s as secureSessionStorage, l as translateError, t as translateErrorCode, k as translateErrorCodes } from './errorTranslation-CCC5IWoN.js';
|
|
2
|
+
import './api-RK-xY1Ah.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Sistema centralizado de resolución de configuración para npm-crudify-ui
|
|
6
|
-
*
|
|
6
|
+
*
|
|
7
|
+
* Prioridad:
|
|
8
|
+
* 1. Cookies (producción con Lambda@Edge multitenancy) - MAYOR PRIORIDAD
|
|
9
|
+
* 2. Props explícitas (desarrollo local con .env) - FALLBACK
|
|
10
|
+
* 3. Error (ninguna configuración disponible)
|
|
11
|
+
*
|
|
12
|
+
* En producción, Lambda@Edge inyecta cookies con la configuración del tenant.
|
|
13
|
+
* En desarrollo local, no hay cookies y se usan las variables de .env como fallback.
|
|
7
14
|
*/
|
|
8
15
|
type CrudifyEnvironment = "dev" | "stg" | "api" | "prod";
|
|
9
16
|
interface ResolvedConfig {
|
|
@@ -52,7 +59,7 @@ declare function useResolvedConfig(options?: ConfigResolverOptions): ResolvedCon
|
|
|
52
59
|
type AuthEventType = "SESSION_EXPIRED" | "TOKEN_REFRESH_FAILED" | "UNAUTHORIZED" | "TOKEN_EXPIRED";
|
|
53
60
|
type AuthEventDetails = {
|
|
54
61
|
message?: string;
|
|
55
|
-
error?:
|
|
62
|
+
error?: unknown;
|
|
56
63
|
source?: string;
|
|
57
64
|
};
|
|
58
65
|
type AuthEvent = {
|
package/dist/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkD3NBX3SMjs = require('./chunk-D3NBX3SM.js');var _chunkYIIUEOXCjs = require('./chunk-YIIUEOXC.js');var _chunkGNGIFVA4js = require('./chunk-GNGIFVA4.js');exports.ERROR_CODES = _chunkYIIUEOXCjs.a; exports.ERROR_SEVERITY_MAP = _chunkYIIUEOXCjs.b; exports.NavigationTracker = _chunkGNGIFVA4js.j; exports.authEventBus = _chunkGNGIFVA4js.i; exports.createErrorTranslator = _chunkGNGIFVA4js.h; exports.decodeJwtSafely = _chunkGNGIFVA4js.k; exports.getCookie = _chunkGNGIFVA4js.b; exports.getCurrentUserEmail = _chunkGNGIFVA4js.l; exports.getErrorMessage = _chunkYIIUEOXCjs.e; exports.handleCrudifyError = _chunkYIIUEOXCjs.g; exports.isTokenExpired = _chunkGNGIFVA4js.m; exports.parseApiError = _chunkYIIUEOXCjs.c; exports.parseJavaScriptError = _chunkYIIUEOXCjs.f; exports.parseTransactionError = _chunkYIIUEOXCjs.d; exports.resolveConfig = _chunkGNGIFVA4js.c; exports.secureLocalStorage = _chunkD3NBX3SMjs.b; exports.secureSessionStorage = _chunkD3NBX3SMjs.a; exports.translateError = _chunkGNGIFVA4js.g; exports.translateErrorCode = _chunkGNGIFVA4js.e; exports.translateErrorCodes = _chunkGNGIFVA4js.f; exports.useResolvedConfig = _chunkGNGIFVA4js.d;
|
package/dist/utils.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as R,b as c}from"./chunk-
|
|
1
|
+
import{a as R,b as c}from"./chunk-7J5RTLCS.mjs";import{a as m,b as v,c as d,d as g,e as u,f as x,g as C}from"./chunk-BJ6PIVZR.mjs";import{b as r,c as e,d as o,e as t,f as a,g as n,h as s,i as E,j as i,k as p,l as f,m as l}from"./chunk-GCH3QGKL.mjs";export{m as ERROR_CODES,v as ERROR_SEVERITY_MAP,i as NavigationTracker,E as authEventBus,s as createErrorTranslator,p as decodeJwtSafely,r as getCookie,f as getCurrentUserEmail,u as getErrorMessage,C as handleCrudifyError,l as isTokenExpired,d as parseApiError,x as parseJavaScriptError,g as parseTransactionError,e as resolveConfig,c as secureLocalStorage,R as secureSessionStorage,n as translateError,t as translateErrorCode,a as translateErrorCodes,o as useResolvedConfig};
|