@spine-event-engine/server 2.0.0-snapshot.2 → 2.0.0-snapshot.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +225 -518
- package/REFERENCE.md +498 -49
- package/dist/browser/browser-server.d.ts +95 -0
- package/dist/browser/browser-server.d.ts.map +1 -0
- package/dist/{server → browser}/browser-server.js +93 -7
- package/dist/browser/browser-server.js.map +1 -0
- package/dist/browser/durable-subscription-bindings.d.ts.map +1 -0
- package/dist/browser/durable-subscription-bindings.js.map +1 -0
- package/dist/browser/index.d.ts +12 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +24 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/options.d.ts +183 -0
- package/dist/browser/options.d.ts.map +1 -0
- package/dist/browser/options.js +15 -0
- package/dist/browser/options.js.map +1 -0
- package/dist/bus/command-bus.d.ts +2 -0
- package/dist/bus/command-bus.d.ts.map +1 -1
- package/dist/bus/command-bus.js +36 -1
- package/dist/bus/command-bus.js.map +1 -1
- package/dist/bus/event-dispatcher-registry.d.ts +2 -2
- package/dist/bus/event-dispatcher-registry.js +3 -3
- package/dist/bus/event-dispatcher-registry.js.map +1 -1
- package/dist/context/bounded-context.d.ts +238 -83
- package/dist/context/bounded-context.d.ts.map +1 -1
- package/dist/context/bounded-context.js +1083 -286
- package/dist/context/bounded-context.js.map +1 -1
- package/dist/context/effective-tenant.d.ts +9 -0
- package/dist/context/effective-tenant.d.ts.map +1 -0
- package/dist/context/effective-tenant.js +58 -0
- package/dist/context/effective-tenant.js.map +1 -0
- package/dist/context/entity-inbox.d.ts.map +1 -1
- package/dist/context/entity-inbox.js +24 -17
- package/dist/context/entity-inbox.js.map +1 -1
- package/dist/context/local-inbox-handoff.d.ts +7 -3
- package/dist/context/local-inbox-handoff.d.ts.map +1 -1
- package/dist/context/local-inbox-handoff.js +32 -26
- package/dist/context/local-inbox-handoff.js.map +1 -1
- package/dist/context/projection-handoff.d.ts.map +1 -1
- package/dist/context/projection-handoff.js +36 -31
- package/dist/context/projection-handoff.js.map +1 -1
- package/dist/context/tenant-index.d.ts.map +1 -1
- package/dist/context/tenant-index.js +72 -2
- package/dist/context/tenant-index.js.map +1 -1
- package/dist/delivery/delivery-ports.d.ts +14 -4
- package/dist/delivery/delivery-ports.d.ts.map +1 -1
- package/dist/delivery/delivery.d.ts +19 -21
- package/dist/delivery/delivery.d.ts.map +1 -1
- package/dist/delivery/delivery.js +541 -158
- package/dist/delivery/delivery.js.map +1 -1
- package/dist/delivery/inbox-storage.d.ts +12 -3
- package/dist/delivery/inbox-storage.d.ts.map +1 -1
- package/dist/delivery/inbox-storage.js +160 -67
- package/dist/delivery/inbox-storage.js.map +1 -1
- package/dist/delivery/inbox.d.ts +9 -0
- package/dist/delivery/inbox.d.ts.map +1 -1
- package/dist/delivery/inbox.js +11 -0
- package/dist/delivery/inbox.js.map +1 -1
- package/dist/delivery/sharded-work-registry.d.ts.map +1 -1
- package/dist/delivery/sharded-work-registry.js +2 -1
- package/dist/delivery/sharded-work-registry.js.map +1 -1
- package/dist/entity/entity-metadata.d.ts +14 -5
- package/dist/entity/entity-metadata.d.ts.map +1 -1
- package/dist/entity/entity-metadata.js +38 -2
- package/dist/entity/entity-metadata.js.map +1 -1
- package/dist/entity/entity-storage-descriptor.d.ts +25 -5
- package/dist/entity/entity-storage-descriptor.d.ts.map +1 -1
- package/dist/entity/entity-storage-descriptor.js +69 -23
- package/dist/entity/entity-storage-descriptor.js.map +1 -1
- package/dist/entity/entity-transaction.d.ts +46 -42
- package/dist/entity/entity-transaction.d.ts.map +1 -1
- package/dist/entity/entity-transaction.js +130 -35
- package/dist/entity/entity-transaction.js.map +1 -1
- package/dist/entity/entity.d.ts +243 -98
- package/dist/entity/entity.d.ts.map +1 -1
- package/dist/entity/entity.js +405 -226
- package/dist/entity/entity.js.map +1 -1
- package/dist/entity/spec-scanner.d.ts +13 -1
- package/dist/entity/spec-scanner.d.ts.map +1 -1
- package/dist/entity/spec-scanner.js +20 -3
- package/dist/entity/spec-scanner.js.map +1 -1
- package/dist/handler/command-registration-readiness.d.ts +6 -6
- package/dist/handler/command-registration-readiness.d.ts.map +1 -1
- package/dist/handler/command-registration-readiness.js +4 -2
- package/dist/handler/command-registration-readiness.js.map +1 -1
- package/dist/handler/declared-rejections.d.ts +11 -0
- package/dist/handler/declared-rejections.d.ts.map +1 -0
- package/dist/handler/declared-rejections.js +34 -0
- package/dist/handler/declared-rejections.js.map +1 -0
- package/dist/handler/event-registration-readiness.d.ts +13 -56
- package/dist/handler/event-registration-readiness.d.ts.map +1 -1
- package/dist/handler/event-registration-readiness.js +23 -43
- package/dist/handler/event-registration-readiness.js.map +1 -1
- package/dist/handler/generated-handler-registry.d.ts +72 -33
- package/dist/handler/generated-handler-registry.d.ts.map +1 -1
- package/dist/handler/generated-handler-registry.js +421 -43
- package/dist/handler/generated-handler-registry.js.map +1 -1
- package/dist/handler/generated-registry-discovery.d.ts.map +1 -1
- package/dist/handler/generated-registry-discovery.js +2 -4
- package/dist/handler/generated-registry-discovery.js.map +1 -1
- package/dist/handler/handler-decorators.d.ts +91 -37
- package/dist/handler/handler-decorators.d.ts.map +1 -1
- package/dist/handler/handler-decorators.js +124 -31
- package/dist/handler/handler-decorators.js.map +1 -1
- package/dist/handler/handler-metadata.d.ts +105 -60
- package/dist/handler/handler-metadata.d.ts.map +1 -1
- package/dist/handler/handler-metadata.js +275 -57
- package/dist/handler/handler-metadata.js.map +1 -1
- package/dist/handler/registration-readiness-metadata.d.ts +4 -0
- package/dist/handler/registration-readiness-metadata.d.ts.map +1 -1
- package/dist/handler/registration-readiness-metadata.js +84 -2
- package/dist/handler/registration-readiness-metadata.js.map +1 -1
- package/dist/handler/standalone.d.ts +25 -0
- package/dist/handler/standalone.d.ts.map +1 -0
- package/dist/handler/standalone.js +38 -0
- package/dist/handler/standalone.js.map +1 -0
- package/dist/index.d.ts +9 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/repository/command-routing.d.ts +63 -10
- package/dist/repository/command-routing.d.ts.map +1 -1
- package/dist/repository/command-routing.js +41 -8
- package/dist/repository/command-routing.js.map +1 -1
- package/dist/repository/event-routing.d.ts +64 -9
- package/dist/repository/event-routing.d.ts.map +1 -1
- package/dist/repository/event-routing.js +42 -7
- package/dist/repository/event-routing.js.map +1 -1
- package/dist/repository/primitive-id.d.ts +12 -23
- package/dist/repository/primitive-id.d.ts.map +1 -1
- package/dist/repository/primitive-id.js +2 -27
- package/dist/repository/primitive-id.js.map +1 -1
- package/dist/repository/repository.d.ts +317 -87
- package/dist/repository/repository.d.ts.map +1 -1
- package/dist/repository/repository.js +3746 -856
- package/dist/repository/repository.js.map +1 -1
- package/dist/repository/state-update-routing.d.ts +67 -8
- package/dist/repository/state-update-routing.d.ts.map +1 -1
- package/dist/repository/state-update-routing.js +45 -6
- package/dist/repository/state-update-routing.js.map +1 -1
- package/dist/runtime/runtime.js +1 -1
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/signal-metadata.d.ts +22 -47
- package/dist/runtime/signal-metadata.d.ts.map +1 -1
- package/dist/runtime/signal-metadata.js +34 -69
- package/dist/runtime/signal-metadata.js.map +1 -1
- package/dist/runtime/signal-publisher.d.ts +144 -0
- package/dist/runtime/signal-publisher.d.ts.map +1 -0
- package/dist/runtime/signal-publisher.js +248 -0
- package/dist/runtime/signal-publisher.js.map +1 -0
- package/dist/runtime/standalone-handler-runtime.d.ts +130 -0
- package/dist/runtime/standalone-handler-runtime.d.ts.map +1 -0
- package/dist/runtime/standalone-handler-runtime.js +382 -0
- package/dist/runtime/standalone-handler-runtime.js.map +1 -0
- package/dist/server/environment-attachment.d.ts.map +1 -1
- package/dist/server/environment-attachment.js +2 -1
- package/dist/server/environment-attachment.js.map +1 -1
- package/dist/server/environment-delivery-worker.d.ts.map +1 -1
- package/dist/server/environment-delivery-worker.js +21 -12
- package/dist/server/environment-delivery-worker.js.map +1 -1
- package/dist/server/managed-server-application.d.ts +4 -1
- package/dist/server/managed-server-application.d.ts.map +1 -1
- package/dist/server/managed-server-application.js +2 -2
- package/dist/server/managed-server-application.js.map +1 -1
- package/dist/server/node-coordinator.js +2 -2
- package/dist/server/node-coordinator.js.map +1 -1
- package/dist/server/server-log.d.ts.map +1 -1
- package/dist/server/server-log.js +4 -0
- package/dist/server/server-log.js.map +1 -1
- package/dist/server/server.d.ts +9 -177
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +428 -178
- package/dist/server/server.js.map +1 -1
- package/dist/services/query-reader.d.ts +19 -0
- package/dist/services/query-reader.d.ts.map +1 -0
- package/dist/services/query-reader.js +43 -0
- package/dist/services/query-reader.js.map +1 -0
- package/dist/services/registered-targets.d.ts +73 -0
- package/dist/services/registered-targets.d.ts.map +1 -0
- package/dist/services/registered-targets.js +127 -0
- package/dist/services/registered-targets.js.map +1 -0
- package/dist/services/spine-services.d.ts +26 -12
- package/dist/services/spine-services.d.ts.map +1 -1
- package/dist/services/spine-services.js +1047 -969
- package/dist/services/spine-services.js.map +1 -1
- package/dist/spi/delivery.d.ts +5 -0
- package/dist/spi/delivery.d.ts.map +1 -0
- package/dist/spi/delivery.js +18 -0
- package/dist/spi/delivery.js.map +1 -0
- package/dist/spi/handler-registry.d.ts +8 -0
- package/dist/spi/handler-registry.d.ts.map +1 -0
- package/dist/spi/handler-registry.js +15 -0
- package/dist/spi/handler-registry.js.map +1 -0
- package/dist/stand/stand.d.ts +73 -1
- package/dist/stand/stand.d.ts.map +1 -1
- package/dist/stand/stand.js +221 -48
- package/dist/stand/stand.js.map +1 -1
- package/dist/stand/subscription-observer.d.ts.map +1 -1
- package/dist/stand/subscription-observer.js +5 -12
- package/dist/stand/subscription-observer.js.map +1 -1
- package/dist/stand/subscription-registry.js +1 -1
- package/dist/stand/subscription-registry.js.map +1 -1
- package/dist/testing/index.d.ts +25 -3
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +23 -3
- package/dist/testing/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +33 -23
- package/dist/handler/build-time-handler-analyzer.d.ts +0 -150
- package/dist/handler/build-time-handler-analyzer.d.ts.map +0 -1
- package/dist/handler/build-time-handler-analyzer.js +0 -1101
- package/dist/handler/build-time-handler-analyzer.js.map +0 -1
- package/dist/handler/generated-registry-writer.d.ts +0 -58
- package/dist/handler/generated-registry-writer.d.ts.map +0 -1
- package/dist/handler/generated-registry-writer.js +0 -458
- package/dist/handler/generated-registry-writer.js.map +0 -1
- package/dist/handler/handler-codegen.d.ts +0 -48
- package/dist/handler/handler-codegen.d.ts.map +0 -1
- package/dist/handler/handler-codegen.js +0 -214
- package/dist/handler/handler-codegen.js.map +0 -1
- package/dist/server/browser-server.d.ts +0 -49
- package/dist/server/browser-server.d.ts.map +0 -1
- package/dist/server/browser-server.js.map +0 -1
- package/dist/server/durable-subscription-bindings.d.ts.map +0 -1
- package/dist/server/durable-subscription-bindings.js.map +0 -1
- /package/dist/{server → browser}/durable-subscription-bindings.d.ts +0 -0
- /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
|
|
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
|
-
*
|
|
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
|
-
|
|
26
|
-
|
|
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
|
-
*
|
|
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
|
|
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
|
|
104
|
+
* Describes an Aggregate, Projection, or Process Manager class accepted by a repository.
|
|
38
105
|
*
|
|
39
|
-
* @typeParam Instance
|
|
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) &
|
|
110
|
+
export type RepositoryEntityType<Instance extends RepositoryEntityInstance = RepositoryEntityInstance> = (abstract new (...args: never[]) => Instance) & {
|
|
44
111
|
/**
|
|
45
|
-
* Prototype
|
|
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
|
-
*
|
|
121
|
+
* Entity class, state schema, and routing options for a repository.
|
|
55
122
|
*
|
|
56
|
-
* @typeParam EntityType
|
|
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
|
-
|
|
127
|
+
interface RepositoryOptionsBase<EntityType extends RepositoryEntityType & ConcreteRepositoryEntityType<EntityType>> {
|
|
61
128
|
/**
|
|
62
|
-
* Entity
|
|
129
|
+
* Entity class constructed by this repository.
|
|
63
130
|
*/
|
|
64
131
|
readonly entityType: EntityType;
|
|
65
132
|
/**
|
|
66
|
-
* Generated
|
|
133
|
+
* Generated schema for this repository's Entity state.
|
|
67
134
|
*/
|
|
68
135
|
readonly schema: RepositoryStateSchema<EntityType>;
|
|
69
136
|
/**
|
|
70
|
-
*
|
|
137
|
+
* Constructs each new or restored Entity with application dependencies.
|
|
71
138
|
*
|
|
72
|
-
*
|
|
73
|
-
* must
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
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
|
|
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
|
|
236
|
+
* Entity class registered with the repository.
|
|
133
237
|
*/
|
|
134
238
|
readonly entityType: EntityType;
|
|
135
239
|
/**
|
|
136
|
-
*
|
|
240
|
+
* Aggregate, Projection, or Process Manager family of the Entity class.
|
|
137
241
|
*/
|
|
138
242
|
readonly entityFamily: EntityFamily;
|
|
139
243
|
/**
|
|
140
|
-
* Generated
|
|
244
|
+
* Generated schema for the Entity state.
|
|
141
245
|
*/
|
|
142
246
|
readonly stateSchema: RepositoryStateSchema<EntityType>;
|
|
143
247
|
/**
|
|
144
|
-
* Descriptor
|
|
248
|
+
* Descriptor metadata for the Entity state.
|
|
145
249
|
*/
|
|
146
250
|
readonly metadata: EntityMetadata<RepositoryStateSchema<EntityType>>;
|
|
147
251
|
/**
|
|
148
|
-
* Fully qualified Protobuf
|
|
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
|
|
265
|
+
* Entity class registered with the repository.
|
|
162
266
|
*/
|
|
163
267
|
readonly entityType: RepositoryEntityType;
|
|
164
268
|
/**
|
|
165
|
-
*
|
|
269
|
+
* Aggregate, Projection, or Process Manager family of the Entity class.
|
|
166
270
|
*/
|
|
167
271
|
readonly entityFamily: EntityFamily;
|
|
168
272
|
/**
|
|
169
|
-
* Generated
|
|
273
|
+
* Generated schema for the Entity state.
|
|
170
274
|
*/
|
|
171
275
|
readonly stateSchema: DescriptorMessageSchema;
|
|
172
276
|
/**
|
|
173
|
-
* Descriptor
|
|
277
|
+
* Descriptor metadata for the Entity state.
|
|
174
278
|
*/
|
|
175
279
|
readonly metadata: EntityMetadata;
|
|
176
280
|
/**
|
|
177
|
-
* Fully qualified Protobuf
|
|
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
|
-
*
|
|
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
|
-
*
|
|
314
|
+
* Configures storage and handlers for one Entity class.
|
|
211
315
|
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
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
|
|
232
|
-
* with one
|
|
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
|
|
335
|
+
* Returns the Entity class registered with this repository.
|
|
245
336
|
*
|
|
246
|
-
* @returns The
|
|
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
|
|
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
|
|
362
|
+
* Returns descriptor metadata for this repository's Entity state.
|
|
272
363
|
*
|
|
273
|
-
* @returns
|
|
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
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
888
|
+
readonly requireDescendingVersions?: boolean;
|
|
659
889
|
readonly cacheCompleteVersionGroups?: boolean;
|
|
660
890
|
}): {
|
|
661
891
|
readonly read: (depth: number) => Promise<readonly Entry[]>;
|