@spine-event-engine/server 2.0.0-snapshot.16 → 2.0.0-snapshot.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +17 -3
  2. package/REFERENCE.md +66 -12
  3. package/dist/context/bounded-context.d.ts +72 -14
  4. package/dist/context/bounded-context.d.ts.map +1 -1
  5. package/dist/context/bounded-context.js +130 -49
  6. package/dist/context/bounded-context.js.map +1 -1
  7. package/dist/context/effective-tenant.d.ts +9 -0
  8. package/dist/context/effective-tenant.d.ts.map +1 -0
  9. package/dist/context/effective-tenant.js +58 -0
  10. package/dist/context/effective-tenant.js.map +1 -0
  11. package/dist/context/tenant-index.d.ts.map +1 -1
  12. package/dist/context/tenant-index.js +70 -1
  13. package/dist/context/tenant-index.js.map +1 -1
  14. package/dist/delivery/delivery.d.ts.map +1 -1
  15. package/dist/delivery/delivery.js +270 -26
  16. package/dist/delivery/delivery.js.map +1 -1
  17. package/dist/delivery/inbox-storage.d.ts +7 -0
  18. package/dist/delivery/inbox-storage.d.ts.map +1 -1
  19. package/dist/delivery/inbox-storage.js +110 -0
  20. package/dist/delivery/inbox-storage.js.map +1 -1
  21. package/dist/entity/entity-metadata.d.ts +2 -2
  22. package/dist/entity/entity-metadata.js +2 -2
  23. package/dist/entity/entity-metadata.js.map +1 -1
  24. package/dist/entity/entity-storage-descriptor.d.ts +24 -4
  25. package/dist/entity/entity-storage-descriptor.d.ts.map +1 -1
  26. package/dist/entity/entity-storage-descriptor.js +69 -23
  27. package/dist/entity/entity-storage-descriptor.js.map +1 -1
  28. package/dist/entity/entity.d.ts +19 -18
  29. package/dist/entity/entity.d.ts.map +1 -1
  30. package/dist/entity/entity.js +61 -24
  31. package/dist/entity/entity.js.map +1 -1
  32. package/dist/entity/spec-scanner.d.ts +13 -1
  33. package/dist/entity/spec-scanner.d.ts.map +1 -1
  34. package/dist/entity/spec-scanner.js +20 -3
  35. package/dist/entity/spec-scanner.js.map +1 -1
  36. package/dist/index.d.ts +1 -1
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js.map +1 -1
  39. package/dist/repository/command-routing.d.ts +63 -10
  40. package/dist/repository/command-routing.d.ts.map +1 -1
  41. package/dist/repository/command-routing.js +41 -8
  42. package/dist/repository/command-routing.js.map +1 -1
  43. package/dist/repository/event-routing.d.ts +64 -9
  44. package/dist/repository/event-routing.d.ts.map +1 -1
  45. package/dist/repository/event-routing.js +42 -7
  46. package/dist/repository/event-routing.js.map +1 -1
  47. package/dist/repository/repository.d.ts +96 -10
  48. package/dist/repository/repository.d.ts.map +1 -1
  49. package/dist/repository/repository.js +437 -133
  50. package/dist/repository/repository.js.map +1 -1
  51. package/dist/repository/state-update-routing.d.ts +67 -8
  52. package/dist/repository/state-update-routing.d.ts.map +1 -1
  53. package/dist/repository/state-update-routing.js +45 -6
  54. package/dist/repository/state-update-routing.js.map +1 -1
  55. package/dist/server/server.d.ts.map +1 -1
  56. package/dist/server/server.js +407 -109
  57. package/dist/server/server.js.map +1 -1
  58. package/dist/services/registered-targets.d.ts +73 -0
  59. package/dist/services/registered-targets.d.ts.map +1 -0
  60. package/dist/services/registered-targets.js +127 -0
  61. package/dist/services/registered-targets.js.map +1 -0
  62. package/dist/services/spine-services.d.ts +26 -12
  63. package/dist/services/spine-services.d.ts.map +1 -1
  64. package/dist/services/spine-services.js +1044 -962
  65. package/dist/services/spine-services.js.map +1 -1
  66. package/dist/stand/stand.d.ts +73 -1
  67. package/dist/stand/stand.d.ts.map +1 -1
  68. package/dist/stand/stand.js +220 -48
  69. package/dist/stand/stand.js.map +1 -1
  70. package/dist/stand/subscription-observer.d.ts.map +1 -1
  71. package/dist/stand/subscription-observer.js +4 -11
  72. package/dist/stand/subscription-observer.js.map +1 -1
  73. package/dist/tsconfig.tsbuildinfo +1 -1
  74. package/package.json +12 -12
