@cratis/chronicle 6.52.1 → 6.53.1
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/dist/projections/ProjectionDefinitionCompiler.d.ts.map +1 -1
- package/dist/projections/ProjectionDefinitionCompiler.js +22 -18
- package/dist/projections/ProjectionDefinitionCompiler.js.map +1 -1
- package/dist/projections/modelBound/childrenAndNestedBuilder.d.ts +6 -4
- package/dist/projections/modelBound/childrenAndNestedBuilder.d.ts.map +1 -1
- package/dist/projections/modelBound/childrenAndNestedBuilder.js +14 -12
- package/dist/projections/modelBound/childrenAndNestedBuilder.js.map +1 -1
- package/dist/reactors/Reactors.d.ts.map +1 -1
- package/dist/reactors/Reactors.js +2 -0
- package/dist/reactors/Reactors.js.map +1 -1
- package/dist/reactors/index.d.ts +1 -0
- package/dist/reactors/index.d.ts.map +1 -1
- package/dist/reactors/index.js +1 -0
- package/dist/reactors/index.js.map +1 -1
- package/dist/reactors/startAtTail.d.ts +18 -0
- package/dist/reactors/startAtTail.d.ts.map +1 -0
- package/dist/reactors/startAtTail.js +30 -0
- package/dist/reactors/startAtTail.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/webhooks/WebhookDefinitionBuilder.d.ts +1 -1
- package/dist/webhooks/WebhookDefinitionBuilder.d.ts.map +1 -1
- package/dist/webhooks/WebhookDefinitionBuilder.js +3 -1
- package/dist/webhooks/WebhookDefinitionBuilder.js.map +1 -1
- package/dist/webhooks/Webhooks.d.ts.map +1 -1
- package/dist/webhooks/Webhooks.js +2 -1
- package/dist/webhooks/Webhooks.js.map +1 -1
- package/jobs/for_Jobs/against_a_kernel/when_managing_a_replay_job.integration.spec.ts +25 -15
- package/package.json +2 -2
- package/projections/ProjectionDefinitionCompiler.ts +21 -18
- package/projections/for_ProjectionDefinitionCompiler/against_a_kernel/when_subscribing_with_from_all_events.integration.spec.ts +52 -48
- package/projections/for_ProjectionDefinitionCompiler/when_compiling_from_all_events.spec.ts +52 -25
- package/projections/for_ProjectionDefinitionCompiler/when_compiling_from_all_events.standard.spec.ts +49 -9
- package/projections/modelBound/childrenAndNestedBuilder.ts +17 -12
- package/reactors/Reactors.startAtTail.spec.ts +60 -0
- package/reactors/Reactors.ts +2 -0
- package/reactors/for_Reactors/against_a_kernel/when_starting_at_the_tail.integration.spec.ts +107 -0
- package/reactors/index.ts +1 -0
- package/reactors/startAtTail.spec.ts +31 -0
- package/reactors/startAtTail.ts +33 -0
- package/webhooks/WebhookDefinitionBuilder.ts +9 -7
- package/webhooks/Webhooks.ts +2 -1
package/reactors/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { ReactorDelivery } from './ReactorDelivery.js';
|
|
|
6
6
|
export { reactor, getReactorMetadata, isReactor } from './reactor.js';
|
|
7
7
|
export { handles } from '../events/handles.js';
|
|
8
8
|
export { onceOnly } from './onceOnly.js';
|
|
9
|
+
export { startAtTail } from './startAtTail.js';
|
|
9
10
|
export { replay } from './replay.js';
|
|
10
11
|
export type { ReactorMetadata } from './reactor.js';
|
|
11
12
|
export type { IReactors } from './IReactors.js';
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
import { describe, expect, it } from 'vitest';
|
|
5
|
+
import { isStartAtTail, startAtTail } from './startAtTail.js';
|
|
6
|
+
|
|
7
|
+
@startAtTail()
|
|
8
|
+
class MarkedReactor {}
|
|
9
|
+
|
|
10
|
+
class OrdinaryReactor {}
|
|
11
|
+
|
|
12
|
+
class InheritedReactor extends MarkedReactor {}
|
|
13
|
+
|
|
14
|
+
describe('the start-at-tail decorator', () => {
|
|
15
|
+
it('marks the reactor class', () => {
|
|
16
|
+
expect(isStartAtTail(MarkedReactor)).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('leaves an unmarked class alone', () => {
|
|
20
|
+
expect(isStartAtTail(OrdinaryReactor)).toBe(false);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('is not inherited by a subclass', () => {
|
|
24
|
+
expect(isStartAtTail(InheritedReactor)).toBe(false);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('refuses to decorate anything but a class', () => {
|
|
28
|
+
const decorate = startAtTail() as unknown as (target: object, context: { kind: string }) => void;
|
|
29
|
+
expect(() => decorate(() => {}, { kind: 'method' })).toThrow(TypeError);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import 'reflect-metadata';
|
|
5
|
+
|
|
6
|
+
const METADATA_KEY = 'chronicle:reactor:startAtTail';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A new reactor normally catches up from the beginning of the event sequence, so one whose handlers have side
|
|
10
|
+
* effects acts on every historical event the moment it is deployed. `@onceOnly()` does not prevent that, because it
|
|
11
|
+
* only excludes replay.
|
|
12
|
+
*
|
|
13
|
+
* Marks a reactor class so that the first time Chronicle sees it, it begins at the tail of the event sequence and
|
|
14
|
+
* observes only what is appended from then on. A reactor that already has a position keeps it, so the marker is safe
|
|
15
|
+
* to leave in place. Renaming the reactor or moving it changes its default id and makes it a new reactor, which
|
|
16
|
+
* starts at the tail again, unless an explicit id is given to `@reactor()`. An explicit replay still replays from the
|
|
17
|
+
* beginning. Both the Chronicle server and the client must support it; a server that predates it ignores the request.
|
|
18
|
+
* The marker is not inherited by subclasses.
|
|
19
|
+
* @returns A class decorator for legacy and standard TypeScript decorators.
|
|
20
|
+
*/
|
|
21
|
+
export function startAtTail(): ClassDecorator & ((value: Function, context: ClassDecoratorContext) => void) {
|
|
22
|
+
return (target: object, context?: ClassDecoratorContext) => {
|
|
23
|
+
if (typeof context === 'object' && context.kind !== 'class') {
|
|
24
|
+
throw new TypeError('Start-at-tail can only decorate a reactor class.');
|
|
25
|
+
}
|
|
26
|
+
Reflect.defineMetadata(METADATA_KEY, true, target);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Whether this reactor class is marked to start at the tail (without inheriting the marker). */
|
|
31
|
+
export function isStartAtTail(target: Function): boolean {
|
|
32
|
+
return Reflect.getOwnMetadata(METADATA_KEY, target) === true;
|
|
33
|
+
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// Copyright (c) Cratis. All rights reserved.
|
|
2
2
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
import {
|
|
5
|
+
EventGenerationDelivery,
|
|
6
|
+
type BasicAuthorization,
|
|
7
|
+
type BearerTokenAuthorization,
|
|
8
|
+
type OAuthAuthorization,
|
|
9
|
+
type OneOfBasicAuthorizationBearerTokenAuthorizationOAuthAuthorization,
|
|
10
|
+
type WebhookDefinition
|
|
10
11
|
} from '@cratis/chronicle.contracts';
|
|
11
12
|
import { Constructor } from '@cratis/fundamentals';
|
|
12
13
|
import { IEventTypes } from '../events/IEventTypes.js';
|
|
@@ -140,7 +141,8 @@ export class WebhookDefinitionBuilder implements IWebhookDefinitionBuilder {
|
|
|
140
141
|
IsReplayable: this._isReplayable,
|
|
141
142
|
IsActive: this._isActive,
|
|
142
143
|
IsNotReplayable: !this._isReplayable,
|
|
143
|
-
IsInactive: !this._isActive
|
|
144
|
+
IsInactive: !this._isActive,
|
|
145
|
+
GenerationDelivery: EventGenerationDelivery.Compatibility
|
|
144
146
|
};
|
|
145
147
|
}
|
|
146
148
|
}
|
package/webhooks/Webhooks.ts
CHANGED
|
@@ -104,7 +104,8 @@ export class Webhooks implements IWebhooks {
|
|
|
104
104
|
IsReplayable: webhook.IsReplayable,
|
|
105
105
|
IsActive: webhook.IsActive,
|
|
106
106
|
IsNotReplayable: !webhook.IsReplayable,
|
|
107
|
-
IsInactive: !webhook.IsActive
|
|
107
|
+
IsInactive: !webhook.IsActive,
|
|
108
|
+
GenerationDelivery: webhook.GenerationDelivery
|
|
108
109
|
}));
|
|
109
110
|
}
|
|
110
111
|
|