@nextage/era-lib 1.0.177 → 1.0.179
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/build/events/base-event.controller.d.ts +36 -12
- package/build/events/base-event.controller.d.ts.map +1 -1
- package/build/events/base-event.controller.js +81 -47
- package/build/events/base-event.controller.js.map +1 -1
- package/build/events/base-listener.d.ts +4 -3
- package/build/events/base-listener.d.ts.map +1 -1
- package/build/events/base-listener.js +7 -2
- package/build/events/base-listener.js.map +1 -1
- package/build/events/base-nats-listener.d.ts +4 -3
- package/build/events/base-nats-listener.d.ts.map +1 -1
- package/build/events/base-nats-listener.js +7 -2
- package/build/events/base-nats-listener.js.map +1 -1
- package/build/events/base-nats-publisher.d.ts +4 -3
- package/build/events/base-nats-publisher.d.ts.map +1 -1
- package/build/events/base-nats-publisher.js +7 -2
- package/build/events/base-nats-publisher.js.map +1 -1
- package/build/events/base-publisher.d.ts +4 -3
- package/build/events/base-publisher.d.ts.map +1 -1
- package/build/events/base-publisher.js +7 -2
- package/build/events/base-publisher.js.map +1 -1
- package/build/events/event-relay.d.ts +26 -0
- package/build/events/event-relay.d.ts.map +1 -0
- package/build/events/event-relay.js +95 -0
- package/build/events/event-relay.js.map +1 -0
- package/build/events/index.d.ts +2 -0
- package/build/events/index.d.ts.map +1 -1
- package/build/events/index.js +2 -0
- package/build/events/index.js.map +1 -1
- package/build/events/interfaces.d.ts +11 -0
- package/build/events/interfaces.d.ts.map +1 -1
- package/build/events/publisher-registry.d.ts +21 -0
- package/build/events/publisher-registry.d.ts.map +1 -0
- package/build/events/publisher-registry.js +46 -0
- package/build/events/publisher-registry.js.map +1 -0
- package/build/events/types/index.d.ts +2 -0
- package/build/events/types/index.d.ts.map +1 -1
- package/build/events/types/index.js +2 -0
- package/build/events/types/index.js.map +1 -1
- package/build/events/types/outbox.interfaces.d.ts +10 -0
- package/build/events/types/outbox.interfaces.d.ts.map +1 -1
- package/build/events/types/relay.constants.d.ts +3 -0
- package/build/events/types/relay.constants.d.ts.map +1 -0
- package/build/events/types/relay.constants.js +9 -0
- package/build/events/types/relay.constants.js.map +1 -0
- package/build/events/types/relay.interfaces.d.ts +11 -0
- package/build/events/types/relay.interfaces.d.ts.map +1 -0
- package/build/events/types/relay.interfaces.js +5 -0
- package/build/events/types/relay.interfaces.js.map +1 -0
- package/package.json +1 -1
|
@@ -3,8 +3,9 @@ import { BaseMongoDoc } from '@nextage/nx-frame-be/build/common/base/base.interf
|
|
|
3
3
|
import { BaseController } from '@nextage/nx-frame-be/build/common/base/base.controller';
|
|
4
4
|
import { NxContext } from '@nextage/nx-frame-be';
|
|
5
5
|
import { Event, IPublisher } from './interfaces';
|
|
6
|
+
import { PublisherProvider } from './types/relay.interfaces';
|
|
6
7
|
import { QueueEventType } from './types/enums';
|
|
7
|
-
export declare abstract class BaseEventCtrl<TCreate extends Event, TUpdate extends Event, TRemove extends Event, TAttrs, TDoc extends BaseMongoDoc, TModel extends BaseModel<TAttrs, TDoc, any>> extends BaseController<TAttrs, TDoc, TModel> {
|
|
8
|
+
export declare abstract class BaseEventCtrl<TCreate extends Event, TUpdate extends Event, TRemove extends Event, TAttrs, TDoc extends BaseMongoDoc, TModel extends BaseModel<TAttrs, TDoc, any>> extends BaseController<TAttrs, TDoc, TModel> implements PublisherProvider {
|
|
8
9
|
/**
|
|
9
10
|
* Declarative publish field-map (Step 3.4c). The default parsePub* methods pick
|
|
10
11
|
* exactly these keys from the entity, replacing the ~57 hand-written per-controller
|
|
@@ -28,6 +29,16 @@ export declare abstract class BaseEventCtrl<TCreate extends Event, TUpdate exten
|
|
|
28
29
|
protected abstract createPublisher: IPublisher<TCreate>[];
|
|
29
30
|
protected abstract updatePublisher: IPublisher<TUpdate>[];
|
|
30
31
|
protected abstract removePublisher: IPublisher<TRemove>[];
|
|
32
|
+
constructor(config: {
|
|
33
|
+
model: TModel;
|
|
34
|
+
mergeUpdate?: boolean;
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* All publishers this controller owns (create + update + remove). Read LAZILY by
|
|
38
|
+
* the relay's publisher registry to route a `sent:false` outbox row back to its
|
|
39
|
+
* publisher family by subject — so it runs after the subclass field initialisers.
|
|
40
|
+
*/
|
|
41
|
+
eventPublishers(): IPublisher<Event>[];
|
|
31
42
|
private publishConfig?;
|
|
32
43
|
/**
|
|
33
44
|
* Inizializza la configurazione dei publisher (lazy initialization)
|
|
@@ -40,12 +51,24 @@ export declare abstract class BaseEventCtrl<TCreate extends Event, TUpdate exten
|
|
|
40
51
|
* @param context
|
|
41
52
|
*/
|
|
42
53
|
/**
|
|
54
|
+
* Build the parsed, ready-to-publish message for a write: parse the payload,
|
|
55
|
+
* resolve the subject (shared by every publisher of the type — same event on
|
|
56
|
+
* NATS + msg) and stamp the OUTGOING cascade meta from `context._event` (root
|
|
57
|
+
* when absent). Returns undefined when the type has no publisher/parser. Built
|
|
58
|
+
* ONCE and reused for both the outbox row and the immediate dispatch.
|
|
43
59
|
*
|
|
44
60
|
* @param item
|
|
45
61
|
* @param type
|
|
46
62
|
* @param context
|
|
47
63
|
*/
|
|
48
|
-
|
|
64
|
+
private buildMessage;
|
|
65
|
+
/**
|
|
66
|
+
* Dispatch a prepared message on every publisher of its type. Shared by the
|
|
67
|
+
* immediate post-commit dispatch and the relay replay.
|
|
68
|
+
*
|
|
69
|
+
* @param msg
|
|
70
|
+
*/
|
|
71
|
+
private publishMessage;
|
|
49
72
|
/**
|
|
50
73
|
* Overridable post-write / post-read enrichment of the RETURNED document (e.g.
|
|
51
74
|
* populate references, attach a joined aggregate). Runs AFTER the atomic write
|
|
@@ -98,22 +121,23 @@ export declare abstract class BaseEventCtrl<TCreate extends Event, TUpdate exten
|
|
|
98
121
|
*/
|
|
99
122
|
remove(id: string, context: NxContext): Promise<TDoc>;
|
|
100
123
|
/**
|
|
101
|
-
* Persist an outbox row (sent:false) for
|
|
102
|
-
*
|
|
103
|
-
*
|
|
124
|
+
* Persist an outbox row (sent:false) for the prepared message inside the
|
|
125
|
+
* caller's transaction. The row carries the subject + parsed payload + cascade
|
|
126
|
+
* meta, so the relay can replay it faithfully. Returns the row id, or undefined
|
|
127
|
+
* when there is no message or no outbox registered (the event is then still
|
|
128
|
+
* dispatched, just not tracked).
|
|
104
129
|
*
|
|
105
|
-
* @param
|
|
106
|
-
* @param type
|
|
130
|
+
* @param msg
|
|
107
131
|
* @param context
|
|
108
132
|
*/
|
|
109
133
|
private enqueueOutbox;
|
|
110
134
|
/**
|
|
111
|
-
* Dispatch the
|
|
112
|
-
* the transaction commits, so `publish` (a non-DB side effect) is
|
|
113
|
-
* by `withTransaction` and a broker failure leaves a recoverable
|
|
135
|
+
* Dispatch the prepared message to the broker, then mark the outbox row as sent.
|
|
136
|
+
* Runs AFTER the transaction commits, so `publish` (a non-DB side effect) is
|
|
137
|
+
* never retried by `withTransaction` and a broker failure leaves a recoverable
|
|
138
|
+
* sent:false row for the relay (Step 3.5).
|
|
114
139
|
*
|
|
115
|
-
* @param
|
|
116
|
-
* @param type
|
|
140
|
+
* @param msg
|
|
117
141
|
* @param outboxId
|
|
118
142
|
* @param context
|
|
119
143
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-event.controller.d.ts","sourceRoot":"","sources":["../../src/events/base-event.controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"base-event.controller.d.ts","sourceRoot":"","sources":["../../src/events/base-event.controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAuB,mDAAmD,CAAC;AAC/F,OAAO,EAAE,YAAY,EAAE,MAAoB,wDAAwD,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,MAAkB,wDAAwD,CAAC;AAEpG,OAAO,EAAE,SAAS,EAAE,MAAuB,sBAAsB,CAAC;AAGlE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAe,cAAc,CAAC;AAO1D,OAAO,EAAE,iBAAiB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AA;KAAE;IAM5D;;;;OAIG;IACH,eAAe,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE;IAKtC,OAAO,CAAC,aAAa,CAAC,CAAmD;IAEzE;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAqBxB;;;;;OAKG;IAoBH;;;;;;;;;;OAUG;IACH,OAAO,CAAC,YAAY;IAcpB;;;;;OAKG;YACW,cAAc;IAM5B;;;;;;;;;OASG;cACa,WAAW,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAKzE;;;;;OAKG;IACY,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAMzE;;;;;OAKG;IACH;;;;;;;;;;OAUG;IACY,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBtE;;;;;;OAMG;IACY,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBlF;;;;;OAKG;IACY,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBpE;;;;;;;;;OASG;YACW,aAAa;IAY3B;;;;;;;;;OASG;YACW,cAAc;CAU7B"}
|
|
@@ -6,23 +6,9 @@ const mongo_utils_1 = require("@nextage/nx-frame-be/build/common/base/mongo-util
|
|
|
6
6
|
const outbox_1 = require("./outbox");
|
|
7
7
|
const cascade_1 = require("./cascade");
|
|
8
8
|
const field_map_1 = require("./field-map");
|
|
9
|
+
const publisher_registry_1 = require("./publisher-registry");
|
|
9
10
|
const enums_1 = require("./types/enums");
|
|
10
11
|
class BaseEventCtrl extends base_controller_1.BaseController {
|
|
11
|
-
constructor() {
|
|
12
|
-
// protected abstract CreatePublisher: new (client: MsgClientInterface) => Publisher<TCreate> | NatsPublisher<TCreate>;
|
|
13
|
-
// protected abstract UpdatePublisher: new (client: MsgClientInterface) => Publisher<TUpdate> | NatsPublisher<TUpdate>;
|
|
14
|
-
// protected abstract RemovePublisher: new (client: MsgClientInterface) => Publisher<TRemove> | NatsPublisher<TRemove>;
|
|
15
|
-
super(...arguments);
|
|
16
|
-
/**
|
|
17
|
-
* Declarative publish field-map (Step 3.4c). The default parsePub* methods pick
|
|
18
|
-
* exactly these keys from the entity, replacing the ~57 hand-written per-controller
|
|
19
|
-
* parsers. `pubFields` drives BOTH create and update; set `pubUpdateFields` only
|
|
20
|
-
* for the rare create ≠ update case; `pubRemoveFields` is the leaner remove subset.
|
|
21
|
-
* A subclass may still OVERRIDE parsePub* directly for non-pick (computed) payloads.
|
|
22
|
-
*/
|
|
23
|
-
this.pubFields = [];
|
|
24
|
-
this.pubRemoveFields = [];
|
|
25
|
-
}
|
|
26
12
|
/**
|
|
27
13
|
* Default create/update/remove parsers: a pure pick over the declared field-map.
|
|
28
14
|
* Overridable when a payload needs computed values (see e.g. i18n-shaped events).
|
|
@@ -39,6 +25,33 @@ class BaseEventCtrl extends base_controller_1.BaseController {
|
|
|
39
25
|
parsePubRemoveItem(item, type) {
|
|
40
26
|
return (0, field_map_1.pickPubFields)(item, this.pubRemoveFields);
|
|
41
27
|
}
|
|
28
|
+
// protected abstract createPublisher: Publisher<TCreate> | NatsPublisher<TCreate>;
|
|
29
|
+
// protected abstract updatePublisher: Publisher<TUpdate> | NatsPublisher<TUpdate>;
|
|
30
|
+
// protected abstract removePublisher: Publisher<TRemove> | NatsPublisher<TRemove>;
|
|
31
|
+
constructor(config) {
|
|
32
|
+
super(config);
|
|
33
|
+
// protected abstract CreatePublisher: new (client: MsgClientInterface) => Publisher<TCreate> | NatsPublisher<TCreate>;
|
|
34
|
+
// protected abstract UpdatePublisher: new (client: MsgClientInterface) => Publisher<TUpdate> | NatsPublisher<TUpdate>;
|
|
35
|
+
// protected abstract RemovePublisher: new (client: MsgClientInterface) => Publisher<TRemove> | NatsPublisher<TRemove>;
|
|
36
|
+
/**
|
|
37
|
+
* Declarative publish field-map (Step 3.4c). The default parsePub* methods pick
|
|
38
|
+
* exactly these keys from the entity, replacing the ~57 hand-written per-controller
|
|
39
|
+
* parsers. `pubFields` drives BOTH create and update; set `pubUpdateFields` only
|
|
40
|
+
* for the rare create ≠ update case; `pubRemoveFields` is the leaner remove subset.
|
|
41
|
+
* A subclass may still OVERRIDE parsePub* directly for non-pick (computed) payloads.
|
|
42
|
+
*/
|
|
43
|
+
this.pubFields = [];
|
|
44
|
+
this.pubRemoveFields = [];
|
|
45
|
+
(0, publisher_registry_1.registerPublisherProvider)(this);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* All publishers this controller owns (create + update + remove). Read LAZILY by
|
|
49
|
+
* the relay's publisher registry to route a `sent:false` outbox row back to its
|
|
50
|
+
* publisher family by subject — so it runs after the subclass field initialisers.
|
|
51
|
+
*/
|
|
52
|
+
eventPublishers() {
|
|
53
|
+
return [...this.createPublisher, ...this.updatePublisher, ...this.removePublisher];
|
|
54
|
+
}
|
|
42
55
|
/**
|
|
43
56
|
* Inizializza la configurazione dei publisher (lazy initialization)
|
|
44
57
|
*/
|
|
@@ -84,18 +97,36 @@ class BaseEventCtrl extends base_controller_1.BaseController {
|
|
|
84
97
|
// }
|
|
85
98
|
// }
|
|
86
99
|
/**
|
|
100
|
+
* Build the parsed, ready-to-publish message for a write: parse the payload,
|
|
101
|
+
* resolve the subject (shared by every publisher of the type — same event on
|
|
102
|
+
* NATS + msg) and stamp the OUTGOING cascade meta from `context._event` (root
|
|
103
|
+
* when absent). Returns undefined when the type has no publisher/parser. Built
|
|
104
|
+
* ONCE and reused for both the outbox row and the immediate dispatch.
|
|
87
105
|
*
|
|
88
106
|
* @param item
|
|
89
107
|
* @param type
|
|
90
108
|
* @param context
|
|
91
109
|
*/
|
|
92
|
-
|
|
110
|
+
buildMessage(item, type, context) {
|
|
93
111
|
const { publishers, parser } = this.getPublishConfig()[type] ?? {};
|
|
94
112
|
if (!publishers?.length || !parser)
|
|
95
|
-
return;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
113
|
+
return undefined;
|
|
114
|
+
return {
|
|
115
|
+
type,
|
|
116
|
+
subject: publishers[0].subject,
|
|
117
|
+
data: parser(item, type),
|
|
118
|
+
meta: (0, cascade_1.outgoingMeta)(context?._event),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Dispatch a prepared message on every publisher of its type. Shared by the
|
|
123
|
+
* immediate post-commit dispatch and the relay replay.
|
|
124
|
+
*
|
|
125
|
+
* @param msg
|
|
126
|
+
*/
|
|
127
|
+
async publishMessage(msg) {
|
|
128
|
+
const publishers = this.getPublishConfig()[msg.type]?.publishers ?? [];
|
|
129
|
+
await Promise.all(publishers.map(pub => pub.publish(msg.data, msg.meta)));
|
|
99
130
|
}
|
|
100
131
|
/**
|
|
101
132
|
* Overridable post-write / post-read enrichment of the RETURNED document (e.g.
|
|
@@ -138,15 +169,15 @@ class BaseEventCtrl extends base_controller_1.BaseController {
|
|
|
138
169
|
* @returns
|
|
139
170
|
*/
|
|
140
171
|
async create(item, context) {
|
|
141
|
-
let
|
|
172
|
+
let msg;
|
|
142
173
|
let outboxId;
|
|
143
174
|
const res = await this.withTransaction(context, async (ctx) => {
|
|
144
175
|
const created = await super.create(item, ctx);
|
|
145
|
-
|
|
146
|
-
outboxId = await this.enqueueOutbox(
|
|
176
|
+
msg = this.buildMessage(created.toJSON(), enums_1.QueueEventType.create, context);
|
|
177
|
+
outboxId = await this.enqueueOutbox(msg, ctx);
|
|
147
178
|
return created;
|
|
148
179
|
});
|
|
149
|
-
await this.dispatchOutbox(
|
|
180
|
+
await this.dispatchOutbox(msg, outboxId, context);
|
|
150
181
|
return this.decorateDoc(res, context);
|
|
151
182
|
}
|
|
152
183
|
/**
|
|
@@ -157,15 +188,15 @@ class BaseEventCtrl extends base_controller_1.BaseController {
|
|
|
157
188
|
* @returns
|
|
158
189
|
*/
|
|
159
190
|
async update(id, item, context) {
|
|
160
|
-
let
|
|
191
|
+
let msg;
|
|
161
192
|
let outboxId;
|
|
162
193
|
const res = await this.withTransaction(context, async (ctx) => {
|
|
163
194
|
const updated = await super.update(id, item, ctx);
|
|
164
|
-
|
|
165
|
-
outboxId = await this.enqueueOutbox(
|
|
195
|
+
msg = this.buildMessage({ id, ...updated.toObject() }, enums_1.QueueEventType.update, context);
|
|
196
|
+
outboxId = await this.enqueueOutbox(msg, ctx);
|
|
166
197
|
return updated;
|
|
167
198
|
});
|
|
168
|
-
await this.dispatchOutbox(
|
|
199
|
+
await this.dispatchOutbox(msg, outboxId, context);
|
|
169
200
|
return this.decorateDoc(res, context);
|
|
170
201
|
}
|
|
171
202
|
/**
|
|
@@ -175,47 +206,50 @@ class BaseEventCtrl extends base_controller_1.BaseController {
|
|
|
175
206
|
* @returns
|
|
176
207
|
*/
|
|
177
208
|
async remove(id, context) {
|
|
178
|
-
let
|
|
209
|
+
let msg;
|
|
179
210
|
let outboxId;
|
|
180
211
|
const res = await this.withTransaction(context, async (ctx) => {
|
|
181
212
|
const removed = await this.model.remove(id, ctx);
|
|
182
|
-
|
|
183
|
-
outboxId = await this.enqueueOutbox(
|
|
213
|
+
msg = this.buildMessage({ id, ...removed.toObject() }, enums_1.QueueEventType.remove, context);
|
|
214
|
+
outboxId = await this.enqueueOutbox(msg, ctx);
|
|
184
215
|
return removed;
|
|
185
216
|
});
|
|
186
|
-
await this.dispatchOutbox(
|
|
217
|
+
await this.dispatchOutbox(msg, outboxId, context);
|
|
187
218
|
return res;
|
|
188
219
|
}
|
|
189
220
|
/**
|
|
190
|
-
* Persist an outbox row (sent:false) for
|
|
191
|
-
*
|
|
192
|
-
*
|
|
221
|
+
* Persist an outbox row (sent:false) for the prepared message inside the
|
|
222
|
+
* caller's transaction. The row carries the subject + parsed payload + cascade
|
|
223
|
+
* meta, so the relay can replay it faithfully. Returns the row id, or undefined
|
|
224
|
+
* when there is no message or no outbox registered (the event is then still
|
|
225
|
+
* dispatched, just not tracked).
|
|
193
226
|
*
|
|
194
|
-
* @param
|
|
195
|
-
* @param type
|
|
227
|
+
* @param msg
|
|
196
228
|
* @param context
|
|
197
229
|
*/
|
|
198
|
-
async enqueueOutbox(
|
|
230
|
+
async enqueueOutbox(msg, context) {
|
|
199
231
|
const outbox = (0, outbox_1.getOutbox)();
|
|
200
|
-
if (!outbox)
|
|
232
|
+
if (!outbox || !msg)
|
|
201
233
|
return undefined;
|
|
202
234
|
const id = (0, mongo_utils_1.genObjectId)().toString();
|
|
203
|
-
const evt = { id, type, data:
|
|
235
|
+
const evt = { id, type: msg.type, subject: msg.subject, data: msg.data, meta: msg.meta };
|
|
204
236
|
await outbox.create(evt, context);
|
|
205
237
|
return id;
|
|
206
238
|
}
|
|
207
239
|
/**
|
|
208
|
-
* Dispatch the
|
|
209
|
-
* the transaction commits, so `publish` (a non-DB side effect) is
|
|
210
|
-
* by `withTransaction` and a broker failure leaves a recoverable
|
|
240
|
+
* Dispatch the prepared message to the broker, then mark the outbox row as sent.
|
|
241
|
+
* Runs AFTER the transaction commits, so `publish` (a non-DB side effect) is
|
|
242
|
+
* never retried by `withTransaction` and a broker failure leaves a recoverable
|
|
243
|
+
* sent:false row for the relay (Step 3.5).
|
|
211
244
|
*
|
|
212
|
-
* @param
|
|
213
|
-
* @param type
|
|
245
|
+
* @param msg
|
|
214
246
|
* @param outboxId
|
|
215
247
|
* @param context
|
|
216
248
|
*/
|
|
217
|
-
async dispatchOutbox(
|
|
218
|
-
|
|
249
|
+
async dispatchOutbox(msg, outboxId, context) {
|
|
250
|
+
if (!msg)
|
|
251
|
+
return;
|
|
252
|
+
await this.publishMessage(msg);
|
|
219
253
|
const outbox = (0, outbox_1.getOutbox)();
|
|
220
254
|
if (outbox && outboxId)
|
|
221
255
|
await outbox.markSent(outboxId, context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-event.controller.js","sourceRoot":"","sources":["../../src/events/base-event.controller.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"base-event.controller.js","sourceRoot":"","sources":["../../src/events/base-event.controller.ts"],"names":[],"mappings":";;;AAEA,4FAAoG;AACpG,oFAAgG;AAKhG,qCAAsD;AACtD,uCAAuD;AACvD,2CAAyD;AACzD,6DAAkE;AAIlE,yCAA2D;AAO3D,MAAsB,aAAmK,SAAQ,gCAAoC;IAiBnO;;;;;;OAMG;IACO,kBAAkB,CAAC,IAAY,EAAE,IAAoB;QAC7D,OAAO,IAAA,yBAAa,EAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAoB,CAAC;IAChE,CAAC;IAES,kBAAkB,CAAC,IAAY,EAAE,IAAoB;QAC7D,OAAO,IAAA,yBAAa,EAAC,IAAI,EAAE,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,SAAS,CAAoB,CAAC;IACxF,CAAC;IAES,kBAAkB,CAAC,IAAY,EAAE,IAAoB;QAC7D,OAAO,IAAA,yBAAa,EAAC,IAAI,EAAE,IAAI,CAAC,eAAe,CAAoB,CAAC;IACtE,CAAC;IAKD,mFAAmF;IACnF,mFAAmF;IACnF,mFAAmF;IAEnF,YAAY,MAAgD;QAE1D,KAAK,CAAC,MAAM,CAAC,CAAC;QA3ChB,uHAAuH;QACvH,uHAAuH;QACvH,uHAAuH;QAEvH;;;;;;WAMG;QACO,cAAS,GAA4B,EAAE,CAAC;QAExC,oBAAe,GAAsB,EAAE,CAAC;QA+BhD,IAAA,8CAAyB,EAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACH,eAAe;QAEb,OAAO,CAAC,GAAG,IAAI,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC;IACrF,CAAC;IAID;;OAEG;IACK,gBAAgB;QACtB,IAA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EjB,MAAM,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QAE/B,MAAM,MAAM,GAAG,IAAA,kBAAS,GAAE,CAAC;QAC3B,IAAI,MAAM,IAAI,QAAQ;YACpB,MAAM,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;CACF;AAzSD,sCAySC"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { NxContext } from '@nextage/nx-frame-be';
|
|
2
2
|
import { Message } from './event-message';
|
|
3
|
-
import {
|
|
3
|
+
import { ClientProvider, Event, EventSubOptions } from './interfaces';
|
|
4
4
|
import { EventContext, IncomingEventRef } from './types/event-envelope.interfaces';
|
|
5
5
|
export declare abstract class Listener<T extends Event> {
|
|
6
6
|
abstract subject: T['subject'];
|
|
7
7
|
abstract queueGroupName: string;
|
|
8
8
|
abstract onMessage(data: T['data'], msg: Message): Promise<void>;
|
|
9
|
-
private readonly
|
|
9
|
+
private readonly provider;
|
|
10
10
|
private subscription;
|
|
11
11
|
private messageStack;
|
|
12
12
|
private wait;
|
|
13
13
|
protected _incoming: IncomingEventRef | undefined;
|
|
14
14
|
protected ackWait: number;
|
|
15
|
-
constructor(
|
|
15
|
+
constructor(provider: ClientProvider);
|
|
16
|
+
private get client();
|
|
16
17
|
subscriptionOptions(): EventSubOptions;
|
|
17
18
|
listen(): Promise<void>;
|
|
18
19
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-listener.d.ts","sourceRoot":"","sources":["../../src/events/base-listener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"base-listener.d.ts","sourceRoot":"","sources":["../../src/events/base-listener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,SAAS,EAAE,MAAqC,sBAAsB,CAAC;AAClG,OAAO,EAAE,OAAO,EAAE,MAAyD,iBAAiB,CAAC;AAE7F,OAAO,EAAE,cAAc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or(provider) {
|
|
8
8
|
this.messageStack = [];
|
|
9
9
|
this.wait = false;
|
|
10
10
|
this.ackWait = 5 * 1000;
|
|
11
|
-
this.
|
|
11
|
+
this.provider = provider;
|
|
12
|
+
}
|
|
13
|
+
// Resolve the client only at listen/stop time, so the transport may be
|
|
14
|
+
// connected AFTER this listener is constructed (finding B8).
|
|
15
|
+
get client() {
|
|
16
|
+
return this.provider.client;
|
|
12
17
|
}
|
|
13
18
|
subscriptionOptions() {
|
|
14
19
|
return {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-listener.js","sourceRoot":"","sources":["../../src/events/base-listener.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"base-listener.js","sourceRoot":"","sources":["../../src/events/base-listener.ts"],"names":[],"mappings":";;;AAAA,sDAAkG;AAKlG,uCAAuF;AAEvF,MAAsB,QAAQ;IAmB5B,YAAa,QAAwB;QAT7B,iBAAY,GAAiB,EAAE,CAAC;QAChC,SAAI,GAAyB,KAAK,CAAC;QAMjC,YAAO,GAAoB,CAAC,GAAG,IAAI,CAAC;QAG5C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,uEAAuE;IACvE,6DAA6D;IAC7D,IAAY,MAAM;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED,mBAAmB;QAEjB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,KAAK,CAAC,MAAM;QAEV,IAAI,CAAC,YAAY,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAC7C,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,cAAc,EACnB,IAAI,CAAC,mBAAmB,EAAE,CAC3B,CAAC;QAEF,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC,SAAS,EAAE,CAAC,GAAY,EAAE,EAAE;YAEhD,iBAAG,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,IAAI,CAA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E,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;gBACrD,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;gBACO,CAAC;YAEP,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC7B,CAAC;IACH,CAAC;IAED;;;;OAIG;IACO,WAAW,CAAC,OAAkB,EAAE;QAExC,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC;IAC5E,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QAER,IAAI,IAAI,CAAC,YAAY;YACnB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC/C,CAAC;IAED;;;;OAIG;IACK,YAAY,CAAC,GAAY;QAE/B,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;QAC3B,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IACzF,CAAC;CACF;AA3ID,4BA2IC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { NxContext } from '@nextage/nx-frame-be';
|
|
2
|
-
import {
|
|
2
|
+
import { ClientProvider, Event, EventSubOptions } from './interfaces';
|
|
3
3
|
import { EventContext, IncomingEventRef } from './types/event-envelope.interfaces';
|
|
4
4
|
import { JsMsg } from 'nats';
|
|
5
5
|
export declare abstract class NatsListener<T extends Event> {
|
|
6
|
-
private readonly
|
|
6
|
+
private readonly provider;
|
|
7
7
|
abstract subject: T['subject'];
|
|
8
8
|
abstract queueGroupName: string;
|
|
9
9
|
abstract streamName: string;
|
|
@@ -14,7 +14,8 @@ export declare abstract class NatsListener<T extends Event> {
|
|
|
14
14
|
protected maxDeliver: number;
|
|
15
15
|
protected nakBackoffMs: number[];
|
|
16
16
|
abstract onMessage(data: T['data'], msg: JsMsg): Promise<void>;
|
|
17
|
-
constructor(
|
|
17
|
+
constructor(provider: ClientProvider);
|
|
18
|
+
private get client();
|
|
18
19
|
/**
|
|
19
20
|
*
|
|
20
21
|
* @returns
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-nats-listener.d.ts","sourceRoot":"","sources":["../../src/events/base-nats-listener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"base-nats-listener.d.ts","sourceRoot":"","sources":["../../src/events/base-nats-listener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,SAAS,EAAE,MAAkD,sBAAsB,CAAC;AAClG,OAAO,EAAE,cAAc,EAAE,KAAK,EAAsB,eAAe,EAAE,MAAM,cAAc,CAAC;AAG1F,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAkC,mCAAmC,CAAC;AAE/G,OAAO,EAAY,KAAK,EAAE,MAAiD,MAAM,CAAC;AAElF,8BAAsB,YAAY,CAAC,CAAC,SAAS,KAAK;IA2BnC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAzBtC,QAAQ,CAAC,OAAO,EAAS,CAAC,CAAC,SAAS,CAAC,CAAC;IACtC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAM,MAAM,CAAC;IAEhC,OAAO,CAAC,QAAQ,CAAC,CAAiB;IAClC,OAAO,CAAC,WAAW,CAAsB;IAMzC,SAAS,CAAC,SAAS,CAAC,EAAK,gBAAgB,CAAC;IAE1C,SAAS,CAAC,OAAO,EAAQ,MAAM,CAAuB;IACtD,SAAS,CAAC,UAAU,EAAK,MAAM,CAAK;IAMpC,SAAS,CAAC,YAAY,EAAG,MAAM,EAAE,CAAuB;IAGxD,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;gBAEhC,QAAQ,EAAE,cAAc;IAItD,OAAO,KAAK,MAAM,GAGjB;IAED;;;OAGG;IACH,mBAAmB,IAAI,eAAe;IAKtC;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAsB7B;;;;OAIG;YACW,eAAe;IAqB7B;;;;;;;;OAQG;cACa,aAAa,CAAC,GAAG,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;IAmDxD;;;;OAIG;cACa,oBAAoB,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU/E;;;;;;OAMG;IACH,SAAS,CAAC,WAAW,CAAC,IAAI,GAAE,SAAc,GAAG,YAAY;IAKzD;;;;OAIG;cACa,gBAAgB,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAyB9E;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAe3B;;;OAGG;IACH,OAAO,CAAC,eAAe;IAKvB;;OAEG;IACH,OAAO,CAAC,UAAU;IAMlB;;;;OAIG;IACH,OAAO,CAAC,MAAM;IAKd;;;;OAIG;IACH,OAAO,CAAC,YAAY;CAYrB"}
|
|
@@ -5,8 +5,8 @@ const nx_frame_be_1 = require("@nextage/nx-frame-be");
|
|
|
5
5
|
const dlq_constants_1 = require("./types/dlq.constants");
|
|
6
6
|
const cascade_1 = require("./cascade");
|
|
7
7
|
class NatsListener {
|
|
8
|
-
constructor(
|
|
9
|
-
this.
|
|
8
|
+
constructor(provider) {
|
|
9
|
+
this.provider = provider;
|
|
10
10
|
this.isListening = false;
|
|
11
11
|
this.ackWait = 30 * 1000 * 1000000; // 30 secondi in nanosecondi;
|
|
12
12
|
this.maxDeliver = 3;
|
|
@@ -16,6 +16,11 @@ class NatsListener {
|
|
|
16
16
|
// maxDeliver = 3).
|
|
17
17
|
this.nakBackoffMs = [1000, 5000, 15000];
|
|
18
18
|
}
|
|
19
|
+
// Resolve the client only at listen/DLQ/stop time, so the transport may be
|
|
20
|
+
// connected AFTER this listener is constructed (finding B8).
|
|
21
|
+
get client() {
|
|
22
|
+
return this.provider.client;
|
|
23
|
+
}
|
|
19
24
|
/**
|
|
20
25
|
*
|
|
21
26
|
* @returns
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-nats-listener.js","sourceRoot":"","sources":["../../src/events/base-nats-listener.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"base-nats-listener.js","sourceRoot":"","sources":["../../src/events/base-nats-listener.ts"],"names":[],"mappings":";;;AAAA,sDAAkG;AAElG,yDAAmG;AAGnG,uCAAuF;AAGvF,MAAsB,YAAY;IA2BhC,YAA8B,QAAwB;QAAxB,aAAQ,GAAR,QAAQ,CAAgB;QApB9C,gBAAW,GAAgB,KAAK,CAAC;QAQ/B,YAAO,GAAiB,EAAE,GAAG,IAAI,GAAG,OAAO,CAAC,CAAC,6BAA6B;QAC1E,eAAU,GAAc,CAAC,CAAC;QAEpC,0EAA0E;QAC1E,wEAAwE;QACxE,0EAA0E;QAC1E,mBAAmB;QACT,iBAAY,GAAc,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAKE,CAAC;IAE3D,2EAA2E;IAC3E,6DAA6D;IAC7D,IAAY,MAAM;QAEhB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACH,mBAAmB;QAEjB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM;QAEV,IAAI,CAAC;YAEH,kDAAkD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AK,EAAE,CAAC;YACf,iBAAG,CAAC,MAAM,CAAC,IAAI,CAAC,4BAA4B,IAAI,CAAC,OAAO,4CAA4C,CAAC,CAAC;QACxG,CAAC;IACH,CAAC;IAED;;;OAGG;IACK,eAAe,CAAC,GAAU;QAEhC,OAAO,GAAG,CAAC,IAAI,EAAE,aAAa,IAAI,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACK,UAAU,CAAC,UAAkB;QAEnC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAChF,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACK,MAAM,CAAC,GAAU;QAEvB,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACK,YAAY,CAAC,GAAU;QAE7B,IAAI,CAAC;YAEH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACtC,CAAC;QACD,OAAO,KAAK,EAAE,CAAC;YAEb,iBAAG,CAAC,MAAM,CAAC,KAAK,CAAC,iCAAiC,IAAI,CAAC,OAAO,OAAO,EAAE,KAAK,CAAC,CAAC;YAC9E,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;CACF;AArRD,oCAqRC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { JetStreamPublishOptions } from 'nats';
|
|
2
|
-
import { Event, IPublisher
|
|
2
|
+
import { ClientProvider, Event, IPublisher } from './interfaces';
|
|
3
3
|
import { EventMeta } from './types/event-envelope.interfaces';
|
|
4
4
|
export declare abstract class NatsPublisher<T extends Event> implements IPublisher<T, Partial<JetStreamPublishOptions>> {
|
|
5
|
-
private readonly
|
|
5
|
+
private readonly provider;
|
|
6
6
|
abstract subject: T['subject'];
|
|
7
|
-
constructor(
|
|
7
|
+
constructor(provider: ClientProvider);
|
|
8
|
+
private get client();
|
|
8
9
|
/**
|
|
9
10
|
* Emit the event wrapped in the shared in-band envelope (id / subject / data /
|
|
10
11
|
* timestamp / cascade meta). The metadata rides in the payload so loop-guard and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-nats-publisher.d.ts","sourceRoot":"","sources":["../../src/events/base-nats-publisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,
|
|
1
|
+
{"version":3,"file":"base-nats-publisher.d.ts","sourceRoot":"","sources":["../../src/events/base-nats-publisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAoC,MAAM,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,UAAU,EAAsB,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,SAAS,EAAE,MAAkD,mCAAmC,CAAC;AAG1G,8BAAsB,aAAa,CAAC,CAAC,SAAS,KAAK,CAAE,YAAW,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAIjG,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAFrC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC;gBAEF,QAAQ,EAAE,cAAc;IAIrD,OAAO,KAAK,MAAM,GAGjB;IAED;;;;;;;;OAQG;IACG,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAiB5G"}
|
|
@@ -3,8 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NatsPublisher = void 0;
|
|
4
4
|
const cascade_1 = require("./cascade");
|
|
5
5
|
class NatsPublisher {
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
6
|
+
constructor(provider) {
|
|
7
|
+
this.provider = provider;
|
|
8
|
+
}
|
|
9
|
+
// Resolve the client only when actually publishing, so the transport may be
|
|
10
|
+
// connected AFTER this publisher (and its owning controller) is constructed.
|
|
11
|
+
get client() {
|
|
12
|
+
return this.provider.client;
|
|
8
13
|
}
|
|
9
14
|
/**
|
|
10
15
|
* Emit the event wrapped in the shared in-band envelope (id / subject / data /
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-nats-publisher.js","sourceRoot":"","sources":["../../src/events/base-nats-publisher.ts"],"names":[],"mappings":";;;AAGA,
|
|
1
|
+
{"version":3,"file":"base-nats-publisher.js","sourceRoot":"","sources":["../../src/events/base-nats-publisher.ts"],"names":[],"mappings":";;;AAGA,uCAAkF;AAElF,MAAsB,aAAa;IAIjC,YAA6B,QAAwB;QAAxB,aAAQ,GAAR,QAAQ,CAAgB;IAAG,CAAC;IAEzD,4EAA4E;IAC5E,6EAA6E;IAC7E,IAAY,MAAM;QAEhB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,OAAO,CAAC,IAAe,EAAE,IAAgB,EAAE,OAA0C;QAE1F,IAAI,CAAC;YAEF,MAAM,QAAQ,GAAG,IAAA,uBAAa,EAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;YAEzD,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CACvB,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EACxB,OAAO,CACR,CAAC;QAEJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,2BAA2B,IAAI,CAAC,OAAO,IAAI,EAAE,KAAK,CAAC,CAAC;YAClE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAvCD,sCAuCC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Event, IPublisher
|
|
1
|
+
import { ClientProvider, Event, IPublisher } from './interfaces';
|
|
2
2
|
import { EventMeta } from './types/event-envelope.interfaces';
|
|
3
3
|
export declare abstract class Publisher<T extends Event> implements IPublisher<T> {
|
|
4
|
+
private readonly provider;
|
|
4
5
|
abstract subject: T['subject'];
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
constructor(provider: ClientProvider);
|
|
7
|
+
private get client();
|
|
7
8
|
/**
|
|
8
9
|
* Emit the event wrapped in the shared in-band envelope, so the msg bus carries
|
|
9
10
|
* the same cascade metadata as the NATS transport (transport-agnostic tracing).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-publisher.d.ts","sourceRoot":"","sources":["../../src/events/base-publisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"base-publisher.d.ts","sourceRoot":"","sources":["../../src/events/base-publisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,UAAU,EAAsB,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,SAAS,EAAE,MAAkD,mCAAmC,CAAC;AAG1G,8BAAsB,SAAS,CAAC,CAAC,SAAS,KAAK,CAAE,YAAW,UAAU,CAAC,CAAC,CAAC;IAI3D,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAFrC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC;gBAEF,QAAQ,EAAE,cAAc;IAIrD,OAAO,KAAK,MAAM,GAGjB;IAED;;;;;;;OAOG;IACG,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CAKhE"}
|
|
@@ -3,8 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Publisher = void 0;
|
|
4
4
|
const cascade_1 = require("./cascade");
|
|
5
5
|
class Publisher {
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
6
|
+
constructor(provider) {
|
|
7
|
+
this.provider = provider;
|
|
8
|
+
}
|
|
9
|
+
// Resolve the client only when actually publishing, so the transport may be
|
|
10
|
+
// connected AFTER this publisher (and its owning controller) is constructed.
|
|
11
|
+
get client() {
|
|
12
|
+
return this.provider.client;
|
|
8
13
|
}
|
|
9
14
|
/**
|
|
10
15
|
* Emit the event wrapped in the shared in-band envelope, so the msg bus carries
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-publisher.js","sourceRoot":"","sources":["../../src/events/base-publisher.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"base-publisher.js","sourceRoot":"","sources":["../../src/events/base-publisher.ts"],"names":[],"mappings":";;;AAEA,uCAAkF;AAElF,MAAsB,SAAS;IAI7B,YAA6B,QAAwB;QAAxB,aAAQ,GAAR,QAAQ,CAAgB;IAAG,CAAC;IAEzD,4EAA4E;IAC5E,6EAA6E;IAC7E,IAAY,MAAM;QAEhB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO,CAAC,IAAe,EAAE,IAAgB;QAE7C,MAAM,QAAQ,GAAG,IAAA,uBAAa,EAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACzD,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC3E,CAAC;CACF;AA1BD,8BA0BC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { EventRelayOptions } from './types/relay.interfaces';
|
|
2
|
+
export declare class EventRelay {
|
|
3
|
+
private readonly batchSize;
|
|
4
|
+
private readonly intervalMs;
|
|
5
|
+
private readonly onError;
|
|
6
|
+
private readonly onSkip;
|
|
7
|
+
private timer?;
|
|
8
|
+
private draining;
|
|
9
|
+
constructor(opts?: EventRelayOptions);
|
|
10
|
+
/**
|
|
11
|
+
* Drain one batch: the oldest `sent:false` rows → re-publish each on every
|
|
12
|
+
* publisher registered for its subject → mark it sent. A row whose subject has
|
|
13
|
+
* no registered publisher (controller not loaded) is skipped and retried on the
|
|
14
|
+
* next tick. Returns the number of rows successfully re-published. Never throws
|
|
15
|
+
* for a single row/broker failure — that row simply stays `sent:false`.
|
|
16
|
+
*/
|
|
17
|
+
drainOnce(): Promise<number>;
|
|
18
|
+
/**
|
|
19
|
+
* Start the relay: an immediate startup drain, then a periodic sweep every
|
|
20
|
+
* `intervalMs`. The timer is `unref`'d so it never keeps the process alive.
|
|
21
|
+
*/
|
|
22
|
+
start(): void;
|
|
23
|
+
/** Stop the periodic sweep (graceful shutdown / test teardown). */
|
|
24
|
+
stop(): void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=event-relay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-relay.d.ts","sourceRoot":"","sources":["../../src/events/event-relay.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,iBAAiB,EAAE,MAAwC,0BAA0B,CAAC;AAG/F,qBAAa,UAAU;IAErB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAU;IACpC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4B;IACpD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA4C;IAEnE,OAAO,CAAC,KAAK,CAAC,CAAmC;IACjD,OAAO,CAAC,QAAQ,CAAS;gBAEb,IAAI,GAAE,iBAAsB;IAQxC;;;;;;OAMG;IACG,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IA2ClC;;;OAGG;IACH,KAAK,IAAI,IAAI;IAab,mEAAmE;IACnE,IAAI,IAAI,IAAI;CAOb"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ────────────────────────────────────────────────────────────────────────────
|
|
3
|
+
* EVENT RELAY — at-least-once redelivery of `sent:false` outbox rows (Step 3.5)
|
|
4
|
+
*
|
|
5
|
+
* Closes finding E1: with the atomic outbox (3.4) an entity + its outbox row are
|
|
6
|
+
* committed together, then published post-commit; if the broker is down or the
|
|
7
|
+
* process crashes in that window the row stays `sent:false` and — until now — was
|
|
8
|
+
* never re-published. The relay drains those rows:
|
|
9
|
+
* • at startup → recover events accumulated while THIS service was down;
|
|
10
|
+
* • periodically → recover from a transient broker/network outage while the
|
|
11
|
+
* process stays up (the publish failed but we did not crash).
|
|
12
|
+
*
|
|
13
|
+
* Re-publish is safe (at-least-once): downstream consumers are version-guarded
|
|
14
|
+
* (3.3), so a duplicate delivery is idempotent. Routing back to the publisher is
|
|
15
|
+
* via the subject persisted on the row + the publisher registry.
|
|
16
|
+
* ──────────────────────────────────────────────────────────────────────────── */
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.EventRelay = void 0;
|
|
19
|
+
const outbox_1 = require("./outbox");
|
|
20
|
+
const publisher_registry_1 = require("./publisher-registry");
|
|
21
|
+
const relay_constants_1 = require("./types/relay.constants");
|
|
22
|
+
class EventRelay {
|
|
23
|
+
constructor(opts = {}) {
|
|
24
|
+
this.draining = false;
|
|
25
|
+
this.batchSize = opts.batchSize ?? relay_constants_1.DEFAULT_RELAY_BATCH_SIZE;
|
|
26
|
+
this.intervalMs = opts.intervalMs ?? relay_constants_1.DEFAULT_RELAY_INTERVAL_MS;
|
|
27
|
+
this.onError = opts.onError ?? (() => { });
|
|
28
|
+
this.onSkip = opts.onSkip ?? (() => { });
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Drain one batch: the oldest `sent:false` rows → re-publish each on every
|
|
32
|
+
* publisher registered for its subject → mark it sent. A row whose subject has
|
|
33
|
+
* no registered publisher (controller not loaded) is skipped and retried on the
|
|
34
|
+
* next tick. Returns the number of rows successfully re-published. Never throws
|
|
35
|
+
* for a single row/broker failure — that row simply stays `sent:false`.
|
|
36
|
+
*/
|
|
37
|
+
async drainOnce() {
|
|
38
|
+
const outbox = (0, outbox_1.getOutbox)();
|
|
39
|
+
if (!outbox)
|
|
40
|
+
return 0;
|
|
41
|
+
// Re-entrancy guard: a slow batch must not overlap the periodic tick.
|
|
42
|
+
if (this.draining)
|
|
43
|
+
return 0;
|
|
44
|
+
this.draining = true;
|
|
45
|
+
let sent = 0;
|
|
46
|
+
try {
|
|
47
|
+
const rows = await outbox.findUnsent(this.batchSize);
|
|
48
|
+
for (const row of rows) {
|
|
49
|
+
const publishers = (0, publisher_registry_1.resolvePublishers)(row.subject);
|
|
50
|
+
if (!publishers.length) {
|
|
51
|
+
this.onSkip(row.subject, row.id);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
await Promise.all(publishers.map(pub => pub.publish(row.data, row.meta)));
|
|
56
|
+
await outbox.markSent(row.id, {});
|
|
57
|
+
sent++;
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
// Leave the row sent:false for the next tick; do not abort the batch.
|
|
61
|
+
this.onError(err);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
this.onError(err);
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
this.draining = false;
|
|
70
|
+
}
|
|
71
|
+
return sent;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Start the relay: an immediate startup drain, then a periodic sweep every
|
|
75
|
+
* `intervalMs`. The timer is `unref`'d so it never keeps the process alive.
|
|
76
|
+
*/
|
|
77
|
+
start() {
|
|
78
|
+
if (this.timer)
|
|
79
|
+
return;
|
|
80
|
+
void this.drainOnce().catch(err => this.onError(err));
|
|
81
|
+
this.timer = setInterval(() => {
|
|
82
|
+
void this.drainOnce().catch(err => this.onError(err));
|
|
83
|
+
}, this.intervalMs);
|
|
84
|
+
this.timer.unref?.();
|
|
85
|
+
}
|
|
86
|
+
/** Stop the periodic sweep (graceful shutdown / test teardown). */
|
|
87
|
+
stop() {
|
|
88
|
+
if (this.timer) {
|
|
89
|
+
clearInterval(this.timer);
|
|
90
|
+
this.timer = undefined;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.EventRelay = EventRelay;
|
|
95
|
+
//# sourceMappingURL=event-relay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-relay.js","sourceRoot":"","sources":["../../src/events/event-relay.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;AAElF,qCAA+E;AAC/E,6DAA2F;AAE3F,6DAA8F;AAE9F,MAAa,UAAU;IAUrB,YAAY,OAA0B,EAAE;QAFhC,aAAQ,GAAG,KAAK,CAAC;QAIvB,IAAI,CAAC,SAAS,GAAI,IAAI,CAAC,SAAS,IAAK,0CAAwB,CAAC;QAC9D,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,2CAAyB,CAAC;QAC/D,IAAI,CAAC,OAAO,GAAM,IAAI,CAAC,OAAO,IAAO,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAChD,IAAI,CAAC,MAAM,GAAO,IAAI,CAAC,MAAM,IAAQ,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAClD,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,SAAS;QAEb,MAAM,MAAM,GAAG,IAAA,kBAAS,GAAE,CAAC;QAC3B,IAAI,CAAC,MAAM;YAAE,OAAO,CAAC,CAAC;QAEtB,sEAAsE;QACtE,IAAI,IAAI,CAAC,QAAQ;YAAE,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K,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;QAEtD,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;YAC5B,KAAK,IAAI,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;QACxD,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAEpB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;IACvB,CAAC;IAED,mEAAmE;IACnE,IAAI;QAEF,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC1B,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACzB,CAAC;IACH,CAAC;CACF;AA7FD,gCA6FC"}
|
package/build/events/index.d.ts
CHANGED
|
@@ -3,8 +3,10 @@ export * from './interfaces';
|
|
|
3
3
|
export * from './types';
|
|
4
4
|
export * from './base-event.controller';
|
|
5
5
|
export * from './cascade';
|
|
6
|
+
export * from './event-relay';
|
|
6
7
|
export * from './field-map';
|
|
7
8
|
export * from './outbox';
|
|
9
|
+
export * from './publisher-registry';
|
|
8
10
|
export * from './msg-client-manager';
|
|
9
11
|
export * from './msg-wrapper';
|
|
10
12
|
export * from './base-listener';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AAExB,cAAc,yBAAyB,CAAC;AACxC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AAExB,cAAc,yBAAyB,CAAC;AACxC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC;AAGrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AAGjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AAGvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAGhC,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AAGjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC"}
|
package/build/events/index.js
CHANGED
|
@@ -19,8 +19,10 @@ __exportStar(require("./interfaces"), exports);
|
|
|
19
19
|
__exportStar(require("./types"), exports);
|
|
20
20
|
__exportStar(require("./base-event.controller"), exports);
|
|
21
21
|
__exportStar(require("./cascade"), exports);
|
|
22
|
+
__exportStar(require("./event-relay"), exports);
|
|
22
23
|
__exportStar(require("./field-map"), exports);
|
|
23
24
|
__exportStar(require("./outbox"), exports);
|
|
25
|
+
__exportStar(require("./publisher-registry"), exports);
|
|
24
26
|
// messages on memory
|
|
25
27
|
__exportStar(require("./msg-client-manager"), exports);
|
|
26
28
|
__exportStar(require("./msg-wrapper"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,+CAA6B;AAC7B,0CAAwB;AAExB,0DAAwC;AACxC,4CAA0B;AAC1B,8CAA4B;AAC5B,2CAAyB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,+CAA6B;AAC7B,0CAAwB;AAExB,0DAAwC;AACxC,4CAA0B;AAC1B,gDAA8B;AAC9B,8CAA4B;AAC5B,2CAAyB;AACzB,uDAAqC;AAErC,qBAAqB;AACrB,uDAAqC;AACrC,gDAA8B;AAC9B,kDAAgC;AAChC,mDAAiC;AAEjC,mBAAmB;AACnB,wDAAsC;AACtC,iDAA+B;AAC/B,uDAAqC;AACrC,wDAAsC;AAEtC,YAAY;AACZ,iDAA+B;AAC/B,yCAAuB;AAEvB,aAAa;AACb,kDAAgC;AAChC,gDAA8B;AAC9B,6CAA2B;AAC3B,mDAAiC;AACjC,iDAA+B;AAC/B,4CAA0B;AAC1B,sDAAoC;AACpC,2CAAyB;AACzB,kDAAgC;AAEhC,cAAc;AACd,4CAA0B;AAC1B,kDAAgC;AAChC,oDAAkC;AAClC,qDAAmC;AACnC,qDAAmC;AACnC,oDAAkC;AAClC,iDAA+B;AAC/B,mDAAiC;AAEjC,oBAAoB;AACpB,kDAAgC;AAChC,+CAA6B;AAE7B,kBAAkB;AAClB,mCAAmC;AAEnC,cAAc"}
|
|
@@ -6,6 +6,17 @@ export interface MsgClientInterface {
|
|
|
6
6
|
subscribe: (...args: any[]) => any;
|
|
7
7
|
unsubscribe: (...args: any[]) => any;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Deferred access to a message-bus client. Publishers and listeners receive a
|
|
11
|
+
* provider (typically the `natsWrapper` / `msgWrapper` singleton) instead of the
|
|
12
|
+
* resolved client, and read `provider.client` only at publish/listen time. This
|
|
13
|
+
* keeps NATS access LAZY: controllers can be constructed (and their modules
|
|
14
|
+
* imported) before the transport is connected, without tripping the wrapper's
|
|
15
|
+
* "client before connecting" guard (finding B8).
|
|
16
|
+
*/
|
|
17
|
+
export interface ClientProvider {
|
|
18
|
+
readonly client: MsgClientInterface;
|
|
19
|
+
}
|
|
9
20
|
export interface EventSubOptions {
|
|
10
21
|
maxDeliver?: number;
|
|
11
22
|
ackWait?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/events/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAO,eAAe,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAO,sBAAsB,CAAC;AAEjD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IACnF,SAAS,EAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;IACrC,WAAW,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;CACtC;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAK,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,KAAK;IACpB,OAAO,EAAE,QAAQ,CAAC;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AE,CAAC,CAAC,SAAS,CAAC,CAAC;IACtB,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Event, IPublisher } from './interfaces';
|
|
2
|
+
import { PublisherProvider } from './types/relay.interfaces';
|
|
3
|
+
/**
|
|
4
|
+
* Register a controller as a publisher provider. Idempotent (Set-backed): a
|
|
5
|
+
* singleton controller constructed once registers once. Called from the
|
|
6
|
+
* BaseEventCtrl constructor with `this`.
|
|
7
|
+
*
|
|
8
|
+
* @param provider
|
|
9
|
+
*/
|
|
10
|
+
export declare function registerPublisherProvider(provider: PublisherProvider): void;
|
|
11
|
+
/**
|
|
12
|
+
* All registered publishers whose `subject` matches, gathered across every
|
|
13
|
+
* provider. Read lazily at call time, so a provider registered in a constructor
|
|
14
|
+
* (before its publisher fields are initialised) still resolves correctly later.
|
|
15
|
+
*
|
|
16
|
+
* @param subject
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolvePublishers(subject: string): IPublisher<Event>[];
|
|
19
|
+
/** Clear all registered providers (test isolation). */
|
|
20
|
+
export declare function clearPublisherProviders(): void;
|
|
21
|
+
//# sourceMappingURL=publisher-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publisher-registry.d.ts","sourceRoot":"","sources":["../../src/events/publisher-registry.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAI7D;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAG3E;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,EAAE,CAStE;AAED,uDAAuD;AACvD,wBAAgB,uBAAuB,IAAI,IAAI,CAG9C"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ────────────────────────────────────────────────────────────────────────────
|
|
3
|
+
* PUBLISHER REGISTRY — subject → publisher resolution for the relay (Step 3.5)
|
|
4
|
+
*
|
|
5
|
+
* The relay reads a `sent:false` outbox row and must re-publish it, but the
|
|
6
|
+
* concrete publisher lives PER-CONTROLLER (create/update/removePublisher on each
|
|
7
|
+
* BaseEventCtrl). A controller registers ITSELF as a provider in its constructor;
|
|
8
|
+
* the relay later asks `resolvePublishers(subject)`, which reads each provider's
|
|
9
|
+
* `eventPublishers()` LAZILY — so it runs at relay-time (fields initialised), not
|
|
10
|
+
* at construction-time (subclass field initialisers run AFTER super()).
|
|
11
|
+
* ──────────────────────────────────────────────────────────────────────────── */
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.registerPublisherProvider = registerPublisherProvider;
|
|
14
|
+
exports.resolvePublishers = resolvePublishers;
|
|
15
|
+
exports.clearPublisherProviders = clearPublisherProviders;
|
|
16
|
+
const _providers = new Set();
|
|
17
|
+
/**
|
|
18
|
+
* Register a controller as a publisher provider. Idempotent (Set-backed): a
|
|
19
|
+
* singleton controller constructed once registers once. Called from the
|
|
20
|
+
* BaseEventCtrl constructor with `this`.
|
|
21
|
+
*
|
|
22
|
+
* @param provider
|
|
23
|
+
*/
|
|
24
|
+
function registerPublisherProvider(provider) {
|
|
25
|
+
_providers.add(provider);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* All registered publishers whose `subject` matches, gathered across every
|
|
29
|
+
* provider. Read lazily at call time, so a provider registered in a constructor
|
|
30
|
+
* (before its publisher fields are initialised) still resolves correctly later.
|
|
31
|
+
*
|
|
32
|
+
* @param subject
|
|
33
|
+
*/
|
|
34
|
+
function resolvePublishers(subject) {
|
|
35
|
+
const out = [];
|
|
36
|
+
for (const provider of _providers)
|
|
37
|
+
for (const pub of provider.eventPublishers())
|
|
38
|
+
if (pub.subject === subject)
|
|
39
|
+
out.push(pub);
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
/** Clear all registered providers (test isolation). */
|
|
43
|
+
function clearPublisherProviders() {
|
|
44
|
+
_providers.clear();
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=publisher-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publisher-registry.js","sourceRoot":"","sources":["../../src/events/publisher-registry.ts"],"names":[],"mappings":";AAAA;;;;;;;;;kFASkF;;AAclF,8DAGC;AASD,8CASC;AAGD,0DAGC;AApCD,MAAM,UAAU,GAAG,IAAI,GAAG,EAAqB,CAAC;AAEhD;;;;;;GAMG;AACH,SAAgB,yBAAyB,CAAC,QAA2B;IAEnE,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC3B,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAC,OAAe;IAE/C,MAAM,GAAG,GAAwB,EAAE,CAAC;IAEpC,KAAK,MAAM,QAAQ,IAAI,UAAU;QAC/B,KAAK,MAAM,GAAG,IAAI,QAAQ,CAAC,eAAe,EAAE;YAC1C,IAAI,GAAG,CAAC,OAAO,KAAK,OAAO;gBAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAE/C,OAAO,GAAG,CAAC;AACb,CAAC;AAED,uDAAuD;AACvD,SAAgB,uBAAuB;IAErC,UAAU,CAAC,KAAK,EAAE,CAAC;AACrB,CAAC"}
|
|
@@ -15,12 +15,14 @@ export * from './vulnerability.enums';
|
|
|
15
15
|
export * from './asset.constants';
|
|
16
16
|
export * from './dlq.constants';
|
|
17
17
|
export * from './event-envelope.constants';
|
|
18
|
+
export * from './relay.constants';
|
|
18
19
|
export * from './asset.interfaces';
|
|
19
20
|
export * from './control.interfaces';
|
|
20
21
|
export * from './dlq.interfaces';
|
|
21
22
|
export * from './event-envelope.interfaces';
|
|
22
23
|
export * from './events.interfaces';
|
|
23
24
|
export * from './outbox.interfaces';
|
|
25
|
+
export * from './relay.interfaces';
|
|
24
26
|
export * from './risk-analysis.interfaces';
|
|
25
27
|
export * from './threat.interfaces';
|
|
26
28
|
export * from './vulnerability.interfaces';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/events/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AAExB,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AAEtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/events/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AAExB,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AAEtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAElC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAG3C,cAAc,kBAAkB,CAAC"}
|
|
@@ -31,12 +31,14 @@ __exportStar(require("./vulnerability.enums"), exports);
|
|
|
31
31
|
__exportStar(require("./asset.constants"), exports);
|
|
32
32
|
__exportStar(require("./dlq.constants"), exports);
|
|
33
33
|
__exportStar(require("./event-envelope.constants"), exports);
|
|
34
|
+
__exportStar(require("./relay.constants"), exports);
|
|
34
35
|
__exportStar(require("./asset.interfaces"), exports);
|
|
35
36
|
__exportStar(require("./control.interfaces"), exports);
|
|
36
37
|
__exportStar(require("./dlq.interfaces"), exports);
|
|
37
38
|
__exportStar(require("./event-envelope.interfaces"), exports);
|
|
38
39
|
__exportStar(require("./events.interfaces"), exports);
|
|
39
40
|
__exportStar(require("./outbox.interfaces"), exports);
|
|
41
|
+
__exportStar(require("./relay.interfaces"), exports);
|
|
40
42
|
__exportStar(require("./risk-analysis.interfaces"), exports);
|
|
41
43
|
__exportStar(require("./threat.interfaces"), exports);
|
|
42
44
|
__exportStar(require("./vulnerability.interfaces"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/events/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AAExB,wDAAsC;AACtC,gDAA8B;AAC9B,sDAAoC;AACpC,wDAAsC;AACtC,uDAAqC;AACrC,kDAAgC;AAChC,4DAA0C;AAC1C,iDAA+B;AAC/B,uDAAqC;AACrC,wDAAsC;AACtC,iDAA+B;AAC/B,oDAAkC;AAClC,wDAAsC;AAEtC,oDAAkC;AAClC,kDAAgC;AAChC,6DAA2C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/events/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AAExB,wDAAsC;AACtC,gDAA8B;AAC9B,sDAAoC;AACpC,wDAAsC;AACtC,uDAAqC;AACrC,kDAAgC;AAChC,4DAA0C;AAC1C,iDAA+B;AAC/B,uDAAqC;AACrC,wDAAsC;AACtC,iDAA+B;AAC/B,oDAAkC;AAClC,wDAAsC;AAEtC,oDAAkC;AAClC,kDAAgC;AAChC,6DAA2C;AAC3C,oDAAkC;AAElC,qDAAmC;AACnC,uDAAqC;AACrC,mDAAiC;AACjC,8DAA4C;AAC5C,sDAAoC;AACpC,sDAAoC;AACpC,qDAAmC;AACnC,6DAA2C;AAC3C,sDAAoC;AACpC,6DAA2C;AAE3C,YAAY;AACZ,mDAAiC"}
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { NxContext } from '@nextage/nx-frame-be';
|
|
2
2
|
import { QueueEventType } from './enums';
|
|
3
|
+
import { EventMeta } from './event-envelope.interfaces';
|
|
3
4
|
export interface OutboxEvent {
|
|
4
5
|
id: string;
|
|
5
6
|
type: QueueEventType;
|
|
7
|
+
subject: string;
|
|
6
8
|
data: any;
|
|
9
|
+
meta?: EventMeta;
|
|
10
|
+
}
|
|
11
|
+
export interface OutboxMessage {
|
|
12
|
+
type: QueueEventType;
|
|
13
|
+
subject: string;
|
|
14
|
+
data: any;
|
|
15
|
+
meta: EventMeta;
|
|
7
16
|
}
|
|
8
17
|
export interface OutboxPort {
|
|
9
18
|
create(evt: OutboxEvent, context: NxContext): Promise<void>;
|
|
10
19
|
markSent(id: string, context: NxContext): Promise<void>;
|
|
20
|
+
findUnsent(limit: number): Promise<OutboxEvent[]>;
|
|
11
21
|
}
|
|
12
22
|
//# sourceMappingURL=outbox.interfaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outbox.interfaces.d.ts","sourceRoot":"","sources":["../../../src/events/types/outbox.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAW,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"outbox.interfaces.d.ts","sourceRoot":"","sources":["../../../src/events/types/outbox.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAW,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAW,6BAA6B,CAAC;AAS7D,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAO,MAAM,CAAC;IAChB,IAAI,EAAK,cAAc,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAK,GAAG,CAAC;IACb,IAAI,CAAC,EAAI,SAAS,CAAC;CACpB;AAQD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAK,cAAc,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAK,GAAG,CAAC;IACb,IAAI,EAAK,SAAS,CAAC;CACpB;AAUD,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,GAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,GAAQ,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,UAAU,CAAC,KAAK,EAAE,MAAM,GAAuB,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;CACvE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay.constants.d.ts","sourceRoot":"","sources":["../../../src/events/types/relay.constants.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,wBAAwB,MAAO,CAAC;AAC7C,eAAO,MAAM,yBAAyB,QAAS,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Relay (Step 3.5) tuning defaults. The relay redelivers `sent:false` outbox rows
|
|
3
|
+
// at startup (recover from a previous crash) and periodically (recover from a
|
|
4
|
+
// transient broker/network outage while the process stays up).
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DEFAULT_RELAY_INTERVAL_MS = exports.DEFAULT_RELAY_BATCH_SIZE = void 0;
|
|
7
|
+
exports.DEFAULT_RELAY_BATCH_SIZE = 100; // rows drained per tick
|
|
8
|
+
exports.DEFAULT_RELAY_INTERVAL_MS = 30000; // 30s periodic sweep
|
|
9
|
+
//# sourceMappingURL=relay.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay.constants.js","sourceRoot":"","sources":["../../../src/events/types/relay.constants.ts"],"names":[],"mappings":";AAAA,kFAAkF;AAClF,8EAA8E;AAC9E,+DAA+D;;;AAElD,QAAA,wBAAwB,GAAI,GAAG,CAAC,CAAI,wBAAwB;AAC5D,QAAA,yBAAyB,GAAG,KAAM,CAAC,CAAC,qBAAqB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Event, IPublisher } from '../interfaces';
|
|
2
|
+
export interface EventRelayOptions {
|
|
3
|
+
batchSize?: number;
|
|
4
|
+
intervalMs?: number;
|
|
5
|
+
onError?: (err: unknown) => void;
|
|
6
|
+
onSkip?: (subject: string, id: string) => void;
|
|
7
|
+
}
|
|
8
|
+
export interface PublisherProvider {
|
|
9
|
+
eventPublishers(): IPublisher<Event>[];
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=relay.interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay.interfaces.d.ts","sourceRoot":"","sources":["../../../src/events/types/relay.interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAIlD,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAG,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAK,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IACpC,MAAM,CAAC,EAAM,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACpD;AAKD,MAAM,WAAW,iBAAiB;IAChC,eAAe,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;CACxC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Relay (Step 3.5) contracts. Kept separate from the relay/registry logic that
|
|
3
|
+
// consumes them (house rule: types live in `<concern>.interfaces.ts`).
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
//# sourceMappingURL=relay.interfaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay.interfaces.js","sourceRoot":"","sources":["../../../src/events/types/relay.interfaces.ts"],"names":[],"mappings":";AAAA,+EAA+E;AAC/E,uEAAuE"}
|