package/README.md CHANGED
@@ -164,9 +164,23 @@ abstract class RequestCoordinator extends ProcessManager<string, typeof RequestV
164
164
  ```
165
165
 
166
166
  These reads are eventually consistent. `limit()` may not exceed 1,000, and
167
- `all()` can be expensive for a large Projection; prefer a targeted, ordered,
168
- bounded query. Queries inherit the active handler's actor and tenant; there is
169
- no tenant override.
167
+ `all()` can be expensive for a large read model; prefer a targeted, ordered,
168
+ bounded query.
169
+
170
+ The Entity type identifies its context among those registered with the same
171
+ `Server`. For example, an order process can query a product in a catalogue
172
+ context without naming that context. An Entity in another context must allow
173
+ queries (`query` or `full` visibility). Registering the same Entity type in two
174
+ contexts causes a startup error.
175
+
176
+ The [Orders example](https://github.com/SpineEventEngine/spine-ts/blob/master/examples/orders/README.md#cross-context-order-review)
177
+ shows this in an Event handler and includes a runnable integration test.
178
+
179
+ Queries preserve the handler's actor and effective tenant; there is no tenant
180
+ override. Single-tenant execution uses `SINGLE_TENANT`, even when the request
181
+ omits a tenant field. A named tenant cannot query a single-tenant context: that
182
+ fails before reading. See the [query contract](REFERENCE.md#handler-routing-and-operations)
183
+ for the complete tenant rules and empty-result behavior.
170
184
 
171
185
  Use `EntityQuery.all(...)` when every predicate must match and
172
186
  `EntityQuery.either(...)` when any branch may match.
package/REFERENCE.md CHANGED
@@ -173,7 +173,20 @@ To override the default channel factory, add
173
173
  Event, command, and state-update routing accepts exact schemas and generated
174
174
  message-interface tokens. It selects an exact schema first, then the first
175
175
  matching token, then the replacement or default route. The route runs when the message is accepted; its
176
- validated typed targets are stored and reused for retries. The legacy-named
176
+ validated typed targets are stored and reused for retries. Route callbacks may
177
+ return a value or a Promise. `CommandRouting.create(EntityClass)`,
178
+ `EventRouting.create(EntityClass)`, and `StateUpdateRouting.create(ProjectionClass)`
179
+ infer the receiving ID, state, and application Entity types. The selected class
180
+ must be the same constructor registered by the repository;
181
+ construction rejects a mismatch even when two classes share ID and state types.
182
+ The callback's third argument exposes `findIds(query)`, `findStates(query)`, and `find(query)`
183
+ for that repository in the signal's tenant. The read access rejects new calls
184
+ after the route finishes. ID-only `create<Id>()` declarations remain valid.
185
+ Direct `repository.routeCommand()` and `repository.routeEvent()` calls return
186
+ Promises and must be awaited. Commands select exactly one ID; Events and state
187
+ updates may select any number of distinct IDs. After validation and stable
188
+ deduplication, routes above 1,000 recipients emit one warning and retain every
189
+ recipient. Inbox replay uses stored target IDs without rerouting. The legacy-named
177
190
  local `catchUpReadSide()` helper is unrelated to retry: it resets and replays
178
191
  the whole local read side, and is not Projection catch-up.
179
192
 
@@ -228,17 +241,49 @@ Nested promises and structural or imported thenable lookalikes are rejected duri
228
241
  The entity transaction remains open until that promise settles; rejection rolls
229
242
  back framework state and suppresses produced output, but cannot undo external
230
243
  side effects. Process Managers may use their protected read-only query surface
231
- for eventually consistent projection state during a handler. Aggregates must
232
- not use projection reads for invariants.
244
+ for eventually consistent Entity state during a handler. Aggregates must not
245
+ use these reads for invariants.
233
246
 
234
- `select(schema, columns)` supports `byId`, typed `where`, `mask`, `orderBy`,
247
+ `select(schema, columns)` supports `byId`, typed `where`, `orderBy`,
235
248
  `limit`, `read`, `findById`, and `all`. A Process Manager query returns at most
236
- 1,000 states. `all()` is a convenience and can be costly on a large Projection;
249
+ 1,000 states and accepts at most 1,000 explicit IDs at execution. A generated
250
+ `StateQuery.create()...build()` value also works with `this.select(query).read()`; its read
251
+ binds the current handler actor and tenant. `all()` is a convenience and can be costly on a large read model;
237
252
  prefer an ID-targeted or ordered bounded query.
238
253
 
239
254
  Use `EntityQuery.all(...)` to require every predicate and `EntityQuery.either(...)`
240
255
  to accept any branch. Query execution inherits the active handler's actor and
241
- tenant; the protected read-only facade has no tenant override.
256
+ effective tenant; the protected read-only facade has no tenant override.
257
+
258
+ `RepositoryReadQueries<EntityType>` describes the receiving repository's typed
259
+ `findIds`, `findStates`, and `find` reads. A read returns all matches unless the
260
+ shared generated query sets a limit. States are detached messages; `find`
261
+ restores application Entity instances with stored Version and lifecycle flags.
262
+ The framework binds each read scope to the incoming signal tenant. Routing
263
+ callbacks receive that scope as their third argument while they run.
264
+
265
+ For contexts registered with one `Server`, the target Entity's type URL selects
266
+ its context. No context name or network request is required. The Server rejects
267
+ duplicate Entity type registrations before starting delivery recovery or
268
+ listening, identifying the type and both contexts. Contexts used without a
269
+ Server retain local querying; separate Servers do not share query routes.
270
+
271
+ Cross-context targets must declare `query` or `full` visibility. This applies
272
+ to any Entity family with queryable state. Unknown targets, foreign targets
273
+ without query visibility, and tenant mismatches produce errors before storage
274
+ reads. Existing local and public-query visibility behavior is unchanged.
275
+
276
+ Single-tenant execution resolves to the built-in `SINGLE_TENANT` identity;
277
+ omitting the wire tenant field does not create tenant-free execution. Named
278
+ tenants can query their corresponding multitenant partition, not a single-tenant
279
+ destination. `SINGLE_TENANT` can query a single-tenant destination or its same
280
+ partition in a multitenant destination. The query never replaces the tenant to
281
+ suit the target. A valid query with no matching record keeps its ordinary empty
282
+ result (`undefined` from `findById()`). Reads remain eventually consistent.
283
+
284
+ Routes are available before recovered handlers execute. Server shutdown drains
285
+ accepted handlers across contexts before closing any target read-side; failed
286
+ startup validation participates in context and resource cleanup.
242
287
 
243
288
  ```ts
