@rolandsall24/nest-mediator 1.0.0 → 1.2.0-beta.1
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 +184 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/context/mediator-context.d.ts +6 -0
- package/dist/lib/context/mediator-context.d.ts.map +1 -1
- package/dist/lib/context/mediator-context.js.map +1 -1
- package/dist/lib/event-store/strategies/index.d.ts +0 -6
- package/dist/lib/event-store/strategies/index.d.ts.map +1 -1
- package/dist/lib/event-store/strategies/index.js +5 -19
- package/dist/lib/event-store/strategies/index.js.map +1 -1
- package/dist/lib/event-store/strategies/persistence-consumer.strategy.d.ts +4 -5
- package/dist/lib/event-store/strategies/persistence-consumer.strategy.d.ts.map +1 -1
- package/dist/lib/event-store/strategies/persistence-consumer.strategy.js +15 -19
- package/dist/lib/event-store/strategies/persistence-consumer.strategy.js.map +1 -1
- package/dist/lib/mediator-flow/index.d.ts +4 -0
- package/dist/lib/mediator-flow/index.d.ts.map +1 -0
- package/dist/lib/mediator-flow/index.js +20 -0
- package/dist/lib/mediator-flow/index.js.map +1 -0
- package/dist/lib/mediator-flow/protocol.d.ts +104 -0
- package/dist/lib/mediator-flow/protocol.d.ts.map +1 -0
- package/dist/lib/mediator-flow/protocol.js +49 -0
- package/dist/lib/mediator-flow/protocol.js.map +1 -0
- package/dist/lib/mediator-flow/step-emitter.d.ts +24 -0
- package/dist/lib/mediator-flow/step-emitter.d.ts.map +1 -0
- package/dist/lib/mediator-flow/step-emitter.js +140 -0
- package/dist/lib/mediator-flow/step-emitter.js.map +1 -0
- package/dist/lib/mediator-flow/topology-collector.d.ts +22 -0
- package/dist/lib/mediator-flow/topology-collector.d.ts.map +1 -0
- package/dist/lib/mediator-flow/topology-collector.js +109 -0
- package/dist/lib/mediator-flow/topology-collector.js.map +1 -0
- package/dist/lib/nest-mediator.module.d.ts +127 -28
- package/dist/lib/nest-mediator.module.d.ts.map +1 -1
- package/dist/lib/nest-mediator.module.js +82 -13
- package/dist/lib/nest-mediator.module.js.map +1 -1
- package/dist/lib/services/command.bus.d.ts +10 -1
- package/dist/lib/services/command.bus.d.ts.map +1 -1
- package/dist/lib/services/command.bus.js +30 -3
- package/dist/lib/services/command.bus.js.map +1 -1
- package/dist/lib/services/event.bus.d.ts +23 -32
- package/dist/lib/services/event.bus.d.ts.map +1 -1
- package/dist/lib/services/event.bus.js +107 -40
- package/dist/lib/services/event.bus.js.map +1 -1
- package/dist/lib/services/mediator.bus.d.ts +138 -35
- package/dist/lib/services/mediator.bus.d.ts.map +1 -1
- package/dist/lib/services/mediator.bus.js +138 -35
- package/dist/lib/services/mediator.bus.js.map +1 -1
- package/dist/lib/services/pipeline.orchestrator.d.ts +12 -1
- package/dist/lib/services/pipeline.orchestrator.d.ts.map +1 -1
- package/dist/lib/services/pipeline.orchestrator.js +37 -3
- package/dist/lib/services/pipeline.orchestrator.js.map +1 -1
- package/dist/lib/services/query.bus.d.ts +10 -1
- package/dist/lib/services/query.bus.d.ts.map +1 -1
- package/dist/lib/services/query.bus.js +30 -3
- package/dist/lib/services/query.bus.js.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/images/execution-trace-flow.png +0 -0
- package/images/execution-trace-sequence.png +0 -0
- package/images/topology-view.png +0 -0
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -13,8 +13,18 @@ A lightweight CQRS mediator for NestJS — start simple, add event persistence w
|
|
|
13
13
|
- **Flexible Event Store** — PostgreSQL-backed, bring your own pool or repository
|
|
14
14
|
- **Optimistic Concurrency** — Sequence-based version control with `ConcurrencyError`
|
|
15
15
|
- **Correlation & Causation IDs** — Automatic distributed tracing via `AsyncLocalStorage`
|
|
16
|
+
- **MediatorFlow Dashboard** — Real-time visual monitoring, topology graphs, execution tracing
|
|
16
17
|
- **Zero config** — Decorator-based auto-discovery, built on NestJS DI
|
|
17
18
|
|
|
19
|
+
### Topology View
|
|
20
|
+

|
|
21
|
+
|
|
22
|
+
### Execution Trace — Flow
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
### Execution Trace — Sequence
|
|
26
|
+

