@spine-event-engine/server 2.0.0-snapshot.2 → 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 (227) hide show
  1. package/README.md +225 -518
  2. package/REFERENCE.md +498 -49
  3. package/dist/browser/browser-server.d.ts +95 -0
  4. package/dist/browser/browser-server.d.ts.map +1 -0
  5. package/dist/{server → browser}/browser-server.js +93 -7
  6. package/dist/browser/browser-server.js.map +1 -0
  7. package/dist/browser/durable-subscription-bindings.d.ts.map +1 -0
  8. package/dist/browser/durable-subscription-bindings.js.map +1 -0
  9. package/dist/browser/index.d.ts +12 -0
  10. package/dist/browser/index.d.ts.map +1 -0
  11. package/dist/browser/index.js +24 -0
  12. package/dist/browser/index.js.map +1 -0
  13. package/dist/browser/options.d.ts +183 -0
  14. package/dist/browser/options.d.ts.map +1 -0
  15. package/dist/browser/options.js +15 -0
  16. package/dist/browser/options.js.map +1 -0
  17. package/dist/bus/command-bus.d.ts +2 -0
  18. package/dist/bus/command-bus.d.ts.map +1 -1
  19. package/dist/bus/command-bus.js +36 -1
  20. package/dist/bus/command-bus.js.map +1 -1
  21. package/dist/bus/event-dispatcher-registry.d.ts +2 -2
  22. package/dist/bus/event-dispatcher-registry.js +3 -3
  23. package/dist/bus/event-dispatcher-registry.js.map +1 -1
  24. package/dist/context/bounded-context.d.ts +238 -83
  25. package/dist/context/bounded-context.d.ts.map +1 -1
  26. package/dist/context/bounded-context.js +1083 -286
  27. package/dist/context/bounded-context.js.map +1 -1
  28. package/dist/context/effective-tenant.d.ts +9 -0
  29. package/dist/context/effective-tenant.d.ts.map +1 -0
  30. package/dist/context/effective-tenant.js +58 -0
  31. package/dist/context/effective-tenant.js.map +1 -0
  32. package/dist/context/entity-inbox.d.ts.map +1 -1
  33. package/dist/context/entity-inbox.js +24 -17
  34. package/dist/context/entity-inbox.js.map +1 -1
  35. package/dist/context/local-inbox-handoff.d.ts +7 -3
  36. package/dist/context/local-inbox-handoff.d.ts.map +1 -1
  37. package/dist/context/local-inbox-handoff.js +32 -26
  38. package/dist/context/local-inbox-handoff.js.map +1 -1
  39. package/dist/context/projection-handoff.d.ts.map +1 -1
  40. package/dist/context/projection-handoff.js +36 -31
  41. package/dist/context/projection-handoff.js.map +1 -1
  42. package/dist/context/tenant-index.d.ts.map +1 -1
  43. package/dist/context/tenant-index.js +72 -2
  44. package/dist/context/tenant-index.js.map +1 -1
  45. package/dist/delivery/delivery-ports.d.ts +14 -4
  46. package/dist/delivery/delivery-ports.d.ts.map +1 -1
  47. package/dist/delivery/delivery.d.ts +19 -21
  48. package/dist/delivery/delivery.d.ts.map +1 -1
  49. package/dist/delivery/delivery.js +541 -158
  50. package/dist/delivery/delivery.js.map +1 -1
  51. package/dist/delivery/inbox-storage.d.ts +12 -3
  52. package/dist/delivery/inbox-storage.d.ts.map +1 -1
  53. package/dist/delivery/inbox-storage.js +160 -67
  54. package/dist/delivery/inbox-storage.js.map +1 -1
  55. package/dist/delivery/inbox.d.ts +9 -0
  56. package/dist/delivery/inbox.d.ts.map +1 -1
  57. package/dist/delivery/inbox.js +11 -0
  58. package/dist/delivery/inbox.js.map +1 -1
  59. package/dist/delivery/sharded-work-registry.d.ts.map +1 -1
  60. package/dist/delivery/sharded-work-registry.js +2 -1
  61. package/dist/delivery/sharded-work-registry.js.map +1 -1
  62. package/dist/entity/entity-metadata.d.ts +14 -5
  63. package/dist/entity/entity-metadata.d.ts.map +1 -1
  64. package/dist/entity/entity-metadata.js +38 -2
  65. package/dist/entity/entity-metadata.js.map +1 -1
  66. package/dist/entity/entity-storage-descriptor.d.ts +25 -5
  67. package/dist/entity/entity-storage-descriptor.d.ts.map +1 -1
  68. package/dist/entity/entity-storage-descriptor.js +69 -23
  69. package/dist/entity/entity-storage-descriptor.js.map +1 -1
  70. package/dist/entity/entity-transaction.d.ts +46 -42
  71. package/dist/entity/entity-transaction.d.ts.map +1 -1
  72. package/dist/entity/entity-transaction.js +130 -35
  73. package/dist/entity/entity-transaction.js.map +1 -1
  74. package/dist/entity/entity.d.ts +243 -98
  75. package/dist/entity/entity.d.ts.map +1 -1
  76. package/dist/entity/entity.js +405 -226
  77. package/dist/entity/entity.js.map +1 -1
  78. package/dist/entity/spec-scanner.d.ts +13 -1
  79. package/dist/entity/spec-scanner.d.ts.map +1 -1
  80. package/dist/entity/spec-scanner.js +20 -3
  81. package/dist/entity/spec-scanner.js.map +1 -1
  82. package/dist/handler/command-registration-readiness.d.ts +6 -6
  83. package/dist/handler/command-registration-readiness.d.ts.map +1 -1
  84. package/dist/handler/command-registration-readiness.js +4 -2
  85. package/dist/handler/command-registration-readiness.js.map +1 -1
  86. package/dist/handler/declared-rejections.d.ts +11 -0
  87. package/dist/handler/declared-rejections.d.ts.map +1 -0
  88. package/dist/handler/declared-rejections.js +34 -0
  89. package/dist/handler/declared-rejections.js.map +1 -0
  90. package/dist/handler/event-registration-readiness.d.ts +13 -56
  91. package/dist/handler/event-registration-readiness.d.ts.map +1 -1
  92. package/dist/handler/event-registration-readiness.js +23 -43
  93. package/dist/handler/event-registration-readiness.js.map +1 -1
  94. package/dist/handler/generated-handler-registry.d.ts +72 -33
  95. package/dist/handler/generated-handler-registry.d.ts.map +1 -1
  96. package/dist/handler/generated-handler-registry.js +421 -43
  97. package/dist/handler/generated-handler-registry.js.map +1 -1
  98. package/dist/handler/generated-registry-discovery.d.ts.map +1 -1
  99. package/dist/handler/generated-registry-discovery.js +2 -4
  100. package/dist/handler/generated-registry-discovery.js.map +1 -1
  101. package/dist/handler/handler-decorators.d.ts +91 -37
  102. package/dist/handler/handler-decorators.d.ts.map +1 -1
  103. package/dist/handler/handler-decorators.js +124 -31
  104. package/dist/handler/handler-decorators.js.map +1 -1
  105. package/dist/handler/handler-metadata.d.ts +105 -60
  106. package/dist/handler/handler-metadata.d.ts.map +1 -1
  107. package/dist/handler/handler-metadata.js +275 -57
  108. package/dist/handler/handler-metadata.js.map +1 -1
  109. package/dist/handler/registration-readiness-metadata.d.ts +4 -0
  110. package/dist/handler/registration-readiness-metadata.d.ts.map +1 -1
  111. package/dist/handler/registration-readiness-metadata.js +84 -2
  112. package/dist/handler/registration-readiness-metadata.js.map +1 -1
  113. package/dist/handler/standalone.d.ts +25 -0
  114. package/dist/handler/standalone.d.ts.map +1 -0
  115. package/dist/handler/standalone.js +38 -0
  116. package/dist/handler/standalone.js.map +1 -0
  117. package/dist/index.d.ts +9 -9
  118. package/dist/index.d.ts.map +1 -1
  119. package/dist/index.js +3 -3
  120. package/dist/index.js.map +1 -1
  121. package/dist/repository/command-routing.d.ts +63 -10
  122. package/dist/repository/command-routing.d.ts.map +1 -1
  123. package/dist/repository/command-routing.js +41 -8
  124. package/dist/repository/command-routing.js.map +1 -1
  125. package/dist/repository/event-routing.d.ts +64 -9
  126. package/dist/repository/event-routing.d.ts.map +1 -1
  127. package/dist/repository/event-routing.js +42 -7
  128. package/dist/repository/event-routing.js.map +1 -1
  129. package/dist/repository/primitive-id.d.ts +12 -23
  130. package/dist/repository/primitive-id.d.ts.map +1 -1
  131. package/dist/repository/primitive-id.js +2 -27
  132. package/dist/repository/primitive-id.js.map +1 -1
  133. package/dist/repository/repository.d.ts +317 -87
  134. package/dist/repository/repository.d.ts.map +1 -1
  135. package/dist/repository/repository.js +3746 -856
  136. package/dist/repository/repository.js.map +1 -1
  137. package/dist/repository/state-update-routing.d.ts +67 -8
  138. package/dist/repository/state-update-routing.d.ts.map +1 -1
  139. package/dist/repository/state-update-routing.js +45 -6
  140. package/dist/repository/state-update-routing.js.map +1 -1
  141. package/dist/runtime/runtime.js +1 -1
  142. package/dist/runtime/runtime.js.map +1 -1
  143. package/dist/runtime/signal-metadata.d.ts +22 -47
  144. package/dist/runtime/signal-metadata.d.ts.map +1 -1
  145. package/dist/runtime/signal-metadata.js +34 -69
  146. package/dist/runtime/signal-metadata.js.map +1 -1
  147. package/dist/runtime/signal-publisher.d.ts +144 -0
  148. package/dist/runtime/signal-publisher.d.ts.map +1 -0
  149. package/dist/runtime/signal-publisher.js +248 -0
  150. package/dist/runtime/signal-publisher.js.map +1 -0
  151. package/dist/runtime/standalone-handler-runtime.d.ts +130 -0
  152. package/dist/runtime/standalone-handler-runtime.d.ts.map +1 -0
  153. package/dist/runtime/standalone-handler-runtime.js +382 -0
  154. package/dist/runtime/standalone-handler-runtime.js.map +1 -0
  155. package/dist/server/environment-attachment.d.ts.map +1 -1
  156. package/dist/server/environment-attachment.js +2 -1
  157. package/dist/server/environment-attachment.js.map +1 -1
  158. package/dist/server/environment-delivery-worker.d.ts.map +1 -1
  159. package/dist/server/environment-delivery-worker.js +21 -12
  160. package/dist/server/environment-delivery-worker.js.map +1 -1
  161. package/dist/server/managed-server-application.d.ts +4 -1
  162. package/dist/server/managed-server-application.d.ts.map +1 -1
  163. package/dist/server/managed-server-application.js +2 -2
  164. package/dist/server/managed-server-application.js.map +1 -1
  165. package/dist/server/node-coordinator.js +2 -2
  166. package/dist/server/node-coordinator.js.map +1 -1
  167. package/dist/server/server-log.d.ts.map +1 -1
  168. package/dist/server/server-log.js +4 -0
  169. package/dist/server/server-log.js.map +1 -1
  170. package/dist/server/server.d.ts +9 -177
  171. package/dist/server/server.d.ts.map +1 -1
  172. package/dist/server/server.js +428 -178
  173. package/dist/server/server.js.map +1 -1
  174. package/dist/services/query-reader.d.ts +19 -0
  175. package/dist/services/query-reader.d.ts.map +1 -0
  176. package/dist/services/query-reader.js +43 -0
  177. package/dist/services/query-reader.js.map +1 -0
  178. package/dist/services/registered-targets.d.ts +73 -0
  179. package/dist/services/registered-targets.d.ts.map +1 -0
  180. package/dist/services/registered-targets.js +127 -0
  181. package/dist/services/registered-targets.js.map +1 -0
  182. package/dist/services/spine-services.d.ts +26 -12
  183. package/dist/services/spine-services.d.ts.map +1 -1
  184. package/dist/services/spine-services.js +1047 -969
  185. package/dist/services/spine-services.js.map +1 -1
  186. package/dist/spi/delivery.d.ts +5 -0
  187. package/dist/spi/delivery.d.ts.map +1 -0
  188. package/dist/spi/delivery.js +18 -0
  189. package/dist/spi/delivery.js.map +1 -0
  190. package/dist/spi/handler-registry.d.ts +8 -0
  191. package/dist/spi/handler-registry.d.ts.map +1 -0
  192. package/dist/spi/handler-registry.js +15 -0
  193. package/dist/spi/handler-registry.js.map +1 -0
  194. package/dist/stand/stand.d.ts +73 -1
  195. package/dist/stand/stand.d.ts.map +1 -1
  196. package/dist/stand/stand.js +221 -48
  197. package/dist/stand/stand.js.map +1 -1
  198. package/dist/stand/subscription-observer.d.ts.map +1 -1
  199. package/dist/stand/subscription-observer.js +5 -12
  200. package/dist/stand/subscription-observer.js.map +1 -1
  201. package/dist/stand/subscription-registry.js +1 -1
  202. package/dist/stand/subscription-registry.js.map +1 -1
  203. package/dist/testing/index.d.ts +25 -3
  204. package/dist/testing/index.d.ts.map +1 -1
  205. package/dist/testing/index.js +23 -3
  206. package/dist/testing/index.js.map +1 -1
  207. package/dist/tsconfig.tsbuildinfo +1 -1
  208. package/package.json +33 -23
  209. package/dist/handler/build-time-handler-analyzer.d.ts +0 -150
  210. package/dist/handler/build-time-handler-analyzer.d.ts.map +0 -1
  211. package/dist/handler/build-time-handler-analyzer.js +0 -1101
  212. package/dist/handler/build-time-handler-analyzer.js.map +0 -1
  213. package/dist/handler/generated-registry-writer.d.ts +0 -58
  214. package/dist/handler/generated-registry-writer.d.ts.map +0 -1
  215. package/dist/handler/generated-registry-writer.js +0 -458
  216. package/dist/handler/generated-registry-writer.js.map +0 -1
  217. package/dist/handler/handler-codegen.d.ts +0 -48
  218. package/dist/handler/handler-codegen.d.ts.map +0 -1
  219. package/dist/handler/handler-codegen.js +0 -214
  220. package/dist/handler/handler-codegen.js.map +0 -1
  221. package/dist/server/browser-server.d.ts +0 -49
  222. package/dist/server/browser-server.d.ts.map +0 -1
  223. package/dist/server/browser-server.js.map +0 -1
  224. package/dist/server/durable-subscription-bindings.d.ts.map +0 -1
  225. package/dist/server/durable-subscription-bindings.js.map +0 -1
  226. /package/dist/{server → browser}/durable-subscription-bindings.d.ts +0 -0
  227. /package/dist/{server → browser}/durable-subscription-bindings.js +0 -0