244
289
  import type { Message } from "@bufbuild/protobuf";
@@ -790,9 +835,11 @@ delivery and handler storage part of one distributed transaction.
790
835
 
791
836
  `keepUntil` is the optional deduplication-protection deadline, not a second
792
837
  retention setting. A delivered row is cleanup-eligible when that deadline is
793
- absent or elapsed. Under current shard ownership, environment delivery performs
794
- one bounded cleanup page, plus at most one continuation after a full protected
795
- page makes no removal. Direct local storage atomically verifies ownership and
838
+ absent or elapsed (`keepUntil <= now`). Delivery skips per-record mutation checks
839
+ and deletion attempts for rows whose deadline is still in the future. Cleanup
840
+ and retained-row duplicate recognition use the same applicable clock. Eligible
841
+ rows still receive final time and shard checks before deletion.
842
+ Direct local storage atomically verifies ownership and
796
843
  the exact delivered snapshot during removal. A remote adapter may instead read
797
844
  and compare the snapshot before sending a separate best-effort removal request;
798
845
  that sequence is not an atomic compare-and-delete guarantee. Pending, retryable,
@@ -813,7 +860,6 @@ const context = BoundedContext.singleTenant("Tasks")
813
860
 
814
861
  Aggregate commands and Process Manager commands/events derive their target shard
815
862
  internally and persist their envelope in the target Entity Inbox before any
816
- handler runs. Delivery is never a post-request callback: local and remote
817
863
  handler runs. Local intake can directly drain the persisted Inbox in the
818
864
  current request path. Attached `ServerEnvironment` ports acknowledge admission
819
865
  and delivery workers replay it through the same path. Projection rows remain
@@ -828,14 +874,22 @@ durable supervisor state, topology failover, exactly-once effects, or automatic
828
874
  retry of unknown remote mutations.
829
875
 
830
876
  Each Inbox read is bounded to one page. That bound does not limit the total
