@nocios/crudify-components 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -9,9 +9,9 @@ export { F as FileItem, v as FileStatus, L as LoginResult, N as NotificationOpti
9
9
  import * as react_jsx_runtime from 'react/jsx-runtime';
10
10
  import { ThemeOptions } from '@mui/material';
11
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';
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-qwwQTvCO.mjs';
13
- import { ApiResponse, IModule, ModuleCreateInput, ModuleEditInput, ActionListFilters, IAction, ActionCreateInput, ActionEditInput, UpdateActionsProfilesInput, UpdateActionsProfilesResponse, CalculatePermissionsInput, CalculatePermissionsResponse } from '@nocios/crudify-admin';
14
- export { ActionCreateInput, ActionEditInput, ActionListFilters, ApiResponse, IAction, IModule, ModuleCreateInput, ModuleEditInput, UpdateActionsProfilesInput, UpdateActionsProfilesResponse } from '@nocios/crudify-admin';
12
+ export { h as CrudifyEnvironment, E as ERROR_CODES, n as ERROR_SEVERITY_MAP, w as ErrorCode, x as ErrorSeverity, y as ErrorTranslationConfig, P as ParsedError, R as ResolvedTenantConfig, T as TenantConfig, b as TenantConfigOptions, v as createErrorTranslator, d as decodeJwtSafely, g as getCurrentUserEmail, m as getErrorMessage, j as handleCrudifyError, i as isTokenExpired, p as parseApiError, l as parseJavaScriptError, k as parseTransactionError, r as resolveTenantConfig, a as secureLocalStorage, s as secureSessionStorage, q as translateError, t as translateErrorCode, o as translateErrorCodes, u as useTenantConfig } from './errorTranslation-DeeDj7Vt.mjs';
13
+ import { ApiResponse, IModule, ModuleCreateInput, ModuleEditInput, ActionListFilters, IAction, ActionCreateInput, ActionEditInput, UpdateActionsProfilesInput, UpdateActionsProfilesResponse, CalculatePermissionsInput, CalculatePermissionsResponse } from '@nocios/crudify-admin-sdk';
14
+ export { ActionCreateInput, ActionEditInput, ActionListFilters, ApiResponse, IAction, IModule, ModuleCreateInput, ModuleEditInput, UpdateActionsProfilesInput, UpdateActionsProfilesResponse } from '@nocios/crudify-admin-sdk';
15
15
 
16
16
  interface CrudifyContextValue {
17
17
  crudify: typeof crudify__default | null;
@@ -127,7 +127,8 @@ type CrudifyThemeProviderProps = {
127
127
  };
128
128
  /**
129
129
  * Provider de tema para aplicaciones Crudify
130
- * Lee automáticamente la cookie "theme" y aplica el tema a Material-UI
130
+ * Lee automáticamente el theme desde window.__TENANT_CONFIG__ (inyectado por Lambda@Edge)
131
+ * y aplica el tema a Material-UI
131
132
  *
132
133
  * @example
133
134
  * ```tsx
@@ -180,11 +181,11 @@ declare function allPasswordRulesPassed(evaluated: EvaluatedPasswordRule[]): boo
180
181
  * - dev/stg: All logs (error, warn, info, debug)
181
182
  * - prod: Only errors (default)
182
183
  *
183
- * AUTO-DETECTION:
184
+ * AUTO-DETECTION (v2.0.0 - No longer uses cookies):
184
185
  * The logger will automatically detect the environment from:
185
186
  * 1. Explicit setEnvironment() call (highest priority)
186
- * 2. Cookie named 'environment' (for production with Lambda@Edge)
187
- * 3. window.__CRUDIFY_ENV__ global variable
187
+ * 2. window.__TENANT_CONFIG__.environment (production with Lambda@Edge)
188
+ * 3. window.__CRUDIFY_ENV__ global variable (legacy/fallback)
188
189
  * 4. Default to "prod" for safety
189
190
  *
190
191
  * Usage:
@@ -193,7 +194,7 @@ declare function allPasswordRulesPassed(evaluated: EvaluatedPasswordRule[]): boo
193
194
  * // Option 1: Explicit configuration (recommended for apps)
194
195
  * logger.setEnvironment('dev'); // or 'stg', 'prod'
195
196
  *
196
- * // Option 2: Auto-detection (reads cookie or global)
197
+ * // Option 2: Auto-detection (reads from window.__TENANT_CONFIG__)
197
198
  * // Just use the logger - it will auto-detect
198
199
  *
199
200
  * logger.error('Something failed', { userId: '123' });
package/dist/index.d.ts CHANGED
@@ -9,9 +9,9 @@ export { F as FileItem, v as FileStatus, L as LoginResult, N as NotificationOpti
9
9
  import * as react_jsx_runtime from 'react/jsx-runtime';
10
10
  import { ThemeOptions } from '@mui/material';
11
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';
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-DGdrMidg.js';
13
- import { ApiResponse, IModule, ModuleCreateInput, ModuleEditInput, ActionListFilters, IAction, ActionCreateInput, ActionEditInput, UpdateActionsProfilesInput, UpdateActionsProfilesResponse, CalculatePermissionsInput, CalculatePermissionsResponse } from '@nocios/crudify-admin';
14
- export { ActionCreateInput, ActionEditInput, ActionListFilters, ApiResponse, IAction, IModule, ModuleCreateInput, ModuleEditInput, UpdateActionsProfilesInput, UpdateActionsProfilesResponse } from '@nocios/crudify-admin';
12
+ export { h as CrudifyEnvironment, E as ERROR_CODES, n as ERROR_SEVERITY_MAP, w as ErrorCode, x as ErrorSeverity, y as ErrorTranslationConfig, P as ParsedError, R as ResolvedTenantConfig, T as TenantConfig, b as TenantConfigOptions, v as createErrorTranslator, d as decodeJwtSafely, g as getCurrentUserEmail, m as getErrorMessage, j as handleCrudifyError, i as isTokenExpired, p as parseApiError, l as parseJavaScriptError, k as parseTransactionError, r as resolveTenantConfig, a as secureLocalStorage, s as secureSessionStorage, q as translateError, t as translateErrorCode, o as translateErrorCodes, u as useTenantConfig } from './errorTranslation-By5Av0tL.js';
13
+ import { ApiResponse, IModule, ModuleCreateInput, ModuleEditInput, ActionListFilters, IAction, ActionCreateInput, ActionEditInput, UpdateActionsProfilesInput, UpdateActionsProfilesResponse, CalculatePermissionsInput, CalculatePermissionsResponse } from '@nocios/crudify-admin-sdk';
14
+ export { ActionCreateInput, ActionEditInput, ActionListFilters, ApiResponse, IAction, IModule, ModuleCreateInput, ModuleEditInput, UpdateActionsProfilesInput, UpdateActionsProfilesResponse } from '@nocios/crudify-admin-sdk';
15
15
 
16
16
  interface CrudifyContextValue {
17
17
  crudify: typeof crudify__default | null;
@@ -127,7 +127,8 @@ type CrudifyThemeProviderProps = {
127
127
  };
128
128
  /**
129
129
  * Provider de tema para aplicaciones Crudify
130
- * Lee automáticamente la cookie "theme" y aplica el tema a Material-UI
130
+ * Lee automáticamente el theme desde window.__TENANT_CONFIG__ (inyectado por Lambda@Edge)
131
+ * y aplica el tema a Material-UI
131
132
  *
132
133
  * @example
133
134
  * ```tsx
@@ -180,11 +181,11 @@ declare function allPasswordRulesPassed(evaluated: EvaluatedPasswordRule[]): boo
180
181
  * - dev/stg: All logs (error, warn, info, debug)
181
182
  * - prod: Only errors (default)
182
183
  *
183
- * AUTO-DETECTION:
184
+ * AUTO-DETECTION (v2.0.0 - No longer uses cookies):
184
185
  * The logger will automatically detect the environment from:
185
186
  * 1. Explicit setEnvironment() call (highest priority)
186
- * 2. Cookie named 'environment' (for production with Lambda@Edge)
187
- * 3. window.__CRUDIFY_ENV__ global variable
187
+ * 2. window.__TENANT_CONFIG__.environment (production with Lambda@Edge)
188
+ * 3. window.__CRUDIFY_ENV__ global variable (legacy/fallback)
188
189
  * 4. Default to "prod" for safety
189
190
  *
190
191
  * Usage:
@@ -193,7 +194,7 @@ declare function allPasswordRulesPassed(evaluated: EvaluatedPasswordRule[]): boo
193
194
  * // Option 1: Explicit configuration (recommended for apps)
194
195
  * logger.setEnvironment('dev'); // or 'stg', 'prod'
195
196
  *
196
- * // Option 2: Auto-detection (reads cookie or global)
197
+ * // Option 2: Auto-detection (reads from window.__TENANT_CONFIG__)
197
198
  * // Just use the logger - it will auto-detect
198
199
  *
199
200
  * logger.error('Something failed', { userId: '123' });
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; } async function _asyncOptionalChain(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 = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkPNI3ZBZVjs = require('./chunk-PNI3ZBZV.js');var _chunk2XOTIEKSjs = require('./chunk-2XOTIEKS.js');var _chunkCHDM7KGHjs = require('./chunk-CHDM7KGH.js');var _chunk5HFI5CZ5js = require('./chunk-5HFI5CZ5.js');var _chunkNSV6ECYOjs = require('./chunk-NSV6ECYO.js');var _chunkMFYHD6S5js = require('./chunk-MFYHD6S5.js');var _crudifysdk = require('@nocios/crudify-sdk'); var _crudifysdk2 = _interopRequireDefault(_crudifysdk); _createStarExport(_crudifysdk);var _react = require('react');var _material = require('@mui/material');var _jsxruntime = require('react/jsx-runtime');var ir=(e={})=>{try{let r=_chunkMFYHD6S5js.b.call(void 0, "theme");if(r){let t=JSON.parse(decodeURIComponent(r));return{...e,...t}}}catch(r){_chunkMFYHD6S5js.a.warn("Error parsing theme from cookie",r instanceof Error?{errorMessage:r.message}:{message:String(r)})}return e};function nr({children:e,defaultTheme:r={},disableCssBaseline:t=!1}){let o=_react.useMemo.call(void 0, ()=>{let n=ir(r);return _material.createTheme.call(void 0, n)},[r]);return _jsxruntime.jsxs.call(void 0, _material.ThemeProvider,{theme:o,children:[!t&&_jsxruntime.jsx.call(void 0, _material.CssBaseline,{}),e]})}var _reactrouterdom = require('react-router-dom');var pr={border:"5px solid rgba(0, 0, 0, 0.1)",borderTopColor:"#3B82F6",borderRadius:"50%",width:"50px",height:"50px",animation:"spin 1s linear infinite"},ur=()=>_jsxruntime.jsx.call(void 0, "style",{children:`
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; } async function _asyncOptionalChain(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 = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkAOPB3KXBjs = require('./chunk-AOPB3KXB.js');var _chunkRORGWKHPjs = require('./chunk-RORGWKHP.js');var _chunkLK6QVSG4js = require('./chunk-LK6QVSG4.js');var _chunk4VN5YRYZjs = require('./chunk-4VN5YRYZ.js');var _chunkNSV6ECYOjs = require('./chunk-NSV6ECYO.js');var _chunkCR5KJUSTjs = require('./chunk-CR5KJUST.js');var _crudifysdk = require('@nocios/crudify-sdk'); var _crudifysdk2 = _interopRequireDefault(_crudifysdk); _createStarExport(_crudifysdk);var _react = require('react');var _material = require('@mui/material');var _jsxruntime = require('react/jsx-runtime');var nr=(e={})=>{try{let r=_chunkCR5KJUSTjs.b.call(void 0, );if(r.configSource!=="none"&&r.theme)return{...e,...r.theme}}catch(r){_chunkCR5KJUSTjs.a.warn("Error reading theme from config",r instanceof Error?{errorMessage:r.message}:{message:String(r)})}return e};function sr({children:e,defaultTheme:r={},disableCssBaseline:t=!1}){let o=_react.useMemo.call(void 0, ()=>{let n=nr(r);return _material.createTheme.call(void 0, n)},[r]);return _jsxruntime.jsxs.call(void 0, _material.ThemeProvider,{theme:o,children:[!t&&_jsxruntime.jsx.call(void 0, _material.CssBaseline,{}),e]})}var _reactrouterdom = require('react-router-dom');var ur={border:"5px solid rgba(0, 0, 0, 0.1)",borderTopColor:"#3B82F6",borderRadius:"50%",width:"50px",height:"50px",animation:"spin 1s linear infinite"},cr=()=>_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 g({stage:e="loading",message:r}){let o=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, ur,{}),_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:pr}),_jsxruntime.jsx.call(void 0, "p",{style:{fontSize:"1.25em",fontWeight:"500",marginTop:"24px",color:"#1f2937"},children:o})]})]})}var lr=/^[a-zA-Z0-9\-_./\?=&%#]+$/,dr=[/^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]/,/\\/],k= exports.validateInternalRedirect =(e,r="/")=>{if(!e||typeof e!="string")return r;let t=e.trim();if(!t)return r;if(!t.startsWith("/"))return _chunkMFYHD6S5js.a.warn("Open redirect blocked (relative path)",{path:e}),r;if(!lr.test(t))return _chunkMFYHD6S5js.a.warn("Open redirect blocked (invalid characters)",{path:e}),r;let o=t.toLowerCase();for(let i of dr)if(i.test(o))return _chunkMFYHD6S5js.a.warn("Open redirect blocked (dangerous pattern)",{path:e}),r;let n=t.split("?")[0].split("/").filter(Boolean);if(n.length===0)return t;for(let i of n)if(i===".."||i.includes(":")||i.length>100)return _chunkMFYHD6S5js.a.warn("Open redirect blocked (suspicious path part)",{part:i}),r;return t},M= exports.extractSafeRedirectFromUrl =(e,r="/")=>{try{let o=(typeof e=="string"?new URLSearchParams(e):e).get("redirect");if(!o)return r;let n=decodeURIComponent(o);return k(n,r)}catch(t){return _chunkMFYHD6S5js.a.warn("Error parsing redirect parameter",t instanceof Error?{errorMessage:t.message}:{message:String(t)}),r}};function V({children:e,loadingComponent:r,loginPath:t="/login"}){let{isAuthenticated:o,isLoading:n,isLoggingOut:i,isInitialized:y,tokens:c,error:f}=_chunkCHDM7KGHjs.l.call(void 0, ),u=_reactrouterdom.useLocation.call(void 0, );if(!y||n&&!i)return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:r||_jsxruntime.jsx.call(void 0, g,{stage:"validating-session"})});let l=o&&_optionalChain([c, 'optionalAccess', _2 => _2.accessToken])&&c.accessToken.length>0;if(f||!o||!l){if(i)return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:t,replace:!0});let R=u.pathname+u.search;if(u.pathname===t||u.pathname.startsWith(t))return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:t,replace:!0});let S=k(R),w=encodeURIComponent(S);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:`${t}?redirect=${w}`,replace:!0})}return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e})}var L="crudify_tokens",mr="crudify_enc_key";function B(){try{let e=localStorage.getItem(L);return e?e.startsWith("v2:")&&e.length>50:!1}catch (e2){return!1}}function W(){try{let e=localStorage.getItem(mr);return e!==null&&e.length>=32}catch (e3){return!1}}function U(){return B()&&W()}function H(){try{let e=localStorage.getItem(L);return e?!e.startsWith("v2:")||e.length<50:!1}catch (e4){return!1}}function gr(){try{H()&&localStorage.removeItem(L)}catch (e5){}}function Y({children:e,redirectTo:r="/",loadingComponent:t,initTimeout:o=3e3}){let{isAuthenticated:n,isInitialized:i}=_chunkCHDM7KGHjs.l.call(void 0, ),y=_reactrouterdom.useLocation.call(void 0, ),[c]=_react.useState.call(void 0, ()=>U()),[f,u]=_react.useState.call(void 0, !1);if(_react.useEffect.call(void 0, ()=>{if(!i&&c){let l=setTimeout(()=>{u(!0)},o);return()=>clearTimeout(l)}},[i,c,o]),i&&n){let l=new URLSearchParams(y.search),R=M(l,r);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:R,replace:!0})}return i&&!n?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e}):c&&!f?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:t||_jsxruntime.jsx.call(void 0, g,{stage:"validating-session"})}):_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e})}function J({children:e,behavior:r="redirect-if-authenticated",redirectTo:t="/",loadingComponent:o}){let{isAuthenticated:n,isInitialized:i}=_chunkCHDM7KGHjs.l.call(void 0, );return i?r==="allow-all"?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e}):n?_jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:t,replace:!0}):_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e}):_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:o||_jsxruntime.jsx.call(void 0, g,{stage:"validating-session"})})}var Q=_react.createContext.call(void 0, void 0),hr= exports.CrudifyInitializer =({config:e,children:r,fallback:t=null,onInitialized:o,onError:n})=>{let[i,y]=_react.useState.call(void 0, !1),[c,f]=_react.useState.call(void 0, !1),[u,l]=_react.useState.call(void 0, null),R=_react.useRef.call(void 0, !1),S=_react.useRef.call(void 0, !1);_react.useEffect.call(void 0, ()=>{R.current||(_chunkCHDM7KGHjs.q.registerHighPriorityInitializer(),R.current=!0),S.current||(S.current=!0,(async()=>{f(!0),l(null);try{let d=_chunkMFYHD6S5js.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(!d.publicApiKey)throw new Error("Crudify configuration missing. Please provide publicApiKey via props or ensure cookies are set by Lambda.");let v=d.env||"prod";_chunkMFYHD6S5js.a.setEnvironment(v),await _chunkCHDM7KGHjs.q.initialize({priority:"HIGH",publicApiKey:d.publicApiKey,env:d.env||"prod",enableLogging:_optionalChain([e, 'optionalAccess', _6 => _6.enableLogging]),requestedBy:"CrudifyInitializer"}),y(!0),f(!1),o&&o()}catch(d){let v=d instanceof Error?d:new Error(String(d));l(v),f(!1),n&&n(v)}})())},[_optionalChain([e, 'optionalAccess', _7 => _7.publicApiKey]),_optionalChain([e, 'optionalAccess', _8 => _8.env]),_optionalChain([e, 'optionalAccess', _9 => _9.enableLogging]),o,n]);let w={isInitialized:i,isInitializing:c,error:u};return c&&t?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:t}):(u&&_chunkMFYHD6S5js.a.error("[CrudifyInitializer] Initialization failed",u),_jsxruntime.jsx.call(void 0, Q.Provider,{value:w,children:r}))},Sr= exports.useCrudifyInitializer =()=>{let e=_react.useContext.call(void 0, Q);if(!e)throw new Error("useCrudifyInitializer must be used within CrudifyInitializer");return e};var _crudifyadmin = require('@nocios/crudify-admin'); var _crudifyadmin2 = _interopRequireDefault(_crudifyadmin);var X=!1,I=null,h=null;async function Tr(){let r=await _chunkCHDM7KGHjs.d.getInstance().getTokenInfo(),t=_optionalChain([r, 'optionalAccess', _10 => _10.apiEndpointAdmin]),o=_optionalChain([r, 'optionalAccess', _11 => _11.apiKeyEndpointAdmin]);return t&&o?{apiUrl:t,apiKey:o}:_chunkCHDM7KGHjs.h.waitForCredentials()}async function Er(){if(!X)return I||(I=(async()=>{try{let e=_chunkCHDM7KGHjs.d.getInstance(),{apiUrl:r,apiKey:t}=await Tr();h=await _asyncOptionalChain([(await e.getTokenInfo()), 'optionalAccess', async _12 => _12.crudifyTokens, 'optionalAccess', async _13 => _13.accessToken])||null,_crudifyadmin2.default.init({url:r,apiKey:t,getAdditionalHeaders:()=>h?{Authorization:`Bearer ${h}`}:{}}),X=!0}catch(e){throw I=null,_chunkMFYHD6S5js.a.error("[crudifyAdminWrapper] Initialization failed",e instanceof Error?e:{message:String(e)}),e}})(),I)}async function a(e){try{await Er();let r=_chunkCHDM7KGHjs.d.getInstance();h=await _asyncOptionalChain([(await r.getTokenInfo()), 'optionalAccess', async _14 => _14.crudifyTokens, 'optionalAccess', async _15 => _15.accessToken])||null;let o=await e(),n=o.errors&&(typeof o.errors=="string"&&o.errors.includes("401")||Array.isArray(o.errors)&&o.errors.some(i=>typeof i=="string"&&i.includes("401")));return!o.success&&n?await r.refreshTokens()?(h=await _asyncOptionalChain([(await r.getTokenInfo()), 'optionalAccess', async _16 => _16.crudifyTokens, 'optionalAccess', async _17 => _17.accessToken])||null,await e()):(_chunkMFYHD6S5js.a.error("[crudifyAdmin] Token refresh failed"),typeof window<"u"&&(window.location.href="/login"),o):o}catch(r){return _chunkMFYHD6S5js.a.error("[crudifyAdmin] Operation error",r instanceof Error?r:{message:String(r)}),{success:!1,errors:r instanceof Error?r.message:"Unknown error"}}}var kr={listModules:()=>a(()=>_crudifyadmin2.default.listModules()),getModule:e=>a(()=>_crudifyadmin2.default.getModule(e)),createModule:e=>a(()=>_crudifyadmin2.default.createModule(e)),editModule:(e,r)=>a(()=>_crudifyadmin2.default.editModule(e,r)),deleteModule:e=>a(()=>_crudifyadmin2.default.deleteModule(e)),activateModule:e=>a(()=>_crudifyadmin2.default.activateModule(e)),deactivateModule:e=>a(()=>_crudifyadmin2.default.deactivateModule(e)),getModuleVersions:e=>a(()=>_crudifyadmin2.default.getModuleVersions(e)),listActions:e=>a(()=>_crudifyadmin2.default.listActions(e)),getAction:e=>a(()=>_crudifyadmin2.default.getAction(e)),createAction:e=>a(()=>_crudifyadmin2.default.createAction(e)),editAction:(e,r)=>a(()=>_crudifyadmin2.default.editAction(e,r)),deleteAction:e=>a(()=>_crudifyadmin2.default.deleteAction(e)),activateAction:e=>a(()=>_crudifyadmin2.default.activateAction(e)),deactivateAction:e=>a(()=>_crudifyadmin2.default.deactivateAction(e)),getActionVersions:e=>a(()=>_crudifyadmin2.default.getActionVersions(e)),getActionsByProfile:e=>a(()=>_crudifyadmin2.default.getActionsByProfile(e)),updateActionsProfiles:e=>a(()=>_crudifyadmin2.default.updateActionsProfiles(e)),calculatePermissions:e=>a(()=>_crudifyadmin2.default.calculatePermissions(e))};exports.AuthRoute = Y; exports.CRITICAL_TRANSLATIONS = _chunkPNI3ZBZVjs.a; exports.CrossTabSyncManager = _chunkCHDM7KGHjs.b; exports.CrudiaAutoGenerate = _chunkPNI3ZBZVjs.s; exports.CrudiaFileField = _chunkPNI3ZBZVjs.t; exports.CrudiaMarkdownField = _chunkPNI3ZBZVjs.u; exports.CrudifyInitializationManager = _chunkCHDM7KGHjs.p; exports.CrudifyInitializer = hr; exports.CrudifyLogin = _chunkPNI3ZBZVjs.l; exports.CrudifyProvider = _chunkCHDM7KGHjs.i; exports.CrudifyThemeProvider = nr; exports.DEFAULT_PASSWORD_RULES = _chunkPNI3ZBZVjs.k; exports.ERROR_CODES = _chunkNSV6ECYOjs.a; exports.ERROR_SEVERITY_MAP = _chunkNSV6ECYOjs.b; exports.GlobalNotificationProvider = _chunkCHDM7KGHjs.f; exports.GuestRoute = J; exports.LoginComponent = _chunkPNI3ZBZVjs.q; exports.POLICY_ACTIONS = _chunkPNI3ZBZVjs.n; exports.PREFERRED_POLICY_ORDER = _chunkPNI3ZBZVjs.o; exports.PasswordRequirements = _chunkPNI3ZBZVjs.h; exports.Policies = _chunkPNI3ZBZVjs.p; exports.ProtectedRoute = V; exports.SessionDebugInfo = _chunkCHDM7KGHjs.m; exports.SessionLoadingScreen = g; exports.SessionManager = _chunkCHDM7KGHjs.d; exports.SessionProvider = _chunkCHDM7KGHjs.k; exports.SessionStatus = _chunkPNI3ZBZVjs.r; exports.TokenStorage = _chunkCHDM7KGHjs.a; exports.TranslationService = _chunkPNI3ZBZVjs.d; exports.TranslationsProvider = _chunkPNI3ZBZVjs.f; exports.UserProfileDisplay = _chunkPNI3ZBZVjs.m; exports.allPasswordRulesPassed = _chunkPNI3ZBZVjs.j; exports.clearCorruptedTokens = gr; exports.createErrorTranslator = _chunkMFYHD6S5js.o; exports.crossTabSync = _chunkCHDM7KGHjs.c; exports.crudify = _crudifysdk2.default; exports.crudifyAdmin = kr; exports.crudifyInitManager = _chunkCHDM7KGHjs.q; exports.decodeJwtSafely = _chunkMFYHD6S5js.q; exports.evaluatePasswordRules = _chunkPNI3ZBZVjs.i; exports.extractSafeRedirectFromUrl = M; exports.getCookie = _chunkMFYHD6S5js.b; exports.getCriticalLanguages = _chunkPNI3ZBZVjs.b; exports.getCriticalTranslations = _chunkPNI3ZBZVjs.c; exports.getCurrentUserEmail = _chunkMFYHD6S5js.r; exports.getErrorMessage = _chunkNSV6ECYOjs.e; exports.handleCrudifyError = _chunkNSV6ECYOjs.g; exports.hasCorruptedTokens = H; exports.hasEncryptionKeyHash = W; exports.hasStoredTokens = B; exports.isTokenExpired = _chunkMFYHD6S5js.s; exports.logger = _chunkMFYHD6S5js.a; exports.parseApiError = _chunkNSV6ECYOjs.c; exports.parseJavaScriptError = _chunkNSV6ECYOjs.f; exports.parseTransactionError = _chunkNSV6ECYOjs.d; exports.secureLocalStorage = _chunk5HFI5CZ5js.b; exports.secureSessionStorage = _chunk5HFI5CZ5js.a; exports.shouldWaitForInitialization = U; exports.translateError = _chunkMFYHD6S5js.n; exports.translateErrorCode = _chunkMFYHD6S5js.l; exports.translateErrorCodes = _chunkMFYHD6S5js.m; exports.translationService = _chunkPNI3ZBZVjs.e; exports.useAuth = _chunk2XOTIEKSjs.b; exports.useAutoGenerate = _chunkCHDM7KGHjs.o; exports.useCrudify = _chunkCHDM7KGHjs.j; exports.useCrudifyInitializer = Sr; exports.useCrudifyWithNotifications = _chunk2XOTIEKSjs.d; exports.useData = _chunk2XOTIEKSjs.c; exports.useFileUpload = _chunkCHDM7KGHjs.r; exports.useGlobalNotification = _chunkCHDM7KGHjs.g; exports.useSession = _chunkCHDM7KGHjs.e; exports.useSessionContext = _chunkCHDM7KGHjs.l; exports.useTranslations = _chunkPNI3ZBZVjs.g; exports.useUserData = _chunk2XOTIEKSjs.a; exports.useUserProfile = _chunkCHDM7KGHjs.n; exports.validateInternalRedirect = k;
6
+ `});function g({stage:e="loading",message:r}){let o=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, cr,{}),_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:ur}),_jsxruntime.jsx.call(void 0, "p",{style:{fontSize:"1.25em",fontWeight:"500",marginTop:"24px",color:"#1f2937"},children:o})]})]})}var dr=/^[a-zA-Z0-9\-_./\?=&%#]+$/,fr=[/^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]/,/\\/],k= exports.validateInternalRedirect =(e,r="/")=>{if(!e||typeof e!="string")return r;let t=e.trim();if(!t)return r;if(!t.startsWith("/"))return _chunkCR5KJUSTjs.a.warn("Open redirect blocked (relative path)",{path:e}),r;if(!dr.test(t))return _chunkCR5KJUSTjs.a.warn("Open redirect blocked (invalid characters)",{path:e}),r;let o=t.toLowerCase();for(let i of fr)if(i.test(o))return _chunkCR5KJUSTjs.a.warn("Open redirect blocked (dangerous pattern)",{path:e}),r;let n=t.split("?")[0].split("/").filter(Boolean);if(n.length===0)return t;for(let i of n)if(i===".."||i.includes(":")||i.length>100)return _chunkCR5KJUSTjs.a.warn("Open redirect blocked (suspicious path part)",{part:i}),r;return t},M= exports.extractSafeRedirectFromUrl =(e,r="/")=>{try{let o=(typeof e=="string"?new URLSearchParams(e):e).get("redirect");if(!o)return r;let n=decodeURIComponent(o);return k(n,r)}catch(t){return _chunkCR5KJUSTjs.a.warn("Error parsing redirect parameter",t instanceof Error?{errorMessage:t.message}:{message:String(t)}),r}};function V({children:e,loadingComponent:r,loginPath:t="/login"}){let{isAuthenticated:o,isLoading:n,isLoggingOut:i,isInitialized:y,tokens:c,error:f}=_chunkLK6QVSG4js.l.call(void 0, ),u=_reactrouterdom.useLocation.call(void 0, );if(!y||n&&!i)return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:r||_jsxruntime.jsx.call(void 0, g,{stage:"validating-session"})});let l=o&&_optionalChain([c, 'optionalAccess', _2 => _2.accessToken])&&c.accessToken.length>0;if(f||!o||!l){if(i)return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:t,replace:!0});let R=u.pathname+u.search;if(u.pathname===t||u.pathname.startsWith(t))return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:t,replace:!0});let S=k(R),w=encodeURIComponent(S);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:`${t}?redirect=${w}`,replace:!0})}return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e})}var L="crudify_tokens",gr="crudify_enc_key";function B(){try{let e=localStorage.getItem(L);return e?e.startsWith("v2:")&&e.length>50:!1}catch (e2){return!1}}function W(){try{let e=localStorage.getItem(gr);return e!==null&&e.length>=32}catch (e3){return!1}}function U(){return B()&&W()}function H(){try{let e=localStorage.getItem(L);return e?!e.startsWith("v2:")||e.length<50:!1}catch (e4){return!1}}function yr(){try{H()&&localStorage.removeItem(L)}catch (e5){}}function Y({children:e,redirectTo:r="/",loadingComponent:t,initTimeout:o=3e3}){let{isAuthenticated:n,isInitialized:i}=_chunkLK6QVSG4js.l.call(void 0, ),y=_reactrouterdom.useLocation.call(void 0, ),[c]=_react.useState.call(void 0, ()=>U()),[f,u]=_react.useState.call(void 0, !1);if(_react.useEffect.call(void 0, ()=>{if(!i&&c){let l=setTimeout(()=>{u(!0)},o);return()=>clearTimeout(l)}},[i,c,o]),i&&n){let l=new URLSearchParams(y.search),R=M(l,r);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:R,replace:!0})}return i&&!n?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e}):c&&!f?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:t||_jsxruntime.jsx.call(void 0, g,{stage:"validating-session"})}):_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e})}function $({children:e,behavior:r="redirect-if-authenticated",redirectTo:t="/",loadingComponent:o}){let{isAuthenticated:n,isInitialized:i}=_chunkLK6QVSG4js.l.call(void 0, );return i?r==="allow-all"?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e}):n?_jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:t,replace:!0}):_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e}):_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:o||_jsxruntime.jsx.call(void 0, g,{stage:"validating-session"})})}var Q=_react.createContext.call(void 0, void 0),Sr= exports.CrudifyInitializer =({config:e,children:r,fallback:t=null,onInitialized:o,onError:n})=>{let[i,y]=_react.useState.call(void 0, !1),[c,f]=_react.useState.call(void 0, !1),[u,l]=_react.useState.call(void 0, null),R=_react.useRef.call(void 0, !1),S=_react.useRef.call(void 0, !1);_react.useEffect.call(void 0, ()=>{R.current||(_chunkLK6QVSG4js.q.registerHighPriorityInitializer(),R.current=!0),S.current||(S.current=!0,(async()=>{f(!0),l(null);try{let d=_chunkCR5KJUSTjs.d.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(!d.publicApiKey)throw new Error("Crudify configuration missing. Please provide publicApiKey via props or ensure cookies are set by Lambda.");let v=d.env||"prod";_chunkCR5KJUSTjs.a.setEnvironment(v),await _chunkLK6QVSG4js.q.initialize({priority:"HIGH",publicApiKey:d.publicApiKey,env:d.env||"prod",enableLogging:_optionalChain([e, 'optionalAccess', _6 => _6.enableLogging]),requestedBy:"CrudifyInitializer"}),y(!0),f(!1),o&&o()}catch(d){let v=d instanceof Error?d:new Error(String(d));l(v),f(!1),n&&n(v)}})())},[_optionalChain([e, 'optionalAccess', _7 => _7.publicApiKey]),_optionalChain([e, 'optionalAccess', _8 => _8.env]),_optionalChain([e, 'optionalAccess', _9 => _9.enableLogging]),o,n]);let w={isInitialized:i,isInitializing:c,error:u};return c&&t?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:t}):(u&&_chunkCR5KJUSTjs.a.error("[CrudifyInitializer] Initialization failed",u),_jsxruntime.jsx.call(void 0, Q.Provider,{value:w,children:r}))},vr= exports.useCrudifyInitializer =()=>{let e=_react.useContext.call(void 0, Q);if(!e)throw new Error("useCrudifyInitializer must be used within CrudifyInitializer");return e};var _crudifyadminsdk = require('@nocios/crudify-admin-sdk'); var _crudifyadminsdk2 = _interopRequireDefault(_crudifyadminsdk);var X=!1,I=null,h=null;async function Er(){let r=await _chunkLK6QVSG4js.d.getInstance().getTokenInfo(),t=_optionalChain([r, 'optionalAccess', _10 => _10.apiEndpointAdmin]),o=_optionalChain([r, 'optionalAccess', _11 => _11.apiKeyEndpointAdmin]);return t&&o?{apiUrl:t,apiKey:o}:_chunkLK6QVSG4js.h.waitForCredentials()}async function kr(){if(!X)return I||(I=(async()=>{try{let e=_chunkLK6QVSG4js.d.getInstance(),{apiUrl:r,apiKey:t}=await Er();h=await _asyncOptionalChain([(await e.getTokenInfo()), 'optionalAccess', async _12 => _12.crudifyTokens, 'optionalAccess', async _13 => _13.accessToken])||null,_crudifyadminsdk2.default.init({url:r,apiKey:t,getAdditionalHeaders:()=>h?{Authorization:`Bearer ${h}`}:{}}),X=!0}catch(e){throw I=null,_chunkCR5KJUSTjs.a.error("[crudifyAdminWrapper] Initialization failed",e instanceof Error?e:{message:String(e)}),e}})(),I)}async function a(e){try{await kr();let r=_chunkLK6QVSG4js.d.getInstance();h=await _asyncOptionalChain([(await r.getTokenInfo()), 'optionalAccess', async _14 => _14.crudifyTokens, 'optionalAccess', async _15 => _15.accessToken])||null;let o=await e(),n=o.errors&&(typeof o.errors=="string"&&o.errors.includes("401")||Array.isArray(o.errors)&&o.errors.some(i=>typeof i=="string"&&i.includes("401")));return!o.success&&n?await r.refreshTokens()?(h=await _asyncOptionalChain([(await r.getTokenInfo()), 'optionalAccess', async _16 => _16.crudifyTokens, 'optionalAccess', async _17 => _17.accessToken])||null,await e()):(_chunkCR5KJUSTjs.a.error("[crudifyAdmin] Token refresh failed"),typeof window<"u"&&(window.location.href="/login"),o):o}catch(r){return _chunkCR5KJUSTjs.a.error("[crudifyAdmin] Operation error",r instanceof Error?r:{message:String(r)}),{success:!1,errors:r instanceof Error?r.message:"Unknown error"}}}var wr={listModules:()=>a(()=>_crudifyadminsdk2.default.listModules()),getModule:e=>a(()=>_crudifyadminsdk2.default.getModule(e)),createModule:e=>a(()=>_crudifyadminsdk2.default.createModule(e)),editModule:(e,r)=>a(()=>_crudifyadminsdk2.default.editModule(e,r)),deleteModule:e=>a(()=>_crudifyadminsdk2.default.deleteModule(e)),activateModule:e=>a(()=>_crudifyadminsdk2.default.activateModule(e)),deactivateModule:e=>a(()=>_crudifyadminsdk2.default.deactivateModule(e)),getModuleVersions:e=>a(()=>_crudifyadminsdk2.default.getModuleVersions(e)),listActions:e=>a(()=>_crudifyadminsdk2.default.listActions(e)),getAction:e=>a(()=>_crudifyadminsdk2.default.getAction(e)),createAction:e=>a(()=>_crudifyadminsdk2.default.createAction(e)),editAction:(e,r)=>a(()=>_crudifyadminsdk2.default.editAction(e,r)),deleteAction:e=>a(()=>_crudifyadminsdk2.default.deleteAction(e)),activateAction:e=>a(()=>_crudifyadminsdk2.default.activateAction(e)),deactivateAction:e=>a(()=>_crudifyadminsdk2.default.deactivateAction(e)),getActionVersions:e=>a(()=>_crudifyadminsdk2.default.getActionVersions(e)),getActionsByProfile:e=>a(()=>_crudifyadminsdk2.default.getActionsByProfile(e)),updateActionsProfiles:e=>a(()=>_crudifyadminsdk2.default.updateActionsProfiles(e)),calculatePermissions:e=>a(()=>_crudifyadminsdk2.default.calculatePermissions(e))};exports.AuthRoute = Y; exports.CRITICAL_TRANSLATIONS = _chunkAOPB3KXBjs.a; exports.CrossTabSyncManager = _chunkLK6QVSG4js.b; exports.CrudiaAutoGenerate = _chunkAOPB3KXBjs.s; exports.CrudiaFileField = _chunkAOPB3KXBjs.t; exports.CrudiaMarkdownField = _chunkAOPB3KXBjs.u; exports.CrudifyInitializationManager = _chunkLK6QVSG4js.p; exports.CrudifyInitializer = Sr; exports.CrudifyLogin = _chunkAOPB3KXBjs.l; exports.CrudifyProvider = _chunkLK6QVSG4js.i; exports.CrudifyThemeProvider = sr; exports.DEFAULT_PASSWORD_RULES = _chunkAOPB3KXBjs.k; exports.ERROR_CODES = _chunkNSV6ECYOjs.a; exports.ERROR_SEVERITY_MAP = _chunkNSV6ECYOjs.b; exports.GlobalNotificationProvider = _chunkLK6QVSG4js.f; exports.GuestRoute = $; exports.LoginComponent = _chunkAOPB3KXBjs.q; exports.POLICY_ACTIONS = _chunkAOPB3KXBjs.n; exports.PREFERRED_POLICY_ORDER = _chunkAOPB3KXBjs.o; exports.PasswordRequirements = _chunkAOPB3KXBjs.h; exports.Policies = _chunkAOPB3KXBjs.p; exports.ProtectedRoute = V; exports.SessionDebugInfo = _chunkLK6QVSG4js.m; exports.SessionLoadingScreen = g; exports.SessionManager = _chunkLK6QVSG4js.d; exports.SessionProvider = _chunkLK6QVSG4js.k; exports.SessionStatus = _chunkAOPB3KXBjs.r; exports.TokenStorage = _chunkLK6QVSG4js.a; exports.TranslationService = _chunkAOPB3KXBjs.d; exports.TranslationsProvider = _chunkAOPB3KXBjs.f; exports.UserProfileDisplay = _chunkAOPB3KXBjs.m; exports.allPasswordRulesPassed = _chunkAOPB3KXBjs.j; exports.clearCorruptedTokens = yr; exports.createErrorTranslator = _chunkCR5KJUSTjs.p; exports.crossTabSync = _chunkLK6QVSG4js.c; exports.crudify = _crudifysdk2.default; exports.crudifyAdmin = wr; exports.crudifyInitManager = _chunkLK6QVSG4js.q; exports.decodeJwtSafely = _chunkCR5KJUSTjs.r; exports.evaluatePasswordRules = _chunkAOPB3KXBjs.i; exports.extractSafeRedirectFromUrl = M; exports.getCriticalLanguages = _chunkAOPB3KXBjs.b; exports.getCriticalTranslations = _chunkAOPB3KXBjs.c; exports.getCurrentUserEmail = _chunkCR5KJUSTjs.s; exports.getErrorMessage = _chunkNSV6ECYOjs.e; exports.handleCrudifyError = _chunkNSV6ECYOjs.g; exports.hasCorruptedTokens = H; exports.hasEncryptionKeyHash = W; exports.hasStoredTokens = B; exports.isTokenExpired = _chunkCR5KJUSTjs.t; exports.logger = _chunkCR5KJUSTjs.a; exports.parseApiError = _chunkNSV6ECYOjs.c; exports.parseJavaScriptError = _chunkNSV6ECYOjs.f; exports.parseTransactionError = _chunkNSV6ECYOjs.d; exports.resolveTenantConfig = _chunkCR5KJUSTjs.b; exports.secureLocalStorage = _chunk4VN5YRYZjs.b; exports.secureSessionStorage = _chunk4VN5YRYZjs.a; exports.shouldWaitForInitialization = U; exports.translateError = _chunkCR5KJUSTjs.o; exports.translateErrorCode = _chunkCR5KJUSTjs.m; exports.translateErrorCodes = _chunkCR5KJUSTjs.n; exports.translationService = _chunkAOPB3KXBjs.e; exports.useAuth = _chunkRORGWKHPjs.b; exports.useAutoGenerate = _chunkLK6QVSG4js.o; exports.useCrudify = _chunkLK6QVSG4js.j; exports.useCrudifyInitializer = vr; exports.useCrudifyWithNotifications = _chunkRORGWKHPjs.d; exports.useData = _chunkRORGWKHPjs.c; exports.useFileUpload = _chunkLK6QVSG4js.r; exports.useGlobalNotification = _chunkLK6QVSG4js.g; exports.useSession = _chunkLK6QVSG4js.e; exports.useSessionContext = _chunkLK6QVSG4js.l; exports.useTenantConfig = _chunkCR5KJUSTjs.c; exports.useTranslations = _chunkAOPB3KXBjs.g; exports.useUserData = _chunkRORGWKHPjs.a; exports.useUserProfile = _chunkLK6QVSG4js.n; exports.validateInternalRedirect = k;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import{a as j,b as ee,c as re,d as te,e as oe,f as ie,g as ne,h as be,i as Me,j as ze,k as Le,l as Ue,m as Fe,n as Ne,o as Ge,p as De,q as Ke,r as _e,s as Be,t as qe,u as Ye}from"./chunk-HVTRRU4W.mjs";import{a as Je,b as $e,c as Ze,d as je}from"./chunk-U4RS66TB.mjs";import{a as se,b as le,c as de,d as A,e as fe,f as Re,g as xe,h as D,i as Ae,j as Ce,k as Pe,l as m,m as Ie,n as Oe,o as Ve,p as We,q as T,r as He}from"./chunk-NBQH6QOU.mjs";import{a as Qe,b as Xe}from"./chunk-JNEWPO2J.mjs";import{a as he,b as Se,c as ve,d as Te,e as Ee,f as ke,g as we}from"./chunk-JAPL7EZJ.mjs";import{a as p,b,c as G,l as ae,m as pe,n as ue,o as ce,q as me,r as ge,s as ye}from"./chunk-MGJZTOEM.mjs";import{default as Tt}from"@nocios/crudify-sdk";export*from"@nocios/crudify-sdk";import{useMemo as er}from"react";import{ThemeProvider as rr,createTheme as tr,CssBaseline as or}from"@mui/material";import{jsx as sr,jsxs as ar}from"react/jsx-runtime";var ir=(e={})=>{try{let r=b("theme");if(r){let t=JSON.parse(decodeURIComponent(r));return{...e,...t}}}catch(r){p.warn("Error parsing theme from cookie",r instanceof Error?{errorMessage:r.message}:{message:String(r)})}return e};function nr({children:e,defaultTheme:r={},disableCssBaseline:t=!1}){let o=er(()=>{let n=ir(r);return tr(n)},[r]);return ar(rr,{theme:o,children:[!t&&sr(or,{}),e]})}import{Navigate as z,useLocation as fr}from"react-router-dom";import{Fragment as cr,jsx as E,jsxs as K}from"react/jsx-runtime";var pr={border:"5px solid rgba(0, 0, 0, 0.1)",borderTopColor:"#3B82F6",borderRadius:"50%",width:"50px",height:"50px",animation:"spin 1s linear infinite"},ur=()=>E("style",{children:`
1
+ import{a as j,b as ee,c as re,d as te,e as oe,f as ne,g as se,h as Me,i as ze,j as Le,k as Ue,l as Oe,m as Ne,n as Ge,o as De,p as Ke,q as _e,r as Ve,s as We,t as Ye,u as $e}from"./chunk-7ORHVSWL.mjs";import{a as Je,b as Ze,c as Qe,d as er}from"./chunk-XZ6OGRJR.mjs";import{a as ae,b as de,c as fe,d as x,e as me,f as Ce,g as xe,h as D,i as Ae,j as Pe,k as Ie,l as m,m as he,n as Fe,o as Be,p as He,q as T,r as qe}from"./chunk-GT7B57S5.mjs";import{a as Xe,b as je}from"./chunk-RJBX4MWF.mjs";import{a as Se,b as ve,c as Te,d as Ee,e as ke,f as we,g as be}from"./chunk-JAPL7EZJ.mjs";import{a as p,b,c as ie,d as G,m as pe,n as ue,o as ce,p as le,r as ge,s as ye,t as Re}from"./chunk-4ILUXVPW.mjs";import{default as Et}from"@nocios/crudify-sdk";export*from"@nocios/crudify-sdk";import{useMemo as rr}from"react";import{ThemeProvider as tr,createTheme as or,CssBaseline as ir}from"@mui/material";import{jsx as ar,jsxs as pr}from"react/jsx-runtime";var nr=(e={})=>{try{let r=b();if(r.configSource!=="none"&&r.theme)return{...e,...r.theme}}catch(r){p.warn("Error reading theme from config",r instanceof Error?{errorMessage:r.message}:{message:String(r)})}return e};function sr({children:e,defaultTheme:r={},disableCssBaseline:t=!1}){let o=rr(()=>{let n=nr(r);return or(n)},[r]);return pr(tr,{theme:o,children:[!t&&ar(ir,{}),e]})}import{Navigate as z,useLocation as mr}from"react-router-dom";import{Fragment as lr,jsx as E,jsxs as K}from"react/jsx-runtime";var ur={border:"5px solid rgba(0, 0, 0, 0.1)",borderTopColor:"#3B82F6",borderRadius:"50%",width:"50px",height:"50px",animation:"spin 1s linear infinite"},cr=()=>E("style",{children:`
2
2
  @keyframes spin {
3
3
  0% { transform: rotate(0deg); }
4
4
  100% { transform: rotate(360deg); }
5
5
  }
6
- `});function g({stage:e="loading",message:r}){let o=r||{initializing:"Initializing application...","validating-session":"Validating session...",loading:"Loading..."}[e];return K(cr,{children:[E(ur,{}),K("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:[E("div",{style:pr}),E("p",{style:{fontSize:"1.25em",fontWeight:"500",marginTop:"24px",color:"#1f2937"},children:o})]})]})}var lr=/^[a-zA-Z0-9\-_./\?=&%#]+$/,dr=[/^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]/,/\\/],k=(e,r="/")=>{if(!e||typeof e!="string")return r;let t=e.trim();if(!t)return r;if(!t.startsWith("/"))return p.warn("Open redirect blocked (relative path)",{path:e}),r;if(!lr.test(t))return p.warn("Open redirect blocked (invalid characters)",{path:e}),r;let o=t.toLowerCase();for(let i of dr)if(i.test(o))return p.warn("Open redirect blocked (dangerous pattern)",{path:e}),r;let n=t.split("?")[0].split("/").filter(Boolean);if(n.length===0)return t;for(let i of n)if(i===".."||i.includes(":")||i.length>100)return p.warn("Open redirect blocked (suspicious path part)",{part:i}),r;return t},M=(e,r="/")=>{try{let o=(typeof e=="string"?new URLSearchParams(e):e).get("redirect");if(!o)return r;let n=decodeURIComponent(o);return k(n,r)}catch(t){return p.warn("Error parsing redirect parameter",t instanceof Error?{errorMessage:t.message}:{message:String(t)}),r}};import{Fragment as _,jsx as x}from"react/jsx-runtime";function V({children:e,loadingComponent:r,loginPath:t="/login"}){let{isAuthenticated:o,isLoading:n,isLoggingOut:i,isInitialized:y,tokens:c,error:f}=m(),u=fr();if(!y||n&&!i)return x(_,{children:r||x(g,{stage:"validating-session"})});let l=o&&c?.accessToken&&c.accessToken.length>0;if(f||!o||!l){if(i)return x(z,{to:t,replace:!0});let R=u.pathname+u.search;if(u.pathname===t||u.pathname.startsWith(t))return x(z,{to:t,replace:!0});let S=k(R),w=encodeURIComponent(S);return x(z,{to:`${t}?redirect=${w}`,replace:!0})}return x(_,{children:e})}import{useState as q,useEffect as yr}from"react";import{Navigate as Rr,useLocation as xr}from"react-router-dom";var L="crudify_tokens",mr="crudify_enc_key";function B(){try{let e=localStorage.getItem(L);return e?e.startsWith("v2:")&&e.length>50:!1}catch{return!1}}function W(){try{let e=localStorage.getItem(mr);return e!==null&&e.length>=32}catch{return!1}}function U(){return B()&&W()}function H(){try{let e=localStorage.getItem(L);return e?!e.startsWith("v2:")||e.length<50:!1}catch{return!1}}function gr(){try{H()&&localStorage.removeItem(L)}catch{}}import{Fragment as O,jsx as C}from"react/jsx-runtime";function Y({children:e,redirectTo:r="/",loadingComponent:t,initTimeout:o=3e3}){let{isAuthenticated:n,isInitialized:i}=m(),y=xr(),[c]=q(()=>U()),[f,u]=q(!1);if(yr(()=>{if(!i&&c){let l=setTimeout(()=>{u(!0)},o);return()=>clearTimeout(l)}},[i,c,o]),i&&n){let l=new URLSearchParams(y.search),R=M(l,r);return C(Rr,{to:R,replace:!0})}return i&&!n?C(O,{children:e}):c&&!f?C(O,{children:t||C(g,{stage:"validating-session"})}):C(O,{children:e})}import{Navigate as Ar}from"react-router-dom";import{Fragment as F,jsx as P}from"react/jsx-runtime";function J({children:e,behavior:r="redirect-if-authenticated",redirectTo:t="/",loadingComponent:o}){let{isAuthenticated:n,isInitialized:i}=m();return i?r==="allow-all"?P(F,{children:e}):n?P(Ar,{to:t,replace:!0}):P(F,{children:e}):P(F,{children:o||P(g,{stage:"validating-session"})})}import{createContext as Cr,useContext as Pr,useEffect as Ir,useRef as $,useState as N}from"react";import{Fragment as vr,jsx as Z}from"react/jsx-runtime";var Q=Cr(void 0),hr=({config:e,children:r,fallback:t=null,onInitialized:o,onError:n})=>{let[i,y]=N(!1),[c,f]=N(!1),[u,l]=N(null),R=$(!1),S=$(!1);Ir(()=>{R.current||(T.registerHighPriorityInitializer(),R.current=!0),S.current||(S.current=!0,(async()=>{f(!0),l(null);try{let d=G({publicApiKey:e?.publicApiKey,env:e?.env,enableDebug:e?.enableLogging});if(!d.publicApiKey)throw new Error("Crudify configuration missing. Please provide publicApiKey via props or ensure cookies are set by Lambda.");let v=d.env||"prod";p.setEnvironment(v),await T.initialize({priority:"HIGH",publicApiKey:d.publicApiKey,env:d.env||"prod",enableLogging:e?.enableLogging,requestedBy:"CrudifyInitializer"}),y(!0),f(!1),o&&o()}catch(d){let v=d instanceof Error?d:new Error(String(d));l(v),f(!1),n&&n(v)}})())},[e?.publicApiKey,e?.env,e?.enableLogging,o,n]);let w={isInitialized:i,isInitializing:c,error:u};return c&&t?Z(vr,{children:t}):(u&&p.error("[CrudifyInitializer] Initialization failed",u),Z(Q.Provider,{value:w,children:r}))},Sr=()=>{let e=Pr(Q);if(!e)throw new Error("useCrudifyInitializer must be used within CrudifyInitializer");return e};import s from"@nocios/crudify-admin";var X=!1,I=null,h=null;async function Tr(){let r=await A.getInstance().getTokenInfo(),t=r?.apiEndpointAdmin,o=r?.apiKeyEndpointAdmin;return t&&o?{apiUrl:t,apiKey:o}:D.waitForCredentials()}async function Er(){if(!X)return I||(I=(async()=>{try{let e=A.getInstance(),{apiUrl:r,apiKey:t}=await Tr();h=(await e.getTokenInfo())?.crudifyTokens?.accessToken||null,s.init({url:r,apiKey:t,getAdditionalHeaders:()=>h?{Authorization:`Bearer ${h}`}:{}}),X=!0}catch(e){throw I=null,p.error("[crudifyAdminWrapper] Initialization failed",e instanceof Error?e:{message:String(e)}),e}})(),I)}async function a(e){try{await Er();let r=A.getInstance();h=(await r.getTokenInfo())?.crudifyTokens?.accessToken||null;let o=await e(),n=o.errors&&(typeof o.errors=="string"&&o.errors.includes("401")||Array.isArray(o.errors)&&o.errors.some(i=>typeof i=="string"&&i.includes("401")));return!o.success&&n?await r.refreshTokens()?(h=(await r.getTokenInfo())?.crudifyTokens?.accessToken||null,await e()):(p.error("[crudifyAdmin] Token refresh failed"),typeof window<"u"&&(window.location.href="/login"),o):o}catch(r){return p.error("[crudifyAdmin] Operation error",r instanceof Error?r:{message:String(r)}),{success:!1,errors:r instanceof Error?r.message:"Unknown error"}}}var kr={listModules:()=>a(()=>s.listModules()),getModule:e=>a(()=>s.getModule(e)),createModule:e=>a(()=>s.createModule(e)),editModule:(e,r)=>a(()=>s.editModule(e,r)),deleteModule:e=>a(()=>s.deleteModule(e)),activateModule:e=>a(()=>s.activateModule(e)),deactivateModule:e=>a(()=>s.deactivateModule(e)),getModuleVersions:e=>a(()=>s.getModuleVersions(e)),listActions:e=>a(()=>s.listActions(e)),getAction:e=>a(()=>s.getAction(e)),createAction:e=>a(()=>s.createAction(e)),editAction:(e,r)=>a(()=>s.editAction(e,r)),deleteAction:e=>a(()=>s.deleteAction(e)),activateAction:e=>a(()=>s.activateAction(e)),deactivateAction:e=>a(()=>s.deactivateAction(e)),getActionVersions:e=>a(()=>s.getActionVersions(e)),getActionsByProfile:e=>a(()=>s.getActionsByProfile(e)),updateActionsProfiles:e=>a(()=>s.updateActionsProfiles(e)),calculatePermissions:e=>a(()=>s.calculatePermissions(e))};export{Y as AuthRoute,j as CRITICAL_TRANSLATIONS,le as CrossTabSyncManager,Be as CrudiaAutoGenerate,qe as CrudiaFileField,Ye as CrudiaMarkdownField,We as CrudifyInitializationManager,hr as CrudifyInitializer,Ue as CrudifyLogin,Ae as CrudifyProvider,nr as CrudifyThemeProvider,Le as DEFAULT_PASSWORD_RULES,he as ERROR_CODES,Se as ERROR_SEVERITY_MAP,Re as GlobalNotificationProvider,J as GuestRoute,Ke as LoginComponent,Ne as POLICY_ACTIONS,Ge as PREFERRED_POLICY_ORDER,be as PasswordRequirements,De as Policies,V as ProtectedRoute,Ie as SessionDebugInfo,g as SessionLoadingScreen,A as SessionManager,Pe as SessionProvider,_e as SessionStatus,se as TokenStorage,te as TranslationService,ie as TranslationsProvider,Fe as UserProfileDisplay,ze as allPasswordRulesPassed,gr as clearCorruptedTokens,ce as createErrorTranslator,de as crossTabSync,Tt as crudify,kr as crudifyAdmin,T as crudifyInitManager,me as decodeJwtSafely,Me as evaluatePasswordRules,M as extractSafeRedirectFromUrl,b as getCookie,ee as getCriticalLanguages,re as getCriticalTranslations,ge as getCurrentUserEmail,Ee as getErrorMessage,we as handleCrudifyError,H as hasCorruptedTokens,W as hasEncryptionKeyHash,B as hasStoredTokens,ye as isTokenExpired,p as logger,ve as parseApiError,ke as parseJavaScriptError,Te as parseTransactionError,Xe as secureLocalStorage,Qe as secureSessionStorage,U as shouldWaitForInitialization,ue as translateError,ae as translateErrorCode,pe as translateErrorCodes,oe as translationService,$e as useAuth,Ve as useAutoGenerate,Ce as useCrudify,Sr as useCrudifyInitializer,je as useCrudifyWithNotifications,Ze as useData,He as useFileUpload,xe as useGlobalNotification,fe as useSession,m as useSessionContext,ne as useTranslations,Je as useUserData,Oe as useUserProfile,k as validateInternalRedirect};
6
+ `});function g({stage:e="loading",message:r}){let o=r||{initializing:"Initializing application...","validating-session":"Validating session...",loading:"Loading..."}[e];return K(lr,{children:[E(cr,{}),K("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:[E("div",{style:ur}),E("p",{style:{fontSize:"1.25em",fontWeight:"500",marginTop:"24px",color:"#1f2937"},children:o})]})]})}var dr=/^[a-zA-Z0-9\-_./\?=&%#]+$/,fr=[/^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]/,/\\/],k=(e,r="/")=>{if(!e||typeof e!="string")return r;let t=e.trim();if(!t)return r;if(!t.startsWith("/"))return p.warn("Open redirect blocked (relative path)",{path:e}),r;if(!dr.test(t))return p.warn("Open redirect blocked (invalid characters)",{path:e}),r;let o=t.toLowerCase();for(let i of fr)if(i.test(o))return p.warn("Open redirect blocked (dangerous pattern)",{path:e}),r;let n=t.split("?")[0].split("/").filter(Boolean);if(n.length===0)return t;for(let i of n)if(i===".."||i.includes(":")||i.length>100)return p.warn("Open redirect blocked (suspicious path part)",{part:i}),r;return t},M=(e,r="/")=>{try{let o=(typeof e=="string"?new URLSearchParams(e):e).get("redirect");if(!o)return r;let n=decodeURIComponent(o);return k(n,r)}catch(t){return p.warn("Error parsing redirect parameter",t instanceof Error?{errorMessage:t.message}:{message:String(t)}),r}};import{Fragment as _,jsx as C}from"react/jsx-runtime";function V({children:e,loadingComponent:r,loginPath:t="/login"}){let{isAuthenticated:o,isLoading:n,isLoggingOut:i,isInitialized:y,tokens:c,error:f}=m(),u=mr();if(!y||n&&!i)return C(_,{children:r||C(g,{stage:"validating-session"})});let l=o&&c?.accessToken&&c.accessToken.length>0;if(f||!o||!l){if(i)return C(z,{to:t,replace:!0});let R=u.pathname+u.search;if(u.pathname===t||u.pathname.startsWith(t))return C(z,{to:t,replace:!0});let S=k(R),w=encodeURIComponent(S);return C(z,{to:`${t}?redirect=${w}`,replace:!0})}return C(_,{children:e})}import{useState as q,useEffect as Rr}from"react";import{Navigate as Cr,useLocation as xr}from"react-router-dom";var L="crudify_tokens",gr="crudify_enc_key";function B(){try{let e=localStorage.getItem(L);return e?e.startsWith("v2:")&&e.length>50:!1}catch{return!1}}function W(){try{let e=localStorage.getItem(gr);return e!==null&&e.length>=32}catch{return!1}}function U(){return B()&&W()}function H(){try{let e=localStorage.getItem(L);return e?!e.startsWith("v2:")||e.length<50:!1}catch{return!1}}function yr(){try{H()&&localStorage.removeItem(L)}catch{}}import{Fragment as O,jsx as A}from"react/jsx-runtime";function Y({children:e,redirectTo:r="/",loadingComponent:t,initTimeout:o=3e3}){let{isAuthenticated:n,isInitialized:i}=m(),y=xr(),[c]=q(()=>U()),[f,u]=q(!1);if(Rr(()=>{if(!i&&c){let l=setTimeout(()=>{u(!0)},o);return()=>clearTimeout(l)}},[i,c,o]),i&&n){let l=new URLSearchParams(y.search),R=M(l,r);return A(Cr,{to:R,replace:!0})}return i&&!n?A(O,{children:e}):c&&!f?A(O,{children:t||A(g,{stage:"validating-session"})}):A(O,{children:e})}import{Navigate as Ar}from"react-router-dom";import{Fragment as F,jsx as P}from"react/jsx-runtime";function $({children:e,behavior:r="redirect-if-authenticated",redirectTo:t="/",loadingComponent:o}){let{isAuthenticated:n,isInitialized:i}=m();return i?r==="allow-all"?P(F,{children:e}):n?P(Ar,{to:t,replace:!0}):P(F,{children:e}):P(F,{children:o||P(g,{stage:"validating-session"})})}import{createContext as Pr,useContext as Ir,useEffect as hr,useRef as J,useState as N}from"react";import{Fragment as Tr,jsx as Z}from"react/jsx-runtime";var Q=Pr(void 0),Sr=({config:e,children:r,fallback:t=null,onInitialized:o,onError:n})=>{let[i,y]=N(!1),[c,f]=N(!1),[u,l]=N(null),R=J(!1),S=J(!1);hr(()=>{R.current||(T.registerHighPriorityInitializer(),R.current=!0),S.current||(S.current=!0,(async()=>{f(!0),l(null);try{let d=G({publicApiKey:e?.publicApiKey,env:e?.env,enableDebug:e?.enableLogging});if(!d.publicApiKey)throw new Error("Crudify configuration missing. Please provide publicApiKey via props or ensure cookies are set by Lambda.");let v=d.env||"prod";p.setEnvironment(v),await T.initialize({priority:"HIGH",publicApiKey:d.publicApiKey,env:d.env||"prod",enableLogging:e?.enableLogging,requestedBy:"CrudifyInitializer"}),y(!0),f(!1),o&&o()}catch(d){let v=d instanceof Error?d:new Error(String(d));l(v),f(!1),n&&n(v)}})())},[e?.publicApiKey,e?.env,e?.enableLogging,o,n]);let w={isInitialized:i,isInitializing:c,error:u};return c&&t?Z(Tr,{children:t}):(u&&p.error("[CrudifyInitializer] Initialization failed",u),Z(Q.Provider,{value:w,children:r}))},vr=()=>{let e=Ir(Q);if(!e)throw new Error("useCrudifyInitializer must be used within CrudifyInitializer");return e};import s from"@nocios/crudify-admin-sdk";var X=!1,I=null,h=null;async function Er(){let r=await x.getInstance().getTokenInfo(),t=r?.apiEndpointAdmin,o=r?.apiKeyEndpointAdmin;return t&&o?{apiUrl:t,apiKey:o}:D.waitForCredentials()}async function kr(){if(!X)return I||(I=(async()=>{try{let e=x.getInstance(),{apiUrl:r,apiKey:t}=await Er();h=(await e.getTokenInfo())?.crudifyTokens?.accessToken||null,s.init({url:r,apiKey:t,getAdditionalHeaders:()=>h?{Authorization:`Bearer ${h}`}:{}}),X=!0}catch(e){throw I=null,p.error("[crudifyAdminWrapper] Initialization failed",e instanceof Error?e:{message:String(e)}),e}})(),I)}async function a(e){try{await kr();let r=x.getInstance();h=(await r.getTokenInfo())?.crudifyTokens?.accessToken||null;let o=await e(),n=o.errors&&(typeof o.errors=="string"&&o.errors.includes("401")||Array.isArray(o.errors)&&o.errors.some(i=>typeof i=="string"&&i.includes("401")));return!o.success&&n?await r.refreshTokens()?(h=(await r.getTokenInfo())?.crudifyTokens?.accessToken||null,await e()):(p.error("[crudifyAdmin] Token refresh failed"),typeof window<"u"&&(window.location.href="/login"),o):o}catch(r){return p.error("[crudifyAdmin] Operation error",r instanceof Error?r:{message:String(r)}),{success:!1,errors:r instanceof Error?r.message:"Unknown error"}}}var wr={listModules:()=>a(()=>s.listModules()),getModule:e=>a(()=>s.getModule(e)),createModule:e=>a(()=>s.createModule(e)),editModule:(e,r)=>a(()=>s.editModule(e,r)),deleteModule:e=>a(()=>s.deleteModule(e)),activateModule:e=>a(()=>s.activateModule(e)),deactivateModule:e=>a(()=>s.deactivateModule(e)),getModuleVersions:e=>a(()=>s.getModuleVersions(e)),listActions:e=>a(()=>s.listActions(e)),getAction:e=>a(()=>s.getAction(e)),createAction:e=>a(()=>s.createAction(e)),editAction:(e,r)=>a(()=>s.editAction(e,r)),deleteAction:e=>a(()=>s.deleteAction(e)),activateAction:e=>a(()=>s.activateAction(e)),deactivateAction:e=>a(()=>s.deactivateAction(e)),getActionVersions:e=>a(()=>s.getActionVersions(e)),getActionsByProfile:e=>a(()=>s.getActionsByProfile(e)),updateActionsProfiles:e=>a(()=>s.updateActionsProfiles(e)),calculatePermissions:e=>a(()=>s.calculatePermissions(e))};export{Y as AuthRoute,j as CRITICAL_TRANSLATIONS,de as CrossTabSyncManager,We as CrudiaAutoGenerate,Ye as CrudiaFileField,$e as CrudiaMarkdownField,He as CrudifyInitializationManager,Sr as CrudifyInitializer,Oe as CrudifyLogin,Ae as CrudifyProvider,sr as CrudifyThemeProvider,Ue as DEFAULT_PASSWORD_RULES,Se as ERROR_CODES,ve as ERROR_SEVERITY_MAP,Ce as GlobalNotificationProvider,$ as GuestRoute,_e as LoginComponent,Ge as POLICY_ACTIONS,De as PREFERRED_POLICY_ORDER,Me as PasswordRequirements,Ke as Policies,V as ProtectedRoute,he as SessionDebugInfo,g as SessionLoadingScreen,x as SessionManager,Ie as SessionProvider,Ve as SessionStatus,ae as TokenStorage,te as TranslationService,ne as TranslationsProvider,Ne as UserProfileDisplay,Le as allPasswordRulesPassed,yr as clearCorruptedTokens,le as createErrorTranslator,fe as crossTabSync,Et as crudify,wr as crudifyAdmin,T as crudifyInitManager,ge as decodeJwtSafely,ze as evaluatePasswordRules,M as extractSafeRedirectFromUrl,ee as getCriticalLanguages,re as getCriticalTranslations,ye as getCurrentUserEmail,ke as getErrorMessage,be as handleCrudifyError,H as hasCorruptedTokens,W as hasEncryptionKeyHash,B as hasStoredTokens,Re as isTokenExpired,p as logger,Te as parseApiError,we as parseJavaScriptError,Ee as parseTransactionError,b as resolveTenantConfig,je as secureLocalStorage,Xe as secureSessionStorage,U as shouldWaitForInitialization,ce as translateError,pe as translateErrorCode,ue as translateErrorCodes,oe as translationService,Ze as useAuth,Be as useAutoGenerate,Pe as useCrudify,vr as useCrudifyInitializer,er as useCrudifyWithNotifications,Qe as useData,qe as useFileUpload,xe as useGlobalNotification,me as useSession,m as useSessionContext,ie as useTenantConfig,se as useTranslations,Je as useUserData,Fe as useUserProfile,k as validateInternalRedirect};
package/dist/utils.d.mts CHANGED
@@ -1,52 +1,6 @@
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-qwwQTvCO.mjs';
1
+ export { C as ConfigResolverOptions, h as CrudifyEnvironment, E as ERROR_CODES, n as ERROR_SEVERITY_MAP, w as ErrorCode, x as ErrorSeverity, y as ErrorTranslationConfig, P as ParsedError, f as ResolvedConfig, R as ResolvedTenantConfig, T as TenantConfig, b as TenantConfigOptions, v as createErrorTranslator, d as decodeJwtSafely, g as getCurrentUserEmail, m as getErrorMessage, j as handleCrudifyError, i as isTokenExpired, p as parseApiError, l as parseJavaScriptError, k as parseTransactionError, c as resolveConfig, r as resolveTenantConfig, a as secureLocalStorage, s as secureSessionStorage, q as translateError, t as translateErrorCode, o as translateErrorCodes, e as useResolvedConfig, u as useTenantConfig } from './errorTranslation-DeeDj7Vt.mjs';
2
2
  import './api-B4uXiHF0.mjs';
3
3
 
4
- /**
5
- * Sistema centralizado de resolución de configuración para npm-crudify-ui
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.
14
- */
15
- type CrudifyEnvironment = "dev" | "stg" | "api" | "prod";
16
- interface ResolvedConfig {
17
- publicApiKey?: string;
18
- env?: CrudifyEnvironment;
19
- appName?: string;
20
- logo?: string;
21
- loginActions?: string[];
22
- featureKeys?: string[];
23
- theme?: Record<string, unknown>;
24
- configSource: "props" | "cookies" | "none";
25
- }
26
- interface ConfigResolverOptions {
27
- publicApiKey?: string;
28
- env?: CrudifyEnvironment;
29
- appName?: string;
30
- logo?: string;
31
- loginActions?: string[];
32
- featureKeys?: string[];
33
- enableDebug?: boolean;
34
- }
35
- /**
36
- * Resolves Crudify configuration with the following priority:
37
- * 1. Cookies (production with Lambda multitenancy) - HIGHEST PRIORITY
38
- * 2. Props (local development with .env) - FALLBACK
39
- * 3. None (error - missing configuration)
40
- *
41
- * This resolver is responsible for reading cookies and applying correct priority.
42
- */
43
- declare function resolveConfig(options?: ConfigResolverOptions): ResolvedConfig;
44
- /**
45
- * React hook to use config resolver
46
- * Useful when you need config in a component
47
- */
48
- declare function useResolvedConfig(options?: ConfigResolverOptions): ResolvedConfig;
49
-
50
4
  /**
51
5
  * Event Bus para coordinar acciones de autenticación
52
6
  * Previene race conditions y asegura respuesta única a errores
@@ -172,4 +126,4 @@ declare class NavigationTracker {
172
126
  isActive(): boolean;
173
127
  }
174
128
 
175
- export { type AuthEvent, type AuthEventDetails, type AuthEventType, type ConfigResolverOptions, type CrudifyEnvironment, NavigationTracker, type ResolvedConfig, authEventBus, resolveConfig, useResolvedConfig };
129
+ export { type AuthEvent, type AuthEventDetails, type AuthEventType, NavigationTracker, authEventBus };
package/dist/utils.d.ts CHANGED
@@ -1,52 +1,6 @@
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-DGdrMidg.js';
1
+ export { C as ConfigResolverOptions, h as CrudifyEnvironment, E as ERROR_CODES, n as ERROR_SEVERITY_MAP, w as ErrorCode, x as ErrorSeverity, y as ErrorTranslationConfig, P as ParsedError, f as ResolvedConfig, R as ResolvedTenantConfig, T as TenantConfig, b as TenantConfigOptions, v as createErrorTranslator, d as decodeJwtSafely, g as getCurrentUserEmail, m as getErrorMessage, j as handleCrudifyError, i as isTokenExpired, p as parseApiError, l as parseJavaScriptError, k as parseTransactionError, c as resolveConfig, r as resolveTenantConfig, a as secureLocalStorage, s as secureSessionStorage, q as translateError, t as translateErrorCode, o as translateErrorCodes, e as useResolvedConfig, u as useTenantConfig } from './errorTranslation-By5Av0tL.js';
2
2
  import './api-B4uXiHF0.js';
3
3
 
4
- /**
5
- * Sistema centralizado de resolución de configuración para npm-crudify-ui
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.
14
- */
15
- type CrudifyEnvironment = "dev" | "stg" | "api" | "prod";
16
- interface ResolvedConfig {
17
- publicApiKey?: string;
18
- env?: CrudifyEnvironment;
19
- appName?: string;
20
- logo?: string;
21
- loginActions?: string[];
22
- featureKeys?: string[];
23
- theme?: Record<string, unknown>;
24
- configSource: "props" | "cookies" | "none";
25
- }
26
- interface ConfigResolverOptions {
27
- publicApiKey?: string;
28
- env?: CrudifyEnvironment;
29
- appName?: string;
30
- logo?: string;
31
- loginActions?: string[];
32
- featureKeys?: string[];
33
- enableDebug?: boolean;
34
- }
35
- /**
36
- * Resolves Crudify configuration with the following priority:
37
- * 1. Cookies (production with Lambda multitenancy) - HIGHEST PRIORITY
38
- * 2. Props (local development with .env) - FALLBACK
39
- * 3. None (error - missing configuration)
40
- *
41
- * This resolver is responsible for reading cookies and applying correct priority.
42
- */
43
- declare function resolveConfig(options?: ConfigResolverOptions): ResolvedConfig;
44
- /**
45
- * React hook to use config resolver
46
- * Useful when you need config in a component
47
- */
48
- declare function useResolvedConfig(options?: ConfigResolverOptions): ResolvedConfig;
49
-
50
4
  /**
51
5
  * Event Bus para coordinar acciones de autenticación
52
6
  * Previene race conditions y asegura respuesta única a errores
@@ -172,4 +126,4 @@ declare class NavigationTracker {
172
126
  isActive(): boolean;
173
127
  }
174
128
 
175
- export { type AuthEvent, type AuthEventDetails, type AuthEventType, type ConfigResolverOptions, type CrudifyEnvironment, NavigationTracker, type ResolvedConfig, authEventBus, resolveConfig, useResolvedConfig };
129
+ export { type AuthEvent, type AuthEventDetails, type AuthEventType, NavigationTracker, authEventBus };
package/dist/utils.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk5HFI5CZ5js = require('./chunk-5HFI5CZ5.js');var _chunkNSV6ECYOjs = require('./chunk-NSV6ECYO.js');var _chunkMFYHD6S5js = require('./chunk-MFYHD6S5.js');exports.ERROR_CODES = _chunkNSV6ECYOjs.a; exports.ERROR_SEVERITY_MAP = _chunkNSV6ECYOjs.b; exports.NavigationTracker = _chunkMFYHD6S5js.p; exports.authEventBus = _chunkMFYHD6S5js.e; exports.createErrorTranslator = _chunkMFYHD6S5js.o; exports.decodeJwtSafely = _chunkMFYHD6S5js.q; exports.getCookie = _chunkMFYHD6S5js.b; exports.getCurrentUserEmail = _chunkMFYHD6S5js.r; exports.getErrorMessage = _chunkNSV6ECYOjs.e; exports.handleCrudifyError = _chunkNSV6ECYOjs.g; exports.isTokenExpired = _chunkMFYHD6S5js.s; exports.parseApiError = _chunkNSV6ECYOjs.c; exports.parseJavaScriptError = _chunkNSV6ECYOjs.f; exports.parseTransactionError = _chunkNSV6ECYOjs.d; exports.resolveConfig = _chunkMFYHD6S5js.c; exports.secureLocalStorage = _chunk5HFI5CZ5js.b; exports.secureSessionStorage = _chunk5HFI5CZ5js.a; exports.translateError = _chunkMFYHD6S5js.n; exports.translateErrorCode = _chunkMFYHD6S5js.l; exports.translateErrorCodes = _chunkMFYHD6S5js.m; exports.useResolvedConfig = _chunkMFYHD6S5js.d;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4VN5YRYZjs = require('./chunk-4VN5YRYZ.js');var _chunkNSV6ECYOjs = require('./chunk-NSV6ECYO.js');var _chunkCR5KJUSTjs = require('./chunk-CR5KJUST.js');exports.ERROR_CODES = _chunkNSV6ECYOjs.a; exports.ERROR_SEVERITY_MAP = _chunkNSV6ECYOjs.b; exports.NavigationTracker = _chunkCR5KJUSTjs.q; exports.authEventBus = _chunkCR5KJUSTjs.f; exports.createErrorTranslator = _chunkCR5KJUSTjs.p; exports.decodeJwtSafely = _chunkCR5KJUSTjs.r; exports.getCurrentUserEmail = _chunkCR5KJUSTjs.s; exports.getErrorMessage = _chunkNSV6ECYOjs.e; exports.handleCrudifyError = _chunkNSV6ECYOjs.g; exports.isTokenExpired = _chunkCR5KJUSTjs.t; exports.parseApiError = _chunkNSV6ECYOjs.c; exports.parseJavaScriptError = _chunkNSV6ECYOjs.f; exports.parseTransactionError = _chunkNSV6ECYOjs.d; exports.resolveConfig = _chunkCR5KJUSTjs.d; exports.resolveTenantConfig = _chunkCR5KJUSTjs.b; exports.secureLocalStorage = _chunk4VN5YRYZjs.b; exports.secureSessionStorage = _chunk4VN5YRYZjs.a; exports.translateError = _chunkCR5KJUSTjs.o; exports.translateErrorCode = _chunkCR5KJUSTjs.m; exports.translateErrorCodes = _chunkCR5KJUSTjs.n; exports.useResolvedConfig = _chunkCR5KJUSTjs.e; exports.useTenantConfig = _chunkCR5KJUSTjs.c;
package/dist/utils.mjs CHANGED
@@ -1 +1 @@
1
- import{a as R,b as c}from"./chunk-JNEWPO2J.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-JAPL7EZJ.mjs";import{b as r,c as e,d as o,e as t,l as a,m as n,n as s,o as E,p as i,q as p,r as f,s as l}from"./chunk-MGJZTOEM.mjs";export{m as ERROR_CODES,v as ERROR_SEVERITY_MAP,i as NavigationTracker,t as authEventBus,E 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,s as translateError,a as translateErrorCode,n as translateErrorCodes,o as useResolvedConfig};
1
+ import{a as R,b as y}from"./chunk-RJBX4MWF.mjs";import{a as C,b as v,c as m,d,e as u,f as x,g as T}from"./chunk-JAPL7EZJ.mjs";import{b as r,c as e,d as o,e as t,f as n,m as a,n as s,o as i,p as f,q as p,r as E,s as l,t as g}from"./chunk-4ILUXVPW.mjs";export{C as ERROR_CODES,v as ERROR_SEVERITY_MAP,p as NavigationTracker,n as authEventBus,f as createErrorTranslator,E as decodeJwtSafely,l as getCurrentUserEmail,u as getErrorMessage,T as handleCrudifyError,g as isTokenExpired,m as parseApiError,x as parseJavaScriptError,d as parseTransactionError,o as resolveConfig,r as resolveTenantConfig,y as secureLocalStorage,R as secureSessionStorage,i as translateError,a as translateErrorCode,s as translateErrorCodes,t as useResolvedConfig,e as useTenantConfig};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocios/crudify-components",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "engines": {
5
5
  "node": ">=24.12.0"
6
6
  },
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@mdxeditor/editor": "^3.52.0",
45
- "@nocios/crudify-admin": "^5.0.2",
45
+ "@nocios/crudify-admin-sdk": "^1.0.0",
46
46
  "@nocios/crudify-sdk": "^1.0.0",
47
47
  "dompurify": "^3.2.7",
48
48
  "uuid": "^13.0.0"