@@ -1,7 +1,10 @@
1
- import { type Message } from "@bufbuild/protobuf";
1
+ import { type Message, type MessageShape } from "@bufbuild/protobuf";
2
+ import type { EntityQueryDescription } from "@spine-event-engine/core/codegen";
2
3
  import { type MessageSchema, StringifierRegistry } from "@spine-event-engine/core";
3
- import { type Command, type Event, type TenantId } from "@spine-event-engine/proto";
4
+ import { type Command, type Event, type TenantId, type Version } from "@spine-event-engine/proto";
5
+ import { type EntityRecord } from "@spine-event-engine/proto/generated/spine/server/entity/entity_pb.js";
4
6
  import { type StorageFactory, type StorageMode } from "@spine-event-engine/storage";
7
+ import { SignalPublisher } from "../runtime/signal-publisher.js";
5
8
  import { type CommandRouting } from "./command-routing.js";
6
9
  import { type EventRouting } from "./event-routing.js";
7
10
  import { type StateUpdateRouting } from "./state-update-routing.js";
@@ -9,40 +12,104 @@ import type { CommandDispatcher } from "../bus/command-dispatcher.js";
9
12
  import type { EventDispatcher } from "../bus/event-dispatcher.js";
10
13
  import { Delivery } from "../delivery/delivery.js";