831
- pending work: an active drain can advance to another page while it retains the
832
- shard. Delivery compares pending rows with delivered rows in the current page
877
+ pending work: an active drain continues from the last row read until that scan
878
+ ends. It restarts from the beginning only if the completed scan delivered
879
+ messages, allowing it to find work added during delivery. It finishes after a
880
+ scan delivers nothing; it does not restart after each productive page.
881
+ Delivery compares pending rows with delivered rows in the current page
833
882
  and a process-local cache of the 1,000 most recent deliveries, then removes
834
883
  duplicates. The 30-second Inbox deduplication window controls how long delivered
835
884
  rows remain available as duplicate evidence; it is not a replay-retention
836
885
  period. Persisted accepted rows follow their delivery lifecycle and may be
837
886
  replayed according to that lifecycle after the deduplication window has elapsed.
838
887
 
888
+ Direct delivery uses the configured Inbox storage clock for both retained-row
889
+ duplicate checks and early cleanup filtering. Remote delivery uses local client
890
+ wall-clock time for these checks and does not assume it is synchronized with
891
+ the remote server.
892
+
839
893
  `DeliveryMonitor` is an instantiable, customizable policy seam exposing
840
894
  asynchronous continuation, start/completion, failed-reception, pickup-failure,
841
895
  and already-picked hooks.
@@ -218,6 +218,19 @@ interface FrameworkConstructionToken {
218
218
  readonly frameworkConstructionToken: true;
219
219
  }
220
220
  interface BoundedContextAccess {
221
+ /**
222
+ * Stops new work admission before a Server drains all its contexts.
223
+ *
224
+ * @param context Built context entering shutdown.
225
+ */
226
+ beginClose(context: BoundedContext): void;
227
+ /**
228
+ * Waits for accepted work while every Stand remains available.
229
+ *
230
+ * @param context Built context whose work must settle.
231
+ * @returns Completion after the context's accepted work drains.
232
+ */
233
+ drainWork(context: BoundedContext): Promise<void>;
221
234
  /**
222
235
  * Checks whether a value is a builder created by this module.
223
236
  *
@@ -330,6 +343,63 @@ interface BoundedContextAccess {
330
343
  */
331
344
  delivery(context: BoundedContext): ContextDeliveryDescriptor;
332
345
  }
346
+ /**
347
+ * Prepared services passed through the framework-only context construction hook.
348
+ */
349
+ interface BoundedContextAssembly {
350
+ /**
351
+ * Immutable context metadata.
352
+ */
353
+ readonly snapshot: BoundedContextSnapshot;
354
+ /**
355
+ * Command dispatch for this context.
356
+ */
357
+ readonly commandBus: CommandBus;
358
+ /**
359
+ * Domain Event dispatch for this context.
360
+ */
361
+ readonly eventBus: EventBus;
362
+ /**
363
+ * System Event dispatch for the paired context.
364
+ */
365
+ readonly systemEventBus: EventBus;
366
+ /**
367
+ * Publishes signals produced by handlers.
368
+ */
369
+ readonly publisher: SignalPublisher;
370
+ /**
371
+ * Domain read-side Stand.
372
+ */
373
+ readonly stand: Stand;
374
+ /**
375
+ * Paired System read-side Stand.
376
+ */
377
+ readonly systemStand: Stand;
378
+ /**
379
+ * Coordinates paired subscriptions.
380
+ */
381
+ readonly subscriptionRuntime: SubscriptionRuntime;
382
+ /**
383
+ * Paired System Context metadata.
384
+ */
385
+ readonly systemSpec: ContextSpecSnapshot;
386
+ /**
387
+ * Provider that creates context storage.
388
+ */
389
+ readonly storageFactory: StorageFactory;
390
+ /**
391
+ * Repositories registered in this context.
392
+ */
393
+ readonly repositories: readonly RepositoryView[];
394
+ /**
395
+ * Sharding choice for Entity Inbox delivery.
396
+ */
397
+ readonly deliveryStrategy: DeliveryStrategy;
398
+ /**
399
+ * Proof of framework-controlled construction.
400
+ */
401
+ readonly token: FrameworkConstructionToken;
402
+ }
333
403
  /**
334
404
  * Represents a built bounded context and its command, event, repository, and read-side resources.
335
405
  */
