@nocios/crudify-components 2.0.44 → 2.0.60

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.
Files changed (76) hide show
  1. package/.github/workflows/ci.yml +70 -0
  2. package/.husky/pre-commit +26 -0
  3. package/.husky/pre-push +30 -0
  4. package/.prettierignore +18 -0
  5. package/.prettierrc +9 -0
  6. package/.scannerwork/.sonar_lock +0 -0
  7. package/.scannerwork/report-task.txt +6 -0
  8. package/README.md +44 -36
  9. package/README_DEPTH.md +148 -141
  10. package/coverage/coverage-final.json +83 -83
  11. package/coverage/index.html +175 -175
  12. package/coverage/lcov-report/base.css +224 -0
  13. package/coverage/lcov-report/block-navigation.js +87 -0
  14. package/coverage/lcov-report/favicon.png +0 -0
  15. package/coverage/lcov-report/index.html +686 -0
  16. package/coverage/lcov-report/prettify.css +1 -0
  17. package/coverage/lcov-report/prettify.js +2 -0
  18. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  19. package/coverage/lcov-report/sorter.js +210 -0
  20. package/coverage/lcov.info +22388 -0
  21. package/dist/{CrudiaMarkdownField-CXAuu-v2.d.ts → CrudiaMarkdownField-CkiBwG-U.d.ts} +8 -8
  22. package/dist/{CrudiaMarkdownField-TNyMLb-h.d.mts → CrudiaMarkdownField-D-DqiXMQ.d.mts} +8 -8
  23. package/dist/{GlobalNotificationProvider-Zq18OkpI.d.ts → GlobalNotificationProvider-CdwdNv_8.d.mts} +4 -4
  24. package/dist/{GlobalNotificationProvider-Zq18OkpI.d.mts → GlobalNotificationProvider-CdwdNv_8.d.ts} +4 -4
  25. package/dist/chunk-2WAUZ6KI.js +1 -0
  26. package/dist/chunk-3IGZNZCT.mjs +1 -0
  27. package/dist/chunk-43L2PP77.mjs +1 -0
  28. package/dist/chunk-6VS5OT3A.mjs +1 -0
  29. package/dist/chunk-BWJTTMKS.js +1 -0
  30. package/dist/chunk-EMPPCCVU.js +1 -0
  31. package/dist/chunk-J43UPGBE.js +1 -0
  32. package/dist/chunk-K6ZRXOJ7.mjs +1 -0
  33. package/dist/chunk-RYQQZTEP.js +1 -0
  34. package/dist/chunk-VTMSOK4V.mjs +1 -0
  35. package/dist/components.d.mts +3 -3
  36. package/dist/components.d.ts +3 -3
  37. package/dist/components.js +1 -1
  38. package/dist/components.mjs +1 -1
  39. package/dist/{errorTranslation-D-Y7uNN_.d.mts → errorTranslation-BcX8AaK7.d.mts} +5 -5
  40. package/dist/{errorTranslation-DDlAXpMl.d.ts → errorTranslation-CF-5JClP.d.ts} +5 -5
  41. package/dist/hooks.d.mts +3 -3
  42. package/dist/hooks.d.ts +3 -3
  43. package/dist/hooks.js +1 -1
  44. package/dist/hooks.mjs +1 -1
  45. package/dist/{index-U--xRr8A.d.mts → index-D06kTP0C.d.mts} +18 -18
  46. package/dist/{index-dXVRVcEB.d.ts → index-DEDnmsdO.d.ts} +18 -18
  47. package/dist/index.d.mts +361 -361
  48. package/dist/index.d.ts +361 -361
  49. package/dist/index.js +2 -2
  50. package/dist/index.mjs +2 -2
  51. package/dist/{tenantConfig-DqJqQkoR.d.mts → tenantConfig-CYnS9TPV.d.mts} +14 -8
  52. package/dist/{tenantConfig-DqJqQkoR.d.ts → tenantConfig-CYnS9TPV.d.ts} +14 -8
  53. package/dist/utils.d.mts +3 -3
  54. package/dist/utils.d.ts +3 -3
  55. package/dist/utils.js +1 -1
  56. package/dist/utils.mjs +1 -1
  57. package/eslint.config.mjs +140 -0
  58. package/package.json +32 -3
  59. package/scripts/bump-version.cjs +23 -0
  60. package/sonar-project.properties +23 -0
  61. package/tests/helpers/testUtils.tsx +89 -0
  62. package/tests/hooks/useSession/testUtils.tsx +212 -0
  63. package/tests/setup.ts +139 -0
  64. package/tests/vitest.d.ts +1 -0
  65. package/vitest.config.ts +20 -9
  66. package/.github/workflows/test.yml +0 -59
  67. package/dist/chunk-2IOB6HHT.js +0 -1
  68. package/dist/chunk-2WHCDP7V.mjs +0 -1
  69. package/dist/chunk-37WOWEJG.js +0 -1
  70. package/dist/chunk-44VU4TSP.mjs +0 -1
  71. package/dist/chunk-4LMFQECS.js +0 -1
  72. package/dist/chunk-BXFEQ6KP.js +0 -1
  73. package/dist/chunk-MFQKGZI4.js +0 -1
  74. package/dist/chunk-NJERBWND.mjs +0 -1
  75. package/dist/chunk-WMLIOPUC.mjs +0 -1
  76. package/dist/chunk-XMEZUDF6.mjs +0 -1