11
14
  import { type InboxMessage, type InboxMessageInput } from "../delivery/inbox.js";
12
- import { Aggregate, type Entity, ProcessManager, Projection, type EntityFamily } from "../entity/entity.js";
15
+ import { Aggregate, type EntityOptions, ProcessManager, Projection, type EntityFamily } from "../entity/entity.js";
13
16
  import { type DescriptorFieldMetadata, type DescriptorMessageSchema, type EntityMetadata } from "../entity/entity-metadata.js";
14
17
  import { type EventHandlerFilterPlan } from "../handler/event-handler-filter.js";
15
18
  import { SignalMetadata } from "../runtime/signal-metadata.js";
16
- import { type CommandAssignmentHandlerMetadata, type CommandReactionHandlerMetadata, type EntityHandlersMetadata, type EventReactionHandlerMetadata, type StateSubscriptionHandlerMetadata, type RegisteredHandlerMetadata, type WhereOptions } from "../handler/handler-metadata.js";
17
- import { type Stand } from "../stand/stand.js";
18
- type RepositoryEntityInstance<Schema extends DescriptorMessageSchema = DescriptorMessageSchema> = Aggregate<unknown, Schema, unknown> | Projection<unknown, Schema, unknown> | ProcessManager<unknown, Schema, unknown>;
19
+ import { type CommandAssignmentHandlerMetadata, type CommandReactionHandlerMetadata, type EntityHandlersMetadata, type EventReactionHandlerMetadata, type StateSubscriptionHandlerMetadata, type HandlerMetadata, type RegisteredHandlerMetadata, type WhereOptions } from "../handler/handler-metadata.js";
20
+ import { standAccess, type Stand } from "../stand/stand.js";
19
21
  /**
20
- * Generated Protobuf-ES state schema carried by a repository entity constructor.
22
+ * Represents an Aggregate, Projection, or Process Manager with a state schema.
23
+ *
24
+ * @typeParam Schema Generated state schema of the Entity instance.
25
+ */
26
+ type RepositoryEntityInstance<Schema extends DescriptorMessageSchema = DescriptorMessageSchema> = Aggregate<unknown, Schema> | Projection<unknown, Schema> | ProcessManager<unknown, Schema>;
27
+ /**
28
+ * Generated state schema declared by a repository's Entity class.
29
+ *
30
+ * @typeParam EntityType Entity constructor whose state schema is selected.
31
+ */
32
+ export type RepositoryStateSchema<EntityType extends RepositoryEntityType> = EntityType["prototype"] extends Aggregate<unknown, infer Schema> ? Schema : EntityType["prototype"] extends Projection<unknown, infer Schema> ? Schema : EntityType["prototype"] extends ProcessManager<unknown, infer Schema> ? Schema : never;
33
+ /**
34
+ * Selects the ID type declared by a repository Entity constructor.
35
+ *
36
+ * @typeParam EntityType Entity constructor whose ID type is selected.
37
+ */
38
+ export type RepositoryEntityId<EntityType extends RepositoryEntityType> = EntityType["prototype"] extends Aggregate<infer Id, DescriptorMessageSchema> ? Id : EntityType["prototype"] extends Projection<infer Id, DescriptorMessageSchema> ? Id : EntityType["prototype"] extends ProcessManager<infer Id, DescriptorMessageSchema> ? Id : never;
39
+ /**
40
+ * Read operations available for one receiving repository and incoming signal tenant.
41
+ * The routing invocation closes this access when it finishes.
42
+ *
43
+ * @typeParam EntityType Registered application Entity class.
44
+ */
45
+ export interface RepositoryReadQueries<EntityType extends RepositoryEntityType> {
46
+ /**
47
+ * Returns matching typed IDs in query order.
48
+ *
49
+ * @param query Query for this repository's state schema.
50
+ * @returns Every matching ID unless the query sets a limit.
51
+ */
52
+ findIds(query: EntityQueryDescription<RepositoryStateSchema<EntityType>, RepositoryEntityId<EntityType>>): Promise<readonly RepositoryEntityId<EntityType>[]>;
53
+ /**
54
+ * Returns independent complete generated state messages.
55
+ *
56
+ * @param query Query for this repository's state schema.
57
+ * @returns Detached states in query order.
58
+ */
59
+ findStates(query: EntityQueryDescription<RepositoryStateSchema<EntityType>, RepositoryEntityId<EntityType>>): Promise<readonly MessageShape<RepositoryStateSchema<EntityType>>[]>;
60
+ /**
61
+ * Restores application Entity instances with stored versions and lifecycle flags.
62
+ *
63
+ * @param query Query for this repository's state schema.
64
+ * @returns Registered application instances in query order.
65
+ */
66
+ find(query: EntityQueryDescription<RepositoryStateSchema<EntityType>, RepositoryEntityId<EntityType>>): Promise<readonly InstanceType<EntityType>[]>;
67
+ }
68
+ /**
69
+ * Describes handler metadata compatible with an Entity constructor.
70
+ *
71
+ * @typeParam EntityType Entity constructor represented by the handlers.
21
72
  */
