@cratis/chronicle 6.7.1 → 6.9.0

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 (70) hide show
  1. package/EventStore.ts +10 -4
  2. package/README.md +14 -5
  3. package/dist/EventStore.d.ts +1 -0
  4. package/dist/EventStore.d.ts.map +1 -1
  5. package/dist/EventStore.js +7 -4
  6. package/dist/EventStore.js.map +1 -1
  7. package/dist/eventSequences/EventLog.d.ts +2 -1
  8. package/dist/eventSequences/EventLog.d.ts.map +1 -1
  9. package/dist/eventSequences/EventLog.js +2 -2
  10. package/dist/eventSequences/EventLog.js.map +1 -1
  11. package/dist/eventSequences/EventSequence.d.ts +3 -1
  12. package/dist/eventSequences/EventSequence.d.ts.map +1 -1
  13. package/dist/eventSequences/EventSequence.js +11 -6
  14. package/dist/eventSequences/EventSequence.js.map +1 -1
  15. package/dist/events/constraints/ConstraintBuilder.d.ts +2 -0
  16. package/dist/events/constraints/ConstraintBuilder.d.ts.map +1 -1
  17. package/dist/events/constraints/ConstraintBuilder.js.map +1 -1
  18. package/dist/events/constraints/Constraints.d.ts +8 -3
  19. package/dist/events/constraints/Constraints.d.ts.map +1 -1
  20. package/dist/events/constraints/Constraints.js +147 -6
  21. package/dist/events/constraints/Constraints.js.map +1 -1
  22. package/dist/events/constraints/index.d.ts +2 -0
  23. package/dist/events/constraints/index.d.ts.map +1 -1
  24. package/dist/events/constraints/index.js +2 -0
  25. package/dist/events/constraints/index.js.map +1 -1
  26. package/dist/events/constraints/removeConstraint.d.ts +11 -0
  27. package/dist/events/constraints/removeConstraint.d.ts.map +1 -0
  28. package/dist/events/constraints/removeConstraint.js +24 -0
  29. package/dist/events/constraints/removeConstraint.js.map +1 -0
  30. package/dist/events/constraints/unique.d.ts +21 -0
  31. package/dist/events/constraints/unique.d.ts.map +1 -0
  32. package/dist/events/constraints/unique.js +37 -0
  33. package/dist/events/constraints/unique.js.map +1 -0
  34. package/dist/reactors/Reactors.d.ts.map +1 -1
  35. package/dist/reactors/Reactors.js +64 -13
  36. package/dist/reactors/Reactors.js.map +1 -1
  37. package/dist/reactors/index.d.ts +2 -0
  38. package/dist/reactors/index.d.ts.map +1 -1
  39. package/dist/reactors/index.js +2 -0
  40. package/dist/reactors/index.js.map +1 -1
  41. package/dist/reactors/onceOnly.d.ts +11 -0
  42. package/dist/reactors/onceOnly.d.ts.map +1 -0
  43. package/dist/reactors/onceOnly.js +34 -0
  44. package/dist/reactors/onceOnly.js.map +1 -0
  45. package/dist/reactors/replay.d.ts +14 -0
  46. package/dist/reactors/replay.d.ts.map +1 -0
  47. package/dist/reactors/replay.js +33 -0
  48. package/dist/reactors/replay.js.map +1 -0
  49. package/dist/tsconfig.tsbuildinfo +1 -1
  50. package/eventSequences/EventLog.ts +4 -2
  51. package/eventSequences/EventSequence.ts +10 -6
  52. package/events/classDecorators.standard.spec.ts +45 -1
  53. package/events/constraints/ConstraintBuilder.ts +2 -0
  54. package/events/constraints/Constraints.ts +140 -7
  55. package/events/constraints/for_Constraints/when_combining_decorators_with_fluent_constraints.spec.ts +142 -0
  56. package/events/constraints/for_Constraints/when_inheriting_removal_decorators.legacy.spec.ts +36 -0
  57. package/events/constraints/for_Constraints/when_registering_decorated_constraints.spec.ts +63 -0
  58. package/events/constraints/for_Constraints/when_registering_decorated_event_types.spec.ts +90 -0
  59. package/events/constraints/for_Constraints/when_rejecting_incompatible_unique_merges.spec.ts +108 -0
  60. package/events/constraints/for_Constraints/when_resolving_violation_messages.spec.ts +92 -0
  61. package/events/constraints/index.ts +2 -0
  62. package/events/constraints/removeConstraint.ts +28 -0
  63. package/events/constraints/unique.ts +45 -0
  64. package/package.json +2 -2
  65. package/reactors/Reactors.replay.legacy.spec.ts +241 -0
  66. package/reactors/Reactors.ts +65 -14
  67. package/reactors/decorators.standard.spec.ts +39 -0
  68. package/reactors/index.ts +2 -0
  69. package/reactors/onceOnly.ts +34 -0
  70. package/reactors/replay.ts +36 -0
