@nocios/crudify-components 1.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/.github/workflows/test.yml +59 -0
- package/.nvmrc +1 -0
- package/README.md +398 -0
- package/README_DEPTH.md +1230 -0
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/coverage-final.json +85 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +506 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +210 -0
- package/dist/CrudiaMarkdownField-C54-A_J3.d.mts +328 -0
- package/dist/CrudiaMarkdownField-C8HQh7s5.d.ts +328 -0
- package/dist/GlobalNotificationProvider-Zq18OkpI.d.mts +96 -0
- package/dist/GlobalNotificationProvider-Zq18OkpI.d.ts +96 -0
- package/dist/api-B4uXiHF0.d.mts +118 -0
- package/dist/api-B4uXiHF0.d.ts +118 -0
- package/dist/chunk-2XOTIEKS.js +1 -0
- package/dist/chunk-5HFI5CZ5.js +1 -0
- package/dist/chunk-CHDM7KGH.js +1 -0
- package/dist/chunk-HVTRRU4W.mjs +1 -0
- package/dist/chunk-JAPL7EZJ.mjs +1 -0
- package/dist/chunk-JNEWPO2J.mjs +1 -0
- package/dist/chunk-MFYHD6S5.js +1 -0
- package/dist/chunk-MGJZTOEM.mjs +1 -0
- package/dist/chunk-NBQH6QOU.mjs +1 -0
- package/dist/chunk-NSV6ECYO.js +1 -0
- package/dist/chunk-PNI3ZBZV.js +1 -0
- package/dist/chunk-U4RS66TB.mjs +1 -0
- package/dist/components.d.mts +24 -0
- package/dist/components.d.ts +24 -0
- package/dist/components.js +1 -0
- package/dist/components.mjs +1 -0
- package/dist/errorTranslation-DGdrMidg.d.ts +143 -0
- package/dist/errorTranslation-qwwQTvCO.d.mts +143 -0
- package/dist/hooks.d.mts +6 -0
- package/dist/hooks.d.ts +6 -0
- package/dist/hooks.js +1 -0
- package/dist/hooks.mjs +1 -0
- package/dist/index-BUKX3duW.d.ts +854 -0
- package/dist/index-Y9tTsinC.d.mts +854 -0
- package/dist/index.d.mts +1274 -0
- package/dist/index.d.ts +1274 -0
- package/dist/index.js +6 -0
- package/dist/index.mjs +6 -0
- package/dist/utils.d.mts +175 -0
- package/dist/utils.d.ts +175 -0
- package/dist/utils.js +1 -0
- package/dist/utils.mjs +1 -0
- package/package.json +88 -0
- package/vitest.config.ts +28 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
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, d as CrudifyLoginConfig, e as CrudifyLoginProps, f as CrudifyLoginTranslations, L as LoginComponent, P as Policies, h as PolicyAction, S as SessionStatus, g as UserLoginData, U as UserProfileDisplay } from './CrudiaMarkdownField-C8HQh7s5.js';
|
|
2
|
+
export { G as GlobalNotificationProvider, a as GlobalNotificationProviderProps, N as Notification, b as NotificationSeverity, u as useGlobalNotification } from './GlobalNotificationProvider-Zq18OkpI.js';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import 'react';
|
|
5
|
+
|
|
6
|
+
type SessionTimeIndicatorProps = {
|
|
7
|
+
/** Tiempo mínimo (en minutos) para mostrar el indicador. Default: 5 */
|
|
8
|
+
showBelowMinutes?: number;
|
|
9
|
+
/** Posición del indicador. Default: "bottom-right" */
|
|
10
|
+
position?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
11
|
+
/** Color del indicador cuando quedan >2 minutos. Default: "warning" */
|
|
12
|
+
colorNormal?: string;
|
|
13
|
+
/** Color del indicador cuando quedan <2 minutos. Default: "error" */
|
|
14
|
+
colorCritical?: string;
|
|
15
|
+
/** Permitir personalizar el estilo del contenedor */
|
|
16
|
+
style?: React.CSSProperties;
|
|
17
|
+
/** Permitir personalizar clases CSS */
|
|
18
|
+
className?: string;
|
|
19
|
+
};
|
|
20
|
+
declare function SessionTimeIndicator({ showBelowMinutes, position, colorNormal, // orange (warning)
|
|
21
|
+
colorCritical, // red (error)
|
|
22
|
+
style, className, }?: SessionTimeIndicatorProps): react_jsx_runtime.JSX.Element | null;
|
|
23
|
+
|
|
24
|
+
export { SessionTimeIndicator, type SessionTimeIndicatorProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPNI3ZBZVjs = require('./chunk-PNI3ZBZV.js');var _chunkCHDM7KGHjs = require('./chunk-CHDM7KGH.js');require('./chunk-NSV6ECYO.js');require('./chunk-MFYHD6S5.js');var _react = require('react');var _jsxruntime = require('react/jsx-runtime');function z({showBelowMinutes:f=5,position:m="bottom-right",colorNormal:c="#ed6c02",colorCritical:x="#d32f2f",style:u,className:g}={}){let{isAuthenticated:o,tokens:t}=_chunkCHDM7KGHjs.e.call(void 0, ),[i,y]=_react.useState.call(void 0, 0),[h,C]=_react.useState.call(void 0, 100);if(_react.useEffect.call(void 0, ()=>{if(!o||!t)return;let v=setInterval(()=>{let P=Date.now(),p=t.expiresAt-P,w=900*1e3;y(Math.max(0,p)),C(Math.max(0,p/w*100))},1e3);return()=>clearInterval(v)},[o,t]),!o||i<=0)return null;let e=Math.floor(i/6e4),S=Math.floor(i%6e4/1e3);if(e>=f)return null;let s=e<2,a=s?x:c,b={"top-left":{top:"16px",left:"16px"},"top-right":{top:"16px",right:"16px"},"bottom-left":{bottom:"16px",left:"16px"},"bottom-right":{bottom:"16px",right:"16px"}}[m];return _jsxruntime.jsxs.call(void 0, "div",{className:g,style:{position:"fixed",...b,padding:"12px 16px",backgroundColor:"white",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",minWidth:"200px",zIndex:9999,fontFamily:"system-ui, -apple-system, sans-serif",...u},children:[_jsxruntime.jsxs.call(void 0, "div",{style:{marginBottom:"8px"},children:[_jsxruntime.jsx.call(void 0, "div",{style:{fontSize:"12px",fontWeight:600,color:a,marginBottom:"4px"},children:s?"\u26A0\uFE0F Sesi\xF3n expirando":"\u23F0 Sesi\xF3n por expirar"}),_jsxruntime.jsxs.call(void 0, "div",{style:{fontSize:"14px",color:"#333",fontWeight:500},children:[e,":",S.toString().padStart(2,"0")]})]}),_jsxruntime.jsx.call(void 0, "div",{style:{width:"100%",height:"6px",backgroundColor:"#e0e0e0",borderRadius:"3px",overflow:"hidden"},children:_jsxruntime.jsx.call(void 0, "div",{style:{width:`${h}%`,height:"100%",backgroundColor:a,transition:"width 1s linear"}})})]})}exports.CrudiaAutoGenerate = _chunkPNI3ZBZVjs.s; exports.CrudiaFileField = _chunkPNI3ZBZVjs.t; exports.CrudiaMarkdownField = _chunkPNI3ZBZVjs.u; exports.CrudifyLogin = _chunkPNI3ZBZVjs.l; exports.GlobalNotificationProvider = _chunkCHDM7KGHjs.f; exports.LoginComponent = _chunkPNI3ZBZVjs.q; exports.Policies = _chunkPNI3ZBZVjs.p; exports.SessionStatus = _chunkPNI3ZBZVjs.r; exports.SessionTimeIndicator = z; exports.UserProfileDisplay = _chunkPNI3ZBZVjs.m; exports.useGlobalNotification = _chunkCHDM7KGHjs.g;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{l as N,m as T,p as M,q as k,r as G,s as L,t as A,u as R}from"./chunk-HVTRRU4W.mjs";import{e as d,f as F,g as I}from"./chunk-NBQH6QOU.mjs";import"./chunk-JAPL7EZJ.mjs";import"./chunk-MGJZTOEM.mjs";import{useEffect as B,useState as l}from"react";import{jsx as r,jsxs as n}from"react/jsx-runtime";function z({showBelowMinutes:f=5,position:m="bottom-right",colorNormal:c="#ed6c02",colorCritical:x="#d32f2f",style:u,className:g}={}){let{isAuthenticated:o,tokens:t}=d(),[i,y]=l(0),[h,C]=l(100);if(B(()=>{if(!o||!t)return;let v=setInterval(()=>{let P=Date.now(),p=t.expiresAt-P,w=900*1e3;y(Math.max(0,p)),C(Math.max(0,p/w*100))},1e3);return()=>clearInterval(v)},[o,t]),!o||i<=0)return null;let e=Math.floor(i/6e4),S=Math.floor(i%6e4/1e3);if(e>=f)return null;let s=e<2,a=s?x:c,b={"top-left":{top:"16px",left:"16px"},"top-right":{top:"16px",right:"16px"},"bottom-left":{bottom:"16px",left:"16px"},"bottom-right":{bottom:"16px",right:"16px"}}[m];return n("div",{className:g,style:{position:"fixed",...b,padding:"12px 16px",backgroundColor:"white",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",minWidth:"200px",zIndex:9999,fontFamily:"system-ui, -apple-system, sans-serif",...u},children:[n("div",{style:{marginBottom:"8px"},children:[r("div",{style:{fontSize:"12px",fontWeight:600,color:a,marginBottom:"4px"},children:s?"\u26A0\uFE0F Sesi\xF3n expirando":"\u23F0 Sesi\xF3n por expirar"}),n("div",{style:{fontSize:"14px",color:"#333",fontWeight:500},children:[e,":",S.toString().padStart(2,"0")]})]}),r("div",{style:{width:"100%",height:"6px",backgroundColor:"#e0e0e0",borderRadius:"3px",overflow:"hidden"},children:r("div",{style:{width:`${h}%`,height:"100%",backgroundColor:a,transition:"width 1s linear"}})})]})}export{L as CrudiaAutoGenerate,A as CrudiaFileField,R as CrudiaMarkdownField,N as CrudifyLogin,F as GlobalNotificationProvider,k as LoginComponent,M as Policies,G as SessionStatus,z as SessionTimeIndicator,T as UserProfileDisplay,I as useGlobalNotification};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { J as JwtPayload } from './api-B4uXiHF0.js';
|
|
2
|
+
|
|
3
|
+
interface JWTPayload extends JwtPayload {
|
|
4
|
+
"cognito:username"?: string;
|
|
5
|
+
}
|
|
6
|
+
declare const decodeJwtSafely: (token: string) => JWTPayload | null;
|
|
7
|
+
declare const getCurrentUserEmail: () => string | null;
|
|
8
|
+
declare const isTokenExpired: (token: string) => boolean;
|
|
9
|
+
|
|
10
|
+
declare const getCookie: (name: string) => string | null;
|
|
11
|
+
|
|
12
|
+
declare class SecureStorage {
|
|
13
|
+
private readonly storage;
|
|
14
|
+
private encryptionKey;
|
|
15
|
+
private salt;
|
|
16
|
+
private initPromise;
|
|
17
|
+
private initialized;
|
|
18
|
+
constructor(storageType?: "localStorage" | "sessionStorage");
|
|
19
|
+
/**
|
|
20
|
+
* Initialize encryption key asynchronously
|
|
21
|
+
* Must be called before using encryption methods
|
|
22
|
+
*/
|
|
23
|
+
private ensureInitialized;
|
|
24
|
+
private initialize;
|
|
25
|
+
private generateFingerprint;
|
|
26
|
+
private clearLegacyData;
|
|
27
|
+
setItem(key: string, value: string, expiryMinutes?: number): Promise<void>;
|
|
28
|
+
getItem(key: string): Promise<string | null>;
|
|
29
|
+
removeItem(key: string): void;
|
|
30
|
+
clear(): void;
|
|
31
|
+
setToken(token: string): Promise<void>;
|
|
32
|
+
getToken(): Promise<string | null>;
|
|
33
|
+
hasValidToken(): Promise<boolean>;
|
|
34
|
+
migrateFromLocalStorage(key: string): Promise<void>;
|
|
35
|
+
private uint8ArrayToBase64;
|
|
36
|
+
private base64ToUint8Array;
|
|
37
|
+
}
|
|
38
|
+
declare const secureSessionStorage: SecureStorage;
|
|
39
|
+
declare const secureLocalStorage: SecureStorage;
|
|
40
|
+
|
|
41
|
+
declare const ERROR_CODES: {
|
|
42
|
+
readonly INVALID_CREDENTIALS: "INVALID_CREDENTIALS";
|
|
43
|
+
readonly UNAUTHORIZED: "UNAUTHORIZED";
|
|
44
|
+
readonly INVALID_API_KEY: "INVALID_API_KEY";
|
|
45
|
+
readonly USER_NOT_FOUND: "USER_NOT_FOUND";
|
|
46
|
+
readonly USER_NOT_ACTIVE: "USER_NOT_ACTIVE";
|
|
47
|
+
readonly NO_PERMISSION: "NO_PERMISSION";
|
|
48
|
+
readonly ITEM_NOT_FOUND: "ITEM_NOT_FOUND";
|
|
49
|
+
readonly NOT_FOUND: "NOT_FOUND";
|
|
50
|
+
readonly IN_USE: "IN_USE";
|
|
51
|
+
readonly FIELD_ERROR: "FIELD_ERROR";
|
|
52
|
+
readonly BAD_REQUEST: "BAD_REQUEST";
|
|
53
|
+
readonly INVALID_EMAIL: "INVALID_EMAIL";
|
|
54
|
+
readonly INVALID_CODE: "INVALID_CODE";
|
|
55
|
+
readonly INTERNAL_SERVER_ERROR: "INTERNAL_SERVER_ERROR";
|
|
56
|
+
readonly DATABASE_CONNECTION_ERROR: "DATABASE_CONNECTION_ERROR";
|
|
57
|
+
readonly INVALID_CONFIGURATION: "INVALID_CONFIGURATION";
|
|
58
|
+
readonly UNKNOWN_OPERATION: "UNKNOWN_OPERATION";
|
|
59
|
+
readonly TOO_MANY_REQUESTS: "TOO_MANY_REQUESTS";
|
|
60
|
+
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
61
|
+
readonly TIMEOUT_ERROR: "TIMEOUT_ERROR";
|
|
62
|
+
};
|
|
63
|
+
type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
|
|
64
|
+
type ErrorSeverity = "info" | "warning" | "error" | "critical";
|
|
65
|
+
declare const ERROR_SEVERITY_MAP: Record<ErrorCode, ErrorSeverity>;
|
|
66
|
+
interface ParsedError {
|
|
67
|
+
code: ErrorCode;
|
|
68
|
+
message: string;
|
|
69
|
+
severity: ErrorSeverity;
|
|
70
|
+
field?: string;
|
|
71
|
+
details?: Record<string, unknown>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Parse a Crudify API response and extract standardized error information
|
|
75
|
+
*/
|
|
76
|
+
declare function parseApiError(response: unknown): ParsedError[];
|
|
77
|
+
/**
|
|
78
|
+
* Parse transaction response errors
|
|
79
|
+
*/
|
|
80
|
+
declare function parseTransactionError(response: unknown): ParsedError[];
|
|
81
|
+
/**
|
|
82
|
+
* Get a human-readable error message for an error code
|
|
83
|
+
*/
|
|
84
|
+
declare function getErrorMessage(code: ErrorCode): string;
|
|
85
|
+
/**
|
|
86
|
+
* Handle JavaScript/Network errors and convert to ParsedError
|
|
87
|
+
*/
|
|
88
|
+
declare function parseJavaScriptError(error: unknown): ParsedError;
|
|
89
|
+
/**
|
|
90
|
+
* Universal error handler that can process any type of error from Crudify APIs
|
|
91
|
+
*/
|
|
92
|
+
declare function handleCrudifyError(error: unknown): ParsedError[];
|
|
93
|
+
|
|
94
|
+
interface ErrorTranslationConfig {
|
|
95
|
+
/** Función de traducción de i18next */
|
|
96
|
+
translateFn: (key: string) => string;
|
|
97
|
+
/** Idioma actual (opcional, para logging) */
|
|
98
|
+
currentLanguage?: string;
|
|
99
|
+
/** Habilitar logs de debug */
|
|
100
|
+
enableDebug?: boolean;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Traduce un código de error usando jerarquía de fallbacks
|
|
104
|
+
*/
|
|
105
|
+
declare function translateErrorCode(errorCode: string, config: ErrorTranslationConfig): string;
|
|
106
|
+
/**
|
|
107
|
+
* Traduce múltiples códigos de error
|
|
108
|
+
*/
|
|
109
|
+
declare function translateErrorCodes(errorCodes: string[], config: ErrorTranslationConfig): string[];
|
|
110
|
+
/**
|
|
111
|
+
* Traduce un error completo (código + mensaje personalizado)
|
|
112
|
+
*/
|
|
113
|
+
declare function translateError(error: {
|
|
114
|
+
code: string;
|
|
115
|
+
message?: string;
|
|
116
|
+
field?: string;
|
|
117
|
+
}, config: ErrorTranslationConfig): string;
|
|
118
|
+
/**
|
|
119
|
+
* Hook para usar en componentes React con i18next
|
|
120
|
+
*/
|
|
121
|
+
declare function createErrorTranslator(translateFn: (key: string) => string, options?: {
|
|
122
|
+
currentLanguage?: string;
|
|
123
|
+
enableDebug?: boolean;
|
|
124
|
+
}): {
|
|
125
|
+
translateErrorCode: (code: string) => string;
|
|
126
|
+
translateErrorCodes: (codes: string[]) => string[];
|
|
127
|
+
translateError: (error: {
|
|
128
|
+
code: string;
|
|
129
|
+
message?: string;
|
|
130
|
+
field?: string;
|
|
131
|
+
}) => string;
|
|
132
|
+
translateApiError: (apiResponse: {
|
|
133
|
+
data?: {
|
|
134
|
+
response?: {
|
|
135
|
+
status?: string;
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
status?: string;
|
|
139
|
+
code?: string;
|
|
140
|
+
} | null | undefined) => string;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export { ERROR_CODES as E, type ParsedError as P, getCookie as a, secureLocalStorage as b, parseTransactionError as c, decodeJwtSafely as d, parseJavaScriptError as e, getErrorMessage as f, getCurrentUserEmail as g, handleCrudifyError as h, isTokenExpired as i, ERROR_SEVERITY_MAP as j, translateErrorCodes as k, translateError as l, createErrorTranslator as m, type ErrorCode as n, type ErrorSeverity as o, parseApiError as p, type ErrorTranslationConfig as q, secureSessionStorage as s, translateErrorCode as t };
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { J as JwtPayload } from './api-B4uXiHF0.mjs';
|
|
2
|
+
|
|
3
|
+
interface JWTPayload extends JwtPayload {
|
|
4
|
+
"cognito:username"?: string;
|
|
5
|
+
}
|
|
6
|
+
declare const decodeJwtSafely: (token: string) => JWTPayload | null;
|
|
7
|
+
declare const getCurrentUserEmail: () => string | null;
|
|
8
|
+
declare const isTokenExpired: (token: string) => boolean;
|
|
9
|
+
|
|
10
|
+
declare const getCookie: (name: string) => string | null;
|
|
11
|
+
|
|
12
|
+
declare class SecureStorage {
|
|
13
|
+
private readonly storage;
|
|
14
|
+
private encryptionKey;
|
|
15
|
+
private salt;
|
|
16
|
+
private initPromise;
|
|
17
|
+
private initialized;
|
|
18
|
+
constructor(storageType?: "localStorage" | "sessionStorage");
|
|
19
|
+
/**
|
|
20
|
+
* Initialize encryption key asynchronously
|
|
21
|
+
* Must be called before using encryption methods
|
|
22
|
+
*/
|
|
23
|
+
private ensureInitialized;
|
|
24
|
+
private initialize;
|
|
25
|
+
private generateFingerprint;
|
|
26
|
+
private clearLegacyData;
|
|
27
|
+
setItem(key: string, value: string, expiryMinutes?: number): Promise<void>;
|
|
28
|
+
getItem(key: string): Promise<string | null>;
|
|
29
|
+
removeItem(key: string): void;
|
|
30
|
+
clear(): void;
|
|
31
|
+
setToken(token: string): Promise<void>;
|
|
32
|
+
getToken(): Promise<string | null>;
|
|
33
|
+
hasValidToken(): Promise<boolean>;
|
|
34
|
+
migrateFromLocalStorage(key: string): Promise<void>;
|
|
35
|
+
private uint8ArrayToBase64;
|
|
36
|
+
private base64ToUint8Array;
|
|
37
|
+
}
|
|
38
|
+
declare const secureSessionStorage: SecureStorage;
|
|
39
|
+
declare const secureLocalStorage: SecureStorage;
|
|
40
|
+
|
|
41
|
+
declare const ERROR_CODES: {
|
|
42
|
+
readonly INVALID_CREDENTIALS: "INVALID_CREDENTIALS";
|
|
43
|
+
readonly UNAUTHORIZED: "UNAUTHORIZED";
|
|
44
|
+
readonly INVALID_API_KEY: "INVALID_API_KEY";
|
|
45
|
+
readonly USER_NOT_FOUND: "USER_NOT_FOUND";
|
|
46
|
+
readonly USER_NOT_ACTIVE: "USER_NOT_ACTIVE";
|
|
47
|
+
readonly NO_PERMISSION: "NO_PERMISSION";
|
|
48
|
+
readonly ITEM_NOT_FOUND: "ITEM_NOT_FOUND";
|
|
49
|
+
readonly NOT_FOUND: "NOT_FOUND";
|
|
50
|
+
readonly IN_USE: "IN_USE";
|
|
51
|
+
readonly FIELD_ERROR: "FIELD_ERROR";
|
|
52
|
+
readonly BAD_REQUEST: "BAD_REQUEST";
|
|
53
|
+
readonly INVALID_EMAIL: "INVALID_EMAIL";
|
|
54
|
+
readonly INVALID_CODE: "INVALID_CODE";
|
|
55
|
+
readonly INTERNAL_SERVER_ERROR: "INTERNAL_SERVER_ERROR";
|
|
56
|
+
readonly DATABASE_CONNECTION_ERROR: "DATABASE_CONNECTION_ERROR";
|
|
57
|
+
readonly INVALID_CONFIGURATION: "INVALID_CONFIGURATION";
|
|
58
|
+
readonly UNKNOWN_OPERATION: "UNKNOWN_OPERATION";
|
|
59
|
+
readonly TOO_MANY_REQUESTS: "TOO_MANY_REQUESTS";
|
|
60
|
+
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
61
|
+
readonly TIMEOUT_ERROR: "TIMEOUT_ERROR";
|
|
62
|
+
};
|
|
63
|
+
type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
|
|
64
|
+
type ErrorSeverity = "info" | "warning" | "error" | "critical";
|
|
65
|
+
declare const ERROR_SEVERITY_MAP: Record<ErrorCode, ErrorSeverity>;
|
|
66
|
+
interface ParsedError {
|
|
67
|
+
code: ErrorCode;
|
|
68
|
+
message: string;
|
|
69
|
+
severity: ErrorSeverity;
|
|
70
|
+
field?: string;
|
|
71
|
+
details?: Record<string, unknown>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Parse a Crudify API response and extract standardized error information
|
|
75
|
+
*/
|
|
76
|
+
declare function parseApiError(response: unknown): ParsedError[];
|
|
77
|
+
/**
|
|
78
|
+
* Parse transaction response errors
|
|
79
|
+
*/
|
|
80
|
+
declare function parseTransactionError(response: unknown): ParsedError[];
|
|
81
|
+
/**
|
|
82
|
+
* Get a human-readable error message for an error code
|
|
83
|
+
*/
|
|
84
|
+
declare function getErrorMessage(code: ErrorCode): string;
|
|
85
|
+
/**
|
|
86
|
+
* Handle JavaScript/Network errors and convert to ParsedError
|
|
87
|
+
*/
|
|
88
|
+
declare function parseJavaScriptError(error: unknown): ParsedError;
|
|
89
|
+
/**
|
|
90
|
+
* Universal error handler that can process any type of error from Crudify APIs
|
|
91
|
+
*/
|
|
92
|
+
declare function handleCrudifyError(error: unknown): ParsedError[];
|
|
93
|
+
|
|
94
|
+
interface ErrorTranslationConfig {
|
|
95
|
+
/** Función de traducción de i18next */
|
|
96
|
+
translateFn: (key: string) => string;
|
|
97
|
+
/** Idioma actual (opcional, para logging) */
|
|
98
|
+
currentLanguage?: string;
|
|
99
|
+
/** Habilitar logs de debug */
|
|
100
|
+
enableDebug?: boolean;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Traduce un código de error usando jerarquía de fallbacks
|
|
104
|
+
*/
|
|
105
|
+
declare function translateErrorCode(errorCode: string, config: ErrorTranslationConfig): string;
|
|
106
|
+
/**
|
|
107
|
+
* Traduce múltiples códigos de error
|
|
108
|
+
*/
|
|
109
|
+
declare function translateErrorCodes(errorCodes: string[], config: ErrorTranslationConfig): string[];
|
|
110
|
+
/**
|
|
111
|
+
* Traduce un error completo (código + mensaje personalizado)
|
|
112
|
+
*/
|
|
113
|
+
declare function translateError(error: {
|
|
114
|
+
code: string;
|
|
115
|
+
message?: string;
|
|
116
|
+
field?: string;
|
|
117
|
+
}, config: ErrorTranslationConfig): string;
|
|
118
|
+
/**
|
|
119
|
+
* Hook para usar en componentes React con i18next
|
|
120
|
+
*/
|
|
121
|
+
declare function createErrorTranslator(translateFn: (key: string) => string, options?: {
|
|
122
|
+
currentLanguage?: string;
|
|
123
|
+
enableDebug?: boolean;
|
|
124
|
+
}): {
|
|
125
|
+
translateErrorCode: (code: string) => string;
|
|
126
|
+
translateErrorCodes: (codes: string[]) => string[];
|
|
127
|
+
translateError: (error: {
|
|
128
|
+
code: string;
|
|
129
|
+
message?: string;
|
|
130
|
+
field?: string;
|
|
131
|
+
}) => string;
|
|
132
|
+
translateApiError: (apiResponse: {
|
|
133
|
+
data?: {
|
|
134
|
+
response?: {
|
|
135
|
+
status?: string;
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
status?: string;
|
|
139
|
+
code?: string;
|
|
140
|
+
} | null | undefined) => string;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export { ERROR_CODES as E, type ParsedError as P, getCookie as a, secureLocalStorage as b, parseTransactionError as c, decodeJwtSafely as d, parseJavaScriptError as e, getErrorMessage as f, getCurrentUserEmail as g, handleCrudifyError as h, isTokenExpired as i, ERROR_SEVERITY_MAP as j, translateErrorCodes as k, translateError as l, createErrorTranslator as m, type ErrorCode as n, type ErrorSeverity as o, parseApiError as p, type ErrorTranslationConfig as q, secureSessionStorage as s, translateErrorCode as t };
|
package/dist/hooks.d.mts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { F as FileItem, v as FileStatus, d as SessionState, 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, i as useUserData, q as useUserProfile } from './index-Y9tTsinC.mjs';
|
|
2
|
+
export { A as AutoGenerateConfig, d as UseAutoGenerateOptions, U as UseAutoGenerateReturn, c as useAutoGenerate } from './GlobalNotificationProvider-Zq18OkpI.mjs';
|
|
3
|
+
import './api-B4uXiHF0.mjs';
|
|
4
|
+
import 'react/jsx-runtime';
|
|
5
|
+
import 'react';
|
|
6
|
+
import '@nocios/crudify-sdk';
|
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { F as FileItem, v as FileStatus, d as SessionState, 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, i as useUserData, q as useUserProfile } from './index-BUKX3duW.js';
|
|
2
|
+
export { A as AutoGenerateConfig, d as UseAutoGenerateOptions, U as UseAutoGenerateReturn, c as useAutoGenerate } from './GlobalNotificationProvider-Zq18OkpI.js';
|
|
3
|
+
import './api-B4uXiHF0.js';
|
|
4
|
+
import 'react/jsx-runtime';
|
|
5
|
+
import 'react';
|
|
6
|
+
import '@nocios/crudify-sdk';
|
package/dist/hooks.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk2XOTIEKSjs = require('./chunk-2XOTIEKS.js');var _chunkCHDM7KGHjs = require('./chunk-CHDM7KGH.js');require('./chunk-MFYHD6S5.js');exports.useAuth = _chunk2XOTIEKSjs.b; exports.useAutoGenerate = _chunkCHDM7KGHjs.o; exports.useCrudifyWithNotifications = _chunk2XOTIEKSjs.d; exports.useData = _chunk2XOTIEKSjs.c; exports.useFileUpload = _chunkCHDM7KGHjs.r; exports.useSession = _chunkCHDM7KGHjs.e; exports.useUserData = _chunk2XOTIEKSjs.a; exports.useUserProfile = _chunkCHDM7KGHjs.n;
|
package/dist/hooks.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as s,b as p,c as u,d as a}from"./chunk-U4RS66TB.mjs";import{e,n as t,o,r}from"./chunk-NBQH6QOU.mjs";import"./chunk-MGJZTOEM.mjs";export{p as useAuth,o as useAutoGenerate,a as useCrudifyWithNotifications,u as useData,r as useFileUpload,e as useSession,s as useUserData,t as useUserProfile};
|