22
- export type RepositoryStateSchema<EntityType extends RepositoryEntityType> = EntityType["prototype"] extends Aggregate<infer Id, infer Schema, infer Version> ? [Id, Version] extends [unknown, unknown] ? Schema : never : EntityType["prototype"] extends Projection<infer Id, infer Schema, infer Version> ? [Id, Version] extends [unknown, unknown] ? Schema : never : EntityType["prototype"] extends ProcessManager<infer Id, infer Schema, infer Version> ? [Id, Version] extends [unknown, unknown] ? Schema : never : never;
23
- type RepositoryEntityId<EntityType extends RepositoryEntityType> = EntityType["prototype"] extends Aggregate<infer Id, DescriptorMessageSchema, unknown> ? Id : EntityType["prototype"] extends Projection<infer Id, DescriptorMessageSchema, unknown> ? Id : EntityType["prototype"] extends ProcessManager<infer Id, DescriptorMessageSchema, unknown> ? Id : never;
24
73
  type RepositoryHandlers<EntityType extends RepositoryEntityType> = EntityType["prototype"] extends infer Instance extends object ? EntityHandlersMetadata<Instance, RepositoryStateSchema<EntityType>> : never;
25
- type RepositoryHandlersOptionFor<EntityType extends RepositoryEntityType> = EntityType["prototype"] extends Aggregate<unknown, DescriptorMessageSchema, infer Version> ? [Version] extends [bigint] ? RepositoryHandlers<EntityType> | readonly RepositoryHandlers<EntityType>[] : never : EntityType["prototype"] extends Projection<unknown, DescriptorMessageSchema, infer Version> ? [Version] extends [number] ? RepositoryHandlers<EntityType> | readonly RepositoryHandlers<EntityType>[] : never : EntityType["prototype"] extends ProcessManager<unknown, DescriptorMessageSchema, infer Version> ? [Version] extends [number] ? RepositoryHandlers<EntityType> | readonly RepositoryHandlers<EntityType>[] : never : never;
26
- type StateRoutingOption<EntityType extends RepositoryEntityType> = EntityType["prototype"] extends Projection<unknown, DescriptorMessageSchema, unknown> ? StateUpdateRouting<RepositoryEntityId<EntityType>> : never;
74
+ /**
75
+ * Accepts one or several handler metadata blocks for an Entity constructor.
76
+ *
77
+ * @typeParam EntityType Entity constructor represented by the handlers.
78
+ */
79
+ type RepositoryHandlersOptionFor<EntityType extends RepositoryEntityType> = RepositoryHandlers<EntityType> | readonly RepositoryHandlers<EntityType>[];
80
+ /**
81
+ * Allows state-update routing only for Projection constructors.
82
+ *
83
+ * @typeParam EntityType Entity constructor being configured.
84
+ */
85
+ type StateRoutingOption<EntityType extends RepositoryEntityType> = EntityType["prototype"] extends Projection<unknown, DescriptorMessageSchema> ? StateUpdateRouting<RepositoryEntityId<EntityType>, NoInfer<EntityType>> | StateUpdateRouting<RepositoryEntityId<EntityType>> : never;
86
+ /**
87
+ * Detects a TypeScript union while preserving the complete input type.
88
+ *
89
+ * @typeParam Type Candidate type to test.
90
+ * @typeParam Union Original unsplit candidate type.
91
+ */
27
92
  type IsUnion<Type, Union = Type> = Type extends unknown ? [Union] extends [Type] ? false : true : false;
28
93
  /**
29
- * Single concrete entity constructor accepted by repository identity metadata.
94
+ * Checks whether a repository binds one concrete Entity class and state schema.
30
95
  *
31
96
  * Concrete aggregate, projection, and process-manager classes satisfy this type naturally. Broad
32
97
  * constructor aliases, constructor unions, broad state schemas, and state-schema unions are
33
- * rejected so repository identities cannot erase which state schema the entity owns.
98
+ * rejected so a repository cannot lose its Entity class's state schema.
99
+ *
100
+ * @typeParam EntityType Candidate concrete Entity constructor.
34
101
  */
35
102
  export type ConcreteRepositoryEntityType<EntityType extends RepositoryEntityType> = IsUnion<EntityType> extends true ? never : RepositoryEntityType extends EntityType ? never : [ConstructorParameters<EntityType>] extends [never[]] ? never : IsUnion<RepositoryStateSchema<EntityType>> extends true ? never : DescriptorMessageSchema extends RepositoryStateSchema<EntityType> ? never : unknown;
36
103
  /**
37
- * Describes an entity constructor accepted by repository identity metadata.
104
+ * Describes an Aggregate, Projection, or Process Manager class accepted by a repository.
38
105
  *
39
- * @typeParam Instance - The aggregate, projection, or process-manager instance type.
106
+ * @typeParam Instance The aggregate, projection, or process-manager instance type.
40
107
  * @param args The constructor arguments accepted by the entity class.
41
108
  * @returns An entity instance.
42
109
  */