@@ -0,0 +1,34 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ import 'reflect-metadata';
4
+ const METADATA_KEY = 'chronicle:reactor:onceOnly';
5
+ /**
6
+ * Reactors replay by default. Excludes a whole reactor from replay, or skips one
7
+ * handler for replayed events. A class-level marker is not inherited by subclasses.
8
+ * This does not prevent ordinary redelivery after a failed partition is retried.
9
+ * @returns A class or method decorator for legacy and standard TypeScript decorators.
10
+ */
11
+ export function onceOnly() {
12
+ return (target, propertyOrContext, descriptor) => {
13
+ if (typeof propertyOrContext === 'object') {
14
+ if (propertyOrContext.kind !== 'class' && propertyOrContext.kind !== 'method') {
15
+ throw new TypeError('Once-only can only decorate a reactor class or method.');
16
+ }
17
+ Reflect.defineMetadata(METADATA_KEY, true, target);
18
+ }
19
+ else if (propertyOrContext === undefined) {
20
+ Reflect.defineMetadata(METADATA_KEY, true, target);
21
+ }
22
+ else if (descriptor?.value) {
23
+ Reflect.defineMetadata(METADATA_KEY, true, descriptor.value);
24
+ }
25
+ else {
26
+ throw new TypeError('Once-only can only decorate a reactor class or method.');
27
+ }
28
+ };
29
+ }
30
+ /** Whether this class or handler is marked as once-only (without inheriting the marker). */
31
+ export function isOnceOnly(target) {
32
+ return Reflect.getOwnMetadata(METADATA_KEY, target) === true;
33
+ }
34
+ //# sourceMappingURL=onceOnly.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"onceOnly.js","sourceRoot":"","sources":["../../reactors/onceOnly.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,kBAAkB,CAAC;AAE1B,MAAM,YAAY,GAAG,4BAA4B,CAAC;AAElD;;;;;GAKG;AACH,MAAM,UAAU,QAAQ;IACpB,OAAO,CAAC,MAAc,EAAE,iBAAyF,EAAE,UAA+B,EAAE,EAAE;QAClJ,IAAI,OAAO,iBAAiB,KAAK,QAAQ,EAAE,CAAC;YACxC,IAAI,iBAAiB,CAAC,IAAI,KAAK,OAAO,IAAI,iBAAiB,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC5E,MAAM,IAAI,SAAS,CAAC,wDAAwD,CAAC,CAAC;YAClF,CAAC;YACD,OAAO,CAAC,cAAc,CAAC,YAAY,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QACvD,CAAC;aAAM,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;YACzC,OAAO,CAAC,cAAc,CAAC,YAAY,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QACvD,CAAC;aAAM,IAAI,UAAU,EAAE,KAAK,EAAE,CAAC;YAC3B,OAAO,CAAC,cAAc,CAAC,YAAY,EAAE,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;QACjE,CAAC;aAAM,CAAC;YACJ,MAAM,IAAI,SAAS,CAAC,wDAAwD,CAAC,CAAC;QAClF,CAAC;IACL,CAAC,CAAC;AACN,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,UAAU,CAAC,MAAgB;IACvC,OAAO,OAAO,CAAC,cAAc,CAAC,YAAY,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;AACjE,CAAC"}
@@ -0,0 +1,14 @@
1
+ import 'reflect-metadata';
2
+ /**
3
+ * Marks a method as the alternative handler for an event during replay.
4
+ * Without an explicit event type, name the method `replay<EventClassName>`.
5
+ * The regular camelCase handler continues to handle live events, but this method replaces
6
+ * it during replay. Marking this replay handler with @onceOnly() means neither handler
7
+ * runs for replayed events.
8
+ * @param eventType - Optional event constructor for a differently named replay handler.
9
+ * @returns A method decorator for legacy and standard TypeScript decorators.
10
+ */
11
+ export declare function replay(eventType?: Function): MethodDecorator & ((value: Function, context: ClassMethodDecoratorContext) => void);
12
+ /** Gets the explicit event type, or the convention marker, for a replay handler. */
13
+ export declare function getReplayEventType(method: Function): Function | true | undefined;
14
+ //# sourceMappingURL=replay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../reactors/replay.ts"],"names":[],"mappings":"AAGA,OAAO,kBAAkB,CAAC;AAI1B;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,SAAS,CAAC,EAAE,QAAQ,GAAG,eAAe,GAAG,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,2BAA2B,KAAK,IAAI,CAAC,CAchI;AAED,oFAAoF;AACpF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,QAAQ,GAAG,QAAQ,GAAG,IAAI,GAAG,SAAS,CAEhF"}
@@ -0,0 +1,33 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ import 'reflect-metadata';
4
+ const METADATA_KEY = 'chronicle:reactor:replay';
5
+ /**
6
+ * Marks a method as the alternative handler for an event during replay.
7
+ * Without an explicit event type, name the method `replay<EventClassName>`.
8
+ * The regular camelCase handler continues to handle live events, but this method replaces
9
+ * it during replay. Marking this replay handler with @onceOnly() means neither handler
10
+ * runs for replayed events.
11
+ * @param eventType - Optional event constructor for a differently named replay handler.
12
+ * @returns A method decorator for legacy and standard TypeScript decorators.
13
+ */
14
+ export function replay(eventType) {
15
+ return (target, propertyOrContext, descriptor) => {
16
+ const method = typeof propertyOrContext === 'object' ? target : descriptor?.value;
17
+ if (typeof propertyOrContext === 'object' && (propertyOrContext.kind !== 'method' || propertyOrContext.static || propertyOrContext.private)) {
18
+ throw new TypeError('Replay requires a public instance method.');
19
+ }
20
+ if (typeof propertyOrContext !== 'object' && typeof target === 'function') {
21
+ throw new TypeError('Replay requires a public instance method.');
22
+ }
23
+ if (typeof method !== 'function') {
24
+ throw new TypeError('Replay requires a method.');
25
+ }
26
+ Reflect.defineMetadata(METADATA_KEY, eventType ?? true, method);
27
+ };
28
+ }
29
+ /** Gets the explicit event type, or the convention marker, for a replay handler. */
30
+ export function getReplayEventType(method) {
31
+ return Reflect.getOwnMetadata(METADATA_KEY, method);
32
+ }
33
+ //# sourceMappingURL=replay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay.js","sourceRoot":"","sources":["../../reactors/replay.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,kBAAkB,CAAC;AAE1B,MAAM,YAAY,GAAG,0BAA0B,CAAC;AAEhD;;;;;;;;GAQG;AACH,MAAM,UAAU,MAAM,CAAC,SAAoB;IACvC,OAAO,CAAC,MAAc,EAAE,iBAAgE,EAAE,UAA+B,EAAE,EAAE;QACzH,MAAM,MAAM,GAAG,OAAO,iBAAiB,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,EAAE,KAAK,CAAC;QAClF,IAAI,OAAO,iBAAiB,KAAK,QAAQ,IAAI,CAAC,iBAAiB,CAAC,IAAI,KAAK,QAAQ,IAAI,iBAAiB,CAAC,MAAM,IAAI,iBAAiB,CAAC,OAAO,CAAC,EAAE,CAAC;YAC1I,MAAM,IAAI,SAAS,CAAC,2CAA2C,CAAC,CAAC;QACrE,CAAC;QACD,IAAI,OAAO,iBAAiB,KAAK,QAAQ,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;YACxE,MAAM,IAAI,SAAS,CAAC,2CAA2C,CAAC,CAAC;QACrE,CAAC;QACD,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;YAC/B,MAAM,IAAI,SAAS,CAAC,2BAA2B,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,CAAC,cAAc,CAAC,YAAY,EAAE,SAAS,IAAI,IAAI,EAAE,MAAM,CAAC,CAAC;IACpE,CAAC,CAAC;AACN,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,kBAAkB,CAAC,MAAgB;IAC/C,OAAO,OAAO,CAAC,cAAc,CAAC,YAAY,EAAE,MAAM,CAAgC,CAAC;AACvF,CAAC"}
@@ -1 +1 @@
1
- {"version":"7.0.2","root":["../ChronicleClient.ts","../ChronicleOptions.ts","../EventStore.ts","../EventStoreName.ts","../EventStoreNamespaceName.ts","../IChronicleClient.ts","../IEventStore.ts","../Metrics.ts","../Tracing.ts","../index.ts","../artifacts/DefaultClientArtifactsProvider.ts","../artifacts/IClientArtifactsProvider.ts","../artifacts/index.ts","../artifacts/validateArtifactSchemas.ts","../auditing/Causation.ts","../auditing/CausationManager.ts","../auditing/CausationType.ts","../auditing/ICausationManager.ts","../auditing/index.ts","../compliance/ComplianceContracts.ts","../compliance/ComplianceMetadata.ts","../compliance/ComplianceMetadataResolver.ts","../compliance/ComplianceMetadataType.ts","../compliance/IPIIManager.ts","../compliance/PIIManager.ts","../compliance/PIINotSupportedOnEventSourceId.ts","../compliance/index.ts","../compliance/pii.ts","../compliance/subject.ts","../confidentiality/EncryptedNotSupportedOnEventSourceId.ts","../confidentiality/EncryptionScope.ts","../confidentiality/PIIAndEncryptedCombinedNotSupported.ts","../confidentiality/SecurityMetadata.ts","../confidentiality/SecurityMetadataResolver.ts","../confidentiality/SecurityMetadataType.ts","../confidentiality/encrypted.ts","../confidentiality/index.ts","../connection/ChronicleConnection.ts","../connection/ChronicleConnectionString.ts","../connection/ChronicleServerAddressResolver.ts","../connection/ChronicleServices.ts","../connection/ChronicleSrvResolutionError.ts","../connection/ChronicleSrvResolver.ts","../connection/CompatibilityPreflight.ts","../connection/ConnectionLifecycle.ts","../connection/DateTimeOffset.ts","../connection/Guid.ts","../connection/ILoadBalancerStrategy.ts","../connection/IncompatibleChronicleServer.ts","../connection/KernelKeepAlive.ts","../connection/LeastConnectionsLoadBalancerStrategy.ts","../connection/LoadBalancerMode.ts","../connection/LoadBalancerStrategyFactory.ts","../connection/RandomLoadBalancerStrategy.ts","../connection/RoundRobinLoadBalancerStrategy.ts","../connection/TokenProvider.ts","../connection/callResults.ts","../connection/fetchOAuthAccessToken.ts","../connection/formatServerAddress.ts","../connection/index.ts","../correlation/CorrelationId.ts","../correlation/CorrelationIdManager.ts","../correlation/ICorrelationIdAccessor.ts","../correlation/ICorrelationIdSetter.ts","../correlation/index.ts","../eventSequences/AppendError.ts","../eventSequences/AppendOperationsBroadcaster.ts","../eventSequences/AppendOptions.ts","../eventSequences/AppendResult.ts","../eventSequences/AppendedEventWithResult.ts","../eventSequences/CompleteStreamError.ts","../eventSequences/CompleteStreamResult.ts","../eventSequences/ConcurrencyScope.ts","../eventSequences/ConcurrencyViolation.ts","../eventSequences/ConstraintViolation.ts","../eventSequences/EventForEventSourceId.ts","../eventSequences/EventLog.ts","../eventSequences/EventSequence.ts","../eventSequences/EventSequenceId.ts","../eventSequences/EventSequenceNumber.ts","../eventSequences/IEventLog.ts","../eventSequences/IEventSequence.ts","../eventSequences/ITransactionalEventSequence.ts","../eventSequences/TransactionalEventSequence.ts","../eventSequences/WaitForCompletionResult.ts","../eventSequences/index.ts","../eventStoreSubscriptions/EventStoreSubscriptionBuilder.ts","../eventStoreSubscriptions/EventStoreSubscriptionDefinition.ts","../eventStoreSubscriptions/EventStoreSubscriptionId.ts","../eventStoreSubscriptions/EventStoreSubscriptions.ts","../eventStoreSubscriptions/IEventStoreSubscriptionBuilder.ts","../eventStoreSubscriptions/IEventStoreSubscriptions.ts","../eventStoreSubscriptions/contracts.ts","../eventStoreSubscriptions/index.ts","../events/AppendedEvent.ts","../events/CausationEntry.ts","../events/EventContext.ts","../events/EventType.ts","../events/EventTypeGeneration.ts","../events/EventTypeId.ts","../events/EventTypes.ts","../events/IEventTypes.ts","../events/Tag.ts","../events/WireEventContext.ts","../events/eventTypeDecorator.ts","../events/filterEventsByTagDecorator.ts","../events/index.ts","../events/isRegisteredEvent.ts","../events/mergeTags.ts","../events/tagDecorator.ts","../events/toClientEventContext.ts","../events/constraints/ConstraintBuilder.ts","../events/constraints/ConstraintId.ts","../events/constraints/Constraints.ts","../events/constraints/IConstraint.ts","../events/constraints/IConstraintBuilder.ts","../events/constraints/IConstraints.ts","../events/constraints/IUniqueConstraintBuilder.ts","../events/constraints/UniqueConstraintBuilder.ts","../events/constraints/constraint.ts","../events/constraints/index.ts","../events/migrations/EventMigrationBuilder.ts","../events/migrations/EventMigrationPropertyBuilder.ts","../events/migrations/EventTypeMigrators.ts","../events/migrations/IEventMigrationBuilder.ts","../events/migrations/IEventMigrationPropertyBuilder.ts","../events/migrations/IEventTypeMigration.ts","../events/migrations/IEventTypeMigrators.ts","../events/migrations/InvalidMigrationGenerationGap.ts","../events/migrations/eventTypeMigration.ts","../events/migrations/index.ts","../externalServices/ExternalServiceBuilder.ts","../externalServices/ExternalServices.ts","../externalServices/ExternalServicesContracts.ts","../externalServices/IExternalServiceBuilder.ts","../externalServices/IExternalServices.ts","../externalServices/index.ts","../identities/IIdentityManager.ts","../identities/IdentityManager.ts","../identities/index.ts","../identity/IIdentityProvider.ts","../identity/Identity.ts","../identity/IdentityProvider.ts","../identity/index.ts","../jobs/IJobs.ts","../jobs/JobId.ts","../jobs/Jobs.ts","../jobs/index.ts","../observation/FailedPartition.ts","../observation/FailedPartitionAttempt.ts","../observation/FailedPartitions.ts","../observation/ICanBeNotifiedWhenPartitionReplayed.ts","../observation/ICanBeNotifiedWhenReplay.ts","../observation/IFailedPartitions.ts","../observation/ObserverId.ts","../observation/ObserverRunningState.ts","../observation/index.ts","../observation/notifyReplayLifecycle.ts","../observation/toClientFailedPartition.ts","../observation/toObserverRunningState.ts","../projections/GlobalHandlerPropertyNotOnVariant.ts","../projections/IProjections.ts","../projections/ProjectionId.ts","../projections/ProjectionQueryResult.ts","../projections/ProjectionState.ts","../projections/Projections.ts","../projections/UnableToQueryProjection.ts","../projections/VariantMustDeclareEntersOnEvent.ts","../projections/VariantReclassifier.ts","../projections/index.ts","../projections/declarative/AddBuilder.ts","../projections/declarative/AddChildBuilder.ts","../projections/declarative/AllSetBuilder.ts","../projections/declarative/ChildrenBuilder.ts","../projections/declarative/CompositeKeyBuilder.ts","../projections/declarative/FromBuilder.ts","../projections/declarative/FromEveryBuilder.ts","../projections/declarative/IAddBuilder.ts","../projections/declarative/IAddChildBuilder.ts","../projections/declarative/IAllSetBuilder.ts","../projections/declarative/IChildrenBuilder.ts","../projections/declarative/ICompositeKeyBuilder.ts","../projections/declarative/IFromBuilder.ts","../projections/declarative/IFromEveryBuilder.ts","../projections/declarative/IJoinBuilder.ts","../projections/declarative/INestedBuilder.ts","../projections/declarative/IProjectionBuilder.ts","../projections/declarative/IProjectionBuilderFor.ts","../projections/declarative/IProjectionFor.ts","../projections/declarative/IReadModelPropertiesBuilder.ts","../projections/declarative/IRemovedWithBuilder.ts","../projections/declarative/IRemovedWithJoinBuilder.ts","../projections/declarative/ISetBuilder.ts","../projections/declarative/ISubtractBuilder.ts","../projections/declarative/JoinBuilder.ts","../projections/declarative/NestedBuilder.ts","../projections/declarative/ProjectionBuilderCore.ts","../projections/declarative/ProjectionBuilderFor.ts","../projections/declarative/RemovedWithBuilder.ts","../projections/declarative/RemovedWithJoinBuilder.ts","../projections/declarative/SetBuilder.ts","../projections/declarative/SubtractBuilder.ts","../projections/declarative/index.ts","../projections/declarative/projection.ts","../projections/modelBound/FromEventMetadata.ts","../projections/modelBound/FromEventOptions.ts","../projections/modelBound/addFrom.ts","../projections/modelBound/childrenAndNestedBuilder.ts","../projections/modelBound/childrenFrom.ts","../projections/modelBound/clearWith.ts","../projections/modelBound/count.ts","../projections/modelBound/decrement.ts","../projections/modelBound/entersOn.ts","../projections/modelBound/eventSequence.ts","../projections/modelBound/fromAll.ts","../projections/modelBound/fromEvent.ts","../projections/modelBound/fromEvery.ts","../projections/modelBound/globalFor.ts","../projections/modelBound/increment.ts","../projections/modelBound/index.ts","../projections/modelBound/join.ts","../projections/modelBound/nested.ts","../projections/modelBound/noAutoMap.ts","../projections/modelBound/notRewindable.ts","../projections/modelBound/passive.ts","../projections/modelBound/removedWith.ts","../projections/modelBound/removedWithJoin.ts","../projections/modelBound/setFrom.ts","../projections/modelBound/setFromContext.ts","../projections/modelBound/setValue.ts","../projections/modelBound/subtractFrom.ts","../projections/modelBound/variantOf.ts","../reactors/IReactors.ts","../reactors/ReactorId.ts","../reactors/ReactorResultHandler.ts","../reactors/ReactorSideEffects.ts","../reactors/Reactors.ts","../reactors/index.ts","../reactors/reactor.ts","../readModels/IMaterializedReadModels.ts","../readModels/IReadModels.ts","../readModels/MaterializedReadModels.ts","../readModels/ReadModelChangeset.ts","../readModels/ReadModelId.ts","../readModels/ReadModelSnapshot.ts","../readModels/ReadModelSubjectResolver.ts","../readModels/ReadModels.ts","../readModels/assertUniqueReadModelIds.ts","../readModels/index.ts","../readModels/readModel.ts","../reducers/IReducers.ts","../reducers/ReducerId.ts","../reducers/Reducers.ts","../reducers/index.ts","../reducers/reducer.ts","../schemas/JsonSchema.ts","../schemas/JsonSchemaGenerator.ts","../schemas/createDeferredSchema.ts","../schemas/index.ts","../schemas/jsonSchemaProperty.ts","../seeding/EventSeeding.ts","../seeding/ICanSeedEvents.ts","../seeding/IEventSeeding.ts","../seeding/IEventSeedingBuilder.ts","../seeding/IEventSeedingScopeBuilder.ts","../seeding/index.ts","../seeding/seeder.ts","../sinks/WellKnownSinks.ts","../sinks/index.ts","../transactions/IUnitOfWork.ts","../transactions/IUnitOfWorkManager.ts","../transactions/NoUnitOfWorkHasBeenStarted.ts","../transactions/UnitOfWork.ts","../transactions/UnitOfWorkManager.ts","../transactions/index.ts","../types/DecoratorType.ts","../types/TypeDiscoverer.ts","../types/TypeIntrospector.ts","../types/index.ts","../types/propertyDecoratorMetadata.ts","../types/standardDecoratorMetadata.ts","../webhooks/IWebhook.ts","../webhooks/IWebhookDefinitionBuilder.ts","../webhooks/IWebhooks.ts","../webhooks/WebhookDefinitionBuilder.ts","../webhooks/WebhookId.ts","../webhooks/WebhookTargetUrl.ts","../webhooks/Webhooks.ts","../webhooks/index.ts","../webhooks/webhook.ts"],"packageJsons":["../package.json","../../node_modules/@bufbuild/protobuf/dist/esm/package.json","../../node_modules/@bufbuild/protobuf/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/@bufbuild/protobuf/dist/esm/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/@bufbuild/protobuf/package.json","../../node_modules/@cratis/chronicle.contracts/package.json","../../node_modules/@cratis/fundamentals/dist/esm/package.json","../../node_modules/@cratis/fundamentals/package.json","../../node_modules/@grpc/grpc-js/package.json","../../node_modules/@grpc/proto-loader/package.json","../../node_modules/@js-sdsl/ordered-map/package.json","../../node_modules/@opentelemetry/api/package.json","../../node_modules/@types/node/package.json","../../node_modules/glob/dist/esm/package.json","../../node_modules/glob/package.json","../../node_modules/long/package.json","../../node_modules/long/umd/package.json","../../node_modules/lru-cache/dist/esm/package.json","../../node_modules/lru-cache/package.json","../../node_modules/minimatch/dist/esm/package.json","../../node_modules/minimatch/package.json","../../node_modules/minipass/dist/esm/package.json","../../node_modules/minipass/package.json","../../node_modules/nice-grpc-common/package.json","../../node_modules/nice-grpc/package.json","../../node_modules/path-scurry/dist/esm/package.json","../../node_modules/path-scurry/package.json","../../node_modules/protobufjs/package.json","../../node_modules/reflect-metadata/package.json","../../node_modules/ts-error/package.json","../../node_modules/undici-types/package.json","../../node_modules/undici/package.json"],"missingPackageJsons":["../../node_modules/@bufbuild/protobuf/dist/esm/codegenv1/package.json","../../node_modules/@bufbuild/protobuf/dist/esm/codegenv2/package.json","../../node_modules/@bufbuild/protobuf/dist/esm/reflect/package.json","../../node_modules/@bufbuild/protobuf/dist/esm/wire/package.json","../../node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/package.json","../../node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/package.json","../../node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/package.json","../../node_modules/@bufbuild/protobuf/dist/esm/wkt/package.json","../../node_modules/@bufbuild/protobuf/wire/package.json","../../node_modules/@cratis/chronicle.contracts/dist/esm/generated/google/package.json","../../node_modules/@cratis/chronicle.contracts/dist/esm/generated/google/protobuf/package.json","../../node_modules/@cratis/chronicle.contracts/dist/esm/generated/package.json","../../node_modules/@cratis/chronicle.contracts/dist/esm/generated/protobuf-net/package.json","../../node_modules/@cratis/chronicle.contracts/dist/esm/package.json","../../node_modules/@cratis/chronicle.contracts/dist/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/@bufbuild/protobuf/dist/esm/reflect/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/@bufbuild/protobuf/dist/esm/wire/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/@bufbuild/protobuf/dist/esm/wkt/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/@bufbuild/protobuf/wire/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/nice-grpc-common/package.json","../../node_modules/@cratis/fundamentals/dist/esm/geospatial/package.json","../../node_modules/@cratis/fundamentals/dist/esm/json/package.json","../../node_modules/@grpc/grpc-js/build/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/google/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/google/protobuf/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/grpc/channelz/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/grpc/channelz/v1/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/grpc/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/xds/data/orca/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/xds/data/orca/v3/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/xds/data/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/xds/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/xds/service/orca/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/xds/service/orca/v3/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/xds/service/package.json","../../node_modules/@grpc/grpc-js/build/src/package.json","../../node_modules/@grpc/proto-loader/build/package.json","../../node_modules/@grpc/proto-loader/build/src/package.json","../../node_modules/@js-sdsl/ordered-map/dist/esm/package.json","../../node_modules/@js-sdsl/ordered-map/dist/package.json","../../node_modules/@opentelemetry/api/build/package.json","../../node_modules/@opentelemetry/api/build/src/api/package.json","../../node_modules/@opentelemetry/api/build/src/baggage/internal/package.json","../../node_modules/@opentelemetry/api/build/src/baggage/package.json","../../node_modules/@opentelemetry/api/build/src/common/package.json","../../node_modules/@opentelemetry/api/build/src/context/package.json","../../node_modules/@opentelemetry/api/build/src/diag/package.json","../../node_modules/@opentelemetry/api/build/src/metrics/package.json","../../node_modules/@opentelemetry/api/build/src/package.json","../../node_modules/@opentelemetry/api/build/src/propagation/package.json","../../node_modules/@opentelemetry/api/build/src/trace/internal/package.json","../../node_modules/@opentelemetry/api/build/src/trace/package.json","../../node_modules/@types/assert/package.json","../../node_modules/@types/assert/strict/package.json","../../node_modules/@types/async_hooks/package.json","../../node_modules/@types/buffer/package.json","../../node_modules/@types/child_process/package.json","../../node_modules/@types/cluster/package.json","../../node_modules/@types/console/package.json","../../node_modules/@types/constants/package.json","../../node_modules/@types/crypto/package.json","../../node_modules/@types/dgram/package.json","../../node_modules/@types/diagnostics_channel/package.json","../../node_modules/@types/dns/package.json","../../node_modules/@types/dns/promises/package.json","../../node_modules/@types/domain/package.json","../../node_modules/@types/events/package.json","../../node_modules/@types/fs/package.json","../../node_modules/@types/fs/promises/package.json","../../node_modules/@types/http/package.json","../../node_modules/@types/http2/package.json","../../node_modules/@types/https/package.json","../../node_modules/@types/inspector/package.json","../../node_modules/@types/inspector/promises/package.json","../../node_modules/@types/module/package.json","../../node_modules/@types/net/package.json","../../node_modules/@types/node/assert/package.json","../../node_modules/@types/node/dns/package.json","../../node_modules/@types/node/fs/package.json","../../node_modules/@types/node/inspector/package.json","../../node_modules/@types/node/path/package.json","../../node_modules/@types/node/readline/package.json","../../node_modules/@types/node/stream/package.json","../../node_modules/@types/node/test/package.json","../../node_modules/@types/node/timers/package.json","../../node_modules/@types/node/util/package.json","../../node_modules/@types/node/web-globals/package.json","../../node_modules/@types/node/zlib/package.json","../../node_modules/@types/os/package.json","../../node_modules/@types/path/package.json","../../node_modules/@types/path/posix/package.json","../../node_modules/@types/path/win32/package.json","../../node_modules/@types/perf_hooks/package.json","../../node_modules/@types/process/package.json","../../node_modules/@types/punycode/package.json","../../node_modules/@types/querystring/package.json","../../node_modules/@types/readline/package.json","../../node_modules/@types/readline/promises/package.json","../../node_modules/@types/repl/package.json","../../node_modules/@types/stream/consumers/package.json","../../node_modules/@types/stream/iter/package.json","../../node_modules/@types/stream/package.json","../../node_modules/@types/stream/promises/package.json","../../node_modules/@types/stream/web/package.json","../../node_modules/@types/string_decoder/package.json","../../node_modules/@types/timers/package.json","../../node_modules/@types/timers/promises/package.json","../../node_modules/@types/tls/package.json","../../node_modules/@types/trace_events/package.json","../../node_modules/@types/tty/package.json","../../node_modules/@types/url/package.json","../../node_modules/@types/util/package.json","../../node_modules/@types/util/types/package.json","../../node_modules/@types/v8/package.json","../../node_modules/@types/vm/package.json","../../node_modules/@types/wasi/package.json","../../node_modules/@types/worker_threads/package.json","../../node_modules/@types/zlib/package.json","../../node_modules/assert/package.json","../../node_modules/assert/strict/package.json","../../node_modules/async_hooks/package.json","../../node_modules/buffer/package.json","../../node_modules/child_process/package.json","../../node_modules/cluster/package.json","../../node_modules/console/package.json","../../node_modules/constants/package.json","../../node_modules/crypto/package.json","../../node_modules/dgram/package.json","../../node_modules/diagnostics_channel/package.json","../../node_modules/dns/package.json","../../node_modules/dns/promises/package.json","../../node_modules/domain/package.json","../../node_modules/events/package.json","../../node_modules/fs/package.json","../../node_modules/fs/promises/package.json","../../node_modules/http/package.json","../../node_modules/http2/package.json","../../node_modules/https/package.json","../../node_modules/inspector/package.json","../../node_modules/inspector/promises/package.json","../../node_modules/module/package.json","../../node_modules/net/package.json","../../node_modules/nice-grpc-common/lib/client/package.json","../../node_modules/nice-grpc-common/lib/package.json","../../node_modules/nice-grpc-common/lib/server/package.json","../../node_modules/nice-grpc/lib/client/package.json","../../node_modules/nice-grpc/lib/package.json","../../node_modules/nice-grpc/lib/server/package.json","../../node_modules/nice-grpc/lib/service-definitions/package.json","../../node_modules/nice-grpc/lib/utils/package.json","../../node_modules/os/package.json","../../node_modules/path/package.json","../../node_modules/path/posix/package.json","../../node_modules/path/win32/package.json","../../node_modules/perf_hooks/package.json","../../node_modules/process/package.json","../../node_modules/protobufjs/ext/descriptor/package.json","../../node_modules/protobufjs/ext/package.json","../../node_modules/protobufjs/node_modules/@types/long/package.json","../../node_modules/protobufjs/node_modules/long/package.json","../../node_modules/punycode/package.json","../../node_modules/querystring/package.json","../../node_modules/readline/package.json","../../node_modules/readline/promises/package.json","../../node_modules/repl/package.json","../../node_modules/stream/consumers/package.json","../../node_modules/stream/iter/package.json","../../node_modules/stream/package.json","../../node_modules/stream/promises/package.json","../../node_modules/stream/web/package.json","../../node_modules/string_decoder/package.json","../../node_modules/timers/package.json","../../node_modules/timers/promises/package.json","../../node_modules/tls/package.json","../../node_modules/trace_events/package.json","../../node_modules/ts-error/lib/package.json","../../node_modules/tty/package.json","../../node_modules/undici/types/package.json","../../node_modules/url/package.json","../../node_modules/util/package.json","../../node_modules/util/types/package.json","../../node_modules/v8/package.json","../../node_modules/vm/package.json","../../node_modules/wasi/package.json","../../node_modules/worker_threads/package.json","../../node_modules/zlib/package.json"]}
1
+ {"version":"7.0.2","root":["../ChronicleClient.ts","../ChronicleOptions.ts","../EventStore.ts","../EventStoreName.ts","../EventStoreNamespaceName.ts","../IChronicleClient.ts","../IEventStore.ts","../Metrics.ts","../Tracing.ts","../index.ts","../artifacts/DefaultClientArtifactsProvider.ts","../artifacts/IClientArtifactsProvider.ts","../artifacts/index.ts","../artifacts/validateArtifactSchemas.ts","../auditing/Causation.ts","../auditing/CausationManager.ts","../auditing/CausationType.ts","../auditing/ICausationManager.ts","../auditing/index.ts","../compliance/ComplianceContracts.ts","../compliance/ComplianceMetadata.ts","../compliance/ComplianceMetadataResolver.ts","../compliance/ComplianceMetadataType.ts","../compliance/IPIIManager.ts","../compliance/PIIManager.ts","../compliance/PIINotSupportedOnEventSourceId.ts","../compliance/index.ts","../compliance/pii.ts","../compliance/subject.ts","../confidentiality/EncryptedNotSupportedOnEventSourceId.ts","../confidentiality/EncryptionScope.ts","../confidentiality/PIIAndEncryptedCombinedNotSupported.ts","../confidentiality/SecurityMetadata.ts","../confidentiality/SecurityMetadataResolver.ts","../confidentiality/SecurityMetadataType.ts","../confidentiality/encrypted.ts","../confidentiality/index.ts","../connection/ChronicleConnection.ts","../connection/ChronicleConnectionString.ts","../connection/ChronicleServerAddressResolver.ts","../connection/ChronicleServices.ts","../connection/ChronicleSrvResolutionError.ts","../connection/ChronicleSrvResolver.ts","../connection/CompatibilityPreflight.ts","../connection/ConnectionLifecycle.ts","../connection/DateTimeOffset.ts","../connection/Guid.ts","../connection/ILoadBalancerStrategy.ts","../connection/IncompatibleChronicleServer.ts","../connection/KernelKeepAlive.ts","../connection/LeastConnectionsLoadBalancerStrategy.ts","../connection/LoadBalancerMode.ts","../connection/LoadBalancerStrategyFactory.ts","../connection/RandomLoadBalancerStrategy.ts","../connection/RoundRobinLoadBalancerStrategy.ts","../connection/TokenProvider.ts","../connection/callResults.ts","../connection/fetchOAuthAccessToken.ts","../connection/formatServerAddress.ts","../connection/index.ts","../correlation/CorrelationId.ts","../correlation/CorrelationIdManager.ts","../correlation/ICorrelationIdAccessor.ts","../correlation/ICorrelationIdSetter.ts","../correlation/index.ts","../eventSequences/AppendError.ts","../eventSequences/AppendOperationsBroadcaster.ts","../eventSequences/AppendOptions.ts","../eventSequences/AppendResult.ts","../eventSequences/AppendedEventWithResult.ts","../eventSequences/CompleteStreamError.ts","../eventSequences/CompleteStreamResult.ts","../eventSequences/ConcurrencyScope.ts","../eventSequences/ConcurrencyViolation.ts","../eventSequences/ConstraintViolation.ts","../eventSequences/EventForEventSourceId.ts","../eventSequences/EventLog.ts","../eventSequences/EventSequence.ts","../eventSequences/EventSequenceId.ts","../eventSequences/EventSequenceNumber.ts","../eventSequences/IEventLog.ts","../eventSequences/IEventSequence.ts","../eventSequences/ITransactionalEventSequence.ts","../eventSequences/TransactionalEventSequence.ts","../eventSequences/WaitForCompletionResult.ts","../eventSequences/index.ts","../eventStoreSubscriptions/EventStoreSubscriptionBuilder.ts","../eventStoreSubscriptions/EventStoreSubscriptionDefinition.ts","../eventStoreSubscriptions/EventStoreSubscriptionId.ts","../eventStoreSubscriptions/EventStoreSubscriptions.ts","../eventStoreSubscriptions/IEventStoreSubscriptionBuilder.ts","../eventStoreSubscriptions/IEventStoreSubscriptions.ts","../eventStoreSubscriptions/contracts.ts","../eventStoreSubscriptions/index.ts","../events/AppendedEvent.ts","../events/CausationEntry.ts","../events/EventContext.ts","../events/EventType.ts","../events/EventTypeGeneration.ts","../events/EventTypeId.ts","../events/EventTypes.ts","../events/IEventTypes.ts","../events/Tag.ts","../events/WireEventContext.ts","../events/eventTypeDecorator.ts","../events/filterEventsByTagDecorator.ts","../events/index.ts","../events/isRegisteredEvent.ts","../events/mergeTags.ts","../events/tagDecorator.ts","../events/toClientEventContext.ts","../events/constraints/ConstraintBuilder.ts","../events/constraints/ConstraintId.ts","../events/constraints/Constraints.ts","../events/constraints/IConstraint.ts","../events/constraints/IConstraintBuilder.ts","../events/constraints/IConstraints.ts","../events/constraints/IUniqueConstraintBuilder.ts","../events/constraints/UniqueConstraintBuilder.ts","../events/constraints/constraint.ts","../events/constraints/index.ts","../events/constraints/removeConstraint.ts","../events/constraints/unique.ts","../events/migrations/EventMigrationBuilder.ts","../events/migrations/EventMigrationPropertyBuilder.ts","../events/migrations/EventTypeMigrators.ts","../events/migrations/IEventMigrationBuilder.ts","../events/migrations/IEventMigrationPropertyBuilder.ts","../events/migrations/IEventTypeMigration.ts","../events/migrations/IEventTypeMigrators.ts","../events/migrations/InvalidMigrationGenerationGap.ts","../events/migrations/eventTypeMigration.ts","../events/migrations/index.ts","../externalServices/ExternalServiceBuilder.ts","../externalServices/ExternalServices.ts","../externalServices/ExternalServicesContracts.ts","../externalServices/IExternalServiceBuilder.ts","../externalServices/IExternalServices.ts","../externalServices/index.ts","../identities/IIdentityManager.ts","../identities/IdentityManager.ts","../identities/index.ts","../identity/IIdentityProvider.ts","../identity/Identity.ts","../identity/IdentityProvider.ts","../identity/index.ts","../jobs/IJobs.ts","../jobs/JobId.ts","../jobs/Jobs.ts","../jobs/index.ts","../observation/FailedPartition.ts","../observation/FailedPartitionAttempt.ts","../observation/FailedPartitions.ts","../observation/ICanBeNotifiedWhenPartitionReplayed.ts","../observation/ICanBeNotifiedWhenReplay.ts","../observation/IFailedPartitions.ts","../observation/ObserverId.ts","../observation/ObserverRunningState.ts","../observation/index.ts","../observation/notifyReplayLifecycle.ts","../observation/toClientFailedPartition.ts","../observation/toObserverRunningState.ts","../projections/GlobalHandlerPropertyNotOnVariant.ts","../projections/IProjections.ts","../projections/ProjectionId.ts","../projections/ProjectionQueryResult.ts","../projections/ProjectionState.ts","../projections/Projections.ts","../projections/UnableToQueryProjection.ts","../projections/VariantMustDeclareEntersOnEvent.ts","../projections/VariantReclassifier.ts","../projections/index.ts","../projections/declarative/AddBuilder.ts","../projections/declarative/AddChildBuilder.ts","../projections/declarative/AllSetBuilder.ts","../projections/declarative/ChildrenBuilder.ts","../projections/declarative/CompositeKeyBuilder.ts","../projections/declarative/FromBuilder.ts","../projections/declarative/FromEveryBuilder.ts","../projections/declarative/IAddBuilder.ts","../projections/declarative/IAddChildBuilder.ts","../projections/declarative/IAllSetBuilder.ts","../projections/declarative/IChildrenBuilder.ts","../projections/declarative/ICompositeKeyBuilder.ts","../projections/declarative/IFromBuilder.ts","../projections/declarative/IFromEveryBuilder.ts","../projections/declarative/IJoinBuilder.ts","../projections/declarative/INestedBuilder.ts","../projections/declarative/IProjectionBuilder.ts","../projections/declarative/IProjectionBuilderFor.ts","../projections/declarative/IProjectionFor.ts","../projections/declarative/IReadModelPropertiesBuilder.ts","../projections/declarative/IRemovedWithBuilder.ts","../projections/declarative/IRemovedWithJoinBuilder.ts","../projections/declarative/ISetBuilder.ts","../projections/declarative/ISubtractBuilder.ts","../projections/declarative/JoinBuilder.ts","../projections/declarative/NestedBuilder.ts","../projections/declarative/ProjectionBuilderCore.ts","../projections/declarative/ProjectionBuilderFor.ts","../projections/declarative/RemovedWithBuilder.ts","../projections/declarative/RemovedWithJoinBuilder.ts","../projections/declarative/SetBuilder.ts","../projections/declarative/SubtractBuilder.ts","../projections/declarative/index.ts","../projections/declarative/projection.ts","../projections/modelBound/FromEventMetadata.ts","../projections/modelBound/FromEventOptions.ts","../projections/modelBound/addFrom.ts","../projections/modelBound/childrenAndNestedBuilder.ts","../projections/modelBound/childrenFrom.ts","../projections/modelBound/clearWith.ts","../projections/modelBound/count.ts","../projections/modelBound/decrement.ts","../projections/modelBound/entersOn.ts","../projections/modelBound/eventSequence.ts","../projections/modelBound/fromAll.ts","../projections/modelBound/fromEvent.ts","../projections/modelBound/fromEvery.ts","../projections/modelBound/globalFor.ts","../projections/modelBound/increment.ts","../projections/modelBound/index.ts","../projections/modelBound/join.ts","../projections/modelBound/nested.ts","../projections/modelBound/noAutoMap.ts","../projections/modelBound/notRewindable.ts","../projections/modelBound/passive.ts","../projections/modelBound/removedWith.ts","../projections/modelBound/removedWithJoin.ts","../projections/modelBound/setFrom.ts","../projections/modelBound/setFromContext.ts","../projections/modelBound/setValue.ts","../projections/modelBound/subtractFrom.ts","../projections/modelBound/variantOf.ts","../reactors/IReactors.ts","../reactors/ReactorId.ts","../reactors/ReactorResultHandler.ts","../reactors/ReactorSideEffects.ts","../reactors/Reactors.ts","../reactors/index.ts","../reactors/onceOnly.ts","../reactors/reactor.ts","../reactors/replay.ts","../readModels/IMaterializedReadModels.ts","../readModels/IReadModels.ts","../readModels/MaterializedReadModels.ts","../readModels/ReadModelChangeset.ts","../readModels/ReadModelId.ts","../readModels/ReadModelSnapshot.ts","../readModels/ReadModelSubjectResolver.ts","../readModels/ReadModels.ts","../readModels/assertUniqueReadModelIds.ts","../readModels/index.ts","../readModels/readModel.ts","../reducers/IReducers.ts","../reducers/ReducerId.ts","../reducers/Reducers.ts","../reducers/index.ts","../reducers/reducer.ts","../schemas/JsonSchema.ts","../schemas/JsonSchemaGenerator.ts","../schemas/createDeferredSchema.ts","../schemas/index.ts","../schemas/jsonSchemaProperty.ts","../seeding/EventSeeding.ts","../seeding/ICanSeedEvents.ts","../seeding/IEventSeeding.ts","../seeding/IEventSeedingBuilder.ts","../seeding/IEventSeedingScopeBuilder.ts","../seeding/index.ts","../seeding/seeder.ts","../sinks/WellKnownSinks.ts","../sinks/index.ts","../transactions/IUnitOfWork.ts","../transactions/IUnitOfWorkManager.ts","../transactions/NoUnitOfWorkHasBeenStarted.ts","../transactions/UnitOfWork.ts","../transactions/UnitOfWorkManager.ts","../transactions/index.ts","../types/DecoratorType.ts","../types/TypeDiscoverer.ts","../types/TypeIntrospector.ts","../types/index.ts","../types/propertyDecoratorMetadata.ts","../types/standardDecoratorMetadata.ts","../webhooks/IWebhook.ts","../webhooks/IWebhookDefinitionBuilder.ts","../webhooks/IWebhooks.ts","../webhooks/WebhookDefinitionBuilder.ts","../webhooks/WebhookId.ts","../webhooks/WebhookTargetUrl.ts","../webhooks/Webhooks.ts","../webhooks/index.ts","../webhooks/webhook.ts"],"packageJsons":["../package.json","../../node_modules/@bufbuild/protobuf/dist/esm/package.json","../../node_modules/@bufbuild/protobuf/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/@bufbuild/protobuf/dist/esm/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/@bufbuild/protobuf/package.json","../../node_modules/@cratis/chronicle.contracts/package.json","../../node_modules/@cratis/fundamentals/dist/esm/package.json","../../node_modules/@cratis/fundamentals/package.json","../../node_modules/@grpc/grpc-js/package.json","../../node_modules/@grpc/proto-loader/package.json","../../node_modules/@js-sdsl/ordered-map/package.json","../../node_modules/@opentelemetry/api/package.json","../../node_modules/@types/node/package.json","../../node_modules/glob/dist/esm/package.json","../../node_modules/glob/package.json","../../node_modules/long/package.json","../../node_modules/long/umd/package.json","../../node_modules/lru-cache/dist/esm/package.json","../../node_modules/lru-cache/package.json","../../node_modules/minimatch/dist/esm/package.json","../../node_modules/minimatch/package.json","../../node_modules/minipass/dist/esm/package.json","../../node_modules/minipass/package.json","../../node_modules/nice-grpc-common/package.json","../../node_modules/nice-grpc/package.json","../../node_modules/path-scurry/dist/esm/package.json","../../node_modules/path-scurry/package.json","../../node_modules/protobufjs/package.json","../../node_modules/reflect-metadata/package.json","../../node_modules/ts-error/package.json","../../node_modules/undici-types/package.json","../../node_modules/undici/package.json"],"missingPackageJsons":["../../node_modules/@bufbuild/protobuf/dist/esm/codegenv1/package.json","../../node_modules/@bufbuild/protobuf/dist/esm/codegenv2/package.json","../../node_modules/@bufbuild/protobuf/dist/esm/reflect/package.json","../../node_modules/@bufbuild/protobuf/dist/esm/wire/package.json","../../node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/package.json","../../node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/package.json","../../node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/package.json","../../node_modules/@bufbuild/protobuf/dist/esm/wkt/package.json","../../node_modules/@bufbuild/protobuf/wire/package.json","../../node_modules/@cratis/chronicle.contracts/dist/esm/generated/google/package.json","../../node_modules/@cratis/chronicle.contracts/dist/esm/generated/google/protobuf/package.json","../../node_modules/@cratis/chronicle.contracts/dist/esm/generated/package.json","../../node_modules/@cratis/chronicle.contracts/dist/esm/generated/protobuf-net/package.json","../../node_modules/@cratis/chronicle.contracts/dist/esm/package.json","../../node_modules/@cratis/chronicle.contracts/dist/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/@bufbuild/protobuf/dist/esm/reflect/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/@bufbuild/protobuf/dist/esm/wire/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/@bufbuild/protobuf/dist/esm/wkt/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/@bufbuild/protobuf/wire/package.json","../../node_modules/@cratis/chronicle.contracts/node_modules/nice-grpc-common/package.json","../../node_modules/@cratis/fundamentals/dist/esm/geospatial/package.json","../../node_modules/@cratis/fundamentals/dist/esm/json/package.json","../../node_modules/@grpc/grpc-js/build/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/google/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/google/protobuf/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/grpc/channelz/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/grpc/channelz/v1/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/grpc/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/xds/data/orca/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/xds/data/orca/v3/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/xds/data/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/xds/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/xds/service/orca/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/xds/service/orca/v3/package.json","../../node_modules/@grpc/grpc-js/build/src/generated/xds/service/package.json","../../node_modules/@grpc/grpc-js/build/src/package.json","../../node_modules/@grpc/proto-loader/build/package.json","../../node_modules/@grpc/proto-loader/build/src/package.json","../../node_modules/@js-sdsl/ordered-map/dist/esm/package.json","../../node_modules/@js-sdsl/ordered-map/dist/package.json","../../node_modules/@opentelemetry/api/build/package.json","../../node_modules/@opentelemetry/api/build/src/api/package.json","../../node_modules/@opentelemetry/api/build/src/baggage/internal/package.json","../../node_modules/@opentelemetry/api/build/src/baggage/package.json","../../node_modules/@opentelemetry/api/build/src/common/package.json","../../node_modules/@opentelemetry/api/build/src/context/package.json","../../node_modules/@opentelemetry/api/build/src/diag/package.json","../../node_modules/@opentelemetry/api/build/src/metrics/package.json","../../node_modules/@opentelemetry/api/build/src/package.json","../../node_modules/@opentelemetry/api/build/src/propagation/package.json","../../node_modules/@opentelemetry/api/build/src/trace/internal/package.json","../../node_modules/@opentelemetry/api/build/src/trace/package.json","../../node_modules/@types/assert/package.json","../../node_modules/@types/assert/strict/package.json","../../node_modules/@types/async_hooks/package.json","../../node_modules/@types/buffer/package.json","../../node_modules/@types/child_process/package.json","../../node_modules/@types/cluster/package.json","../../node_modules/@types/console/package.json","../../node_modules/@types/constants/package.json","../../node_modules/@types/crypto/package.json","../../node_modules/@types/dgram/package.json","../../node_modules/@types/diagnostics_channel/package.json","../../node_modules/@types/dns/package.json","../../node_modules/@types/dns/promises/package.json","../../node_modules/@types/domain/package.json","../../node_modules/@types/events/package.json","../../node_modules/@types/fs/package.json","../../node_modules/@types/fs/promises/package.json","../../node_modules/@types/http/package.json","../../node_modules/@types/http2/package.json","../../node_modules/@types/https/package.json","../../node_modules/@types/inspector/package.json","../../node_modules/@types/inspector/promises/package.json","../../node_modules/@types/module/package.json","../../node_modules/@types/net/package.json","../../node_modules/@types/node/assert/package.json","../../node_modules/@types/node/dns/package.json","../../node_modules/@types/node/fs/package.json","../../node_modules/@types/node/inspector/package.json","../../node_modules/@types/node/path/package.json","../../node_modules/@types/node/readline/package.json","../../node_modules/@types/node/stream/package.json","../../node_modules/@types/node/test/package.json","../../node_modules/@types/node/timers/package.json","../../node_modules/@types/node/util/package.json","../../node_modules/@types/node/web-globals/package.json","../../node_modules/@types/node/zlib/package.json","../../node_modules/@types/os/package.json","../../node_modules/@types/path/package.json","../../node_modules/@types/path/posix/package.json","../../node_modules/@types/path/win32/package.json","../../node_modules/@types/perf_hooks/package.json","../../node_modules/@types/process/package.json","../../node_modules/@types/punycode/package.json","../../node_modules/@types/querystring/package.json","../../node_modules/@types/readline/package.json","../../node_modules/@types/readline/promises/package.json","../../node_modules/@types/repl/package.json","../../node_modules/@types/stream/consumers/package.json","../../node_modules/@types/stream/iter/package.json","../../node_modules/@types/stream/package.json","../../node_modules/@types/stream/promises/package.json","../../node_modules/@types/stream/web/package.json","../../node_modules/@types/string_decoder/package.json","../../node_modules/@types/timers/package.json","../../node_modules/@types/timers/promises/package.json","../../node_modules/@types/tls/package.json","../../node_modules/@types/trace_events/package.json","../../node_modules/@types/tty/package.json","../../node_modules/@types/url/package.json","../../node_modules/@types/util/package.json","../../node_modules/@types/util/types/package.json","../../node_modules/@types/v8/package.json","../../node_modules/@types/vm/package.json","../../node_modules/@types/wasi/package.json","../../node_modules/@types/worker_threads/package.json","../../node_modules/@types/zlib/package.json","../../node_modules/assert/package.json","../../node_modules/assert/strict/package.json","../../node_modules/async_hooks/package.json","../../node_modules/buffer/package.json","../../node_modules/child_process/package.json","../../node_modules/cluster/package.json","../../node_modules/console/package.json","../../node_modules/constants/package.json","../../node_modules/crypto/package.json","../../node_modules/dgram/package.json","../../node_modules/diagnostics_channel/package.json","../../node_modules/dns/package.json","../../node_modules/dns/promises/package.json","../../node_modules/domain/package.json","../../node_modules/events/package.json","../../node_modules/fs/package.json","../../node_modules/fs/promises/package.json","../../node_modules/http/package.json","../../node_modules/http2/package.json","../../node_modules/https/package.json","../../node_modules/inspector/package.json","../../node_modules/inspector/promises/package.json","../../node_modules/module/package.json","../../node_modules/net/package.json","../../node_modules/nice-grpc-common/lib/client/package.json","../../node_modules/nice-grpc-common/lib/package.json","../../node_modules/nice-grpc-common/lib/server/package.json","../../node_modules/nice-grpc/lib/client/package.json","../../node_modules/nice-grpc/lib/package.json","../../node_modules/nice-grpc/lib/server/package.json","../../node_modules/nice-grpc/lib/service-definitions/package.json","../../node_modules/nice-grpc/lib/utils/package.json","../../node_modules/os/package.json","../../node_modules/path/package.json","../../node_modules/path/posix/package.json","../../node_modules/path/win32/package.json","../../node_modules/perf_hooks/package.json","../../node_modules/process/package.json","../../node_modules/protobufjs/ext/descriptor/package.json","../../node_modules/protobufjs/ext/package.json","../../node_modules/protobufjs/node_modules/@types/long/package.json","../../node_modules/protobufjs/node_modules/long/package.json","../../node_modules/punycode/package.json","../../node_modules/querystring/package.json","../../node_modules/readline/package.json","../../node_modules/readline/promises/package.json","../../node_modules/repl/package.json","../../node_modules/stream/consumers/package.json","../../node_modules/stream/iter/package.json","../../node_modules/stream/package.json","../../node_modules/stream/promises/package.json","../../node_modules/stream/web/package.json","../../node_modules/string_decoder/package.json","../../node_modules/timers/package.json","../../node_modules/timers/promises/package.json","../../node_modules/tls/package.json","../../node_modules/trace_events/package.json","../../node_modules/ts-error/lib/package.json","../../node_modules/tty/package.json","../../node_modules/undici/types/package.json","../../node_modules/url/package.json","../../node_modules/util/package.json","../../node_modules/util/types/package.json","../../node_modules/v8/package.json","../../node_modules/vm/package.json","../../node_modules/wasi/package.json","../../node_modules/worker_threads/package.json","../../node_modules/zlib/package.json"]}
@@ -6,6 +6,7 @@ import { EventSequence } from './EventSequence.js';
6
6
  import { EventSequenceId } from './EventSequenceId.js';