@@ -338,21 +408,9 @@ export declare class BoundedContext {
338
408
  /**
339
409
  * Creates a Bounded Context from its prepared framework services.
340
410
  *
341
- * @param snapshot Contains the immutable context metadata.
342
- * @param commandBus Dispatches commands accepted by this context.
343
- * @param eventBus Dispatches events accepted by this context.
344
- * @param systemEventBus Dispatches framework-only System events.
345
- * @param publisher Publishes signals produced by context handlers.
346
- * @param stand Stores read-side state for this context.
347
- * @param systemStand Stores read-side state for the paired System Context.
348
- * @param subscriptionRuntime Coordinates subscriptions for the paired contexts.
349
- * @param systemSpec Contains paired System Context metadata.
350
- * @param storageFactory Creates context storage.
351
- * @param repositories Lists repositories to register.
352
- * @param deliveryStrategy Selects immutable Entity Inbox shards.
353
- * @param token Proves framework-controlled construction.
411
+ * @param input Prepared services and framework construction token.
354
412
  */
355
- protected constructor(snapshot: BoundedContextSnapshot, commandBus: CommandBus, eventBus: EventBus, systemEventBus: EventBus, publisher: SignalPublisher, stand: Stand, systemStand: Stand, subscriptionRuntime: SubscriptionRuntime, systemSpec: ContextSpecSnapshot, storageFactory: StorageFactory, repositories: readonly RepositoryView[], deliveryStrategy: DeliveryStrategy, token: FrameworkConstructionToken);
413
+ protected constructor(input: BoundedContextAssembly);
356
414
  /**
357
415
  * Creates a builder for a context without tenant isolation.
358
416
  *
@@ -1 +1 @@
1
- {"version":3,"file":"bounded-context.d.ts","sourceRoot":"","sources":["../../src/context/bounded-context.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAK1C,OAAO,EAKL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,QAAQ,EACd,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAKL,KAAK,cAAc,EACnB,KAAK,cAAc,EAEpB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAE,UAAU,EAAoB,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EACL,QAAQ,EAER,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK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,IAAI;IAKxD;;;;;;;OAOG;IACH,mBAAmB,IAAI,IAAI;IAK3B;;;;;;;;OAQG;IACH,wBAAwB,CAAC,QAAQ,EAAE,yBAAyB,GAAG,IAAI;IAKnE;;;;;OAKG;IACH,oBAAoB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAKtD;;;;;OAKG;IACH,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,IAAI;IAKnD;;;;OAIG;IACH,KAAK,IAAI,cAAc;IAWvB;;;;;;;;;OASG;IACG,UAAU,IAAI,OAAO,CAAC,cAAc,CAAC;IA2S3C;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;CAGzB;AAED;;GAEG;AACH,qBAAa,WAAW;;IAUtB;;;;;OAKG;IACH,SAAS,aAAa,QAAQ,EAAE,mBAAmB,EAAE,KAAK,EAAE,0BAA0B;IAStF;;;;OAIG;IACH,IAAI,IAAI,IAAI,kBAAkB,CAE7B;IAED;;;;OAIG;IACH,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED;;;;OAIG;IACH,IAAI,UAAU,IAAI,UAAU,CAE3B;IAED;;;;OAIG;IACH,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED;;;;OAIG;IACH,IAAI,QAAQ,IAAI,mBAAmB,CAElC;CACF;AA2wDD;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC;IACrD,eAAe,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE,KAAK,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C,CAOC,CAAC"}
@@ -82,6 +82,7 @@ const contextLoggers = new WeakMap();
82
82
  const contextSignalPublishers = new WeakMap();
83
83
  const contextEventBuses = new WeakMap();
84
84
  const closingContexts = new WeakSet();
85
+ const contextClosePhases = new WeakMap();
85
86
  const contextIntegrations = new WeakMap();
86
87
  const systemEventPosters = new WeakMap();
87
88
  const builderBuilds = new WeakMap();
@@ -113,38 +114,25 @@ export class BoundedContext {
113
114
  * Registers the framework-only construction hook for this module.
114
115
  */
115
116
  static {
116
- constructBoundedContext = (snapshot, commandBus, eventBus, systemEventBus, publisher, stand, systemStand, runtime, systemSpec, storageFactory, repositories, deliveryStrategy, token) => new BoundedContext(snapshot, commandBus, eventBus, systemEventBus, publisher, stand, systemStand, runtime, systemSpec, storageFactory, repositories, deliveryStrategy, token);
117
+ constructBoundedContext = (input) => new BoundedContext(input);
117
118
  }
118
119
  /**
119
120
  * Creates a Bounded Context from its prepared framework services.
120
121
  *
121
- * @param snapshot Contains the immutable context metadata.
122
- * @param commandBus Dispatches commands accepted by this context.
123
- * @param eventBus Dispatches events accepted by this context.
124
- * @param systemEventBus Dispatches framework-only System events.
125
- * @param publisher Publishes signals produced by context handlers.
126
- * @param stand Stores read-side state for this context.
127
- * @param systemStand Stores read-side state for the paired System Context.
128
- * @param subscriptionRuntime Coordinates subscriptions for the paired contexts.
129
- * @param systemSpec Contains paired System Context metadata.
130
- * @param storageFactory Creates context storage.
131
- * @param repositories Lists repositories to register.
132
- * @param deliveryStrategy Selects immutable Entity Inbox shards.
133
- * @param token Proves framework-controlled construction.
134
- */
135
- constructor(snapshot, commandBus, eventBus, systemEventBus, publisher, stand, systemStand, subscriptionRuntime, systemSpec, storageFactory, repositories, deliveryStrategy, token) {
136
- ContextParts.requireFrameworkConstructionToken(token, "BoundedContext instances are framework-owned.");
137
- this.#snapshot = ContextParts.cloneContextSnapshot(snapshot);
138
- this.#commandBus = commandBus;
139
- this.#eventBus = eventBus;
140
- this.#systemEventBus = systemEventBus;
141
- this.#publisher = publisher;
142
- contextEventBuses.set(this, [eventBus, systemEventBus]);
143
- this.#stand = stand;
144
- this.#systemStand = systemStand;
145
- this.#subscriptionRuntime = subscriptionRuntime;
146
- this.#storageFactory = storageFactory;
147
- this.#deliveryStrategy = ContextParts.snapshotDeliveryStrategy(deliveryStrategy);
122
+ * @param input Prepared services and framework construction token.
123
+ */
124
+ constructor(input) {
125
+ ContextParts.requireFrameworkConstructionToken(input.token, "BoundedContext instances are framework-owned.");
126
+ this.#snapshot = ContextParts.cloneContextSnapshot(input.snapshot);
127
+ this.#commandBus = input.commandBus;
128
+ this.#eventBus = input.eventBus;
129
+ this.#systemEventBus = input.systemEventBus;
130
+ this.#publisher = input.publisher;
131
+ this.#stand = input.stand;
132
+ this.#systemStand = input.systemStand;
133
+ this.#subscriptionRuntime = input.subscriptionRuntime;
134
+ this.#storageFactory = input.storageFactory;
135
+ this.#deliveryStrategy = ContextParts.snapshotDeliveryStrategy(input.deliveryStrategy);
148
136
  this.#commandEndpoint = Object.freeze({
149
137
  acceptedCommandTypes: () => this.#commandBus.acceptedCommandTypes(),
150
138
  post: (command) => this.#commandBus.post(command),
@@ -153,6 +141,20 @@ export class BoundedContext {
153
141
  acceptedEventTypes: () => ContextParts.exposedEventTypeUrls(this.#eventBus),
154
142
  post: (event) => ContextParts.postContextEvent(this, event),
155
143
  });
144
+ const delivery = this.#createDelivery(input.storageFactory);
145
+ this.#entityInbox = delivery.entityInbox;
146
+ this.#projectionInbox = delivery.projectionInbox;
147
+ this.#installReferences(input, delivery);
148
+ this.#registerAndStart(input.repositories, delivery.tenantIndex);
149
+ Object.freeze(this);
150
+ }
151
+ /**
152
+ * Creates tenant-aware Inboxes and their shared readiness signal.
153
+ *
154
+ * @param storageFactory Provider supplying the tenant catalog.
155
+ * @returns Inboxes, tenant index, and readiness signal.
156
+ */
157
+ #createDelivery(storageFactory) {
156
158
  const deliveryReadiness = new DeliveryReadiness();
157
159
  const tenantIndex = TenantIndexes.create({
158
160
  contextName: this.#snapshot.name.value,
@@ -160,16 +162,40 @@ export class BoundedContext {
160
162
  storageFactory,
161
163
  });
162
164
  const keepTenant = (tenantId) => tenantIndex.keep(tenantId);
163
- this.#entityInbox = new LocalEntityInbox(this.#snapshot.name.value, deliveryReadiness, keepTenant, this.#deliveryStrategy);
164
- this.#projectionInbox = new LocalProjectionInbox(this.#snapshot.name.value, deliveryReadiness, keepTenant);
165
+ const entityInbox = new LocalEntityInbox(this.#snapshot.name.value, deliveryReadiness, keepTenant, this.#deliveryStrategy);
166
+ const projectionInbox = new LocalProjectionInbox(this.#snapshot.name.value, deliveryReadiness, keepTenant);
167
+ return { deliveryReadiness, tenantIndex, entityInbox, projectionInbox };
168
+ }
169
+ /**
170
+ * Installs framework references used after context construction.
171
+ *
172
+ * @param input Prepared framework services.
173
+ * @param delivery Tenant index and Inboxes prepared for this context.
174
+ */
175
+ #installReferences(input, delivery) {
176
+ contextEventBuses.set(this, [this.#eventBus, this.#systemEventBus]);
165
177
  eventSubscribers.set(this, (typeUrl, subscriber) => eventBusAccess.subscribe(this.#eventBus, typeUrl, subscriber));
166
178
  systemEventPosters.set(this, (event) => this.#publisher.publishSystemEvent(event));
167
- contextSystemPairings.set(this, ContextParts.createSystemPairing(this.#snapshot, systemSpec));
168
- contextTenantIndexes.set(this, tenantIndex);
169
- contextStorageFactories.set(this, storageFactory);
170
- contextSubscriptionRuntimes.set(this, subscriptionRuntime);
171
- contextSignalPublishers.set(this, publisher);
172
- contextDeliveryDescriptors.set(this, ContextParts.createDeliveryDescriptor(this.#snapshot, storageFactory, tenantIndex, this.#entityInbox, this.#projectionInbox, deliveryReadiness));
179
+ contextSystemPairings.set(this, ContextParts.createSystemPairing(this.#snapshot, input.systemSpec));
180
+ contextTenantIndexes.set(this, delivery.tenantIndex);
181
+ contextStorageFactories.set(this, input.storageFactory);
182
+ contextSubscriptionRuntimes.set(this, this.#subscriptionRuntime);
183
+ contextSignalPublishers.set(this, this.#publisher);
184
+ contextClosePhases.set(this, {
185
+ begin: () => {
186
+ this.#beginClose();
187
+ },
188
+ drain: () => this.#drainWork(),
189
+ });
190
+ contextDeliveryDescriptors.set(this, ContextParts.createDeliveryDescriptor(this.#snapshot, input.storageFactory, delivery.tenantIndex, this.#entityInbox, this.#projectionInbox, delivery.deliveryReadiness));
191
+ }
192
+ /**
193
+ * Registers repositories and starts subscriptions, closing the tenant index on failure.
194
+ *
195
+ * @param repositories Prepared repositories.
196
+ * @param tenantIndex Index to close if registration fails.
197
+ */
198
+ #registerAndStart(repositories, tenantIndex) {
173
199
  try {
174
200
  this.#registerRepositories(repositories);
175
201
  this.#subscriptionRuntime.start();
@@ -183,7 +209,6 @@ export class BoundedContext {
183
209
  }
184
210
  throw error;
185
211
  }
186
- Object.freeze(this);
187
212
  }
188
213
  #registerRepositories(repositories) {
189
214
  const preparedRepositories = this.#prepareRepositories(repositories);
@@ -401,18 +426,40 @@ export class BoundedContext {
401
426
  * @returns A promise that settles after all resources close.
402
427
  */
403
428
  close() {
429
+ this.#beginClose();
430
+ this.#closed ??= this.#closeOnce();
431
+ return this.#closed;
432
+ }
433
+ /**
434
+ * Stops admission to this context's signal and bus work.
435
+ */
436
+ #beginClose() {
404
437
  closingContexts.add(this);
405
438
  this.#publisher.beginClose();
406
439
  commandBusAccess.beginClose(this.#commandBus);
407
440
  eventBusAccess.beginClose(this.#eventBus);
408
441
  eventBusAccess.beginClose(this.#systemEventBus);
409
- this.#closed ??= this.#closeOnce();
410
- return this.#closed;
411
442
  }
412
- async #closeOnce() {
443
+ /**
444
+ * Closes integration intake and drains accepted context work before Stand close.
445
+ *
446
+ * @returns Completion after the context's accepted work settles.
447
+ */
448
+ async #drainWork() {
413
449
  const errors = [];
414
450
  await ContextParts.closeContextPart(() => ContextParts.closeIntegration(this), errors);
415
451
  await ContextParts.closeContextPart(() => ContextParts.drainContextWork(this.#commandBus, this.#eventBus, this.#systemEventBus, this.#publisher), errors);
452
+ if (errors.length > 0)
453
+ throw new AggregateError(errors, "BoundedContext drain failed.");
454
+ }
455
+ /**
456
+ * Closes the context's remaining stores and repository registrations.
457
+ *
458
+ * @returns Completion after resource closure.
459
+ */
460
+ async #closeOnce() {
461
+ const errors = [];
462
+ await ContextParts.closeContextPart(() => this.#drainWork(), errors);
416
463
  this.#publisher.finishClose();
417
464
  await ContextParts.closeContextPart(() => commandBusAccess.finishClose(this.#commandBus), errors);
418
465
  await ContextParts.closeContextPart(() => eventBusAccess.finishClose(this.#eventBus), errors);
@@ -426,23 +473,43 @@ export class BoundedContext {
426
473
  await ContextParts.closeContextPart(() => {
427
474
  ContextParts.requireTenantIndex(this).close();
428
475
  }, errors);
476
+ await this.#closeRepositories(errors);
477
+ if (errors.length > 0) {
478
+ this.#closed = undefined;
479
+ throw new AggregateError(ContextParts.flattenErrors(errors), "BoundedContext close failed.");
480
+ }
481
+ ContextParts.clearContextMetadata(this);
482
+ }
483
+ /**
484
+ * Clears repository runtime registration after Stand closure.
485
+ *
486
+ * @param errors Failures collected during context closure.
487
+ */
488
+ async #closeRepositories(errors) {
429
489
  for (const repository of this.#repositoryViews) {
430
490
  await ContextParts.closeContextPart(() => {
431
491
  repositoryAccess.clearRuntime(repository);
432
492
  registeredRepositories.delete(repository);
433
493
  }, errors);
434
494
  }
435
- if (errors.length > 0) {
436
- this.#closed = undefined;
437
- throw new AggregateError(ContextParts.flattenErrors(errors), "BoundedContext close failed.");
438
- }
439
- ContextParts.clearContextMetadata(this);
440
495
  }
441
496
  }
442
497
  /**
443
498
  * Exposes framework-only operations for built contexts and their builders.
444
499
  */
445
500
  export const boundedContextAccess = Object.freeze({
501
+ beginClose(context) {
502
+ const phase = contextClosePhases.get(context);
503
+ if (phase === undefined)
504
+ throw new TypeError("Close phase requires a built BoundedContext.");
505
+ phase.begin();
506
+ },
507
+ drainWork(context) {
508
+ const phase = contextClosePhases.get(context);
509
+ if (phase === undefined)
510
+ return Promise.reject(new TypeError("Drain requires a built BoundedContext."));
511
+ return phase.drain();
512
+ },
446
513
  installLogger(context, logger) {
447
514
  if (!contextStorageFactories.has(context)) {
448
515
  throw new TypeError("Context logger requires a built BoundedContext instance.");
@@ -1219,10 +1286,24 @@ const ContextParts = Object.freeze({
1219
1286
  */
1220
1287
  createBoundedContext(specSnapshot, commandBus, eventBus, systemEventBus, publisher, stand, systemStand, runtime, systemSpec, storageFactory, repositories, deliveryStrategy) {
1221
1288
  return constructBoundedContext({
1222
- name: specSnapshot.name,
1223
- tenantMode: ContextParts.toTenantMode(specSnapshot.multitenant),
1224
- spec: specSnapshot,
1225
- }, commandBus, eventBus, systemEventBus, publisher, stand, systemStand, runtime, systemSpec, storageFactory, repositories, deliveryStrategy, frameworkConstructionToken);
1289
+ snapshot: {
1290
+ name: specSnapshot.name,
1291
+ tenantMode: ContextParts.toTenantMode(specSnapshot.multitenant),
1292
+ spec: specSnapshot,
1293
+ },
1294
+ commandBus,
1295
+ eventBus,
1296
+ systemEventBus,
1297
+ publisher,
1298
+ stand,
1299
+ systemStand,
1300
+ subscriptionRuntime: runtime,
1301
+ systemSpec,
1302
+ storageFactory,
1303
+ repositories,
1304
+ deliveryStrategy,
1305
+ token: frameworkConstructionToken,
1306
+ });
1226
1307
  },
1227
1308
  /**
1228
1309
  * Creates the storage mode represented by a context snapshot.