@veloxts/router 0.8.1 → 0.8.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @veloxts/router
2
2
 
3
+ ## 0.8.3
4
+
5
+ ### Patch Changes
6
+
7
+ - bump dependencies across packages (April 2026)
8
+ - Updated dependencies
9
+ - @veloxts/core@0.8.3
10
+ - @veloxts/validation@0.8.3
11
+
12
+ ## 0.8.2
13
+
14
+ ### Patch Changes
15
+
16
+ - merge URL params into POST input for flat .rest() paths
17
+ - Updated dependencies
18
+ - @veloxts/core@0.8.2
19
+ - @veloxts/validation@0.8.2
20
+
3
21
  ## 0.8.1
4
22
 
5
23
  ### Patch Changes
@@ -453,6 +471,7 @@
453
471
  - ### feat(auth): Unified Adapter-Only Architecture
454
472
 
455
473
  **New Features:**
474
+
456
475
  - Add `JwtAdapter` implementing the `AuthAdapter` interface for unified JWT authentication
457
476
  - Add `jwtAuth()` convenience function for direct adapter usage with optional built-in routes (`/api/auth/refresh`, `/api/auth/logout`)
458
477
  - Add `AuthContext` discriminated union (`NativeAuthContext | AdapterAuthContext`) for type-safe auth mode handling
@@ -460,20 +479,24 @@
460
479
  - Add shared decoration utilities (`decorateAuth`, `setRequestAuth`, `checkDoubleRegistration`)
461
480
 
462
481
  **Architecture Changes:**
482
+
463
483
  - `authPlugin` now uses `JwtAdapter` internally - all authentication flows through the adapter pattern
464
484
  - Single code path for authentication (no more dual native/adapter modes)
465
485
  - `authContext.authMode` is now always `'adapter'` with `providerId='jwt'` when using `authPlugin`
466
486
 
467
487
  **Breaking Changes:**
488
+
468
489
  - Remove deprecated `LegacySessionConfig` interface (use `sessionMiddleware` instead)
469
490
  - Remove deprecated `session` field from `AuthConfig`
470
491
  - `User` interface no longer has index signature (extend via declaration merging)
471
492
 
472
493
  **Type Safety Improvements:**
494
+
473
495
  - `AuthContext` discriminated union enables exhaustive type narrowing based on `authMode`
474
496
  - Export `NativeAuthContext` and `AdapterAuthContext` types for explicit typing
475
497
 
476
498
  **Migration:**
499
+
477
500
  - Existing `authPlugin` usage remains backward-compatible
478
501
  - If checking `authContext.token`, use `authContext.session` instead (token stored in session for adapter mode)
479
502
 
@@ -492,10 +515,12 @@
492
515
  Addresses 9 user feedback items to improve DX, reduce boilerplate, and eliminate template duplications.
493
516
 
494
517
  ### Phase 1: Validation Helpers (`@veloxts/validation`)
518
+
495
519
  - Add `prismaDecimal()`, `prismaDecimalNullable()`, `prismaDecimalOptional()` for Prisma Decimal → number conversion
496
520
  - Add `dateToIso`, `dateToIsoNullable`, `dateToIsoOptional` aliases for consistency
497
521
 
498
522
  ### Phase 2: Template Deduplication (`@veloxts/auth`)
523
+
499
524
  - Export `createEnhancedTokenStore()` with token revocation and refresh token reuse detection
500
525
  - Export `parseUserRoles()` and `DEFAULT_ALLOWED_ROLES`
501
526
  - Fix memory leak: track pending timeouts for proper cleanup on `destroy()`
@@ -503,17 +528,20 @@
503
528
  - Fix jwtManager singleton pattern in templates
504
529
 
505
530
  ### Phase 3: Router Helpers (`@veloxts/router`)
531
+
506
532
  - Add `createRouter()` returning `{ collections, router }` for DRY setup
507
533
  - Add `toRouter()` for router-only use cases
508
534
  - Update all router templates to use `createRouter()`
