@nathapp/nestjs-typeorm 3.2.2 → 4.0.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/testing/testing-utils.js +2 -2
- package/dist/testing/testing-utils.js.map +1 -1
- package/dist/typeorm/typeorm-ex.module.d.ts +3 -2
- package/dist/typeorm/typeorm-ex.module.js.map +1 -1
- package/package.json +11 -6
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).
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createInMemoryPgDataSource = exports.createInMemorySqliteDataSource = exports.resolveEmptySingleResult = exports.resolveQueryArrayResult = exports.resolveQuerySingleResult = exports.sqlQueryResult = void 0;
|
|
4
4
|
const typeorm_1 = require("typeorm");
|
|
5
|
-
const
|
|
5
|
+
const nestjs_common_1 = require("@nathapp/nestjs-common");
|
|
6
6
|
exports.sqlQueryResult = {
|
|
7
7
|
fieldCount: 0,
|
|
8
8
|
affectedRows: 0,
|
|
@@ -30,7 +30,7 @@ const createInMemorySqliteDataSource = async (options) => {
|
|
|
30
30
|
exports.createInMemorySqliteDataSource = createInMemorySqliteDataSource;
|
|
31
31
|
const createInMemoryPgDataSource = (options) => {
|
|
32
32
|
const dbOptions = Object.assign({}, { type: "postgres", synchronize: true, }, options);
|
|
33
|
-
const pgMem = (0,
|
|
33
|
+
const pgMem = (0, nestjs_common_1.loadPackage)('pg-mem', 'createInMemoryPgDataSource', () => require('pg-mem'));
|
|
34
34
|
const db = pgMem.newDb();
|
|
35
35
|
db.public.registerFunction({
|
|
36
36
|
name: 'current_database',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing-utils.js","sourceRoot":"","sources":["../../lib/testing/testing-utils.ts"],"names":[],"mappings":";;;AAAA,qCAAwD;AACxD,
|
|
1
|
+
{"version":3,"file":"testing-utils.js","sourceRoot":"","sources":["../../lib/testing/testing-utils.ts"],"names":[],"mappings":";;;AAAA,qCAAwD;AACxD,0DAAqD;AAExC,QAAA,cAAc,GAAG;IAC5B,UAAU,EAAE,CAAC;IACb,YAAY,EAAE,CAAC;IACf,QAAQ,EAAE,CAAC;IACX,IAAI,EAAE,EAAE;IACR,YAAY,EAAE,EAAE;IAChB,aAAa,EAAE,CAAC;CACjB,CAAC;AAEK,MAAM,wBAAwB,GAAG,CACtC,MAAW,EACX,iBAAiB,GAAG,sBAAc,EAClC,EAAE;IACF,OAAO,CAAC,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC,CAAC;AACvC,CAAC,CAAC;AALW,QAAA,wBAAwB,4BAKnC;AAEK,MAAM,uBAAuB,GAAG,CACrC,OAAc,EACd,iBAAiB,GAAG,sBAAc,EAClC,EAAE;IACF,OAAO,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;AACtC,CAAC,CAAC;AALW,QAAA,uBAAuB,2BAKlC;AAEK,MAAM,wBAAwB,GAAG,CACtC,iBAAiB,GAAG,sBAAc,EAClC,EAAE;IACF,OAAO,CAAC,EAAE,EAAE,iBAAiB,CAAC,CAAC;AACjC,CAAC,CAAC;AAJW,QAAA,wBAAwB,4BAInC;AAEK,MAAM,8BAA8B,GAAG,KAAK,EAAE,OAA2B,EAAuB,EAAE;IACvG,MAAM,SAAS,GAAsB,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,GAAG,EAAE,OAAO,CAAC,CAAC;IAC3G,OAAO,IAAI,oBAAU,CAAC,SAAS,CAAC,CAAC;AACnC,CAAC,CAAA;AAHY,QAAA,8BAA8B,kCAG1C;AAEM,MAAM,0BAA0B,GAAG,CAAC,OAA2B,EAAuB,EAAE;IAC7F,MAAM,SAAS,GAAsB,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,GAAG,EAAE,OAAO,CAAC,CAAC;IAC1G,MAAM,KAAK,GAAG,IAAA,2BAAW,EAAC,QAAQ,EAAE,4BAA4B,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC3F,MAAM,EAAE,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;IACzB,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC;QACzB,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,EAAE;QACR,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI;QAC5B,cAAc,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,EAAE;KAC1C,CAAC,CAAC;IAEH,OAAO,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AACxD,CAAC,CAAA;AAZY,QAAA,0BAA0B,8BAYtC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DynamicModule } from "@nestjs/common";
|
|
2
|
-
import { TypeOrmModuleAsyncOptions, TypeOrmModuleOptions } from "@nestjs/typeorm";
|
|
2
|
+
import { TypeOrmModule, TypeOrmModuleAsyncOptions, TypeOrmModuleOptions } from "@nestjs/typeorm";
|
|
3
3
|
import { DataSource, DataSourceOptions } from "typeorm";
|
|
4
|
-
|
|
4
|
+
type EntityClassOrSchema = NonNullable<Parameters<typeof TypeOrmModule.forFeature>[0]>[number];
|
|
5
5
|
export declare const DEFAULT_DATA_SOURCE_NAME = "default";
|
|
6
6
|
export type SupportedConnectionType = "mysql" | "mariadb" | "mongodb" | "postgres";
|
|
7
7
|
export type TypeOrmExModuleOptions = TypeOrmModuleOptions & {
|
|
@@ -21,3 +21,4 @@ export declare class TypeOrmExModule {
|
|
|
21
21
|
private static getCustomRepositoryDataSourceName;
|
|
22
22
|
private static sanitizeOptions;
|
|
23
23
|
}
|
|
24
|
+
export {};
|
|
@@ -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;
|
|
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;AAG9C,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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1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nathapp/nestjs-typeorm",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "@nathapp/nestjs-typeorm",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rimraf dist/ .turbo/",
|
|
@@ -9,18 +9,23 @@
|
|
|
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",
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
20
|
+
},
|
|
16
21
|
"types": "dist/index.d.ts",
|
|
17
22
|
"main": "dist/index.js",
|
|
18
23
|
"directories": {
|
|
19
24
|
"lib": "lib"
|
|
20
25
|
},
|
|
21
26
|
"dependencies": {
|
|
22
|
-
"@nathapp/nestjs-common": "^
|
|
23
|
-
"@nathapp/nestjs-data": "^
|
|
27
|
+
"@nathapp/nestjs-common": "^4.0.0",
|
|
28
|
+
"@nathapp/nestjs-data": "^4.0.0",
|
|
24
29
|
"dayjs": "^1.11.13"
|
|
25
30
|
},
|
|
26
31
|
"devDependencies": {
|
|
@@ -30,8 +35,8 @@
|
|
|
30
35
|
"typescript": "^5"
|
|
31
36
|
},
|
|
32
37
|
"peerDependencies": {
|
|
33
|
-
"@nathapp/nestjs-common": "^
|
|
34
|
-
"@nestjs/typeorm": "^
|
|
38
|
+
"@nathapp/nestjs-common": "^4.0.0-rc.0",
|
|
39
|
+
"@nestjs/typeorm": "^10.0.0 || ^11.0.0 || ^12.0.0",
|
|
35
40
|
"pg-mem": "*",
|
|
36
41
|
"typeorm": "^0.3.27",
|
|
37
42
|
"typeorm-naming-strategies": "^4.1.0"
|