@nextage/era-lib 1.0.209 → 1.0.211
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/constants.d.ts +3 -3
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +3 -3
- package/build/constants.js.map +1 -1
- package/build/events/access-revoked-publisher.d.ts +1 -1
- package/build/events/access-revoked-publisher.js +1 -1
- package/build/events/base/base-event.controller.d.ts +35 -5
- package/build/events/base/base-event.controller.d.ts.map +1 -1
- package/build/events/base/base-event.controller.js +43 -6
- package/build/events/base/base-event.controller.js.map +1 -1
- package/build/events/base/base-msg-listener.d.ts +26 -0
- package/build/events/base/base-msg-listener.d.ts.map +1 -1
- package/build/events/base/base-msg-listener.js +53 -2
- package/build/events/base/base-msg-listener.js.map +1 -1
- package/build/events/base/base-nats-listener.d.ts +2 -2
- package/build/events/base/base-nats-listener.js +3 -3
- package/build/events/base/base-nats-listener.js.map +1 -1
- package/build/events/dlq-manager.js +3 -3
- package/build/events/event-relay.js +2 -2
- package/build/events/field-map.js +1 -1
- package/build/events/interfaces.d.ts +1 -1
- package/build/events/organization/interfaces.d.ts +3 -3
- package/build/events/organization/restored-event.d.ts +1 -1
- package/build/events/publisher-registry.js +1 -1
- package/build/events/revocation-denylist.js +2 -2
- package/build/events/revocation-listener.js +1 -1
- package/build/events/transport/base-client-wrapper.d.ts +1 -1
- package/build/events/transport/base-client-wrapper.js +1 -1
- package/build/events/transport/nats-client-manager.d.ts +1 -1
- package/build/events/transport/nats-client-manager.js +1 -1
- package/build/events/types/dlq.constants.js +1 -1
- package/build/events/types/dlq.constants.js.map +1 -1
- package/build/events/types/dlq.interfaces.js +1 -1
- package/build/events/types/dlq.interfaces.js.map +1 -1
- package/build/events/types/enums.d.ts +1 -1
- package/build/events/types/enums.js +3 -3
- package/build/events/types/enums.js.map +1 -1
- package/build/events/types/relay.constants.js +1 -1
- package/build/events/types/relay.constants.js.map +1 -1
- package/build/events/types/relay.interfaces.js +1 -1
- package/build/events/types/relay.interfaces.js.map +1 -1
- package/build/events/types/revocation.constants.js +1 -1
- package/build/events/types/revocation.constants.js.map +1 -1
- package/build/events/types/revocation.interfaces.js +1 -1
- package/build/events/types/revocation.interfaces.js.map +1 -1
- package/build/interfaces.d.ts +1 -1
- package/build/services/tenant-archive.d.ts +2 -2
- package/build/services/tenant-archive.js +2 -2
- package/build/types/app-config.d.ts +3 -3
- package/build/types/nx-context.d.ts +1 -1
- package/build/types/nx-context.js +1 -1
- package/build/utils/domain.d.ts +1 -1
- package/build/utils/domain.js +1 -1
- package/build/utils/env.constants.js +1 -1
- package/build/utils/env.constants.js.map +1 -1
- package/build/utils/express.d.ts +1 -1
- package/build/utils/express.js +2 -2
- package/build/utils/express.js.map +1 -1
- package/build/utils/functs.d.ts +2 -2
- package/build/utils/functs.js +6 -6
- package/build/utils/functs.js.map +1 -1
- package/build/utils/jwt.constants.d.ts +2 -2
- package/build/utils/jwt.constants.js +2 -2
- package/build/utils/jwt.js +3 -3
- package/build/utils/jwt.js.map +1 -1
- package/build/utils/tenancy.d.ts +4 -4
- package/build/utils/tenancy.js +5 -5
- package/build/utils/tenant.d.ts +6 -6
- package/build/utils/tenant.js +7 -7
- package/build/utils/tenant.js.map +1 -1
- package/package.json +2 -2
package/build/constants.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare const TENANT_EDIT_ROLES: BaseRoles[];
|
|
|
26
26
|
*
|
|
27
27
|
* Like the cumulative groups, they are **not enough**: they say *which role*, never *which
|
|
28
28
|
* organization*. Tenant scoping is applied by `BaseModel` itself, which asks the tenancy
|
|
29
|
-
* provider registered in `utils/tenancy.ts` (opt-out since nx-frame-be 1.0.46
|
|
29
|
+
* provider registered in `utils/tenancy.ts` (opt-out since nx-frame-be 1.0.46).
|
|
30
30
|
*/
|
|
31
31
|
export declare const CROSS_TENANT_ROLES: BaseRoles[];
|
|
32
32
|
export declare const TENANT_DATA_WRITE_ROLES: BaseRoles[];
|
|
@@ -64,7 +64,7 @@ export declare const TENANT_CONFIG_WRITE_ROLES: BaseRoles[];
|
|
|
64
64
|
*/
|
|
65
65
|
export declare const ORG_MANAGE_ROLES: BaseRoles[];
|
|
66
66
|
export declare const ORG_READ_ROLES: BaseRoles[];
|
|
67
|
-
/** Organization-tier roles: the only ones delegable by invitation or grant
|
|
67
|
+
/** Organization-tier roles: the only ones delegable by invitation or grant. */
|
|
68
68
|
export declare const ORG_MEMBER_ROLES: BaseRoles[];
|
|
69
69
|
/** Provider-tier roles: cross-tenant by nature, assignable from the system tier alone. */
|
|
70
70
|
export declare const APP_ROLES: BaseRoles[];
|
|
@@ -227,7 +227,7 @@ export declare const GDPR_DEFAULTS: {
|
|
|
227
227
|
* OUT OF BAND on purpose: a request names its organization through this header
|
|
228
228
|
* (or through the homonymous WebSocket connection param), never through the
|
|
229
229
|
* payload. A `tenantId` carried inside a mutation input would be forgeable by
|
|
230
|
-
* any client, which is exactly the hole
|
|
230
|
+
* any client, which is exactly the hole this closes.
|
|
231
231
|
*
|
|
232
232
|
* Read once where the context is built; from there on it lives on
|
|
233
233
|
* `NxContext.orgId` and is only ever consumed through `resolveTenant`.
|
package/build/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAa,SAAS,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,eAAO,MAAM,mBAAmB,eAAe,CAAC;AAEhD;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,aAAuD,CAAC;AAChF,eAAO,MAAM,YAAY,aAA2D,CAAC;AACrF,eAAO,MAAM,kBAAkB,aAAyD,CAAC;AACzF,eAAO,MAAM,mBAAmB,aAAqD,CAAC;AACtF,eAAO,MAAM,iBAAiB,aAAsD,CAAC;AAErF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAA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;;;;;;;;;CAapB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;CAmBzB,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;CAmB3B,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;CAiB3B,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;CAiB3B,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;CAezB,CAAC;AAMF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,aAAa,CAAC;AACxC,eAAO,MAAM,YAAY,UAAW,CAAC"}
|
package/build/constants.js
CHANGED
|
@@ -29,7 +29,7 @@ exports.TENANT_EDIT_ROLES = [...exports.TENANT_MANAGE_ROLES, enums_1.BaseRoles.O
|
|
|
29
29
|
*
|
|
30
30
|
* Like the cumulative groups, they are **not enough**: they say *which role*, never *which
|
|
31
31
|
* organization*. Tenant scoping is applied by `BaseModel` itself, which asks the tenancy
|
|
32
|
-
* provider registered in `utils/tenancy.ts` (opt-out since nx-frame-be 1.0.46
|
|
32
|
+
* provider registered in `utils/tenancy.ts` (opt-out since nx-frame-be 1.0.46).
|
|
33
33
|
*/
|
|
34
34
|
exports.CROSS_TENANT_ROLES = [...exports.ADMIN_ROLES, enums_1.BaseRoles.APP_TENANT_MNG];
|
|
35
35
|
exports.TENANT_DATA_WRITE_ROLES = [...exports.CROSS_TENANT_ROLES, enums_1.BaseRoles.ORG_MANAGER, enums_1.BaseRoles.ORG_EDITOR];
|
|
@@ -67,7 +67,7 @@ exports.TENANT_CONFIG_WRITE_ROLES = [...exports.CROSS_TENANT_ROLES, enums_1.Base
|
|
|
67
67
|
*/
|
|
68
68
|
exports.ORG_MANAGE_ROLES = [...exports.CROSS_TENANT_ROLES, enums_1.BaseRoles.ORG_MANAGER];
|
|
69
69
|
exports.ORG_READ_ROLES = [...exports.ORG_MANAGE_ROLES, enums_1.BaseRoles.ORG_EDITOR, enums_1.BaseRoles.ORG_MEMBER];
|
|
70
|
-
/** Organization-tier roles: the only ones delegable by invitation or grant
|
|
70
|
+
/** Organization-tier roles: the only ones delegable by invitation or grant. */
|
|
71
71
|
exports.ORG_MEMBER_ROLES = [enums_1.BaseRoles.ORG_MANAGER, enums_1.BaseRoles.ORG_EDITOR, enums_1.BaseRoles.ORG_MEMBER];
|
|
72
72
|
/** Provider-tier roles: cross-tenant by nature, assignable from the system tier alone. */
|
|
73
73
|
exports.APP_ROLES = [enums_1.BaseRoles.APP_CONFIG, enums_1.BaseRoles.APP_TENANT_MNG];
|
|
@@ -194,7 +194,7 @@ exports.GDPR_DEFAULTS = {
|
|
|
194
194
|
* OUT OF BAND on purpose: a request names its organization through this header
|
|
195
195
|
* (or through the homonymous WebSocket connection param), never through the
|
|
196
196
|
* payload. A `tenantId` carried inside a mutation input would be forgeable by
|
|
197
|
-
* any client, which is exactly the hole
|
|
197
|
+
* any client, which is exactly the hole this closes.
|
|
198
198
|
*
|
|
199
199
|
* Read once where the context is built; from there on it lives on
|
|
200
200
|
* `NxContext.orgId` and is only ever consumed through `resolveTenant`.
|
package/build/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,mCAA2C;AAC3C,8DAA+D;AAElD,QAAA,mBAAmB,GAAG,YAAY,CAAC;AAEhD;;;;;;GAMG;AACU,QAAA,WAAW,GAAW,CAAC,iBAAS,CAAC,MAAM,EAAW,iBAAS,CAAC,KAAK,CAAC,CAAC;AACnE,QAAA,YAAY,GAAU,CAAC,GAAG,mBAAW,EAAa,iBAAS,CAAC,UAAU,CAAC,CAAC;AACxE,QAAA,kBAAkB,GAAI,CAAC,GAAG,oBAAY,EAAY,iBAAS,CAAC,cAAc,CAAC,CAAC;AAC5E,QAAA,mBAAmB,GAAG,CAAC,GAAG,0BAAkB,EAAM,iBAAS,CA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AAC;IAC1B,aAAa,EAAY,CAAC;IAC1B,iBAAiB,EAAQ,CAAC;IAC1B,gBAAgB,EAAS,CAAC;IAC1B,oBAAoB,EAAK,CAAC;IAC1B,gBAAgB,EAAS,CAAC;IAC1B,oBAAoB,EAAK,CAAC;IAC1B,mBAAmB,EAAM,CAAC;IAC1B,uBAAuB,EAAE,CAAC;IAC1B,WAAW,EAAc,CAAC;CAC3B,CAAC;AAEW,QAAA,aAAa,GAAG;IAC3B,cAAc,EAAmB,CAAC;IAClC,eAAe,EAAkB,CAAC;IAClC,uBAAuB,EAAU,CAAC;IAClC,2BAA2B,EAAM,CAAC;IAClC,2BAA2B,EAAM,CAAC;IAClC,+BAA+B,EAAE,CAAC;IAClC,mBAAmB,EAAc,CAAC;IAClC,uBAAuB,EAAU,CAAC;IAClC,uBAAuB,EAAU,CAAC;IAClC,2BAA2B,EAAM,CAAC;IAClC,0BAA0B,EAAO,CAAC;IAClC,8BAA8B,EAAG,CAAC;IAClC,qBAAqB,EAAY,CAAC;IAClC,yBAAyB,EAAQ,CAAC;CACnC,CAAC;AAMF;;;;;;;;;;GAUG;AACU,QAAA,aAAa,GAAG,UAAU,CAAC;AAC3B,QAAA,YAAY,GAAI,OAAO,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { NatsPublisher } from './base/base-nats-publisher';
|
|
|
2
2
|
import { AccessRevokedEvent } from './types/revocation.interfaces';
|
|
3
3
|
import { Subjects } from './types/enums';
|
|
4
4
|
/**
|
|
5
|
-
* Publishes `access.revoked` on the ACCESS_EVENTS stream
|
|
5
|
+
* Publishes `access.revoked` on the ACCESS_EVENTS stream.
|
|
6
6
|
*
|
|
7
7
|
* auth-srv emits one event per revoked access-token id (`jti`) on logout so every
|
|
8
8
|
* resource service can deny it near-real-time via the {@link RevocationDenylist}.
|
|
@@ -4,7 +4,7 @@ exports.AccessRevokedPublisher = void 0;
|
|
|
4
4
|
const base_nats_publisher_1 = require("./base/base-nats-publisher");
|
|
5
5
|
const enums_1 = require("./types/enums");
|
|
6
6
|
/**
|
|
7
|
-
* Publishes `access.revoked` on the ACCESS_EVENTS stream
|
|
7
|
+
* Publishes `access.revoked` on the ACCESS_EVENTS stream.
|
|
8
8
|
*
|
|
9
9
|
* auth-srv emits one event per revoked access-token id (`jti`) on logout so every
|
|
10
10
|
* resource service can deny it near-real-time via the {@link RevocationDenylist}.
|
|
@@ -8,7 +8,7 @@ import { PublisherProvider } from '../types/relay.interfaces';
|
|
|
8
8
|
import { QueueEventType, Subjects, WriteEventType } from '../types/enums';
|
|
9
9
|
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 {
|
|
10
10
|
/**
|
|
11
|
-
* Declarative publish field-map
|
|
11
|
+
* Declarative publish field-map. The default parsePub* methods pick
|
|
12
12
|
* exactly these keys from the entity, replacing the ~57 hand-written per-controller
|
|
13
13
|
* parsers. `pubFields` drives BOTH create and update; set `pubUpdateFields` only
|
|
14
14
|
* for the rare create ≠ update case; `pubRemoveFields` is the leaner remove subset.
|
|
@@ -111,7 +111,7 @@ export declare abstract class BaseEventCtrl<TCreate extends Event, TUpdate exten
|
|
|
111
111
|
* populate references, attach a joined aggregate). Runs AFTER the atomic write
|
|
112
112
|
* and event dispatch, so a subclass can shape the doc handed back to its
|
|
113
113
|
* resolvers WITHOUT overriding create / update / get — which would shadow the
|
|
114
|
-
* transactional outbox
|
|
114
|
+
* transactional outbox. Default: identity.
|
|
115
115
|
*
|
|
116
116
|
* @param doc
|
|
117
117
|
* @param context
|
|
@@ -134,8 +134,8 @@ export declare abstract class BaseEventCtrl<TCreate extends Event, TUpdate exten
|
|
|
134
134
|
* Create the entity and its outbox row ATOMICALLY (same transaction when the
|
|
135
135
|
* deployment supports it), then dispatch the event and mark the row sent after
|
|
136
136
|
* commit. A broker failure leaves the row at sent:false (recoverable), never a
|
|
137
|
-
* lost event
|
|
138
|
-
*
|
|
137
|
+
* lost event: the entity write and the outbox row commit together, and no
|
|
138
|
+
* per-controller override may reimplement that dance.
|
|
139
139
|
*
|
|
140
140
|
* @param item
|
|
141
141
|
* @param context
|
|
@@ -153,6 +153,36 @@ export declare abstract class BaseEventCtrl<TCreate extends Event, TUpdate exten
|
|
|
153
153
|
* @returns
|
|
154
154
|
*/
|
|
155
155
|
update(id: string, item: TAttrs, context: NxContext, options?: UpdateOptions): Promise<TDoc>;
|
|
156
|
+
/**
|
|
157
|
+
* The point of an update where the main write has happened and the event does not exist yet.
|
|
158
|
+
*
|
|
159
|
+
* WHEN IT RUNS: inside the transaction of `update`, right after the write of the entity and
|
|
160
|
+
* BEFORE its outbox row is built and persisted. The document it receives is the one the write
|
|
161
|
+
* produced, so it carries the FINAL persisted state, `version` included - the value an ordering
|
|
162
|
+
* guard downstream has to compare against, which no earlier step of the update can know.
|
|
163
|
+
*
|
|
164
|
+
* WHAT IT IS FOR: keeping an invariant of the owning module that spans more than one of its
|
|
165
|
+
* documents, atomically with the write that changes it. The context it receives is the one of the
|
|
166
|
+
* transaction, so every write done with it joins that transaction.
|
|
167
|
+
*
|
|
168
|
+
* FAILURE: a throw aborts the transaction - the main write and every write done here are rolled
|
|
169
|
+
* back, no outbox row is committed and no event is dispatched, because the dispatch happens only
|
|
170
|
+
* after the commit. Without transaction support (a standalone deployment) there is no atomicity
|
|
171
|
+
* to offer: the main write stays, and the throw still prevents the event.
|
|
172
|
+
*
|
|
173
|
+
* WHAT IT MUST NOT DO: announce anything. An event armed or published from here would leave
|
|
174
|
+
* before the commit, or duplicate the one this update already emits. The event of this update is
|
|
175
|
+
* built from the document as written BEFORE this hook, so it keeps representing this entity.
|
|
176
|
+
*
|
|
177
|
+
* The default does nothing, so a controller that does not override it behaves exactly as before.
|
|
178
|
+
*
|
|
179
|
+
* NOTE: the same phase as the MODEL's `afterUpdate`, at the controller's level. The model's belongs
|
|
180
|
+
* to persistence; this one is where the application logic of the owning module lives.
|
|
181
|
+
*
|
|
182
|
+
* @param updated the document as the write produced it
|
|
183
|
+
* @param context the context of the transaction, carrying its session
|
|
184
|
+
*/
|
|
185
|
+
protected afterUpdate(updated: TDoc, context: NxContext): Promise<void>;
|
|
156
186
|
/**
|
|
157
187
|
*
|
|
158
188
|
* @param id
|
|
@@ -175,7 +205,7 @@ export declare abstract class BaseEventCtrl<TCreate extends Event, TUpdate exten
|
|
|
175
205
|
* Dispatch the prepared message to the broker, then mark the outbox row as sent.
|
|
176
206
|
* Runs AFTER the transaction commits, so `publish` (a non-DB side effect) is
|
|
177
207
|
* never retried by `withTransaction` and a broker failure leaves a recoverable
|
|
178
|
-
* sent:false row for the relay
|
|
208
|
+
* sent:false row for the relay.
|
|
179
209
|
*
|
|
180
210
|
* @param msg
|
|
181
211
|
* @param outboxId
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-event.controller.d.ts","sourceRoot":"","sources":["../../../src/events/base/base-event.controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAqC,mDAAmD,CAAC;AAC7G,OAAO,EAAE,YAAY,EAAE,MAAkC,wDAAwD,CAAC;AAClH,OAAO,EAAE,cAAc,EAAE,MAAgC,wDAAwD,CAAC;AAClH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAsB,sBAAsB,CAAC;AAChF,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAA6B,eAAe,CAAC;AAMzE,OAAO,EAAE,aAAa,EAAE,MAAiC,4BAA4B,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAA6B,2BAA2B,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAiB1E,8BAAsB,aAAa,CAAC,OAAO,SAAS,KAAK,EAAE,OAAO,SAAS,KAAK,EAAE,OAAO,SAAS,KAAK,EAAE,MAAM,EAAE,IAAI,SAAS,YAAY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AAE,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAyB3G;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;cACa,WAAW,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7E;;;;;OAKG;IACY,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBpE;;;;;;;;;OASG;cACa,aAAa,CAAC,GAAG,EAAE,aAAa,GAAG,SAAS,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAY9G;;;;;;;;;OASG;cACa,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAU/H;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,aAAa;CAMtB"}
|
|
@@ -33,7 +33,7 @@ class BaseEventCtrl extends base_controller_1.BaseController {
|
|
|
33
33
|
// protected abstract UpdatePublisher: new (client: MsgClientInterface) => Publisher<TUpdate> | NatsPublisher<TUpdate>;
|
|
34
34
|
// protected abstract RemovePublisher: new (client: MsgClientInterface) => Publisher<TRemove> | NatsPublisher<TRemove>;
|
|
35
35
|
/**
|
|
36
|
-
* Declarative publish field-map
|
|
36
|
+
* Declarative publish field-map. The default parsePub* methods pick
|
|
37
37
|
* exactly these keys from the entity, replacing the ~57 hand-written per-controller
|
|
38
38
|
* parsers. `pubFields` drives BOTH create and update; set `pubUpdateFields` only
|
|
39
39
|
* for the rare create ≠ update case; `pubRemoveFields` is the leaner remove subset.
|
|
@@ -178,7 +178,7 @@ class BaseEventCtrl extends base_controller_1.BaseController {
|
|
|
178
178
|
* populate references, attach a joined aggregate). Runs AFTER the atomic write
|
|
179
179
|
* and event dispatch, so a subclass can shape the doc handed back to its
|
|
180
180
|
* resolvers WITHOUT overriding create / update / get — which would shadow the
|
|
181
|
-
* transactional outbox
|
|
181
|
+
* transactional outbox. Default: identity.
|
|
182
182
|
*
|
|
183
183
|
* @param doc
|
|
184
184
|
* @param context
|
|
@@ -206,8 +206,8 @@ class BaseEventCtrl extends base_controller_1.BaseController {
|
|
|
206
206
|
* Create the entity and its outbox row ATOMICALLY (same transaction when the
|
|
207
207
|
* deployment supports it), then dispatch the event and mark the row sent after
|
|
208
208
|
* commit. A broker failure leaves the row at sent:false (recoverable), never a
|
|
209
|
-
* lost event
|
|
210
|
-
*
|
|
209
|
+
* lost event: the entity write and the outbox row commit together, and no
|
|
210
|
+
* per-controller override may reimplement that dance.
|
|
211
211
|
*
|
|
212
212
|
* @param item
|
|
213
213
|
* @param context
|
|
@@ -240,13 +240,50 @@ class BaseEventCtrl extends base_controller_1.BaseController {
|
|
|
240
240
|
let outboxId;
|
|
241
241
|
const res = await this.withTransaction(context, async (ctx) => {
|
|
242
242
|
const updated = await super.update(id, item, ctx, options);
|
|
243
|
-
|
|
243
|
+
// The payload is taken from the document AS WRITTEN, before the hook runs: the event
|
|
244
|
+
// announces the update of this entity, and whatever the hook does - it may touch other
|
|
245
|
+
// documents, and nothing stops it from touching this one - must not change what is announced.
|
|
246
|
+
const written = updated.toObject();
|
|
247
|
+
await this.afterUpdate(updated, ctx);
|
|
248
|
+
msg = this.buildMessage({ id, ...written }, enums_1.QueueEventType.update, context);
|
|
244
249
|
outboxId = await this.enqueueOutbox(msg, ctx);
|
|
245
250
|
return updated;
|
|
246
251
|
});
|
|
247
252
|
await this.dispatchOutbox(msg, outboxId, context);
|
|
248
253
|
return this.decorateDoc(res, context);
|
|
249
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* The point of an update where the main write has happened and the event does not exist yet.
|
|
257
|
+
*
|
|
258
|
+
* WHEN IT RUNS: inside the transaction of `update`, right after the write of the entity and
|
|
259
|
+
* BEFORE its outbox row is built and persisted. The document it receives is the one the write
|
|
260
|
+
* produced, so it carries the FINAL persisted state, `version` included - the value an ordering
|
|
261
|
+
* guard downstream has to compare against, which no earlier step of the update can know.
|
|
262
|
+
*
|
|
263
|
+
* WHAT IT IS FOR: keeping an invariant of the owning module that spans more than one of its
|
|
264
|
+
* documents, atomically with the write that changes it. The context it receives is the one of the
|
|
265
|
+
* transaction, so every write done with it joins that transaction.
|
|
266
|
+
*
|
|
267
|
+
* FAILURE: a throw aborts the transaction - the main write and every write done here are rolled
|
|
268
|
+
* back, no outbox row is committed and no event is dispatched, because the dispatch happens only
|
|
269
|
+
* after the commit. Without transaction support (a standalone deployment) there is no atomicity
|
|
270
|
+
* to offer: the main write stays, and the throw still prevents the event.
|
|
271
|
+
*
|
|
272
|
+
* WHAT IT MUST NOT DO: announce anything. An event armed or published from here would leave
|
|
273
|
+
* before the commit, or duplicate the one this update already emits. The event of this update is
|
|
274
|
+
* built from the document as written BEFORE this hook, so it keeps representing this entity.
|
|
275
|
+
*
|
|
276
|
+
* The default does nothing, so a controller that does not override it behaves exactly as before.
|
|
277
|
+
*
|
|
278
|
+
* NOTE: the same phase as the MODEL's `afterUpdate`, at the controller's level. The model's belongs
|
|
279
|
+
* to persistence; this one is where the application logic of the owning module lives.
|
|
280
|
+
*
|
|
281
|
+
* @param updated the document as the write produced it
|
|
282
|
+
* @param context the context of the transaction, carrying its session
|
|
283
|
+
*/
|
|
284
|
+
async afterUpdate(updated, context) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
250
287
|
/**
|
|
251
288
|
*
|
|
252
289
|
* @param id
|
|
@@ -288,7 +325,7 @@ class BaseEventCtrl extends base_controller_1.BaseController {
|
|
|
288
325
|
* Dispatch the prepared message to the broker, then mark the outbox row as sent.
|
|
289
326
|
* Runs AFTER the transaction commits, so `publish` (a non-DB side effect) is
|
|
290
327
|
* never retried by `withTransaction` and a broker failure leaves a recoverable
|
|
291
|
-
* sent:false row for the relay
|
|
328
|
+
* sent:false row for the relay.
|
|
292
329
|
*
|
|
293
330
|
* @param msg
|
|
294
331
|
* @param outboxId
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-event.controller.js","sourceRoot":"","sources":["../../../src/events/base/base-event.controller.ts"],"names":[],"mappings":";;;AAEA,4FAAkH;AAGlH,wCAAsE;AACtE,kDAA2E;AAC3E,4CAAwE;AACxE,8DAAiF;AAIjF,0CAA0E;AAiB1E,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;IAkBD,mFAAmF;IACnF,mFAAmF;IACnF,mFAAmF;IAEnF,YAAY,MAAgD;QAE1D,KAAK,CAAC,MAAM,CAAC,CAAC;QAxDhB,uHAAuH;QACvH,uHAAuH;QACvH,uHAAuH;QAEvH;;;;;;WAMG;QACO,cAAS,GAA4B,EAAE,CAAC;QAExC,oBAAe,GAAsB,EAAE,CAAC;QAyBlD;;;;;;;;;;WAUG;QACO,qBAAgB,GAAwB,EAAE,CAAC;QAQnD,IAAA,8CAAyB,EAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED;;;;;;OAMG;IACH,eAAe;QAEb,OAAO,CAAC,GAAG,IAAI,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC,eAAe,EAAE,GAAG,IAAI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;YAAE,OAAO,SAAS,CAAC;QAE3B,mFAAmF;QACnF,iFAAiF;QACjF,uEAAuE;QACvE,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAA,6BAAc,EAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAErD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;;;;OASG;IACO,KAAK,CAAC,cAAc,CAAC,GAA8B,EAAE,QAA4B,EAAE,OAAkB;QAE7G,IAAI,CAAC,GAAG;YAAE,OAAO;QAEjB,+EAA+E;QAC/E,gFAAgF;QAChF,6EAA6E;QAC7E,MAAM,IAAA,kCAAmB,EAAC,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;IACjG,CAAC;IAED;;;;;;;;;;;OAWG;IACK,aAAa,CAAC,GAAkB;QAEtC,OAAO,GAAG,CAAC,IAAI,KAAK,sBAAc,CAAC,MAAM;YACvC,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,OAAO,CAAC;YACvC,CAAC,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,UAAU,IAAI,EAAE,CAAC;IAC1D,CAAC;CACF;AA3ZD,sCA2ZC"}
|
|
@@ -13,6 +13,8 @@ export declare abstract class MsgListener<T extends Event> extends Listener<T> {
|
|
|
13
13
|
private subscription;
|
|
14
14
|
private messageStack;
|
|
15
15
|
private wait;
|
|
16
|
+
/** The id of the envelope being handled, so a failure can name the event it belongs to. */
|
|
17
|
+
private inFlightId;
|
|
16
18
|
protected ackWait: number;
|
|
17
19
|
constructor(provider: ClientProvider);
|
|
18
20
|
protected transportNameForLog(): string;
|
|
@@ -40,6 +42,30 @@ export declare abstract class MsgListener<T extends Event> extends Listener<T> {
|
|
|
40
42
|
* previous event.
|
|
41
43
|
*/
|
|
42
44
|
protected handleMessage(msg: Message): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Standardized "message failed" log - the ONE place a HANDLED in-memory failure is reported.
|
|
47
|
+
*
|
|
48
|
+
* ⚠ THIS IS THE OBSERVABILITY CONTRACT OF THIS TRANSPORT, not a consolation prize. The bus is
|
|
49
|
+
* best-effort by design: there is no ack to withhold, no nak to send and no redelivery to
|
|
50
|
+
* schedule, so a failure that has been handled leaves a log line and nothing else. Whatever
|
|
51
|
+
* must survive an error belongs on `NatsListener`, which owns the durable vocabulary.
|
|
52
|
+
*
|
|
53
|
+
* ⚠ IT LIVES HERE AND NOT ON `Listener`. The failure semantics it describes is the in-memory
|
|
54
|
+
* one; `NatsListener` reports its own failures beside its nak/DLQ decisions and would never
|
|
55
|
+
* call this. Giving the shared base an API only one transport uses would be uniformity for its
|
|
56
|
+
* own sake.
|
|
57
|
+
*
|
|
58
|
+
* `protected` on purpose, and no wider: a multi-item subclass has to report the failure of ONE
|
|
59
|
+
* element and carry on with the others, and that is the only reason this is not private.
|
|
60
|
+
*
|
|
61
|
+
* @param error what went wrong
|
|
62
|
+
* @param data the event - or the ITEM of a cascade, when the caller can name it
|
|
63
|
+
* @param method the logical method, for the structured context
|
|
64
|
+
*/
|
|
65
|
+
protected logFailure(error: unknown, data?: {
|
|
66
|
+
id?: string;
|
|
67
|
+
code?: string;
|
|
68
|
+
}, method?: string): void;
|
|
43
69
|
/**
|
|
44
70
|
* Unsubscribes from the in-memory bus on shutdown.
|
|
45
71
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-msg-listener.d.ts","sourceRoot":"","sources":["../../../src/events/base/base-msg-listener.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAyD,kBAAkB,CAAC;AAE9F,OAAO,EAAE,cAAc,EAAE,KAAK,EAAsB,eAAe,EAAE,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAE,QAAQ,EAAE,MAAwD,iBAAiB,CAAC;AAG7F;;;;;G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,OAAO,CAAC,UAAU,CAA4B;IAE9C,SAAS,CAAC,OAAO,EAAU,MAAM,CAAe;gBAEnC,QAAQ,EAAE,cAAc;cAMlB,mBAAmB,IAAI,MAAM;IAOhD,OAAO,KAAK,MAAM,GAGjB;IAED;;;;;OAKG;IACH,mBAAmB,IAAI,eAAe;IAKhC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAqB7B;;;;;OAKG;IACG,aAAa;IAqCnB;;;;;;OAMG;cACa,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IA4B1D;;;;;;;;;;;;;;;;;;;OAmBG;IACH,SAAS,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,GAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAkBtG;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAM3B;;;;;OAKG;IACH,OAAO,CAAC,YAAY;CAKrB"}
|
|
@@ -22,7 +22,7 @@ class MsgListener extends base_listener_1.Listener {
|
|
|
22
22
|
return 'MEM';
|
|
23
23
|
}
|
|
24
24
|
// Resolve the client only at listen/stop time, so the transport may be
|
|
25
|
-
// connected AFTER this listener is constructed
|
|
25
|
+
// connected AFTER this listener is constructed.
|
|
26
26
|
get client() {
|
|
27
27
|
return this.provider.client;
|
|
28
28
|
}
|
|
@@ -40,7 +40,10 @@ class MsgListener extends base_listener_1.Listener {
|
|
|
40
40
|
this.subscription?.on('message', (msg) => {
|
|
41
41
|
nx_frame_be_1.APP.logger.info(`📥 Received message on: ${this.subject} / ${this.queueGroupName}`, (0, nx_frame_be_1.logClassCtx)(this));
|
|
42
42
|
this.messageStack.push(msg);
|
|
43
|
-
|
|
43
|
+
// THE PROMISE IS NEVER DROPPED. `checkMessages` handles the failure of a single message
|
|
44
|
+
// itself, so this guard should never fire - which is exactly why it is here: nothing this
|
|
45
|
+
// class starts may end up as an unhandled rejection, whatever is added below later.
|
|
46
|
+
void this.checkMessages().catch(error => this.logFailure(error));
|
|
44
47
|
});
|
|
45
48
|
}
|
|
46
49
|
/**
|
|
@@ -59,9 +62,23 @@ class MsgListener extends base_listener_1.Listener {
|
|
|
59
62
|
try {
|
|
60
63
|
await this.handleMessage(msg);
|
|
61
64
|
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
// HANDLED HERE, AND HANDLED MEANS EXACTLY THIS: the failure is reported and the message is
|
|
67
|
+
// dropped. There is no ack to withhold, no nak to send and no redelivery to schedule - the
|
|
68
|
+
// transport is best-effort by design, and a retry here would make it a different one.
|
|
69
|
+
//
|
|
70
|
+
// ⚠ WHY IT MATTERS THAT IT IS CAUGHT AT ALL. Left to propagate, this rejection escaped a
|
|
71
|
+
// promise nobody awaited and reached the process, where `nx-frame-be` installs a handler
|
|
72
|
+
// that treats an unhandled rejection as fatal and asks for an emergency shutdown. A failing
|
|
73
|
+
// subscriber must not be able to take the service down.
|
|
74
|
+
this.logFailure(error, { id: this.inFlightId });
|
|
75
|
+
}
|
|
62
76
|
finally {
|
|
63
77
|
this.wait = false;
|
|
64
78
|
}
|
|
79
|
+
// ⚠ ALWAYS REACHED, and that is the second half of the fix. When the await above threw, this
|
|
80
|
+
// line was skipped and every message already queued behind the failing one stayed in the
|
|
81
|
+
// stack until some later publish happened to restart the drain.
|
|
65
82
|
await this.checkMessages();
|
|
66
83
|
}
|
|
67
84
|
/**
|
|
@@ -72,8 +89,10 @@ class MsgListener extends base_listener_1.Listener {
|
|
|
72
89
|
* previous event.
|
|
73
90
|
*/
|
|
74
91
|
async handleMessage(msg) {
|
|
92
|
+
this.inFlightId = undefined;
|
|
75
93
|
try {
|
|
76
94
|
const { id, data, meta } = (0, cascade_1.unwrapEnvelope)(this.parseMessage(msg));
|
|
95
|
+
this.inFlightId = id;
|
|
77
96
|
const violation = (0, cascade_1.cascadeViolation)(meta, this.subject);
|
|
78
97
|
if (violation) {
|
|
79
98
|
nx_frame_be_1.APP.logger.warn(`🔁 Cascade guard tripped on '${this.subject}': ${violation}`, (0, nx_frame_be_1.logClassCtx)(this));
|
|
@@ -87,6 +106,38 @@ class MsgListener extends base_listener_1.Listener {
|
|
|
87
106
|
this._incoming = undefined;
|
|
88
107
|
}
|
|
89
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Standardized "message failed" log - the ONE place a HANDLED in-memory failure is reported.
|
|
111
|
+
*
|
|
112
|
+
* ⚠ THIS IS THE OBSERVABILITY CONTRACT OF THIS TRANSPORT, not a consolation prize. The bus is
|
|
113
|
+
* best-effort by design: there is no ack to withhold, no nak to send and no redelivery to
|
|
114
|
+
* schedule, so a failure that has been handled leaves a log line and nothing else. Whatever
|
|
115
|
+
* must survive an error belongs on `NatsListener`, which owns the durable vocabulary.
|
|
116
|
+
*
|
|
117
|
+
* ⚠ IT LIVES HERE AND NOT ON `Listener`. The failure semantics it describes is the in-memory
|
|
118
|
+
* one; `NatsListener` reports its own failures beside its nak/DLQ decisions and would never
|
|
119
|
+
* call this. Giving the shared base an API only one transport uses would be uniformity for its
|
|
120
|
+
* own sake.
|
|
121
|
+
*
|
|
122
|
+
* `protected` on purpose, and no wider: a multi-item subclass has to report the failure of ONE
|
|
123
|
+
* element and carry on with the others, and that is the only reason this is not private.
|
|
124
|
+
*
|
|
125
|
+
* @param error what went wrong
|
|
126
|
+
* @param data the event - or the ITEM of a cascade, when the caller can name it
|
|
127
|
+
* @param method the logical method, for the structured context
|
|
128
|
+
*/
|
|
129
|
+
logFailure(error, data = {}, method) {
|
|
130
|
+
const stream = this.streamNameForLog();
|
|
131
|
+
nx_frame_be_1.APP.logger.error(`${this.transportNameForLog()} ${this.subject} ${this.queueGroupName}${stream ? ` ${stream}` : ''} - FAILED ${data?.id ?? '?'} ${data?.code ?? ''}`.trimEnd(), this.loggerCtx(method, {
|
|
132
|
+
event: 'failed',
|
|
133
|
+
eventId: data?.id,
|
|
134
|
+
eventCode: data?.code,
|
|
135
|
+
eventSubject: this.subject,
|
|
136
|
+
queueGroupName: this.queueGroupName,
|
|
137
|
+
streamName: stream,
|
|
138
|
+
error
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
90
141
|
/**
|
|
91
142
|
* Unsubscribes from the in-memory bus on shutdown.
|
|
92
143
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-msg-listener.js","sourceRoot":"","sources":["../../../src/events/base/base-msg-listener.ts"],"names":[],"mappings":";;;AAAA,sDAAkG;AAIlG,mDAA6F;AAC7F,wCAAwF;AAExF;;;;;GAKG;AACH,MAAsB,WAA6B,SAAQ,wBAAW;
|
|
1
|
+
{"version":3,"file":"base-msg-listener.js","sourceRoot":"","sources":["../../../src/events/base/base-msg-listener.ts"],"names":[],"mappings":";;;AAAA,sDAAkG;AAIlG,mDAA6F;AAC7F,wCAAwF;AAExF;;;;;GAKG;AACH,MAAsB,WAA6B,SAAQ,wBAAW;IAepE,YAAa,QAAwB;QAEnC,KAAK,EAAE,CAAC;QAVF,iBAAY,GAAmB,EAAE,CAAC;QAClC,SAAI,GAA2B,KAAK,CAAC;QAKnC,YAAO,GAAsB,CAAC,GAAG,IAAI,CAAC;QAK9C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAEkB,mBAAmB;QAEpC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,uEAAuE;IACvE,gDAAgD;IAChD,IAAY,MAAM;QAEhB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,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,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I,EAAE,EAAE,IAAI,GAAG,IAAI,IAAI,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC,OAAO,EAAE,EAC7J,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE;YACrB,KAAK,EAAW,QAAQ;YACxB,OAAO,EAAS,IAAI,EAAE,EAAE;YACxB,SAAS,EAAO,IAAI,EAAE,IAAI;YAC1B,YAAY,EAAI,IAAI,CAAC,OAAO;YAC5B,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,UAAU,EAAM,MAAM;YACtB,KAAK;SACN,CAAC,CACH,CAAC;IACJ,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;;;;;OAKG;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;AAzMD,kCAyMC"}
|
|
@@ -27,13 +27,13 @@ export declare abstract class NatsListener<T extends Event> extends Listener<T>
|
|
|
27
27
|
subscriptionOptions(): EventSubOptions;
|
|
28
28
|
/**
|
|
29
29
|
* Creates the JetStream durable consumer for this subject and starts the
|
|
30
|
-
* consume loop. Safe to call after the transport connects
|
|
30
|
+
* consume loop. Safe to call after the transport connects.
|
|
31
31
|
*/
|
|
32
32
|
listen(): Promise<void>;
|
|
33
33
|
/**
|
|
34
34
|
* Consume loop. Owns the message iteration and lifecycle; the per-message
|
|
35
35
|
* ack/nak/term decision lives in `handleMessage` so it can be unit-tested in
|
|
36
|
-
* isolation and so subclasses never have to ack again
|
|
36
|
+
* isolation and so subclasses never have to ack again.
|
|
37
37
|
*/
|
|
38
38
|
private processMessages;
|
|
39
39
|
/**
|
|
@@ -29,7 +29,7 @@ class NatsListener extends base_listener_1.Listener {
|
|
|
29
29
|
return this.streamName;
|
|
30
30
|
}
|
|
31
31
|
// Resolve the client only at listen/DLQ/stop time, so the transport may be
|
|
32
|
-
// connected AFTER this listener is constructed
|
|
32
|
+
// connected AFTER this listener is constructed.
|
|
33
33
|
get client() {
|
|
34
34
|
return this.provider.client;
|
|
35
35
|
}
|
|
@@ -44,7 +44,7 @@ class NatsListener extends base_listener_1.Listener {
|
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Creates the JetStream durable consumer for this subject and starts the
|
|
47
|
-
* consume loop. Safe to call after the transport connects
|
|
47
|
+
* consume loop. Safe to call after the transport connects.
|
|
48
48
|
*/
|
|
49
49
|
async listen() {
|
|
50
50
|
try {
|
|
@@ -63,7 +63,7 @@ class NatsListener extends base_listener_1.Listener {
|
|
|
63
63
|
/**
|
|
64
64
|
* Consume loop. Owns the message iteration and lifecycle; the per-message
|
|
65
65
|
* ack/nak/term decision lives in `handleMessage` so it can be unit-tested in
|
|
66
|
-
* isolation and so subclasses never have to ack again
|
|
66
|
+
* isolation and so subclasses never have to ack again.
|
|
67
67
|
*/
|
|
68
68
|
async processMessages() {
|
|
69
69
|
if (!this.consumer)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-nats-listener.js","sourceRoot":"","sources":["../../../src/events/base/base-nats-listener.ts"],"names":[],"mappings":";;;AAAA,sDAAkG;AAElG,0DAAoG;AAEpG,mDAA6F;AAC7F,wCAAwF;AAGxF;;;GAGG;AACH,MAAsB,YAA8B,SAAQ,wBAAW;IAkBrE,YAA8B,QAAwB;QAEpD,KAAK,EAAE,CAAC;QAFoB,aAAQ,GAAR,QAAQ,CAAgB;QAb9C,gBAAW,GAAgB,KAAK,CAAC;QAE/B,YAAO,GAAiB,EAAE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hC,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;;;;;OAKG;IACK,MAAM,CAAC,GAAU;QAEvB,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;OAKG;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;AAlRD,oCAkRC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* ────────────────────────────────────────────────────────────────────────────
|
|
3
|
-
* DLQ MANAGER — dead-letter observability & replay
|
|
3
|
+
* DLQ MANAGER — dead-letter observability & replay
|
|
4
4
|
*
|
|
5
|
-
* The failure path
|
|
5
|
+
* The failure path already parks poison messages on the `DLQ_EVENTS`
|
|
6
6
|
* stream: a message failing on `<subject>` is stored on `dlq.<subject>` as a
|
|
7
7
|
* `DeadLetterEnvelope` (original subject/stream/queue, delivery count, error,
|
|
8
8
|
* raw payload, timestamp) and dropped from its source stream. Until now the DLQ
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* ORIGINAL subject once the bug is fixed, then delete it from the DLQ.
|
|
15
15
|
*
|
|
16
16
|
* Replay is safe: the re-published event re-enters the normal, version-guarded
|
|
17
|
-
*
|
|
17
|
+
* consumer path, so a duplicate delivery is idempotent. The DLQ
|
|
18
18
|
* stream uses `Limits` retention (ack does NOT delete), so replay removes a
|
|
19
19
|
* message EXPLICITLY by its stream sequence only AFTER the re-publish succeeds —
|
|
20
20
|
* a failed re-publish leaves the message parked (no loss).
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* ────────────────────────────────────────────────────────────────────────────
|
|
3
|
-
* EVENT RELAY — at-least-once redelivery of `sent:false` outbox rows
|
|
3
|
+
* EVENT RELAY — at-least-once redelivery of `sent:false` outbox rows
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* With the atomic outbox an entity and its outbox row are
|
|
6
6
|
* committed together, then published post-commit; if the broker is down or the
|
|
7
7
|
* process crashes in that window the row stays `sent:false` and — until now — was
|
|
8
8
|
* never re-published. The relay drains those rows:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* ────────────────────────────────────────────────────────────────────────────
|
|
3
|
-
* FIELD-MAP — declarative publish payload picker
|
|
3
|
+
* FIELD-MAP — declarative publish payload picker
|
|
4
4
|
*
|
|
5
5
|
* Backs the default parsePub{Create,Update,Remove}Item of BaseEventCtrl: a pure
|
|
6
6
|
* key-pick that replaces ~57 hand-written per-controller parsers. Keys are copied
|
|
@@ -24,7 +24,7 @@ export interface MsgClientInterface {
|
|
|
24
24
|
* resolved client, and read `provider.client` only at publish/listen time. This
|
|
25
25
|
* keeps NATS access LAZY: controllers can be constructed (and their modules
|
|
26
26
|
* imported) before the transport is connected, without tripping the wrapper's
|
|
27
|
-
* "client before connecting" guard
|
|
27
|
+
* "client before connecting" guard.
|
|
28
28
|
*/
|
|
29
29
|
export interface ClientProvider {
|
|
30
30
|
readonly client: MsgClientInterface;
|