7
7
  import { IEventLog } from './IEventLog.js';
8
8
  import { IUnitOfWorkManager } from '../transactions/IUnitOfWorkManager.js';
9
+ import type { ConstraintViolation } from './ConstraintViolation.js';
9
10
 
10
11
  /**
11
12
  * Implements {@link IEventLog} by extending the base {@link EventSequence}.
@@ -16,8 +17,9 @@ export class EventLog extends EventSequence implements IEventLog {
16
17
  eventStoreName: string,
17
18
  namespace: string,
18
19
  connection: ChronicleConnection,
19
- unitOfWorkManager: IUnitOfWorkManager
20
+ unitOfWorkManager: IUnitOfWorkManager,
21
+ resolveConstraintMessage?: (violation: ConstraintViolation) => ConstraintViolation
20
22
  ) {
21
- super(EventSequenceId.eventLog, eventStoreName, namespace, connection, unitOfWorkManager);
23
+ super(EventSequenceId.eventLog, eventStoreName, namespace, connection, unitOfWorkManager, resolveConstraintMessage);
22
24
  }
23
25
  }
@@ -55,7 +55,8 @@ export class EventSequence implements IEventSequence {
55
55
  private readonly _eventStoreName: string,
56
56
  private readonly _namespace: string,
57
57
  private readonly _connection: ChronicleConnection,
58
- private readonly _unitOfWorkManager: IUnitOfWorkManager
58
+ private readonly _unitOfWorkManager: IUnitOfWorkManager,
59
+ private readonly _resolveConstraintMessage?: (violation: ConstraintViolation) => ConstraintViolation
59
60
  ) {
60
61
  this.transactional = new TransactionalEventSequence(this, this._unitOfWorkManager);
61
62
  }
@@ -695,11 +696,14 @@ export class EventSequence implements IEventSequence {
695
696
  errors: string[],
696
697
  concurrencyViolation?: { EventSourceId?: string; ExpectedSequenceNumber?: bigint; ActualSequenceNumber?: bigint }
697
698
  ): AppendResult {
698
- const mappedViolations: ConstraintViolation[] = constraintViolations.map(violation => ({
699
- constraintId: violation.ConstraintId ?? '',
700
- message: violation.Message ?? '',
701
- details: violation.Details ?? {}
702
- }));
699
+ const mappedViolations: ConstraintViolation[] = constraintViolations.map(violation => {
700
+ const mapped = {
701
+ constraintId: violation.ConstraintId ?? '',
702
+ message: violation.Message ?? '',
703
+ details: violation.Details ?? {}
704
+ };
705
+ return this._resolveConstraintMessage?.(mapped) ?? mapped;
706
+ });
703
707
 
704
708
  const mappedErrors = errors.map(message => ({ message }));
705
709
 
@@ -1,8 +1,14 @@
1
1
  // Copyright (c) Cratis. All rights reserved.
2
2
  // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
 
4
- import { describe, expect, it } from 'vitest';
4
+ import { describe, expect, it, vi } from 'vitest';
5
+ import { DefaultClientArtifactsProvider } from '../artifacts/DefaultClientArtifactsProvider.js';
6
+ import type { IClientArtifactsProvider } from '../artifacts/IClientArtifactsProvider.js';
7
+ import type { ChronicleConnection } from '../connection/ChronicleConnection.js';
8
+ import { Constraints } from './constraints/Constraints.js';
5
9
  import { constraint, getConstraintMetadata } from './constraints/constraint.js';
10
+ import { unique, getUniqueEventMetadata, getUniquePropertyMetadata } from './constraints/unique.js';
11
+ import { removeConstraint, getRemovedConstraintNames } from './constraints/removeConstraint.js';
6
12
  import { eventType, getEventTypeMetadata } from './eventTypeDecorator.js';
7
13
  import { filterEventsByTag, getFilterTagsFor } from './filterEventsByTagDecorator.js';
8
14
  import { eventTypeMigration, getEventTypeMigrationMetadata } from './migrations/eventTypeMigration.js';
@@ -29,6 +35,20 @@ class Migration {}
29
35
  @constraint('standard-constraint')
30
36
  class Constraint {}
31
37
 
38
+ @eventType('standard-unique-property')
39
+ class UniquePropertyEvent {
40
+ @unique('standard-unique-name', 'Already taken') name = '';
41
+ }
42
+
43
+ @eventType('standard-unique-class')
44
+ @unique('standard-unique-type', 'Already registered')
45
+ class UniqueEvent {}
46
+
47
+ @eventType('standard-unique-release')
48
+ @removeConstraint('standard-unique-name')
49
+ @removeConstraint('standard-unique-type')
50
+ class UniqueRelease {}
51
+
32
52
  @tag('first')
33
53
  @tags('second')
34
54
  @filterEventsByTag('required')
@@ -61,6 +81,9 @@ describe('standard class decorators', () => {
61
81
  expect(getEventTypeMetadata(Previous)?.schema.properties).toEqual({});
62
82
  expect(getEventTypeMigrationMetadata(Migration)?.eventType.generation.value).toBe(2);
63
83
  expect(getConstraintMetadata(Constraint)?.id.value).toBe('standard-constraint');
84
+ expect(getUniquePropertyMetadata(UniquePropertyEvent, 'name')).toEqual({ name: 'standard-unique-name', message: 'Already taken' });
85
+ expect(getUniqueEventMetadata(UniqueEvent)).toEqual({ name: 'standard-unique-type', message: 'Already registered' });
86
+ expect(getRemovedConstraintNames(UniqueRelease)).toEqual(['standard-unique-type', 'standard-unique-name']);
64
87
  expect(getTagsFor(Tagged).map(item => item.value)).toEqual(['second', 'first']);
65
88
  expect(getFilterTagsFor(Tagged).map(item => item.value)).toEqual(['required']);
66
89
  expect(getFromEventMetadata(ModelBound)).toHaveLength(1);
@@ -74,4 +97,25 @@ describe('standard class decorators', () => {
74
97
  expect(getSeederMetadata(Seeder)?.isSeeder).toBe(true);
75
98
  expect(getWebhookMetadata(Webhook)?.targetUrl.value).toBe('https://example.com/hooks');
76
99
  });
100
+
101
+ it('registers standard-decorated constraints through normal artifact discovery', async () => {
102
+ const register = vi.fn().mockResolvedValue({});
103
+ const connection = { constraints: { register } } as unknown as ChronicleConnection;
104
+ const artifacts = {
105
+ eventTypes: DefaultClientArtifactsProvider.default.eventTypes.filter(type =>
106
+ [UniquePropertyEvent, UniqueEvent, UniqueRelease].includes(type)),
107
+ constraints: []
108
+ } as unknown as IClientArtifactsProvider;
109
+ const constraints = new Constraints('store', connection, artifacts);
110
+ await constraints.register();
111
+ const definitions = register.mock.calls[0][0].Constraints;
112
+ const property = definitions.find((definition: { Name: string }) => definition.Name === 'standard-unique-name');
113
+ const eventType = definitions.find((definition: { Name: string }) => definition.Name === 'standard-unique-type');
114
+ expect(property.Definition.Value0.EventDefinitions).toEqual([
115
+ { EventTypeId: 'standard-unique-property', Properties: ['name'] }
116
+ ]);
117
+ expect(property.RemovedWith).toEqual(['standard-unique-release']);
118
+ expect(eventType.Definition.Value1.EventTypeIds).toEqual(['standard-unique-class']);
119
+ expect(eventType.RemovedWith).toEqual(['standard-unique-release']);
120
+ });
77
121
  });
@@ -16,6 +16,8 @@ export interface ConstraintScopeCapture {
16
16
  /** Represents the captured definition of a unique event type constraint. */