509
535
 
510
536
  ### Phase 4: Guard Type Narrowing - Experimental (`@veloxts/auth`, `@veloxts/router`)
537
+
511
538
  - Add `NarrowingGuard` interface with phantom `_narrows` type
512
539
  - Add `authenticatedNarrow` and `hasRoleNarrow()` guards
513
540
  - Add `guardNarrow()` method to `ProcedureBuilder` for context narrowing
514
541
  - Enables `ctx.user` to be non-null after guard passes
515
542
 
516
543
  ### Phase 5: Documentation (`@veloxts/router`)
544
+
517
545
  - Document `.rest()` override patterns
518
546
  - Document `createRouter()` helper usage
519
547
  - Document `guardNarrow()` experimental API
@@ -1438,6 +1466,7 @@
1438
1466
  ### Patch Changes
1439
1467
 
1440
1468
  - Fix Prisma client generation in scaffolder
1469
+
1441
1470
  - Added automatic Prisma client generation after dependency installation in create-velox-app
1442
1471
  - Fixed database template to validate DATABASE_URL environment variable
1443
1472
  - Added alpha release warning to all package READMEs
@@ -218,25 +218,20 @@ function gatherInput(request, route) {
218
218
  const params = isPlainObject(request.params) ? request.params : {};
219
219
  const query = isPlainObject(request.query) ? request.query : {};
220
220
  const body = isPlainObject(request.body) ? request.body : {};
221
- // Check if this is a nested route (has single parent or multiple parents)
222
- const hasParentResource = route.procedure.parentResource !== undefined ||
223
- (route.procedure.parentResources !== undefined && route.procedure.parentResources.length > 0);
224
221
  switch (route.method) {
225
222
  case 'GET':
226
223
  case 'DELETE':
227
224
  // GET/DELETE: params (for :id and all parent params) + query (for filters/pagination/options)
228
225
  return { ...params, ...query };
226
+ case 'POST':
229
227
  case 'PUT':
230
228
  case 'PATCH':
231
- // PUT/PATCH: params (for :id and all parent params) + body (for data)
229
+ // POST/PUT/PATCH: params (for :id and all parent params) + body (for data).
230
+ // POST must merge params unconditionally — flat conventional creates have
231
+ // empty params (no-op spread), but RPC-style .rest() overrides such as
232
+ // POST /retro/phase/:sessionId/next rely on this merge to surface path
233
+ // params to the input schema.
232
234
  return { ...params, ...body };
233
- case 'POST':
234
- // POST: For nested routes, merge params (for all parent IDs) with body
235
- // For flat routes, use body only (no ID in params for creates)
236
- if (hasParentResource) {
237
- return { ...params, ...body };
238
- }
239
- return request.body;
240
235
  default:
241
236
  return request.body;
242
237
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veloxts/router",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "description": "Procedure definitions with tRPC and REST routing for VeloxTS framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -37,17 +37,17 @@
37
37
  }
38
38
  },
39
39
  "dependencies": {
40
- "@trpc/server": "11.12.0",
41
- "fastify": "5.8.2",
42
- "@veloxts/core": "0.8.1",
43
- "@veloxts/validation": "0.8.1"
40
+ "@trpc/server": "11.16.0",
41
+ "fastify": "5.8.5",
42
+ "@veloxts/core": "0.8.3",
43
+ "@veloxts/validation": "0.8.3"
44
44
  },
45
45
  "devDependencies": {
46
- "@vitest/coverage-v8": "4.1.0",
47
- "esbuild": "0.27.4",
46
+ "@vitest/coverage-v8": "4.1.5",
47
+ "esbuild": "0.28.0",
48
48
  "typescript": "5.9.3",
49
- "vite": "7.3.1",
50
- "vitest": "4.1.0",
49
+ "vite": "7.3.2",
50
+ "vitest": "4.1.5",
51
51
  "zod": "4.3.6"
52
52
  },
53
53
  "peerDependencies": {