@cratis/chronicle 6.48.0 → 6.50.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.
- package/EventStore.ts +8 -2
- package/IEventStore.ts +8 -0
- package/artifacts/DefaultClientArtifactsProvider.ts +5 -0
- package/artifacts/IClientArtifactsProvider.ts +3 -0
- package/connection/ChronicleConnection.ts +6 -0
- package/connection/ChronicleServices.ts +2 -0
- package/dist/EventStore.d.ts +2 -0
- package/dist/EventStore.d.ts.map +1 -1
- package/dist/EventStore.js +7 -2
- package/dist/EventStore.js.map +1 -1
- package/dist/IEventStore.d.ts +7 -0
- package/dist/IEventStore.d.ts.map +1 -1
- package/dist/artifacts/DefaultClientArtifactsProvider.d.ts +2 -0
- package/dist/artifacts/DefaultClientArtifactsProvider.d.ts.map +1 -1
- package/dist/artifacts/DefaultClientArtifactsProvider.js +4 -0
- package/dist/artifacts/DefaultClientArtifactsProvider.js.map +1 -1
- package/dist/artifacts/IClientArtifactsProvider.d.ts +2 -0
- package/dist/artifacts/IClientArtifactsProvider.d.ts.map +1 -1
- package/dist/connection/ChronicleConnection.d.ts +1 -0
- package/dist/connection/ChronicleConnection.d.ts.map +1 -1
- package/dist/connection/ChronicleConnection.js +5 -1
- package/dist/connection/ChronicleConnection.js.map +1 -1
- package/dist/connection/ChronicleServices.d.ts +2 -1
- package/dist/connection/ChronicleServices.d.ts.map +1 -1
- package/dist/eventSequences/AppendOptions.d.ts +22 -0
- package/dist/eventSequences/AppendOptions.d.ts.map +1 -1
- package/dist/eventSequences/EventForEventSourceId.d.ts +17 -0
- package/dist/eventSequences/EventForEventSourceId.d.ts.map +1 -1
- package/dist/eventSequences/EventLog.d.ts +2 -1
- package/dist/eventSequences/EventLog.d.ts.map +1 -1
- package/dist/eventSequences/EventLog.js +2 -2
- package/dist/eventSequences/EventLog.js.map +1 -1
- package/dist/eventSequences/EventSequence.d.ts +4 -1
- package/dist/eventSequences/EventSequence.d.ts.map +1 -1
- package/dist/eventSequences/EventSequence.js +59 -13
- package/dist/eventSequences/EventSequence.js.map +1 -1
- package/dist/eventSequences/ITransactionalEventSequence.d.ts +5 -2
- package/dist/eventSequences/ITransactionalEventSequence.d.ts.map +1 -1
- package/dist/eventSequences/NamedTagsWithRegisteredEventSourceNotSupported.d.ts +5 -0
- package/dist/eventSequences/NamedTagsWithRegisteredEventSourceNotSupported.d.ts.map +1 -0
- package/dist/eventSequences/NamedTagsWithRegisteredEventSourceNotSupported.js +12 -0
- package/dist/eventSequences/NamedTagsWithRegisteredEventSourceNotSupported.js.map +1 -0
- package/dist/eventSequences/TransactionalEventSequence.d.ts +3 -2
- package/dist/eventSequences/TransactionalEventSequence.d.ts.map +1 -1
- package/dist/eventSequences/TransactionalEventSequence.js +7 -4
- package/dist/eventSequences/TransactionalEventSequence.js.map +1 -1
- package/dist/eventSequences/createAppendNotification.d.ts +2 -1
- package/dist/eventSequences/createAppendNotification.d.ts.map +1 -1
- package/dist/eventSequences/createAppendNotification.js +3 -2
- package/dist/eventSequences/createAppendNotification.js.map +1 -1
- package/dist/eventSequences/ensureNamedTagBatchIsSupported.d.ts +3 -0
- package/dist/eventSequences/ensureNamedTagBatchIsSupported.d.ts.map +1 -0
- package/dist/eventSequences/ensureNamedTagBatchIsSupported.js +10 -0
- package/dist/eventSequences/ensureNamedTagBatchIsSupported.js.map +1 -0
- package/dist/eventSequences/index.d.ts +1 -0
- package/dist/eventSequences/index.d.ts.map +1 -1
- package/dist/eventSequences/index.js +1 -0
- package/dist/eventSequences/index.js.map +1 -1
- package/dist/eventSequences/prepareBatchAppend.d.ts +1 -0
- package/dist/eventSequences/prepareBatchAppend.d.ts.map +1 -1
- package/dist/eventSequences/prepareBatchAppend.js +4 -1
- package/dist/eventSequences/prepareBatchAppend.js.map +1 -1
- package/dist/eventSequences/prepareSingleAppend.d.ts +1 -0
- package/dist/eventSequences/prepareSingleAppend.d.ts.map +1 -1
- package/dist/eventSequences/prepareSingleAppend.js +3 -1
- package/dist/eventSequences/prepareSingleAppend.js.map +1 -1
- package/dist/eventSequences/resolveEventSourceRouting.d.ts +39 -0
- package/dist/eventSequences/resolveEventSourceRouting.d.ts.map +1 -0
- package/dist/eventSequences/resolveEventSourceRouting.js +92 -0
- package/dist/eventSequences/resolveEventSourceRouting.js.map +1 -0
- package/dist/eventSources/ConcurrencyDimensions.d.ts +19 -0
- package/dist/eventSources/ConcurrencyDimensions.d.ts.map +1 -0
- package/dist/eventSources/ConcurrencyDimensions.js +19 -0
- package/dist/eventSources/ConcurrencyDimensions.js.map +1 -0
- package/dist/eventSources/DuplicateEventSourceName.d.ts +6 -0
- package/dist/eventSources/DuplicateEventSourceName.d.ts.map +1 -0
- package/dist/eventSources/DuplicateEventSourceName.js +12 -0
- package/dist/eventSources/DuplicateEventSourceName.js.map +1 -0
- package/dist/eventSources/DuplicateEventStreamName.d.ts +7 -0
- package/dist/eventSources/DuplicateEventStreamName.d.ts.map +1 -0
- package/dist/eventSources/DuplicateEventStreamName.js +14 -0
- package/dist/eventSources/DuplicateEventStreamName.js.map +1 -0
- package/dist/eventSources/EventRoutingContradictsEventSource.d.ts +9 -0
- package/dist/eventSources/EventRoutingContradictsEventSource.d.ts.map +1 -0
- package/dist/eventSources/EventRoutingContradictsEventSource.js +18 -0
- package/dist/eventSources/EventRoutingContradictsEventSource.js.map +1 -0
- package/dist/eventSources/EventSourceDefinition.d.ts +20 -0
- package/dist/eventSources/EventSourceDefinition.d.ts.map +1 -0
- package/dist/eventSources/EventSourceDefinition.js +4 -0
- package/dist/eventSources/EventSourceDefinition.js.map +1 -0
- package/dist/eventSources/EventSources.d.ts +31 -0
- package/dist/eventSources/EventSources.d.ts.map +1 -0
- package/dist/eventSources/EventSources.js +90 -0
- package/dist/eventSources/EventSources.js.map +1 -0
- package/dist/eventSources/EventStreamDefinition.d.ts +13 -0
- package/dist/eventSources/EventStreamDefinition.d.ts.map +1 -0
- package/dist/eventSources/EventStreamDefinition.js +4 -0
- package/dist/eventSources/EventStreamDefinition.js.map +1 -0
- package/dist/eventSources/EventStreamDoesNotBelongToEventSource.d.ts +7 -0
- package/dist/eventSources/EventStreamDoesNotBelongToEventSource.d.ts.map +1 -0
- package/dist/eventSources/EventStreamDoesNotBelongToEventSource.js +14 -0
- package/dist/eventSources/EventStreamDoesNotBelongToEventSource.js.map +1 -0
- package/dist/eventSources/EventStreamRequiresEventSource.d.ts +6 -0
- package/dist/eventSources/EventStreamRequiresEventSource.d.ts.map +1 -0
- package/dist/eventSources/EventStreamRequiresEventSource.js +12 -0
- package/dist/eventSources/EventStreamRequiresEventSource.js.map +1 -0
- package/dist/eventSources/IEventSources.d.ts +27 -0
- package/dist/eventSources/IEventSources.d.ts.map +1 -0
- package/dist/eventSources/IEventSources.js +4 -0
- package/dist/eventSources/IEventSources.js.map +1 -0
- package/dist/eventSources/ResolvedEventRouting.d.ts +37 -0
- package/dist/eventSources/ResolvedEventRouting.d.ts.map +1 -0
- package/dist/eventSources/ResolvedEventRouting.js +60 -0
- package/dist/eventSources/ResolvedEventRouting.js.map +1 -0
- package/dist/eventSources/UnknownEventSource.d.ts +6 -0
- package/dist/eventSources/UnknownEventSource.d.ts.map +1 -0
- package/dist/eventSources/UnknownEventSource.js +12 -0
- package/dist/eventSources/UnknownEventSource.js.map +1 -0
- package/dist/eventSources/eventSource.d.ts +60 -0
- package/dist/eventSources/eventSource.d.ts.map +1 -0
- package/dist/eventSources/eventSource.js +72 -0
- package/dist/eventSources/eventSource.js.map +1 -0
- package/dist/eventSources/index.d.ts +17 -0
- package/dist/eventSources/index.d.ts.map +1 -0
- package/dist/eventSources/index.js +13 -0
- package/dist/eventSources/index.js.map +1 -0
- package/dist/events/EventContext.d.ts +12 -0
- package/dist/events/EventContext.d.ts.map +1 -1
- package/dist/events/InvalidNamedTag.d.ts +8 -0
- package/dist/events/InvalidNamedTag.d.ts.map +1 -0
- package/dist/events/InvalidNamedTag.js +13 -0
- package/dist/events/InvalidNamedTag.js.map +1 -0
- package/dist/events/NamedTag.d.ts +25 -0
- package/dist/events/NamedTag.d.ts.map +1 -0
- package/dist/events/NamedTag.js +39 -0
- package/dist/events/NamedTag.js.map +1 -0
- package/dist/events/WireEventContext.d.ts +2 -0
- package/dist/events/WireEventContext.d.ts.map +1 -1
- package/dist/events/index.d.ts +3 -0
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +3 -0
- package/dist/events/index.js.map +1 -1
- package/dist/events/mergeNamedTags.d.ts +13 -0
- package/dist/events/mergeNamedTags.d.ts.map +1 -0
- package/dist/events/mergeNamedTags.js +39 -0
- package/dist/events/mergeNamedTags.js.map +1 -0
- package/dist/events/toClientEventContext.d.ts.map +1 -1
- package/dist/events/toClientEventContext.js +4 -1
- package/dist/events/toClientEventContext.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/projections/eventContextPropertyExpression.d.ts.map +1 -1
- package/dist/projections/eventContextPropertyExpression.js +2 -0
- package/dist/projections/eventContextPropertyExpression.js.map +1 -1
- package/dist/testing/InProcessEventSequence.d.ts.map +1 -1
- package/dist/testing/InProcessEventSequence.js +17 -7
- package/dist/testing/InProcessEventSequence.js.map +1 -1
- package/dist/testing/ReactorScenario.d.ts.map +1 -1
- package/dist/testing/ReactorScenario.js +6 -0
- package/dist/testing/ReactorScenario.js.map +1 -1
- package/dist/testing/projections/ProjectionReadModelProcessor.d.ts.map +1 -1
- package/dist/testing/projections/ProjectionReadModelProcessor.js +2 -1
- package/dist/testing/projections/ProjectionReadModelProcessor.js.map +1 -1
- package/dist/testing/singleAppendRoute.d.ts +5 -0
- package/dist/testing/singleAppendRoute.d.ts.map +1 -1
- package/dist/testing/singleAppendRoute.js +12 -1
- package/dist/testing/singleAppendRoute.js.map +1 -1
- package/dist/transactions/IUnitOfWork.d.ts +4 -1
- package/dist/transactions/IUnitOfWork.d.ts.map +1 -1
- package/dist/transactions/TransactionalAppendOptions.d.ts +14 -0
- package/dist/transactions/TransactionalAppendOptions.d.ts.map +1 -0
- package/dist/transactions/TransactionalAppendOptions.js +4 -0
- package/dist/transactions/TransactionalAppendOptions.js.map +1 -0
- package/dist/transactions/TransactionalEventRouting.d.ts +12 -0
- package/dist/transactions/TransactionalEventRouting.d.ts.map +1 -0
- package/dist/transactions/TransactionalEventRouting.js +4 -0
- package/dist/transactions/TransactionalEventRouting.js.map +1 -0
- package/dist/transactions/UnitOfWork.d.ts +2 -1
- package/dist/transactions/UnitOfWork.d.ts.map +1 -1
- package/dist/transactions/UnitOfWork.js +17 -2
- package/dist/transactions/UnitOfWork.js.map +1 -1
- package/dist/transactions/index.d.ts +2 -0
- package/dist/transactions/index.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/DecoratorType.d.ts +3 -1
- package/dist/types/DecoratorType.d.ts.map +1 -1
- package/dist/types/DecoratorType.js +2 -0
- package/dist/types/DecoratorType.js.map +1 -1
- package/eventSequences/AppendOptions.ts +25 -0
- package/eventSequences/EventForEventSourceId.ts +20 -0
- package/eventSequences/EventLog.ts +4 -2
- package/eventSequences/EventSequence.ts +62 -13
- package/eventSequences/ITransactionalEventSequence.ts +5 -2
- package/eventSequences/NamedTagsWithRegisteredEventSourceNotSupported.ts +12 -0
- package/eventSequences/TransactionalEventSequence.ts +8 -4
- package/eventSequences/createAppendNotification.ts +4 -2
- package/eventSequences/ensureNamedTagBatchIsSupported.ts +11 -0
- package/eventSequences/for_EventSequence/against_a_kernel/when_appending_named_tags.integration.spec.ts +107 -0
- package/eventSequences/for_EventSequence/when_appending_named_tags/given.fixture.ts +38 -0
- package/eventSequences/for_EventSequence/when_appending_named_tags/with_a_batch.spec.ts +49 -0
- package/eventSequences/for_EventSequence/when_appending_named_tags/with_a_single_event.spec.ts +47 -0
- package/eventSequences/for_EventSequence/when_appending_named_tags/with_an_invalid_tag.spec.ts +36 -0
- package/eventSequences/for_EventSequence/when_appending_named_tags/with_registered_sources.spec.ts +74 -0
- package/eventSequences/for_TransactionalEventSequence/when_appending_many_with_named_tags.spec.ts +41 -0
- package/eventSequences/index.ts +1 -0
- package/eventSequences/prepareBatchAppend.ts +4 -1
- package/eventSequences/prepareSingleAppend.ts +3 -1
- package/eventSequences/resolveEventSourceRouting.ts +125 -0
- package/eventSources/ConcurrencyDimensions.ts +26 -0
- package/eventSources/DuplicateEventSourceName.ts +10 -0
- package/eventSources/DuplicateEventStreamName.ts +10 -0
- package/eventSources/EventRoutingContradictsEventSource.ts +10 -0
- package/eventSources/EventSourceDefinition.ts +27 -0
- package/eventSources/EventSources.ts +93 -0
- package/eventSources/EventStreamDefinition.ts +18 -0
- package/eventSources/EventStreamDoesNotBelongToEventSource.ts +10 -0
- package/eventSources/EventStreamRequiresEventSource.ts +10 -0
- package/eventSources/IEventSources.ts +33 -0
- package/eventSources/ResolvedEventRouting.ts +78 -0
- package/eventSources/UnknownEventSource.ts +10 -0
- package/eventSources/eventSource.ts +116 -0
- package/eventSources/for_EventSources/against_a_kernel/when_appending_through_registered_sources.integration.spec.ts +106 -0
- package/eventSources/for_EventSources/when_appending_through_a_definition.spec.ts +190 -0
- package/eventSources/for_EventSources/when_batch_requires_differing_guards.spec.ts +139 -0
- package/eventSources/for_EventSources/when_discovering_and_registering.spec.ts +94 -0
- package/eventSources/index.ts +19 -0
- package/events/EventContext.ts +14 -0
- package/events/InvalidNamedTag.ts +13 -0
- package/events/NamedTag.ts +44 -0
- package/events/WireEventContext.ts +2 -0
- package/events/for_EventContext/with_event_source.spec.ts +22 -0
- package/events/for_NamedTag/when_constructing/with_invalid_values.spec.ts +17 -0
- package/events/for_NamedTag/when_constructing/with_valid_values.spec.ts +19 -0
- package/events/for_mergeNamedTags/when_merging/with_event_and_call_tags.spec.ts +31 -0
- package/events/for_mergeNamedTags/when_merging/with_invalid_entries.spec.ts +17 -0
- package/events/for_toClientEventContext/when_converting_named_tags.spec.ts +31 -0
- package/events/index.ts +3 -0
- package/events/mergeNamedTags.ts +37 -0
- package/events/toClientEventContext.ts +4 -1
- package/for_EventStore/when_implementing_a_legacy_event_store.spec.ts +19 -0
- package/index.ts +3 -0
- package/package.json +6 -6
- package/projections/eventContextPropertyExpression.ts +3 -1
- package/testing/EventScenario.event-sources.spec.ts +34 -0
- package/testing/InProcessEventSequence.ts +17 -7
- package/testing/ReactorScenario.ts +6 -0
- package/testing/for_EventScenario/when_appending_named_tags/with_named_tags.spec.ts +48 -0
- package/testing/for_ReactorScenario/when_recording_side_effects/with_named_tags.spec.ts +119 -0
- package/testing/for_ReadModelScenario/when_seeding_with_options/with_named_tags.spec.ts +35 -0
- package/testing/projections/ProjectionReadModelProcessor.ts +2 -1
- package/testing/singleAppendRoute.ts +13 -1
- package/transactions/IUnitOfWork.ts +4 -1
- package/transactions/TransactionalAppendOptions.ts +17 -0
- package/transactions/TransactionalEventRouting.ts +16 -0
- package/transactions/UnitOfWork.ts +22 -2
- package/transactions/for_UnitOfWork/when_committing_events_with_event_source_routing.spec.ts +41 -0
- package/transactions/for_UnitOfWork/when_committing_events_with_named_tags.spec.ts +112 -0
- package/transactions/index.ts +2 -0
- package/types/DecoratorType.ts +4 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventStreamDoesNotBelongToEventSource.js","sourceRoot":"","sources":["../../eventSources/EventStreamDoesNotBelongToEventSource.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,8EAA8E;AAC9E,MAAM,OAAO,qCAAsC,SAAQ,KAAK;IACvC,WAAW;IAAmB,MAAM;IAAzD,YAAqB,WAAmB,EAAW,MAAc;QAC7D,KAAK,CAAC,qBAAqB,MAAM,0CAA0C,WAAW,IAAI,CAAC,CAAC;2BAD3E,WAAW;sBAAmB,MAAM;QAErD,IAAI,CAAC,IAAI,GAAG,uCAAuC,CAAC;IACxD,CAAC;CACJ"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Thrown when an append names a stream without naming the event source that declares it. */
|
|
2
|
+
export declare class EventStreamRequiresEventSource extends Error {
|
|
3
|
+
readonly stream: string;
|
|
4
|
+
constructor(stream: string);
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=EventStreamRequiresEventSource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventStreamRequiresEventSource.d.ts","sourceRoot":"","sources":["../../eventSources/EventStreamRequiresEventSource.ts"],"names":[],"mappings":"AAGA,6FAA6F;AAC7F,qBAAa,8BAA+B,SAAQ,KAAK;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM;IAAnC,YAAqB,MAAM,EAAE,MAAM,EAGlC;CACJ"}
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
/** Thrown when an append names a stream without naming the event source that declares it. */
|
|
4
|
+
export class EventStreamRequiresEventSource extends Error {
|
|
5
|
+
stream;
|
|
6
|
+
constructor(stream) {
|
|
7
|
+
super(`The event stream '${stream}' can only be used together with an event source.`);
|
|
8
|
+
this.stream = stream;
|
|
9
|
+
this.name = 'EventStreamRequiresEventSource';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=EventStreamRequiresEventSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventStreamRequiresEventSource.js","sourceRoot":"","sources":["../../eventSources/EventStreamRequiresEventSource.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,6FAA6F;AAC7F,MAAM,OAAO,8BAA+B,SAAQ,KAAK;IAChC,MAAM;IAA3B,YAAqB,MAAc;QAC/B,KAAK,CAAC,qBAAqB,MAAM,mDAAmD,CAAC,CAAC;sBADrE,MAAM;QAEvB,IAAI,CAAC,IAAI,GAAG,gCAAgC,CAAC;IACjD,CAAC;CACJ"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Constructor } from '@cratis/fundamentals';
|
|
2
|
+
import type { EventSourceDefinition } from './EventSourceDefinition.js';
|
|
3
|
+
/**
|
|
4
|
+
* Defines the discovery and registration of event source definitions.
|
|
5
|
+
*/
|
|
6
|
+
export interface IEventSources {
|
|
7
|
+
/** Gets all discovered event source definitions. */
|
|
8
|
+
readonly all: ReadonlyArray<EventSourceDefinition>;
|
|
9
|
+
/**
|
|
10
|
+
* Discovers the event source definitions from the client artifacts.
|
|
11
|
+
* @throws DuplicateEventSourceName when two definitions share a name.
|
|
12
|
+
* @throws DuplicateEventStreamName when a definition declares the same stream twice.
|
|
13
|
+
*/
|
|
14
|
+
discover(): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Registers the discovered definitions with the Kernel. Registration is an upsert; the Kernel retains
|
|
17
|
+
* historical definitions that are no longer registered. Does nothing when there are no definitions.
|
|
18
|
+
*/
|
|
19
|
+
register(): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Gets the definition by class or name.
|
|
22
|
+
* @param eventSource - The class decorated with `@eventSource`, or the definition name.
|
|
23
|
+
* @throws UnknownEventSource when there is no such definition.
|
|
24
|
+
*/
|
|
25
|
+
getFor(eventSource: Constructor | string): EventSourceDefinition;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=IEventSources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEventSources.d.ts","sourceRoot":"","sources":["../../eventSources/IEventSources.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAExE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,oDAAoD;IACpD,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAC;IAEnD;;;;OAIG;IACH,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1B;;;OAGG;IACH,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1B;;;;OAIG;IACH,MAAM,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,GAAG,qBAAqB,CAAC;CACpE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEventSources.js","sourceRoot":"","sources":["../../eventSources/IEventSources.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Constructor } from '@cratis/fundamentals';
|
|
2
|
+
import type { ConcurrencyDimensionFlags } from './ConcurrencyDimensions.js';
|
|
3
|
+
import type { EventSourceDefinition } from './EventSourceDefinition.js';
|
|
4
|
+
import type { EventStreamDefinition } from './EventStreamDefinition.js';
|
|
5
|
+
import type { IEventSources } from './IEventSources.js';
|
|
6
|
+
/** The explicit routing a caller supplied next to a definition. */
|
|
7
|
+
export interface ExplicitRouting {
|
|
8
|
+
/** Explicit event source type, if any. */
|
|
9
|
+
sourceType?: string;
|
|
10
|
+
/** Explicit event stream type, if any. */
|
|
11
|
+
streamType?: string;
|
|
12
|
+
}
|
|
13
|
+
/** The routing of an append resolved through an event source definition. */
|
|
14
|
+
export declare class ResolvedEventRouting {
|
|
15
|
+
readonly definition: EventSourceDefinition;
|
|
16
|
+
readonly stream?: EventStreamDefinition | undefined;
|
|
17
|
+
private constructor();
|
|
18
|
+
/** The registered event source name written on the event. */
|
|
19
|
+
get eventSource(): string;
|
|
20
|
+
/** The event source type written on the event. */
|
|
21
|
+
get sourceType(): string;
|
|
22
|
+
/** The event stream type to write, or undefined to let the Kernel choose. */
|
|
23
|
+
get streamType(): string | undefined;
|
|
24
|
+
/** The concurrency dimensions that apply: the stream's when it declares any, otherwise the source's. */
|
|
25
|
+
get dimensions(): ConcurrencyDimensionFlags;
|
|
26
|
+
/**
|
|
27
|
+
* Resolves the routing of an append.
|
|
28
|
+
* @param eventSources - The event sources; undefined when the store has none.
|
|
29
|
+
* @param eventSource - The definition class or name; undefined for a legacy append.
|
|
30
|
+
* @param stream - The declared stream name, if any.
|
|
31
|
+
* @param explicit - Explicit routing that must not contradict the definition.
|
|
32
|
+
* @returns The routing, or undefined when no definition is involved.
|
|
33
|
+
* @throws UnknownEventSource, EventStreamDoesNotBelongToEventSource, EventRoutingContradictsEventSource, EventStreamRequiresEventSource.
|
|
34
|
+
*/
|
|
35
|
+
static resolve(eventSources: IEventSources | undefined, eventSource: Constructor | string | undefined, stream: string | undefined, explicit?: ExplicitRouting): ResolvedEventRouting | undefined;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=ResolvedEventRouting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResolvedEventRouting.d.ts","sourceRoot":"","sources":["../../eventSources/ResolvedEventRouting.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMxD,mEAAmE;AACnE,MAAM,WAAW,eAAe;IAC5B,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,4EAA4E;AAC5E,qBAAa,oBAAoB;IACT,QAAQ,CAAC,UAAU,EAAE,qBAAqB;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,qBAAqB;IAAvG,OAAO,eAAoG;IAE3G,6DAA6D;IAC7D,IAAI,WAAW,IAAI,MAAM,CAAiC;IAE1D,kDAAkD;IAClD,IAAI,UAAU,IAAI,MAAM,CAAiC;IAEzD,6EAA6E;IAC7E,IAAI,UAAU,IAAI,MAAM,GAAG,SAAS,CAA8B;IAElE,wGAAwG;IACxG,IAAI,UAAU,IAAI,yBAAyB,CAE1C;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,OAAO,CACV,YAAY,EAAE,aAAa,GAAG,SAAS,EACvC,WAAW,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,EAC7C,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,QAAQ,GAAE,eAAoB,GAC/B,oBAAoB,GAAG,SAAS,CAsBlC;CACJ"}
|
|
@@ -0,0 +1,60 @@
|
|
|
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 { EventRoutingContradictsEventSource } from './EventRoutingContradictsEventSource.js';
|
|
4
|
+
import { EventStreamDoesNotBelongToEventSource } from './EventStreamDoesNotBelongToEventSource.js';
|
|
5
|
+
import { EventStreamRequiresEventSource } from './EventStreamRequiresEventSource.js';
|
|
6
|
+
import { UnknownEventSource } from './UnknownEventSource.js';
|
|
7
|
+
/** The routing of an append resolved through an event source definition. */
|
|
8
|
+
export class ResolvedEventRouting {
|
|
9
|
+
definition;
|
|
10
|
+
stream;
|
|
11
|
+
constructor(definition, stream) {
|
|
12
|
+
this.definition = definition;
|
|
13
|
+
this.stream = stream;
|
|
14
|
+
}
|
|
15
|
+
/** The registered event source name written on the event. */
|
|
16
|
+
get eventSource() { return this.definition.name; }
|
|
17
|
+
/** The event source type written on the event. */
|
|
18
|
+
get sourceType() { return this.definition.name; }
|
|
19
|
+
/** The event stream type to write, or undefined to let the Kernel choose. */
|
|
20
|
+
get streamType() { return this.stream?.name; }
|
|
21
|
+
/** The concurrency dimensions that apply: the stream's when it declares any, otherwise the source's. */
|
|
22
|
+
get dimensions() {
|
|
23
|
+
return this.stream && this.stream.concurrency !== 0 ? this.stream.concurrency : this.definition.concurrency;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Resolves the routing of an append.
|
|
27
|
+
* @param eventSources - The event sources; undefined when the store has none.
|
|
28
|
+
* @param eventSource - The definition class or name; undefined for a legacy append.
|
|
29
|
+
* @param stream - The declared stream name, if any.
|
|
30
|
+
* @param explicit - Explicit routing that must not contradict the definition.
|
|
31
|
+
* @returns The routing, or undefined when no definition is involved.
|
|
32
|
+
* @throws UnknownEventSource, EventStreamDoesNotBelongToEventSource, EventRoutingContradictsEventSource, EventStreamRequiresEventSource.
|
|
33
|
+
*/
|
|
34
|
+
static resolve(eventSources, eventSource, stream, explicit = {}) {
|
|
35
|
+
if (eventSource === undefined) {
|
|
36
|
+
if (stream !== undefined)
|
|
37
|
+
throw new EventStreamRequiresEventSource(stream);
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
if (!eventSources)
|
|
41
|
+
throw new UnknownEventSource(typeof eventSource === 'string' ? eventSource : eventSource.name);
|
|
42
|
+
const definition = eventSources.getFor(eventSource);
|
|
43
|
+
const isSet = (value, unspecified) => value !== undefined && value !== '' && !unspecified.includes(value);
|
|
44
|
+
if (isSet(explicit.sourceType, ['Default', 'Unspecified']) && explicit.sourceType !== definition.name) {
|
|
45
|
+
throw new EventRoutingContradictsEventSource(definition.name, 'event source type', definition.name, explicit.sourceType);
|
|
46
|
+
}
|
|
47
|
+
const explicitStream = isSet(explicit.streamType, ['All']) ? explicit.streamType : undefined;
|
|
48
|
+
if (stream !== undefined && explicitStream !== undefined && stream !== explicitStream) {
|
|
49
|
+
throw new EventRoutingContradictsEventSource(definition.name, 'event stream type', stream, explicitStream);
|
|
50
|
+
}
|
|
51
|
+
const name = stream ?? explicitStream;
|
|
52
|
+
if (name === undefined)
|
|
53
|
+
return new ResolvedEventRouting(definition);
|
|
54
|
+
const found = definition.streams.find(candidate => candidate.name === name);
|
|
55
|
+
if (!found)
|
|
56
|
+
throw new EventStreamDoesNotBelongToEventSource(definition.name, name);
|
|
57
|
+
return new ResolvedEventRouting(definition, found);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=ResolvedEventRouting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResolvedEventRouting.js","sourceRoot":"","sources":["../../eventSources/ResolvedEventRouting.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAOrG,OAAO,EAAE,kCAAkC,EAAE,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAE,qCAAqC,EAAE,MAAM,4CAA4C,CAAC;AACnG,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAW7D,4EAA4E;AAC5E,MAAM,OAAO,oBAAoB;IACA,UAAU;IAAkC,MAAM;IAA/E,YAA6B,UAAiC,EAAW,MAA8B;0BAA1E,UAAU;sBAAkC,MAAM;IAA2B,CAAC;IAE3G,6DAA6D;IAC7D,IAAI,WAAW,KAAa,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IAE1D,kDAAkD;IAClD,IAAI,UAAU,KAAa,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IAEzD,6EAA6E;IAC7E,IAAI,UAAU,KAAyB,OAAO,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;IAElE,wGAAwG;IACxG,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;IAChH,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,OAAO,CACV,YAAuC,EACvC,WAA6C,EAC7C,MAA0B,EAC1B,QAAQ,GAAoB,EAAE;QAE9B,IAAI,WAAW,KAA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AI,KAAK,SAAS;YAAE,OAAO,IAAI,oBAAoB,CAAC,UAAU,CAAC,CAAC;QACpE,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;QAC5E,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,qCAAqC,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACnF,OAAO,IAAI,oBAAoB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACvD,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnknownEventSource.d.ts","sourceRoot":"","sources":["../../eventSources/UnknownEventSource.ts"],"names":[],"mappings":"AAGA,uFAAuF;AACvF,qBAAa,kBAAmB,SAAQ,KAAK;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM;IAAxC,YAAqB,WAAW,EAAE,MAAM,EAGvC;CACJ"}
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
/** Thrown when an append names an event source that is not a discovered definition. */
|
|
4
|
+
export class UnknownEventSource extends Error {
|
|
5
|
+
eventSource;
|
|
6
|
+
constructor(eventSource) {
|
|
7
|
+
super(`The event source '${eventSource}' is not a discovered event source definition.`);
|
|
8
|
+
this.eventSource = eventSource;
|
|
9
|
+
this.name = 'UnknownEventSource';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=UnknownEventSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnknownEventSource.js","sourceRoot":"","sources":["../../eventSources/UnknownEventSource.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,uFAAuF;AACvF,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IACpB,WAAW;IAAhC,YAAqB,WAAmB;QACpC,KAAK,CAAC,qBAAqB,WAAW,gDAAgD,CAAC,CAAC;2BADvE,WAAW;QAE5B,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACrC,CAAC;CACJ"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import type { ChronicleClassDecorator } from '../types/standardDecoratorMetadata.js';
|
|
3
|
+
import type { ConcurrencyDimensionFlags } from './ConcurrencyDimensions.js';
|
|
4
|
+
/** Optional settings for {@link eventSource}. */
|
|
5
|
+
export interface EventSourceOptions {
|
|
6
|
+
/** The stable name. Defaults to the class name without a trailing `EventSource`. */
|
|
7
|
+
name?: string;
|
|
8
|
+
/** The description of the event source. */
|
|
9
|
+
description?: string;
|
|
10
|
+
/** The default dimensions that take part in concurrency checks; combine {@link ConcurrencyDimensions} values with `|`. */
|
|
11
|
+
concurrency?: ConcurrencyDimensionFlags;
|
|
12
|
+
}
|
|
13
|
+
/** Optional settings for {@link eventStream}. */
|
|
14
|
+
export interface EventStreamOptions {
|
|
15
|
+
/** The description of the stream. */
|
|
16
|
+
description?: string;
|
|
17
|
+
/** The dimensions that take part in concurrency checks for the stream. Falls back to the event source when omitted or none. */
|
|
18
|
+
concurrency?: ConcurrencyDimensionFlags;
|
|
19
|
+
}
|
|
20
|
+
/** Metadata recorded by {@link eventSource}. */
|
|
21
|
+
export interface EventSourceMetadata {
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly description: string;
|
|
24
|
+
readonly concurrency: ConcurrencyDimensionFlags;
|
|
25
|
+
}
|
|
26
|
+
/** Metadata recorded by {@link eventStream}. */
|
|
27
|
+
export interface EventStreamMetadata {
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly description: string;
|
|
30
|
+
readonly concurrency: ConcurrencyDimensionFlags;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Declares a class as an event source definition, discovered and registered with the Kernel at startup.
|
|
34
|
+
* The definition is not tied to event types; an append routes through it with `AppendOptions.eventSource`.
|
|
35
|
+
* Supports legacy and standard class decorators.
|
|
36
|
+
* @param options - Optional name (defaults to the class name without a trailing `EventSource`), description and concurrency.
|
|
37
|
+
* @returns A class decorator.
|
|
38
|
+
*/
|
|
39
|
+
export declare function eventSource(options?: EventSourceOptions): ChronicleClassDecorator;
|
|
40
|
+
/**
|
|
41
|
+
* Declares a stream of an event source. Repeat the decorator for several streams.
|
|
42
|
+
* Only takes effect on a class that is also decorated with {@link eventSource}.
|
|
43
|
+
* @param name - The stable name of the stream, which is the event stream type of appended events.
|
|
44
|
+
* @param options - Optional description and concurrency dimensions.
|
|
45
|
+
* @returns A class decorator.
|
|
46
|
+
*/
|
|
47
|
+
export declare function eventStream(name: string, options?: EventStreamOptions): ChronicleClassDecorator;
|
|
48
|
+
/**
|
|
49
|
+
* Gets the event source metadata declared on a class.
|
|
50
|
+
* @param target - The class constructor.
|
|
51
|
+
* @returns The metadata, or undefined when the class is not an event source.
|
|
52
|
+
*/
|
|
53
|
+
export declare function getEventSourceMetadata(target: Function): EventSourceMetadata | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Gets the streams declared on a class, in declaration order (duplicates are preserved so they can be rejected).
|
|
56
|
+
* @param target - The class constructor.
|
|
57
|
+
* @returns The declared streams.
|
|
58
|
+
*/
|
|
59
|
+
export declare function getEventStreamsFor(target: Function): ReadonlyArray<EventStreamMetadata>;
|
|
60
|
+
//# sourceMappingURL=eventSource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventSource.d.ts","sourceRoot":"","sources":["../../eventSources/eventSource.ts"],"names":[],"mappings":"AAGA,OAAO,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAM5E,iDAAiD;AACjD,MAAM,WAAW,kBAAkB;IAC/B,oFAAoF;IACpF,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,2CAA2C;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,0HAA0H;IAC1H,WAAW,CAAC,EAAE,yBAAyB,CAAC;CAC3C;AAED,iDAAiD;AACjD,MAAM,WAAW,kBAAkB;IAC/B,qCAAqC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,+HAA+H;IAC/H,WAAW,CAAC,EAAE,yBAAyB,CAAC;CAC3C;AAED,gDAAgD;AAChD,MAAM,WAAW,mBAAmB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,yBAAyB,CAAC;CACnD;AAED,gDAAgD;AAChD,MAAM,WAAW,mBAAmB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,yBAAyB,CAAC;CACnD;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,uBAAuB,CAmBjF;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,uBAAuB,CAS/F;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,QAAQ,GAAG,mBAAmB,GAAG,SAAS,CAExF;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,QAAQ,GAAG,aAAa,CAAC,mBAAmB,CAAC,CAEvF"}
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
import { DecoratorType, TypeDiscoverer } from '../types/index.js';
|
|
5
|
+
const EVENT_SOURCE_METADATA_KEY = 'chronicle:eventSource';
|
|
6
|
+
const EVENT_STREAMS_METADATA_KEY = 'chronicle:eventSource:streams';
|
|
7
|
+
let registrationCounter = 0;
|
|
8
|
+
/**
|
|
9
|
+
* Declares a class as an event source definition, discovered and registered with the Kernel at startup.
|
|
10
|
+
* The definition is not tied to event types; an append routes through it with `AppendOptions.eventSource`.
|
|
11
|
+
* Supports legacy and standard class decorators.
|
|
12
|
+
* @param options - Optional name (defaults to the class name without a trailing `EventSource`), description and concurrency.
|
|
13
|
+
* @returns A class decorator.
|
|
14
|
+
*/
|
|
15
|
+
export function eventSource(options) {
|
|
16
|
+
return ((target, context) => {
|
|
17
|
+
let constructor = target;
|
|
18
|
+
const metadata = {
|
|
19
|
+
name: options?.name ?? defaultNameFor(constructor),
|
|
20
|
+
description: options?.description ?? '',
|
|
21
|
+
concurrency: options?.concurrency ?? 0
|
|
22
|
+
};
|
|
23
|
+
Reflect.defineMetadata(EVENT_SOURCE_METADATA_KEY, metadata, target);
|
|
24
|
+
TypeDiscoverer.default.register(DecoratorType.EventSource, constructor, `${metadata.name}#${registrationCounter++}`);
|
|
25
|
+
context?.addInitializer(function () {
|
|
26
|
+
if (this !== constructor) {
|
|
27
|
+
constructor = this;
|
|
28
|
+
Reflect.defineMetadata(EVENT_SOURCE_METADATA_KEY, metadata, constructor);
|
|
29
|
+
Reflect.defineMetadata(EVENT_STREAMS_METADATA_KEY, Reflect.getOwnMetadata(EVENT_STREAMS_METADATA_KEY, target), constructor);
|
|
30
|
+
TypeDiscoverer.default.register(DecoratorType.EventSource, constructor, `${metadata.name}#${registrationCounter++}`);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Declares a stream of an event source. Repeat the decorator for several streams.
|
|
37
|
+
* Only takes effect on a class that is also decorated with {@link eventSource}.
|
|
38
|
+
* @param name - The stable name of the stream, which is the event stream type of appended events.
|
|
39
|
+
* @param options - Optional description and concurrency dimensions.
|
|
40
|
+
* @returns A class decorator.
|
|
41
|
+
*/
|
|
42
|
+
export function eventStream(name, options) {
|
|
43
|
+
return ((target) => {
|
|
44
|
+
const existing = Reflect.getOwnMetadata(EVENT_STREAMS_METADATA_KEY, target) ?? [];
|
|
45
|
+
// Decorators evaluate bottom-up; unshift keeps declaration order.
|
|
46
|
+
Reflect.defineMetadata(EVENT_STREAMS_METADATA_KEY, [
|
|
47
|
+
{ name, description: options?.description ?? '', concurrency: options?.concurrency ?? 0 },
|
|
48
|
+
...existing
|
|
49
|
+
], target);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Gets the event source metadata declared on a class.
|
|
54
|
+
* @param target - The class constructor.
|
|
55
|
+
* @returns The metadata, or undefined when the class is not an event source.
|
|
56
|
+
*/
|
|
57
|
+
export function getEventSourceMetadata(target) {
|
|
58
|
+
return Reflect.getOwnMetadata(EVENT_SOURCE_METADATA_KEY, target);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Gets the streams declared on a class, in declaration order (duplicates are preserved so they can be rejected).
|
|
62
|
+
* @param target - The class constructor.
|
|
63
|
+
* @returns The declared streams.
|
|
64
|
+
*/
|
|
65
|
+
export function getEventStreamsFor(target) {
|
|
66
|
+
return Reflect.getOwnMetadata(EVENT_STREAMS_METADATA_KEY, target) ?? [];
|
|
67
|
+
}
|
|
68
|
+
function defaultNameFor(type) {
|
|
69
|
+
const suffix = 'EventSource';
|
|
70
|
+
return type.name.length > suffix.length && type.name.endsWith(suffix) ? type.name.slice(0, -suffix.length) : type.name;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=eventSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventSource.js","sourceRoot":"","sources":["../../eventSources/eventSource.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAA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rencyDimensions.js';
|
|
2
|
+
export type { ConcurrencyDimensionFlags } from './ConcurrencyDimensions.js';
|
|
3
|
+
export type { EventSourceDefinition } from './EventSourceDefinition.js';
|
|
4
|
+
export type { EventStreamDefinition } from './EventStreamDefinition.js';
|
|
5
|
+
export { eventSource, eventStream, getEventSourceMetadata, getEventStreamsFor } from './eventSource.js';
|
|
6
|
+
export type { EventSourceOptions, EventStreamOptions, EventSourceMetadata, EventStreamMetadata } from './eventSource.js';
|
|
7
|
+
export type { IEventSources } from './IEventSources.js';
|
|
8
|
+
export { EventSources } from './EventSources.js';
|
|
9
|
+
export { ResolvedEventRouting } from './ResolvedEventRouting.js';
|
|
10
|
+
export type { ExplicitRouting } from './ResolvedEventRouting.js';
|
|
11
|
+
export { UnknownEventSource } from './UnknownEventSource.js';
|
|
12
|
+
export { DuplicateEventSourceName } from './DuplicateEventSourceName.js';
|
|
13
|
+
export { DuplicateEventStreamName } from './DuplicateEventStreamName.js';
|
|
14
|
+
export { EventStreamDoesNotBelongToEventSource } from './EventStreamDoesNotBelongToEventSource.js';
|
|
15
|
+
export { EventRoutingContradictsEventSource } from './EventRoutingContradictsEventSource.js';
|
|
16
|
+
export { EventStreamRequiresEventSource } from './EventStreamRequiresEventSource.js';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../eventSources/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,YAAY,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAC5E,YAAY,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,YAAY,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACxG,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACzH,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,YAAY,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,qCAAqC,EAAE,MAAM,4CAA4C,CAAC;AACnG,OAAO,EAAE,kCAAkC,EAAE,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
export { ConcurrencyDimensions } from './ConcurrencyDimensions.js';
|
|
4
|
+
export { eventSource, eventStream, getEventSourceMetadata, getEventStreamsFor } from './eventSource.js';
|
|
5
|
+
export { EventSources } from './EventSources.js';
|
|
6
|
+
export { ResolvedEventRouting } from './ResolvedEventRouting.js';
|
|
7
|
+
export { UnknownEventSource } from './UnknownEventSource.js';
|
|
8
|
+
export { DuplicateEventSourceName } from './DuplicateEventSourceName.js';
|
|
9
|
+
export { DuplicateEventStreamName } from './DuplicateEventStreamName.js';
|
|
10
|
+
export { EventStreamDoesNotBelongToEventSource } from './EventStreamDoesNotBelongToEventSource.js';
|
|
11
|
+
export { EventRoutingContradictsEventSource } from './EventRoutingContradictsEventSource.js';
|
|
12
|
+
export { EventStreamRequiresEventSource } from './EventStreamRequiresEventSource.js';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../eventSources/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAInE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGxG,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,qCAAqC,EAAE,MAAM,4CAA4C,CAAC;AACnG,OAAO,EAAE,kCAAkC,EAAE,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EventType } from './EventType.js';
|
|
2
2
|
import { CausationEntry } from './CausationEntry.js';
|
|
3
3
|
import { Tag } from './Tag.js';
|
|
4
|
+
import type { NamedTag } from './NamedTag.js';
|
|
4
5
|
import type { Identity } from '../identity/Identity.js';
|
|
5
6
|
/**
|
|
6
7
|
* Represents contextual information about an appended event.
|
|
@@ -20,6 +21,11 @@ export interface EventContext {
|
|
|
20
21
|
readonly eventStreamType?: string;
|
|
21
22
|
/** The stream identifier returned by the kernel. */
|
|
22
23
|
readonly eventStreamId?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The registered event source definition the event was appended through.
|
|
26
|
+
* Undefined for events appended without a definition, including events stored before event sources existed.
|
|
27
|
+
*/
|
|
28
|
+
readonly eventSource?: string;
|
|
23
29
|
/** The compliance subject returned by the kernel. */
|
|
24
30
|
readonly subject?: string;
|
|
25
31
|
/** The persisted event hash. */
|
|
@@ -38,5 +44,11 @@ export interface EventContext {
|
|
|
38
44
|
readonly causation: ReadonlyArray<CausationEntry>;
|
|
39
45
|
/** The tags the event carries. */
|
|
40
46
|
readonly tags: ReadonlyArray<Tag>;
|
|
47
|
+
/**
|
|
48
|
+
* The structured named tags the event carries, in the order the kernel stored them.
|
|
49
|
+
* Always present on events read from or delivered by the kernel (empty when the event has none);
|
|
50
|
+
* optional so that contexts constructed by hand remain valid.
|
|
51
|
+
*/
|
|
52
|
+
readonly namedTags?: ReadonlyArray<NamedTag>;
|
|
41
53
|
}
|
|
42
54
|
//# sourceMappingURL=EventContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventContext.d.ts","sourceRoot":"","sources":["../../events/EventContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,8DAA8D;IAC9D,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAEhC,iDAAiD;IACjD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAE/B,oDAAoD;IACpD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE7B,kDAAkD;IAClD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B,8CAA8C;IAC9C,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAElC,8CAA8C;IAC9C,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAElC,oDAAoD;IACpD,QAAQ,C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C,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B,8CAA8C;IAC9C,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAElC,8CAA8C;IAC9C,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAElC,oDAAoD;IACpD,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAEhC;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B,qDAAqD;IACrD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAE1B,gCAAgC;IAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEvB,8CAA8C;IAC9C,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAE7B,qDAAqD;IACrD,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAEnC,6BAA6B;IAC7B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAE9B,6CAA6C;IAC7C,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC;IAExB,gDAAgD;IAChD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAE/B,yCAAyC;IACzC,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IAElD,kCAAkC;IAClC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IAElC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;CAChD"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The error that is thrown when a named tag has a blank name or a non-string value, or a named tag
|
|
3
|
+
* collection contains an entry that is not a named tag. Mirrors the .NET client's `InvalidNamedTag`.
|
|
4
|
+
*/
|
|
5
|
+
export declare class InvalidNamedTag extends Error {
|
|
6
|
+
constructor();
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=InvalidNamedTag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InvalidNamedTag.d.ts","sourceRoot":"","sources":["../../events/InvalidNamedTag.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACtC,cAGC;CACJ"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
/**
|
|
4
|
+
* The error that is thrown when a named tag has a blank name or a non-string value, or a named tag
|
|
5
|
+
* collection contains an entry that is not a named tag. Mirrors the .NET client's `InvalidNamedTag`.
|
|
6
|
+
*/
|
|
7
|
+
export class InvalidNamedTag extends Error {
|
|
8
|
+
constructor() {
|
|
9
|
+
super('Named tags require a nonblank name and a non-null value; named tag collections cannot contain null elements.');
|
|
10
|
+
this.name = 'InvalidNamedTag';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=InvalidNamedTag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InvalidNamedTag.js","sourceRoot":"","sources":["../../events/InvalidNamedTag.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACtC;QACI,KAAK,CAAC,8GAA8G,CAAC,CAAC;QACtH,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAClC,CAAC;CACJ"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Associates a name with an exact, opaque event tag value. Names and values are compared exactly
|
|
3
|
+
* (ordinal and case-sensitive); one name may carry several values on the same event.
|
|
4
|
+
* Mirrors the .NET client's `NamedTag`.
|
|
5
|
+
*/
|
|
6
|
+
export declare class NamedTag {
|
|
7
|
+
/** The name of the tag. Never blank. */
|
|
8
|
+
readonly name: string;
|
|
9
|
+
/** The exact, opaque value of the tag. May be empty. */
|
|
10
|
+
readonly value: string;
|
|
11
|
+
/**
|
|
12
|
+
* Initializes a new instance of {@link NamedTag}.
|
|
13
|
+
* @param name - The name. Must be a nonblank string.
|
|
14
|
+
* @param value - The opaque value. Must be a string; the empty string is allowed.
|
|
15
|
+
* @throws {@link InvalidNamedTag} when the name is blank or not a string, or the value is not a string.
|
|
16
|
+
*/
|
|
17
|
+
constructor(name: string, value: string);
|
|
18
|
+
/**
|
|
19
|
+
* Determines whether this tag has the same name and value as another, compared exactly.
|
|
20
|
+
* @param other - The tag to compare with.
|
|
21
|
+
* @returns True when both name and value are equal.
|
|
22
|
+
*/
|
|
23
|
+
equals(other: NamedTag): boolean;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=NamedTag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NamedTag.d.ts","sourceRoot":"","sources":["../../events/NamedTag.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,qBAAa,QAAQ;IACjB,wCAAwC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,wDAAwD;IACxD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB;;;;;OAKG;IACH,YAAY,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAOtC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAE/B;CACJ"}
|
|
@@ -0,0 +1,39 @@
|
|
|
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 { InvalidNamedTag } from './InvalidNamedTag.js';
|
|
4
|
+
// Matches .NET string.IsNullOrWhiteSpace, which also treats U+0085 and other Unicode white space as blank.
|
|
5
|
+
const blank = /^\p{White_Space}*$/u;
|
|
6
|
+
/**
|
|
7
|
+
* Associates a name with an exact, opaque event tag value. Names and values are compared exactly
|
|
8
|
+
* (ordinal and case-sensitive); one name may carry several values on the same event.
|
|
9
|
+
* Mirrors the .NET client's `NamedTag`.
|
|
10
|
+
*/
|
|
11
|
+
export class NamedTag {
|
|
12
|
+
/** The name of the tag. Never blank. */
|
|
13
|
+
name;
|
|
14
|
+
/** The exact, opaque value of the tag. May be empty. */
|
|
15
|
+
value;
|
|
16
|
+
/**
|
|
17
|
+
* Initializes a new instance of {@link NamedTag}.
|
|
18
|
+
* @param name - The name. Must be a nonblank string.
|
|
19
|
+
* @param value - The opaque value. Must be a string; the empty string is allowed.
|
|
20
|
+
* @throws {@link InvalidNamedTag} when the name is blank or not a string, or the value is not a string.
|
|
21
|
+
*/
|
|
22
|
+
constructor(name, value) {
|
|
23
|
+
if (typeof name !== 'string' || blank.test(name) || typeof value !== 'string') {
|
|
24
|
+
throw new InvalidNamedTag();
|
|
25
|
+
}
|
|
26
|
+
this.name = name;
|
|
27
|
+
this.value = value;
|
|
28
|
+
Object.freeze(this);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Determines whether this tag has the same name and value as another, compared exactly.
|
|
32
|
+
* @param other - The tag to compare with.
|
|
33
|
+
* @returns True when both name and value are equal.
|
|
34
|
+
*/
|
|
35
|
+
equals(other) {
|
|
36
|
+
return other instanceof NamedTag && other.name === this.name && other.value === this.value;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=NamedTag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NamedTag.js","sourceRoot":"","sources":["../../events/NamedTag.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,2GAA2G;AAC3G,MAAM,KAAK,GAAG,qBAAqB,CAAC;AAEpC;;;;GAIG;AACH,MAAM,OAAO,QAAQ;IACjB,wCAAwC;IAC/B,IAAI,CAAS;IAEtB,wDAAwD;IAC/C,KAAK,CAAS;IAEvB;;;;;OAKG;IACH,YAAY,IAAY,EAAE,KAAa;QACnC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC5E,MAAM,IAAI,eAAe,EAAE,CAAC;QAChC,CAAC;QACD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAe;QAClB,OAAO,KAAK,YAAY,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC;IAC/F,CAAC;CACJ"}
|
|
@@ -3,6 +3,8 @@ import type { AppendedEventResponse } from '@cratis/chronicle.contracts';
|
|
|
3
3
|
export type WireEventContext = Omit<NonNullable<AppendedEventResponse['Context']>, 'ObservationState'> & {
|
|
4
4
|
/** Numeric wire value shared by the generated observation-state enums. */
|
|
5
5
|
ObservationState: number;
|
|
6
|
+
/** The registered event source name; empty or absent when the event was not appended through a definition. */
|
|
7
|
+
EventSource?: string;
|
|
6
8
|
/** Store metadata is carried by observer deliveries, but not every read response. */
|
|
7
9
|
EventStore?: string;
|
|
8
10
|
/** Namespace metadata is carried by observer deliveries, but not every read response. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WireEventContext.d.ts","sourceRoot":"","sources":["../../events/WireEventContext.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEzE,2FAA2F;AAC3F,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,WAAW,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,EAAE,kBAAkB,CAAC,GAAG;IACrG,0EAA0E;IAC1E,gBAAgB,EAAE,MAAM,CAAC;IACzB,qFAAqF;IACrF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC"}
|
|
1
|
+
{"version":3,"file":"WireEventContext.d.ts","sourceRoot":"","sources":["../../events/WireEventContext.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEzE,2FAA2F;AAC3F,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,WAAW,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,EAAE,kBAAkB,CAAC,GAAG;IACrG,0EAA0E;IAC1E,gBAAgB,EAAE,MAAM,CAAC;IACzB,8GAA8G;IAC9G,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qFAAqF;IACrF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC"}
|
package/dist/events/index.d.ts
CHANGED
|
@@ -17,6 +17,9 @@ export { filterEventsByTag, getFilterTagsFor } from './filterEventsByTagDecorato
|
|
|
17
17
|
export { eventSourceType, getEventSourceTypeFor } from './eventSourceTypeDecorator.js';
|
|
18
18
|
export { eventStreamType, getEventStreamTypeFor } from './eventStreamTypeDecorator.js';
|
|
19
19
|
export { mergeTags } from './mergeTags.js';
|
|
20
|
+
export { NamedTag } from './NamedTag.js';
|
|
21
|
+
export { InvalidNamedTag } from './InvalidNamedTag.js';
|
|
22
|
+
export { mergeNamedTags } from './mergeNamedTags.js';
|
|
20
23
|
export * from './constraints/index.js';
|
|
21
24
|
export * from './migrations/index.js';
|
|
22
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../events/index.ts"],"names":[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C,cAAc,uBAAuB,CAAC"}
|
package/dist/events/index.js
CHANGED
|
@@ -14,6 +14,9 @@ export { filterEventsByTag, getFilterTagsFor } from './filterEventsByTagDecorato
|
|
|
14
14
|
export { eventSourceType, getEventSourceTypeFor } from './eventSourceTypeDecorator.js';
|
|
15
15
|
export { eventStreamType, getEventStreamTypeFor } from './eventStreamTypeDecorator.js';
|
|
16
16
|
export { mergeTags } from './mergeTags.js';
|
|
17
|
+
export { NamedTag } from './NamedTag.js';
|
|
18
|
+
export { InvalidNamedTag } from './InvalidNamedTag.js';
|
|
19
|
+
export { mergeNamedTags } from './mergeNamedTags.js';
|
|
17
20
|
export * from './constraints/index.js';
|
|
18
21
|
export * from './migrations/index.js';
|
|
19
22
|
//# sourceMappingURL=index.js.map
|
package/dist/events/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../events/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,uCAAuC,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAMpI,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,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