@@ -0,0 +1,70 @@
1
+ name: Test & Quality Check
2
+
3
+ on:
4
+ push:
5
+ branches: [main, stg, prod]
6
+ pull_request:
7
+ branches: [main, stg, prod]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ timeout-minutes: 15
13
+
14
+ steps:
15
+ - uses: actions/checkout@v4.2.2
16
+
17
+ - name: Use Node.js 24.12.0
18
+ uses: actions/setup-node@v4.1.0
19
+ with:
20
+ node-version: '24.12.0'
21
+
22
+ - name: Setup pnpm
23
+ uses: pnpm/action-setup@v4.0.0
24
+ with:
25
+ version: 10.28.2
26
+
27
+ - name: Get pnpm store directory
28
+ id: pnpm-cache
29
+ shell: bash
30
+ run: |
31
+ echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
32
+
33
+ - name: Setup pnpm cache
34
+ uses: actions/cache@v4.2.0
35
+ with:
36
+ path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
37
+ key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
38
+ restore-keys: |
39
+ ${{ runner.os }}-pnpm-store-
40
+
41
+ - name: Install dependencies
42
+ run: pnpm install --frozen-lockfile
43
+
44
+ - name: Run linter
45
+ run: pnpm run lint --if-present
46
+ continue-on-error: true
47
+
48
+ - name: Run type check
49
+ run: pnpm run typecheck --if-present
50
+ continue-on-error: true
51
+
52
+ - name: Run tests with coverage
53
+ run: pnpm test -- --run
54
+ timeout-minutes: 5
55
+
56
+ - name: Upload coverage to Codecov
57
+ if: success()
58
+ uses: codecov/codecov-action@v5.1.2
59
+ with:
60
+ files: ./coverage/coverage-final.json
61
+ flags: unittests
62
+ name: codecov-umbrella
63
+ continue-on-error: true
64
+
65
+ - name: Build package
66
+ run: pnpm run build
67
+
68
+ - name: Check bundle size
69
+ run: pnpm run build:analyze --if-present
70
+ continue-on-error: true
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env sh
2
+
3
+ # Cargar variables de entorno (archivo simple, sin comandos)
4
+ . ~/.zshenv 2>/dev/null
5
+
6
+ echo "Running pre-commit checks (fast)..."
7
+
8
+ # 0. Format staged files with Prettier
9
+ echo "\n[0/4] Formatting staged files..."
10
+ pnpm exec lint-staged || exit 1
11
+
12
+ # 1. Auto-increment version
13
+ echo "\n[1/4] Bumping version..."
14
+ node scripts/bump-version.cjs || exit 1
15
+ git add package.json
16
+
17
+ # 2. TypeCheck (mas rapido, detecta errores de tipos)
18
+ echo "\n[2/4] Type checking..."
19
+ pnpm run typecheck || exit 1
20
+
21
+ # 3. Lint (rapido, detecta problemas de codigo)
22
+ echo "\n[3/4] Linting..."
23
+ pnpm run lint || exit 1
24
+
25
+ echo "\n✅ Pre-commit checks passed!"
26
+ echo "Note: Tests, build and sonar will run on pre-push"
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env sh
2
+
3
+ # Cargar variables de entorno (archivo simple, sin comandos)
4
+ . ~/.zshenv 2>/dev/null
5
+
6
+ echo "Running pre-push checks (comprehensive)..."
7
+
8
+ # 1. TypeCheck
9
+ echo "\n[1/5] Type checking..."
10
+ pnpm run typecheck || exit 1
11
+
12
+ # 2. Lint
13
+ echo "\n[2/5] Linting..."
14
+ pnpm run lint || exit 1
15
+
16
+ # 3. Tests con coverage
17
+ echo "\n[3/5] Running tests..."
18
+ pnpm run test:coverage || exit 1
19
+
20
+ # 4. Build (valida que el bundle se genera)
21
+ echo "\n[4/5] Building..."
22
+ pnpm run build || exit 1
23
+
24
+ echo "\n✅ All critical checks passed!"
25
+
26
+ # 5. Sonar (no bloqueante - si falla, el push continua)
27
+ echo "\n[5/5] Running sonar analysis (non-blocking)..."
28
+ pnpm run sonar || echo "⚠️ Sonar analysis failed, but push will continue"
29
+
30
+ echo "\n🚀 Ready to push!"
@@ -0,0 +1,18 @@
1
+ # Dependencies
2
+ node_modules
3
+ pnpm-lock.yaml
4
+
5
+ # Build outputs
6
+ dist
7
+ coverage
8
+ .scannerwork
9
+
10
+ # Logs
11
+ *.log
12
+ npm-debug.log*
13
+ pnpm-debug.log*
14
+
15
+ # Misc
16
+ .DS_Store
17
+ .env
18
+ .env.*
package/.prettierrc ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "printWidth": 120,
3
+ "tabWidth": 2,
4
+ "useTabs": false,
5
+ "semi": true,
6
+ "singleQuote": true,
7
+ "trailingComma": "es5",
8
+ "endOfLine": "lf"
9
+ }
File without changes
@@ -0,0 +1,6 @@
1
+ projectKey=nocios_crudify-components
2
+ serverUrl=http://localhost:9000
3
+ serverVersion=26.1.0.118079
4
+ dashboardUrl=http://localhost:9000/dashboard?id=nocios_crudify-components
5
+ ceTaskId=dd307102-0399-458e-9b8e-3816161c5f79
6
+ ceTaskUrl=http://localhost:9000/api/ce/task?id=dd307102-0399-458e-9b8e-3816161c5f79
package/README.md CHANGED
@@ -75,18 +75,18 @@ VITE_TEST_LOGIN_ACTIONS=createUser,forgotPassword
75
75
  #### 2. Configurar Providers
