@veloxts/orm 0.8.3 → 0.9.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/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @veloxts/orm
2
2
 
3
+ ## 0.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - feat(router): add raw() response primitive for redirects, cookies, custom headers and .check() post-middleware authorization primitive
8
+
9
+ ### Patch Changes
10
+
11
+ - ca6ede3: Plugin contract fixes — eliminates three workaround `addHook` blocks freehand projects need to write today.
12
+ - **`@veloxts/orm`**: `ctx.db` is now writable so middleware (e.g. transactional handlers) can swap in a tx client via `Object.assign(ctx, { db: tx })` without redefining the property.
13
+ - **`@veloxts/core`**: registers an empty-JSON-body fallback parser at app construction. POSTs with `Content-Type: application/json` and empty body now reach handlers as `input = {}` instead of being rejected with 400 by Fastify's default parser.
14
+ - **`@veloxts/events`, `@veloxts/cache`, `@veloxts/mail`, `@veloxts/queue`, `@veloxts/storage`**: each plugin now mirrors its `request.<name>` decoration onto the procedure context (`request.context.<name>`), matching the existing auth-plugin pattern. `ctx.events`, `ctx.cache`, `ctx.mail`, `ctx.queue`, `ctx.storage` are now populated automatically — no manual bridging hook required.
15
+
16
+ **Behavior changes to be aware of on upgrade:**
17
+ - `@veloxts/core` now registers an `application/json` content-type parser by default. If you previously called `app.server.addContentTypeParser('application/json', ...)` in user code, you will now hit `FST_ERR_CTP_ALREADY_PRESENT`. Call `app.server.removeContentTypeParser('application/json')` first, then register your own parser.
18
+ - `ctx.db` was previously frozen via `Object.defineProperty({ writable: false })`. Library authors who relied on the strict-mode TypeError on reassignment should switch to defensive copying (`{ ...ctx }`) instead. End-user procedures and middleware are unaffected.
19
+
20
+ - Updated dependencies
21
+ - Updated dependencies [ca6ede3]
22
+ - @veloxts/core@0.9.0
23
+
3
24
  ## 0.8.3
4
25
 
5
26
  ### Patch Changes
@@ -421,7 +442,6 @@
421
442
  - ### feat(auth): Unified Adapter-Only Architecture
422
443
 
423
444
  **New Features:**
424
-
425
445
  - Add `JwtAdapter` implementing the `AuthAdapter` interface for unified JWT authentication
426
446
  - Add `jwtAuth()` convenience function for direct adapter usage with optional built-in routes (`/api/auth/refresh`, `/api/auth/logout`)
427
447
  - Add `AuthContext` discriminated union (`NativeAuthContext | AdapterAuthContext`) for type-safe auth mode handling
@@ -429,24 +449,20 @@
429
449
  - Add shared decoration utilities (`decorateAuth`, `setRequestAuth`, `checkDoubleRegistration`)
430
450
 
431
451
  **Architecture Changes:**
432
-
433
452
  - `authPlugin` now uses `JwtAdapter` internally - all authentication flows through the adapter pattern
434
453
  - Single code path for authentication (no more dual native/adapter modes)
435
454
  - `authContext.authMode` is now always `'adapter'` with `providerId='jwt'` when using `authPlugin`
436
455
 
437
456
  **Breaking Changes:**
438
-
439
457
  - Remove deprecated `LegacySessionConfig` interface (use `sessionMiddleware` instead)
440
458
  - Remove deprecated `session` field from `AuthConfig`
441
459
  - `User` interface no longer has index signature (extend via declaration merging)
442
460
 
443
461
  **Type Safety Improvements:**
444
-
445
462
  - `AuthContext` discriminated union enables exhaustive type narrowing based on `authMode`
446
463
  - Export `NativeAuthContext` and `AdapterAuthContext` types for explicit typing
447
464
 
448
465
  **Migration:**
