@cratis/chronicle 3.1.1 → 4.0.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 +1 -1
- package/compliance/ComplianceContracts.ts +59 -0
- package/compliance/IPIIManager.ts +12 -0
- package/compliance/PIIManager.spec.ts +50 -0
- package/compliance/PIIManager.ts +9 -0
- package/compliance/PIINotSupportedOnEventSourceId.ts +21 -0
- package/compliance/index.ts +2 -0
- package/compliance/pii.spec.ts +37 -0
- package/compliance/pii.ts +16 -1
- package/compliance/subject.spec.ts +45 -0
- package/compliance/subject.ts +64 -0
- package/dist/EventStore.js +1 -1
- package/dist/EventStore.js.map +1 -1
- package/dist/compliance/ComplianceContracts.d.ts +31 -0
- package/dist/compliance/ComplianceContracts.d.ts.map +1 -1
- package/dist/compliance/ComplianceContracts.js +52 -0
- package/dist/compliance/ComplianceContracts.js.map +1 -1
- package/dist/compliance/IPIIManager.d.ts +11 -0
- package/dist/compliance/IPIIManager.d.ts.map +1 -1
- package/dist/compliance/PIIManager.d.ts +2 -0
- package/dist/compliance/PIIManager.d.ts.map +1 -1
- package/dist/compliance/PIIManager.js +8 -0
- package/dist/compliance/PIIManager.js.map +1 -1
- package/dist/compliance/PIINotSupportedOnEventSourceId.d.ts +11 -0
- package/dist/compliance/PIINotSupportedOnEventSourceId.d.ts.map +1 -0
- package/dist/compliance/PIINotSupportedOnEventSourceId.js +19 -0
- package/dist/compliance/PIINotSupportedOnEventSourceId.js.map +1 -0
- package/dist/compliance/index.d.ts +2 -0
- package/dist/compliance/index.d.ts.map +1 -1
- package/dist/compliance/index.js +2 -0
- package/dist/compliance/index.js.map +1 -1
- package/dist/compliance/pii.d.ts.map +1 -1
- package/dist/compliance/pii.js +13 -1
- package/dist/compliance/pii.js.map +1 -1
- package/dist/compliance/subject.d.ts +39 -0
- package/dist/compliance/subject.d.ts.map +1 -0
- package/dist/compliance/subject.js +58 -0
- package/dist/compliance/subject.js.map +1 -0
- package/dist/eventSequences/AppendOptions.d.ts +8 -0
- package/dist/eventSequences/AppendOptions.d.ts.map +1 -1
- package/dist/eventSequences/EventForEventSourceId.d.ts +7 -0
- package/dist/eventSequences/EventForEventSourceId.d.ts.map +1 -1
- package/dist/eventSequences/EventSequence.d.ts.map +1 -1
- package/dist/eventSequences/EventSequence.js +17 -6
- package/dist/eventSequences/EventSequence.js.map +1 -1
- package/dist/events/EventContext.d.ts +3 -0
- package/dist/events/EventContext.d.ts.map +1 -1
- package/dist/events/Tag.d.ts +10 -0
- package/dist/events/Tag.d.ts.map +1 -0
- package/dist/events/Tag.js +16 -0
- package/dist/events/Tag.js.map +1 -0
- package/dist/events/filterEventsByTagDecorator.d.ts +35 -0
- package/dist/events/filterEventsByTagDecorator.d.ts.map +1 -0
- package/dist/events/filterEventsByTagDecorator.js +48 -0
- package/dist/events/filterEventsByTagDecorator.js.map +1 -0
- package/dist/events/index.d.ts +4 -0
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +4 -0
- package/dist/events/index.js.map +1 -1
- package/dist/events/mergeTags.d.ts +12 -0
- package/dist/events/mergeTags.d.ts.map +1 -0
- package/dist/events/mergeTags.js +26 -0
- package/dist/events/mergeTags.js.map +1 -0
- package/dist/events/tagDecorator.d.ts +38 -0
- package/dist/events/tagDecorator.d.ts.map +1 -0
- package/dist/events/tagDecorator.js +54 -0
- package/dist/events/tagDecorator.js.map +1 -0
- package/dist/observation/ObserverRunningState.d.ts +9 -15
- package/dist/observation/ObserverRunningState.d.ts.map +1 -1
- package/dist/observation/ObserverRunningState.js +8 -14
- package/dist/observation/ObserverRunningState.js.map +1 -1
- package/dist/observation/index.d.ts +1 -0
- package/dist/observation/index.d.ts.map +1 -1
- package/dist/observation/index.js +1 -0
- package/dist/observation/index.js.map +1 -1
- package/dist/observation/toObserverRunningState.d.ts +9 -0
- package/dist/observation/toObserverRunningState.d.ts.map +1 -0
- package/dist/observation/toObserverRunningState.js +26 -0
- package/dist/observation/toObserverRunningState.js.map +1 -0
- package/dist/projections/IProjections.d.ts +71 -1
- package/dist/projections/IProjections.d.ts.map +1 -1
- package/dist/projections/ProjectionQueryResult.d.ts +8 -0
- package/dist/projections/ProjectionQueryResult.d.ts.map +1 -0
- package/dist/projections/ProjectionQueryResult.js +4 -0
- package/dist/projections/ProjectionQueryResult.js.map +1 -0
- package/dist/projections/ProjectionState.d.ts +18 -0
- package/dist/projections/ProjectionState.d.ts.map +1 -0
- package/dist/projections/ProjectionState.js +4 -0
- package/dist/projections/ProjectionState.js.map +1 -0
- package/dist/projections/Projections.d.ts +46 -1
- package/dist/projections/Projections.d.ts.map +1 -1
- package/dist/projections/Projections.js +153 -6
- package/dist/projections/Projections.js.map +1 -1
- package/dist/projections/UnableToQueryProjection.d.ts +12 -0
- package/dist/projections/UnableToQueryProjection.d.ts.map +1 -0
- package/dist/projections/UnableToQueryProjection.js +17 -0
- package/dist/projections/UnableToQueryProjection.js.map +1 -0
- package/dist/projections/index.d.ts +3 -0
- package/dist/projections/index.d.ts.map +1 -1
- package/dist/projections/index.js +1 -0
- package/dist/projections/index.js.map +1 -1
- package/dist/projections/modelBound/eventSequence.d.ts +22 -0
- package/dist/projections/modelBound/eventSequence.d.ts.map +1 -0
- package/dist/projections/modelBound/eventSequence.js +34 -0
- package/dist/projections/modelBound/eventSequence.js.map +1 -0
- package/dist/projections/modelBound/fromAll.d.ts +26 -0
- package/dist/projections/modelBound/fromAll.d.ts.map +1 -0
- package/dist/projections/modelBound/fromAll.js +31 -0
- package/dist/projections/modelBound/fromAll.js.map +1 -0
- package/dist/projections/modelBound/index.d.ts +4 -0
- package/dist/projections/modelBound/index.d.ts.map +1 -1
- package/dist/projections/modelBound/index.js +3 -0
- package/dist/projections/modelBound/index.js.map +1 -1
- package/dist/projections/modelBound/noAutoMap.d.ts +26 -0
- package/dist/projections/modelBound/noAutoMap.d.ts.map +1 -0
- package/dist/projections/modelBound/noAutoMap.js +44 -0
- package/dist/projections/modelBound/noAutoMap.js.map +1 -0
- package/dist/reactors/Reactors.d.ts.map +1 -1
- package/dist/reactors/Reactors.js +7 -3
- package/dist/reactors/Reactors.js.map +1 -1
- package/dist/readModels/MaterializedReadModels.d.ts +0 -1
- package/dist/readModels/MaterializedReadModels.d.ts.map +1 -1
- package/dist/readModels/MaterializedReadModels.js +2 -8
- package/dist/readModels/MaterializedReadModels.js.map +1 -1
- package/dist/readModels/ReadModelSubjectResolver.d.ts +22 -0
- package/dist/readModels/ReadModelSubjectResolver.d.ts.map +1 -0
- package/dist/readModels/ReadModelSubjectResolver.js +38 -0
- package/dist/readModels/ReadModelSubjectResolver.js.map +1 -0
- package/dist/readModels/ReadModels.d.ts.map +1 -1
- package/dist/readModels/ReadModels.js +7 -7
- package/dist/readModels/ReadModels.js.map +1 -1
- package/dist/readModels/index.d.ts +1 -0
- package/dist/readModels/index.d.ts.map +1 -1
- package/dist/readModels/index.js +1 -0
- package/dist/readModels/index.js.map +1 -1
- package/dist/reducers/Reducers.d.ts.map +1 -1
- package/dist/reducers/Reducers.js +21 -3
- package/dist/reducers/Reducers.js.map +1 -1
- package/dist/schemas/JsonSchema.d.ts +14 -0
- package/dist/schemas/JsonSchema.d.ts.map +1 -1
- package/dist/schemas/JsonSchemaGenerator.d.ts +61 -5
- package/dist/schemas/JsonSchemaGenerator.d.ts.map +1 -1
- package/dist/schemas/JsonSchemaGenerator.js +130 -26
- package/dist/schemas/JsonSchemaGenerator.js.map +1 -1
- package/dist/schemas/index.d.ts +1 -1
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/seeding/EventSeeding.d.ts.map +1 -1
- package/dist/seeding/EventSeeding.js +3 -1
- package/dist/seeding/EventSeeding.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/eventSequences/AppendOptions.ts +9 -0
- package/eventSequences/EventForEventSourceId.ts +9 -0
- package/eventSequences/EventSequence.ts +20 -6
- package/events/EventContext.ts +4 -0
- package/events/Tag.ts +14 -0
- package/events/filterEventsByTagDecorator.ts +51 -0
- package/events/index.ts +4 -0
- package/events/mergeTags.spec.ts +50 -0
- package/events/mergeTags.ts +27 -0
- package/events/tagDecorator.spec.ts +115 -0
- package/events/tagDecorator.ts +59 -0
- package/observation/ObserverRunningState.ts +9 -18
- package/observation/index.ts +1 -0
- package/observation/toObserverRunningState.ts +27 -0
- package/package.json +8 -8
- package/projections/IProjections.ts +81 -1
- package/projections/ProjectionQueryResult.ts +10 -0
- package/projections/ProjectionState.ts +25 -0
- package/projections/Projections.childrenAndNested.spec.ts +1 -1
- package/projections/Projections.modelBoundCompleteness.spec.ts +224 -0
- package/projections/Projections.operationalSurface.spec.ts +257 -0
- package/projections/Projections.spec.ts +1 -1
- package/projections/Projections.ts +180 -5
- package/projections/UnableToQueryProjection.ts +17 -0
- package/projections/index.ts +3 -0
- package/projections/modelBound/eventSequence.ts +38 -0
- package/projections/modelBound/fromAll.ts +42 -0
- package/projections/modelBound/index.ts +4 -0
- package/projections/modelBound/noAutoMap.ts +47 -0
- package/reactors/Reactors.ts +7 -3
- package/readModels/MaterializedReadModels.spec.ts +98 -0
- package/readModels/MaterializedReadModels.ts +2 -8
- package/readModels/ReadModelSubjectResolver.spec.ts +84 -0
- package/readModels/ReadModelSubjectResolver.ts +44 -0
- package/readModels/ReadModels.spec.ts +118 -0
- package/readModels/ReadModels.ts +7 -7
- package/readModels/index.ts +1 -0
- package/reducers/Reducers.spec.ts +80 -0
- package/reducers/Reducers.ts +22 -3
- package/schemas/JsonSchema.ts +16 -0
- package/schemas/JsonSchemaGenerator.spec.ts +195 -0
- package/schemas/JsonSchemaGenerator.ts +145 -27
- package/schemas/index.ts +1 -1
- package/seeding/EventSeeding.ts +3 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { Tag } from './Tag';
|
|
3
|
+
/**
|
|
4
|
+
* TypeScript decorator that restricts a reactor or reducer so that it only handles events
|
|
5
|
+
* that carry a specific tag. This is the TypeScript equivalent of the C# `[FilterEventsByTag]`
|
|
6
|
+
* attribute.
|
|
7
|
+
*
|
|
8
|
+
* Apply this decorator to a `@reactor()` or `@reducer()`-decorated class to filter the observed
|
|
9
|
+
* event stream to events tagged with the given value. Use {@link tag}/{@link tags} when the
|
|
10
|
+
* intent is to *label* an observer for discoverability; use this decorator when the intent is
|
|
11
|
+
* to *filter* which events reach it. Applying the decorator more than once accumulates filter
|
|
12
|
+
* tags - a class handles events carrying any of the applied tags.
|
|
13
|
+
*
|
|
14
|
+
* @param value - The tag value that an event must carry in order to be dispatched to the observer.
|
|
15
|
+
* @returns A class decorator.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* @reactor()
|
|
20
|
+
* @filterEventsByTag('vip')
|
|
21
|
+
* class VipWelcomeReactor {
|
|
22
|
+
* async customerRegistered(event: CustomerRegistered): Promise<void> {
|
|
23
|
+
* console.log(`Welcome VIP customer ${event.emailAddress}`);
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function filterEventsByTag(value: string): ClassDecorator;
|
|
29
|
+
/**
|
|
30
|
+
* Gets all filter tags applied to a class via {@link filterEventsByTag}.
|
|
31
|
+
* @param target - The class constructor to retrieve filter tags for.
|
|
32
|
+
* @returns The filter tags applied to the class, or an empty array if none are.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getFilterTagsFor(target: Function): Tag[];
|
|
35
|
+
//# sourceMappingURL=filterEventsByTagDecorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filterEventsByTagDecorator.d.ts","sourceRoot":"","sources":["../../events/filterEventsByTagDecorator.ts"],"names":[],"mappings":"AAGA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAM5B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,CAM/D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,QAAQ,GAAG,GAAG,EAAE,CAExD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
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 { Tag } from './Tag';
|
|
5
|
+
import { mergeTags } from './mergeTags';
|
|
6
|
+
/** Metadata key used to store the tags a reactor or reducer filters events by. */
|
|
7
|
+
const FILTER_TAGS_METADATA_KEY = 'chronicle:filterEventsByTag';
|
|
8
|
+
/**
|
|
9
|
+
* TypeScript decorator that restricts a reactor or reducer so that it only handles events
|
|
10
|
+
* that carry a specific tag. This is the TypeScript equivalent of the C# `[FilterEventsByTag]`
|
|
11
|
+
* attribute.
|
|
12
|
+
*
|
|
13
|
+
* Apply this decorator to a `@reactor()` or `@reducer()`-decorated class to filter the observed
|
|
14
|
+
* event stream to events tagged with the given value. Use {@link tag}/{@link tags} when the
|
|
15
|
+
* intent is to *label* an observer for discoverability; use this decorator when the intent is
|
|
16
|
+
* to *filter* which events reach it. Applying the decorator more than once accumulates filter
|
|
17
|
+
* tags - a class handles events carrying any of the applied tags.
|
|
18
|
+
*
|
|
19
|
+
* @param value - The tag value that an event must carry in order to be dispatched to the observer.
|
|
20
|
+
* @returns A class decorator.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* @reactor()
|
|
25
|
+
* @filterEventsByTag('vip')
|
|
26
|
+
* class VipWelcomeReactor {
|
|
27
|
+
* async customerRegistered(event: CustomerRegistered): Promise<void> {
|
|
28
|
+
* console.log(`Welcome VIP customer ${event.emailAddress}`);
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export function filterEventsByTag(value) {
|
|
34
|
+
return (target) => {
|
|
35
|
+
const existing = Reflect.getMetadata(FILTER_TAGS_METADATA_KEY, target) ?? [];
|
|
36
|
+
const merged = mergeTags(existing, [value]).map(tagValue => new Tag(tagValue));
|
|
37
|
+
Reflect.defineMetadata(FILTER_TAGS_METADATA_KEY, merged, target);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Gets all filter tags applied to a class via {@link filterEventsByTag}.
|
|
42
|
+
* @param target - The class constructor to retrieve filter tags for.
|
|
43
|
+
* @returns The filter tags applied to the class, or an empty array if none are.
|
|
44
|
+
*/
|
|
45
|
+
export function getFilterTagsFor(target) {
|
|
46
|
+
return Reflect.getMetadata(FILTER_TAGS_METADATA_KEY, target) ?? [];
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=filterEventsByTagDecorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filterEventsByTagDecorator.js","sourceRoot":"","sources":["../../events/filterEventsByTagDecorator.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,kFAAkF;AAClF,MAAM,wBAAwB,GAAG,6BAA6B,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC3C,OAAO,CAAC,MAAc,EAAE,EAAE;QACtB,MAAM,QAAQ,GAAI,OAAO,CAAC,WAAW,CAAC,wBAAwB,EAAE,MAAM,CAAuB,IAAI,EAAE,CAAC;QACpG,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC/E,OAAO,CAAC,cAAc,CAAC,wBAAwB,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACrE,CAAC,CAAC;AACN,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAgB;IAC7C,OAAQ,OAAO,CAAC,WAAW,CAAC,wBAAwB,EAAE,MAAM,CAAuB,IAAI,EAAE,CAAC;AAC9F,CAAC"}
|
package/dist/events/index.d.ts
CHANGED
|
@@ -8,6 +8,10 @@ export type { CausationEntry } from './CausationEntry';
|
|
|
8
8
|
export type { AppendedEvent } from './AppendedEvent';
|
|
9
9
|
export type { IEventTypes } from './IEventTypes';
|
|
10
10
|
export { EventTypes } from './EventTypes';
|
|
11
|
+
export { Tag } from './Tag';
|
|
12
|
+
export { tag, tags, getTagsFor } from './tagDecorator';
|
|
13
|
+
export { filterEventsByTag, getFilterTagsFor } from './filterEventsByTagDecorator';
|
|
14
|
+
export { mergeTags } from './mergeTags';
|
|
11
15
|
export * from './constraints';
|
|
12
16
|
export * from './migrations';
|
|
13
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../events/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjI,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../events/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjI,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|
package/dist/events/index.js
CHANGED
|
@@ -5,6 +5,10 @@ export { EventTypeId } from './EventTypeId';
|
|
|
5
5
|
export { EventTypeGeneration } from './EventTypeGeneration';
|
|
6
6
|
export { eventType, getEventTypeFor, hasEventType, getEventTypeMetadata, getEventTypeJsonSchemaFor } from './eventTypeDecorator';
|
|
7
7
|
export { EventTypes } from './EventTypes';
|
|
8
|
+
export { Tag } from './Tag';
|
|
9
|
+
export { tag, tags, getTagsFor } from './tagDecorator';
|
|
10
|
+
export { filterEventsByTag, getFilterTagsFor } from './filterEventsByTagDecorator';
|
|
11
|
+
export { mergeTags } from './mergeTags';
|
|
8
12
|
export * from './constraints';
|
|
9
13
|
export * from './migrations';
|
|
10
14
|
//# 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,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAMjI,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../events/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAMjI,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Tag } from './Tag';
|
|
2
|
+
/**
|
|
3
|
+
* Merges one or more sources of tags - static tags declared on a type, tags carried by an
|
|
4
|
+
* individual event instance, and tags supplied at call time - into a single, distinct list of
|
|
5
|
+
* tag values. Mirrors the .NET client, which merges static, instance, and dynamic tags the
|
|
6
|
+
* same way before sending an append request.
|
|
7
|
+
* @param sources - The tag sources to merge. Each may be a mix of strings and {@link Tag} instances,
|
|
8
|
+
* or undefined when that source contributed no tags.
|
|
9
|
+
* @returns The distinct, merged tag values.
|
|
10
|
+
*/
|
|
11
|
+
export declare function mergeTags(...sources: ReadonlyArray<Iterable<string | Tag> | undefined>): string[];
|
|
12
|
+
//# sourceMappingURL=mergeTags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeTags.d.ts","sourceRoot":"","sources":["../../events/mergeTags.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,GAAG,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,MAAM,EAAE,CAYjG"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
* Merges one or more sources of tags - static tags declared on a type, tags carried by an
|
|
5
|
+
* individual event instance, and tags supplied at call time - into a single, distinct list of
|
|
6
|
+
* tag values. Mirrors the .NET client, which merges static, instance, and dynamic tags the
|
|
7
|
+
* same way before sending an append request.
|
|
8
|
+
* @param sources - The tag sources to merge. Each may be a mix of strings and {@link Tag} instances,
|
|
9
|
+
* or undefined when that source contributed no tags.
|
|
10
|
+
* @returns The distinct, merged tag values.
|
|
11
|
+
*/
|
|
12
|
+
export function mergeTags(...sources) {
|
|
13
|
+
const values = new Set();
|
|
14
|
+
for (const source of sources) {
|
|
15
|
+
if (!source)
|
|
16
|
+
continue;
|
|
17
|
+
for (const entry of source) {
|
|
18
|
+
const value = typeof entry === 'string' ? entry : entry.value;
|
|
19
|
+
if (value.trim().length > 0) {
|
|
20
|
+
values.add(value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return [...values];
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=mergeTags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeTags.js","sourceRoot":"","sources":["../../events/mergeTags.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAIrG;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CAAC,GAAG,OAA0D;IACnF,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IACjC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,MAAM;YAAE,SAAS;QACtB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YACzB,MAAM,KAAK,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;YAC9D,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC1B,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACtB,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { Tag } from './Tag';
|
|
3
|
+
/**
|
|
4
|
+
* TypeScript decorator that labels an event type, reactor, or reducer with one or more tags.
|
|
5
|
+
* This is the TypeScript equivalent of the C# `[Tag]` attribute.
|
|
6
|
+
*
|
|
7
|
+
* Applying the decorator more than once accumulates tags rather than replacing them, so
|
|
8
|
+
* `@tag('a')` followed by `@tag('b')` on the same class results in both `'a'` and `'b'`.
|
|
9
|
+
*
|
|
10
|
+
* @param values - The tags to apply.
|
|
11
|
+
* @returns A class decorator.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* @eventType()
|
|
16
|
+
* @tag('analytics', 'user-action')
|
|
17
|
+
* class UserLoggedIn {
|
|
18
|
+
* constructor(readonly userId: string) {}
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function tag(...values: string[]): ClassDecorator;
|
|
23
|
+
/**
|
|
24
|
+
* TypeScript decorator that labels an event type, reactor, or reducer with one or more tags.
|
|
25
|
+
* This is the TypeScript equivalent of the C# `[Tags]` attribute, and behaves identically to
|
|
26
|
+
* {@link tag} - use whichever reads more naturally at the call site.
|
|
27
|
+
*
|
|
28
|
+
* @param values - The tags to apply.
|
|
29
|
+
* @returns A class decorator.
|
|
30
|
+
*/
|
|
31
|
+
export declare function tags(...values: string[]): ClassDecorator;
|
|
32
|
+
/**
|
|
33
|
+
* Gets all tags applied to a class via {@link tag} or {@link tags}.
|
|
34
|
+
* @param target - The class constructor to retrieve tags for.
|
|
35
|
+
* @returns The tags applied to the class, or an empty array if none are.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getTagsFor(target: Function): Tag[];
|
|
38
|
+
//# sourceMappingURL=tagDecorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tagDecorator.d.ts","sourceRoot":"","sources":["../../events/tagDecorator.ts"],"names":[],"mappings":"AAGA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAM5B;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,GAAG,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,cAAc,CAEvD;AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,cAAc,CAExD;AAQD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,QAAQ,GAAG,GAAG,EAAE,CAElD"}
|
|
@@ -0,0 +1,54 @@
|
|
|
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 { Tag } from './Tag';
|
|
5
|
+
import { mergeTags } from './mergeTags';
|
|
6
|
+
/** Metadata key used to store the tags labeling a class. */
|
|
7
|
+
const TAGS_METADATA_KEY = 'chronicle:tags';
|
|
8
|
+
/**
|
|
9
|
+
* TypeScript decorator that labels an event type, reactor, or reducer with one or more tags.
|
|
10
|
+
* This is the TypeScript equivalent of the C# `[Tag]` attribute.
|
|
11
|
+
*
|
|
12
|
+
* Applying the decorator more than once accumulates tags rather than replacing them, so
|
|
13
|
+
* `@tag('a')` followed by `@tag('b')` on the same class results in both `'a'` and `'b'`.
|
|
14
|
+
*
|
|
15
|
+
* @param values - The tags to apply.
|
|
16
|
+
* @returns A class decorator.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* @eventType()
|
|
21
|
+
* @tag('analytics', 'user-action')
|
|
22
|
+
* class UserLoggedIn {
|
|
23
|
+
* constructor(readonly userId: string) {}
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function tag(...values) {
|
|
28
|
+
return (target) => addTags(target, values);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* TypeScript decorator that labels an event type, reactor, or reducer with one or more tags.
|
|
32
|
+
* This is the TypeScript equivalent of the C# `[Tags]` attribute, and behaves identically to
|
|
33
|
+
* {@link tag} - use whichever reads more naturally at the call site.
|
|
34
|
+
*
|
|
35
|
+
* @param values - The tags to apply.
|
|
36
|
+
* @returns A class decorator.
|
|
37
|
+
*/
|
|
38
|
+
export function tags(...values) {
|
|
39
|
+
return (target) => addTags(target, values);
|
|
40
|
+
}
|
|
41
|
+
function addTags(target, values) {
|
|
42
|
+
const existing = Reflect.getMetadata(TAGS_METADATA_KEY, target) ?? [];
|
|
43
|
+
const merged = mergeTags(existing, values).map(value => new Tag(value));
|
|
44
|
+
Reflect.defineMetadata(TAGS_METADATA_KEY, merged, target);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Gets all tags applied to a class via {@link tag} or {@link tags}.
|
|
48
|
+
* @param target - The class constructor to retrieve tags for.
|
|
49
|
+
* @returns The tags applied to the class, or an empty array if none are.
|
|
50
|
+
*/
|
|
51
|
+
export function getTagsFor(target) {
|
|
52
|
+
return Reflect.getMetadata(TAGS_METADATA_KEY, target) ?? [];
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=tagDecorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tagDecorator.js","sourceRoot":"","sources":["../../events/tagDecorator.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,4DAA4D;AAC5D,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAE3C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,GAAG,CAAC,GAAG,MAAgB;IACnC,OAAO,CAAC,MAAc,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,IAAI,CAAC,GAAG,MAAgB;IACpC,OAAO,CAAC,MAAc,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,OAAO,CAAC,MAAc,EAAE,MAAgB;IAC7C,MAAM,QAAQ,GAAI,OAAO,CAAC,WAAW,CAAC,iBAAiB,EAAE,MAAM,CAAuB,IAAI,EAAE,CAAC;IAC7F,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IACxE,OAAO,CAAC,cAAc,CAAC,iBAAiB,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC9D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,MAAgB;IACvC,OAAQ,OAAO,CAAC,WAAW,CAAC,iBAAiB,EAAE,MAAM,CAAuB,IAAI,EAAE,CAAC;AACvF,CAAC"}
|
|
@@ -4,21 +4,15 @@
|
|
|
4
4
|
export declare enum ObserverRunningState {
|
|
5
5
|
/** The observer is in an unknown state. */
|
|
6
6
|
Unknown = "Unknown",
|
|
7
|
-
/** The observer is
|
|
8
|
-
Subscribing = "Subscribing",
|
|
9
|
-
/** The observer is replaying events from the beginning. */
|
|
10
|
-
Replaying = "Replaying",
|
|
11
|
-
/** The observer is resuming after a pause. */
|
|
12
|
-
Resuming = "Resuming",
|
|
13
|
-
/** The observer is actively processing events. */
|
|
7
|
+
/** The observer is active and waiting for new events. */
|
|
14
8
|
Active = "Active",
|
|
15
|
-
/** The observer is
|
|
16
|
-
|
|
17
|
-
/** The observer
|
|
18
|
-
|
|
19
|
-
/** The observer is
|
|
20
|
-
|
|
21
|
-
/** The observer
|
|
22
|
-
|
|
9
|
+
/** The observer is suspended. */
|
|
10
|
+
Suspended = "Suspended",
|
|
11
|
+
/** The observer is replaying. */
|
|
12
|
+
Replaying = "Replaying",
|
|
13
|
+
/** The observer is disconnected. */
|
|
14
|
+
Disconnected = "Disconnected",
|
|
15
|
+
/** The observer is quarantined. */
|
|
16
|
+
Quarantined = "Quarantined"
|
|
23
17
|
}
|
|
24
18
|
//# sourceMappingURL=ObserverRunningState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObserverRunningState.d.ts","sourceRoot":"","sources":["../../observation/ObserverRunningState.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,oBAAY,oBAAoB;IAC5B,2CAA2C;IAC3C,OAAO,YAAY;IAEnB,yDAAyD;IACzD,WAAW
|
|
1
|
+
{"version":3,"file":"ObserverRunningState.d.ts","sourceRoot":"","sources":["../../observation/ObserverRunningState.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,oBAAY,oBAAoB;IAC5B,2CAA2C;IAC3C,OAAO,YAAY;IAEnB,yDAAyD;IACzD,MAAM,WAAW;IAEjB,iCAAiC;IACjC,SAAS,cAAc;IAEvB,iCAAiC;IACjC,SAAS,cAAc;IAEvB,oCAAoC;IACpC,YAAY,iBAAiB;IAE7B,mCAAmC;IACnC,WAAW,gBAAgB;CAC9B"}
|
|
@@ -7,21 +7,15 @@ export var ObserverRunningState;
|
|
|
7
7
|
(function (ObserverRunningState) {
|
|
8
8
|
/** The observer is in an unknown state. */
|
|
9
9
|
ObserverRunningState["Unknown"] = "Unknown";
|
|
10
|
-
/** The observer is
|
|
11
|
-
ObserverRunningState["Subscribing"] = "Subscribing";
|
|
12
|
-
/** The observer is replaying events from the beginning. */
|
|
13
|
-
ObserverRunningState["Replaying"] = "Replaying";
|
|
14
|
-
/** The observer is resuming after a pause. */
|
|
15
|
-
ObserverRunningState["Resuming"] = "Resuming";
|
|
16
|
-
/** The observer is actively processing events. */
|
|
10
|
+
/** The observer is active and waiting for new events. */
|
|
17
11
|
ObserverRunningState["Active"] = "Active";
|
|
18
|
-
/** The observer is
|
|
19
|
-
ObserverRunningState["
|
|
20
|
-
/** The observer
|
|
21
|
-
ObserverRunningState["
|
|
22
|
-
/** The observer is
|
|
23
|
-
ObserverRunningState["Failed"] = "Failed";
|
|
24
|
-
/** The observer has been disconnected. */
|
|
12
|
+
/** The observer is suspended. */
|
|
13
|
+
ObserverRunningState["Suspended"] = "Suspended";
|
|
14
|
+
/** The observer is replaying. */
|
|
15
|
+
ObserverRunningState["Replaying"] = "Replaying";
|
|
16
|
+
/** The observer is disconnected. */
|
|
25
17
|
ObserverRunningState["Disconnected"] = "Disconnected";
|
|
18
|
+
/** The observer is quarantined. */
|
|
19
|
+
ObserverRunningState["Quarantined"] = "Quarantined";
|
|
26
20
|
})(ObserverRunningState || (ObserverRunningState = {}));
|
|
27
21
|
//# sourceMappingURL=ObserverRunningState.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObserverRunningState.js","sourceRoot":"","sources":["../../observation/ObserverRunningState.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG;;GAEG;AACH,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"ObserverRunningState.js","sourceRoot":"","sources":["../../observation/ObserverRunningState.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG;;GAEG;AACH,MAAM,CAAN,IAAY,oBAkBX;AAlBD,WAAY,oBAAoB;IAC5B,2CAA2C;IAC3C,2CAAmB,CAAA;IAEnB,yDAAyD;IACzD,yCAAiB,CAAA;IAEjB,iCAAiC;IACjC,+CAAuB,CAAA;IAEvB,iCAAiC;IACjC,+CAAuB,CAAA;IAEvB,oCAAoC;IACpC,qDAA6B,CAAA;IAE7B,mCAAmC;IACnC,mDAA2B,CAAA;AAC/B,CAAC,EAlBW,oBAAoB,KAApB,oBAAoB,QAkB/B"}
|
|
@@ -4,6 +4,7 @@ export type { FailedPartition } from './FailedPartition';
|
|
|
4
4
|
export type { FailedPartitionAttempt } from './FailedPartitionAttempt';
|
|
5
5
|
export type { IFailedPartitions } from './IFailedPartitions';
|
|
6
6
|
export { FailedPartitions } from './FailedPartitions';
|
|
7
|
+
export { toObserverRunningState } from './toObserverRunningState';
|
|
7
8
|
export type { ICanBeNotifiedWhenReplay } from './ICanBeNotifiedWhenReplay';
|
|
8
9
|
export type { ICanBeNotifiedWhenPartitionReplayed } from './ICanBeNotifiedWhenPartitionReplayed';
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../observation/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,YAAY,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACvE,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,YAAY,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../observation/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,YAAY,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACvE,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,YAAY,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,YAAY,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../observation/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAI9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../observation/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAI9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ObserverRunningState as ContractObserverRunningState } from '@cratis/chronicle.contracts';
|
|
2
|
+
import { ObserverRunningState } from './ObserverRunningState';
|
|
3
|
+
/**
|
|
4
|
+
* Converts a wire {@link ContractObserverRunningState} into the client {@link ObserverRunningState}.
|
|
5
|
+
* @param state - The wire running state to convert.
|
|
6
|
+
* @returns The converted client running state.
|
|
7
|
+
*/
|
|
8
|
+
export declare function toObserverRunningState(state: ContractObserverRunningState): ObserverRunningState;
|
|
9
|
+
//# sourceMappingURL=toObserverRunningState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toObserverRunningState.d.ts","sourceRoot":"","sources":["../../observation/toObserverRunningState.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,IAAI,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AACnG,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,4BAA4B,GAAG,oBAAoB,CAehG"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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 { ObserverRunningState as ContractObserverRunningState } from '@cratis/chronicle.contracts';
|
|
4
|
+
import { ObserverRunningState } from './ObserverRunningState';
|
|
5
|
+
/**
|
|
6
|
+
* Converts a wire {@link ContractObserverRunningState} into the client {@link ObserverRunningState}.
|
|
7
|
+
* @param state - The wire running state to convert.
|
|
8
|
+
* @returns The converted client running state.
|
|
9
|
+
*/
|
|
10
|
+
export function toObserverRunningState(state) {
|
|
11
|
+
switch (state) {
|
|
12
|
+
case ContractObserverRunningState.Active:
|
|
13
|
+
return ObserverRunningState.Active;
|
|
14
|
+
case ContractObserverRunningState.Suspended:
|
|
15
|
+
return ObserverRunningState.Suspended;
|
|
16
|
+
case ContractObserverRunningState.Replaying:
|
|
17
|
+
return ObserverRunningState.Replaying;
|
|
18
|
+
case ContractObserverRunningState.Disconnected:
|
|
19
|
+
return ObserverRunningState.Disconnected;
|
|
20
|
+
case ContractObserverRunningState.Quarantined:
|
|
21
|
+
return ObserverRunningState.Quarantined;
|
|
22
|
+
default:
|
|
23
|
+
return ObserverRunningState.Unknown;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=toObserverRunningState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toObserverRunningState.js","sourceRoot":"","sources":["../../observation/toObserverRunningState.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,EAAE,oBAAoB,IAAI,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AACnG,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAmC;IACtE,QAAQ,KAAK,EAAE,CAAC;QACZ,KAAK,4BAA4B,CAAC,MAAM;YACpC,OAAO,oBAAoB,CAAC,MAAM,CAAC;QACvC,KAAK,4BAA4B,CAAC,SAAS;YACvC,OAAO,oBAAoB,CAAC,SAAS,CAAC;QAC1C,KAAK,4BAA4B,CAAC,SAAS;YACvC,OAAO,oBAAoB,CAAC,SAAS,CAAC;QAC1C,KAAK,4BAA4B,CAAC,YAAY;YAC1C,OAAO,oBAAoB,CAAC,YAAY,CAAC;QAC7C,KAAK,4BAA4B,CAAC,WAAW;YACzC,OAAO,oBAAoB,CAAC,WAAW,CAAC;QAC5C;YACI,OAAO,oBAAoB,CAAC,OAAO,CAAC;IAC5C,CAAC;AACL,CAAC"}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import { Constructor } from '@cratis/fundamentals';
|
|
2
|
+
import { FailedPartition } from '../observation/FailedPartition';
|
|
3
|
+
import { JobId } from '../jobs/JobId';
|
|
4
|
+
import { ProjectionId } from './ProjectionId';
|
|
5
|
+
import { ProjectionQueryResult } from './ProjectionQueryResult';
|
|
6
|
+
import { ProjectionState } from './ProjectionState';
|
|
1
7
|
/**
|
|
2
|
-
* Defines a system to work with projections, including discovery
|
|
8
|
+
* Defines a system to work with projections, including discovery, registration and operating
|
|
9
|
+
* on projections that are known to the Chronicle Kernel.
|
|
3
10
|
*/
|
|
4
11
|
export interface IProjections {
|
|
5
12
|
/**
|
|
@@ -12,5 +19,68 @@ export interface IProjections {
|
|
|
12
19
|
* @returns A promise that resolves when registration is complete.
|
|
13
20
|
*/
|
|
14
21
|
register(): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Check if there is a definition for a specific projection identifier.
|
|
24
|
+
* @param projectionId - Identifier of the projection.
|
|
25
|
+
* @returns True if it exists, false if not.
|
|
26
|
+
*/
|
|
27
|
+
hasFor(projectionId: ProjectionId | string): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Check if there is a definition for the projection that maintains a specific read model.
|
|
30
|
+
* @param readModelType - Type of read model to check for.
|
|
31
|
+
* @returns True if it exists, false if not.
|
|
32
|
+
*/
|
|
33
|
+
hasForModel(readModelType: Constructor): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Get the {@link ProjectionId} for the projection that maintains a specific read model.
|
|
36
|
+
* @param readModelType - Type of read model to get for.
|
|
37
|
+
* @returns The {@link ProjectionId} for the read model.
|
|
38
|
+
* @remarks A model-bound projection has no projection type of its own - its read model type is the
|
|
39
|
+
* only handle it has. A declarative projection is only resolvable here when it declares its
|
|
40
|
+
* read model type explicitly (the second argument to the `projection()` decorator); one whose read
|
|
41
|
+
* model is inferred at registration time cannot be resolved before `register()` has run.
|
|
42
|
+
*/
|
|
43
|
+
getProjectionIdFor(readModelType: Constructor): ProjectionId;
|
|
44
|
+
/**
|
|
45
|
+
* Get the state of a specific projection.
|
|
46
|
+
* @param projectionId - Identifier of the projection to get the state for.
|
|
47
|
+
* @returns The {@link ProjectionState}.
|
|
48
|
+
*/
|
|
49
|
+
getStateFor(projectionId: ProjectionId | string): Promise<ProjectionState>;
|
|
50
|
+
/**
|
|
51
|
+
* Get the state of the projection that maintains a specific read model.
|
|
52
|
+
* @param readModelType - Type of read model to get the state for.
|
|
53
|
+
* @returns The {@link ProjectionState}.
|
|
54
|
+
*/
|
|
55
|
+
getStateForModel(readModelType: Constructor): Promise<ProjectionState>;
|
|
56
|
+
/**
|
|
57
|
+
* Get any failed partitions for the projection that maintains a specific read model.
|
|
58
|
+
* @param readModelType - Type of read model to get for.
|
|
59
|
+
* @returns Collection of {@link FailedPartition}, if any.
|
|
60
|
+
*/
|
|
61
|
+
getFailedPartitionsForModel(readModelType: Constructor): Promise<FailedPartition[]>;
|
|
62
|
+
/**
|
|
63
|
+
* Replay a specific projection by its identifier.
|
|
64
|
+
* @param projectionId - Identifier of the projection to replay.
|
|
65
|
+
* @returns The {@link JobId} of the replay job that was started or resumed.
|
|
66
|
+
*/
|
|
67
|
+
replay(projectionId: ProjectionId | string): Promise<JobId>;
|
|
68
|
+
/**
|
|
69
|
+
* Replay the projection that maintains a specific read model.
|
|
70
|
+
* @param readModelType - Type of read model to replay the projection for.
|
|
71
|
+
* @returns The {@link JobId} of the replay job that was started or resumed.
|
|
72
|
+
*/
|
|
73
|
+
replayForModel(readModelType: Constructor): Promise<JobId>;
|
|
74
|
+
/**
|
|
75
|
+
* Query a projection declaration against the event log without registering it.
|
|
76
|
+
* @param declaration - The Projection Declaration Language string to query.
|
|
77
|
+
* @param eventSequenceId - Optional event sequence identifier to query. Defaults to `"event-log"`.
|
|
78
|
+
* @returns A {@link ProjectionQueryResult} containing the resulting read model entries.
|
|
79
|
+
* @remarks The declaration may omit the `=> ReadModelType` target - in that case the read model
|
|
80
|
+
* schema is inferred from the events used in the projection. An inferred read model can never be
|
|
81
|
+
* registered as a permanent projection; query-only declarations are exclusively for ad-hoc
|
|
82
|
+
* exploration.
|
|
83
|
+
*/
|
|
84
|
+
query(declaration: string, eventSequenceId?: string): Promise<ProjectionQueryResult>;
|
|
15
85
|
}
|
|
16
86
|
//# sourceMappingURL=IProjections.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IProjections.d.ts","sourceRoot":"","sources":["../../projections/IProjections.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"IProjections.d.ts","sourceRoot":"","sources":["../../projections/IProjections.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;GAGG;AACH,MAAM,WAAW,YAAY;IACzB;;;OAGG;IACH,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1B;;;OAGG;IACH,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1B;;;;OAIG;IACH,MAAM,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,GAAG,OAAO,CAAC;IAErD;;;;OAIG;IACH,WAAW,CAAC,aAAa,EAAE,WAAW,GAAG,OAAO,CAAC;IAEjD;;;;;;;;OAQG;IACH,kBAAkB,CAAC,aAAa,EAAE,WAAW,GAAG,YAAY,CAAC;IAE7D;;;;OAIG;IACH,WAAW,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAE3E;;;;OAIG;IACH,gBAAgB,CAAC,aAAa,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAEvE;;;;OAIG;IACH,2BAA2B,CAAC,aAAa,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAEpF;;;;OAIG;IACH,MAAM,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAE5D;;;;OAIG;IACH,cAAc,CAAC,aAAa,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAE3D;;;;;;;;;OASG;IACH,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACxF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the result of querying a projection against the event log.
|
|
3
|
+
*/
|
|
4
|
+
export interface ProjectionQueryResult {
|
|
5
|
+
/** Collection of JSON representations of the resulting read model entries. */
|
|
6
|
+
readonly readModelEntries: ReadonlyArray<string>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=ProjectionQueryResult.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectionQueryResult.d.ts","sourceRoot":"","sources":["../../projections/ProjectionQueryResult.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC,8EAA8E;IAC9E,QAAQ,CAAC,gBAAgB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACpD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectionQueryResult.js","sourceRoot":"","sources":["../../projections/ProjectionQueryResult.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ObserverRunningState } from '../observation/ObserverRunningState';
|
|
2
|
+
import { EventSequenceNumber } from '../eventSequences/EventSequenceNumber';
|
|
3
|
+
/**
|
|
4
|
+
* Represents the state of a projection.
|
|
5
|
+
*/
|
|
6
|
+
export interface ProjectionState {
|
|
7
|
+
/** The current running state of the projection. */
|
|
8
|
+
readonly runningState: ObserverRunningState;
|
|
9
|
+
/** Indicates whether the projection is subscribed to its handler. */
|
|
10
|
+
readonly isSubscribed: boolean;
|
|
11
|
+
/** The next event sequence number the projection will process. */
|
|
12
|
+
readonly nextEventSequenceNumber: EventSequenceNumber;
|
|
13
|
+
/** The last event sequence number the projection handled. */
|
|
14
|
+
readonly lastHandledEventSequenceNumber: EventSequenceNumber;
|
|
15
|
+
/** The current tail event sequence number of the event sequence the projection observes. */
|
|
16
|
+
readonly tailEventSequenceNumber: EventSequenceNumber;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=ProjectionState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectionState.d.ts","sourceRoot":"","sources":["../../projections/ProjectionState.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,mDAAmD;IACnD,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;IAE5C,qEAAqE;IACrE,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAE/B,kEAAkE;IAClE,QAAQ,CAAC,uBAAuB,EAAE,mBAAmB,CAAC;IAEtD,6DAA6D;IAC7D,QAAQ,CAAC,8BAA8B,EAAE,mBAAmB,CAAC;IAE7D,4FAA4F;IAC5F,QAAQ,CAAC,uBAAuB,EAAE,mBAAmB,CAAC;CACzD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectionState.js","sourceRoot":"","sources":["../../projections/ProjectionState.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG"}
|