@artenc/nest-orm 2.1.0 → 3.1.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/README.md +43 -2
- package/dist/decorators/binary-uuid-column.js +25 -22
- package/dist/decorators/binary-uuid-column.js.map +1 -1
- package/dist/entities/abstract-orm.entity.d.ts +12 -0
- package/dist/entities/abstract-orm.entity.js +33 -17
- package/dist/entities/abstract-orm.entity.js.map +1 -1
- package/dist/index.d.ts +9 -6
- package/dist/index.js +6 -16
- package/dist/index.js.map +1 -1
- package/dist/lib/constructor.js +1 -2
- package/dist/lib/transaction-context.js +2 -5
- package/dist/lib/transaction-context.js.map +1 -1
- package/dist/lib/utc-data-source.js +13 -7
- package/dist/lib/utc-data-source.js.map +1 -1
- package/dist/orm.module.js +14 -17
- package/dist/orm.module.js.map +1 -1
- package/dist/services/abstract-orm.service.d.ts +4 -4
- package/dist/services/abstract-orm.service.js +20 -10
- package/dist/services/abstract-orm.service.js.map +1 -1
- package/dist/services/transaction.service.js +9 -12
- package/dist/services/transaction.service.js.map +1 -1
- package/dist/utils/generated-column.util.d.ts +1 -1
- package/dist/utils/generated-column.util.js +6 -11
- package/dist/utils/generated-column.util.js.map +1 -1
- package/package.json +35 -46
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Helper library to work with TypeORM in NestJS: a base entity with a transaction-
|
|
|
4
4
|
|
|
5
5
|
## Key features
|
|
6
6
|
|
|
7
|
-
- **Transaction-aware entities** — an entity's `save()` always
|
|
7
|
+
- **Transaction-aware entities** — an entity's `save()` and `remove()` always write through the right connection, whether that's its repository or an active transaction, with no manual bookkeeping.
|
|
8
8
|
- **Generic CRUD service** — get `create`/`find`/`findOne`/`update`/`remove`/... for an entity without hand-writing the same repository boilerplate every time.
|
|
9
9
|
- **Automatic transaction propagation** — wrap a block of work in a transaction and every entity/service call inside it joins that transaction automatically, including nested calls.
|
|
10
10
|
- **Compact UUID storage** — store UUIDs as 16-byte binary columns instead of 36-character strings, with optional auto-generation.
|
|
@@ -17,6 +17,8 @@ npm install @artenc/nest-orm
|
|
|
17
17
|
|
|
18
18
|
`@nestjs/common`, `@nestjs/typeorm`, and `typeorm` are peer dependencies — install them in your app if you haven't already (any NestJS + TypeORM project already has them).
|
|
19
19
|
|
|
20
|
+
It needs NestJS 12, `@nestjs/typeorm` 12 and TypeORM 1.x. The package is ESM only, as NestJS 12 is: a CommonJS application loads it through `require(esm)`, which needs Node.js 20.19+, 22.13+ or 24.11+, as TypeORM 1.x does.
|
|
21
|
+
|
|
20
22
|
## Usage
|
|
21
23
|
|
|
22
24
|
### `OrmModule`
|
|
@@ -98,6 +100,13 @@ user.apply({ name: 'Ada Lovelace', role: 'admin' }) // 'role' is silently ignore
|
|
|
98
100
|
await user.save()
|
|
99
101
|
```
|
|
100
102
|
|
|
103
|
+
An entity removes itself through the same connection as `save()`, an active transaction's included, with `remove()`: softly for an entity with a `@DeleteDateColumn`, setting its delete date on the entity too, and for good otherwise. `hardRemove()` removes it for good either way. A removal for good leaves the entity without its primary key, as TypeORM's does.
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
await note.remove() // note.deletedAt is set, and reads leave it out
|
|
107
|
+
await note.hardRemove() // the row is gone
|
|
108
|
+
```
|
|
109
|
+
|
|
101
110
|
### `BinaryUuidColumn`
|
|
102
111
|
|
|
103
112
|
Stores a UUID as a 16-byte `binary` column instead of a 36-character string — smaller and faster to index — and can optionally generate the value for you on insert.
|
|
@@ -129,7 +138,7 @@ export class User extends AbstractOrmEntity {
|
|
|
129
138
|
|
|
130
139
|
### `AbstractOrmService`
|
|
131
140
|
|
|
132
|
-
`AbstractOrmService(Entity)` returns a class with `create`, `exists`, `find`, `findOne`, `count`, `update`, `remove`, and `createQueryBuilder` already implemented against `Entity`'s repository — extend it instead of hand-writing the same boilerplate for every entity:
|
|
141
|
+
`AbstractOrmService(Entity)` returns a class with `create`, `exists`, `find`, `findOne`, `count`, `update`, `remove`, `hardRemove`, and `createQueryBuilder` already implemented against `Entity`'s repository — extend it instead of hand-writing the same boilerplate for every entity:
|
|
133
142
|
|
|
134
143
|
```ts
|
|
135
144
|
import { Injectable } from '@nestjs/common'
|
|
@@ -149,6 +158,22 @@ await userOrmService.update({ id: user.id }, { name: 'Ada Lovelace' })
|
|
|
149
158
|
await userOrmService.remove({ id: user.id })
|
|
150
159
|
```
|
|
151
160
|
|
|
161
|
+
For an entity with a `@DeleteDateColumn`, `remove()` removes softly: it sets the rows' delete date, and TypeORM leaves them out of reads from then on, joined relations included, unless a read asks for them with `withDeleted: true`. `hardRemove()` removes rows for good either way. A soft removal doesn't run the database's `ON DELETE CASCADE`, as the row stays. An entity removes itself the same way, with its own [`remove()` and `hardRemove()`](#abstractormentity).
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
@Entity('notes')
|
|
165
|
+
export class Note extends AbstractOrmEntity {
|
|
166
|
+
// …
|
|
167
|
+
@DeleteDateColumn()
|
|
168
|
+
deletedAt!: Date | null
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
await noteOrmService.remove({ id }) // sets deletedAt
|
|
172
|
+
await noteOrmService.findOne({ where: { id } }) // null
|
|
173
|
+
await noteOrmService.findOne({ where: { id }, withDeleted: true }) // the note, with deletedAt
|
|
174
|
+
await noteOrmService.hardRemove({ id }) // the row is gone
|
|
175
|
+
```
|
|
176
|
+
|
|
152
177
|
Register the entity's repository the usual way and provide the service:
|
|
153
178
|
|
|
154
179
|
```ts
|
|
@@ -167,6 +192,16 @@ export class UserModule {}
|
|
|
167
192
|
|
|
168
193
|
Every method takes an optional trailing `enforceEntityManager` argument to run against a specific `EntityManager` instead of the entity's default repository — useful outside of `TransactionService` (e.g. a manually managed `QueryRunner`).
|
|
169
194
|
|
|
195
|
+
A `null` or `undefined` in a condition throws, as TypeORM 1.x refuses them in `find`, `findOne`, `count`, `exists`, `update` and `remove`, rather than dropping the condition: `remove({ id: undefined })` fails instead of deleting every row. Match a `NULL` with `IsNull()`:
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
import { IsNull } from 'typeorm'
|
|
199
|
+
|
|
200
|
+
await userOrmService.find({ where: { deletedAt: IsNull() } })
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
A query builder's `where()` isn't checked: `{ deletedAt: null }` there compares with `= NULL`, which matches nothing, so use `IsNull()` there too. TypeORM's `invalidWhereValuesBehavior` option, given to `OrmModule.forRoot*()`, changes how conditions are checked.
|
|
204
|
+
|
|
170
205
|
### `TransactionService`
|
|
171
206
|
|
|
172
207
|
Wraps a block of work in a real database transaction and makes the transaction's `EntityManager` ambiently available (via `AsyncLocalStorage`) to every `AbstractOrmService`/`AbstractOrmEntity` call made inside it — no need to thread an `EntityManager` through every method call by hand:
|
|
@@ -251,6 +286,12 @@ export default new UtcDataSource({
|
|
|
251
286
|
})
|
|
252
287
|
```
|
|
253
288
|
|
|
289
|
+
## Development
|
|
290
|
+
|
|
291
|
+
The tests include ones against a real MySQL, which needs nothing set up beyond Docker: `npm test` runs a throwaway MySQL 8.4 container, in UTC, on port 3307, and removes it afterwards. To keep one running across test runs, start it with `npm run test:mysql:start`, and remove it with `npm run test:mysql:stop`.
|
|
292
|
+
|
|
293
|
+
The settings are in `.env.example`; a `.env` overrides any of them. With `DB_CONTAINER=false`, the tests use the MySQL at `DB_HOST` instead, which must run in UTC; they drop and create its tables.
|
|
294
|
+
|
|
254
295
|
## License
|
|
255
296
|
|
|
256
297
|
MIT
|
|
@@ -1,59 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const typeorm_1 = require("typeorm");
|
|
7
|
-
const uuid_1 = require("uuid");
|
|
8
|
-
const generated_column_util_1 = require("../utils/generated-column.util");
|
|
9
|
-
function BinaryUuidColumn(options) {
|
|
1
|
+
import { randomUUID as randomUUIDv4 } from 'crypto';
|
|
2
|
+
import { Column } from 'typeorm';
|
|
3
|
+
import { v7 as randomUUIDv7 } from 'uuid';
|
|
4
|
+
import { addGeneratedColumn } from '../utils/generated-column.util.js';
|
|
5
|
+
export function BinaryUuidColumn(options) {
|
|
10
6
|
const { generated = false, version = 'v7', ...rest } = options ?? {};
|
|
11
7
|
return (target, propertyKey) => {
|
|
12
8
|
// Always registered (even when generated is false) so that a subclass redeclaring this
|
|
13
9
|
// column without `generated: true` can explicitly opt out of an ancestor's auto-generation,
|
|
14
10
|
// rather than silently inheriting it because the subclass "said nothing" about the property.
|
|
15
|
-
|
|
11
|
+
addGeneratedColumn(target.constructor, {
|
|
16
12
|
propertyKey: String(propertyKey),
|
|
17
13
|
generator: generated
|
|
18
14
|
? () => {
|
|
19
15
|
switch (version) {
|
|
20
16
|
case 'v4':
|
|
21
|
-
return (
|
|
17
|
+
return randomUUIDv4();
|
|
22
18
|
case 'v7':
|
|
23
|
-
return (
|
|
19
|
+
return randomUUIDv7();
|
|
24
20
|
default:
|
|
25
21
|
throw new Error(`Unsupported BinaryUuidColumn version: ${String(version)}`);
|
|
26
22
|
}
|
|
27
23
|
}
|
|
28
24
|
: null,
|
|
29
25
|
});
|
|
30
|
-
|
|
26
|
+
Column({
|
|
31
27
|
...rest,
|
|
32
28
|
type: 'binary',
|
|
33
29
|
length: 16,
|
|
34
|
-
transformer:
|
|
30
|
+
transformer: binaryUuidTransformer,
|
|
35
31
|
})(target, propertyKey);
|
|
36
32
|
};
|
|
37
33
|
}
|
|
38
|
-
|
|
34
|
+
export const binaryUuidTransformer = {
|
|
39
35
|
to(value) {
|
|
40
36
|
if (value == null) {
|
|
41
37
|
return null;
|
|
42
38
|
}
|
|
43
|
-
|
|
44
|
-
if (!/^[0-9a-f]{32}$/.test(compact)) {
|
|
45
|
-
throw new Error(`Invalid UUID: ${value}`);
|
|
46
|
-
}
|
|
47
|
-
return Buffer.from(compact, 'hex');
|
|
39
|
+
return Buffer.from(compactUuid(value), 'hex');
|
|
48
40
|
},
|
|
49
41
|
from(value) {
|
|
50
42
|
if (value == null) {
|
|
51
43
|
return null;
|
|
52
44
|
}
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
// TypeORM also passes it the UUID an insert saved, still a string, as it reads back the values the database
|
|
46
|
+
// filled in, e.g. a CreateDateColumn's
|
|
47
|
+
if (typeof value === 'string') {
|
|
48
|
+
return formatUuid(compactUuid(value));
|
|
49
|
+
}
|
|
50
|
+
return formatUuid(value.toString('hex'));
|
|
55
51
|
},
|
|
56
52
|
};
|
|
53
|
+
function compactUuid(value) {
|
|
54
|
+
const compact = value.toLowerCase().replace(/-/g, '');
|
|
55
|
+
if (!/^[0-9a-f]{32}$/.test(compact)) {
|
|
56
|
+
throw new Error(`Invalid UUID: ${value}`);
|
|
57
|
+
}
|
|
58
|
+
return compact;
|
|
59
|
+
}
|
|
57
60
|
function formatUuid(hex) {
|
|
58
61
|
return [hex.slice(0, 8), hex.slice(8, 12), hex.slice(12, 16), hex.slice(16, 20), hex.slice(20, 32)].join('-');
|
|
59
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binary-uuid-column.js","sourceRoot":"","sources":["../../src/decorators/binary-uuid-column.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"binary-uuid-column.js","sourceRoot":"","sources":["../../src/decorators/binary-uuid-column.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,QAAQ,CAAA;AACnD,OAAO,EAAE,MAAM,EAAmC,MAAM,SAAS,CAAA;AACjE,OAAO,EAAE,EAAE,IAAI,YAAY,EAAE,MAAM,MAAM,CAAA;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAsBtE,MAAM,UAAU,gBAAgB,CAAC,OAA2B;IACxD,MAAM,EAAE,SAAS,GAAG,KAAK,EAAE,OAAO,GAAG,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;IAEpE,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,EAA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AC;CACJ,CAAA;AAED,SAAS,WAAW,CAAC,KAAa;IAC9B,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;IAErD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,iBAAiB,KAAK,EAAE,CAAC,CAAA;IAC7C,CAAC;IAED,OAAO,OAAO,CAAA;AAClB,CAAC;AAED,SAAS,UAAU,CAAC,GAAW;IAC3B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACjH,CAAC"}
|
|
@@ -5,9 +5,21 @@ export declare abstract class AbstractOrmEntity {
|
|
|
5
5
|
setRepository(repository: Repository<this>): void;
|
|
6
6
|
setEntityManager(entityManager: EntityManager): void;
|
|
7
7
|
save(): Promise<this>;
|
|
8
|
+
/**
|
|
9
|
+
* Removes the entity: softly for an entity with a `@DeleteDateColumn`, and for good otherwise
|
|
10
|
+
*/
|
|
11
|
+
remove(): Promise<this>;
|
|
12
|
+
/**
|
|
13
|
+
* Removes the entity for good, also one with a `@DeleteDateColumn`
|
|
14
|
+
*/
|
|
15
|
+
hardRemove(): Promise<this>;
|
|
8
16
|
protected fillable(): (keyof this)[];
|
|
9
17
|
apply(fields: object): void;
|
|
10
18
|
private get repositoryOrEntityManager();
|
|
19
|
+
/**
|
|
20
|
+
* The repository of the entity's class: the one it holds, or the entity manager's
|
|
21
|
+
*/
|
|
22
|
+
private get entityRepository();
|
|
11
23
|
private get contextEntityManager();
|
|
12
24
|
protected generateBinaryUuidColumns(): void;
|
|
13
25
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8,16 +7,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const transaction_context_1 = require("../lib/transaction-context");
|
|
16
|
-
const generated_column_util_1 = require("../utils/generated-column.util");
|
|
10
|
+
import { Exclude } from 'class-transformer';
|
|
11
|
+
import { BeforeInsert, EntityManager, Repository } from 'typeorm';
|
|
12
|
+
import { txStorage } from '../lib/transaction-context.js';
|
|
13
|
+
import { getGeneratedColumns } from '../utils/generated-column.util.js';
|
|
17
14
|
// Blocked unconditionally in apply(), regardless of fillable(), to prevent prototype pollution
|
|
18
15
|
// if a fillable() override ever lists one of these by mistake.
|
|
19
16
|
const UNSAFE_APPLY_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
|
|
20
|
-
class AbstractOrmEntity {
|
|
17
|
+
export class AbstractOrmEntity {
|
|
21
18
|
repository;
|
|
22
19
|
entityManager;
|
|
23
20
|
setRepository(repository) {
|
|
@@ -35,6 +32,19 @@ class AbstractOrmEntity {
|
|
|
35
32
|
save() {
|
|
36
33
|
return this.repositoryOrEntityManager.save(this);
|
|
37
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Removes the entity: softly for an entity with a `@DeleteDateColumn`, and for good otherwise
|
|
37
|
+
*/
|
|
38
|
+
remove() {
|
|
39
|
+
const repository = this.entityRepository;
|
|
40
|
+
return repository.metadata.deleteDateColumn ? repository.softRemove(this) : repository.remove(this);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Removes the entity for good, also one with a `@DeleteDateColumn`
|
|
44
|
+
*/
|
|
45
|
+
hardRemove() {
|
|
46
|
+
return this.entityRepository.remove(this);
|
|
47
|
+
}
|
|
38
48
|
fillable() {
|
|
39
49
|
return [];
|
|
40
50
|
}
|
|
@@ -62,13 +72,20 @@ class AbstractOrmEntity {
|
|
|
62
72
|
}
|
|
63
73
|
throw new Error('No repository or entity manager available');
|
|
64
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* The repository of the entity's class: the one it holds, or the entity manager's
|
|
77
|
+
*/
|
|
78
|
+
get entityRepository() {
|
|
79
|
+
const target = this.repositoryOrEntityManager;
|
|
80
|
+
return 'getRepository' in target ? target.getRepository(this.constructor) : target;
|
|
81
|
+
}
|
|
65
82
|
get contextEntityManager() {
|
|
66
|
-
const store =
|
|
83
|
+
const store = txStorage.getStore();
|
|
67
84
|
if (!store) {
|
|
68
85
|
return undefined;
|
|
69
86
|
}
|
|
70
87
|
if (this.repository) {
|
|
71
|
-
return store.get(this.repository.manager.
|
|
88
|
+
return store.get(this.repository.manager.dataSource);
|
|
72
89
|
}
|
|
73
90
|
// No pinned repository to key the lookup by — e.g. a plain `new Entity()` never
|
|
74
91
|
// routed through AbstractOrmService, or one loaded via a raw EntityManager/Repository
|
|
@@ -84,7 +101,7 @@ class AbstractOrmEntity {
|
|
|
84
101
|
return store.values().next().value;
|
|
85
102
|
}
|
|
86
103
|
generateBinaryUuidColumns() {
|
|
87
|
-
const generatedColumns =
|
|
104
|
+
const generatedColumns = getGeneratedColumns(this.constructor);
|
|
88
105
|
for (const column of generatedColumns) {
|
|
89
106
|
if (!column.generator) {
|
|
90
107
|
continue;
|
|
@@ -97,17 +114,16 @@ class AbstractOrmEntity {
|
|
|
97
114
|
}
|
|
98
115
|
}
|
|
99
116
|
}
|
|
100
|
-
exports.AbstractOrmEntity = AbstractOrmEntity;
|
|
101
117
|
__decorate([
|
|
102
|
-
|
|
103
|
-
__metadata("design:type",
|
|
118
|
+
Exclude(),
|
|
119
|
+
__metadata("design:type", Repository)
|
|
104
120
|
], AbstractOrmEntity.prototype, "repository", void 0);
|
|
105
121
|
__decorate([
|
|
106
|
-
|
|
107
|
-
__metadata("design:type",
|
|
122
|
+
Exclude(),
|
|
123
|
+
__metadata("design:type", EntityManager)
|
|
108
124
|
], AbstractOrmEntity.prototype, "entityManager", void 0);
|
|
109
125
|
__decorate([
|
|
110
|
-
|
|
126
|
+
BeforeInsert(),
|
|
111
127
|
__metadata("design:type", Function),
|
|
112
128
|
__metadata("design:paramtypes", []),
|
|
113
129
|
__metadata("design:returntype", void 0)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract-orm.entity.js","sourceRoot":"","sources":["../../src/entities/abstract-orm.entity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"abstract-orm.entity.js","sourceRoot":"","sources":["../../src/entities/abstract-orm.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEjE,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AAEvE,+FAA+F;AAC/F,+DAA+D;AAC/D,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAA;AAE5E,MAAM,OAAgB,iBAAiB;IAE3B,UAAU,CAAmB;IAE7B,aAAa,CAAgB;IAE9B,aAAa,CAAC,UAA4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AK,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAA;IACtC,CAAC;IAGS,yBAAyB;QAC/B,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,IAAI,CAAC,WAA0B,CAAC,CAAA;QAE7E,KAAK,MAAM,MAAM,IAAI,gBAAgB,EAAE,CAAC;YACpC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;gBACpB,SAAQ;YACZ,CAAC;YACD,MAAM,YAAY,GAAI,IAAgC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;YAC1E,IAAI,YAAY,KAAK,IAAI,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;gBACtD,CAAC;gBAAC,IAAgC,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC,SAAS,EAAE,CAAA;YAC/E,CAAC;QACL,CAAC;IACL,CAAC;CACJ;AAjHW;IADP,OAAO,EAAE;8BACW,UAAU;qDAAM;AAE7B;IADP,OAAO,EAAE;8BACc,aAAa;wDAAA;AAkG3B;IADT,YAAY,EAAE;;;;kEAad"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
export { BinaryUuidColumn,
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
1
|
+
export { BinaryUuidColumn, binaryUuidTransformer } from './decorators/binary-uuid-column.js';
|
|
2
|
+
export type { BinaryUuidOptions, BinaryUuidVersion } from './decorators/binary-uuid-column.js';
|
|
3
|
+
export { AbstractOrmEntity } from './entities/abstract-orm.entity.js';
|
|
4
|
+
export { AbstractOrmService } from './services/abstract-orm.service.js';
|
|
5
|
+
export type { IOrmService } from './services/abstract-orm.service.js';
|
|
6
|
+
export { TransactionService } from './services/transaction.service.js';
|
|
7
|
+
export { UtcDataSource } from './lib/utc-data-source.js';
|
|
8
|
+
export { OrmModule } from './orm.module.js';
|
|
9
|
+
export type { OrmModuleAsyncOptions, OrmModuleOptions, OrmUtcOptions } from './orm.module.js';
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var abstract_orm_entity_1 = require("./entities/abstract-orm.entity");
|
|
8
|
-
Object.defineProperty(exports, "AbstractOrmEntity", { enumerable: true, get: function () { return abstract_orm_entity_1.AbstractOrmEntity; } });
|
|
9
|
-
var abstract_orm_service_1 = require("./services/abstract-orm.service");
|
|
10
|
-
Object.defineProperty(exports, "AbstractOrmService", { enumerable: true, get: function () { return abstract_orm_service_1.AbstractOrmService; } });
|
|
11
|
-
var transaction_service_1 = require("./services/transaction.service");
|
|
12
|
-
Object.defineProperty(exports, "TransactionService", { enumerable: true, get: function () { return transaction_service_1.TransactionService; } });
|
|
13
|
-
var utc_data_source_1 = require("./lib/utc-data-source");
|
|
14
|
-
Object.defineProperty(exports, "UtcDataSource", { enumerable: true, get: function () { return utc_data_source_1.UtcDataSource; } });
|
|
15
|
-
var orm_module_1 = require("./orm.module");
|
|
16
|
-
Object.defineProperty(exports, "OrmModule", { enumerable: true, get: function () { return orm_module_1.OrmModule; } });
|
|
1
|
+
export { BinaryUuidColumn, binaryUuidTransformer } from './decorators/binary-uuid-column.js';
|
|
2
|
+
export { AbstractOrmEntity } from './entities/abstract-orm.entity.js';
|
|
3
|
+
export { AbstractOrmService } from './services/abstract-orm.service.js';
|
|
4
|
+
export { TransactionService } from './services/transaction.service.js';
|
|
5
|
+
export { UtcDataSource } from './lib/utc-data-source.js';
|
|
6
|
+
export { OrmModule } from './orm.module.js';
|
|
17
7
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAG5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAA;AAErE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAA;AAEvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAEtE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA"}
|
package/dist/lib/constructor.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.txStorage = void 0;
|
|
4
|
-
const node_async_hooks_1 = require("node:async_hooks");
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
5
2
|
// Keyed by DataSource so a multi-connection app can have more than one ambient transaction
|
|
6
3
|
// active at once (e.g. one DataSource's transaction nested inside another's) without one
|
|
7
4
|
// overwriting or being mistaken for the other's.
|
|
8
|
-
|
|
5
|
+
export const txStorage = new AsyncLocalStorage();
|
|
9
6
|
//# sourceMappingURL=transaction-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-context.js","sourceRoot":"","sources":["../../src/lib/transaction-context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transaction-context.js","sourceRoot":"","sources":["../../src/lib/transaction-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAGpD,2FAA2F;AAC3F,yFAAyF;AACzF,iDAAiD;AACjD,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,iBAAiB,EAAkC,CAAA"}
|
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UtcDataSource = void 0;
|
|
4
|
-
const typeorm_1 = require("typeorm");
|
|
1
|
+
import { DataSource } from 'typeorm';
|
|
5
2
|
/**
|
|
6
3
|
* A data source that stores and reads dates as UTC, and fails to initialize unless the database server runs in UTC
|
|
7
4
|
* too: the server fills `DEFAULT CURRENT_TIMESTAMP` columns in its own time zone, so both must agree.
|
|
8
5
|
* Databases without UTC handling here are refused.
|
|
9
6
|
*/
|
|
10
|
-
class UtcDataSource extends
|
|
7
|
+
export class UtcDataSource extends DataSource {
|
|
11
8
|
constructor(options) {
|
|
12
9
|
super(UtcDataSource.utcOptions(options));
|
|
13
10
|
}
|
|
14
11
|
async initialize() {
|
|
15
12
|
await super.initialize();
|
|
16
|
-
|
|
13
|
+
try {
|
|
14
|
+
await this.assertUtcServer();
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
// Closed, so a refused server keeps no connections open, e.g. as TypeOrmModule retries with a new one; the
|
|
18
|
+
// refusal is what's thrown
|
|
19
|
+
if (this.isInitialized) {
|
|
20
|
+
await this.destroy().catch(() => undefined);
|
|
21
|
+
}
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
17
24
|
return this;
|
|
18
25
|
}
|
|
19
26
|
static utcOptions(options) {
|
|
@@ -41,5 +48,4 @@ class UtcDataSource extends typeorm_1.DataSource {
|
|
|
41
48
|
}
|
|
42
49
|
}
|
|
43
50
|
}
|
|
44
|
-
exports.UtcDataSource = UtcDataSource;
|
|
45
51
|
//# sourceMappingURL=utc-data-source.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utc-data-source.js","sourceRoot":"","sources":["../../src/lib/utc-data-source.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utc-data-source.js","sourceRoot":"","sources":["../../src/lib/utc-data-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,SAAS,CAAA;AAEvD;;;;GAIG;AACH,MAAM,OAAO,aAAc,SAAQ,UAAU;IACzC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E,uEAAuE,CAC/H,CAAA;gBACL,CAAC;gBACD,OAAM;YACV,CAAC;YACD;gBACI,MAAM,IAAI,KAAK,CAAC,iCAAiC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;QAC7E,CAAC;IACL,CAAC;CACJ"}
|
package/dist/orm.module.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -6,22 +5,20 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
6
|
};
|
|
8
7
|
var OrmModule_1;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const utc_data_source_1 = require("./lib/utc-data-source");
|
|
14
|
-
const transaction_service_1 = require("./services/transaction.service");
|
|
8
|
+
import { Module } from '@nestjs/common';
|
|
9
|
+
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
10
|
+
import { UtcDataSource } from './lib/utc-data-source.js';
|
|
11
|
+
import { TransactionService } from './services/transaction.service.js';
|
|
15
12
|
/**
|
|
16
13
|
* Sets up the TypeORM connection for `OrmModule.forRoot*()` and re-exports the plain `OrmModule`, so the application
|
|
17
14
|
* and every library share one `OrmModule` and one `TransactionService`.
|
|
18
15
|
*/
|
|
19
16
|
let OrmCoreModule = class OrmCoreModule {
|
|
20
17
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
(0, common_1.Module)({})
|
|
18
|
+
OrmCoreModule = __decorate([
|
|
19
|
+
Module({})
|
|
24
20
|
], OrmCoreModule);
|
|
21
|
+
export { OrmCoreModule };
|
|
25
22
|
/**
|
|
26
23
|
* Provides `TransactionService`. It's imported in one of two ways:
|
|
27
24
|
*
|
|
@@ -47,11 +44,11 @@ let OrmModule = OrmModule_1 = class OrmModule {
|
|
|
47
44
|
module: OrmCoreModule,
|
|
48
45
|
imports: [
|
|
49
46
|
OrmModule_1,
|
|
50
|
-
|
|
47
|
+
TypeOrmModule.forRootAsync({
|
|
51
48
|
...typeOrmOptions,
|
|
52
49
|
// TypeORM's module initializes the returned data source, which runs its UTC check
|
|
53
50
|
...(utc && {
|
|
54
|
-
dataSourceFactory: (dataSourceOptions) => Promise.resolve(new
|
|
51
|
+
dataSourceFactory: (dataSourceOptions) => Promise.resolve(new UtcDataSource(dataSourceOptions)),
|
|
55
52
|
}),
|
|
56
53
|
}),
|
|
57
54
|
],
|
|
@@ -59,11 +56,11 @@ let OrmModule = OrmModule_1 = class OrmModule {
|
|
|
59
56
|
};
|
|
60
57
|
}
|
|
61
58
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
exports: [transaction_service_1.TransactionService],
|
|
59
|
+
OrmModule = OrmModule_1 = __decorate([
|
|
60
|
+
Module({
|
|
61
|
+
providers: [TransactionService],
|
|
62
|
+
exports: [TransactionService],
|
|
67
63
|
})
|
|
68
64
|
], OrmModule);
|
|
65
|
+
export { OrmModule };
|
|
69
66
|
//# sourceMappingURL=orm.module.js.map
|
package/dist/orm.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orm.module.js","sourceRoot":"","sources":["../src/orm.module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"orm.module.js","sourceRoot":"","sources":["../src/orm.module.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAiB,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAmD,MAAM,iBAAiB,CAAA;AAChG,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,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A8BrB"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { DeepPartial, DeleteResult, EntityManager, FindManyOptions, FindOneOptions, FindOptionsWhere, Repository, SelectQueryBuilder, UpdateResult } from 'typeorm';
|
|
2
|
-
import { QueryDeepPartialEntity } from 'typeorm/query-builder/QueryPartialEntity';
|
|
1
|
+
import { DeepPartial, DeleteResult, EntityManager, FindManyOptions, FindOneOptions, FindOptionsWhere, QueryDeepPartialEntity, Repository, SelectQueryBuilder, UpdateResult } from 'typeorm';
|
|
3
2
|
import { Type } from '@nestjs/common';
|
|
4
|
-
import { AbstractOrmEntity } from '../entities/abstract-orm.entity';
|
|
5
|
-
import { Constructor } from '../lib/constructor';
|
|
3
|
+
import { AbstractOrmEntity } from '../entities/abstract-orm.entity.js';
|
|
4
|
+
import { Constructor } from '../lib/constructor.js';
|
|
6
5
|
export interface IOrmService<T extends AbstractOrmEntity> {
|
|
7
6
|
readonly repository: Repository<T>;
|
|
8
7
|
create(props: DeepPartial<T>, enforceEntityManager?: EntityManager): Promise<T>;
|
|
@@ -12,6 +11,7 @@ export interface IOrmService<T extends AbstractOrmEntity> {
|
|
|
12
11
|
count(conditions: FindManyOptions<T>, enforceEntityManager?: EntityManager): Promise<number>;
|
|
13
12
|
update(criteria: FindOptionsWhere<T>, props: QueryDeepPartialEntity<T>, enforceEntityManager?: EntityManager): Promise<UpdateResult>;
|
|
14
13
|
remove(conditions: FindOptionsWhere<T>, enforceEntityManager?: EntityManager): Promise<DeleteResult>;
|
|
14
|
+
hardRemove(conditions: FindOptionsWhere<T>, enforceEntityManager?: EntityManager): Promise<DeleteResult>;
|
|
15
15
|
createQueryBuilder(alias: string, enforceEntityManager?: EntityManager): SelectQueryBuilder<T>;
|
|
16
16
|
}
|
|
17
17
|
export declare function AbstractOrmService<T extends AbstractOrmEntity>(entity: Constructor<T>): Type<IOrmService<T>>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8,12 +7,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const transaction_context_1 = require("../lib/transaction-context");
|
|
16
|
-
function AbstractOrmService(entity) {
|
|
10
|
+
import { Repository, } from 'typeorm';
|
|
11
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
12
|
+
import { txStorage } from '../lib/transaction-context.js';
|
|
13
|
+
export function AbstractOrmService(entity) {
|
|
17
14
|
class AbstractOrmServiceHost {
|
|
18
15
|
repository;
|
|
19
16
|
async create(props, enforceEntityManager) {
|
|
@@ -45,7 +42,20 @@ function AbstractOrmService(entity) {
|
|
|
45
42
|
update(criteria, props, enforceEntityManager) {
|
|
46
43
|
return this.getRepository(enforceEntityManager).update(criteria, props);
|
|
47
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Removes the matching rows: softly for an entity with a `@DeleteDateColumn`, setting their delete date, so reads
|
|
47
|
+
* leave them out from then on, and for good otherwise; `hardRemove()` removes them for good either way
|
|
48
|
+
*/
|
|
48
49
|
remove(conditions, enforceEntityManager) {
|
|
50
|
+
const repository = this.getRepository(enforceEntityManager);
|
|
51
|
+
return repository.metadata.deleteDateColumn
|
|
52
|
+
? repository.softDelete(conditions)
|
|
53
|
+
: repository.delete(conditions);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Removes the matching rows for good, also for an entity with a `@DeleteDateColumn`
|
|
57
|
+
*/
|
|
58
|
+
hardRemove(conditions, enforceEntityManager) {
|
|
49
59
|
return this.getRepository(enforceEntityManager).delete(conditions);
|
|
50
60
|
}
|
|
51
61
|
createQueryBuilder(alias, enforceEntityManager) {
|
|
@@ -72,12 +82,12 @@ function AbstractOrmService(entity) {
|
|
|
72
82
|
return enforceEntityManager ?? this.contextEntityManager;
|
|
73
83
|
}
|
|
74
84
|
get contextEntityManager() {
|
|
75
|
-
return
|
|
85
|
+
return txStorage.getStore()?.get(this.repository.manager.dataSource);
|
|
76
86
|
}
|
|
77
87
|
}
|
|
78
88
|
__decorate([
|
|
79
|
-
|
|
80
|
-
__metadata("design:type",
|
|
89
|
+
InjectRepository(entity),
|
|
90
|
+
__metadata("design:type", Repository)
|
|
81
91
|
], AbstractOrmServiceHost.prototype, "repository", void 0);
|
|
82
92
|
return AbstractOrmServiceHost;
|
|
83
93
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract-orm.service.js","sourceRoot":"","sources":["../../src/services/abstract-orm.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"abstract-orm.service.js","sourceRoot":"","sources":["../../src/services/abstract-orm.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAQH,UAAU,GAGb,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAGlD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAqBzD,MAAM,UAAU,kBAAkB,CAA8B,MAAsB;IAClF,MAAM,sBAAsB;QAExB,UAAU,CAAgB;QAEnB,KAAK,CAAC,MAAM,CAAC,KAAqB,EAAE,oBAAoC;YAC3E,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAA;YAE3D,MAAM,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YACtC,MAAM,UAAU,CAAC,IAAI,CAAC,KAAK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IAAI,IAAI,CAAC,oBAAoB,CAAA;QAC5D,CAAC;QAED,IAAY,oBAAoB;YAC5B,OAAO,SAAS,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;QACxE,CAAC;KACJ;IApGG;QADC,gBAAgB,CAAC,MAAM,CAAC;kCACZ,UAAU;8DAAG;IAqG9B,OAAO,sBAAsB,CAAA;AACjC,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8,18 +7,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const common_1 = require("@nestjs/common");
|
|
15
|
-
const transaction_context_1 = require("../lib/transaction-context");
|
|
10
|
+
import { DataSource } from 'typeorm';
|
|
11
|
+
import { Injectable } from '@nestjs/common';
|
|
12
|
+
import { txStorage } from '../lib/transaction-context.js';
|
|
16
13
|
let TransactionService = class TransactionService {
|
|
17
14
|
dataSource;
|
|
18
15
|
constructor(dataSource) {
|
|
19
16
|
this.dataSource = dataSource;
|
|
20
17
|
}
|
|
21
18
|
async transaction(fn) {
|
|
22
|
-
const currentStore =
|
|
19
|
+
const currentStore = txStorage.getStore();
|
|
23
20
|
const manager = currentStore?.get(this.dataSource) ?? this.dataSource.manager;
|
|
24
21
|
return manager.transaction(async (txManager) => {
|
|
25
22
|
// Copy rather than mutate: the current store may still be referenced by sibling
|
|
@@ -27,13 +24,13 @@ let TransactionService = class TransactionService {
|
|
|
27
24
|
// this call), which must not see this DataSource's entry appear underneath them.
|
|
28
25
|
const nextStore = new Map(currentStore);
|
|
29
26
|
nextStore.set(this.dataSource, txManager);
|
|
30
|
-
return
|
|
27
|
+
return txStorage.run(nextStore, () => fn(txManager));
|
|
31
28
|
});
|
|
32
29
|
}
|
|
33
30
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
(
|
|
37
|
-
__metadata("design:paramtypes", [typeorm_1.DataSource])
|
|
31
|
+
TransactionService = __decorate([
|
|
32
|
+
Injectable(),
|
|
33
|
+
__metadata("design:paramtypes", [DataSource])
|
|
38
34
|
], TransactionService);
|
|
35
|
+
export { TransactionService };
|
|
39
36
|
//# sourceMappingURL=transaction.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.service.js","sourceRoot":"","sources":["../../src/services/transaction.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transaction.service.js","sourceRoot":"","sources":["../../src/services/transaction.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAiB,MAAM,SAAS,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAGlD,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IACE;IAA7B,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAEhD,KAAK,CAAC,WAAW,CAAI,EAA0C;QAClE,MAAM,YAAY,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAA;QACzC,MAAM,OAAO,GAAG,YAAY,EAAE,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAA;QAE7E,OAAO,OAAO,CAAC,WAAW,CAAC,KAAK,EAAE,SAAwB,EAAE,EAAE;YAC1D,gFAAgF;YAChF,mFAAmF;YACnF,iFAAiF;YACjF,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAA;YACvC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;YACzC,OAAO,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;QACxD,CAAC,CAAC,CAAA;IACN,CAAC;CACJ,CAAA;AAhBY,kBAAkB;IAD9B,UAAU,EAAE;qCAEgC,UAAU;GAD1C,kBAAkB,CAgB9B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Constructor } from '../lib/constructor';
|
|
1
|
+
import { Constructor } from '../lib/constructor.js';
|
|
2
2
|
export declare const GENERATED_COLUMNS: unique symbol;
|
|
3
3
|
export declare function addGeneratedColumn(constructor: Constructor, column: GeneratedColumnMetadata): void;
|
|
4
4
|
export declare function getGeneratedColumns(constructor: Constructor): GeneratedColumnMetadata[];
|
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GENERATED_COLUMNS = void 0;
|
|
4
|
-
exports.addGeneratedColumn = addGeneratedColumn;
|
|
5
|
-
exports.getGeneratedColumns = getGeneratedColumns;
|
|
6
|
-
exports.GENERATED_COLUMNS = Symbol('GENERATED_COLUMNS');
|
|
1
|
+
export const GENERATED_COLUMNS = Symbol('GENERATED_COLUMNS');
|
|
7
2
|
// Recorded per-class as OWN metadata only (never merged with an ancestor's at write time), so a
|
|
8
3
|
// subclass redeclaring a column always shadows its parent's entry for that property instead of
|
|
9
4
|
// stacking alongside it. `generator: null` explicitly opts a property out of an ancestor's
|
|
10
5
|
// auto-generation, distinct from a subclass saying nothing about the property at all.
|
|
11
|
-
function addGeneratedColumn(constructor, column) {
|
|
12
|
-
const existing = (Reflect.getOwnMetadata(
|
|
13
|
-
Reflect.defineMetadata(
|
|
6
|
+
export function addGeneratedColumn(constructor, column) {
|
|
7
|
+
const existing = (Reflect.getOwnMetadata(GENERATED_COLUMNS, constructor) ?? []);
|
|
8
|
+
Reflect.defineMetadata(GENERATED_COLUMNS, [...existing, column], constructor);
|
|
14
9
|
}
|
|
15
10
|
// Walks the prototype chain from the topmost ancestor down to `constructor`, merging each class's
|
|
16
11
|
// OWN entries by propertyKey so a more-derived class's declaration always wins over an inherited one.
|
|
17
|
-
function getGeneratedColumns(constructor) {
|
|
12
|
+
export function getGeneratedColumns(constructor) {
|
|
18
13
|
const chain = [];
|
|
19
14
|
for (let current = constructor; current; current = Object.getPrototypeOf(current)) {
|
|
20
15
|
chain.unshift(current);
|
|
21
16
|
}
|
|
22
17
|
const byPropertyKey = new Map();
|
|
23
18
|
for (const ctor of chain) {
|
|
24
|
-
const ownColumns = (Reflect.getOwnMetadata(
|
|
19
|
+
const ownColumns = (Reflect.getOwnMetadata(GENERATED_COLUMNS, ctor) ?? []);
|
|
25
20
|
for (const column of ownColumns) {
|
|
26
21
|
byPropertyKey.set(column.propertyKey, column);
|
|
27
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generated-column.util.js","sourceRoot":"","sources":["../../src/utils/generated-column.util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generated-column.util.js","sourceRoot":"","sources":["../../src/utils/generated-column.util.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAA;AAE5D,gGAAgG;AAChG,+FAA+F;AAC/F,2FAA2F;AAC3F,sFAAsF;AACtF,MAAM,UAAU,kBAAkB,CAAC,WAAwB,EAAE,MAA+B;IACxF,MAAM,QAAQ,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,iBAAiB,EAAE,WAAW,CAAC,IAAI,EAAE,CAA8B,CAAA;IAC5G,OAAO,CAAC,cAAc,CAAC,iBAAiB,EAAE,CAAC,GAAG,QAAQ,EAAE,MAAM,CAAC,EAAE,WAAW,CAAC,CAAA;AACjF,CAAC;AAED,kGAAkG;AAClG,sGAAsG;AACtG,MAAM,UAAU,mBAAmB,CAAC,WAAwB;IACxD,MAAM,KAAK,GAAkB,EAAE,CAAA;IAC/B,KACI,IAAI,OAAO,GAAuB,WAAW,EAC7C,OAAO,EACP,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,OAAO,CAAuB,EAChE,CAAC;QACC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC1B,CAAC;IAED,MAAM,aAAa,GAAG,IAAI,GAAG,EAAmC,CAAA;IAChE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,UAAU,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,iBAAiB,EAAE,IAAI,CAAC,IAAI,EAAE,CAA8B,CAAA;QACvG,KAAK,MAAM,MAAM,IAAI,UAAU,EAAE,CAAC;YAC9B,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;QACjD,CAAC;IACL,CAAC;IAED,OAAO,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,CAAA;AACtC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artenc/nest-orm",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Helper utility to work with TypeORM",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nestjs",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"author": "artenc",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"private": false,
|
|
22
|
+
"type": "module",
|
|
22
23
|
"repository": {
|
|
23
24
|
"type": "git",
|
|
24
25
|
"url": "git+https://gitlab.com/nestjs-utility-modules/nest-orm.git"
|
|
@@ -35,69 +36,57 @@
|
|
|
35
36
|
"exports": {
|
|
36
37
|
".": {
|
|
37
38
|
"types": "./dist/index.d.ts",
|
|
38
|
-
"
|
|
39
|
-
"import": "./dist/index.js"
|
|
39
|
+
"default": "./dist/index.js"
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
"sideEffects": false,
|
|
43
43
|
"files": [
|
|
44
44
|
"dist"
|
|
45
45
|
],
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": "^20.19.0 || ^22.13.0 || >=24.11.0"
|
|
48
|
+
},
|
|
46
49
|
"scripts": {
|
|
47
50
|
"build": "nest build",
|
|
48
51
|
"prepack": "npm test && npm run build",
|
|
49
52
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
50
53
|
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
|
51
|
-
"test": "
|
|
52
|
-
"
|
|
53
|
-
"test:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
"<rootDir>/test"
|
|
58
|
-
],
|
|
59
|
-
"testRegex": ".*\\.spec\\.ts$",
|
|
60
|
-
"transform": {
|
|
61
|
-
"^.+\\.ts$": "ts-jest"
|
|
62
|
-
},
|
|
63
|
-
"setupFiles": [
|
|
64
|
-
"reflect-metadata"
|
|
65
|
-
],
|
|
66
|
-
"testEnvironment": "node",
|
|
67
|
-
"collectCoverageFrom": [
|
|
68
|
-
"src/**/*.ts"
|
|
69
|
-
],
|
|
70
|
-
"coverageDirectory": "coverage"
|
|
54
|
+
"test": "npm run typecheck && vitest run",
|
|
55
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
56
|
+
"test:watch": "vitest",
|
|
57
|
+
"test:cov": "vitest run --coverage",
|
|
58
|
+
"test:mysql:start": "node test/support/mysql-server.ts start",
|
|
59
|
+
"test:mysql:stop": "node test/support/mysql-server.ts stop"
|
|
71
60
|
},
|
|
72
61
|
"dependencies": {
|
|
73
62
|
"class-transformer": "^0.5.1",
|
|
74
|
-
"uuid": "^
|
|
63
|
+
"uuid": "^14.0.3"
|
|
75
64
|
},
|
|
76
65
|
"peerDependencies": {
|
|
77
|
-
"@nestjs/common": "^
|
|
78
|
-
"@nestjs/typeorm": "^
|
|
79
|
-
"typeorm": "^
|
|
66
|
+
"@nestjs/common": "^12.0.0",
|
|
67
|
+
"@nestjs/typeorm": "^12.0.0",
|
|
68
|
+
"typeorm": "^1.1.3"
|
|
80
69
|
},
|
|
81
70
|
"devDependencies": {
|
|
82
|
-
"@eslint/js": "^
|
|
83
|
-
"@nestjs/cli": "^
|
|
84
|
-
"@nestjs/common": "^
|
|
85
|
-
"@nestjs/core": "^
|
|
86
|
-
"@nestjs/schematics": "^
|
|
87
|
-
"@nestjs/typeorm": "^
|
|
88
|
-
"@types/
|
|
89
|
-
"@
|
|
90
|
-
"eslint": "^
|
|
91
|
-
"eslint-config-prettier": "^10.
|
|
92
|
-
"eslint-plugin-prettier": "^5.
|
|
93
|
-
"globals": "^
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"prettier": "^3.4.2",
|
|
71
|
+
"@eslint/js": "^10.0.1",
|
|
72
|
+
"@nestjs/cli": "^12.0.15",
|
|
73
|
+
"@nestjs/common": "^12.6.3",
|
|
74
|
+
"@nestjs/core": "^12.6.3",
|
|
75
|
+
"@nestjs/schematics": "^12.0.17",
|
|
76
|
+
"@nestjs/typeorm": "^12.0.3",
|
|
77
|
+
"@types/node": "^22.20.7",
|
|
78
|
+
"@vitest/coverage-v8": "^5.1.2",
|
|
79
|
+
"eslint": "^10.16.0",
|
|
80
|
+
"eslint-config-prettier": "^10.1.9",
|
|
81
|
+
"eslint-plugin-prettier": "^5.5.7",
|
|
82
|
+
"globals": "^17.14.0",
|
|
83
|
+
"mysql2": "^3.26.0",
|
|
84
|
+
"prettier": "^3.10.1",
|
|
97
85
|
"reflect-metadata": "^0.2.2",
|
|
98
|
-
"
|
|
99
|
-
"typeorm": "^
|
|
100
|
-
"typescript": "
|
|
101
|
-
"typescript-eslint": "^8.
|
|
86
|
+
"rxjs": "^7.8.2",
|
|
87
|
+
"typeorm": "^1.1.3",
|
|
88
|
+
"typescript": "~6.0.3",
|
|
89
|
+
"typescript-eslint": "^8.74.0",
|
|
90
|
+
"vitest": "^5.1.2"
|
|
102
91
|
}
|
|
103
92
|
}
|