76
76
 
77
77
  ```tsx
78
- import { SessionProvider, crudify } from "@nocios/crudify-components";
78
+ import { SessionProvider, crudify } from '@nocios/crudify-components';
79
79
 
80
80
  function App() {
81
81
  useEffect(() => {
82
82
  // Inicializar crudify (opcional)
83
83
  const initCrudify = async () => {
84
84
  const publicApiKey = import.meta.env.VITE_TEST_PUBLIC_API_KEY;
85
- const environment = import.meta.env.VITE_TEST_ENV || "dev";
85
+ const environment = import.meta.env.VITE_TEST_ENV || 'dev';
86
86
 
87
87
  if (publicApiKey) {
88
88
  crudify.config(environment);
89
- await crudify.init(publicApiKey, "debug");
89
+ await crudify.init(publicApiKey, 'debug');
90
90
  }
91
91
  };
92
92
 
@@ -97,12 +97,12 @@ function App() {
97
97
  <SessionProvider
98
98
  options={{
99
99
  autoRestore: true,
100
- enableLogging: process.env.NODE_ENV === "development",
100
+ enableLogging: process.env.NODE_ENV === 'development',
101
101
  }}
102
102
  config={{
103
103
  publicApiKey: import.meta.env.VITE_TEST_PUBLIC_API_KEY,
104
104
  env: import.meta.env.VITE_TEST_ENV,
105
- loginActions: import.meta.env.VITE_TEST_LOGIN_ACTIONS?.split(","),
105
+ loginActions: import.meta.env.VITE_TEST_LOGIN_ACTIONS?.split(','),
106
106
  }}
107
107
  >
108
108
  <YourApp />
@@ -114,17 +114,17 @@ function App() {
114
114
  #### 3. Usar CrudifyLogin con configuración automática
115
115
 
116
116
  ```tsx
