@nocios/crudify-ui 4.0.8 → 4.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,124 @@
1
+ import { J as JwtPayload } from './api-Djqihi4n.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 encryptionKey;
14
+ private readonly storage;
15
+ constructor(storageType?: "localStorage" | "sessionStorage");
16
+ private generateEncryptionKey;
17
+ setItem(key: string, value: string, expiryMinutes?: number): void;
18
+ getItem(key: string): string | null;
19
+ removeItem(key: string): void;
20
+ setToken(token: string): void;
21
+ getToken(): string | null;
22
+ }
23
+ declare const secureSessionStorage: SecureStorage;
24
+ declare const secureLocalStorage: SecureStorage;
25
+
26
+ declare const ERROR_CODES: {
27
+ readonly INVALID_CREDENTIALS: "INVALID_CREDENTIALS";
28
+ readonly UNAUTHORIZED: "UNAUTHORIZED";
29
+ readonly INVALID_API_KEY: "INVALID_API_KEY";
30
+ readonly USER_NOT_FOUND: "USER_NOT_FOUND";
31
+ readonly USER_NOT_ACTIVE: "USER_NOT_ACTIVE";
32
+ readonly NO_PERMISSION: "NO_PERMISSION";
33
+ readonly ITEM_NOT_FOUND: "ITEM_NOT_FOUND";
34
+ readonly NOT_FOUND: "NOT_FOUND";
35
+ readonly IN_USE: "IN_USE";
36
+ readonly FIELD_ERROR: "FIELD_ERROR";
37
+ readonly BAD_REQUEST: "BAD_REQUEST";
38
+ readonly INVALID_EMAIL: "INVALID_EMAIL";
39
+ readonly INVALID_CODE: "INVALID_CODE";
40
+ readonly INTERNAL_SERVER_ERROR: "INTERNAL_SERVER_ERROR";
41
+ readonly DATABASE_CONNECTION_ERROR: "DATABASE_CONNECTION_ERROR";
42
+ readonly INVALID_CONFIGURATION: "INVALID_CONFIGURATION";
43
+ readonly UNKNOWN_OPERATION: "UNKNOWN_OPERATION";
44
+ readonly TOO_MANY_REQUESTS: "TOO_MANY_REQUESTS";
45
+ readonly NETWORK_ERROR: "NETWORK_ERROR";
46
+ readonly TIMEOUT_ERROR: "TIMEOUT_ERROR";
47
+ };
48
+ type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
49
+ type ErrorSeverity = "info" | "warning" | "error" | "critical";
50
+ declare const ERROR_SEVERITY_MAP: Record<ErrorCode, ErrorSeverity>;
51
+ interface ParsedError {
52
+ code: ErrorCode;
53
+ message: string;
54
+ severity: ErrorSeverity;
55
+ field?: string;
56
+ details?: Record<string, unknown>;
57
+ }
58
+ /**
59
+ * Parse a Crudify API response and extract standardized error information
60
+ */
61
+ declare function parseApiError(response: unknown): ParsedError[];
62
+ /**
63
+ * Parse transaction response errors
64
+ */
65
+ declare function parseTransactionError(response: unknown): ParsedError[];
66
+ /**
67
+ * Get a human-readable error message for an error code
68
+ */
69
+ declare function getErrorMessage(code: ErrorCode): string;
70
+ /**
71
+ * Handle JavaScript/Network errors and convert to ParsedError
72
+ */
73
+ declare function parseJavaScriptError(error: unknown): ParsedError;
74
+ /**
75
+ * Universal error handler that can process any type of error from Crudify APIs
76
+ */
77
+ declare function handleCrudifyError(error: unknown): ParsedError[];
78
+
79
+ /**
80
+ * Utilidad robusta para traducir códigos de error con fallbacks inteligentes
81
+ * Busca en múltiples namespaces y devuelve la traducción más específica disponible
82
+ */
83
+ interface ErrorTranslationConfig {
84
+ /** Función de traducción de i18next */
85
+ translateFn: (key: string) => string;
86
+ /** Idioma actual (opcional, para logging) */
87
+ currentLanguage?: string;
88
+ /** Habilitar logs de debug */
89
+ enableDebug?: boolean;
90
+ }
91
+ /**
92
+ * Traduce un código de error usando jerarquía de fallbacks
93
+ */
94
+ declare function translateErrorCode(errorCode: string, config: ErrorTranslationConfig): string;
95
+ /**
96
+ * Traduce múltiples códigos de error
97
+ */
98
+ declare function translateErrorCodes(errorCodes: string[], config: ErrorTranslationConfig): string[];
99
+ /**
100
+ * Traduce un error completo (código + mensaje personalizado)
101
+ */
102
+ declare function translateError(error: {
103
+ code: string;
104
+ message?: string;
105
+ field?: string;
106
+ }, config: ErrorTranslationConfig): string;
107
+ /**
108
+ * Hook para usar en componentes React con i18next
109
+ */
110
+ declare function createErrorTranslator(translateFn: (key: string) => string, options?: {
111
+ currentLanguage?: string;
112
+ enableDebug?: boolean;
113
+ }): {
114
+ translateErrorCode: (code: string) => string;
115
+ translateErrorCodes: (codes: string[]) => string[];
116
+ translateError: (error: {
117
+ code: string;
118
+ message?: string;
119
+ field?: string;
120
+ }) => string;
121
+ translateApiError: (apiResponse: any) => string;
122
+ };
123
+
124
+ export { ERROR_CODES, ERROR_SEVERITY_MAP, type ErrorCode, type ErrorSeverity, type ErrorTranslationConfig, type ParsedError, createErrorTranslator, decodeJwtSafely, getCookie, getCurrentUserEmail, getErrorMessage, handleCrudifyError, isTokenExpired, parseApiError, parseJavaScriptError, parseTransactionError, secureLocalStorage, secureSessionStorage, translateError, translateErrorCode, translateErrorCodes };
@@ -0,0 +1,124 @@
1
+ import { J as JwtPayload } from './api-Djqihi4n.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 encryptionKey;
14
+ private readonly storage;
15
+ constructor(storageType?: "localStorage" | "sessionStorage");
16
+ private generateEncryptionKey;
17
+ setItem(key: string, value: string, expiryMinutes?: number): void;
18
+ getItem(key: string): string | null;
19
+ removeItem(key: string): void;
20
+ setToken(token: string): void;
21
+ getToken(): string | null;
22
+ }
23
+ declare const secureSessionStorage: SecureStorage;
24
+ declare const secureLocalStorage: SecureStorage;
25
+
26
+ declare const ERROR_CODES: {
27
+ readonly INVALID_CREDENTIALS: "INVALID_CREDENTIALS";
28
+ readonly UNAUTHORIZED: "UNAUTHORIZED";
29
+ readonly INVALID_API_KEY: "INVALID_API_KEY";
30
+ readonly USER_NOT_FOUND: "USER_NOT_FOUND";
31
+ readonly USER_NOT_ACTIVE: "USER_NOT_ACTIVE";
32
+ readonly NO_PERMISSION: "NO_PERMISSION";
33
+ readonly ITEM_NOT_FOUND: "ITEM_NOT_FOUND";
34
+ readonly NOT_FOUND: "NOT_FOUND";
35
+ readonly IN_USE: "IN_USE";
36
+ readonly FIELD_ERROR: "FIELD_ERROR";
37
+ readonly BAD_REQUEST: "BAD_REQUEST";
38
+ readonly INVALID_EMAIL: "INVALID_EMAIL";
39
+ readonly INVALID_CODE: "INVALID_CODE";
40
+ readonly INTERNAL_SERVER_ERROR: "INTERNAL_SERVER_ERROR";
41
+ readonly DATABASE_CONNECTION_ERROR: "DATABASE_CONNECTION_ERROR";
42
+ readonly INVALID_CONFIGURATION: "INVALID_CONFIGURATION";
43
+ readonly UNKNOWN_OPERATION: "UNKNOWN_OPERATION";
44
+ readonly TOO_MANY_REQUESTS: "TOO_MANY_REQUESTS";
45
+ readonly NETWORK_ERROR: "NETWORK_ERROR";
46
+ readonly TIMEOUT_ERROR: "TIMEOUT_ERROR";
47
+ };
48
+ type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
49
+ type ErrorSeverity = "info" | "warning" | "error" | "critical";
50
+ declare const ERROR_SEVERITY_MAP: Record<ErrorCode, ErrorSeverity>;
51
+ interface ParsedError {
52
+ code: ErrorCode;
53
+ message: string;
54
+ severity: ErrorSeverity;
55
+ field?: string;
56
+ details?: Record<string, unknown>;
57
+ }
58
+ /**
59
+ * Parse a Crudify API response and extract standardized error information
60
+ */
61
+ declare function parseApiError(response: unknown): ParsedError[];
62
+ /**
63
+ * Parse transaction response errors
64
+ */
65
+ declare function parseTransactionError(response: unknown): ParsedError[];
66
+ /**
67
+ * Get a human-readable error message for an error code
68
+ */
69
+ declare function getErrorMessage(code: ErrorCode): string;
70
+ /**
71
+ * Handle JavaScript/Network errors and convert to ParsedError
72
+ */
73
+ declare function parseJavaScriptError(error: unknown): ParsedError;
74
+ /**
75
+ * Universal error handler that can process any type of error from Crudify APIs
76
+ */
77
+ declare function handleCrudifyError(error: unknown): ParsedError[];
78
+
79
+ /**
80
+ * Utilidad robusta para traducir códigos de error con fallbacks inteligentes
81
+ * Busca en múltiples namespaces y devuelve la traducción más específica disponible
82
+ */
83
+ interface ErrorTranslationConfig {
84
+ /** Función de traducción de i18next */
85
+ translateFn: (key: string) => string;
86
+ /** Idioma actual (opcional, para logging) */
87
+ currentLanguage?: string;
88
+ /** Habilitar logs de debug */
89
+ enableDebug?: boolean;
90
+ }
91
+ /**
92
+ * Traduce un código de error usando jerarquía de fallbacks
93
+ */
94
+ declare function translateErrorCode(errorCode: string, config: ErrorTranslationConfig): string;
95
+ /**
96
+ * Traduce múltiples códigos de error
97
+ */
98
+ declare function translateErrorCodes(errorCodes: string[], config: ErrorTranslationConfig): string[];
99
+ /**
100
+ * Traduce un error completo (código + mensaje personalizado)
101
+ */
102
+ declare function translateError(error: {
103
+ code: string;
104
+ message?: string;
105
+ field?: string;
106
+ }, config: ErrorTranslationConfig): string;
107
+ /**
108
+ * Hook para usar en componentes React con i18next
109
+ */
110
+ declare function createErrorTranslator(translateFn: (key: string) => string, options?: {
111
+ currentLanguage?: string;
112
+ enableDebug?: boolean;
113
+ }): {
114
+ translateErrorCode: (code: string) => string;
115
+ translateErrorCodes: (codes: string[]) => string[];
116
+ translateError: (error: {
117
+ code: string;
118
+ message?: string;
119
+ field?: string;
120
+ }) => string;
121
+ translateApiError: (apiResponse: any) => string;
122
+ };
123
+
124
+ export { ERROR_CODES, ERROR_SEVERITY_MAP, type ErrorCode, type ErrorSeverity, type ErrorTranslationConfig, type ParsedError, createErrorTranslator, decodeJwtSafely, getCookie, getCurrentUserEmail, getErrorMessage, handleCrudifyError, isTokenExpired, parseApiError, parseJavaScriptError, parseTransactionError, secureLocalStorage, secureSessionStorage, translateError, translateErrorCode, translateErrorCodes };
package/dist/utils.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkNNY4A73Vjs = require('./chunk-NNY4A73V.js');var _chunkYIIUEOXCjs = require('./chunk-YIIUEOXC.js');var _chunk6EBMA4HZjs = require('./chunk-6EBMA4HZ.js');exports.ERROR_CODES = _chunkYIIUEOXCjs.a; exports.ERROR_SEVERITY_MAP = _chunkYIIUEOXCjs.b; exports.createErrorTranslator = _chunk6EBMA4HZjs.e; exports.decodeJwtSafely = _chunk6EBMA4HZjs.f; exports.getCookie = _chunk6EBMA4HZjs.a; exports.getCurrentUserEmail = _chunk6EBMA4HZjs.g; exports.getErrorMessage = _chunkYIIUEOXCjs.e; exports.handleCrudifyError = _chunkYIIUEOXCjs.g; exports.isTokenExpired = _chunk6EBMA4HZjs.h; exports.parseApiError = _chunkYIIUEOXCjs.c; exports.parseJavaScriptError = _chunkYIIUEOXCjs.f; exports.parseTransactionError = _chunkYIIUEOXCjs.d; exports.secureLocalStorage = _chunkNNY4A73Vjs.b; exports.secureSessionStorage = _chunkNNY4A73Vjs.a; exports.translateError = _chunk6EBMA4HZjs.d; exports.translateErrorCode = _chunk6EBMA4HZjs.b; exports.translateErrorCodes = _chunk6EBMA4HZjs.c;
package/dist/utils.mjs ADDED
@@ -0,0 +1 @@
1
+ import{a as C,b as S}from"./chunk-T2CPA46I.mjs";import{a as p,b as i,c as l,d,e as f,f as m,g as x}from"./chunk-BJ6PIVZR.mjs";import{a as r,b as e,c as o,d as a,e as t,f as s,g as E,h as n}from"./chunk-YS3C7YG5.mjs";export{p as ERROR_CODES,i as ERROR_SEVERITY_MAP,t as createErrorTranslator,s as decodeJwtSafely,r as getCookie,E as getCurrentUserEmail,f as getErrorMessage,x as handleCrudifyError,n as isTokenExpired,l as parseApiError,m as parseJavaScriptError,d as parseTransactionError,S as secureLocalStorage,C as secureSessionStorage,a as translateError,e as translateErrorCode,o as translateErrorCodes};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocios/crudify-ui",
3
- "version": "4.0.8",
3
+ "version": "4.0.9",
4
4
  "description": "Biblioteca de componentes UI para Crudify",