17
17
  export interface UniqueEventTypeCapture {
18
18
  eventTypeId: string;
19
+ eventTypeIds?: string[];
20
+ removedWithEventTypeIds?: string[];
19
21
  message?: string;
20
22
  name?: string;
21
23
  }
@@ -2,17 +2,40 @@
2
2
  // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
 
4
4
  import { ConstraintType } from '@cratis/chronicle.contracts';
5
+ import type { ConstraintViolation } from '../../eventSequences/ConstraintViolation.js';
5
6
  import { IClientArtifactsProvider } from '../../artifacts/index.js';
6
7
  import { ChronicleConnection } from '../../connection/index.js';
7
8
  import { ConstraintId } from './ConstraintId.js';
8
9
  import { IConstraint } from './IConstraint.js';
9
10
  import { IConstraints } from './IConstraints.js';
10
- import { ConstraintBuilder, ConstraintCapture } from './ConstraintBuilder.js';
11
+ import { ConstraintBuilder, ConstraintCapture, ConstraintScopeCapture } from './ConstraintBuilder.js';
12
+ import { UniqueConstraintBuilder } from './UniqueConstraintBuilder.js';
11
13
  import { getConstraintMetadata } from './constraint.js';
14
+ import { getUniqueEventMetadata, getUniquePropertyMetadata } from './unique.js';
15
+ import { getRemovedConstraintNames } from './removeConstraint.js';
16
+ import { TypeIntrospector } from '../../types/TypeIntrospector.js';
17
+ import { getEventTypeFor } from '../eventTypeDecorator.js';
12
18
 