117
- import { CrudifyLogin } from "@nocios/crudify-components";
117
+ import { CrudifyLogin } from '@nocios/crudify-components';
118
118
 
119
119
  function LoginPage() {
120
120
  return (
121
121
  <CrudifyLogin
122
122
  onLoginSuccess={(userData) => {
123
- console.log("Login exitoso:", userData);
123
+ console.log('Login exitoso:', userData);
124
124
  // Navegar al dashboard
125
125
  }}
126
126
  onError={(error) => {
127
- console.error("Error en login:", error);
127
+ console.error('Error en login:', error);
128
128
  }}
129
129
  />
130
130
  );
@@ -145,8 +145,8 @@ La librería las detectará automáticamente:
145
145
  // En producción, la configuración se lee de cookies automáticamente
146
146
  <SessionProvider
147
147
  config={{
148
- appName: "Mi App",
149
- colors: { primaryColor: "#1976d2" },
148
+ appName: 'Mi App',
149
+ colors: { primaryColor: '#1976d2' },
150
150
  // publicApiKey, env y loginActions se leen de cookies automáticamente
151
151
  }}
152
152
  >
@@ -159,13 +159,13 @@ La librería las detectará automáticamente:
159
159
  ### useAuth - Autenticación
160
160
 
161
161
  ```tsx
162
- import { useAuth } from "@nocios/crudify-components";
162
+ import { useAuth } from '@nocios/crudify-components';
163
163
 
164
164
  function LoginComponent() {
165
165
  const { login, logout, isAuthenticated, isLoading } = useAuth();
166
166
 
167
167
  const handleLogin = async () => {
168
- const result = await login("user@example.com", "password");
168
+ const result = await login('user@example.com', 'password');
169
169
  };
170
170
 
171
171
  return isAuthenticated ? (
@@ -181,7 +181,7 @@ function LoginComponent() {
181
181
  ### useUserData - Datos del Usuario
182
182
 
183
183
  ```tsx
184
- import { useUserData } from "@nocios/crudify-components";
184
+ import { useUserData } from '@nocios/crudify-components';
185
185
 
186
186
  function UserProfile() {
187
187
  const { userData, sessionData, isLoading } = useUserData();
@@ -201,17 +201,17 @@ function UserProfile() {
201
201
  ### useData - Operaciones CRUD
202
202
 
203
203
  ```tsx
204
- import { useData } from "@nocios/crudify-components";
204
+ import { useData } from '@nocios/crudify-components';
205
205
 
206
206
  function ProductManager() {
207
207
  const { create, read, update, remove } = useData();
208
208
 
209
209
  const createProduct = async () => {
210
- await create("products", { name: "Nuevo Producto", price: 99.99 });
210
+ await create('products', { name: 'Nuevo Producto', price: 99.99 });
211
211
  };
212
212
 
213
213
  const getProducts = async () => {
214
- const products = await read("products", { limit: 10 });
214
+ const products = await read('products', { limit: 10 });
215
215
  };
216
216
 
217
217
  return <button onClick={createProduct}>Crear Producto</button>;
@@ -223,20 +223,20 @@ function ProductManager() {
223
223
  ### CrudifyLogin - Login Completo
224
224
 
225
225
  ```tsx
226
- import { CrudifyLogin, SessionProvider } from "@nocios/crudify-components";
226
+ import { CrudifyLogin, SessionProvider } from '@nocios/crudify-components';
227
227
 
228
228
  function AuthPage() {
229
229
  return (
230
230
  <SessionProvider
231
231
  config={{
232
- appName: "Mi App",
233
- logo: "/logo.png",
234
- colors: { primaryColor: "#1976d2" },
232
+ appName: 'Mi App',
233
+ logo: '/logo.png',
234
+ colors: { primaryColor: '#1976d2' },
235
235
  }}
236
236
  >
237
237
  <CrudifyLogin
238
238
  onLoginSuccess={(userData) => {
239
- console.log("Login exitoso:", userData);
239
+ console.log('Login exitoso:', userData);
240
240
  }}
241
241
  language="es"
242
242
  />
@@ -248,7 +248,7 @@ function AuthPage() {
248
248
  ### ProtectedRoute - Protección de Rutas
249
249
 
250
250
  ```tsx
251
- import { ProtectedRoute } from "@nocios/crudify-components";
251
+ import { ProtectedRoute } from '@nocios/crudify-components';
252
252
 
253
253
  function App() {
254
254
  return (
@@ -262,13 +262,21 @@ function App() {
262
262
  ### Policies - Gestión de Políticas Públicas
263
263
 
264
264
  ```tsx
265
- import { Policies, POLICY_ACTIONS, PolicyAction } from "@nocios/crudify-components";
265
+ import { Policies, POLICY_ACTIONS, PolicyAction } from '@nocios/crudify-components';
266
266
 
267
267
  function ModuleConfiguration() {
268
268
  const [policies, setPolicies] = useState([]);
269
- const availableFields = ["name", "email", "description", "status"];
269
+ const availableFields = ['name', 'email', 'description', 'status'];
270
270
 
271
- return <Policies policies={policies} onChange={setPolicies} availableFields={availableFields} errors={null} isSubmitting={false} />;
271
+ return (
272
+ <Policies
273
+ policies={policies}
274
+ onChange={setPolicies}
275
+ availableFields={availableFields}
276
+ errors={null}
277
+ isSubmitting={false}
278
+ />
279
+ );
272
280
  }
273
281
  ```
274
282
 
@@ -277,11 +285,11 @@ function ModuleConfiguration() {
277
285
  Re-exporta completamente `@nocios/crudify-sdk`:
278
286
 
279
287
  ```tsx
280
- import { crudify } from "@nocios/crudify-components";
288
+ import { crudify } from '@nocios/crudify-components';
281
289
 
282
290
  // Usar directamente la API de crudify
283
- const result = await crudify.create("users", userData);
284
- const users = await crudify.read("users");
291
+ const result = await crudify.create('users', userData);
292
+ const users = await crudify.read('users');
285
293
  ```
286
294
 
287
295
  ## 🛠️ Utilidades
@@ -289,7 +297,7 @@ const users = await crudify.read("users");
289
297
  ### JWT Utils
290
298
 
291
299
  ```tsx
292
- import { decodeJwtSafely, getCurrentUserEmail } from "@nocios/crudify-components";
300
+ import { decodeJwtSafely, getCurrentUserEmail } from '@nocios/crudify-components';
293
301
 
294
302
  const payload = decodeJwtSafely(token);
295
303
  const email = getCurrentUserEmail();
@@ -298,7 +306,7 @@ const email = getCurrentUserEmail();
298
306
  ### Error Handler
299
307
 
300
308
  ```tsx
301
- import { handleCrudifyError, getErrorMessage } from "@nocios/crudify-components";
309
+ import { handleCrudifyError, getErrorMessage } from '@nocios/crudify-components';
302
310
 
303
311
  try {
304
312
  // operación
@@ -311,9 +319,9 @@ try {
311
319
  ## 🚀 Ejemplo Completo
312
320
 
313
321
  ```tsx
314
- import React from "react";
315
- import { BrowserRouter, Routes, Route } from "react-router-dom";
316
- import { SessionProvider, ProtectedRoute, CrudifyLogin, useSessionContext } from "@nocios/crudify-components";
322
+ import React from 'react';
323
+ import { BrowserRouter, Routes, Route } from 'react-router-dom';
324
+ import { SessionProvider, ProtectedRoute, CrudifyLogin, useSessionContext } from '@nocios/crudify-components';
317
325
 
318
326
  function Dashboard() {
319
327
  const { sessionData, logout } = useSessionContext();
@@ -329,8 +337,8 @@ function Dashboard() {
329
337
 
330
338
  function LoginPage() {
331
339
  return (
332
- <div style={{ maxWidth: "400px", margin: "0 auto" }}>
333
- <CrudifyLogin onLoginSuccess={(userData) => console.log("Login:", userData)} />
340
+ <div style={{ maxWidth: '400px', margin: '0 auto' }}>
341
+ <CrudifyLogin onLoginSuccess={(userData) => console.log('Login:', userData)} />
334
342
  </div>
335
343
  );
336
344
  }
@@ -361,7 +369,7 @@ function App() {
361
369
  Tipos completos incluidos:
362
370
 
363
371
  ```tsx
364
- import type { CrudifyLoginProps, UseAuthReturn, UserProfile, TokenData } from "@nocios/crudify-components";
372
+ import type { CrudifyLoginProps, UseAuthReturn, UserProfile, TokenData } from '@nocios/crudify-components';
365
373
  ```
366
374
 
367
375
  ## 🌐 Internacionalización