@nathapp/nestjs-typeorm 3.2.1 → 3.3.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/AGENTS.md +188 -0
- package/CLAUDE.md +18 -0
- package/GEMINI.md +186 -0
- package/codex.md +186 -0
- package/dist/decorator/date-column.decorator.js +37 -5
- package/dist/decorator/date-column.decorator.js.map +1 -1
- package/dist/errors/database-error.mapper.d.ts +1 -0
- package/dist/errors/database-error.mapper.js +5 -3
- package/dist/errors/database-error.mapper.js.map +1 -1
- package/dist/pagination/paginate.js +1 -2
- package/dist/pagination/paginate.js.map +1 -1
- package/dist/repository/abstract-typeorm.repository.js +6 -3
- package/dist/repository/abstract-typeorm.repository.js.map +1 -1
- package/dist/repository/base.repository.d.ts +0 -1
- package/dist/repository/base.repository.js +22 -39
- package/dist/repository/base.repository.js.map +1 -1
- package/dist/typeorm/typeorm-ex.module.d.ts +1 -0
- package/dist/typeorm/typeorm-ex.module.js +24 -40
- package/dist/typeorm/typeorm-ex.module.js.map +1 -1
- package/package.json +6 -4
package/AGENTS.md
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# Agent Instructions
|
|
2
|
+
|
|
3
|
+
This file is auto-generated from `.nax/context.md`.
|
|
4
|
+
DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
|
|
5
|
+
|
|
6
|
+
These instructions apply to all AI coding agents in this project.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Project Metadata
|
|
11
|
+
|
|
12
|
+
> Auto-injected by `nax generate`
|
|
13
|
+
|
|
14
|
+
**Project:** `@nathapp/nestjs-typeorm`
|
|
15
|
+
|
|
16
|
+
**Language:** TypeScript
|
|
17
|
+
|
|
18
|
+
**Key dependencies:** @nathapp/typescript-config, typescript
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
# @nathapp/nestjs-typeorm
|
|
22
|
+
|
|
23
|
+
TypeORM integration (renamed from `@nathapp/nestjs-data`).
|
|
24
|
+
|
|
25
|
+
## Commands
|
|
26
|
+
- Test: `npx jest --config test/jest-test.json --no-coverage`
|
|
27
|
+
- Build: `npx tsc`
|
|
28
|
+
|
|
29
|
+
## Key Classes
|
|
30
|
+
- `BaseSpRepository` — stored procedure helper with `callQuery()`, recordset mapping.
|
|
31
|
+
- `TypeOrmExModule` — custom repository registration via `@CustomRepository()` decorator.
|
|
32
|
+
- `BaseTypeOrmModuleOptionFactory` — abstract factory for TypeORM connection options.
|
|
33
|
+
|
|
34
|
+
## Portable Repository
|
|
35
|
+
|
|
36
|
+
`AbstractTypeOrmRepository<TDomain, TEntity, TId>` implements
|
|
37
|
+
`IRepository<TDomain, TId>` from `@nathapp/nestjs-data`. Use it when services
|
|
38
|
+
should depend on the portable interface (decoupled from TypeORM). Subclass and
|
|
39
|
+
implement `toDomain`, `toPersistenceCreate`, `toPersistenceUpdate`. Add bespoke
|
|
40
|
+
TypeORM-specific methods (e.g. `createQueryBuilder`) on top — they are
|
|
41
|
+
automatically transaction-aware via the protected `repo` getter.
|
|
42
|
+
|
|
43
|
+
For ORM-specific power that does not need the portable contract, keep using
|
|
44
|
+
`BaseRepository` / `BaseSpRepository` — they are unrelated and remain unchanged.
|
|
45
|
+
|
|
46
|
+
### Wiring via `forCustomRepository`
|
|
47
|
+
|
|
48
|
+
`TypeOrmExModule.forCustomRepository` is the standard wiring path for all three
|
|
49
|
+
repository styles. The factory branches on the base class:
|
|
50
|
+
|
|
51
|
+
- `extends AbstractTypeOrmRepository` → `new repo(tx, entity)` from `@CustomRepository(Entity)` metadata + injected per-DataSource tx manager token
|
|
52
|
+
- `extends BaseRepository` → `new repo(dataSource)`
|
|
53
|
+
- `extends Repository<T>` → manager-getter trick + ALS retrofit (transaction-aware when `forRoot({ transaction: true })`)
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import { CustomRepository, AbstractTypeOrmRepository, TypeOrmExModule } from '@nathapp/nestjs-typeorm';
|
|
57
|
+
import { Repository } from 'typeorm';
|
|
58
|
+
|
|
59
|
+
// New code: portable IRepository<User> — no manual constructor needed
|
|
60
|
+
@CustomRepository(UserEntity)
|
|
61
|
+
export class UserRepository extends AbstractTypeOrmRepository<User, UserEntity, string> {
|
|
62
|
+
protected toDomain(e: UserEntity): User { return { id: e.id, email: e.email_address, name: e.full_name }; }
|
|
63
|
+
protected toPersistenceCreate(d: User): UserEntity { /* ... */ }
|
|
64
|
+
protected toPersistenceUpdate(p: Partial<User>): Partial<UserEntity> { /* ... */ }
|
|
65
|
+
|
|
66
|
+
// Bespoke TypeORM-specific method — already tx-aware via this.repo
|
|
67
|
+
async findActiveByEmail(email: string): Promise<User | null> {
|
|
68
|
+
const e = await this.repo
|
|
69
|
+
.createQueryBuilder('u')
|
|
70
|
+
.where('u.email_address = :email AND u.status = 1', { email })
|
|
71
|
+
.getOne();
|
|
72
|
+
return e ? this.toDomain(e) : null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Legacy / coupling-explicit: extend Repository<T> directly
|
|
77
|
+
@CustomRepository(InvoiceEntity)
|
|
78
|
+
export class InvoiceRepository extends Repository<InvoiceEntity> {
|
|
79
|
+
// QueryBuilder, raw SQL, etc. — automatically participates in txManager.run()
|
|
80
|
+
// when the module is registered with forRoot({ transaction: true }).
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@Module({
|
|
84
|
+
imports: [
|
|
85
|
+
TypeOrmExModule.forRoot({ type: 'mysql', /* ... */, transaction: true }),
|
|
86
|
+
TypeOrmExModule.forCustomRepository([UserRepository, InvoiceRepository]),
|
|
87
|
+
],
|
|
88
|
+
providers: [
|
|
89
|
+
// Bind the IRepository<User> token to the concrete class.
|
|
90
|
+
{ provide: USER_REPOSITORY, useExisting: UserRepository },
|
|
91
|
+
],
|
|
92
|
+
exports: [USER_REPOSITORY],
|
|
93
|
+
})
|
|
94
|
+
export class UserModule {}
|
|
95
|
+
|
|
96
|
+
// Service depends on the portable contract:
|
|
97
|
+
@Injectable()
|
|
98
|
+
export class UserService {
|
|
99
|
+
constructor(@Inject(USER_REPOSITORY) private readonly users: IRepository<User>) {}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Multi-DataSource binding
|
|
104
|
+
|
|
105
|
+
Pass the DataSource name as the second argument to `forCustomRepository` so the
|
|
106
|
+
factory injects the matching per-DataSource tx manager token:
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
@Module({
|
|
110
|
+
imports: [
|
|
111
|
+
TypeOrmExModule.forRoot({ name: 'analytics', type: 'mysql', /* ... */, transaction: true }),
|
|
112
|
+
TypeOrmExModule.forCustomRepository([AnalyticsRepo], 'analytics'),
|
|
113
|
+
],
|
|
114
|
+
providers: [
|
|
115
|
+
{ provide: ANALYTICS_REPOSITORY, useExisting: AnalyticsRepo },
|
|
116
|
+
],
|
|
117
|
+
})
|
|
118
|
+
export class AnalyticsModule {}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Limitations
|
|
122
|
+
|
|
123
|
+
- The `AbstractTypeOrmRepository` branch instantiates with `(tx, entity)` only.
|
|
124
|
+
Subclasses that need to inject additional providers (e.g. a logger) must
|
|
125
|
+
register manually via `providers: [...]` instead of `forCustomRepository`.
|
|
126
|
+
- Legacy `@Transactional` method decorator and `BaseSpRepository.callQuery` use a
|
|
127
|
+
separate `transactionContext` ALS that is not unified with `TypeOrmTransactionManager`.
|
|
128
|
+
Out of scope; tracked as a follow-up.
|
|
129
|
+
|
|
130
|
+
## Multi-DB
|
|
131
|
+
|
|
132
|
+
Multiple TypeORM DataSources in one process are wired by repeating
|
|
133
|
+
`TypeOrmExModule.forRoot` with different `name` values. Each call publishes a
|
|
134
|
+
per-DataSource transaction manager token via `getTypeOrmTransactionManagerToken(name)`.
|
|
135
|
+
The **default** DataSource additionally aliases the global `TRANSACTION_MANAGER`
|
|
136
|
+
symbol from `@nathapp/nestjs-data`, so single-DB consumers do not change.
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
import {
|
|
140
|
+
TypeOrmExModule,
|
|
141
|
+
getTypeOrmTransactionManagerToken,
|
|
142
|
+
} from '@nathapp/nestjs-typeorm';
|
|
143
|
+
import { ITransactionManager } from '@nathapp/nestjs-data';
|
|
144
|
+
|
|
145
|
+
@Module({
|
|
146
|
+
imports: [
|
|
147
|
+
TypeOrmExModule.forRoot({ /* default DS config */, transaction: true }),
|
|
148
|
+
TypeOrmExModule.forRoot({ name: 'analytics', /* ... */, transaction: true }),
|
|
149
|
+
],
|
|
150
|
+
})
|
|
151
|
+
export class AppModule {}
|
|
152
|
+
|
|
153
|
+
@Injectable()
|
|
154
|
+
export class AnalyticsService {
|
|
155
|
+
constructor(
|
|
156
|
+
@Inject(getTypeOrmTransactionManagerToken('analytics'))
|
|
157
|
+
private readonly tx: ITransactionManager,
|
|
158
|
+
) {}
|
|
159
|
+
|
|
160
|
+
async ingest(events: Event[]) {
|
|
161
|
+
return this.tx.run(async () => {
|
|
162
|
+
// Wraps analytics-DS writes only.
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Atomicity boundary — read this carefully
|
|
169
|
+
|
|
170
|
+
A `tx.run()` on a named tx manager covers **only** that DataSource's writes. If
|
|
171
|
+
code inside `tx.run('dbA')` also writes to dbB via a different tx manager, those
|
|
172
|
+
dbB writes are **independent** — they commit/roll back on their own. There is no
|
|
173
|
+
2PC, no distributed transaction, no cross-DB atomicity.
|
|
174
|
+
|
|
175
|
+
**This is intentional.** Cross-DB consistency in microservices is solved with
|
|
176
|
+
sagas / outbox patterns, not transactions.
|
|
177
|
+
|
|
178
|
+
### Default connection convenience
|
|
179
|
+
|
|
180
|
+
For services that only ever talk to one DataSource, keep using
|
|
181
|
+
`@Inject(TRANSACTION_MANAGER)` from `@nathapp/nestjs-data`. It is registered as
|
|
182
|
+
an alias for `getTypeOrmTransactionManagerToken()` (the default DataSource)
|
|
183
|
+
automatically. No multi-DB token churn for single-DB code.
|
|
184
|
+
|
|
185
|
+
## Gotchas
|
|
186
|
+
- Pagination types (`Page`, `PageOption`) moved to `@nathapp/nestjs-common` — import from there.
|
|
187
|
+
- Uses `import * as dayjs` (NOT default import) — do NOT add `esModuleInterop` to this package's tsconfig.
|
|
188
|
+
- Jest config omits `esModuleInterop` intentionally (unlike other packages).
|
package/CLAUDE.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
# Project Context
|
|
2
|
+
|
|
3
|
+
This file is auto-generated from `.nax/context.md`.
|
|
4
|
+
DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Project Metadata
|
|
9
|
+
|
|
10
|
+
> Auto-injected by `nax generate`
|
|
11
|
+
|
|
12
|
+
**Project:** `@nathapp/nestjs-typeorm`
|
|
13
|
+
|
|
14
|
+
**Language:** TypeScript
|
|
15
|
+
|
|
16
|
+
**Key dependencies:** @nathapp/typescript-config, typescript
|
|
17
|
+
|
|
18
|
+
---
|
|
1
19
|
# @nathapp/nestjs-typeorm
|
|
2
20
|
|
|
3
21
|
TypeORM integration (renamed from `@nathapp/nestjs-data`).
|
package/GEMINI.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# Gemini CLI Context
|
|
2
|
+
|
|
3
|
+
This file is auto-generated from `.nax/context.md`.
|
|
4
|
+
DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Project Metadata
|
|
9
|
+
|
|
10
|
+
> Auto-injected by `nax generate`
|
|
11
|
+
|
|
12
|
+
**Project:** `@nathapp/nestjs-typeorm`
|
|
13
|
+
|
|
14
|
+
**Language:** TypeScript
|
|
15
|
+
|
|
16
|
+
**Key dependencies:** @nathapp/typescript-config, typescript
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
# @nathapp/nestjs-typeorm
|
|
20
|
+
|
|
21
|
+
TypeORM integration (renamed from `@nathapp/nestjs-data`).
|
|
22
|
+
|
|
23
|
+
## Commands
|
|
24
|
+
- Test: `npx jest --config test/jest-test.json --no-coverage`
|
|
25
|
+
- Build: `npx tsc`
|
|
26
|
+
|
|
27
|
+
## Key Classes
|
|
28
|
+
- `BaseSpRepository` — stored procedure helper with `callQuery()`, recordset mapping.
|
|
29
|
+
- `TypeOrmExModule` — custom repository registration via `@CustomRepository()` decorator.
|
|
30
|
+
- `BaseTypeOrmModuleOptionFactory` — abstract factory for TypeORM connection options.
|
|
31
|
+
|
|
32
|
+
## Portable Repository
|
|
33
|
+
|
|
34
|
+
`AbstractTypeOrmRepository<TDomain, TEntity, TId>` implements
|
|
35
|
+
`IRepository<TDomain, TId>` from `@nathapp/nestjs-data`. Use it when services
|
|
36
|
+
should depend on the portable interface (decoupled from TypeORM). Subclass and
|
|
37
|
+
implement `toDomain`, `toPersistenceCreate`, `toPersistenceUpdate`. Add bespoke
|
|
38
|
+
TypeORM-specific methods (e.g. `createQueryBuilder`) on top — they are
|
|
39
|
+
automatically transaction-aware via the protected `repo` getter.
|
|
40
|
+
|
|
41
|
+
For ORM-specific power that does not need the portable contract, keep using
|
|
42
|
+
`BaseRepository` / `BaseSpRepository` — they are unrelated and remain unchanged.
|
|
43
|
+
|
|
44
|
+
### Wiring via `forCustomRepository`
|
|
45
|
+
|
|
46
|
+
`TypeOrmExModule.forCustomRepository` is the standard wiring path for all three
|
|
47
|
+
repository styles. The factory branches on the base class:
|
|
48
|
+
|
|
49
|
+
- `extends AbstractTypeOrmRepository` → `new repo(tx, entity)` from `@CustomRepository(Entity)` metadata + injected per-DataSource tx manager token
|
|
50
|
+
- `extends BaseRepository` → `new repo(dataSource)`
|
|
51
|
+
- `extends Repository<T>` → manager-getter trick + ALS retrofit (transaction-aware when `forRoot({ transaction: true })`)
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { CustomRepository, AbstractTypeOrmRepository, TypeOrmExModule } from '@nathapp/nestjs-typeorm';
|
|
55
|
+
import { Repository } from 'typeorm';
|
|
56
|
+
|
|
57
|
+
// New code: portable IRepository<User> — no manual constructor needed
|
|
58
|
+
@CustomRepository(UserEntity)
|
|
59
|
+
export class UserRepository extends AbstractTypeOrmRepository<User, UserEntity, string> {
|
|
60
|
+
protected toDomain(e: UserEntity): User { return { id: e.id, email: e.email_address, name: e.full_name }; }
|
|
61
|
+
protected toPersistenceCreate(d: User): UserEntity { /* ... */ }
|
|
62
|
+
protected toPersistenceUpdate(p: Partial<User>): Partial<UserEntity> { /* ... */ }
|
|
63
|
+
|
|
64
|
+
// Bespoke TypeORM-specific method — already tx-aware via this.repo
|
|
65
|
+
async findActiveByEmail(email: string): Promise<User | null> {
|
|
66
|
+
const e = await this.repo
|
|
67
|
+
.createQueryBuilder('u')
|
|
68
|
+
.where('u.email_address = :email AND u.status = 1', { email })
|
|
69
|
+
.getOne();
|
|
70
|
+
return e ? this.toDomain(e) : null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Legacy / coupling-explicit: extend Repository<T> directly
|
|
75
|
+
@CustomRepository(InvoiceEntity)
|
|
76
|
+
export class InvoiceRepository extends Repository<InvoiceEntity> {
|
|
77
|
+
// QueryBuilder, raw SQL, etc. — automatically participates in txManager.run()
|
|
78
|
+
// when the module is registered with forRoot({ transaction: true }).
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@Module({
|
|
82
|
+
imports: [
|
|
83
|
+
TypeOrmExModule.forRoot({ type: 'mysql', /* ... */, transaction: true }),
|
|
84
|
+
TypeOrmExModule.forCustomRepository([UserRepository, InvoiceRepository]),
|
|
85
|
+
],
|
|
86
|
+
providers: [
|
|
87
|
+
// Bind the IRepository<User> token to the concrete class.
|
|
88
|
+
{ provide: USER_REPOSITORY, useExisting: UserRepository },
|
|
89
|
+
],
|
|
90
|
+
exports: [USER_REPOSITORY],
|
|
91
|
+
})
|
|
92
|
+
export class UserModule {}
|
|
93
|
+
|
|
94
|
+
// Service depends on the portable contract:
|
|
95
|
+
@Injectable()
|
|
96
|
+
export class UserService {
|
|
97
|
+
constructor(@Inject(USER_REPOSITORY) private readonly users: IRepository<User>) {}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Multi-DataSource binding
|
|
102
|
+
|
|
103
|
+
Pass the DataSource name as the second argument to `forCustomRepository` so the
|
|
104
|
+
factory injects the matching per-DataSource tx manager token:
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
@Module({
|
|
108
|
+
imports: [
|
|
109
|
+
TypeOrmExModule.forRoot({ name: 'analytics', type: 'mysql', /* ... */, transaction: true }),
|
|
110
|
+
TypeOrmExModule.forCustomRepository([AnalyticsRepo], 'analytics'),
|
|
111
|
+
],
|
|
112
|
+
providers: [
|
|
113
|
+
{ provide: ANALYTICS_REPOSITORY, useExisting: AnalyticsRepo },
|
|
114
|
+
],
|
|
115
|
+
})
|
|
116
|
+
export class AnalyticsModule {}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Limitations
|
|
120
|
+
|
|
121
|
+
- The `AbstractTypeOrmRepository` branch instantiates with `(tx, entity)` only.
|
|
122
|
+
Subclasses that need to inject additional providers (e.g. a logger) must
|
|
123
|
+
register manually via `providers: [...]` instead of `forCustomRepository`.
|
|
124
|
+
- Legacy `@Transactional` method decorator and `BaseSpRepository.callQuery` use a
|
|
125
|
+
separate `transactionContext` ALS that is not unified with `TypeOrmTransactionManager`.
|
|
126
|
+
Out of scope; tracked as a follow-up.
|
|
127
|
+
|
|
128
|
+
## Multi-DB
|
|
129
|
+
|
|
130
|
+
Multiple TypeORM DataSources in one process are wired by repeating
|
|
131
|
+
`TypeOrmExModule.forRoot` with different `name` values. Each call publishes a
|
|
132
|
+
per-DataSource transaction manager token via `getTypeOrmTransactionManagerToken(name)`.
|
|
133
|
+
The **default** DataSource additionally aliases the global `TRANSACTION_MANAGER`
|
|
134
|
+
symbol from `@nathapp/nestjs-data`, so single-DB consumers do not change.
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
import {
|
|
138
|
+
TypeOrmExModule,
|
|
139
|
+
getTypeOrmTransactionManagerToken,
|
|
140
|
+
} from '@nathapp/nestjs-typeorm';
|
|
141
|
+
import { ITransactionManager } from '@nathapp/nestjs-data';
|
|
142
|
+
|
|
143
|
+
@Module({
|
|
144
|
+
imports: [
|
|
145
|
+
TypeOrmExModule.forRoot({ /* default DS config */, transaction: true }),
|
|
146
|
+
TypeOrmExModule.forRoot({ name: 'analytics', /* ... */, transaction: true }),
|
|
147
|
+
],
|
|
148
|
+
})
|
|
149
|
+
export class AppModule {}
|
|
150
|
+
|
|
151
|
+
@Injectable()
|
|
152
|
+
export class AnalyticsService {
|
|
153
|
+
constructor(
|
|
154
|
+
@Inject(getTypeOrmTransactionManagerToken('analytics'))
|
|
155
|
+
private readonly tx: ITransactionManager,
|
|
156
|
+
) {}
|
|
157
|
+
|
|
158
|
+
async ingest(events: Event[]) {
|
|
159
|
+
return this.tx.run(async () => {
|
|
160
|
+
// Wraps analytics-DS writes only.
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Atomicity boundary — read this carefully
|
|
167
|
+
|
|
168
|
+
A `tx.run()` on a named tx manager covers **only** that DataSource's writes. If
|
|
169
|
+
code inside `tx.run('dbA')` also writes to dbB via a different tx manager, those
|
|
170
|
+
dbB writes are **independent** — they commit/roll back on their own. There is no
|
|
171
|
+
2PC, no distributed transaction, no cross-DB atomicity.
|
|
172
|
+
|
|
173
|
+
**This is intentional.** Cross-DB consistency in microservices is solved with
|
|
174
|
+
sagas / outbox patterns, not transactions.
|
|
175
|
+
|
|
176
|
+
### Default connection convenience
|
|
177
|
+
|
|
178
|
+
For services that only ever talk to one DataSource, keep using
|
|
179
|
+
`@Inject(TRANSACTION_MANAGER)` from `@nathapp/nestjs-data`. It is registered as
|
|
180
|
+
an alias for `getTypeOrmTransactionManagerToken()` (the default DataSource)
|
|
181
|
+
automatically. No multi-DB token churn for single-DB code.
|
|
182
|
+
|
|
183
|
+
## Gotchas
|
|
184
|
+
- Pagination types (`Page`, `PageOption`) moved to `@nathapp/nestjs-common` — import from there.
|
|
185
|
+
- Uses `import * as dayjs` (NOT default import) — do NOT add `esModuleInterop` to this package's tsconfig.
|
|
186
|
+
- Jest config omits `esModuleInterop` intentionally (unlike other packages).
|
package/codex.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# Codex Instructions
|
|
2
|
+
|
|
3
|
+
This file is auto-generated from `.nax/context.md`.
|
|
4
|
+
DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Project Metadata
|
|
9
|
+
|
|
10
|
+
> Auto-injected by `nax generate`
|
|
11
|
+
|
|
12
|
+
**Project:** `@nathapp/nestjs-typeorm`
|
|
13
|
+
|
|
14
|
+
**Language:** TypeScript
|
|
15
|
+
|
|
16
|
+
**Key dependencies:** @nathapp/typescript-config, typescript
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
# @nathapp/nestjs-typeorm
|
|
20
|
+
|
|
21
|
+
TypeORM integration (renamed from `@nathapp/nestjs-data`).
|
|
22
|
+
|
|
23
|
+
## Commands
|
|
24
|
+
- Test: `npx jest --config test/jest-test.json --no-coverage`
|
|
25
|
+
- Build: `npx tsc`
|
|
26
|
+
|
|
27
|
+
## Key Classes
|
|
28
|
+
- `BaseSpRepository` — stored procedure helper with `callQuery()`, recordset mapping.
|
|
29
|
+
- `TypeOrmExModule` — custom repository registration via `@CustomRepository()` decorator.
|
|
30
|
+
- `BaseTypeOrmModuleOptionFactory` — abstract factory for TypeORM connection options.
|
|
31
|
+
|
|
32
|
+
## Portable Repository
|
|
33
|
+
|
|
34
|
+
`AbstractTypeOrmRepository<TDomain, TEntity, TId>` implements
|
|
35
|
+
`IRepository<TDomain, TId>` from `@nathapp/nestjs-data`. Use it when services
|
|
36
|
+
should depend on the portable interface (decoupled from TypeORM). Subclass and
|
|
37
|
+
implement `toDomain`, `toPersistenceCreate`, `toPersistenceUpdate`. Add bespoke
|
|
38
|
+
TypeORM-specific methods (e.g. `createQueryBuilder`) on top — they are
|
|
39
|
+
automatically transaction-aware via the protected `repo` getter.
|
|
40
|
+
|
|
41
|
+
For ORM-specific power that does not need the portable contract, keep using
|
|
42
|
+
`BaseRepository` / `BaseSpRepository` — they are unrelated and remain unchanged.
|
|
43
|
+
|
|
44
|
+
### Wiring via `forCustomRepository`
|
|
45
|
+
|
|
46
|
+
`TypeOrmExModule.forCustomRepository` is the standard wiring path for all three
|
|
47
|
+
repository styles. The factory branches on the base class:
|
|
48
|
+
|
|
49
|
+
- `extends AbstractTypeOrmRepository` → `new repo(tx, entity)` from `@CustomRepository(Entity)` metadata + injected per-DataSource tx manager token
|
|
50
|
+
- `extends BaseRepository` → `new repo(dataSource)`
|
|
51
|
+
- `extends Repository<T>` → manager-getter trick + ALS retrofit (transaction-aware when `forRoot({ transaction: true })`)
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { CustomRepository, AbstractTypeOrmRepository, TypeOrmExModule } from '@nathapp/nestjs-typeorm';
|
|
55
|
+
import { Repository } from 'typeorm';
|
|
56
|
+
|
|
57
|
+
// New code: portable IRepository<User> — no manual constructor needed
|
|
58
|
+
@CustomRepository(UserEntity)
|
|
59
|
+
export class UserRepository extends AbstractTypeOrmRepository<User, UserEntity, string> {
|
|
60
|
+
protected toDomain(e: UserEntity): User { return { id: e.id, email: e.email_address, name: e.full_name }; }
|
|
61
|
+
protected toPersistenceCreate(d: User): UserEntity { /* ... */ }
|
|
62
|
+
protected toPersistenceUpdate(p: Partial<User>): Partial<UserEntity> { /* ... */ }
|
|
63
|
+
|
|
64
|
+
// Bespoke TypeORM-specific method — already tx-aware via this.repo
|
|
65
|
+
async findActiveByEmail(email: string): Promise<User | null> {
|
|
66
|
+
const e = await this.repo
|
|
67
|
+
.createQueryBuilder('u')
|
|
68
|
+
.where('u.email_address = :email AND u.status = 1', { email })
|
|
69
|
+
.getOne();
|
|
70
|
+
return e ? this.toDomain(e) : null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Legacy / coupling-explicit: extend Repository<T> directly
|
|
75
|
+
@CustomRepository(InvoiceEntity)
|
|
76
|
+
export class InvoiceRepository extends Repository<InvoiceEntity> {
|
|
77
|
+
// QueryBuilder, raw SQL, etc. — automatically participates in txManager.run()
|
|
78
|
+
// when the module is registered with forRoot({ transaction: true }).
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@Module({
|
|
82
|
+
imports: [
|
|
83
|
+
TypeOrmExModule.forRoot({ type: 'mysql', /* ... */, transaction: true }),
|
|
84
|
+
TypeOrmExModule.forCustomRepository([UserRepository, InvoiceRepository]),
|
|
85
|
+
],
|
|
86
|
+
providers: [
|
|
87
|
+
// Bind the IRepository<User> token to the concrete class.
|
|
88
|
+
{ provide: USER_REPOSITORY, useExisting: UserRepository },
|
|
89
|
+
],
|
|
90
|
+
exports: [USER_REPOSITORY],
|
|
91
|
+
})
|
|
92
|
+
export class UserModule {}
|
|
93
|
+
|
|
94
|
+
// Service depends on the portable contract:
|
|
95
|
+
@Injectable()
|
|
96
|
+
export class UserService {
|
|
97
|
+
constructor(@Inject(USER_REPOSITORY) private readonly users: IRepository<User>) {}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Multi-DataSource binding
|
|
102
|
+
|
|
103
|
+
Pass the DataSource name as the second argument to `forCustomRepository` so the
|
|
104
|
+
factory injects the matching per-DataSource tx manager token:
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
@Module({
|
|
108
|
+
imports: [
|
|
109
|
+
TypeOrmExModule.forRoot({ name: 'analytics', type: 'mysql', /* ... */, transaction: true }),
|
|
110
|
+
TypeOrmExModule.forCustomRepository([AnalyticsRepo], 'analytics'),
|
|
111
|
+
],
|
|
112
|
+
providers: [
|
|
113
|
+
{ provide: ANALYTICS_REPOSITORY, useExisting: AnalyticsRepo },
|
|
114
|
+
],
|
|
115
|
+
})
|
|
116
|
+
export class AnalyticsModule {}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Limitations
|
|
120
|
+
|
|
121
|
+
- The `AbstractTypeOrmRepository` branch instantiates with `(tx, entity)` only.
|
|
122
|
+
Subclasses that need to inject additional providers (e.g. a logger) must
|
|
123
|
+
register manually via `providers: [...]` instead of `forCustomRepository`.
|
|
124
|
+
- Legacy `@Transactional` method decorator and `BaseSpRepository.callQuery` use a
|
|
125
|
+
separate `transactionContext` ALS that is not unified with `TypeOrmTransactionManager`.
|
|
126
|
+
Out of scope; tracked as a follow-up.
|
|
127
|
+
|
|
128
|
+
## Multi-DB
|
|
129
|
+
|
|
130
|
+
Multiple TypeORM DataSources in one process are wired by repeating
|
|
131
|
+
`TypeOrmExModule.forRoot` with different `name` values. Each call publishes a
|
|
132
|
+
per-DataSource transaction manager token via `getTypeOrmTransactionManagerToken(name)`.
|
|
133
|
+
The **default** DataSource additionally aliases the global `TRANSACTION_MANAGER`
|
|
134
|
+
symbol from `@nathapp/nestjs-data`, so single-DB consumers do not change.
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
import {
|
|
138
|
+
TypeOrmExModule,
|
|
139
|
+
getTypeOrmTransactionManagerToken,
|
|
140
|
+
} from '@nathapp/nestjs-typeorm';
|
|
141
|
+
import { ITransactionManager } from '@nathapp/nestjs-data';
|
|
142
|
+
|
|
143
|
+
@Module({
|
|
144
|
+
imports: [
|
|
145
|
+
TypeOrmExModule.forRoot({ /* default DS config */, transaction: true }),
|
|
146
|
+
TypeOrmExModule.forRoot({ name: 'analytics', /* ... */, transaction: true }),
|
|
147
|
+
],
|
|
148
|
+
})
|
|
149
|
+
export class AppModule {}
|
|
150
|
+
|
|
151
|
+
@Injectable()
|
|
152
|
+
export class AnalyticsService {
|
|
153
|
+
constructor(
|
|
154
|
+
@Inject(getTypeOrmTransactionManagerToken('analytics'))
|
|
155
|
+
private readonly tx: ITransactionManager,
|
|
156
|
+
) {}
|
|
157
|
+
|
|
158
|
+
async ingest(events: Event[]) {
|
|
159
|
+
return this.tx.run(async () => {
|
|
160
|
+
// Wraps analytics-DS writes only.
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Atomicity boundary — read this carefully
|
|
167
|
+
|
|
168
|
+
A `tx.run()` on a named tx manager covers **only** that DataSource's writes. If
|
|
169
|
+
code inside `tx.run('dbA')` also writes to dbB via a different tx manager, those
|
|
170
|
+
dbB writes are **independent** — they commit/roll back on their own. There is no
|
|
171
|
+
2PC, no distributed transaction, no cross-DB atomicity.
|
|
172
|
+
|
|
173
|
+
**This is intentional.** Cross-DB consistency in microservices is solved with
|
|
174
|
+
sagas / outbox patterns, not transactions.
|
|
175
|
+
|
|
176
|
+
### Default connection convenience
|
|
177
|
+
|
|
178
|
+
For services that only ever talk to one DataSource, keep using
|
|
179
|
+
`@Inject(TRANSACTION_MANAGER)` from `@nathapp/nestjs-data`. It is registered as
|
|
180
|
+
an alias for `getTypeOrmTransactionManagerToken()` (the default DataSource)
|
|
181
|
+
automatically. No multi-DB token churn for single-DB code.
|
|
182
|
+
|
|
183
|
+
## Gotchas
|
|
184
|
+
- Pagination types (`Page`, `PageOption`) moved to `@nathapp/nestjs-common` — import from there.
|
|
185
|
+
- Uses `import * as dayjs` (NOT default import) — do NOT add `esModuleInterop` to this package's tsconfig.
|
|
186
|
+
- Jest config omits `esModuleInterop` intentionally (unlike other packages).
|
|
@@ -1,16 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var _a;
|
|
5
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
37
|
exports.DateColumn = exports.UpdateDate = exports.CreateDate = exports.NullableDateString = exports.toDateString = void 0;
|
|
7
|
-
const
|
|
38
|
+
const dayjsModule = __importStar(require("dayjs"));
|
|
8
39
|
const typeorm_1 = require("typeorm");
|
|
9
40
|
const common_1 = require("@nestjs/common");
|
|
10
41
|
const class_transformer_1 = require("class-transformer");
|
|
42
|
+
const dayjs = (_a = dayjsModule.default) !== null && _a !== void 0 ? _a : dayjsModule;
|
|
11
43
|
const DEFAULT_DATE_FORMAT = "YYYY-MM-DD HH:mm:ss";
|
|
12
44
|
const toDateString = (value, format) => {
|
|
13
|
-
return value ? (
|
|
45
|
+
return value ? dayjs(value).format(format || DEFAULT_DATE_FORMAT) : value;
|
|
14
46
|
};
|
|
15
47
|
exports.toDateString = toDateString;
|
|
16
48
|
const NullableDateString = (options = { toPlainOnly: true }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-column.decorator.js","sourceRoot":"","sources":["../../lib/decorator/date-column.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"date-column.decorator.js","sourceRoot":"","sources":["../../lib/decorator/date-column.decorator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAoC;AACpC,qCAAoF;AACpF,2CAAiD;AACjD,yDAAgE;AAGhE,MAAM,KAAK,GAAuC,MAAC,WAAmB,CAAC,OAAO,mCAAI,WAAW,CAAC;AAE9F,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAE3C,MAAM,YAAY,GAAG,CAAC,KAAW,EAAE,MAAe,EAAE,EAAE;IAC3D,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC5E,CAAC,CAAC;AAFW,QAAA,YAAY,gBAEvB;AAEK,MAAM,kBAAkB,GAAG,CAAC,UAA4B,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,EAAE;IACtF,OAAO,mBAAmB,CACxB,IAAA,6BAAS,EAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAA,oBAAY,EAAC,KAAK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E;YACX,EAAE,EAAE,CAAC,KAAW,EAAE,EAAE,CAAC,IAAA,oBAAY,EAAC,KAAK,EAAE,MAAM,CAAC;YAChD,IAAI,EAAE,CAAC,KAAU,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC;SACtC;QACD,GAAG,OAAO;QACV,IAAI,EAAE,UAAU;KACjB,CAAC,CACH,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,UAAU,cAWrB"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DatabaseErrorMapper = void 0;
|
|
4
4
|
const nestjs_common_1 = require("@nathapp/nestjs-common");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
5
6
|
class DatabaseErrorMapper {
|
|
6
7
|
static mapToAppException(error) {
|
|
7
8
|
const errorCode = error.code;
|
|
@@ -10,15 +11,16 @@ class DatabaseErrorMapper {
|
|
|
10
11
|
const mapping = errorCode ? this.ERROR_MAPPINGS[errorCode] : undefined;
|
|
11
12
|
const httpStatus = (mapping === null || mapping === void 0 ? void 0 : mapping.httpStatus) || 500;
|
|
12
13
|
const appExceptionCode = errorNumber || 9999;
|
|
13
|
-
|
|
14
|
+
this.logger.error('Database error', {
|
|
14
15
|
originalError: errorMessage,
|
|
15
16
|
dbCode: errorCode,
|
|
16
17
|
dbErrno: errorNumber,
|
|
17
|
-
};
|
|
18
|
-
return new nestjs_common_1.AppException(appExceptionCode,
|
|
18
|
+
});
|
|
19
|
+
return new nestjs_common_1.AppException(appExceptionCode, {}, 'database', httpStatus);
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
exports.DatabaseErrorMapper = DatabaseErrorMapper;
|
|
23
|
+
DatabaseErrorMapper.logger = new common_1.Logger(DatabaseErrorMapper.name);
|
|
22
24
|
DatabaseErrorMapper.ERROR_MAPPINGS = {
|
|
23
25
|
'ER_DUP_ENTRY': { httpStatus: 409, message: 'Duplicate entry detected' },
|
|
24
26
|
'ER_NO_REFERENCED_ROW_2': { httpStatus: 400, message: 'Foreign key constraint violation' },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database-error.mapper.js","sourceRoot":"","sources":["../../lib/errors/database-error.mapper.ts"],"names":[],"mappings":";;;AAAA,0DAAsD;
|
|
1
|
+
{"version":3,"file":"database-error.mapper.js","sourceRoot":"","sources":["../../lib/errors/database-error.mapper.ts"],"names":[],"mappings":";;;AAAA,0DAAsD;AACtD,2CAAwC;AAexC,MAAa,mBAAmB;IAmC9B,MAAM,CAAC,iBAAiB,CAAC,KAAU;QACjC,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC;QAC7B,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC;QAChC,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,IAAI,wBAAwB,CAAC;QAG/D,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAGvE,MAAM,UAAU,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU,KAAI,GAAG,CAAC;QAG9C,MAAM,gBAAgB,GAAG,WAAW,IAAI,IAAI,CAAC;QAG7C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,EAAE;YAClC,aAAa,EAAE,YAAY;YAC3B,MAAM,EAAE,SAAS;YACjB,OAAO,EAAE,WAAW;SACrB,CAAC,CAAC;QAEH,OAAO,IAAI,4BAAY,CACrB,gBAAgB,EAChB,EAAE,EACF,UAAU,EACV,UAAU,CACX,CAAC;IACJ,CAAC;;AA9DH,kDA+DC;AA9DyB,0BAAM,GAAG,IAAI,eAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;AAE9C,kCAAc,GAAiC;IAErE,cAAc,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,0BAA0B,EAAE;IAGxE,wBAAwB,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,kCAAkC,EAAE;IAC1F,wBAAwB,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,iCAAiC,EAAE;IAGzF,WAAW,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,6BAA6B,EAAE;IACxE,cAAc,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,6BAA6B,EAAE;IAC3E,WAAW,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,yBAAyB,EAAE;IAGpE,wBAAwB,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,wBAAwB,EAAE;IAChF,0BAA0B,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,wBAAwB,EAAE;IAGlF,gBAAgB,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,kBAAkB,EAAE;IAClE,kBAAkB,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,sBAAsB,EAAE;IACxE,oBAAoB,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,gBAAgB,EAAE;IAGpE,kBAAkB,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,4BAA4B,EAAE;IAC9E,sBAAsB,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,4BAA4B,EAAE;CACnF,CAAC"}
|
|
@@ -25,8 +25,7 @@ async function paginateRepository(repository, options, searchOptions, transformO
|
|
|
25
25
|
}
|
|
26
26
|
async function paginateQueryBuilder(queryBuilder, options, transformOptions) {
|
|
27
27
|
const { take, skip } = (0, nestjs_common_1.resolvePageOption)(options);
|
|
28
|
-
const total = await queryBuilder.
|
|
29
|
-
const result = await queryBuilder.skip(skip).take(take).getMany();
|
|
28
|
+
const [result, total] = await queryBuilder.skip(skip).take(take).getManyAndCount();
|
|
30
29
|
return new nestjs_common_1.Page(options, total, result, transformOptions);
|
|
31
30
|
}
|
|
32
31
|
async function paginateMongoRepository(repository, options, searchOptions, transformOptions) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paginate.js","sourceRoot":"","sources":["../../lib/pagination/paginate.ts"],"names":[],"mappings":";;AAcA,4BA8BC;AA5CD,0DAIgC;AAEhC,qCAMiB;AAEV,KAAK,UAAU,QAAQ,CAC5B,wBAGyB,EACzB,OAAoB,EACpB,aAAkC,EAClC,gBAAsC;IAEtC,IAAI,wBAAwB,YAAY,yBAAe,EAAE,CAAC;QACxD,OAAO,uBAAuB,CAC5B,wBAAwB,EACxB,OAAO,EACP,aAAa,EACb,gBAAgB,CACjB,CAAC;IACJ,CAAC;SAAM,IAAI,wBAAwB,YAAY,oBAAU,EAAE,CAAC;QAC1D,OAAO,kBAAkB,CACvB,wBAAwB,EACxB,OAAO,EACP,aAAa,EACb,gBAAgB,CACjB,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,oBAAoB,CACzB,wBAAwB,EACxB,OAAO,EACP,gBAAgB,CACjB,CAAC;IACJ,CAAC;AACH,CAAC;AAED,KAAK,UAAU,kBAAkB,CAC/B,UAAyB,EACzB,OAAoB,EACpB,aAAkC,EAClC,gBAAsC;IAEtC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAA,iCAAiB,EAAC,OAAO,CAAC,CAAC;IAClD,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,MAAM,UAAU,CAAC,YAAY,CAAC;QACpD,IAAI;QACJ,IAAI;QACJ,GAAG,aAAa;KACjB,CAAC,CAAC;IACH,OAAO,IAAI,oBAAI,CAAI,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAC/D,CAAC;AAED,KAAK,UAAU,oBAAoB,CACjC,YAAmC,EACnC,OAAoB,EACpB,gBAAsC;IAEtC,MAAM,EAAE,IAAI,EAAE,IA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D,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACnF,OAAO,IAAI,oBAAI,CAAI,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAC/D,CAAC;AAED,KAAK,UAAU,uBAAuB,CACpC,UAA8B,EAC9B,OAAoB,EACpB,aAAkC,EAClC,gBAAsC;IAEtC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAA,iCAAiB,EAAC,OAAO,CAAC,CAAC;IAClD,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,MAAM,UAAU,CAAC,YAAY,CAAC;QACpD,IAAI;QACJ,IAAI;QACJ,GAAG,aAAa;KACjB,CAAC,CAAC;IAEH,OAAO,IAAI,oBAAI,CAAI,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -53,12 +53,15 @@ let AbstractTypeOrmRepository = class AbstractTypeOrmRepository {
|
|
|
53
53
|
}
|
|
54
54
|
async update(id, patch) {
|
|
55
55
|
const persistencePatch = this.toPersistenceUpdate(patch);
|
|
56
|
-
await this.repo.update(id, persistencePatch);
|
|
57
|
-
|
|
56
|
+
const result = await this.repo.update(id, persistencePatch);
|
|
57
|
+
if (!result.affected || result.affected === 0) {
|
|
58
|
+
throw new Error(`Entity not found after update: id=${String(id)}`);
|
|
59
|
+
}
|
|
60
|
+
const updated = await this.findById(id);
|
|
58
61
|
if (!updated) {
|
|
59
62
|
throw new Error(`Entity not found after update: id=${String(id)}`);
|
|
60
63
|
}
|
|
61
|
-
return
|
|
64
|
+
return updated;
|
|
62
65
|
}
|
|
63
66
|
async delete(id) {
|
|
64
67
|
await this.repo.delete(id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract-typeorm.repository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,EAAE,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAO;QAClB,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAS,CAAC,CAAC;IACpC,CAAC;CACF,CAAA;AArEqB,8DAAyB;oCAAzB,yBAAyB;IAM1C,WAAA,IAAA,eAAM,EAAC,iCAAmB,CAAC,CAAA;;GANV,yBAAyB,CAqE9C"}
|
|
@@ -39,13 +39,13 @@ class BaseSpRepository extends BaseRepository {
|
|
|
39
39
|
}
|
|
40
40
|
return [];
|
|
41
41
|
}
|
|
42
|
-
const
|
|
43
|
-
if (1 <
|
|
44
|
-
const
|
|
45
|
-
for (let i = 0;
|
|
46
|
-
const recordset =
|
|
42
|
+
const recordsets = results.slice(0, -1);
|
|
43
|
+
if (1 < recordsets.length) {
|
|
44
|
+
const mapped = [];
|
|
45
|
+
for (let i = 0; recordsets.length > i; i++) {
|
|
46
|
+
const recordset = recordsets[i];
|
|
47
47
|
if (!rename) {
|
|
48
|
-
|
|
48
|
+
mapped.push(recordset);
|
|
49
49
|
}
|
|
50
50
|
else {
|
|
51
51
|
const result = [];
|
|
@@ -53,12 +53,12 @@ class BaseSpRepository extends BaseRepository {
|
|
|
53
53
|
const record = recordset[i];
|
|
54
54
|
result.push(this.renameKey(record, rename));
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
mapped.push(result);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
return
|
|
59
|
+
return mapped;
|
|
60
60
|
}
|
|
61
|
-
const recordset =
|
|
61
|
+
const recordset = recordsets[0];
|
|
62
62
|
if (objectifyForSignleRecord) {
|
|
63
63
|
if (1 == recordset.length) {
|
|
64
64
|
if (rename) {
|
|
@@ -125,24 +125,22 @@ class BaseSpRepository extends BaseRepository {
|
|
|
125
125
|
parameters,
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
|
-
renameKey(object, rename, depth) {
|
|
129
|
-
|
|
128
|
+
renameKey(object, rename, depth = 0) {
|
|
129
|
+
const result = {};
|
|
130
|
+
for (const key of Object.keys(object)) {
|
|
130
131
|
try {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
case 'Object':
|
|
140
|
-
case 'Array':
|
|
141
|
-
this.renameKey(object[key], rename, depth + 1);
|
|
132
|
+
let value = object[key];
|
|
133
|
+
if (value && 'object' === typeof value) {
|
|
134
|
+
const type = value.constructor ? value.constructor.name : '';
|
|
135
|
+
if (type === 'Object') {
|
|
136
|
+
value = this.renameKey(value, rename, depth + 1);
|
|
137
|
+
}
|
|
138
|
+
else if (type === 'Array') {
|
|
139
|
+
value = value.map((item) => item && typeof item === 'object' ? this.renameKey(item, rename, depth + 1) : item);
|
|
142
140
|
}
|
|
143
141
|
}
|
|
144
142
|
const newKey = rename(key, depth, object);
|
|
145
|
-
|
|
143
|
+
result[newKey] = value;
|
|
146
144
|
}
|
|
147
145
|
catch (error) {
|
|
148
146
|
if (error && typeof error === 'object') {
|
|
@@ -152,22 +150,7 @@ class BaseSpRepository extends BaseRepository {
|
|
|
152
150
|
throw error;
|
|
153
151
|
}
|
|
154
152
|
}
|
|
155
|
-
return
|
|
156
|
-
}
|
|
157
|
-
changeKey(object, name, newName) {
|
|
158
|
-
if (!object || name == newName) {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
if ('object' === typeof object) {
|
|
162
|
-
const item = Object.getOwnPropertyDescriptor(object, name);
|
|
163
|
-
if (item) {
|
|
164
|
-
Object.defineProperty(object, newName, item);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
object[newName] = object[name];
|
|
169
|
-
}
|
|
170
|
-
delete object[name];
|
|
153
|
+
return result;
|
|
171
154
|
}
|
|
172
155
|
}
|
|
173
156
|
exports.BaseSpRepository = BaseSpRepository;
|
|
@@ -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GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC1C,CAAC;gBACD,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAjOD,4CAiOC"}
|
|
@@ -13,6 +13,7 @@ export type TypeOrmExModuleAsyncOptions = TypeOrmModuleAsyncOptions & {
|
|
|
13
13
|
export declare class TypeOrmExModule {
|
|
14
14
|
static forRoot(options?: TypeOrmExModuleOptions): DynamicModule;
|
|
15
15
|
static forRootAsync(options?: TypeOrmExModuleAsyncOptions): DynamicModule;
|
|
16
|
+
private static applyTransactionProviders;
|
|
16
17
|
static forFeature(entities?: EntityClassOrSchema[], dataSource?: string): DynamicModule;
|
|
17
18
|
static forCustomRepository<T extends new (...args: any[]) => any>(repositories: T[], dataSource?: DataSource | DataSourceOptions | string): DynamicModule;
|
|
18
19
|
private static getTxTokenForCustomRepository;
|
|
@@ -21,27 +21,8 @@ class TypeOrmExModule {
|
|
|
21
21
|
imports: [typeorm_1.TypeOrmModule.forRoot(sanitizedOptions)],
|
|
22
22
|
};
|
|
23
23
|
if (transaction) {
|
|
24
|
-
const als = new async_hooks_1.AsyncLocalStorage();
|
|
25
24
|
const dataSourceName = typeOrmOptions.name || exports.DEFAULT_DATA_SOURCE_NAME;
|
|
26
|
-
|
|
27
|
-
const namedTxToken = (0, typeorm_transaction_manager_token_1.getTypeOrmTransactionManagerToken)(dataSourceName);
|
|
28
|
-
const namedAlsToken = (0, typeorm_transaction_constants_1.getTypeOrmTransactionAlsToken)(dataSourceName);
|
|
29
|
-
const isDefaultConnection = dataSourceName === exports.DEFAULT_DATA_SOURCE_NAME;
|
|
30
|
-
const alsProvider = {
|
|
31
|
-
provide: namedAlsToken,
|
|
32
|
-
useValue: als,
|
|
33
|
-
};
|
|
34
|
-
const transactionManagerProvider = {
|
|
35
|
-
provide: namedTxToken,
|
|
36
|
-
inject: [dataSourceToken],
|
|
37
|
-
useFactory: (dataSource) => new typeorm_transaction_manager_1.TypeOrmTransactionManager(dataSource, als),
|
|
38
|
-
};
|
|
39
|
-
result.providers = [alsProvider, transactionManagerProvider];
|
|
40
|
-
result.exports = [namedTxToken, namedAlsToken];
|
|
41
|
-
if (isDefaultConnection) {
|
|
42
|
-
result.providers.push({ provide: nestjs_data_1.TRANSACTION_MANAGER, useExisting: namedTxToken });
|
|
43
|
-
result.exports.push(nestjs_data_1.TRANSACTION_MANAGER);
|
|
44
|
-
}
|
|
25
|
+
this.applyTransactionProviders(result, dataSourceName);
|
|
45
26
|
}
|
|
46
27
|
return result;
|
|
47
28
|
}
|
|
@@ -52,30 +33,33 @@ class TypeOrmExModule {
|
|
|
52
33
|
imports: [typeorm_1.TypeOrmModule.forRootAsync(typeOrmAsyncOptions)],
|
|
53
34
|
};
|
|
54
35
|
if (transaction) {
|
|
55
|
-
const als = new async_hooks_1.AsyncLocalStorage();
|
|
56
36
|
const dataSourceName = typeOrmAsyncOptions.name || exports.DEFAULT_DATA_SOURCE_NAME;
|
|
57
|
-
|
|
58
|
-
const namedTxToken = (0, typeorm_transaction_manager_token_1.getTypeOrmTransactionManagerToken)(dataSourceName);
|
|
59
|
-
const namedAlsToken = (0, typeorm_transaction_constants_1.getTypeOrmTransactionAlsToken)(dataSourceName);
|
|
60
|
-
const isDefaultConnection = dataSourceName === exports.DEFAULT_DATA_SOURCE_NAME;
|
|
61
|
-
const alsProvider = {
|
|
62
|
-
provide: namedAlsToken,
|
|
63
|
-
useValue: als,
|
|
64
|
-
};
|
|
65
|
-
const transactionManagerProvider = {
|
|
66
|
-
provide: namedTxToken,
|
|
67
|
-
inject: [dataSourceToken],
|
|
68
|
-
useFactory: (dataSource) => new typeorm_transaction_manager_1.TypeOrmTransactionManager(dataSource, als),
|
|
69
|
-
};
|
|
70
|
-
result.providers = [alsProvider, transactionManagerProvider];
|
|
71
|
-
result.exports = [namedTxToken, namedAlsToken];
|
|
72
|
-
if (isDefaultConnection) {
|
|
73
|
-
result.providers.push({ provide: nestjs_data_1.TRANSACTION_MANAGER, useExisting: namedTxToken });
|
|
74
|
-
result.exports.push(nestjs_data_1.TRANSACTION_MANAGER);
|
|
75
|
-
}
|
|
37
|
+
this.applyTransactionProviders(result, dataSourceName);
|
|
76
38
|
}
|
|
77
39
|
return result;
|
|
78
40
|
}
|
|
41
|
+
static applyTransactionProviders(result, dataSourceName) {
|
|
42
|
+
const als = new async_hooks_1.AsyncLocalStorage();
|
|
43
|
+
const dataSourceToken = (0, typeorm_1.getDataSourceToken)(dataSourceName === exports.DEFAULT_DATA_SOURCE_NAME ? undefined : dataSourceName);
|
|
44
|
+
const namedTxToken = (0, typeorm_transaction_manager_token_1.getTypeOrmTransactionManagerToken)(dataSourceName);
|
|
45
|
+
const namedAlsToken = (0, typeorm_transaction_constants_1.getTypeOrmTransactionAlsToken)(dataSourceName);
|
|
46
|
+
const isDefaultConnection = dataSourceName === exports.DEFAULT_DATA_SOURCE_NAME;
|
|
47
|
+
const alsProvider = {
|
|
48
|
+
provide: namedAlsToken,
|
|
49
|
+
useValue: als,
|
|
50
|
+
};
|
|
51
|
+
const transactionManagerProvider = {
|
|
52
|
+
provide: namedTxToken,
|
|
53
|
+
inject: [dataSourceToken],
|
|
54
|
+
useFactory: (dataSource) => new typeorm_transaction_manager_1.TypeOrmTransactionManager(dataSource, als),
|
|
55
|
+
};
|
|
56
|
+
result.providers = [alsProvider, transactionManagerProvider];
|
|
57
|
+
result.exports = [namedTxToken, namedAlsToken];
|
|
58
|
+
if (isDefaultConnection) {
|
|
59
|
+
result.providers.push({ provide: nestjs_data_1.TRANSACTION_MANAGER, useExisting: namedTxToken });
|
|
60
|
+
result.exports.push(nestjs_data_1.TRANSACTION_MANAGER);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
79
63
|
static forFeature(entities, dataSource = exports.DEFAULT_DATA_SOURCE_NAME) {
|
|
80
64
|
return {
|
|
81
65
|
module: TypeOrmExModule,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeorm-ex.module.js","sourceRoot":"","sources":["../../lib/typeorm/typeorm-ex.module.ts"],"names":[],"mappings":";;;AACA,6CAAqH;AAErH,6CAAgD;AAChD,4CAA4D;AAC5D,mDAAyD;AACzD,8CAA+C;AAC/C,2FAAsF;AACtF,4FAAuF;AACvF,wGAAqG;AACrG,gGAAsH;AACtH,sDAA2D;AAE9C,QAAA,wBAAwB,GAAG,SAAS,CAAC;AAoDlD,MAAa,eAAe;IAGnB,MAAM,CAAC,OAAO,CAAC,UAAkC,EAA4B;QAClF,MAAM,EAAE,WAAW,EAAE,GAAG,cAAc,EAAE,GAAG,OAAO,CAAC;QACnD,MAAM,gBAAgB,GAAG,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;QAE9D,MAAM,MAAM,GAAkB;YAC5B,MAAM,EAAE,eAAe;YACvB,OAAO,EAAE,CAAC,uBAAa,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;SACnD,CAAC;QAEF,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,
|
|
1
|
+
{"version":3,"file":"typeorm-ex.module.js","sourceRoot":"","sources":["../../lib/typeorm/typeorm-ex.module.ts"],"names":[],"mappings":";;;AACA,6CAAqH;AAErH,6CAAgD;AAChD,4CAA4D;AAC5D,mDAAyD;AACzD,8CAA+C;AAC/C,2FAAsF;AACtF,4FAAuF;AACvF,wGAAqG;AACrG,gGAAsH;AACtH,sDAA2D;AAE9C,QAAA,wBAAwB,GAAG,SAAS,CAAC;AAoDlD,MAAa,eAAe;IAGnB,MAAM,CAAC,OAAO,CAAC,UAAkC,EAA4B;QAClF,MAAM,EAAE,WAAW,EAAE,GAAG,cAAc,EAAE,GAAG,OAAO,CAAC;QACnD,MAAM,gBAAgB,GAAG,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;QAE9D,MAAM,MAAM,GAAkB;YAC5B,MAAM,EAAE,eAAe;YACvB,OAAO,EAAE,CAAC,uBAAa,CAAC,OAAO,CAAC,gBAAgB,CAA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|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nathapp/nestjs-typeorm",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "@nathapp/nestjs-typeorm",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rimraf dist/ .turbo/",
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
"test": "jest --config ./test/jest-test.json",
|
|
10
10
|
"test:cov": "jest --config ./test/jest-test.json --coverage",
|
|
11
11
|
"test:watch": "jest --config ./test/jest-test.json --watch",
|
|
12
|
-
"lint": "eslint -c .eslintrc.js"
|
|
12
|
+
"lint": "eslint -c .eslintrc.js",
|
|
13
|
+
"type-check": "tsc --noEmit -p tsconfig.json",
|
|
14
|
+
"lint:fix": "eslint -c .eslintrc.js --fix"
|
|
13
15
|
},
|
|
14
16
|
"author": "William Khoo",
|
|
15
17
|
"license": "ISC",
|
|
@@ -19,8 +21,8 @@
|
|
|
19
21
|
"lib": "lib"
|
|
20
22
|
},
|
|
21
23
|
"dependencies": {
|
|
22
|
-
"@nathapp/nestjs-common": "^3.
|
|
23
|
-
"@nathapp/nestjs-data": "^3.
|
|
24
|
+
"@nathapp/nestjs-common": "^3.3.0",
|
|
25
|
+
"@nathapp/nestjs-data": "^3.3.0",
|
|
24
26
|
"dayjs": "^1.11.13"
|
|
25
27
|
},
|
|
26
28
|
"devDependencies": {
|