|
|
27
|
+
|
|
18
28
|
## Installation
|
|
19
29
|
|
|
20
30
|
```bash
|
|
@@ -807,11 +817,185 @@ NestMediatorModule.forRoot({
|
|
|
807
817
|
mode?: 'audit' | 'source', // default: 'audit'
|
|
808
818
|
tableName?: string, // default: 'domain_events'
|
|
809
819
|
},
|
|
820
|
+
mediatorFlow?: {
|
|
821
|
+
enabled: boolean, // enable telemetry export
|
|
822
|
+
collectorUrl: string, // MediatorFlow server URL
|
|
823
|
+
serviceName?: string, // default: 'unknown'
|
|
824
|
+
batchSize?: number, // default: 50
|
|
825
|
+
flushIntervalMs?: number, // default: 2000
|
|
826
|
+
includePayloads?: boolean, // default: false
|
|
827
|
+
httpTimeoutMs?: number, // default: 3000
|
|
828
|
+
},
|
|
810
829
|
})
|
|
811
830
|
```
|
|
812
831
|
|
|
813
832
|
---
|
|
814
833
|
|
|
834
|
+
## MediatorFlow — Visual Monitoring Dashboard
|
|
835
|
+
|
|
836
|
+
MediatorFlow is a real-time monitoring dashboard that visualizes every command, query, event, and consumer execution in your application. It ships as a standalone server (`mediator-flow-server`) with an embedded React dashboard.
|
|
837
|
+
|
|
838
|
+
```
|
|
839
|
+
NestJS App (@rolandsall24/nest-mediator)
|
|
840
|
+
|
|
|
841
|
+
+---> POST /collect/topology (on boot — sends full architecture map)
|
|
842
|
+
+---> POST /collect/steps (batched — execution telemetry)
|
|
843
|
+
|
|
|
844
|
+
v
|
|
845
|
+
MediatorFlow Server (NestJS + PostgreSQL)
|
|
846
|
+
|
|
|
847
|
+
v
|
|
848
|
+
React Dashboard (topology graph, trace list, execution flow, stats)
|
|
849
|
+
```
|
|
850
|
+
|
|
851
|
+
### What You Get
|
|
852
|
+
|
|
853
|
+
- **Real-time stats dashboard** — Throughput, error rate, top slow handlers, top errors at a glance
|
|
854
|
+
- **Interactive topology graph** — Visual map of your entire CQRS architecture: commands, handlers, events, consumers, behaviors, and their connections. Click any node for details.
|
|
855
|
+
- **Paginated trace list** — Every command/query execution as a trace with status, duration, step count. Search and filter by entry name, status, or service.
|
|
856
|
+
- **Execution flow visualization** — Click a trace to see a full DAG (directed acyclic graph) showing the causation chain: which handler published which event, which consumers ran, where errors occurred.
|
|
857
|
+
- **Sequence diagram view** — Step-by-step chronological view with compact mode for dense traces
|
|
858
|
+
- **Compensation chain display** — When saga compensation fires, see the full rollback flow
|
|
859
|
+
- **Category filtering** — Toggle visibility of commands, events, consumers, behaviors in any graph view
|
|
860
|
+
- **Resizable graph nodes** — Drag to resize any node in topology or execution flow views
|
|
861
|
+
|
|
862
|
+
### Quick Start — Docker (Recommended)
|
|
863
|
+
|
|
864
|
+
**Option A: Pull from DockerHub** (fastest)
|
|
865
|
+
|
|
866
|
+
```bash
|
|
867
|
+
docker run -d -p 4800:4800 --name mediatorflow rolandsall24/mediatorflow:latest
|
|
868
|
+
```
|
|
869
|
+
|
|
870
|
+
**Option B: Build locally**
|
|
871
|
+
|
|
872
|
+
```bash
|
|
873
|
+
cd mediator-flow-server
|
|
874
|
+
npm run docker:up # builds and starts on port 4800
|
|
875
|
+
```
|
|
876
|
+
|
|
877
|
+
Open [http://localhost:4800](http://localhost:4800) to see the dashboard.
|
|
878
|
+
|
|
879
|
+
To stop:
|
|
880
|
+
```bash
|
|
881
|
+
npm run docker:down
|
|
882
|
+
# or if using Option A:
|
|
883
|
+
docker rm -f mediatorflow
|
|
884
|
+
```
|
|
885
|
+
|
|
886
|
+
### Quick Start — Local Development
|
|
887
|
+
|
|
888
|
+
```bash
|
|
889
|
+
cd mediator-flow-server
|
|
890
|
+
|
|
891
|
+
# 1. Start PostgreSQL (port 5433)
|
|
892
|
+
npm run dev:db
|
|
893
|
+
|
|
894
|
+
# 2. Start API + UI with hot reload
|
|
895
|
+
npm run dev:start
|
|
896
|
+
|
|
897
|
+
# To stop everything:
|
|
898
|
+
npm run dev:stop
|
|
899
|
+
```
|
|
900
|
+
|
|
901
|
+
The API runs on `http://localhost:4000` and the UI dev server on `http://localhost:5173`.
|
|
902
|
+
|
|
903
|
+
### Enable Telemetry in Your App
|
|
904
|
+
|
|
905
|
+
Add the `mediatorFlow` option to your module configuration. That's it — the library handles batching, flushing, and topology export automatically.
|
|
906
|
+
|
|
907
|
+
```typescript
|
|
908
|
+
import { Module } from '@nestjs/common';
|
|
909
|
+
import { NestMediatorModule } from '@rolandsall24/nest-mediator';
|
|
910
|
+
|
|
911
|
+
@Module({
|
|
912
|
+
imports: [
|
|
913
|
+
NestMediatorModule.forRoot({
|
|
914
|
+
enableLogging: true,
|
|
915
|
+
mediatorFlow: {
|
|
916
|
+
enabled: true,
|
|
917
|
+
collectorUrl: 'http://localhost:4800', // MediatorFlow server URL
|
|
918
|
+
serviceName: 'order-service', // identifies your service in the dashboard
|
|
919
|
+
},
|
|
920
|
+
}),
|
|
921
|
+
],
|
|
922
|
+
providers: [/* your handlers, consumers, etc. */],
|
|
923
|
+
})
|
|
924
|
+
export class AppModule {}
|
|
925
|
+
```
|
|
926
|
+
|
|
927
|
+
### Configuration Options
|
|
928
|
+
|
|
929
|
+
| Option | Default | Description |
|
|
930
|
+
|--------|---------|-------------|
|
|
931
|
+
| `enabled` | — | Enable/disable telemetry export |
|
|
932
|
+
| `collectorUrl` | — | MediatorFlow server URL (e.g., `http://localhost:4800`) |
|
|
933
|
+
| `serviceName` | `'unknown'` | Service name shown in the dashboard |
|
|
934
|
+
| `batchSize` | `50` | Number of steps to buffer before flushing |
|
|
935
|
+
| `flushIntervalMs` | `2000` | Maximum time between flushes (ms) |
|
|
936
|
+
| `includePayloads` | `false` | Include command/event payloads in telemetry (may contain sensitive data) |
|
|
937
|
+
| `httpTimeoutMs` | `3000` | Timeout for HTTP flush calls to the collector |
|
|
938
|
+
|
|
939
|
+
### How It Works
|
|
940
|
+
|
|
941
|
+
**On application boot**, the library sends your full architecture topology to the MediatorFlow server — every registered command, handler, event, consumer (with criticality and compensation info), behavior (with priority and scope), and aggregate. This builds the topology graph.
|
|
942
|
+
|
|
943
|
+
**During runtime**, every execution step is captured as a lightweight telemetry event:
|
|
944
|
+
|
|
945
|
+
| Step Type | When |
|
|
946
|
+
|-----------|------|
|
|
947
|
+
| `COMMAND_DISPATCHED` | Command enters the mediator |
|
|
948
|
+
| `COMMAND_HANDLER_STARTED/COMPLETED/FAILED` | Handler lifecycle |
|
|
949
|
+
| `QUERY_DISPATCHED` | Query enters the mediator |
|
|
950
|
+
| `QUERY_HANDLER_STARTED/COMPLETED/FAILED` | Handler lifecycle |
|
|
951
|
+
| `BEHAVIOR_ENTERED/COMPLETED/FAILED` | Pipeline behavior execution |
|
|
952
|
+
| `EVENT_PUBLISHED` | Event dispatched to consumers |
|
|
953
|
+
| `CRITICAL_CONSUMER_STARTED/COMPLETED/FAILED` | Critical consumer lifecycle |
|
|
954
|
+
| `NONCRITICAL_CONSUMER_DISPATCHED/COMPLETED/FAILED` | Non-critical consumer lifecycle |
|
|
955
|
+
| `COMPENSATION_STARTED/COMPLETED/FAILED` | Compensation chain execution |
|
|
956
|
+
| `COMPENSATING_EVENT_PUBLISHED` | Compensating event emitted |
|
|
957
|
+
|
|
958
|
+
Steps are buffered in memory and flushed to the server in batches — either when the buffer reaches `batchSize` or every `flushIntervalMs`, whichever comes first. Flushing is fire-and-forget: if the server is down, steps are dropped and the application continues normally.
|
|
959
|
+
|
|
960
|
+
Each step carries the `correlationId` and `causationId` from `AsyncLocalStorage`, so the dashboard can reconstruct the full execution tree for any trace.
|
|
961
|
+
|
|
962
|
+
### External Database
|
|
963
|
+
|
|
964
|
+
By default, Docker mode runs PostgreSQL inside the container. To use an external database (e.g., AWS RDS):
|
|
965
|
+
|
|
966
|
+
```bash
|
|
967
|
+
docker run -d -p 4800:4800 \
|
|
968
|
+
-e DATABASE_URL=postgres://user:pass@your-rds.amazonaws.com:5432/mediatorflow \
|
|
969
|
+
rolandsall24/mediatorflow:latest
|
|
970
|
+
```
|
|
971
|
+
|
|
972
|
+
Or with docker compose:
|
|
973
|
+
|
|
974
|
+
```bash
|
|
975
|
+
DATABASE_URL=postgres://user:pass@your-rds.amazonaws.com:5432/mediatorflow \
|
|
976
|
+
docker compose up -d
|
|
977
|
+
```
|
|
978
|
+
|
|
979
|
+
The embedded PostgreSQL is automatically skipped when `DATABASE_URL` points to a non-localhost host. Schema migrations run against the external database.
|
|
980
|
+
|
|
981
|
+
### Environment Variables
|
|
982
|
+
|
|
983
|
+
| Variable | Description | Default |
|
|
984
|
+
|----------|-------------|---------|
|
|
985
|
+
| `DATABASE_URL` | External PostgreSQL connection string (skips embedded DB) | — |
|
|
986
|
+
| `PORT` | API port | `4800` |
|
|
987
|
+
| `POSTGRES_USER` | Embedded DB username | `mediatorflow` |
|
|
988
|
+
| `POSTGRES_PASSWORD` | Embedded DB password | `mediatorflow` |
|
|
989
|
+
| `POSTGRES_DB` | Embedded DB name | `mediatorflow` |
|
|
990
|
+
|
|
991
|
+
For full documentation, see the [DockerHub page](https://hub.docker.com/r/rolandsall24/mediatorflow).
|
|
992
|
+
|
|
993
|
+
### Zero Overhead When Disabled
|
|
994
|
+
|
|
995
|
+
When `mediatorFlow.enabled` is `false` (or not set), the `StepEmitter` is still registered as a NestJS provider but its `emit()` method returns immediately on line 1 — zero allocation, zero network calls. The `wrapAsync()` method skips telemetry entirely and just executes your function directly. There is no performance impact when telemetry is off.
|
|
996
|
+
|
|
997
|
+
---
|
|
998
|
+
|
|
815
999
|
## API Reference
|
|
816
1000
|
|
|
817
1001
|
### Interfaces
|
package/dist/index.d.ts
CHANGED
|
@@ -6,5 +6,6 @@ export * from './lib/exceptions/index.js';
|
|
|
6
6
|
export * from './lib/context/index.js';
|
|
7
7
|
export * from './lib/aggregate/index.js';
|
|
8
8
|
export * from './lib/event-store/index.js';
|
|
9
|
+
export type { MediatorFlowExporterConfig } from './lib/mediator-flow/protocol.js';
|
|
9
10
|
export * from './lib/nest-mediator.module.js';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,2BAA2B,CAAC;AAG1C,cAAc,2BAA2B,CAAC;AAG1C,cAAc,yBAAyB,CAAC;AAGxC,cAAc,0BAA0B,CAAC;AAGzC,cAAc,2BAA2B,CAAC;AAG1C,cAAc,wBAAwB,CAAC;AAGvC,cAAc,0BAA0B,CAAC;AAGzC,cAAc,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,2BAA2B,CAAC;AAG1C,cAAc,2BAA2B,CAAC;AAG1C,cAAc,yBAAyB,CAAC;AAGxC,cAAc,0BAA0B,CAAC;AAGzC,cAAc,2BAA2B,CAAC;AAG1C,cAAc,wBAAwB,CAAC;AAGvC,cAAc,0BAA0B,CAAC;AAGzC,cAAc,4BAA4B,CAAC;AAE3C,YAAY,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAGlF,cAAc,+BAA+B,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,aAAa;AACb,4DAA0C;AAE1C,aAAa;AACb,4DAA0C;AAE1C,WAAW;AACX,0DAAwC;AAExC,YAAY;AACZ,2DAAyC;AAEzC,aAAa;AACb,4DAA0C;AAE1C,UAAU;AACV,yDAAuC;AAEvC,6BAA6B;AAC7B,2DAAyC;AAEzC,cAAc;AACd,6DAA2C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,aAAa;AACb,4DAA0C;AAE1C,aAAa;AACb,4DAA0C;AAE1C,WAAW;AACX,0DAAwC;AAExC,YAAY;AACZ,2DAAyC;AAEzC,aAAa;AACb,4DAA0C;AAE1C,UAAU;AACV,yDAAuC;AAEvC,6BAA6B;AAC7B,2DAAyC;AAEzC,cAAc;AACd,6DAA2C;AAI3C,SAAS;AACT,gEAA8C"}
|
|
@@ -18,6 +18,12 @@ export interface MediatorContextData {
|
|
|
18
18
|
* and by child events as their causation_id (parent→child link).
|
|
19
19
|
*/
|
|
20
20
|
currentEventId?: string;
|
|
21
|
+
/**
|
|
22
|
+
* The name of the handler currently executing.
|
|
23
|
+
* Set before a command/event handler runs so that child events
|
|
24
|
+
* can record which handler published them (publishedBy metadata).
|
|
25
|
+
*/
|
|
26
|
+
currentHandlerName?: string;
|
|
21
27
|
}
|
|
22
28
|
/**
|
|
23
29
|
* Manages context propagation through async operations using AsyncLocalStorage.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mediator-context.d.ts","sourceRoot":"","sources":["../../../src/lib/context/mediator-context.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"mediator-context.d.ts","sourceRoot":"","sources":["../../../src/lib/context/mediator-context.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;GAGG;AACH,cAAM,sBAAsB;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgD;IAExE;;;;;;OAMG;IACH,iBAAiB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAQ5D;;;;;;;OAOG;IACH,gBAAgB,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAU5E;;;;;OAKG;IACH,UAAU,IAAI,mBAAmB;IAYjC;;;;OAIG;IACH,UAAU,IAAI,OAAO;IAIrB;;;;;OAKG;IACH,gBAAgB,IAAI,MAAM;IAI1B;;;;OAIG;IACH,cAAc,IAAI,MAAM,GAAG,SAAS;CAGrC;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,wBAA+B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mediator-context.js","sourceRoot":"","sources":["../../../src/lib/context/mediator-context.ts"],"names":[],"mappings":";;;AAAA,6CAAgD;AAChD,+BAAoC;
|
|
1
|
+
{"version":3,"file":"mediator-context.js","sourceRoot":"","sources":["../../../src/lib/context/mediator-context.ts"],"names":[],"mappings":";;;AAAA,6CAAgD;AAChD,+BAAoC;AAiCpC;;;GAGG;AACH,MAAM,sBAAsB;IAA5B;QACmB,YAAO,GAAG,IAAI,+BAAiB,EAAuB,CAAC;IAgF1E,CAAC;IA9EC;;;;;;OAMG;IACH,iBAAiB,CAAI,QAA0B;QAC7C,MAAM,OAAO,GAAwB;YACnC,aAAa,EAAE,IAAA,SAAM,GAAE;YACvB,WAAW,EAAE,SAAS;SACvB,CAAC;QACF,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;;OAOG;IACH,gBAAgB,CAAI,OAAe,EAAE,QAA0B;QAC7D,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACxC,MAAM,YAAY,GAAwB;YACxC,aAAa,EAAE,OAAO,EAAE,aAAa,IAAI,IAAA,SAAM,GAAE;YACjD,WAAW,EAAE,OAAO,EAAE,cAAc;YACpC,cAAc,EAAE,OAAO;SACxB,CAAC;QACF,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAClD,CAAC;IAED;;;;;OAKG;IACH,UAAU;QACR,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACtC,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,KAAK,CAAC;QACf,CAAC;QACD,yCAAyC;QACzC,OAAO;YACL,aAAa,EAAE,IAAA,SAAM,GAAE;YACvB,WAAW,EAAE,SAAS;SACvB,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,SAAS,CAAC;IAC/C,CAAC;IAED;;;;;OAKG;IACH,gBAAgB;QACd,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,aAAa,CAAC;IACzC,CAAC;IAED;;;;OAIG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,WAAW,CAAC;IACvC,CAAC;CACF;AAED;;;GAGG;AACU,QAAA,eAAe,GAAG,IAAI,sBAAsB,EAAE,CAAC"}
|
|
@@ -2,12 +2,6 @@ import { Provider } from '@nestjs/common';
|
|
|
2
2
|
import { EventStoreConfig } from '../../interfaces/index.js';
|
|
3
3
|
export { IEventStoreStrategy } from './event-store-strategy.interface.js';
|
|
4
4
|
export { ISchemaManager } from './schema-manager.interface.js';
|
|
5
|
-
export { PostgresSchemaManager } from './postgres-schema-manager.js';
|
|
6
|
-
export { AbstractPostgresConnectionStrategy } from './abstract-postgres-connection.strategy.js';
|
|
7
|
-
export { ExistingPoolStrategy } from './existing-pool.strategy.js';
|
|
8
|
-
export { UrlConnectionStrategy } from './url-connection.strategy.js';
|
|
9
|
-
export { CustomRepositoryStrategy } from './custom-repository.strategy.js';
|
|
10
|
-
export { PersistenceConsumerStrategy } from './persistence-consumer.strategy.js';
|
|
11
5
|
/**
|
|
12
6
|
* Configure event store by:
|
|
13
7
|
* 1. Running ONE matching repository strategy
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/event-store/strategies/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAQ7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/event-store/strategies/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAQ7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAe/D;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,QAAQ,EAAE,EACrB,MAAM,EAAE,gBAAgB,GACvB,IAAI,CAYN"}
|
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PersistenceConsumerStrategy = exports.CustomRepositoryStrategy = exports.UrlConnectionStrategy = exports.ExistingPoolStrategy = exports.AbstractPostgresConnectionStrategy = exports.PostgresSchemaManager = void 0;
|
|
4
3
|
exports.configureEventStore = configureEventStore;
|
|
5
4
|
const existing_pool_strategy_js_1 = require("./existing-pool.strategy.js");
|
|
6
5
|
const url_connection_strategy_js_1 = require("./url-connection.strategy.js");
|
|
7
6
|
const custom_repository_strategy_js_1 = require("./custom-repository.strategy.js");
|
|
8
7
|
const persistence_consumer_strategy_js_1 = require("./persistence-consumer.strategy.js");
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
Object.defineProperty(exports, "PostgresSchemaManager", { enumerable: true, get: function () { return postgres_schema_manager_js_1.PostgresSchemaManager; } });
|
|
12
|
-
var abstract_postgres_connection_strategy_js_1 = require("./abstract-postgres-connection.strategy.js");
|
|
13
|
-
Object.defineProperty(exports, "AbstractPostgresConnectionStrategy", { enumerable: true, get: function () { return abstract_postgres_connection_strategy_js_1.AbstractPostgresConnectionStrategy; } });
|
|
14
|
-
var existing_pool_strategy_js_2 = require("./existing-pool.strategy.js");
|
|
15
|
-
Object.defineProperty(exports, "ExistingPoolStrategy", { enumerable: true, get: function () { return existing_pool_strategy_js_2.ExistingPoolStrategy; } });
|
|
16
|
-
var url_connection_strategy_js_2 = require("./url-connection.strategy.js");
|
|
17
|
-
Object.defineProperty(exports, "UrlConnectionStrategy", { enumerable: true, get: function () { return url_connection_strategy_js_2.UrlConnectionStrategy; } });
|
|
18
|
-
var custom_repository_strategy_js_2 = require("./custom-repository.strategy.js");
|
|
19
|
-
Object.defineProperty(exports, "CustomRepositoryStrategy", { enumerable: true, get: function () { return custom_repository_strategy_js_2.CustomRepositoryStrategy; } });
|
|
20
|
-
var persistence_consumer_strategy_js_2 = require("./persistence-consumer.strategy.js");
|
|
21
|
-
Object.defineProperty(exports, "PersistenceConsumerStrategy", { enumerable: true, get: function () { return persistence_consumer_strategy_js_2.PersistenceConsumerStrategy; } });
|
|
8
|
+
// Note: Concrete strategy implementations (ExistingPoolStrategy, UrlConnectionStrategy, etc.)
|
|
9
|
+
// are intentionally kept internal. Users configure the event store via NestMediatorModule.forRoot().
|
|
22
10
|
/**
|
|
23
11
|
* Repository strategies - only ONE should match based on config.
|
|
24
12
|
* Order matters: more specific checks first.
|
|
@@ -28,10 +16,6 @@ const repositoryStrategies = [
|
|
|
28
16
|
new existing_pool_strategy_js_1.ExistingPoolStrategy(), // Option 2: useExistingPool
|
|
29
17
|
new url_connection_strategy_js_1.UrlConnectionStrategy(), // Option 1: url
|
|
30
18
|
];
|
|
31
|
-
/**
|
|
32
|
-
* Persistence consumer - always runs after repository is configured.
|
|
33
|
-
*/
|
|
34
|
-
const persistenceConsumerStrategy = new persistence_consumer_strategy_js_1.PersistenceConsumerStrategy();
|
|
35
19
|
/**
|
|
36
20
|
* Configure event store by:
|
|
37
21
|
* 1. Running ONE matching repository strategy
|
|
@@ -45,6 +29,8 @@ function configureEventStore(providers, config) {
|
|
|
45
29
|
break;
|
|
46
30
|
}
|
|
47
31
|
}
|
|
48
|
-
|
|
32
|
+
// 2. Always register the persistence consumer
|
|
33
|
+
const registrar = new persistence_consumer_strategy_js_1.PersistenceConsumerRegistrar();
|
|
34
|
+
providers.push(registrar.createProvider(config));
|
|
49
35
|
}
|
|
50
36
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/event-store/strategies/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/event-store/strategies/index.ts"],"names":[],"mappings":";;AA8BA,kDAeC;AA1CD,2EAAmE;AACnE,6EAAqE;AACrE,mFAA2E;AAC3E,yFAAkF;AAMlF,8FAA8F;AAC9F,qGAAqG;AAErG;;;GAGG;AACH,MAAM,oBAAoB,GAA0B;IAClD,IAAI,wDAAwB,EAAE,EAAG,kCAAkC;IACnE,IAAI,gDAAoB,EAAE,EAAO,4BAA4B;IAC7D,IAAI,kDAAqB,EAAE,EAAM,gBAAgB;CAClD,CAAC;AAEF;;;;GAIG;AACH,SAAgB,mBAAmB,CACjC,SAAqB,EACrB,MAAwB;IAExB,8DAA8D;IAC9D,KAAK,MAAM,QAAQ,IAAI,oBAAoB,EAAE,CAAC;QAC5C,IAAI,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;YAC/B,SAAS,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;YAC3C,MAAM;QACR,CAAC;IACH,CAAC;IAED,8CAA8C;IAC9C,MAAM,SAAS,GAAG,IAAI,+DAA4B,EAAE,CAAC;IACrD,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Provider } from '@nestjs/common';
|
|
2
2
|
import { EventStoreConfig } from '../../interfaces/index.js';
|
|
3
|
-
import { IEventStoreStrategy } from './event-store-strategy.interface.js';
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
4
|
+
* Registers the persistence consumer on the event bus.
|
|
5
|
+
* This always runs when an event store is configured — it is not a strategy.
|
|
6
6
|
*/
|
|
7
|
-
export declare class
|
|
8
|
-
|
|
9
|
-
invoke(config: EventStoreConfig): Provider[];
|
|
7
|
+
export declare class PersistenceConsumerRegistrar {
|
|
8
|
+
createProvider(config: EventStoreConfig): Provider;
|
|
10
9
|
}
|
|
11
10
|
//# sourceMappingURL=persistence-consumer.strategy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistence-consumer.strategy.d.ts","sourceRoot":"","sources":["../../../../src/lib/event-store/strategies/persistence-consumer.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAU,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAiD,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"persistence-consumer.strategy.d.ts","sourceRoot":"","sources":["../../../../src/lib/event-store/strategies/persistence-consumer.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAU,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAiD,MAAM,2BAA2B,CAAC;AAM5G;;;GAGG;AACH,qBAAa,4BAA4B;IACvC,cAAc,CAAC,MAAM,EAAE,gBAAgB,GAAG,QAAQ;CAYnD"}
|
|
@@ -1,32 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.PersistenceConsumerRegistrar = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
const index_js_1 = require("../../interfaces/index.js");
|
|
6
6
|
const event_store_persistence_consumer_js_1 = require("../event-store-persistence.consumer.js");
|
|
7
7
|
const event_bus_js_1 = require("../../services/event.bus.js");
|
|
8
8
|
const logger = new common_1.Logger('EventStore');
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Registers the persistence consumer on the event bus.
|
|
11
|
+
* This always runs when an event store is configured — it is not a strategy.
|
|
11
12
|
*/
|
|
12
|
-
class
|
|
13
|
-
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const consumer = new event_store_persistence_consumer_js_1.EventStorePersistenceConsumer(repo, config);
|
|
22
|
-
eventBus.registerSystemConsumer(consumer, 'EventStorePersistenceConsumer');
|
|
23
|
-
logger.log(`Event store persistence consumer registered (mode: ${config.mode || 'audit'})`);
|
|
24
|
-
return consumer;
|
|
25
|
-
},
|
|
26
|
-
inject: [index_js_1.EVENT_STORE_REPOSITORY, event_bus_js_1.EventBus],
|
|
13
|
+
class PersistenceConsumerRegistrar {
|
|
14
|
+
createProvider(config) {
|
|
15
|
+
return {
|
|
16
|
+
provide: 'EVENT_STORE_PERSISTENCE_CONSUMER',
|
|
17
|
+
useFactory: (repo, eventBus) => {
|
|
18
|
+
const consumer = new event_store_persistence_consumer_js_1.EventStorePersistenceConsumer(repo, config);
|
|
19
|
+
eventBus.registerSystemConsumer(consumer, 'EventStorePersistenceConsumer');
|
|
20
|
+
logger.log(`Event store persistence consumer registered (mode: ${config.mode || 'audit'})`);
|
|
21
|
+
return consumer;
|
|
27
22
|
},
|
|
28
|
-
|
|
23
|
+
inject: [index_js_1.EVENT_STORE_REPOSITORY, event_bus_js_1.EventBus],
|
|
24
|
+
};
|
|
29
25
|
}
|
|
30
26
|
}
|
|
31
|
-
exports.
|
|
27
|
+
exports.PersistenceConsumerRegistrar = PersistenceConsumerRegistrar;
|
|
32
28
|
//# sourceMappingURL=persistence-consumer.strategy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistence-consumer.strategy.js","sourceRoot":"","sources":["../../../../src/lib/event-store/strategies/persistence-consumer.strategy.ts"],"names":[],"mappings":";;;AAAA,2CAAkD;AAClD,wDAA4G;AAC5G,gGAAuF;AACvF,8DAAuD;
|
|
1
|
+
{"version":3,"file":"persistence-consumer.strategy.js","sourceRoot":"","sources":["../../../../src/lib/event-store/strategies/persistence-consumer.strategy.ts"],"names":[],"mappings":";;;AAAA,2CAAkD;AAClD,wDAA4G;AAC5G,gGAAuF;AACvF,8DAAuD;AAEvD,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,YAAY,CAAC,CAAC;AAExC;;;GAGG;AACH,MAAa,4BAA4B;IACvC,cAAc,CAAC,MAAwB;QACrC,OAAO;YACL,OAAO,EAAE,kCAAkC;YAC3C,UAAU,EAAE,CAAC,IAA2B,EAAE,QAAkB,EAAE,EAAE;gBAC9D,MAAM,QAAQ,GAAG,IAAI,mEAA6B,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;gBACjE,QAAQ,CAAC,sBAAsB,CAAC,QAAQ,EAAE,+BAA+B,CAAC,CAAC;gBAC3E,MAAM,CAAC,GAAG,CAAC,sDAAsD,MAAM,CAAC,IAAI,IAAI,OAAO,GAAG,CAAC,CAAC;gBAC5F,OAAO,QAAQ,CAAC;YAClB,CAAC;YACD,MAAM,EAAE,CAAC,iCAAsB,EAAE,uBAAQ,CAAC;SAC3C,CAAC;IACJ,CAAC;CACF;AAbD,oEAaC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/mediator-flow/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./protocol.js"), exports);
|
|
18
|
+
__exportStar(require("./step-emitter.js"), exports);
|
|
19
|
+
__exportStar(require("./topology-collector.js"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/mediator-flow/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,oDAAkC;AAClC,0DAAwC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MediatorFlow Protocol Types
|
|
3
|
+
*
|
|
4
|
+
* Shared TypeScript interfaces used by both the exporter (nest-mediator library)
|
|
5
|
+
* and the collector server (mediator-flow-server).
|
|
6
|
+
*/
|
|
7
|
+
export interface CommandRegistration {
|
|
8
|
+
commandName: string;
|
|
9
|
+
handlerName: string;
|
|
10
|
+
}
|
|
11
|
+
export interface QueryRegistration {
|
|
12
|
+
queryName: string;
|
|
13
|
+
handlerName: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ConsumerRegistration {
|
|
16
|
+
consumerName: string;
|
|
17
|
+
criticality: string;
|
|
18
|
+
order: number;
|
|
19
|
+
hasCompensation: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface EventRegistration {
|
|
22
|
+
eventName: string;
|
|
23
|
+
aggregateType?: string;
|
|
24
|
+
consumers: ConsumerRegistration[];
|
|
25
|
+
}
|
|
26
|
+
export interface BehaviorRegistration {
|
|
27
|
+
behaviorName: string;
|
|
28
|
+
priority: number;
|
|
29
|
+
scope: string;
|
|
30
|
+
requestTypeName?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface AggregateRegistration {
|
|
33
|
+
aggregateType: string;
|
|
34
|
+
repositoryName: string;
|
|
35
|
+
eventTypes: string[];
|
|
36
|
+
}
|
|
37
|
+
export interface TopologyExport {
|
|
38
|
+
serviceName: string;
|
|
39
|
+
instanceId: string;
|
|
40
|
+
bootedAt: string;
|
|
41
|
+
libraryVersion: string;
|
|
42
|
+
commands: CommandRegistration[];
|
|
43
|
+
queries: QueryRegistration[];
|
|
44
|
+
events: EventRegistration[];
|
|
45
|
+
behaviors: BehaviorRegistration[];
|
|
46
|
+
aggregates: AggregateRegistration[];
|
|
47
|
+
}
|
|
48
|
+
export declare enum StepType {
|
|
49
|
+
COMMAND_DISPATCHED = "COMMAND_DISPATCHED",
|
|
50
|
+
COMMAND_HANDLER_STARTED = "COMMAND_HANDLER_STARTED",
|
|
51
|
+
COMMAND_HANDLER_COMPLETED = "COMMAND_HANDLER_COMPLETED",
|
|
52
|
+
COMMAND_HANDLER_FAILED = "COMMAND_HANDLER_FAILED",
|
|
53
|
+
QUERY_DISPATCHED = "QUERY_DISPATCHED",
|
|
54
|
+
QUERY_HANDLER_STARTED = "QUERY_HANDLER_STARTED",
|
|
55
|
+
QUERY_HANDLER_COMPLETED = "QUERY_HANDLER_COMPLETED",
|
|
56
|
+
QUERY_HANDLER_FAILED = "QUERY_HANDLER_FAILED",
|
|
57
|
+
EVENT_PUBLISHED = "EVENT_PUBLISHED",
|
|
58
|
+
SYSTEM_CONSUMER_STARTED = "SYSTEM_CONSUMER_STARTED",
|
|
59
|
+
SYSTEM_CONSUMER_COMPLETED = "SYSTEM_CONSUMER_COMPLETED",
|
|
60
|
+
SYSTEM_CONSUMER_FAILED = "SYSTEM_CONSUMER_FAILED",
|
|
61
|
+
CRITICAL_CONSUMER_STARTED = "CRITICAL_CONSUMER_STARTED",
|
|
62
|
+
CRITICAL_CONSUMER_COMPLETED = "CRITICAL_CONSUMER_COMPLETED",
|
|
63
|
+
CRITICAL_CONSUMER_FAILED = "CRITICAL_CONSUMER_FAILED",
|
|
64
|
+
NONCRITICAL_CONSUMER_DISPATCHED = "NONCRITICAL_CONSUMER_DISPATCHED",
|
|
65
|
+
NONCRITICAL_CONSUMER_COMPLETED = "NONCRITICAL_CONSUMER_COMPLETED",
|
|
66
|
+
NONCRITICAL_CONSUMER_FAILED = "NONCRITICAL_CONSUMER_FAILED",
|
|
67
|
+
BEHAVIOR_ENTERED = "BEHAVIOR_ENTERED",
|
|
68
|
+
BEHAVIOR_COMPLETED = "BEHAVIOR_COMPLETED",
|
|
69
|
+
BEHAVIOR_FAILED = "BEHAVIOR_FAILED",
|
|
70
|
+
COMPENSATION_STARTED = "COMPENSATION_STARTED",
|
|
71
|
+
COMPENSATION_COMPLETED = "COMPENSATION_COMPLETED",
|
|
72
|
+
COMPENSATION_FAILED = "COMPENSATION_FAILED",
|
|
73
|
+
COMPENSATING_EVENT_PUBLISHED = "COMPENSATING_EVENT_PUBLISHED",
|
|
74
|
+
RETRY_ATTEMPTED = "RETRY_ATTEMPTED"
|
|
75
|
+
}
|
|
76
|
+
export interface ExecutionStep {
|
|
77
|
+
stepId: string;
|
|
78
|
+
instanceId: string;
|
|
79
|
+
type: StepType;
|
|
80
|
+
timestamp: string;
|
|
81
|
+
correlationId: string;
|
|
82
|
+
causationId?: string;
|
|
83
|
+
eventId?: string;
|
|
84
|
+
durationMs?: number;
|
|
85
|
+
name: string;
|
|
86
|
+
error?: string;
|
|
87
|
+
payload?: Record<string, unknown>;
|
|
88
|
+
metadata?: Record<string, unknown>;
|
|
89
|
+
}
|
|
90
|
+
export interface StepBatch {
|
|
91
|
+
instanceId: string;
|
|
92
|
+
serviceName: string;
|
|
93
|
+
steps: ExecutionStep[];
|
|
94
|
+
}
|
|
95
|
+
export interface MediatorFlowExporterConfig {
|
|
96
|
+
enabled: boolean;
|
|
97
|
+
collectorUrl: string;
|
|
98
|
+
serviceName?: string;
|
|
99
|
+
batchSize?: number;
|
|
100
|
+
flushIntervalMs?: number;
|
|
101
|
+
includePayloads?: boolean;
|
|
102
|
+
httpTimeoutMs?: number;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../src/lib/mediator-flow/protocol.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MediatorFlow Protocol Types
|
|
4
|
+
*
|
|
5
|
+
* Shared TypeScript interfaces used by both the exporter (nest-mediator library)
|
|
6
|
+
* and the collector server (mediator-flow-server).
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.StepType = void 0;
|
|
10
|
+
// ─── Execution Step Types ───────────────────────────────────────────────────
|
|
11
|
+
var StepType;
|
|
12
|
+
(function (StepType) {
|
|
13
|
+
// Command lifecycle
|
|
14
|
+
StepType["COMMAND_DISPATCHED"] = "COMMAND_DISPATCHED";
|
|
15
|
+
StepType["COMMAND_HANDLER_STARTED"] = "COMMAND_HANDLER_STARTED";
|
|
16
|
+
StepType["COMMAND_HANDLER_COMPLETED"] = "COMMAND_HANDLER_COMPLETED";
|
|
17
|
+
StepType["COMMAND_HANDLER_FAILED"] = "COMMAND_HANDLER_FAILED";
|
|
18
|
+
// Query lifecycle
|
|
19
|
+
StepType["QUERY_DISPATCHED"] = "QUERY_DISPATCHED";
|
|
20
|
+
StepType["QUERY_HANDLER_STARTED"] = "QUERY_HANDLER_STARTED";
|
|
21
|
+
StepType["QUERY_HANDLER_COMPLETED"] = "QUERY_HANDLER_COMPLETED";
|
|
22
|
+
StepType["QUERY_HANDLER_FAILED"] = "QUERY_HANDLER_FAILED";
|
|
23
|
+
// Event lifecycle
|
|
24
|
+
StepType["EVENT_PUBLISHED"] = "EVENT_PUBLISHED";
|
|
25
|
+
// System consumer lifecycle
|
|
26
|
+
StepType["SYSTEM_CONSUMER_STARTED"] = "SYSTEM_CONSUMER_STARTED";
|
|
27
|
+
StepType["SYSTEM_CONSUMER_COMPLETED"] = "SYSTEM_CONSUMER_COMPLETED";
|
|
28
|
+
StepType["SYSTEM_CONSUMER_FAILED"] = "SYSTEM_CONSUMER_FAILED";
|
|
29
|
+
// Critical consumer lifecycle
|
|
30
|
+
StepType["CRITICAL_CONSUMER_STARTED"] = "CRITICAL_CONSUMER_STARTED";
|
|
31
|
+
StepType["CRITICAL_CONSUMER_COMPLETED"] = "CRITICAL_CONSUMER_COMPLETED";
|
|
32
|
+
StepType["CRITICAL_CONSUMER_FAILED"] = "CRITICAL_CONSUMER_FAILED";
|
|
33
|
+
// Non-critical consumer lifecycle
|
|
34
|
+
StepType["NONCRITICAL_CONSUMER_DISPATCHED"] = "NONCRITICAL_CONSUMER_DISPATCHED";
|
|
35
|
+
StepType["NONCRITICAL_CONSUMER_COMPLETED"] = "NONCRITICAL_CONSUMER_COMPLETED";
|
|
36
|
+
StepType["NONCRITICAL_CONSUMER_FAILED"] = "NONCRITICAL_CONSUMER_FAILED";
|
|
37
|
+
// Behavior lifecycle
|
|
38
|
+
StepType["BEHAVIOR_ENTERED"] = "BEHAVIOR_ENTERED";
|
|
39
|
+
StepType["BEHAVIOR_COMPLETED"] = "BEHAVIOR_COMPLETED";
|
|
40
|
+
StepType["BEHAVIOR_FAILED"] = "BEHAVIOR_FAILED";
|
|
41
|
+
// Compensation lifecycle
|
|
42
|
+
StepType["COMPENSATION_STARTED"] = "COMPENSATION_STARTED";
|
|
43
|
+
StepType["COMPENSATION_COMPLETED"] = "COMPENSATION_COMPLETED";
|
|
44
|
+
StepType["COMPENSATION_FAILED"] = "COMPENSATION_FAILED";
|
|
45
|
+
StepType["COMPENSATING_EVENT_PUBLISHED"] = "COMPENSATING_EVENT_PUBLISHED";
|
|
46
|
+
// Retry lifecycle
|
|
47
|
+
StepType["RETRY_ATTEMPTED"] = "RETRY_ATTEMPTED";
|
|
48
|
+
})(StepType || (exports.StepType = StepType = {}));
|
|
49
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../src/lib/mediator-flow/protocol.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAoDH,+EAA+E;AAE/E,IAAY,QA4CX;AA5CD,WAAY,QAAQ;IAClB,oBAAoB;IACpB,qDAAyC,CAAA;IACzC,+DAAmD,CAAA;IACnD,mEAAuD,CAAA;IACvD,6DAAiD,CAAA;IAEjD,kBAAkB;IAClB,iDAAqC,CAAA;IACrC,2DAA+C,CAAA;IAC/C,+DAAmD,CAAA;IACnD,yDAA6C,CAAA;IAE7C,kBAAkB;IAClB,+CAAmC,CAAA;IAEnC,4BAA4B;IAC5B,+DAAmD,CAAA;IACnD,mEAAuD,CAAA;IACvD,6DAAiD,CAAA;IAEjD,8BAA8B;IAC9B,mEAAuD,CAAA;IACvD,uEAA2D,CAAA;IAC3D,iEAAqD,CAAA;IAErD,kCAAkC;IAClC,+EAAmE,CAAA;IACnE,6EAAiE,CAAA;IACjE,uEAA2D,CAAA;IAE3D,qBAAqB;IACrB,iDAAqC,CAAA;IACrC,qDAAyC,CAAA;IACzC,+CAAmC,CAAA;IAEnC,yBAAyB;IACzB,yDAA6C,CAAA;IAC7C,6DAAiD,CAAA;IACjD,uDAA2C,CAAA;IAC3C,yEAA6D,CAAA;IAE7D,kBAAkB;IAClB,+CAAmC,CAAA;AACrC,CAAC,EA5CW,QAAQ,wBAAR,QAAQ,QA4CnB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { OnModuleDestroy } from '@nestjs/common';
|
|
2
|
+
import { ExecutionStep, StepType, MediatorFlowExporterConfig } from './protocol.js';
|
|
3
|
+
export declare class StepEmitter implements OnModuleDestroy {
|
|
4
|
+
private readonly logger;
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
private collectorUrl;
|
|
7
|
+
private serviceName;
|
|
8
|
+
private instanceId;
|
|
9
|
+
private batchSize;
|
|
10
|
+
private flushIntervalMs;
|
|
11
|
+
private includePayloads;
|
|
12
|
+
private httpTimeoutMs;
|
|
13
|
+
private buffer;
|
|
14
|
+
private flushTimer;
|
|
15
|
+
emit(type: StepType, name: string, extra?: Partial<Pick<ExecutionStep, 'eventId' | 'durationMs' | 'error' | 'payload' | 'metadata'>>): void;
|
|
16
|
+
wrapAsync<T>(startType: StepType, completedType: StepType, failedType: StepType, name: string, fn: () => Promise<T>, extra?: Partial<Pick<ExecutionStep, 'eventId' | 'payload' | 'metadata'>>): Promise<T>;
|
|
17
|
+
configure(config: MediatorFlowExporterConfig): void;
|
|
18
|
+
getInstanceId(): string;
|
|
19
|
+
getServiceName(): string;
|
|
20
|
+
getCollectorUrl(): string;
|
|
21
|
+
onModuleDestroy(): Promise<void>;
|
|
22
|
+
private flush;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=step-emitter.d.ts.map
|