@nestjs-transactional/outbox-typeorm 1.0.0-alpha.3 → 1.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/README.md +102 -301
- package/dist/module/outbox-typeorm.module.d.ts +8 -8
- package/dist/module/outbox-typeorm.module.js +4 -4
- package/dist/module/outbox-typeorm.module.js.map +1 -1
- package/dist/repository/typeorm-event-publication.repository.js +1 -3
- package/dist/repository/typeorm-event-publication.repository.js.map +1 -1
- package/dist/schema/schema-initializer.js.map +1 -1
- package/package.json +18 -12
package/README.md
CHANGED
|
@@ -1,363 +1,164 @@
|
|
|
1
1
|
# @nestjs-transactional/outbox-typeorm
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@nestjs-transactional/outbox-typeorm)
|
|
4
4
|
[](https://github.com/igorgolovanov/nestjs-transactional/blob/main/LICENSE)
|
|
5
5
|
|
|
6
|
-
TypeORM
|
|
7
|
-
[`@nestjs-transactional/outbox`](
|
|
8
|
-
`event_publication` table schema, a TypeORM-backed implementation of
|
|
9
|
-
the `EventPublicationRepository` SPI, and (in a later iteration) the
|
|
10
|
-
NestJS module wiring.
|
|
11
|
-
|
|
12
|
-
## Status
|
|
13
|
-
|
|
14
|
-
Alpha. Public API may change between 0.x releases. Current shape:
|
|
15
|
-
|
|
16
|
-
- `EventPublicationEntity` / `EventPublicationArchiveEntity` schema
|
|
17
|
-
with all four indexes for worker / operator / cleanup paths.
|
|
18
|
-
- `TypeOrmEventPublicationRepository` integrates through the
|
|
19
|
-
transparent transactional repository patches in
|
|
20
|
-
[`@nestjs-transactional/typeorm`](../typeorm) — every read and
|
|
21
|
-
write commits atomically with the business transaction.
|
|
22
|
-
- `OutboxTypeOrmModule.forRoot({ dataSource?, isDefault? })` and
|
|
23
|
-
`forRootAsync({...})` — DataSource is resolved from DI via
|
|
24
|
-
`@nestjs/typeorm`'s `getDataSourceToken(name)`, mirroring
|
|
25
|
-
`TypeOrmTransactionalModule`.
|
|
26
|
-
- `SchemaInitializer` for development-time auto-init plus the
|
|
27
|
-
shipped TypeORM migration `CreateEventPublication1700000000000`.
|
|
28
|
-
|
|
29
|
-
Design notes: [`docs/roadmap/README.md`](../../docs/roadmap/README.md),
|
|
30
|
-
[ADR-006](../../docs/adr/006-outbox-pattern.md),
|
|
31
|
-
[ADR-019](../../docs/adr/019-outbox-multi-forroot-pattern.md).
|
|
32
|
-
|
|
33
|
-
## What ships today
|
|
34
|
-
|
|
35
|
-
### Entities
|
|
36
|
-
|
|
37
|
-
- `EventPublicationEntity` (`event_publication`): the hot queue. Four
|
|
38
|
-
indexes cover the worker, operator, and cleanup paths:
|
|
39
|
-
- `(status, publicationDate)` — `findReadyForProcessing`,
|
|
40
|
-
`findStale`.
|
|
41
|
-
- `(status, listenerId)` — per-listener retries.
|
|
42
|
-
- `(eventType)` — operator queries and event externalization.
|
|
43
|
-
- `(completionDate)` — `findCompleted(olderThan)` and
|
|
44
|
-
`deleteCompleted(olderThan)`.
|
|
45
|
-
`status` is `varchar(32)` rather than a Postgres `enum`, to keep new
|
|
46
|
-
lifecycle states from forcing a type migration.
|
|
47
|
-
|
|
48
|
-
- `EventPublicationArchiveEntity` (`event_publication_archive`): the
|
|
49
|
-
cold audit trail used by the `ARCHIVE` completion mode. Same fields
|
|
50
|
-
as `EventPublicationEntity` except `completionDate` is non-nullable
|
|
51
|
-
— rows only arrive here after having completed.
|
|
52
|
-
|
|
53
|
-
### Repository
|
|
54
|
-
|
|
55
|
-
`TypeOrmEventPublicationRepository` implements
|
|
56
|
-
`EventPublicationRepository` from `outbox`. Highlights:
|
|
57
|
-
|
|
58
|
-
- Every read and write goes through the ambient
|
|
59
|
-
`EntityManager` resolved by
|
|
60
|
-
`@nestjs-transactional/typeorm`'s `getCurrentEntityManager`, so
|
|
61
|
-
publication rows commit atomically with the business data when the
|
|
62
|
-
caller is inside a `@Transactional()` scope.
|
|
63
|
-
- `tryClaim` issues a single conditional `UPDATE`
|
|
64
|
-
(`WHERE id = :id AND status IN (PUBLISHED, RESUBMITTED)`) and
|
|
65
|
-
returns whether the row was actually transitioned — atomic under
|
|
66
|
-
concurrent workers.
|
|
67
|
-
- `findReadyForProcessing` uses
|
|
68
|
-
`SELECT ... FOR UPDATE SKIP LOCKED` so multiple workers can poll
|
|
69
|
-
without fighting for the same rows.
|
|
70
|
-
- `archiveCompleted` copies the row into
|
|
71
|
-
`event_publication_archive` and then deletes it from the hot queue
|
|
72
|
-
— atomicity comes from the ambient transaction the processor wraps
|
|
73
|
-
the listener invocation in.
|
|
74
|
-
|
|
75
|
-
## Installation (once published)
|
|
6
|
+
TypeORM storage for
|
|
7
|
+
[`@nestjs-transactional/outbox`](https://www.npmjs.com/package/@nestjs-transactional/outbox).
|
|
76
8
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
@nestjs-transactional/outbox \
|
|
81
|
-
@nestjs-transactional/outbox-typeorm
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
Peer dependencies: `@nestjs/common`, `@nestjs/core`, `@nestjs/typeorm`,
|
|
85
|
-
`reflect-metadata`, `rxjs`, `typeorm`.
|
|
9
|
+
`outbox` defines the registry and the worker but ships no production
|
|
10
|
+
storage. This package provides it: the `event_publication` table, its
|
|
11
|
+
archive, a repository implementation, and a migration to create both.
|
|
86
12
|
|
|
87
|
-
|
|
13
|
+
Publication rows are written through the ambient transaction, so they
|
|
14
|
+
commit with your business data or not at all — that is the guarantee the
|
|
15
|
+
whole pattern rests on, and it comes from the transparent repository
|
|
16
|
+
support in
|
|
17
|
+
[`@nestjs-transactional/typeorm`](https://www.npmjs.com/package/@nestjs-transactional/typeorm).
|
|
88
18
|
|
|
89
|
-
|
|
90
|
-
| ----------------------------------- | -------------------------- |
|
|
91
|
-
| Node.js | `>=22.13.0` |
|
|
92
|
-
| `typeorm` | `^0.3.0 \|\| ^1.0.0` |
|
|
93
|
-
| `@nestjs/typeorm` | `^10.0.0 \|\| ^11.0.0` |
|
|
94
|
-
| `@nestjs/common` / `@nestjs/core` | `^10.0.0 \|\| ^11.0.0` |
|
|
95
|
-
| `reflect-metadata` | `^0.1.13 \|\| ^0.2.0` |
|
|
96
|
-
| `rxjs` | `^7.0.0` |
|
|
19
|
+
## Install
|
|
97
20
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
21
|
+
```bash
|
|
22
|
+
pnpm add @nestjs-transactional/outbox-typeorm \
|
|
23
|
+
@nestjs-transactional/outbox \
|
|
24
|
+
@nestjs-transactional/typeorm \
|
|
25
|
+
@nestjs-transactional/core
|
|
26
|
+
```
|
|
103
27
|
|
|
104
|
-
##
|
|
28
|
+
## Quick start
|
|
105
29
|
|
|
106
|
-
|
|
107
|
-
|
|
30
|
+
Register the two entities on your `DataSource`, then wire four modules
|
|
31
|
+
in this order:
|
|
108
32
|
|
|
109
|
-
```
|
|
33
|
+
```ts
|
|
110
34
|
import { Module } from '@nestjs/common';
|
|
111
|
-
import { DataSource } from 'typeorm';
|
|
112
35
|
import { TransactionalModule } from '@nestjs-transactional/core';
|
|
113
36
|
import { TypeOrmTransactionalModule } from '@nestjs-transactional/typeorm';
|
|
37
|
+
import { OutboxModule, OutboxProcessingModule } from '@nestjs-transactional/outbox';
|
|
114
38
|
import {
|
|
115
|
-
OutboxModule,
|
|
116
|
-
OutboxProcessingModule,
|
|
117
|
-
} from '@nestjs-transactional/outbox';
|
|
118
|
-
import {
|
|
119
|
-
EventPublicationEntity,
|
|
120
39
|
EventPublicationArchiveEntity,
|
|
40
|
+
EventPublicationEntity,
|
|
121
41
|
OutboxTypeOrmModule,
|
|
122
42
|
typeOrmEventPublicationRepositoryProvider,
|
|
123
43
|
} from '@nestjs-transactional/outbox-typeorm';
|
|
124
44
|
|
|
125
|
-
import { OrderPlacedEvent } from './events';
|
|
126
|
-
|
|
127
|
-
const dataSource = new DataSource({
|
|
128
|
-
type: 'postgres',
|
|
129
|
-
// ...
|
|
130
|
-
entities: [
|
|
131
|
-
EventPublicationEntity,
|
|
132
|
-
EventPublicationArchiveEntity,
|
|
133
|
-
// ...your domain entities
|
|
134
|
-
],
|
|
135
|
-
});
|
|
136
|
-
|
|
137
45
|
@Module({
|
|
138
46
|
imports: [
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
47
|
+
TypeOrmModule.forRoot({
|
|
48
|
+
type: 'postgres',
|
|
49
|
+
entities: [EventPublicationEntity, EventPublicationArchiveEntity, Order],
|
|
50
|
+
}),
|
|
142
51
|
|
|
143
|
-
|
|
144
|
-
// actual DataSource via @nestjs/typeorm's
|
|
145
|
-
// `getDataSourceToken(name)` — so `TypeOrmModule.forRoot(...)`
|
|
146
|
-
// must be imported above this. Activates transparent
|
|
147
|
-
// transactional Repository dispatch.
|
|
52
|
+
TransactionalModule.forRoot({ isGlobal: true }),
|
|
148
53
|
TypeOrmTransactionalModule.forRoot({ isDefault: true }),
|
|
149
54
|
|
|
150
|
-
//
|
|
151
|
-
//
|
|
152
|
-
// TypeOrmTransactionalModule). Registers the
|
|
153
|
-
// `TypeOrmEventPublicationRepository` under a private per-DS
|
|
154
|
-
// token; the cross-module bridge
|
|
155
|
-
// `typeOrmEventPublicationRepositoryProvider()` (passed to
|
|
156
|
-
// `OutboxModule.forRoot` below) aliases the official outbox
|
|
157
|
-
// token to that private one. The `SchemaInitializer` is
|
|
158
|
-
// instantiated per-DS — production should disable it and
|
|
159
|
-
// apply the shipped TypeORM migration instead.
|
|
55
|
+
// Auto-create the tables in development only — production runs the
|
|
56
|
+
// migration instead. See Schema below.
|
|
160
57
|
OutboxTypeOrmModule.forRoot({
|
|
161
58
|
schemaInitialization: { enabled: process.env.NODE_ENV !== 'production' },
|
|
162
59
|
}),
|
|
163
60
|
|
|
164
|
-
// 4. Outbox-core wiring. Forward the TypeORM repository via the
|
|
165
|
-
// aliasing Provider so outbox does NOT install its
|
|
166
|
-
// InMemory default.
|
|
167
61
|
OutboxModule.forRoot({
|
|
62
|
+
// Required. Without it `outbox` keeps its in-memory default and
|
|
63
|
+
// nothing is persisted — see the warning below.
|
|
168
64
|
repository: typeOrmEventPublicationRepositoryProvider(),
|
|
169
65
|
republishOnStartup: true,
|
|
170
|
-
processor: { pollingInterval: 1000, batchSize: 100 },
|
|
171
|
-
staleness: { processing: 60_000, monitorInterval: 30_000 },
|
|
172
66
|
}),
|
|
173
67
|
|
|
174
|
-
// 5. Register the event classes the outbox should know about.
|
|
175
|
-
// Each feature module would normally call forFeature() for the
|
|
176
|
-
// events it owns; this single-module example collapses them.
|
|
177
68
|
OutboxModule.forFeature([OrderPlacedEvent]),
|
|
178
69
|
|
|
179
|
-
//
|
|
180
|
-
// staleness monitor on bootstrap. API-only apps that just
|
|
181
|
-
// publish events should NOT import this.
|
|
182
|
-
OutboxProcessingModule,
|
|
70
|
+
OutboxProcessingModule, // worker processes only
|
|
183
71
|
],
|
|
184
72
|
})
|
|
185
73
|
export class AppModule {}
|
|
186
74
|
```
|
|
187
75
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
implementation registered by `OutboxTypeOrmModule.forFeature`. Leaving
|
|
196
|
-
the option out would install two providers for the same token —
|
|
197
|
-
the InMemory one would win and your publications would never reach
|
|
198
|
-
the database.
|
|
199
|
-
|
|
200
|
-
### Publishing events
|
|
201
|
-
|
|
202
|
-
```typescript
|
|
203
|
-
import { Injectable } from '@nestjs/common';
|
|
204
|
-
import { Transactional } from '@nestjs-transactional/core';
|
|
205
|
-
import { OutboxEventPublisher } from '@nestjs-transactional/outbox';
|
|
206
|
-
|
|
207
|
-
@Injectable()
|
|
208
|
-
export class PlaceOrderHandler {
|
|
209
|
-
constructor(private readonly outbox: OutboxEventPublisher) {}
|
|
210
|
-
|
|
211
|
-
@Transactional()
|
|
212
|
-
async handle(orderId: string): Promise<void> {
|
|
213
|
-
// ...persist business data in the same transaction...
|
|
214
|
-
await this.outbox.publish(new OrderPlacedEvent(orderId));
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
```
|
|
76
|
+
> **`repository` is not optional in practice.** `OutboxModule.forRoot()`
|
|
77
|
+
> installs `InMemoryEventPublicationRepository` when the option is
|
|
78
|
+
> omitted, and that provider wins. The application works — publishes,
|
|
79
|
+
> handles, completes — and every publication is lost on restart, with
|
|
80
|
+
> nothing in the database and no error to notice.
|
|
81
|
+
> `typeOrmEventPublicationRepositoryProvider()` aliases the outbox's
|
|
82
|
+
> token to the TypeORM implementation this module registers.
|
|
218
83
|
|
|
219
|
-
|
|
220
|
-
the transaction rolls back, the publication row is rolled back too
|
|
221
|
-
— there is no "event published without the business change landing"
|
|
222
|
-
failure mode.
|
|
84
|
+
## Schema
|
|
223
85
|
|
|
224
|
-
|
|
86
|
+
Two tables. `event_publication` is the hot queue; `event_publication_archive`
|
|
87
|
+
is the cold audit trail used by the `ARCHIVE` completion mode. Four
|
|
88
|
+
indexes cover the worker, operator and cleanup paths — `(status,
|
|
89
|
+
publicationDate)`, `(status, listenerId)`, `(eventType)` and
|
|
90
|
+
`(completionDate)`. `status` is `varchar(32)` rather than an enum, so a
|
|
91
|
+
new lifecycle state never forces a type migration.
|
|
225
92
|
|
|
226
|
-
|
|
227
|
-
import { Injectable } from '@nestjs/common';
|
|
228
|
-
import {
|
|
229
|
-
type IOutboxEventHandler,
|
|
230
|
-
OutboxEventsHandler,
|
|
231
|
-
} from '@nestjs-transactional/outbox';
|
|
232
|
-
|
|
233
|
-
@Injectable()
|
|
234
|
-
@OutboxEventsHandler(OrderPlacedEvent)
|
|
235
|
-
export class InventoryReservationHandler
|
|
236
|
-
implements IOutboxEventHandler<OrderPlacedEvent>
|
|
237
|
-
{
|
|
238
|
-
async handle(event: OrderPlacedEvent): Promise<void> {
|
|
239
|
-
// Runs in a fresh REQUIRES_NEW transaction after the publishing
|
|
240
|
-
// transaction has committed, retried on exception, resumable
|
|
241
|
-
// across process restarts.
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
## Schema management
|
|
247
|
-
|
|
248
|
-
Two supported paths, matching Spring Modulith's split between
|
|
249
|
-
reviewed schema changes and the
|
|
250
|
-
`spring.modulith.events.jdbc.schema-initialization.enabled`
|
|
251
|
-
developer shortcut.
|
|
252
|
-
|
|
253
|
-
### Production: run the TypeORM migration (preferred)
|
|
93
|
+
**In production, run the shipped migration:**
|
|
254
94
|
|
|
255
|
-
|
|
256
|
-
`CreateEventPublication1700000000000`, that creates both
|
|
257
|
-
`event_publication` and `event_publication_archive` with every
|
|
258
|
-
index. Register it with your DataSource and run it through the
|
|
259
|
-
TypeORM CLI as part of your deploy:
|
|
260
|
-
|
|
261
|
-
```typescript
|
|
262
|
-
// data-source.ts
|
|
263
|
-
import { DataSource } from 'typeorm';
|
|
95
|
+
```ts
|
|
264
96
|
import { CreateEventPublication1700000000000 } from '@nestjs-transactional/outbox-typeorm';
|
|
265
97
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
// ...
|
|
269
|
-
migrations: [CreateEventPublication1700000000000, /* ...your own */],
|
|
270
|
-
});
|
|
98
|
+
// In your DataSource config:
|
|
99
|
+
migrations: [CreateEventPublication1700000000000];
|
|
271
100
|
```
|
|
272
101
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
102
|
+
**In development**, `schemaInitialization: { enabled: true }` creates
|
|
103
|
+
both tables at bootstrap instead. It is idempotent and checks for
|
|
104
|
+
existing tables first, but it is still schema DDL at application
|
|
105
|
+
startup: keep it out of production, where a migration gives you a
|
|
106
|
+
reviewable, ordered, reversible change.
|
|
276
107
|
|
|
277
|
-
|
|
278
|
-
before most application-owned migrations. Feel free to copy the
|
|
279
|
-
migration file into your own `migrations/` directory and rename it
|
|
280
|
-
to match your team's timestamp convention — the migration body is
|
|
281
|
-
just a call to `applyEventPublicationSchema(queryRunner)` from this
|
|
282
|
-
package, so keeping a thin wrapper in your own tree is encouraged.
|
|
108
|
+
## Concurrency
|
|
283
109
|
|
|
284
|
-
|
|
110
|
+
`tryClaim` is one conditional `UPDATE`
|
|
111
|
+
(`WHERE id = :id AND status IN (PUBLISHED, RESUBMITTED)`) that reports
|
|
112
|
+
whether the row actually transitioned. That is where the safety lives,
|
|
113
|
+
which is why `findReadyForProcessing` deliberately does **not** lock
|
|
114
|
+
rows.
|
|
285
115
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
116
|
+
`SELECT ... FOR UPDATE SKIP LOCKED` was tried and dropped: a pessimistic
|
|
117
|
+
lock has to be held by a transaction wide enough to span the listener
|
|
118
|
+
invocation, which is unsafe when listeners are slow. Concurrent workers
|
|
119
|
+
may therefore fetch the same row; only one wins the claim, and the
|
|
120
|
+
others move on without invoking anything. The cost is a wasted `SELECT`
|
|
121
|
+
at typical worker counts
|
|
122
|
+
([DD-025](https://github.com/igorgolovanov/nestjs-transactional/blob/main/docs/dd/025-claim-atomicity-obligation.md)).
|
|
290
123
|
|
|
291
|
-
|
|
292
|
-
import { Module } from '@nestjs/common';
|
|
293
|
-
import { DataSource } from 'typeorm';
|
|
294
|
-
import { getDataSourceToken } from '@nestjs/typeorm';
|
|
295
|
-
import {
|
|
296
|
-
SchemaInitializer,
|
|
297
|
-
SCHEMA_INITIALIZATION_OPTIONS,
|
|
298
|
-
} from '@nestjs-transactional/outbox-typeorm';
|
|
124
|
+
## Multiple dataSources
|
|
299
125
|
|
|
300
|
-
|
|
301
|
-
providers: [
|
|
302
|
-
{
|
|
303
|
-
provide: SCHEMA_INITIALIZATION_OPTIONS,
|
|
304
|
-
useValue: { enabled: process.env.NODE_ENV !== 'production' },
|
|
305
|
-
},
|
|
306
|
-
{
|
|
307
|
-
provide: SchemaInitializer,
|
|
308
|
-
useFactory: (ds: DataSource, opts) => new SchemaInitializer(ds, opts),
|
|
309
|
-
inject: [getDataSourceToken(), SCHEMA_INITIALIZATION_OPTIONS],
|
|
310
|
-
},
|
|
311
|
-
],
|
|
312
|
-
})
|
|
313
|
-
export class OutboxSchemaModule {}
|
|
314
|
-
```
|
|
126
|
+
One `forRoot` per dataSource, mirroring the other packages:
|
|
315
127
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
not enable in production** — schema changes should always go
|
|
320
|
-
through a reviewed migration.
|
|
321
|
-
|
|
322
|
-
## Using with `@nestjs-transactional/cqrs`
|
|
323
|
-
|
|
324
|
-
When the application uses `@nestjs/cqrs` aggregates, bind
|
|
325
|
-
`OutboxEventPublisher` under the cqrs package's
|
|
326
|
-
`OUTBOX_PUBLICATION_SCHEDULER` token AND bind
|
|
327
|
-
`OutboxListenerRegistry` under `OUTBOX_LISTENER_REGISTRAR`.
|
|
328
|
-
`HybridEventPublisher` (wired by `CqrsTransactionalModule.forRoot()`)
|
|
329
|
-
then routes every `aggregate.commit()` through both the in-memory
|
|
330
|
-
phase-aware dispatcher AND the outbox, and
|
|
331
|
-
`IntegrationEventsHandlerScanner` routes
|
|
332
|
-
`@IntegrationEventsHandler` classes through the outbox worker.
|
|
333
|
-
See [`../cqrs/README.md#outbox-integration`](../cqrs/README.md#outbox-integration)
|
|
334
|
-
for the full wiring recipe and the trade-offs between
|
|
335
|
-
`@TransactionalEventsHandler`, `@OutboxEventsHandler`, and
|
|
336
|
-
`@IntegrationEventsHandler`.
|
|
337
|
-
|
|
338
|
-
## Testing
|
|
339
|
-
|
|
340
|
-
Integration tests live under `test/integration/` and rely on
|
|
341
|
-
[`testcontainers-node`](https://node.testcontainers.org/) to spin up
|
|
342
|
-
a real Postgres 16 container for every run. Requires Docker to be
|
|
343
|
-
running locally:
|
|
344
|
-
|
|
345
|
-
```bash
|
|
346
|
-
pnpm --filter @nestjs-transactional/outbox-typeorm test:integration
|
|
128
|
+
```ts
|
|
129
|
+
OutboxTypeOrmModule.forRoot(), // 'default'
|
|
130
|
+
OutboxTypeOrmModule.forRoot({ dataSource: 'billing' }), // 'billing'
|
|
347
131
|
```
|
|
348
132
|
|
|
349
|
-
|
|
350
|
-
|
|
133
|
+
Each registers its repository under a per-dataSource token; pass the
|
|
134
|
+
matching name to `typeOrmEventPublicationRepositoryProvider('billing')`
|
|
135
|
+
when wiring that dataSource's `OutboxModule`
|
|
136
|
+
([ADR-019](https://github.com/igorgolovanov/nestjs-transactional/blob/main/docs/adr/019-outbox-multi-forroot-pattern.md)).
|
|
137
|
+
`forRootAsync` is available for config resolved at runtime.
|
|
351
138
|
|
|
352
|
-
##
|
|
353
|
-
|
|
354
|
-
- [`basic-typeorm-outbox`](../../examples/basic-typeorm-outbox) — single-DS outbox with Postgres, atomicity proven by testcontainers.
|
|
355
|
-
- [`multi-datasource-outbox`](../../examples/multi-datasource-outbox) — per-DS `event_publication` tables (ADR-019 multi-`forRoot`).
|
|
356
|
-
- [`shared-database-modular-monolith`](../../examples/shared-database-modular-monolith) — one Postgres, multi-schema, per-module outbox stacks.
|
|
357
|
-
- [`saga-pattern`](../../examples/saga-pattern), [`audit-logging`](../../examples/audit-logging) — outbox-driven business saga and asymmetric audit-DS sink.
|
|
358
|
-
- [`e-commerce-orders`](../../examples/e-commerce-orders) — three-DataSource flagship using `OutboxTypeOrmModule.forRoot` per DS.
|
|
139
|
+
## Compatibility
|
|
359
140
|
|
|
360
|
-
|
|
141
|
+
| Peer | Supported range |
|
|
142
|
+
| --- | --- |
|
|
143
|
+
| Node.js | `>=22.13.0` |
|
|
144
|
+
| `typeorm` | `^0.3.0 \|\| ^1.0.0` |
|
|
145
|
+
| `@nestjs/typeorm` | `^10.0.0 \|\| ^11.0.0` |
|
|
146
|
+
| `@nestjs/common` / `@nestjs/core` | `^10.0.0 \|\| ^11.0.0` |
|
|
147
|
+
| `reflect-metadata` | `^0.1.13 \|\| ^0.2.0` |
|
|
148
|
+
| `rxjs` | `^7.0.0` |
|
|
149
|
+
|
|
150
|
+
CI exercises the repository against a real Postgres via testcontainers
|
|
151
|
+
at three points of the TypeORM range: `0.3.31`, `1.0.0` and `1.1.0`.
|
|
152
|
+
|
|
153
|
+
## Documentation
|
|
154
|
+
|
|
155
|
+
- [Getting started and full docs](https://github.com/igorgolovanov/nestjs-transactional#readme)
|
|
156
|
+
- [Architecture: the outbox pattern](https://github.com/igorgolovanov/nestjs-transactional/blob/main/docs/architecture/outbox-pattern.md)
|
|
157
|
+
- [Outbox architecture (ADR-007)](https://github.com/igorgolovanov/nestjs-transactional/blob/main/docs/adr/007-outbox-architecture.md)
|
|
158
|
+
- Runnable examples:
|
|
159
|
+
[`basic-typeorm-outbox`](https://github.com/igorgolovanov/nestjs-transactional/tree/main/examples/basic-typeorm-outbox),
|
|
160
|
+
[`multi-datasource-outbox`](https://github.com/igorgolovanov/nestjs-transactional/tree/main/examples/multi-datasource-outbox),
|
|
161
|
+
[`shared-database-modular-monolith`](https://github.com/igorgolovanov/nestjs-transactional/tree/main/examples/shared-database-modular-monolith)
|
|
361
162
|
|
|
362
163
|
## License
|
|
363
164
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { type DynamicModule, type InjectionToken, type ModuleMetadata, type Provider } from '@nestjs/common';
|
|
2
2
|
import { type SchemaInitializationOptions } from '../schema/schema-initialization-options';
|
|
3
3
|
/**
|
|
4
|
-
* Options accepted by {@link OutboxTypeOrmModule.forRoot}
|
|
4
|
+
* Options accepted by {@link OutboxTypeOrmModule.forRoot}.
|
|
5
5
|
*
|
|
6
6
|
* The dataSource identifier is now a *string name only*. The actual
|
|
7
7
|
* `DataSource` instance is resolved from DI under
|
|
8
8
|
* `getDataSourceToken(name)` — the same convention `@nestjs/typeorm`
|
|
9
|
-
* uses for `@InjectRepository(E, dataSource)`. Mirrors the
|
|
9
|
+
* uses for `@InjectRepository(E, dataSource)`. Mirrors the
|
|
10
10
|
* shape of `TypeOrmTransactionalModule.forRoot`.
|
|
11
11
|
*/
|
|
12
12
|
export interface OutboxTypeOrmOptions {
|
|
@@ -19,7 +19,7 @@ export interface OutboxTypeOrmOptions {
|
|
|
19
19
|
* Multi-dataSource deployments call `forRoot` once per dataSource;
|
|
20
20
|
* each call registers its own `TypeOrmEventPublicationRepository`
|
|
21
21
|
* instance under {@link getTypeOrmRepositoryProviderToken} so the
|
|
22
|
-
* outbox-side per-DS tokens
|
|
22
|
+
* outbox-side per-DS tokens can resolve them via the
|
|
23
23
|
* provider returned by {@link typeOrmEventPublicationRepositoryProvider}.
|
|
24
24
|
*/
|
|
25
25
|
readonly dataSource?: string;
|
|
@@ -42,7 +42,7 @@ export interface OutboxTypeOrmOptions {
|
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* Asynchronous flavour of {@link OutboxTypeOrmOptions}. Mirrors the
|
|
45
|
-
* shape of `TypeOrmTransactionalModule.forRootAsync
|
|
45
|
+
* shape of `TypeOrmTransactionalModule.forRootAsync`.
|
|
46
46
|
*
|
|
47
47
|
* **dataSource name limitation**: the `dataSource` field on this
|
|
48
48
|
* interface is *statically declared* (not async-resolved). NestJS
|
|
@@ -78,8 +78,8 @@ export interface OutboxTypeOrmAsyncOptions extends Pick<ModuleMetadata, 'imports
|
|
|
78
78
|
export declare function getTypeOrmRepositoryProviderToken(dataSourceName: string): string;
|
|
79
79
|
/**
|
|
80
80
|
* NestJS module that wires the TypeORM persistence backend for the
|
|
81
|
-
* Event Publication Registry
|
|
82
|
-
*
|
|
81
|
+
* Event Publication Registry, mirroring
|
|
82
|
+
* `TypeOrmTransactionalModule.forRoot`. Multi-dataSource
|
|
83
83
|
* setups call {@link forRoot} once per dataSource — each call
|
|
84
84
|
* registers an independent {@link TypeOrmEventPublicationRepository}
|
|
85
85
|
* instance under a private per-dataSource token. The
|
|
@@ -146,7 +146,7 @@ export declare class OutboxTypeOrmModule {
|
|
|
146
146
|
* @internal
|
|
147
147
|
* Counter for `forRootAsync`-only token uniqueness. Mirrors the
|
|
148
148
|
* pattern used in `TypeOrmTransactionalModule.forRootAsync`
|
|
149
|
-
*
|
|
149
|
+
* — every async call gets a unique provider symbol
|
|
150
150
|
* so consecutive calls don't collide.
|
|
151
151
|
*/
|
|
152
152
|
private static asyncCounter;
|
|
@@ -232,7 +232,7 @@ export declare class OutboxTypeOrmModule {
|
|
|
232
232
|
* → TypeOrmEventPublicationRepository instance
|
|
233
233
|
* ```
|
|
234
234
|
*
|
|
235
|
-
*
|
|
235
|
+
* We considered removing this bridge function (delete it,
|
|
236
236
|
* have `OutboxTypeOrmModule.forRoot` register directly under the
|
|
237
237
|
* official outbox-side token), but the change would require
|
|
238
238
|
* `OutboxModule.forRoot` to drop its in-memory default — which would
|
|
@@ -53,8 +53,8 @@ function getOutboxTypeOrmSchemaOptionsToken(dataSourceName) {
|
|
|
53
53
|
const ASYNC_OPTIONS_TOKEN = (id) => Symbol(`OUTBOX_TYPEORM_ASYNC_OPTIONS[${id}]`);
|
|
54
54
|
/**
|
|
55
55
|
* NestJS module that wires the TypeORM persistence backend for the
|
|
56
|
-
* Event Publication Registry
|
|
57
|
-
*
|
|
56
|
+
* Event Publication Registry, mirroring
|
|
57
|
+
* `TypeOrmTransactionalModule.forRoot`. Multi-dataSource
|
|
58
58
|
* setups call {@link forRoot} once per dataSource — each call
|
|
59
59
|
* registers an independent {@link TypeOrmEventPublicationRepository}
|
|
60
60
|
* instance under a private per-dataSource token. The
|
|
@@ -122,7 +122,7 @@ let OutboxTypeOrmModule = class OutboxTypeOrmModule {
|
|
|
122
122
|
* @internal
|
|
123
123
|
* Counter for `forRootAsync`-only token uniqueness. Mirrors the
|
|
124
124
|
* pattern used in `TypeOrmTransactionalModule.forRootAsync`
|
|
125
|
-
*
|
|
125
|
+
* — every async call gets a unique provider symbol
|
|
126
126
|
* so consecutive calls don't collide.
|
|
127
127
|
*/
|
|
128
128
|
static asyncCounter = 0;
|
|
@@ -290,7 +290,7 @@ function buildPerDataSourceExports(dataSourceName) {
|
|
|
290
290
|
* → TypeOrmEventPublicationRepository instance
|
|
291
291
|
* ```
|
|
292
292
|
*
|
|
293
|
-
*
|
|
293
|
+
* We considered removing this bridge function (delete it,
|
|
294
294
|
* have `OutboxTypeOrmModule.forRoot` register directly under the
|
|
295
295
|
* official outbox-side token), but the change would require
|
|
296
296
|
* `OutboxModule.forRoot` to drop its in-memory default — which would
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outbox-typeorm.module.js","sourceRoot":"","sources":["../../src/module/outbox-typeorm.module.ts"],"names":[],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"outbox-typeorm.module.js","sourceRoot":"","sources":["../../src/module/outbox-typeorm.module.ts"],"names":[],"mappings":";;;;;;;;;;AAsGA,8EAEC;AAiUD,8FAKC;AA9aD,2CAOwB;AACxB,6CAAqD;AACrD,yDAA4E;AAG5E,6GAAuG;AACvG,2FAGiD;AACjD,qEAAiE;AA6EjE;;;;;;;GAOG;AACH,SAAgB,iCAAiC,CAAC,cAAsB;IACtE,OAAO,6BAA6B,cAAc,EAAE,CAAC;AACvD,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,sCAAsC,CAAC,cAAsB;IACpE,OAAO,qCAAqC,cAAc,EAAE,CAAC;AAC/D,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,kCAAkC,CAAC,cAAsB;IAChE,OAAO,iCAAiC,cAAc,EAAE,CAAC;AAC3D,CAAC;AAED,MAAM,mBAAmB,GAAG,CAAC,EAAU,EAAU,EAAE,CAAC,MAAM,CAAC,gCAAgC,EAAE,GAAG,CAAC,CAAC;AAElG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;;IAC9B;;;;;;OAMG;IACK,MAAM,CAAC,YAAY,GAAG,CAAC,CAAC;IAEhC;;;;;;OAMG;IACH,MAAM,CAAC,eAAe;QACpB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;IACxB,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,OAAO,CAAC,UAAgC,EAAE;QAC/C,MAAM,cAAc,GAA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;;;;;;;;;;;;GAsEG;AACH,SAAgB,yCAAyC,CAAC,cAAc,GAAG,SAAS;IAClF,OAAO;QACL,OAAO,EAAE,qCAA4B;QACrC,WAAW,EAAE,iCAAiC,CAAC,cAAc,CAAC;KAC/D,CAAC;AACJ,CAAC"}
|
|
@@ -87,9 +87,7 @@ let TypeOrmEventPublicationRepository = class TypeOrmEventPublicationRepository
|
|
|
87
87
|
.update(event_publication_entity_1.EventPublicationEntity)
|
|
88
88
|
.set({
|
|
89
89
|
status,
|
|
90
|
-
...(options.completionDate !== undefined
|
|
91
|
-
? { completionDate: options.completionDate }
|
|
92
|
-
: {}),
|
|
90
|
+
...(options.completionDate !== undefined ? { completionDate: options.completionDate } : {}),
|
|
93
91
|
...(options.failureReason !== undefined ? { failureReason: options.failureReason } : {}),
|
|
94
92
|
...(options.lastResubmissionDate !== undefined
|
|
95
93
|
? { lastResubmissionDate: options.lastResubmissionDate }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeorm-event-publication.repository.js","sourceRoot":"","sources":["../../src/repository/typeorm-event-publication.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAyC;AAEzC,2CAA4C;AAC5C,yDASsC;AACtC,2DAAwE;AACxE,qCAQiB;AAEjB,iGAA2F;AAC3F,iFAA4E;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEI,IAAM,iCAAiC,GAAvC,MAAM,iCAAiC;IAEzB;IACA;IAFnB,YACmB,UAAsB,EACtB,iBAAiB,SAAS;QAD1B,eAAU,GAAV,UAAU,CAAY;QACtB,mBAAc,GAAd,cAAc,CAAY;IAC1C,CAAC;IAEJ,IAAY,EAAE;QACZ,OAAO,IAAA,iCAAuB,EAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACvE,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,MAA6B;QAC3C,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CA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kBAAkB,EAAE;aACpB,MAAM,CAAC,iDAAsB,CAAC;aAC9B,GAAG,CAAC;YACH,MAAM;YACN,GAAG,CAAC,OAAO,CAAC,cAAc,KAAK,SAAS
|
|
1
|
+
{"version":3,"file":"typeorm-event-publication.repository.js","sourceRoot":"","sources":["../../src/repository/typeorm-event-publication.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAyC;AAEzC,2CAA4C;AAC5C,yDASsC;AACtC,2DAAwE;AACxE,qCAQiB;AAEjB,iGAA2F;AAC3F,iFAA4E;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEI,IAAM,iCAAiC,GAAvC,MAAM,iCAAiC;IAEzB;IACA;IAFnB,YACmB,UAAsB,EACtB,iBAAiB,SAAS;QAD1B,eAAU,GAAV,UAAU,CAAY;QACtB,mBAAc,GAAd,cAAc,CAAY;IAC1C,CAAC;IAEJ,IAAY,EAAE;QACZ,OAAO,IAAA,iCAAuB,EAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACvE,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,MAA6B;QAC3C,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACpC,MAAM,MAAM,GAAG,IAAI,iDAAsB,EAAE,CAAC;YAC5C,MAAM,CAAC,EAAE,GAAG,IAAA,wBAAU,GAAE,CAAC;YACzB,MAAM,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;YACrC,MAAM,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;YACnC,MAAM,CAAC,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC;YAC/C,MAAM,CAAC,eAAe,GAAG,KAAK,CAAC,eAAe,IAAI,IAAI,IAAI,EAAE,CAAC;YAC7D,MAAM,CAAC,MAAM,GAAG,0BAAiB,CAAC,SAAS,CAAC;YAC5C,MAAM,CAAC,cAAc,GAAG,IAAI,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AAC;IACvD,CAAC;CACF,CAAA;AA5LY,8EAAiC;4CAAjC,iCAAiC;IAD7C,IAAA,mBAAU,GAAE;;GACA,iCAAiC,CA4L7C;AAED,SAAS,QAAQ,CAAC,MAA8B;IAC9C,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,oBAAoB,EAAE,MAAM,CAAC,oBAAoB;QACjD,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;QAC7C,aAAa,EAAE,MAAM,CAAC,aAAa;KACpC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-initializer.js","sourceRoot":"","sources":["../../src/schema/schema-initializer.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAiF;AAGjF,
|
|
1
|
+
{"version":3,"file":"schema-initializer.js","sourceRoot":"","sources":["../../src/schema/schema-initializer.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAiF;AAGjF,yEAAkG;AAOlG;;;;;;;;;;;;GAYG;AAEI,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAIT;IACA;IAJF,MAAM,GAAG,IAAI,eAAM,CAAC,mBAAiB,CAAC,IAAI,CAAC,CAAC;IAE7D,YACmB,UAAsB,EACtB,OAAoC;QADpC,eAAU,GAAV,UAAU,CAAY;QACtB,YAAO,GAAP,OAAO,CAA6B;IACpD,CAAC;IAEJ,KAAK,CAAC,sBAAsB;QAC1B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YAC1B,OAAO;QACT,CAAC;QAED,IAAI,MAAM,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;YAChC,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,UAAU,kDAAuB,8CAA8C,CAChF,CAAC;YACF,OAAO;QACT,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAiB,kDAAuB,kCAAkC,CAAC,CAAC;QAE5F,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC;QACxD,IAAI,CAAC;YACH,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;YAC5B,MAAM,IAAA,sDAA2B,EAAC,WAAW,CAAC,CAAC;YAC/C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,kDAAuB,sBAAsB,CAAC,CAAC;QACrE,CAAC;gBAAS,CAAC;YACT,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;QAC9B,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACK,KAAK,CAAC,cAAc;QAC1B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CACtC,wCAAwC,EACxC,CAAC,kDAAuB,CAAC,CAC1B,CAAC;QACF,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,IAAI,CAAC;IACjC,CAAC;CACF,CAAA;AA7CY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;;GACA,iBAAiB,CA6C7B"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs-transactional/outbox-typeorm",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "TypeORM persistence backend for @nestjs-transactional/outbox — event_publication table, FOR UPDATE SKIP LOCKED worker safety",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"type": "commonjs",
|
|
7
|
+
"sideEffects": [
|
|
8
|
+
"./dist/entity/*.js"
|
|
9
|
+
],
|
|
6
10
|
"author": "Igor Golovanov",
|
|
7
11
|
"repository": {
|
|
8
12
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/igorgolovanov/nestjs-transactional.git",
|
|
13
|
+
"url": "git+https://github.com/igorgolovanov/nestjs-transactional.git",
|
|
10
14
|
"directory": "packages/outbox-typeorm"
|
|
11
15
|
},
|
|
12
16
|
"bugs": {
|
|
@@ -40,7 +44,6 @@
|
|
|
40
44
|
},
|
|
41
45
|
"publishConfig": {
|
|
42
46
|
"access": "public",
|
|
43
|
-
"tag": "alpha",
|
|
44
47
|
"provenance": true
|
|
45
48
|
},
|
|
46
49
|
"peerDependencies": {
|
|
@@ -50,9 +53,9 @@
|
|
|
50
53
|
"reflect-metadata": "^0.1.13 || ^0.2.0",
|
|
51
54
|
"rxjs": "^7.0.0",
|
|
52
55
|
"typeorm": "^0.3.0 || ^1.0.0",
|
|
53
|
-
"@nestjs-transactional/core": "^1.0.0
|
|
54
|
-
"@nestjs-transactional/outbox": "^1.0.0
|
|
55
|
-
"@nestjs-transactional/typeorm": "^1.0.0
|
|
56
|
+
"@nestjs-transactional/core": "^1.0.0",
|
|
57
|
+
"@nestjs-transactional/outbox": "^1.0.0",
|
|
58
|
+
"@nestjs-transactional/typeorm": "^1.0.0"
|
|
56
59
|
},
|
|
57
60
|
"devDependencies": {
|
|
58
61
|
"@nestjs/common": "^11.0.0",
|
|
@@ -67,12 +70,12 @@
|
|
|
67
70
|
"rxjs": "^7.8.1",
|
|
68
71
|
"testcontainers": "^10.13.0",
|
|
69
72
|
"ts-jest": "^29.2.5",
|
|
70
|
-
"typeorm": "^
|
|
73
|
+
"typeorm": "^1.1.0",
|
|
71
74
|
"typescript": "^5.5.4",
|
|
72
|
-
"@nestjs-transactional/core": "1.0.0
|
|
73
|
-
"@nestjs-transactional/cqrs": "1.0.0
|
|
74
|
-
"@nestjs-transactional/outbox": "1.0.0
|
|
75
|
-
"@nestjs-transactional/typeorm": "1.0.0
|
|
75
|
+
"@nestjs-transactional/core": "1.0.0",
|
|
76
|
+
"@nestjs-transactional/cqrs": "1.0.0",
|
|
77
|
+
"@nestjs-transactional/outbox": "1.0.0",
|
|
78
|
+
"@nestjs-transactional/typeorm": "1.0.0"
|
|
76
79
|
},
|
|
77
80
|
"scripts": {
|
|
78
81
|
"build": "tsc -p tsconfig.build.json",
|
|
@@ -82,6 +85,9 @@
|
|
|
82
85
|
"test:cov": "jest --coverage",
|
|
83
86
|
"test:integration": "jest --config jest.integration.config.js",
|
|
84
87
|
"type-check": "tsc --noEmit",
|
|
85
|
-
"lint": "eslint \"src/**/*.ts\""
|
|
88
|
+
"lint": "eslint \"src/**/*.ts\"",
|
|
89
|
+
"api:check": "api-extractor run",
|
|
90
|
+
"api:update": "api-extractor run --local",
|
|
91
|
+
"publish:check": "publint && attw --pack ."
|
|
86
92
|
}
|
|
87
93
|
}
|