5
5
  "author": "Nocios",
6
6
  "license": "MIT",
@@ -12,36 +12,46 @@
12
12
  "types": "./dist/index.d.ts",
13
13
  "import": "./dist/index.mjs",
14
14
  "require": "./dist/index.js"
15
+ },
16
+ "./components": {
17
+ "types": "./dist/components/index.d.ts",
18
+ "import": "./dist/components/index.mjs",
19
+ "require": "./dist/components/index.js"
20
+ },
21
+ "./hooks": {
22
+ "types": "./dist/hooks/index.d.ts",
23
+ "import": "./dist/hooks/index.mjs",
24
+ "require": "./dist/hooks/index.js"
25
+ },
26
+ "./utils": {
27
+ "types": "./dist/utils/index.d.ts",
28
+ "import": "./dist/utils/index.mjs",
29
+ "require": "./dist/utils/index.js"
15
30
  }
16
31
  },
17
32
  "scripts": {
18
33
  "build": "tsup",
34
+ "build:analyze": "tsup --metafile",
19
35
  "start": "vite example",
20
36
  "prepublishOnly": "npm run build"
21
37
  },
22
38
  "dependencies": {
23
- "@emotion/react": "^11.13.1",
24
- "@emotion/styled": "^11.13.0",
25
- "@mui/icons-material": "^7.1.0",
26
- "@mui/material": "^7.1.0",
27
- "@mui/x-data-grid": "^8.5.1",
28
39
  "@nocios/crudify-browser": "^4.0.0",
29
- "@types/dompurify": "^3.0.5",
30
- "@types/uuid": "^10.0.0",
31
40
  "crypto-js": "^4.2.0",
32
41
  "dompurify": "^3.2.7",
33
- "i18next-browser-languagedetector": "^8.1.0",
34
- "i18next-http-backend": "^3.0.2",
35
- "react": "^19.1.0",
36
- "react-dom": "^19.1.0",
37
- "react-i18next": "^15.5.2",
38
42
  "uuid": "^13.0.0"
39
43
  },
40
44
  "peerDependencies": {
45
+ "@emotion/react": "^11.13.1",
46
+ "@emotion/styled": "^11.13.0",
41
47
  "@mui/icons-material": "^7.1.0",
42
48
  "@mui/material": "^7.1.0",
49
+ "@mui/x-data-grid": "^8.5.1",
50
+ "i18next-browser-languagedetector": "^8.1.0",
51
+ "i18next-http-backend": "^3.0.2",
43
52
  "react": "^19.1.0",
44
- "react-dom": "^19.1.0"
53
+ "react-dom": "^19.1.0",
54
+ "react-i18next": "^15.5.2"
45
55
  },
46
56
  "devDependencies": {
47
57
  "@types/crypto-js": "^4.2.2",