@uql/core 3.14.0 → 3.15.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 +38 -2
- package/README.md +6 -0
- package/dist/browser/uql-browser.min.js.map +1 -1
- package/dist/entity/decorator/definition.d.ts +2 -1
- package/dist/entity/decorator/definition.d.ts.map +1 -1
- package/dist/entity/decorator/definition.js +20 -0
- package/dist/entity/decorator/definition.js.map +1 -1
- package/dist/entity/decorator/hook.d.ts +8 -0
- package/dist/entity/decorator/hook.d.ts.map +1 -0
- package/dist/entity/decorator/hook.js +15 -0
- package/dist/entity/decorator/hook.js.map +1 -0
- package/dist/entity/decorator/index.d.ts +2 -1
- package/dist/entity/decorator/index.d.ts.map +1 -1
- package/dist/entity/decorator/index.js +2 -1
- package/dist/entity/decorator/index.js.map +1 -1
- package/dist/mongo/mongodbQuerier.d.ts +2 -2
- package/dist/mongo/mongodbQuerier.d.ts.map +1 -1
- package/dist/mongo/mongodbQuerier.js +4 -4
- package/dist/mongo/mongodbQuerier.js.map +1 -1
- package/dist/querier/abstractQuerier.d.ts +9 -2
- package/dist/querier/abstractQuerier.d.ts.map +1 -1
- package/dist/querier/abstractQuerier.js +63 -10
- package/dist/querier/abstractQuerier.js.map +1 -1
- package/dist/querier/abstractSqlQuerier.d.ts +2 -2
- package/dist/querier/abstractSqlQuerier.d.ts.map +1 -1
- package/dist/querier/abstractSqlQuerier.js +2 -2
- package/dist/querier/abstractSqlQuerier.js.map +1 -1
- package/dist/type/entity.d.ts +12 -0
- package/dist/type/entity.d.ts.map +1 -1
- package/dist/type/querier.d.ts +18 -1
- package/dist/type/querier.d.ts.map +1 -1
- package/dist/util/hook.util.d.ts +15 -0
- package/dist/util/hook.util.d.ts.map +1 -0
- package/dist/util/hook.util.js +20 -0
- package/dist/util/hook.util.js.map +1 -0
- package/dist/util/index.d.ts +1 -0
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +1 -0
- package/dist/util/index.js.map +1 -1
- package/package.json +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
# [3.
|
|
6
|
+
# [3.15.0](https://github.com/rogerpadilla/uql/compare/@uql/core@3.14.1...@uql/core@3.15.0) (2026-03-07)
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
### Features
|
|
10
10
|
|
|
11
|
-
*
|
|
11
|
+
* Introduce entity lifecycle hooks and global querier listeners. ([27055ca](https://github.com/rogerpadilla/uql/commit/27055ca5be5364be0430300590f6d3ed3503bbec))
|
|
12
|
+
* introduce entity lifecycle hooks with `@BeforeInsert`, `@AfterLoad`, `@BeforeUpdate`, `@BeforeDelete`, and `@AfterDelete` decorators. ([2e901bc](https://github.com/rogerpadilla/uql/commit/2e901bc83801a87ae30fdd069ae35a2d49c72328))
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
|
|
@@ -20,6 +21,41 @@ All notable changes to this project will be documented in this file. Please add
|
|
|
20
21
|
|
|
21
22
|
date format is [yyyy-mm-dd]
|
|
22
23
|
|
|
24
|
+
## [3.15.0] - 2026-03-07
|
|
25
|
+
### New Features
|
|
26
|
+
- **Lifecycle Hooks**: Added entity-level lifecycle hook decorators for domain-specific logic. Seven decorators are available: `@BeforeInsert()`, `@AfterInsert()`, `@BeforeUpdate()`, `@AfterUpdate()`, `@BeforeDelete()`, `@AfterDelete()`, and `@AfterLoad()`. Hooks receive a `HookContext` with access to the active `querier` for transactional DB operations.
|
|
27
|
+
```ts
|
|
28
|
+
@Entity()
|
|
29
|
+
class Article {
|
|
30
|
+
@BeforeInsert()
|
|
31
|
+
generateSlug() {
|
|
32
|
+
this.slug = this.title.toLowerCase().replace(/\s+/g, '-');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@AfterLoad()
|
|
36
|
+
maskSensitiveData() {
|
|
37
|
+
this.internalCode = '***';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
- **Global Querier Listeners**: Added `QuerierListener` interface and `listeners` option on `ExtraOptions` for cross-cutting concerns (audit logging, automatic timestamps, cache invalidation). Listeners fire before entity-level hooks.
|
|
42
|
+
```ts
|
|
43
|
+
const pool = new PgQuerierPool(connectionConfig, {
|
|
44
|
+
listeners: [{
|
|
45
|
+
beforeInsert: ({ entity, payloads }) => { /* audit log */ },
|
|
46
|
+
afterUpdate: ({ entity, querier }) => { /* invalidate cache */ },
|
|
47
|
+
}],
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Architecture
|
|
52
|
+
- **Renamed Internal Methods**: `insertMany`/`updateMany` in `AbstractSqlQuerier` and `MongodbQuerier` are now `internalInsertMany`/`internalUpdateMany` (protected). Public `insertMany`/`updateMany` in `AbstractQuerier` wrap them with hook emission.
|
|
53
|
+
- **New Utility**: `runHooks()` in `util/hook.util.ts` — lightweight hook invocation engine using `entity.prototype[method].call(payload, ctx)`.
|
|
54
|
+
- **Hook Inheritance**: Entity hooks are inherited from parent classes (parent hooks execute first).
|
|
55
|
+
|
|
56
|
+
### Test Coverage
|
|
57
|
+
- **22 new tests** (11 for decorators, 11 for `runHooks`). Total: **1602 tests passing**. Coverage: Statements 97.2%, Branches 90.1%, Functions 98.4%, Lines 98.0%.
|
|
58
|
+
|
|
23
59
|
## [3.14.0] - 2026-03-07
|
|
24
60
|
### Type Safety
|
|
25
61
|
- **Map-Only `$select`**: `$select` now only accepts the map form (e.g., `{ id: true, name: true }`), removing the less type-safe array form. Relation selections are now additive in map form.
|
package/README.md
CHANGED
|
@@ -29,6 +29,7 @@ const users = await querier.findMany(User, {
|
|
|
29
29
|
| **Smart SQL Engine** | Optimized sub-queries, placeholders ($1, $2), and minimal SQL generation via `QueryContext`. |
|
|
30
30
|
| **Thread-Safe by Design** | Centralized task queue and `@Serialized()` decorator prevent race conditions. |
|
|
31
31
|
| **[Declarative Transactions](https://uql.app/transactions)** | Standard `@Transactional()` and `@InjectQuerier()` decorators for NestJS/DI. |
|
|
32
|
+
| **[Lifecycle Hooks](https://uql.app/entities/lifecycle-hooks)**| `@BeforeInsert`, `@AfterLoad` and 5 more decorators for validation, timestamps, and computed fields. |
|
|
32
33
|
| **[Modern & Versatile](https://uql.app/entities/virtual-fields)** | **Pure ESM**, high-res timing, [Soft-delete](https://uql.app/entities/soft-delete), and **Vector/JSONB/JSON** support. |
|
|
33
34
|
| **[Database Migrations](https://www.uql.app/migrations)** | Built-in [Entity-First synchronization](https://uql.app/migrations#3-entity-first-synchronization-development) and a robust CLI for version-controlled schema evolution. |
|
|
34
35
|
| **[Logging & Monitoring](https://www.uql.app/logging)** | Professional-grade monitoring with slow-query detection and colored output. |
|
|
@@ -90,6 +91,10 @@ Annotate your classes with decorators. UQL's engine uses this metadata for both
|
|
|
90
91
|
| `@ManyToOne` | Defines a many-to-one relationship. |
|
|
91
92
|
| `@ManyToMany` | Defines a many-to-many relationship. |
|
|
92
93
|
| `@Virtual()` | Defines a read-only field calculated via SQL (see Advanced). |
|
|
94
|
+
| `@BeforeInsert` / `@AfterInsert` | Lifecycle hooks fired around `insert` operations. |
|
|
95
|
+
| `@BeforeUpdate` / `@AfterUpdate` | Lifecycle hooks fired around `update` operations. |
|
|
96
|
+
| `@BeforeDelete` / `@AfterDelete` | Lifecycle hooks fired around `delete` operations. |
|
|
97
|
+
| `@AfterLoad` | Lifecycle hook fired after loading entities from the database. |
|
|
93
98
|
|
|
94
99
|
### Type Abstraction: Logical vs. Physical
|
|
95
100
|
|
|
@@ -531,6 +536,7 @@ Learn more about UQL at [uql.app](https://uql.app) for details on:
|
|
|
531
536
|
|
|
532
537
|
- [Complex Logical Operators](https://uql.app/querying/logical-operators)
|
|
533
538
|
- [Relationship Mapping (1-1, 1-M, M-M)](https://uql.app/querying/relations)
|
|
539
|
+
- [Lifecycle Hooks](https://uql.app/entities/lifecycle-hooks)
|
|
534
540
|
- [Soft Deletes & Auditing](https://uql.app/entities/soft-delete)
|
|
535
541
|
- [Database Migration & Syncing](https://uql.app/migrations)
|
|
536
542
|
|