@nestjs-transactional/outbox 1.0.0-alpha.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.
Files changed (126) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +396 -0
  3. package/dist/api/completed-event-publications.d.ts +31 -0
  4. package/dist/api/completed-event-publications.js +58 -0
  5. package/dist/api/completed-event-publications.js.map +1 -0
  6. package/dist/api/failed-event-publications.d.ts +36 -0
  7. package/dist/api/failed-event-publications.js +75 -0
  8. package/dist/api/failed-event-publications.js.map +1 -0
  9. package/dist/api/incomplete-event-publications.d.ts +28 -0
  10. package/dist/api/incomplete-event-publications.js +72 -0
  11. package/dist/api/incomplete-event-publications.js.map +1 -0
  12. package/dist/decorators/inject-decorators.d.ts +85 -0
  13. package/dist/decorators/inject-decorators.js +100 -0
  14. package/dist/decorators/inject-decorators.js.map +1 -0
  15. package/dist/decorators/outbox-events-handler.decorator.d.ts +97 -0
  16. package/dist/decorators/outbox-events-handler.decorator.js +58 -0
  17. package/dist/decorators/outbox-events-handler.decorator.js.map +1 -0
  18. package/dist/dispatcher/data-source-outbox-publisher.d.ts +69 -0
  19. package/dist/dispatcher/data-source-outbox-publisher.js +127 -0
  20. package/dist/dispatcher/data-source-outbox-publisher.js.map +1 -0
  21. package/dist/dispatcher/event-publication-processor.d.ts +69 -0
  22. package/dist/dispatcher/event-publication-processor.js +192 -0
  23. package/dist/dispatcher/event-publication-processor.js.map +1 -0
  24. package/dist/dispatcher/outbox-event-publisher.d.ts +129 -0
  25. package/dist/dispatcher/outbox-event-publisher.js +172 -0
  26. package/dist/dispatcher/outbox-event-publisher.js.map +1 -0
  27. package/dist/dispatcher/processor-options.d.ts +24 -0
  28. package/dist/dispatcher/processor-options.js +15 -0
  29. package/dist/dispatcher/processor-options.js.map +1 -0
  30. package/dist/externalization/errors.d.ts +21 -0
  31. package/dist/externalization/errors.js +30 -0
  32. package/dist/externalization/errors.js.map +1 -0
  33. package/dist/externalization/event-externalizer.d.ts +49 -0
  34. package/dist/externalization/event-externalizer.js +14 -0
  35. package/dist/externalization/event-externalizer.js.map +1 -0
  36. package/dist/externalization/externalization-registry.d.ts +56 -0
  37. package/dist/externalization/externalization-registry.js +103 -0
  38. package/dist/externalization/externalization-registry.js.map +1 -0
  39. package/dist/externalization/externalized.decorator.d.ts +121 -0
  40. package/dist/externalization/externalized.decorator.js +87 -0
  41. package/dist/externalization/externalized.decorator.js.map +1 -0
  42. package/dist/externalization/types.d.ts +39 -0
  43. package/dist/externalization/types.js +3 -0
  44. package/dist/externalization/types.js.map +1 -0
  45. package/dist/index.d.ts +38 -0
  46. package/dist/index.js +58 -0
  47. package/dist/index.js.map +1 -0
  48. package/dist/interfaces/outbox-event-handler.interface.d.ts +32 -0
  49. package/dist/interfaces/outbox-event-handler.interface.js +3 -0
  50. package/dist/interfaces/outbox-event-handler.interface.js.map +1 -0
  51. package/dist/module/outbox-processing.module.d.ts +29 -0
  52. package/dist/module/outbox-processing.module.js +66 -0
  53. package/dist/module/outbox-processing.module.js.map +1 -0
  54. package/dist/module/outbox.module.d.ts +196 -0
  55. package/dist/module/outbox.module.js +604 -0
  56. package/dist/module/outbox.module.js.map +1 -0
  57. package/dist/recovery/staleness-monitor.d.ts +39 -0
  58. package/dist/recovery/staleness-monitor.js +118 -0
  59. package/dist/recovery/staleness-monitor.js.map +1 -0
  60. package/dist/recovery/startup-recovery.d.ts +37 -0
  61. package/dist/recovery/startup-recovery.js +55 -0
  62. package/dist/recovery/startup-recovery.js.map +1 -0
  63. package/dist/registry/event-publication-registry.d.ts +70 -0
  64. package/dist/registry/event-publication-registry.js +138 -0
  65. package/dist/registry/event-publication-registry.js.map +1 -0
  66. package/dist/registry/listener-registry.d.ts +52 -0
  67. package/dist/registry/listener-registry.js +67 -0
  68. package/dist/registry/listener-registry.js.map +1 -0
  69. package/dist/registry/multi-ds-listener-registrar.d.ts +78 -0
  70. package/dist/registry/multi-ds-listener-registrar.js +112 -0
  71. package/dist/registry/multi-ds-listener-registrar.js.map +1 -0
  72. package/dist/registry/outbox-listener-scanner.d.ts +66 -0
  73. package/dist/registry/outbox-listener-scanner.js +192 -0
  74. package/dist/registry/outbox-listener-scanner.js.map +1 -0
  75. package/dist/repository/event-publication-repository.d.ts +112 -0
  76. package/dist/repository/event-publication-repository.js +6 -0
  77. package/dist/repository/event-publication-repository.js.map +1 -0
  78. package/dist/serialization/event-serializer.d.ts +28 -0
  79. package/dist/serialization/event-serializer.js +6 -0
  80. package/dist/serialization/event-serializer.js.map +1 -0
  81. package/dist/serialization/event-type-registry.d.ts +41 -0
  82. package/dist/serialization/event-type-registry.js +79 -0
  83. package/dist/serialization/event-type-registry.js.map +1 -0
  84. package/dist/serialization/event-type-resolver.d.ts +43 -0
  85. package/dist/serialization/event-type-resolver.js +66 -0
  86. package/dist/serialization/event-type-resolver.js.map +1 -0
  87. package/dist/serialization/json-event-serializer.d.ts +20 -0
  88. package/dist/serialization/json-event-serializer.js +64 -0
  89. package/dist/serialization/json-event-serializer.js.map +1 -0
  90. package/dist/testing/assertable-published-events.d.ts +71 -0
  91. package/dist/testing/assertable-published-events.js +124 -0
  92. package/dist/testing/assertable-published-events.js.map +1 -0
  93. package/dist/testing/in-memory-repository.d.ts +52 -0
  94. package/dist/testing/in-memory-repository.js +230 -0
  95. package/dist/testing/in-memory-repository.js.map +1 -0
  96. package/dist/testing/index.d.ts +4 -0
  97. package/dist/testing/index.js +20 -0
  98. package/dist/testing/index.js.map +1 -0
  99. package/dist/testing/published-events.d.ts +62 -0
  100. package/dist/testing/published-events.js +110 -0
  101. package/dist/testing/published-events.js.map +1 -0
  102. package/dist/tokens/index.d.ts +2 -0
  103. package/dist/tokens/index.js +14 -0
  104. package/dist/tokens/index.js.map +1 -0
  105. package/dist/tokens/token-utils.d.ts +68 -0
  106. package/dist/tokens/token-utils.js +98 -0
  107. package/dist/tokens/token-utils.js.map +1 -0
  108. package/dist/types/completion-mode.d.ts +16 -0
  109. package/dist/types/completion-mode.js +20 -0
  110. package/dist/types/completion-mode.js.map +1 -0
  111. package/dist/types/errors.d.ts +50 -0
  112. package/dist/types/errors.js +64 -0
  113. package/dist/types/errors.js.map +1 -0
  114. package/dist/types/event-publication.d.ts +47 -0
  115. package/dist/types/event-publication.js +3 -0
  116. package/dist/types/event-publication.js.map +1 -0
  117. package/dist/types/publication-status.d.ts +26 -0
  118. package/dist/types/publication-status.js +30 -0
  119. package/dist/types/publication-status.js.map +1 -0
  120. package/dist/types/resubmission-options.d.ts +37 -0
  121. package/dist/types/resubmission-options.js +62 -0
  122. package/dist/types/resubmission-options.js.map +1 -0
  123. package/dist/types/staleness-config.d.ts +18 -0
  124. package/dist/types/staleness-config.js +10 -0
  125. package/dist/types/staleness-config.js.map +1 -0
  126. package/package.json +77 -0
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Contract implemented by classes annotated with
3
+ * `@OutboxEventsHandler`. The worker invokes `handle(event)` for
4
+ * every event of a type the class is registered for, with an
5
+ * already-deserialised domain payload.
6
+ *
7
+ * `Promise<void>` — synchronous handlers are discouraged: the
8
+ * worker loop awaits the returned promise, so a void-returning
9
+ * implementation that synchronously performs I/O would block the
10
+ * worker until that work completes. Make the operation explicit.
11
+ *
12
+ * Mirrors the ergonomics of `IEventHandler` from `@nestjs/cqrs` —
13
+ * `any` as the default generic parameter is deliberate so that
14
+ * `implements IOutboxEventHandler` without a type argument still
15
+ * type-checks against any concrete event shape.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * @OutboxEventsHandler(OrderPlacedEvent)
20
+ * export class InventoryReservationHandler
21
+ * implements IOutboxEventHandler<OrderPlacedEvent>
22
+ * {
23
+ * async handle(event: OrderPlacedEvent): Promise<void> {
24
+ * // durable, at-least-once, retried on failure
25
+ * }
26
+ * }
27
+ * ```
28
+ */
29
+ export interface IOutboxEventHandler<T = any> {
30
+ handle(event: T): Promise<void>;
31
+ }
32
+ //# sourceMappingURL=outbox-event-handler.interface.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=outbox-event-handler.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outbox-event-handler.interface.js","sourceRoot":"","sources":["../../src/interfaces/outbox-event-handler.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ import { type OnApplicationBootstrap, type OnApplicationShutdown } from '@nestjs/common';
2
+ import { type OutboxProcessingBundle } from './outbox.module';
3
+ /**
4
+ * Auto-starts every configured per-dataSource
5
+ * {@link EventPublicationProcessor} and {@link StalenessMonitor} on
6
+ * application bootstrap and stops them on shutdown.
7
+ *
8
+ * Phase 14.3 generalised this to multi-dataSource: the module reads
9
+ * {@link OUTBOX_PROCESSING_BUNDLE} provided by `OutboxModule.forRoot`
10
+ * — the bundle contains arrays of per-dataSource processors and
11
+ * monitors. Single-dataSource deployments see the bundle with
12
+ * exactly one processor and one monitor; nothing changes for them.
13
+ *
14
+ * Import this module in applications that SHOULD drain every
15
+ * configured outbox (typically a dedicated worker process), but NOT
16
+ * in API applications that only publish events — they should leave
17
+ * processing to the worker.
18
+ *
19
+ * Assumes {@link OutboxModule} is already registered earlier in the
20
+ * module tree (usually as `OutboxModule.forRoot({ isGlobal: true })`);
21
+ * the bundle is looked up from the global DI scope.
22
+ */
23
+ export declare class OutboxProcessingModule implements OnApplicationBootstrap, OnApplicationShutdown {
24
+ private readonly bundle;
25
+ constructor(bundle: OutboxProcessingBundle);
26
+ onApplicationBootstrap(): void;
27
+ onApplicationShutdown(): void;
28
+ }
29
+ //# sourceMappingURL=outbox-processing.module.d.ts.map
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.OutboxProcessingModule = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const outbox_module_1 = require("./outbox.module");
18
+ /**
19
+ * Auto-starts every configured per-dataSource
20
+ * {@link EventPublicationProcessor} and {@link StalenessMonitor} on
21
+ * application bootstrap and stops them on shutdown.
22
+ *
23
+ * Phase 14.3 generalised this to multi-dataSource: the module reads
24
+ * {@link OUTBOX_PROCESSING_BUNDLE} provided by `OutboxModule.forRoot`
25
+ * — the bundle contains arrays of per-dataSource processors and
26
+ * monitors. Single-dataSource deployments see the bundle with
27
+ * exactly one processor and one monitor; nothing changes for them.
28
+ *
29
+ * Import this module in applications that SHOULD drain every
30
+ * configured outbox (typically a dedicated worker process), but NOT
31
+ * in API applications that only publish events — they should leave
32
+ * processing to the worker.
33
+ *
34
+ * Assumes {@link OutboxModule} is already registered earlier in the
35
+ * module tree (usually as `OutboxModule.forRoot({ isGlobal: true })`);
36
+ * the bundle is looked up from the global DI scope.
37
+ */
38
+ let OutboxProcessingModule = class OutboxProcessingModule {
39
+ bundle;
40
+ constructor(bundle) {
41
+ this.bundle = bundle;
42
+ }
43
+ onApplicationBootstrap() {
44
+ for (const processor of this.bundle.processors) {
45
+ processor.start();
46
+ }
47
+ for (const monitor of this.bundle.monitors) {
48
+ monitor.start();
49
+ }
50
+ }
51
+ onApplicationShutdown() {
52
+ for (const processor of this.bundle.processors) {
53
+ processor.stop();
54
+ }
55
+ for (const monitor of this.bundle.monitors) {
56
+ monitor.stop();
57
+ }
58
+ }
59
+ };
60
+ exports.OutboxProcessingModule = OutboxProcessingModule;
61
+ exports.OutboxProcessingModule = OutboxProcessingModule = __decorate([
62
+ (0, common_1.Module)({}),
63
+ __param(0, (0, common_1.Inject)(outbox_module_1.OUTBOX_PROCESSING_BUNDLE)),
64
+ __metadata("design:paramtypes", [Object])
65
+ ], OutboxProcessingModule);
66
+ //# sourceMappingURL=outbox-processing.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outbox-processing.module.js","sourceRoot":"","sources":["../../src/module/outbox-processing.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAKwB;AAExB,mDAGyB;AAEzB;;;;;;;;;;;;;;;;;;;GAmBG;AAEI,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAGd;IAFnB,YAEmB,MAA8B;QAA9B,WAAM,GAAN,MAAM,CAAwB;IAC9C,CAAC;IAEJ,sBAAsB;QACpB,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YAC/C,SAAS,CAAC,KAAK,EAAE,CAAC;QACpB,CAAC;QACD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC3C,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,CAAC;IACH,CAAC;IAED,qBAAqB;QACnB,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YAC/C,SAAS,CAAC,IAAI,EAAE,CAAC;QACnB,CAAC;QACD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC3C,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,CAAC;IACH,CAAC;CACF,CAAA;AAvBY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,eAAM,EAAC,EAAE,CAAC;IAGN,WAAA,IAAA,eAAM,EAAC,wCAAwB,CAAC,CAAA;;GAFxB,sBAAsB,CAuBlC"}
@@ -0,0 +1,196 @@
1
+ import { type DynamicModule, type InjectionToken, type ModuleMetadata, type Provider, type Type } from '@nestjs/common';
2
+ import { EventPublicationProcessor } from '../dispatcher/event-publication-processor';
3
+ import { type EventPublicationProcessorOptions } from '../dispatcher/processor-options';
4
+ import { StalenessMonitor } from '../recovery/staleness-monitor';
5
+ import { StartupRecoveryService } from '../recovery/startup-recovery';
6
+ import { CompletionMode } from '../types/completion-mode';
7
+ import { type StalenessConfig } from '../types/staleness-config';
8
+ /**
9
+ * Synchronous options for {@link OutboxModule.forRoot}.
10
+ *
11
+ * Multi-dataSource deployments call `forRoot` once per dataSource:
12
+ *
13
+ * ```ts
14
+ * OutboxModule.forRoot({}) // default
15
+ * OutboxModule.forRoot({ dataSource: 'billing' }) // billing
16
+ * OutboxModule.forRoot({ dataSource: 'inventory' }) // inventory
17
+ * ```
18
+ *
19
+ * Matches the convention used by `TypeOrmModule`, `MongooseModule`,
20
+ * `ClientsModule`, and others — each `forRoot` call registers a
21
+ * complete provider matrix for one dataSource. Cross-call
22
+ * coordination of the singleton facade / scanner / processing bundle
23
+ * happens through {@link OutboxModule.registrations} (static class
24
+ * storage, mirroring `@nestjs/typeorm`'s `EntitiesMetadataStorage`).
25
+ *
26
+ * Calling `forRoot` twice with the same `dataSource` (or twice with
27
+ * `dataSource` omitted, which both default to `'default'`) throws at
28
+ * module-definition time — dataSource names must be unique across a
29
+ * process.
30
+ *
31
+ * Tests that build multiple modules in sequence must reset the
32
+ * static storage between cases — call {@link OutboxModule.resetForTesting}
33
+ * in `beforeEach` (or `afterEach`).
34
+ */
35
+ export interface OutboxModuleOptions {
36
+ /** dataSource name. Defaults to `'default'`. */
37
+ readonly dataSource?: string;
38
+ /** Register the module as `@Global()`. Default: `true`. */
39
+ readonly isGlobal?: boolean;
40
+ readonly processor?: Partial<EventPublicationProcessorOptions>;
41
+ readonly staleness?: Partial<StalenessConfig>;
42
+ readonly republishOnStartup?: boolean;
43
+ readonly startupBatchSize?: number;
44
+ readonly completionMode?: CompletionMode;
45
+ /**
46
+ * Provider for the event serializer. The Provider's `provide` field
47
+ * is IGNORED — the module re-binds the provider to
48
+ * `getOutboxEventSerializerToken(dataSource)`. Defaults to a JSON
49
+ * serializer wired to this dataSource's `EventTypeRegistry`.
50
+ */
51
+ readonly serializer?: Provider;
52
+ /**
53
+ * Provider for the event publication repository. Same `provide`
54
+ * re-binding as `serializer`. Defaults to
55
+ * {@link InMemoryEventPublicationRepository} — TESTS ONLY. Production
56
+ * deployments wire a durable backend (`outbox-typeorm`, ...).
57
+ */
58
+ readonly repository?: Provider;
59
+ }
60
+ /**
61
+ * Result shape resolved by {@link OutboxModuleAsyncOptions.useFactory}.
62
+ * Provider-valued fields (`serializer`, `repository`) stay static
63
+ * because providers must be known at module-definition time.
64
+ */
65
+ export interface OutboxModuleAsyncFactoryResult {
66
+ readonly processor?: Partial<EventPublicationProcessorOptions>;
67
+ readonly staleness?: Partial<StalenessConfig>;
68
+ readonly republishOnStartup?: boolean;
69
+ readonly startupBatchSize?: number;
70
+ readonly completionMode?: CompletionMode;
71
+ }
72
+ /**
73
+ * Asynchronous options for {@link OutboxModule.forRootAsync}. Each
74
+ * call registers a single dataSource's outbox stack with config
75
+ * resolved asynchronously. Multi-dataSource deployments call
76
+ * `forRootAsync` once per dataSource (symmetric with `forRoot`).
77
+ */
78
+ export interface OutboxModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
79
+ readonly dataSource?: string;
80
+ readonly isGlobal?: boolean;
81
+ readonly serializer?: Provider;
82
+ readonly repository?: Provider;
83
+ readonly useFactory: (...args: never[]) => Promise<OutboxModuleAsyncFactoryResult> | OutboxModuleAsyncFactoryResult;
84
+ readonly inject?: readonly InjectionToken[];
85
+ }
86
+ /** DI token carrying the resolved {@link EventPublicationProcessorOptions}. */
87
+ export declare const OUTBOX_PROCESSOR_OPTIONS: unique symbol;
88
+ /** DI token carrying the resolved {@link StalenessConfig}. */
89
+ export declare const OUTBOX_STALENESS_CONFIG: unique symbol;
90
+ /**
91
+ * Bundle of per-dataSource processors and monitors that
92
+ * {@link OutboxProcessingModule} reads on bootstrap to start every
93
+ * configured outbox loop. Provided by `forRoot` so the processing
94
+ * module needs no per-dataSource configuration of its own.
95
+ */
96
+ export declare const OUTBOX_PROCESSING_BUNDLE: unique symbol;
97
+ /**
98
+ * Shape of the processing bundle. The three arrays are aligned by
99
+ * index — `processors[i]` / `monitors[i]` / `recoveryServices[i]`
100
+ * all belong to the same dataSource.
101
+ */
102
+ export interface OutboxProcessingBundle {
103
+ readonly processors: readonly EventPublicationProcessor[];
104
+ readonly monitors: readonly StalenessMonitor[];
105
+ readonly recoveryServices: readonly StartupRecoveryService[];
106
+ }
107
+ /**
108
+ * NestJS module that wires the Event Publication Registry. ADR-019
109
+ * shape — multi-dataSource deployments call {@link forRoot} once per
110
+ * dataSource. The first call registers process-wide singletons (smart
111
+ * facade, listener scanner, processing bundle); subsequent calls only
112
+ * register per-dataSource providers. Default-DS class-token aliases
113
+ * are registered by whichever call has `dataSource: 'default'` (or
114
+ * `dataSource` omitted).
115
+ *
116
+ * Cross-call state lives in {@link registrations} — a static class
117
+ * storage keyed by dataSource name. Mirrors `@nestjs/typeorm`'s
118
+ * `EntitiesMetadataStorage` pattern.
119
+ *
120
+ * Does NOT start the processor or staleness monitor automatically —
121
+ * import {@link OutboxProcessingModule} in the worker process to
122
+ * auto-start every registered per-dataSource loop on
123
+ * `OnApplicationBootstrap`.
124
+ *
125
+ * Requires `TransactionalModule.forRoot({ isGlobal: true })` registered
126
+ * earlier in the module tree so the per-DS publisher can find the
127
+ * `TransactionManager` via the global DI scope.
128
+ */
129
+ export declare class OutboxModule {
130
+ /**
131
+ * @internal
132
+ * Process-wide registry of every dataSource that has called
133
+ * {@link forRoot} or {@link forRootAsync}. Singleton factories
134
+ * (smart facade, processing bundle) close over this Map and
135
+ * enumerate it at injection time, after every `forRoot` has been
136
+ * evaluated synchronously.
137
+ *
138
+ * Tests that build multiple modules sequentially MUST call
139
+ * {@link resetForTesting} between cases — otherwise residual
140
+ * registrations from earlier tests collide with later ones.
141
+ */
142
+ private static readonly registrations;
143
+ /**
144
+ * Test-only — drop every registration so a subsequent `forRoot`
145
+ * starts from a clean slate. Mirrors the cleanup pattern used with
146
+ * `EntitiesMetadataStorage` in `@nestjs/typeorm` test suites.
147
+ *
148
+ * Production code should never call this. Calling at runtime
149
+ * after the module has been initialised would NOT clear the
150
+ * provider tree NestJS already built — it only clears the
151
+ * registration record that drives subsequent `forRoot` calls.
152
+ *
153
+ * @internal
154
+ */
155
+ static resetForTesting(): void;
156
+ static forRoot(options?: OutboxModuleOptions): DynamicModule;
157
+ /**
158
+ * Asynchronous registration of one dataSource's outbox stack.
159
+ * Symmetric with {@link forRoot} — call once per dataSource;
160
+ * provider-valued fields (`serializer`, `repository`) stay static
161
+ * because providers must be known at module-definition time, while
162
+ * `processor` / `staleness` / etc. resolve via the async factory.
163
+ */
164
+ static forRootAsync(options: OutboxModuleAsyncOptions): DynamicModule;
165
+ /**
166
+ * Register event classes that the outbox should know about — typed
167
+ * inputs to the per-dataSource `EventTypeRegistry` so the JSON
168
+ * serializer can revive stored payloads back into class instances,
169
+ * and so externalization mappings (`@Externalized`) can be picked
170
+ * up by the registry scan.
171
+ *
172
+ * @param eventTypes Event classes to register. Empty array is a
173
+ * no-op (matches `TypeOrmModule.forFeature([])`).
174
+ * @param options Optional per-call options. `dataSource` defaults
175
+ * to `'default'` — single-dataSource consumers omit it.
176
+ *
177
+ * @example Single-dataSource
178
+ * ```ts
179
+ * OutboxModule.forFeature([OrderPlacedEvent, OrderShippedEvent])
180
+ * ```
181
+ *
182
+ * @example Multi-dataSource
183
+ * ```ts
184
+ * OutboxModule.forFeature([BillingEvent], { dataSource: 'billing' })
185
+ * OutboxModule.forFeature([InventoryEvent], { dataSource: 'inventory' })
186
+ * ```
187
+ *
188
+ * Multiple `forFeature` calls accumulate into the per-dataSource
189
+ * registry. Duplicate registrations (same event class, same
190
+ * dataSource) throw at bootstrap with a clear message.
191
+ */
192
+ static forFeature(eventTypes: Type<object>[], options?: {
193
+ readonly dataSource?: string;
194
+ }): DynamicModule;
195
+ }
196
+ //# sourceMappingURL=outbox.module.d.ts.map