449
-
450
466
  - Existing `authPlugin` usage remains backward-compatible
451
467
  - If checking `authContext.token`, use `authContext.session` instead (token stored in session for adapter mode)
452
468
 
@@ -464,12 +480,10 @@
464
480
  Addresses 9 user feedback items to improve DX, reduce boilerplate, and eliminate template duplications.
465
481
 
466
482
  ### Phase 1: Validation Helpers (`@veloxts/validation`)
467
-
468
483
  - Add `prismaDecimal()`, `prismaDecimalNullable()`, `prismaDecimalOptional()` for Prisma Decimal → number conversion
469
484
  - Add `dateToIso`, `dateToIsoNullable`, `dateToIsoOptional` aliases for consistency
470
485
 
471
486
  ### Phase 2: Template Deduplication (`@veloxts/auth`)
472
-
473
487
  - Export `createEnhancedTokenStore()` with token revocation and refresh token reuse detection
474
488
  - Export `parseUserRoles()` and `DEFAULT_ALLOWED_ROLES`
475
489
  - Fix memory leak: track pending timeouts for proper cleanup on `destroy()`
@@ -477,20 +491,17 @@
477
491
  - Fix jwtManager singleton pattern in templates
478
492
 
479
493
  ### Phase 3: Router Helpers (`@veloxts/router`)
480
-
481
494
  - Add `createRouter()` returning `{ collections, router }` for DRY setup
482
495
  - Add `toRouter()` for router-only use cases
483
496
  - Update all router templates to use `createRouter()`
484
497
 
485
498
  ### Phase 4: Guard Type Narrowing - Experimental (`@veloxts/auth`, `@veloxts/router`)
486
-
487
499
  - Add `NarrowingGuard` interface with phantom `_narrows` type
488
500
  - Add `authenticatedNarrow` and `hasRoleNarrow()` guards
489
501
  - Add `guardNarrow()` method to `ProcedureBuilder` for context narrowing
490
502
  - Enables `ctx.user` to be non-null after guard passes
491
503
 
492
504
  ### Phase 5: Documentation (`@veloxts/router`)
493
-
494
505
  - Document `.rest()` override patterns
495
506
  - Document `createRouter()` helper usage
496
507
  - Document `guardNarrow()` experimental API
@@ -1315,7 +1326,6 @@
1315
1326
  ### Patch Changes
1316
1327
 
1317
1328
  - Fix Prisma client generation in scaffolder
1318
-
1319
1329
  - Added automatic Prisma client generation after dependency installation in create-velox-app
1320
1330
  - Fixed database template to validate DATABASE_URL environment variable
1321
1331
  - Added alpha release warning to all package READMEs
package/dist/plugin.js CHANGED
@@ -143,13 +143,13 @@ export function databasePlugin(config) {
143
143
  // The context should be created by @veloxts/core's onRequest hook
144
144
  // which runs before this hook (due to plugin registration order)
145
145
  if (request.context) {
146
- // Extend the context with the database client using Object.defineProperty
147
- // for proper property definition without type assertion side effects
146
+ // Writable so middleware (e.g. transactional handlers) and tests
147
+ // can swap in a tx client via Object.assign on ctx.
148
148
  Object.defineProperty(request.context, 'db', {
149
149
  value: config.client,
150
- writable: false,
150
+ writable: true,
151
151
  enumerable: true,
152
- configurable: true, // Allow redefinition for testing
152
+ configurable: true,
153
153
  });
154
154
  }
155
155
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veloxts/orm",
3
- "version": "0.8.3",
3
+ "version": "0.9.0",
4
4
  "description": "Prisma wrapper with enhanced DX for VeloxTS framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -19,7 +19,7 @@
19
19
  "fastify": "5.8.5",
20
20
  "pg": "8.20.0",
21
21
  "pg-format": "1.0.4",
22
- "@veloxts/core": "0.8.3"
22
+ "@veloxts/core": "0.9.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/pg": "8.20.0",