13
- /**
14
- * Manages discovery and registration of constraints with the Chronicle Kernel.
15
- */
19
+ /** Resolves the name registered with the Chronicle Kernel. */
20
+ function wireNameOf(capture: ConstraintCapture): string {
21
+ return capture.uniqueEventType?.name ?? capture.name;
22
+ }
23
+
24
+ const decoratorScope: ConstraintScopeCapture = {
25
+ perEventSourceType: false,
26
+ perEventStreamType: false,
27
+ perEventStreamId: false
28
+ };
29
+
30
+ function assertMatchingScope(name: string, left: ConstraintScopeCapture, right: ConstraintScopeCapture): void {
31
+ if (left.perEventSourceType !== right.perEventSourceType ||
32
+ left.perEventStreamType !== right.perEventStreamType ||
33
+ left.perEventStreamId !== right.perEventStreamId) {
34
+ throw new Error(`Conflicting scopes for constraint '${name}'.`);
35
+ }
36
+ }
37
+
38
+ /** Manages discovery and registration of constraints with the Chronicle Kernel. */
16
39
  export class Constraints implements IConstraints {
17
40
  private readonly _captures = new Map<string, ConstraintCapture>();
18
41
 
@@ -31,14 +54,107 @@ export class Constraints implements IConstraints {
31
54
  /** @inheritdoc */
32
55
  async discover(): Promise<void> {
33
56
  this._captures.clear();
57
+ const fluentIds = new Set<string>();
34
58
  for (const type of this._clientArtifacts.constraints) {
35
59
  const metadata = getConstraintMetadata(type);
36
60
  if (!metadata) continue;
61
+ if (fluentIds.has(metadata.id.value)) throw new Error(`Duplicate constraint id '${metadata.id.value}'.`);
62
+ fluentIds.add(metadata.id.value);
37
63
 
38
64
  const builder = new ConstraintBuilder(metadata.id.value);
39
65
  const instance = new (type as new () => IConstraint)();
40
66
  instance.define(builder);
41
- this._captures.set(metadata.id.value, builder.capture);
67
+ const capture = builder.capture;
68
+ const name = wireNameOf(capture);
69
+ const existing = this._captures.get(name);
70
+ if (existing?.uniqueEventType && capture.uniqueEventType) {
71
+ assertMatchingScope(name, existing.scope, capture.scope);
72
+ const merged = existing.uniqueEventType;
73
+ if (capture.uniqueEventType.message && !merged.message) merged.message = capture.uniqueEventType.message;
74
+ const ids = merged.eventTypeIds ??= [merged.eventTypeId];
75
+ for (const id of capture.uniqueEventType.eventTypeIds ?? [capture.uniqueEventType.eventTypeId]) {
76
+ if (!ids.includes(id)) ids.push(id);
77
+ }
78
+ const removedWith = merged.removedWithEventTypeIds ??= [];
79
+ for (const id of capture.uniqueEventType.removedWithEventTypeIds ?? []) {
80
+ if (!removedWith.includes(id)) removedWith.push(id);
81
+ }
82
+ } else if (existing) {
83
+ throw new Error(`Duplicate constraint name '${name}'.`);
84
+ } else {
85
+ this._captures.set(name, capture);
86
+ }
87
+ }
88
+
89
+ const removalEvents = new Map<string, Function[]>();
90
+ for (const eventType of this._clientArtifacts.eventTypes) {
91
+ for (const name of getRemovedConstraintNames(eventType)) {
92
+ const events = removalEvents.get(name) ?? [];
93
+ events.push(eventType);
94
+ removalEvents.set(name, events);
95
+ }
96
+ }
97
+
98
+ for (const eventType of this._clientArtifacts.eventTypes) {
99
+ const eventMetadata = getUniqueEventMetadata(eventType);
100
+ if (eventMetadata) {
101
+ const name = eventMetadata.name ?? eventType.name;
102
+ let capture = this._captures.get(name);
103
+ if (!capture) {
104
+ const builder = new ConstraintBuilder(name);
105
+ builder.uniqueFor(eventType, eventMetadata.message, name);
106
+ capture = builder.capture;
107
+ this._captures.set(name, capture);
108
+ } else if (!capture.uniqueEventType) {
109
+ throw new Error(`Constraint '${name}' is not a unique event type constraint.`);
110
+ } else {
111
+ assertMatchingScope(name, capture.scope, decoratorScope);
112
+ if (eventMetadata.message && !capture.uniqueEventType.message) capture.uniqueEventType.message = eventMetadata.message;
113
+ capture.uniqueEventType.eventTypeIds ??= [capture.uniqueEventType.eventTypeId];
114
+ const id = getEventTypeFor(eventType).id.value;
115
+ if (!capture.uniqueEventType.eventTypeIds.includes(id)) capture.uniqueEventType.eventTypeIds.push(id);
116
+ }
117
+ }
118
+
119
+ for (const property of TypeIntrospector.getTrackedProperties(eventType)) {
120
+ const metadata = getUniquePropertyMetadata(eventType, property);
121
+ if (!metadata) continue;
122
+ const name = metadata.name ?? property;
123
+ let capture = this._captures.get(name);
124
+ if (!capture) {
125
+ const builder = new ConstraintBuilder(name);
126
+ builder.unique(() => {});
127
+ capture = builder.capture;
128
+ this._captures.set(name, capture);
129
+ }
130
+ if (!capture.uniqueConstraint) throw new Error(`Constraint '${name}' is not a unique property constraint.`);
131
+ assertMatchingScope(name, capture.scope, decoratorScope);
132
+ if (capture.uniqueConstraint.ignoreCasing) throw new Error(`Conflicting ignoreCasing for unique property constraint '${name}'.`);
133
+ const unique = new UniqueConstraintBuilder(capture.uniqueConstraint);
134
+ const id = getEventTypeFor(eventType).id.value;
135
+ const existing = capture.uniqueConstraint.eventDefinitions.find(definition => definition.eventTypeId === id);
136
+ if (existing && !existing.properties.includes(property)) {
137
+ throw new Error(`Event type '${id}' already added to unique constraint '${name}' with properties '${existing.properties.join(', ')}'.`);
138
+ }
139
+ if (!existing) unique.on(eventType, event => (event as Record<string, unknown>)[property]);
140
+ if (metadata.message && !capture.uniqueConstraint.message) unique.withMessage(metadata.message);
141
+ }
142
+ }
143
+
144
+ for (const [name, eventTypes] of removalEvents) {
145
+ const capture = this._captures.get(name);
146
+ if (capture) {
147
+ if (capture.uniqueConstraint) {
148
+ const unique = new UniqueConstraintBuilder(capture.uniqueConstraint);
149
+ eventTypes.forEach(eventType => unique.removedWith(eventType));
150
+ } else if (capture.uniqueEventType) {
151
+ const removedWith = capture.uniqueEventType.removedWithEventTypeIds ??= [];
152
+ for (const eventType of eventTypes) {
153
+ const id = getEventTypeFor(eventType).id.value;
154
+ if (!removedWith.includes(id)) removedWith.push(id);
155
+ }
156
+ }
157
+ }
42
158
  }
43
159
  }
44
160
 
@@ -85,11 +201,11 @@ export class Constraints implements IConstraints {
85
201
  return {
86
202
  Name: uet.name ?? capture.name,
87
203
  Type: ConstraintType.UniqueEventType,
88
- RemovedWith: [],
204
+ RemovedWith: uet.removedWithEventTypeIds ?? [],
89
205
  Definition: {
90
206
  Value0: undefined,
91
207
  Value1: {
92
- EventTypeIds: [uet.eventTypeId]
208
+ EventTypeIds: uet.eventTypeIds ?? [uet.eventTypeId]
93
209
  }
94
210
  },
95
211
  Scope: scope
@@ -119,4 +235,21 @@ export class Constraints implements IConstraints {
119
235
  hasFor(id: ConstraintId): boolean {
120
236
  return this._captures.has(id.value);
121
237
  }
238
+
239
+ /**
240
+ * Resolves a configured violation message, preserving the Kernel message when none was supplied.
241
+ * @param violation - Violation returned by the Kernel.
242
+ * @returns The violation with its configured message and substituted details, if available.
243
+ */
244
+ resolveMessageFor(violation: ConstraintViolation): ConstraintViolation {
245
+ const capture = this._captures.get(violation.constraintId);
246
+ const message = capture?.uniqueConstraint?.message ?? capture?.uniqueEventType?.message;
247
+ if (!message) return violation;
248
+
249
+ let resolved = message;
250
+ for (const [key, value] of Object.entries(violation.details)) {
251
+ resolved = resolved.replaceAll(`{${key}}`, () => value);
252
+ }
253
+ return { ...violation, message: resolved };
254
+ }
122
255
  }