43
- export type RepositoryEntityType<Instance extends RepositoryEntityInstance = RepositoryEntityInstance> = (abstract new (...args: never[]) => Instance) & typeof Entity<any, DescriptorMessageSchema, any> & {
110
+ export type RepositoryEntityType<Instance extends RepositoryEntityInstance = RepositoryEntityInstance> = (abstract new (...args: never[]) => Instance) & {
44
111
  /**
45
- * Prototype inspected for built-in entity family marker inheritance.
112
+ * Prototype used to identify the Entity family and state schema.
46
113
  */
47
114
  readonly prototype: Instance;
48
115
  /**
@@ -51,40 +118,46 @@ export type RepositoryEntityType<Instance extends RepositoryEntityInstance = Rep
51
118
  readonly name: string;
52
119
  };
53
120
  /**
54
- * Options for constructing repository identity and context-owned registration.
121
+ * Entity class, state schema, and routing options for a repository.
55
122
  *
56
- * @typeParam EntityType - A single concrete aggregate, projection, or process-manager constructor.
123
+ * @typeParam EntityType A single concrete aggregate, projection, or process-manager constructor.
57
124
  * The constructor's prototype must carry one concrete generated state schema; broad constructor,
58
125
  * constructor-union, broad-schema, and schema-union bindings are rejected at compile time.
59
126
  */
60
- export interface RepositoryOptions<EntityType extends RepositoryEntityType & ConcreteRepositoryEntityType<EntityType>> {
127
+ interface RepositoryOptionsBase<EntityType extends RepositoryEntityType & ConcreteRepositoryEntityType<EntityType>> {
61
128
  /**
62
- * Entity constructor owned by this repository identity.
129
+ * Entity class constructed by this repository.
63
130
  */
64
131
  readonly entityType: EntityType;
65
132
  /**
66
- * Generated Protobuf-ES schema for the entity state owned by this repository identity.
133
+ * Generated schema for this repository's Entity state.
67
134
  */
68
135
  readonly schema: RepositoryStateSchema<EntityType>;
69
136
  /**
70
- * Explicit handler metadata used to register repository command and event routing.
137
+ * Constructs each new or restored Entity with application dependencies.
71
138
  *
72
- * Aggregate repositories with handlers can be executed by built bounded contexts and therefore
73
- * must use `bigint` version metadata, matching the persisted aggregate history version type.
74
- * Projection repositories with handlers can be executed by built bounded contexts and therefore
75
- * must use `number` version metadata, matching the protobuf event version carried into Stand.
76
- * Process-manager repositories with handlers also execute through Stand-backed state and must
77
- * use `number` version metadata, matching the Stand version shape used by the local runtime.
139
+ * The callback receives the framework's ID, schema, state, Version, and lifecycle options.
140
+ * It must synchronously return a fresh instance of `entityType` that passes those options to
141
+ * the Entity base constructor. Shared services should be created before context startup and
142
+ * closed by the application after context shutdown.
143
+ *
144
+ * @param options Framework identity, state, Version, and lifecycle values.
145
+ * @returns A synchronous instance of the registered Entity class.
146
+ */
147
+ readonly onCreate?: (options: EntityOptions<RepositoryEntityId<EntityType>, RepositoryStateSchema<EntityType>>) => InstanceType<EntityType>;
148
+ /**
149
+ * Explicit handler metadata used to register repository command and event routing.
150
+ * The metadata must describe this repository's Entity constructor and state schema.
78
151
  */
79
152
  readonly handlers?: RepositoryHandlersOptionFor<EntityType>;
80
153
  /**
81
154
  * Mutable Command route declarations snapshotted when this repository is constructed.
82
155
  */
83
- readonly commandRouting?: CommandRouting<RepositoryEntityId<EntityType>>;
156
+ readonly commandRouting?: CommandRouting<RepositoryEntityId<EntityType>, NoInfer<EntityType>> | CommandRouting<RepositoryEntityId<EntityType>>;
84
157
  /**
85
158
  * Mutable Event route declarations snapshotted when this repository is constructed.
86
159
  */
87
- readonly eventRouting?: EventRouting<RepositoryEntityId<EntityType>>;
160
+ readonly eventRouting?: EventRouting<RepositoryEntityId<EntityType>, NoInfer<EntityType>> | EventRouting<RepositoryEntityId<EntityType>>;
88
161
  /**
89
162
  * Mutable state-update declarations allowed only for Projections.
90
163
  */
@@ -120,32 +193,63 @@ export interface RepositoryOptions<EntityType extends RepositoryEntityType & Con
120
193
  readonly depth?: number;
121
194
  };
122
195
  }
196
+ /**
197
+ * Requires a creation callback when the Entity constructor needs application arguments.
198
+ *
199
+ * @typeParam EntityType Concrete Entity constructor configured by this repository.
200
+ */
201
+ type RepositoryCreationOption<EntityType extends RepositoryEntityType> = [EntityType] extends [
202
+ new (options: EntityOptions<RepositoryEntityId<EntityType>, RepositoryStateSchema<EntityType>>) => InstanceType<EntityType>
203
+ ] ? {
204
+ readonly onCreate?: OnCreate<EntityType>;
205
+ } : {
206
+ readonly onCreate: OnCreate<EntityType>;
207
+ };
208
+ /**
209
+ * Constructs the registered Entity from framework-supplied options.
210
+ *
211
+ * @typeParam EntityType Concrete Entity constructor configured by the repository.
212
+ * @param options Framework identity, state, Version, and lifecycle values.
213
+ * @returns One new Entity instance.
214
+ */
215
+ type OnCreate<EntityType extends RepositoryEntityType> = (options: EntityOptions<RepositoryEntityId<EntityType>, RepositoryStateSchema<EntityType>>) => InstanceType<EntityType>;
216
+ /**
217
+ * Configures repository identity, routing, and optional Entity constructor injection.
218
+ *
219
+ * `onCreate` is required when `EntityType` needs constructor arguments beyond framework
220
+ * `EntityOptions`. The callback runs for new and restored instances before handlers; it receives
221
+ * the authoritative options and must return a synchronous instance of the registered class.
222
+ * Framework history, queries, transactions, and persistence remain configured separately.
223
+ *
224
+ * @typeParam EntityType A single concrete Entity constructor and state schema.
225
+ */
226
+ export type RepositoryOptions<EntityType extends RepositoryEntityType & ConcreteRepositoryEntityType<EntityType>> = RepositoryOptionsBase<EntityType> & RepositoryCreationOption<EntityType>;
123
227
  /**
124
228
  * Immutable copy-safe repository identity snapshot.
125
229
  *
126
- * @typeParam EntityType - The concrete entity constructor owned by the repository. The snapshot's
230
+ * @typeParam EntityType The concrete entity constructor represented by the repository. The snapshot's
127
231
  * state schema and metadata are derived from this constructor so callers cannot spell an impossible
128
232
  * entity/schema snapshot pair.
129
233
  */
130
234
  export interface RepositoryIdentitySnapshot<EntityType extends RepositoryEntityType = RepositoryEntityType> {
131
235
  /**
132
- * Entity constructor owned by the repository.
236
+ * Entity class registered with the repository.
133
237
  */
134
238
  readonly entityType: EntityType;
135
239
  /**
136
- * Entity family inferred from the constructor's built-in family marker base class.
240
+ * Aggregate, Projection, or Process Manager family of the Entity class.
137
241
  */
138
242
  readonly entityFamily: EntityFamily;
139
243
  /**
140
- * Generated Protobuf-ES schema for the owned entity state.
244
+ * Generated schema for the Entity state.
141
245
  */
142
246
  readonly stateSchema: RepositoryStateSchema<EntityType>;
143
247
  /**
144
- * Descriptor-derived metadata for the owned entity state.
248
+ * Descriptor metadata for the Entity state.
145
249
  */
146
250
  readonly metadata: EntityMetadata<RepositoryStateSchema<EntityType>>;
147
251
  /**
148
- * Fully qualified Protobuf type name of the owned entity state.
252
+ * Fully qualified Protobuf name of the Entity state type.
149
253
  */
150
254
  readonly stateFullTypeName: RepositoryStateSchema<EntityType>["typeName"];
151
255
  /**
@@ -158,23 +262,23 @@ export interface RepositoryIdentitySnapshot<EntityType extends RepositoryEntityT
158
262
  */
159
263
  export interface RepositoryView {
160
264
  /**
161
- * Entity constructor owned by the repository.
265
+ * Entity class registered with the repository.
162
266
  */
163
267
  readonly entityType: RepositoryEntityType;
164
268
  /**
165
- * Entity family inferred from the constructor's built-in family marker base class.
269
+ * Aggregate, Projection, or Process Manager family of the Entity class.
166
270
  */
167
271
  readonly entityFamily: EntityFamily;
168
272
  /**
169
- * Generated Protobuf-ES schema for the owned entity state.
273
+ * Generated schema for the Entity state.
170
274
  */
171
275
  readonly stateSchema: DescriptorMessageSchema;
172
276
  /**
173
- * Descriptor-derived metadata for the owned entity state.
277
+ * Descriptor metadata for the Entity state.
174
278
  */
175
279
  readonly metadata: EntityMetadata;
176
280
  /**
177
- * Fully qualified Protobuf type name of the owned entity state.
281
+ * Fully qualified Protobuf name of the Entity state type.
178
282
  */
179
283
  readonly stateFullTypeName: string;
180
284
  /**
@@ -191,7 +295,7 @@ export interface RepositoryView {
191
295
  */
192
296
  export type RepositoryIdentityErrorCode = "ENTITY_SCHEMA_KIND_MISMATCH" | "UNSUPPORTED_ENTITY_TYPE";
193
297
  /**
194
- * Describes an error raised when repository identity metadata cannot be constructed.
298
+ * Error raised when an Entity class and state schema cannot form a repository.
195
299
  */
196
300
  export declare class RepositoryIdentityError extends Error {
197
301
  /**
@@ -207,30 +311,17 @@ export declare class RepositoryIdentityError extends Error {
207
311
  constructor(code: RepositoryIdentityErrorCode, message: string);
208
312
  }
209
313
  /**
210
- * Repository identity and context-owned storage registration over one entity constructor and state schema.
314
+ * Configures storage and handlers for one Entity class.
211
315
  *
212
- * The class records the ownership facts bounded-context registration needs for
213
- * duplicate and conflict checks. Context assembly uses this metadata to attach
214
- * a repository to one built context and open state record storage. With
215
- * authentic explicit aggregate handler metadata, the built context can also
216
- * execute aggregate commands through repository-owned assignees and live
217
- * direct transactional handlers, persist the latest aggregate state plus a diagnostic event journal,
218
- * and hand already-stored events to the event bus. Aggregate and process-manager command
219
- * execution require `command.id` before routing or mutation so produced events
220
- * can carry a contract-valid command origin. With authentic projection
221
- * subscriber metadata, built contexts can also execute projection subscribers
222
- * and write changed projection state through the context-owned `Stand`. With
223
- * authentic process-manager metadata, built contexts can execute command
224
- * assignees, event reactors, and event-commanding handlers, storing changed
225
- * process-manager state through tenant-scoped Stand records with numeric
226
- * versions. The `events` option declares generated event schemas emitted by
227
- * aggregate and process-manager producer handlers. The repository surface still
228
- * does not expose direct entity lookup/storage APIs, inbox/delivery management,
229
- * caches, lifecycle monitors, or transport startup.
316
+ * Construction selects the Entity class, state schema, routing, and optional
317
+ * creation callback. A Bounded Context builder registers the repository. During
318
+ * context assembly, it opens record storage and installs handlers and Inbox
319
+ * targets. Aggregate handlers store state and a diagnostic event journal;
320
+ * Projection and Process Manager handlers store state in Stand. The `events`
321
+ * option lists generated event schemas that handlers may emit.
230
322
  *
231
- * @typeParam EntityType - A single concrete aggregate, projection, or process-manager constructor
232
- * with one concrete generated state schema. Broad constructor, constructor-union, broad-schema, and
233
- * schema-union bindings intentionally fail the public type constraint.
323
+ * @typeParam EntityType One concrete Aggregate, Projection, or Process Manager
324
+ * class with one generated state schema.
234
325
  */
235
326
  export declare class Repository<EntityType extends RepositoryEntityType & ConcreteRepositoryEntityType<EntityType>> implements RepositoryView {
236
327
  #private;
@@ -241,9 +332,9 @@ export declare class Repository<EntityType extends RepositoryEntityType & Concre
241
332
  */
242
333
  constructor(options: RepositoryOptions<EntityType>);
243
334
  /**
244
- * Returns the entity constructor owned by this repository identity.
335
+ * Returns the Entity class registered with this repository.
245
336
  *
246
- * @returns The owned entity constructor.
337
+ * @returns The registered Entity class.
247
338
  */
248
339
  get entityType(): EntityType;
249
340
  /**
@@ -255,7 +346,7 @@ export declare class Repository<EntityType extends RepositoryEntityType & Concre
255
346
  /**
256
347
  * Returns the generated schema for this repository's entity state.
257
348
  *
258
- * @returns The owned state schema.
349
+ * @returns The Entity state schema.
259
350
  */
260
351
  get stateSchema(): RepositoryStateSchema<EntityType>;
261
352
  /**
@@ -268,13 +359,13 @@ export declare class Repository<EntityType extends RepositoryEntityType & Concre
268
359
  */
269
360
  setStateHistoryEnabled(enabled: boolean): void;
270
361
  /**
271
- * Returns descriptor-derived metadata for the owned entity state.
362
+ * Returns descriptor metadata for this repository's Entity state.
272
363
  *
273
- * @returns A metadata view for the owned state.
364
+ * @returns Descriptor metadata for the Entity state.
274
365
  */
275
366
  get metadata(): EntityMetadata<RepositoryStateSchema<EntityType>>;
276
367
  /**
277
- * Returns the fully qualified Protobuf name of the owned entity state.
368
+ * Returns the fully qualified Protobuf name of the Entity state.
278
369
  *
279
370
  * @returns The state message type name.
280
371
  */
@@ -297,7 +388,7 @@ export declare class Repository<EntityType extends RepositoryEntityType & Concre
297
388
  * @param command The command envelope to route.
298
389
  * @returns The calculated command route.
299
390
  */
300
- routeCommand(command: Command): RepositoryCommandRoute<RepositoryEntityId<EntityType>>;
391
+ routeCommand(command: Command): Promise<RepositoryCommandRoute<RepositoryEntityId<EntityType>>>;
301
392
  /**
302
393
  * Routes an Event without invoking a handler.
303
394
  *
@@ -310,7 +401,7 @@ export declare class Repository<EntityType extends RepositoryEntityType & Concre
310
401
  * @param event The event envelope to route.
311
402
  * @returns The calculated event route.
312
403
  */
313
- routeEvent(event: Event): RepositoryEventRoute<RepositoryEntityId<EntityType>>;
404
+ routeEvent(event: Event): Promise<RepositoryEventRoute<RepositoryEntityId<EntityType>>>;
314
405
  }
315
406
  /**
316
407
  * Route-only invocation marker returned by direct repository routing APIs.
@@ -321,6 +412,8 @@ export declare class Repository<EntityType extends RepositoryEntityType & Concre
321
412
  export type RepositoryRouteInvocation = "deferred";
322
413
  /**
323
414
  * Command route calculated by a repository.
415
+ *
416
+ * @typeParam Id Target Entity identifier type.
324
417
  */
325
418
  export interface RepositoryCommandRoute<Id = unknown> {
326
419
  /**
@@ -338,6 +431,8 @@ export interface RepositoryCommandRoute<Id = unknown> {
338
431
  }
339
432
  /**
340
433
  * Event route calculated by a repository.
434
+ *
435
+ * @typeParam Id Target Entity identifier type.
341
436
  */
342
437
  export interface RepositoryEventRoute<Id = unknown> {
343
438
  /**
@@ -356,6 +451,7 @@ export interface RepositoryEventRoute<Id = unknown> {
356
451
  /**
357
452
  * Route calculated for one unpacked Entity state update.
358
453
  *
454
+ * @typeParam Id Target Projection identifier type.
359
455
  * @internal Framework delivery metadata.
360
456
  */
361
457
  interface RepositoryStateUpdateRoute<Id = unknown> extends RepositoryEventRoute<Id> {
@@ -400,13 +496,13 @@ export interface EntityInboxTarget {
400
496
  replay(message: EntityInboxMessage, deliveryTenantId?: TenantId): EntityInboxReplay;
401
497
  }
402
498
  /**
403
- * Defines context-owned Entity Inbox handoff operations.
499
+ * Operations the Bounded Context uses to deliver Entity Inbox messages.
404
500
  *
405
501
  * @internal
406
502
  */
407
503
  export interface EntityInbox {
408
504
  /**
409
- * Returns the context-owned target-to-shard strategy.
505
+ * Returns the strategy that maps Entity Inbox targets to shards.
410
506
  *
411
507
  * @returns The immutable delivery strategy.
412
508
  */
@@ -470,7 +566,7 @@ export interface ProjectionInboxTarget {
470
566
  replay(message: ProjectionInboxMessage, deliveryTenantId?: TenantId): Promise<void>;
471
567
  }
472
568
  /**
473
- * Defines context-owned projection subscriber inbox handoff operations.
569
+ * Operations the Bounded Context uses to deliver Projection Inbox messages.
474
570
  *
475
571
  * @internal
476
572
  */
@@ -555,7 +651,7 @@ export interface RepositoryAccess {
555
651
  * @param event The Entity state-change System event.
556
652
  * @returns The calculated route, or `undefined` for an unrelated state.
557
653
  */
558
- routeStateUpdate(repository: RepositoryView, event: Event): RepositoryStateUpdateRoute | undefined;
654
+ routeStateUpdate(repository: RepositoryView, event: Event): Promise<RepositoryStateUpdateRoute | undefined>;
559
655
  /**
560
656
  * Returns the Entity Inbox target configured for a repository.
561
657
  *
@@ -606,39 +702,173 @@ interface RepositoryRuntime {
606
702
  readonly signalMetadata: SignalMetadata;
607
703
  readonly entityInbox: EntityInbox;
608
704
  readonly projectionInbox: ProjectionInbox;
609
- readonly dispatchStored: (event: Event) => Promise<void>;
610
- readonly dispatchStoredFollowUp: (event: Event) => Promise<void>;
611
- readonly postEventFollowUp: (event: Event) => Promise<void>;
705
+ readonly publisher: SignalPublisher;
612
706
  readonly registerEventSchema: (schema: MessageSchema) => void;
613
- readonly postSystemFollowUp: (event: Event) => Promise<void>;
614
707
  readonly registerSystemEventSchema: (schema: MessageSchema) => void;
615
- readonly onPostCommand: (command: Command) => Promise<void>;
616
- readonly recordDispatchFailure: (event: Event, error: unknown) => void;
617
708
  }
618
709
  type RepositoryHandlersOption = EntityHandlersMetadata | readonly EntityHandlersMetadata[] | undefined;
619
710
  type RepositoryStateSubscribers = readonly RegisteredHandlerMetadata<StateSubscriptionHandlerMetadata>[];
711
+ /**
712
+ * Binds repository queries to a single routing invocation's tenant and lifetime.
713
+ * Routing integration closes the returned access after its callback settles.
714
+ *
715
+ * @internal
716
+ */
717
+ export declare const repositoryReadAccess: Readonly<{
718
+ /**
719
+ * Binds one repository and incoming signal tenant to a read-only scope.
720
+ *
721
+ * @typeParam EntityType Registered application Entity class.
722
+ * @param repository Receiving repository with an active runtime.
723
+ * @param tenantId Signal tenant for a multitenant context.
724
+ * @returns Read methods and the invocation close operation.
725
+ */
726
+ bind<EntityType extends RepositoryEntityType>(repository: RepositoryView & {
727
+ readonly entityType: EntityType;
728
+ }, tenantId?: TenantId): RepositoryReadQueries<EntityType> & {
729
+ close(): void;
730
+ };
731
+ }>;
732
+ /**
733
+ * Internal repository stand operations.
734
+ * @internal
735
+ */
736
+ export declare const RepositoryStand: {
737
+ /**
738
+ * Returns the validated Stand snapshot with the authoritative routed ID.
739
+ *
740
+ * @param repository Supplies the state schema and validated ID descriptor.
741
+ * @param deferred Contains the prepared Stand record.
742
+ * @param entityId Authoritative routed Entity identifier.
743
+ * @returns An isolated prepared record with the authoritative packed ID.
744
+ */
745
+ preparedRecord(repository: RepositoryView, deferred: Awaited<ReturnType<typeof standAccess.deferUpdate>>, entityId: unknown): EntityRecord;
746
+ /**
747
+ * Builds tenant, Version, and lifecycle options for a Stand update.
748
+ *
749
+ * @param tenantId Tenant receiving the update, when present.
750
+ * @param version Committed Spine Version, when present.
751
+ * @param lifecycle Accepted archived and deleted flags.
752
+ * @returns Frozen Stand update options.
753
+ */
754
+ standUpdateOptions(tenantId: TenantId | undefined, version: Version | undefined, lifecycle: {
755
+ readonly archived: boolean;
756
+ readonly deleted: boolean;
757
+ }): {
758
+ readonly tenantId?: TenantId;
759
+ readonly version?: Version;
760
+ readonly lifecycle: {
761
+ readonly archived: boolean;
762
+ readonly deleted: boolean;
763
+ };
764
+ };
765
+ };
620
766
  /**
621
767
  * Internal repository handlers operations.
622
768
  */
623
769
  declare const RepositoryHandlers: {
770
+ /**
771
+ * Rejects outputs not declared by the invoked handler, even if a sibling declares them.
772
+ *
773
+ * @param handler Invoked handler declaration.
774
+ * @param signals Returned domain messages to validate.
775
+ */
776
+ requireDeclaredOutputs(handler: HandlerMetadata, signals: readonly unknown[]): void;
777
+ /**
778
+ * Normalizes one or many handler metadata blocks to a frozen list.
779
+ *
780
+ * @param handlersOption Configured handler metadata.
781
+ * @returns Frozen handler metadata list.
782
+ */
624
783
  normalizeHandlers(handlersOption: RepositoryHandlersOption): readonly EntityHandlersMetadata[];
784
+ /**
785
+ * Groups Event-to-Command reactions by source Event type.
786
+ *
787
+ * @param handlers Entity handler metadata blocks.
788
+ * @returns Reactions indexed by Event type name.
789
+ */
625
790
  createCommandReactionMap(handlers: readonly EntityHandlersMetadata[]): ReadonlyMap<string, readonly RegisteredHandlerMetadata<CommandReactionHandlerMetadata>[]>;
791
+ /**
792
+ * Builds Event field filters for handlers grouped by Event type.
793
+ *
794
+ * @typeParam Value Handler registration carrying schema and filter metadata.
795
+ * @param byEvent Handler registrations indexed by Event type.
796
+ * @param stringifiers Field conversion registry for message-valued filters.
797
+ * @returns Compiled filter plans by Event type.
798
+ */
626
799
  createEventFilterPlans<Value extends {
627
800
  readonly handler: {
628
801
  readonly schema: DescriptorMessageSchema;
629
802
  readonly where?: WhereOptions;
630
803
  };
631
804
  }>(byEvent: ReadonlyMap<string, readonly Value[]>, stringifiers: StringifierRegistry): ReadonlyMap<string, EventHandlerFilterPlan<Value>>;
805
+ /**
806
+ * Finds handlers for domestic or external Event origin.
807
+ *
808
+ * @typeParam Value Handler registration with origin metadata.
809
+ * @param values Candidate handler registrations.
810
+ * @param external Whether the source Event is external.
811
+ * @returns Frozen matching registration list.
812
+ */
632
813
  forOrigin<Value extends {
633
814
  readonly handler: {
634
815
  readonly origin: "domestic" | "external";
635
816
  };
636
817
  }>(values: readonly Value[], external: boolean): readonly Value[];
818
+ /**
819
+ * Maps readiness-selected handlers by registered message type.
820
+ *
821
+ * @typeParam Value Handler registration returned by readiness lookup.
822
+ * @param schemas Registered message schemas.
823
+ * @param find Selects handlers for one type name.
824
+ * @returns Handler lists indexed by message type name.
825
+ */
637
826
  readinessMap<Value>(schemas: readonly MessageSchema[], find: (typeName: string) => readonly Value[]): ReadonlyMap<string, readonly Value[]>;
638
- handlerEmittedSchemas(handler: CommandAssignmentHandlerMetadata | CommandReactionHandlerMetadata | EventReactionHandlerMetadata): readonly DescriptorMessageSchema[];
827
+ /**
828
+ * Reads the declared output schemas for one handler.
829
+ *
830
+ * @param handler Command or Event handler declaration.
831
+ * @returns Generated schemas the handler may emit.
832
+ */
833
+ handlerEmittedSchemas(handler: CommandAssignmentHandlerMetadata | import("../handler/handler-metadata.js").CommandSubstitutionHandlerMetadata | CommandReactionHandlerMetadata | EventReactionHandlerMetadata): readonly DescriptorMessageSchema[];
834
+ /**
835
+ * Reads the declared rejection schemas for a Command handler.
836
+ *
837
+ * @param handler Assignment or substitution declaration.
838
+ * @returns Generated rejection schemas the handler may throw.
839
+ */
840
+ handlerThrownSchemas(handler: CommandAssignmentHandlerMetadata | import("../handler/handler-metadata.js").CommandSubstitutionHandlerMetadata): readonly DescriptorMessageSchema[];
841
+ /**
842
+ * Checks whether handler metadata was supplied as a list.
843
+ *
844
+ * @param value Configured handler metadata.
845
+ * @returns Whether it is a handler list.
846
+ */
639
847
  isHandlersArray(value: RepositoryHandlersOption): value is readonly EntityHandlersMetadata[];
848
+ /**
849
+ * Validates handler metadata against the Entity constructor and family.
850
+ *
851
+ * @param entityType Repository Entity constructor.
852
+ * @param metadata Descriptor-derived state metadata.
853
+ * @param handlers Handler metadata blocks to validate.
854
+ */
640
855
  validateHandlers(entityType: RepositoryEntityType, metadata: EntityMetadata, handlers: readonly EntityHandlersMetadata[]): void;
856
+ /**
857
+ * Returns unique generated schemas by type URL.
858
+ *
859
+ * @param schemas Candidate message schemas.
860
+ * @returns Frozen list retaining the last schema for each type URL.
861
+ */
641
862
  uniqueSchemas(schemas: readonly MessageSchema[]): readonly MessageSchema[];
863
+ /**
864
+ * Adds a value to a map entry, creating its list when absent.
865
+ *
866
+ * @typeParam Key Map key type.
867
+ * @typeParam Value Map value type.
868
+ * @param map Mutable map of value lists.
869
+ * @param key Entry key to update.
870
+ * @param value Value to append.
871
+ */
642
872
  pushMapValue<Key, Value>(map: Map<Key, Value[]>, key: Key, value: Value): void;
643
873
  };
644
874
  /**
@@ -648,14 +878,14 @@ declare const repositoryHistory: {
648
878
  /**
649
879
  * Creates a cache that extends a repository history only when a caller requests more entries.
650
880
  *
651
- * @typeParam Entry - The history entry type.
881
+ * @typeParam Entry The history entry type.
652
882
  * @param load Loads entries before an optional continuation version.
653
883
  * @param versionOf Reads the optional version carried by an entry.
654
- * @param options Selects contiguous-version and complete-group behavior.
884
+ * @param options Selects strictly descending-version and complete-group behavior.
655
885
  * @returns A cache with read and clear operations.
656
886
  */
657
887
  createCache<Entry>(load: (depth: number, startingFromVersion?: bigint) => Promise<readonly Entry[]>, versionOf: (entry: Entry) => bigint | undefined, options?: {
658
- readonly requireContiguousVersions?: boolean;
888
+ readonly requireDescendingVersions?: boolean;
659
889
  readonly cacheCompleteVersionGroups?: boolean;
660
890
  }): {
661
891
  readonly read: (depth: number) => Promise<readonly Entry[]>;