@cratis/chronicle 6.18.0 → 6.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/dist/eventSequences/EventSequence.d.ts.map +1 -1
  2. package/dist/eventSequences/EventSequence.js +2 -9
  3. package/dist/eventSequences/EventSequence.js.map +1 -1
  4. package/dist/eventSequences/prepareSingleAppend.d.ts +12 -0
  5. package/dist/eventSequences/prepareSingleAppend.d.ts.map +1 -0
  6. package/dist/eventSequences/prepareSingleAppend.js +22 -0
  7. package/dist/eventSequences/prepareSingleAppend.js.map +1 -0
  8. package/dist/testing/EventScenario.d.ts +29 -0
  9. package/dist/testing/EventScenario.d.ts.map +1 -0
  10. package/dist/testing/EventScenario.js +60 -0
  11. package/dist/testing/EventScenario.js.map +1 -0
  12. package/dist/testing/EventScenarioGiven.d.ts +9 -0
  13. package/dist/testing/EventScenarioGiven.d.ts.map +1 -0
  14. package/dist/testing/EventScenarioGiven.js +19 -0
  15. package/dist/testing/EventScenarioGiven.js.map +1 -0
  16. package/dist/testing/EventScenarioGivenBuilder.d.ts +9 -0
  17. package/dist/testing/EventScenarioGivenBuilder.d.ts.map +1 -0
  18. package/dist/testing/EventScenarioGivenBuilder.js +12 -0
  19. package/dist/testing/EventScenarioGivenBuilder.js.map +1 -0
  20. package/dist/testing/EventScenarioOptions.d.ts +21 -0
  21. package/dist/testing/EventScenarioOptions.d.ts.map +1 -0
  22. package/dist/testing/EventScenarioOptions.js +4 -0
  23. package/dist/testing/EventScenarioOptions.js.map +1 -0
  24. package/dist/testing/EventScenarioSeed.d.ts +5 -0
  25. package/dist/testing/EventScenarioSeed.d.ts.map +1 -0
  26. package/dist/testing/EventScenarioSeed.js +14 -0
  27. package/dist/testing/EventScenarioSeed.js.map +1 -0
  28. package/dist/testing/EventScenarioWhen.d.ts +11 -0
  29. package/dist/testing/EventScenarioWhen.d.ts.map +1 -0
  30. package/dist/testing/EventScenarioWhen.js +17 -0
  31. package/dist/testing/EventScenarioWhen.js.map +1 -0
  32. package/dist/testing/EventScenarioWhenBuilder.d.ts +9 -0
  33. package/dist/testing/EventScenarioWhenBuilder.d.ts.map +1 -0
  34. package/dist/testing/EventScenarioWhenBuilder.js +12 -0
  35. package/dist/testing/EventScenarioWhenBuilder.js.map +1 -0
  36. package/dist/testing/IReadModelProcessor.d.ts +7 -0
  37. package/dist/testing/IReadModelProcessor.d.ts.map +1 -0
  38. package/dist/testing/IReadModelProcessor.js +4 -0
  39. package/dist/testing/IReadModelProcessor.js.map +1 -0
  40. package/dist/testing/InProcessEventSequence.d.ts +49 -0
  41. package/dist/testing/InProcessEventSequence.d.ts.map +1 -0
  42. package/dist/testing/InProcessEventSequence.js +265 -0
  43. package/dist/testing/InProcessEventSequence.js.map +1 -0
  44. package/dist/testing/ReadModelScenario.d.ts +6 -8
  45. package/dist/testing/ReadModelScenario.d.ts.map +1 -1
  46. package/dist/testing/ReadModelScenario.js +50 -50
  47. package/dist/testing/ReadModelScenario.js.map +1 -1
  48. package/dist/testing/ReadModelState.d.ts +6 -0
  49. package/dist/testing/ReadModelState.d.ts.map +1 -0
  50. package/dist/testing/ReadModelState.js +4 -0
  51. package/dist/testing/ReadModelState.js.map +1 -0
  52. package/dist/testing/ReducerReadModelProcessor.d.ts +13 -0
  53. package/dist/testing/ReducerReadModelProcessor.d.ts.map +1 -0
  54. package/dist/testing/ReducerReadModelProcessor.js +38 -0
  55. package/dist/testing/ReducerReadModelProcessor.js.map +1 -0
  56. package/dist/testing/ScenarioEvent.d.ts +8 -0
  57. package/dist/testing/ScenarioEvent.d.ts.map +1 -0
  58. package/dist/testing/ScenarioEvent.js +4 -0
  59. package/dist/testing/ScenarioEvent.js.map +1 -0
  60. package/dist/testing/UnsupportedEventSequenceOperation.d.ts +5 -0
  61. package/dist/testing/UnsupportedEventSequenceOperation.d.ts.map +1 -0
  62. package/dist/testing/UnsupportedEventSequenceOperation.js +10 -0
  63. package/dist/testing/UnsupportedEventSequenceOperation.js.map +1 -0
  64. package/dist/testing/index.d.ts +8 -0
  65. package/dist/testing/index.d.ts.map +1 -1
  66. package/dist/testing/index.js +7 -0
  67. package/dist/testing/index.js.map +1 -1
  68. package/dist/testing/projections/ProjectionCapabilities.d.ts +3 -0
  69. package/dist/testing/projections/ProjectionCapabilities.d.ts.map +1 -1
  70. package/dist/testing/projections/ProjectionCapabilities.js +117 -43
  71. package/dist/testing/projections/ProjectionCapabilities.js.map +1 -1
  72. package/dist/testing/projections/ProjectionExpressionEvaluator.d.ts +9 -0
  73. package/dist/testing/projections/ProjectionExpressionEvaluator.d.ts.map +1 -0
  74. package/dist/testing/projections/ProjectionExpressionEvaluator.js +68 -0
  75. package/dist/testing/projections/ProjectionExpressionEvaluator.js.map +1 -0
  76. package/dist/testing/projections/ProjectionReadModelProcessor.d.ts +30 -0
  77. package/dist/testing/projections/ProjectionReadModelProcessor.d.ts.map +1 -0
  78. package/dist/testing/projections/ProjectionReadModelProcessor.js +142 -0
  79. package/dist/testing/projections/ProjectionReadModelProcessor.js.map +1 -0
  80. package/dist/testing/projections/ProjectionValueConverter.d.ts +13 -0
  81. package/dist/testing/projections/ProjectionValueConverter.d.ts.map +1 -0
  82. package/dist/testing/projections/ProjectionValueConverter.js +122 -0
  83. package/dist/testing/projections/ProjectionValueConverter.js.map +1 -0
  84. package/dist/testing/projections/for_ProjectionCapabilities/given/Changed.d.ts +0 -2
  85. package/dist/testing/projections/for_ProjectionCapabilities/given/Changed.d.ts.map +1 -1
  86. package/dist/testing/projections/for_ProjectionCapabilities/given/Changed.js +0 -4
  87. package/dist/testing/projections/for_ProjectionCapabilities/given/Changed.js.map +1 -1
  88. package/dist/tsconfig.tsbuildinfo +1 -1
  89. package/eventSequences/EventSequence.ts +2 -12
  90. package/eventSequences/prepareSingleAppend.ts +25 -0
  91. package/package.json +1 -1
  92. package/testing/EventScenario.fixtures.spec.ts +271 -0
  93. package/testing/EventScenario.rejections.spec.ts +307 -0
  94. package/testing/EventScenario.ts +77 -0
  95. package/testing/EventScenarioGiven.ts +16 -0
  96. package/testing/EventScenarioGivenBuilder.ts +11 -0
  97. package/testing/EventScenarioOptions.ts +20 -0
  98. package/testing/EventScenarioSeed.ts +17 -0
  99. package/testing/EventScenarioWhen.ts +16 -0
  100. package/testing/EventScenarioWhenBuilder.ts +11 -0
  101. package/testing/IReadModelProcessor.ts +10 -0
  102. package/testing/InProcessEventSequence.ts +275 -0
  103. package/testing/ReadModelScenario.spec.ts +156 -10
  104. package/testing/ReadModelScenario.ts +57 -57
  105. package/testing/ReadModelState.ts +5 -0
  106. package/testing/ReducerReadModelProcessor.ts +39 -0
  107. package/testing/ScenarioEvent.ts +7 -0
  108. package/testing/UnsupportedEventSequenceOperation.ts +10 -0
  109. package/testing/index.ts +8 -0
  110. package/testing/projections/ProjectionCapabilities.ts +100 -39
  111. package/testing/projections/ProjectionExpressionEvaluator.ts +57 -0
  112. package/testing/projections/ProjectionReadModelProcessor.fixtures.spec.ts +135 -0
  113. package/testing/projections/ProjectionReadModelProcessor.ts +147 -0
  114. package/testing/projections/ProjectionValueConverter.spec.ts +81 -0
  115. package/testing/projections/ProjectionValueConverter.ts +113 -0
  116. package/testing/projections/for_ProjectionCapabilities/given/Changed.ts +1 -3
  117. package/testing/projections/for_ProjectionCapabilities/when_rejecting_unsupported_operations.spec.ts +81 -1
  118. package/testing/projections/for_ProjectionCapabilities/when_validating_numeric_schemas.spec.ts +40 -12
  119. package/testing/projections/for_ProjectionCapabilities/when_validating_schema_boundaries.spec.ts +76 -29
  120. package/testing/projections/for_ProjectionCapabilities/when_validating_supported_operations.spec.ts +8 -35
@@ -0,0 +1,49 @@
1
+ import type { Constructor } from '@cratis/fundamentals';
2
+ import type { AppendedEvent } from '../events/AppendedEvent.js';
3
+ import type { AppendOptions } from '../eventSequences/AppendOptions.js';
4
+ import type { AppendResult } from '../eventSequences/AppendResult.js';
5
+ import type { AppendedEventWithResult } from '../eventSequences/AppendedEventWithResult.js';
6
+ import type { EventForEventSourceId } from '../eventSequences/EventForEventSourceId.js';
7
+ import { EventSequenceId } from '../eventSequences/EventSequenceId.js';
8
+ import { EventSequenceNumber } from '../eventSequences/EventSequenceNumber.js';
9
+ import type { IEventSequence } from '../eventSequences/IEventSequence.js';
10
+ import type { ITransactionalEventSequence } from '../eventSequences/ITransactionalEventSequence.js';
11
+ import type { CompleteStreamResult } from '../eventSequences/CompleteStreamResult.js';
12
+ import type { EventScenarioOptions } from './EventScenarioOptions.js';
13
+ /** Fixture-backed, scenario-local single-append sequence; no kernel or observer scheduler is started. */
14
+ export declare class InProcessEventSequence implements IEventSequence {
15
+ readonly id: EventSequenceId;
16
+ private readonly _catalog;
17
+ private readonly _history;
18
+ private readonly _store;
19
+ private readonly _namespace;
20
+ private readonly _clock;
21
+ private readonly _correlationId?;
22
+ private _setup;
23
+ private _allowSeedAppend;
24
+ private _busy;
25
+ private readonly _results;
26
+ constructor(options: EventScenarioOptions, eventTypes: Constructor[]);
27
+ get results(): readonly AppendResult[];
28
+ get appendedEvents(): readonly AppendedEvent[];
29
+ /** Seed through the same append path, without recording act-phase results. */
30
+ seed(source: string, event: object): Promise<void>;
31
+ get transactional(): ITransactionalEventSequence;
32
+ get appendOperations(): AsyncIterable<AppendedEventWithResult[]>;
33
+ append(eventSourceId: string, event: object, options?: AppendOptions): Promise<AppendResult>;
34
+ appendMany(_eventSourceId: string, _events: object[], _options?: AppendOptions): Promise<AppendResult[]>;
35
+ appendMany(_events: EventForEventSourceId[], _options?: AppendOptions): Promise<AppendResult[]>;
36
+ getNextSequenceNumber(): Promise<EventSequenceNumber>;
37
+ getTailSequenceNumber(source?: string, sourceType?: string, streamType?: string, streamId?: string, types?: Constructor[]): Promise<EventSequenceNumber>;
38
+ getTailSequenceNumberForObserver(observer: Constructor): Promise<EventSequenceNumber>;
39
+ hasEventsFor(source: string): Promise<boolean>;
40
+ getForEventSourceIdAndEventTypes(source: string, types: Constructor[], streamType?: string, streamId?: string, sourceType?: string): Promise<AppendedEvent[]>;
41
+ getFromSequenceNumber(sequence: EventSequenceNumber, source?: string, types?: Constructor[]): Promise<AppendedEvent[]>;
42
+ redact(): Promise<void>;
43
+ redactForEventSource(): Promise<void>;
44
+ completeStream(): Promise<CompleteStreamResult>;
45
+ private snapshot;
46
+ private validateReadSource;
47
+ private unsupported;
48
+ }
49
+ //# sourceMappingURL=InProcessEventSequence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InProcessEventSequence.d.ts","sourceRoot":"","sources":["../../testing/InProcessEventSequence.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAMhE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAC5F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kDAAkD,CAAC;AACpG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAKtF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAMtE,yGAAyG;AACzG,qBAAa,sBAAuB,YAAW,cAAc;IACzD,QAAQ,CAAC,EAAE,EAAE,eAAe,CAAC;IAC7B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgE;IACzF,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAuB;IAChD,OAAO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AAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAO7J;IAEK,gCAAgC,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAE1F;IAEK,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAGnD;IAEK,gCAAgC,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAWlK;IAEK,qBAAqB,CAAC,QAAQ,EAAE,mBAAmB,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAQ3H;IAEK,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAA2F;IAClH,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAyG;IAC9I,cAAc,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAAqG;IAE1J,OAAO,CAAC,QAAQ;IAchB,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,WAAW;CAGtB"}
@@ -0,0 +1,265 @@
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 { createHash } from 'node:crypto';
4
+ import { EventObservationState } from '@cratis/chronicle.contracts';
5
+ import { getEventTypeMetadata } from '../events/eventTypeDecorator.js';
6
+ import { getTagsFor } from '../events/tagDecorator.js';
7
+ import { Tag } from '../events/Tag.js';
8
+ import { EventType } from '../events/EventType.js';
9
+ import { EventTypeId } from '../events/EventTypeId.js';
10
+ import { EventTypeGeneration } from '../events/EventTypeGeneration.js';
11
+ import { Identity } from '../identity/Identity.js';
12
+ import { EventSequenceId } from '../eventSequences/EventSequenceId.js';
13
+ import { EventSequenceNumber } from '../eventSequences/EventSequenceNumber.js';
14
+ import { prepareSingleAppend } from '../eventSequences/prepareSingleAppend.js';
15
+ import { toContractsGuid } from '../connection/Guid.js';
16
+ import { getUniqueEventMetadata, getUniquePropertyMetadata } from '../events/constraints/unique.js';
17
+ import { getRemovedConstraintNames } from '../events/constraints/removeConstraint.js';
18
+ import { UnsupportedEventSequenceOperation } from './UnsupportedEventSequenceOperation.js';
19
+ // JS trim() omits U+0085, which the kernel trims. Reject unproven non-ASCII whitespace and controls.
20
+ const unprovenFilterCharacters = /[\u007f-\u009f]|(?=[^\x00-\x7f])\p{White_Space}/u;
21
+ /** Fixture-backed, scenario-local single-append sequence; no kernel or observer scheduler is started. */
22
+ export class InProcessEventSequence {
23
+ id;
24
+ _catalog = new Map();
25
+ _history = [];
26
+ _store;
27
+ _namespace;
28
+ _clock;
29
+ _correlationId;
30
+ _setup = false;
31
+ _allowSeedAppend = false;
32
+ _busy = false;
33
+ _results = [];
34
+ constructor(options, eventTypes) {
35
+ if (options.eventSequenceId && options.eventSequenceId.value !== EventSequenceId.eventLog.value) {
36
+ throw this.unsupported('options.eventSequenceId', options.eventSequenceId.value, 'Custom sequences are not fixture-backed.');
37
+ }
38
+ this.id = options.eventSequenceId ?? EventSequenceId.eventLog;
39
+ if (options.eventStore !== undefined && options.eventStore !== 'test-event-store') {
40
+ throw this.unsupported('options.eventStore', options.eventStore, 'Custom event stores are not fixture-backed.');
41
+ }
42
+ if (options.namespace !== undefined && options.namespace !== 'default') {
43
+ throw this.unsupported('options.namespace', options.namespace, 'Custom namespaces are not fixture-backed.');
44
+ }
45
+ this._store = options.eventStore ?? 'test-event-store';
46
+ this._namespace = options.namespace ?? 'default';
47
+ this._clock = options.clock ?? (() => new Date());
48
+ this._correlationId = options.correlationId;
49
+ const ids = new Set();
50
+ for (const type of eventTypes) {
51
+ const metadata = getEventTypeMetadata(type);
52
+ if (!metadata)
53
+ throw this.unsupported('artifacts.eventTypes', type.name, 'Event type has no @eventType metadata.');
54
+ const eventType = metadata.eventType;
55
+ if (!eventType.id.value.trim() || eventType.id.value !== eventType.id.value.trim() ||
56
+ unprovenFilterCharacters.test(eventType.id.value) || eventType.id.value.includes(',')) {
57
+ throw this.unsupported('artifacts.eventTypes.id', eventType.id.value, 'Comma-separated or padded event IDs have unproven filter behavior.');
58
+ }
59
+ if (ids.has(eventType.id.value))
60
+ throw this.unsupported('artifacts.eventTypes', type.name, 'Duplicate event ID or generation history.');
61
+ ids.add(eventType.id.value);
62
+ if (eventType.generation.value !== 1 || eventType.tombstone) {
63
+ throw this.unsupported('artifacts.eventTypes', type.name, 'Only generation 1, non-tombstone events are proven.');
64
+ }
65
+ if (options.constraints !== 'disabled' && (getUniqueEventMetadata(type) || getRemovedConstraintNames(type).length ||
66
+ [...metadata.members.keys()].some(key => getUniquePropertyMetadata(type, key)))) {
67
+ throw this.unsupported('artifacts.eventTypes.constraints', type.name, 'Constraint metadata is not supported in this increment.');
68
+ }
69
+ if (getTagsFor(type).length)
70
+ throw this.unsupported('artifacts.eventTypes.tags', type.name, 'Tagged events are not fixture-backed.');
71
+ // Validate the complete schema, not only properties present on a particular event.
72
+ const schema = metadata.schema;
73
+ if (schema.type !== 'object' || schema.compliance?.length || schema.security?.length ||
74
+ schema.enum !== undefined || schema.items !== undefined || schema.format !== undefined ||
75
+ schema.additionalProperties !== false ||
76
+ schema.required?.length !== Object.keys(schema.properties ?? {}).length ||
77
+ !schema.properties || Object.keys(schema.properties).length === 0 ||
78
+ Object.entries(schema.properties).some(([key, property]) => !/^[a-z][a-zA-Z0-9]*$/.test(key) || !['string', 'boolean'].includes(property.type ?? '') ||
79
+ property.format !== undefined || property.compliance?.length || property.security?.length ||
80
+ property.items !== undefined || property.properties !== undefined || property.enum !== undefined ||
81
+ property.additionalProperties !== undefined)) {
82
+ throw this.unsupported('artifacts.eventTypes.schema', type.name, 'Only flat, unclassified string/boolean fields are fixture-backed.');
83
+ }
84
+ this._catalog.set(type, metadata);
85
+ }
86
+ }
87
+ get results() { return Object.freeze([...this._results]); }
88
+ get appendedEvents() { return Object.freeze(this._history.map(event => this.snapshot(event))); }
89
+ /** Seed through the same append path, without recording act-phase results. */
90
+ async seed(source, event) {
91
+ if (this._setup)
92
+ throw this.unsupported('given.events', this.id.value, 'Overlapping setup calls are not fixture-backed.');
93
+ this._setup = true;
94
+ this._allowSeedAppend = true;
95
+ let pending;
96
+ try {
97
+ pending = this.append(source, event);
98
+ }
99
+ finally {
100
+ this._allowSeedAppend = false;
101
+ }
102
+ try {
103
+ const result = await pending;
104
+ if (!result.isSuccess)
105
+ throw new Error(`EventScenario given setup failed: ${JSON.stringify(result)}`);
106
+ }
107
+ finally {
108
+ this._setup = false;
109
+ }
110
+ }
111
+ get transactional() { throw this.unsupported('transactional', this.id.value, 'Transactions require a kernel.'); }
112
+ get appendOperations() { throw this.unsupported('appendOperations', this.id.value, 'Append notifications are not fixture-backed.'); }
113
+ async append(eventSourceId, event, options) {
114
+ if (this._busy || (this._setup && !this._allowSeedAppend)) {
115
+ throw this.unsupported('append', this.id.value, 'Overlapping calls do not have proven ordering.');
116
+ }
117
+ this._busy = true;
118
+ try {
119
+ if (!event || typeof event !== 'object')
120
+ throw this.unsupported('append.event', this.id.value, 'Only registered event instances are supported.');
121
+ if (!/^[A-Za-z0-9_-]+$/.test(eventSourceId))
122
+ throw this.unsupported('append.source', eventSourceId, 'Only simple source identifiers are fixture-backed.');
123
+ if (options && (Reflect.ownKeys(options).length || options.correlationId !== undefined || options.sourceType !== undefined ||
124
+ options.streamType !== undefined || options.streamId !== undefined || options.subject !== undefined ||
125
+ options.occurred !== undefined || options.eventSourceId !== undefined || options.concurrencyScope !== undefined ||
126
+ options.tags !== undefined || options.concurrencyScopes !== undefined)) {
127
+ throw this.unsupported('append.options', event.constructor.name, 'Append metadata, routing and concurrency are not fixture-backed.');
128
+ }
129
+ const metadata = this._catalog.get(event.constructor);
130
+ if (!metadata)
131
+ throw this.unsupported('append.event', event.constructor.name, 'Event is not in the selected, validated catalog.');
132
+ let prepared;
133
+ let content;
134
+ try {
135
+ prepared = prepareSingleAppend(event, this._correlationId ? { correlationId: this._correlationId() } : undefined);
136
+ content = JSON.parse(prepared.content);
137
+ }
138
+ catch (error) {
139
+ throw this.unsupported('append.serialization', event.constructor.name, `Payload or metadata could not be serialized: ${String(error)}.`);
140
+ }
141
+ try {
142
+ toContractsGuid(prepared.correlationId);
143
+ if (!/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test(prepared.correlationId.toString()))
144
+ throw new Error('Invalid correlation ID.');
145
+ }
146
+ catch {
147
+ throw this.unsupported('append.correlationId', event.constructor.name, 'Correlation ID must be a valid GUID.');
148
+ }
149
+ if (prepared.identity !== Identity.system || prepared.causationChain.length !== 2 ||
150
+ Object.keys(prepared.causationChain[0].properties).length !== 0) {
151
+ throw this.unsupported('append.context', event.constructor.name, 'Ambient identity or causation metadata is not fixture-backed.');
152
+ }
153
+ const properties = metadata.schema.properties;
154
+ if (!content || typeof content !== 'object' || Array.isArray(content) ||
155
+ Object.keys(content).length !== Object.keys(properties).length ||
156
+ Object.entries(properties).some(([key, property]) => typeof content[key] !== property.type ||
157
+ (property.type === 'string' && !/^[\x20-\x21\x23-\x5b\x5d-\x7e\u00e9]*$/.test(content[key])))) {
158
+ throw this.unsupported('append.content', event.constructor.name, 'Content differs from the flat scalar schema; null, missing and extra values are not proven.');
159
+ }
160
+ const occurred = this._clock();
161
+ // Date has millisecond precision; only the UTC year range representable by DateTimeOffset is supported.
162
+ if (!(occurred instanceof Date) || Number.isNaN(occurred.getTime()) ||
163
+ occurred.getUTCFullYear() < 1 || occurred.getUTCFullYear() > 9999) {
164
+ throw this.unsupported('append.clock', event.constructor.name, 'Clock must return a valid Date within UTC years 1–9999 (millisecond precision).');
165
+ }
166
+ const canonical = Object.fromEntries(Object.entries(content).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
167
+ const hash = createHash('sha256').update(`${prepared.eventType.id.value}|${eventSourceId}|${JSON.stringify(canonical)}`).digest('base64');
168
+ const sequenceNumber = new EventSequenceNumber(BigInt(this._history.length));
169
+ const stored = {
170
+ eventType: prepared.eventType,
171
+ content,
172
+ context: {
173
+ eventStore: this._store, namespace: this._namespace,
174
+ sequenceNumber: sequenceNumber.value, eventSourceId,
175
+ eventSourceType: 'Default', eventStreamType: 'All', eventStreamId: 'Default',
176
+ subject: eventSourceId, hash, causedBy: prepared.identity, observationState: EventObservationState.Initial,
177
+ eventType: prepared.eventType, occurred, correlationId: prepared.correlationId.toString(),
178
+ causation: prepared.causationChain.map(item => ({ type: item.type.name, occurred: item.occurred, properties: { ...item.properties } })),
179
+ tags: prepared.tags.map(tag => new Tag(tag))
180
+ }
181
+ };
182
+ this._history.push(this.snapshot(stored));
183
+ const result = Object.freeze({
184
+ sequenceNumber: Object.freeze(sequenceNumber), constraintViolations: Object.freeze([]), errors: Object.freeze([]), isSuccess: true,
185
+ waitForCompletion: async () => { throw this.unsupported('waitForCompletion', event.constructor.name, 'No observers run in process.'); }
186
+ });
187
+ if (!this._setup)
188
+ this._results.push(result);
189
+ return result;
190
+ }
191
+ finally {
192
+ // Keep the append in flight until its promise crosses an async boundary.
193
+ await Promise.resolve();
194
+ this._busy = false;
195
+ }
196
+ }
197
+ async appendMany() {
198
+ throw this.unsupported('appendMany', this.id.value, 'Batch atomicity and result mapping require kernel fixtures.');
199
+ }
200
+ async getNextSequenceNumber() { return new EventSequenceNumber(BigInt(this._history.length)); }
201
+ async getTailSequenceNumber(source, sourceType, streamType, streamId, types) {
202
+ if (sourceType !== undefined || streamType !== undefined || streamId !== undefined || types?.length) {
203
+ throw this.unsupported('getTailSequenceNumber.filters', this.id.value, 'Route and event-type tail filters are not fixture-backed.');
204
+ }
205
+ if (source !== undefined)
206
+ this.validateReadSource('getTailSequenceNumber.source', source);
207
+ const last = source === undefined ? this._history.at(-1) : [...this._history].reverse().find(event => event.context.eventSourceId === source);
208
+ return last ? new EventSequenceNumber(last.context.sequenceNumber) : EventSequenceNumber.unset;
209
+ }
210
+ async getTailSequenceNumberForObserver(observer) {
211
+ throw this.unsupported('getTailSequenceNumberForObserver', observer.name, 'Observer discovery is not fixture-backed.');
212
+ }
213
+ async hasEventsFor(source) {
214
+ this.validateReadSource('hasEventsFor.source', source);
215
+ return this._history.some(event => event.context.eventSourceId === source);
216
+ }
217
+ async getForEventSourceIdAndEventTypes(source, types, streamType, streamId, sourceType) {
218
+ if (streamType !== undefined || streamId !== undefined || sourceType !== undefined || !types.length) {
219
+ throw this.unsupported('getForEventSourceIdAndEventTypes.filters', source, 'Only explicit event-type/source filtering is fixture-backed.');
220
+ }
221
+ this.validateReadSource('getForEventSourceIdAndEventTypes.source', source);
222
+ const ids = types.map(type => {
223
+ const metadata = this._catalog.get(type);
224
+ if (!metadata)
225
+ throw this.unsupported('read.eventTypes', type.name, 'Event type is not in the selected catalog.');
226
+ return metadata.eventType.id.value;
227
+ });
228
+ return this._history.filter(event => event.context.eventSourceId === source && ids.includes(event.eventType.id.value)).map(event => this.snapshot(event));
229
+ }
230
+ async getFromSequenceNumber(sequence, source, types) {
231
+ if (sequence.value < 0n || sequence.value > EventSequenceNumber.unset.value) {
232
+ throw this.unsupported('getFromSequenceNumber.sequenceNumber', sequence.value.toString(), 'Sequence numbers must fit unsigned 64-bit wire values.');
233
+ }
234
+ if (types?.length)
235
+ throw this.unsupported('getFromSequenceNumber.filterEventTypes', this.id.value, 'Event-type filtering on sequence reads is not fixture-backed.');
236
+ if (source !== undefined)
237
+ this.validateReadSource('getFromSequenceNumber.source', source);
238
+ return this._history.filter(event => event.context.sequenceNumber >= sequence.value &&
239
+ (source === undefined || event.context.eventSourceId === source)).map(event => this.snapshot(event));
240
+ }
241
+ async redact() { throw this.unsupported('redact', this.id.value, 'Redaction requires kernel storage.'); }
242
+ async redactForEventSource() { throw this.unsupported('redactForEventSource', this.id.value, 'Redaction requires kernel storage.'); }
243
+ async completeStream() { throw this.unsupported('completeStream', this.id.value, 'Stream completion requires a kernel.'); }
244
+ snapshot(event) {
245
+ const eventType = new EventType(new EventTypeId(event.eventType.id.value), new EventTypeGeneration(event.eventType.generation.value), event.eventType.tombstone);
246
+ const causedBy = event.context.causedBy;
247
+ return {
248
+ eventType,
249
+ content: JSON.parse(JSON.stringify(event.content)),
250
+ context: { ...event.context, eventType, occurred: new Date(event.context.occurred),
251
+ causedBy: causedBy && new Identity(causedBy.subject, causedBy.name, causedBy.userName, causedBy.onBehalfOf),
252
+ causation: event.context.causation.map(item => ({ ...item, occurred: item.occurred && new Date(item.occurred), properties: { ...item.properties } })),
253
+ tags: event.context.tags.map(item => new Tag(item.value)) }
254
+ };
255
+ }
256
+ validateReadSource(operation, source) {
257
+ if (!source.trim() || source !== source.trim() || unprovenFilterCharacters.test(source)) {
258
+ throw this.unsupported(operation, source, 'Blank and padded source filters have unproven kernel normalization.');
259
+ }
260
+ }
261
+ unsupported(operation, artifact, reason) {
262
+ return new UnsupportedEventSequenceOperation(operation, artifact, reason);
263
+ }
264
+ }
265
+ //# sourceMappingURL=InProcessEventSequence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InProcessEventSequence.js","sourceRoot":"","sources":["../../testing/InProcessEventSequence.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,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G,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;gBACrJ,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE;SAClE,CAAC;IACN,CAAC;IAEO,kBAAkB,CAAC,SAAiB,EAAE,MAAc;QACxD,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,MAAM,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,wBAAwB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACtF,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,qEAAqE,CAAC,CAAC;QACrH,CAAC;IACL,CAAC;IAEO,WAAW,CAAC,SAAiB,EAAE,QAAgB,EAAE,MAAc;QACnE,OAAO,IAAI,iCAAiC,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC9E,CAAC;CACJ"}
@@ -2,19 +2,18 @@ import 'reflect-metadata';
2
2
  import type { Constructor } from '@cratis/fundamentals';
3
3
  import type { IClientArtifactsProvider } from '../artifacts/IClientArtifactsProvider.js';
4
4
  import { ReadModelScenarioGivenBuilder } from './ReadModelScenarioGivenBuilder.js';
5
- type ScenarioArtifacts = Pick<IClientArtifactsProvider, 'reducers' | 'eventTypes' | 'projections'>;
5
+ type ScenarioArtifacts = Pick<IClientArtifactsProvider, 'reducers' | 'eventTypes' | 'projections'> & Partial<Pick<IClientArtifactsProvider, 'readModels' | 'globalForHandlers'>>;
6
6
  /**
7
- * Folds seeded events through a reducer in-process, without a Chronicle kernel.
8
- * Projections, observer scheduling, storage, migrations, and compliance are not simulated.
7
+ * Folds seeded events through a reducer or a validated flat projection, without a Chronicle kernel.
8
+ * Observer scheduling, storage, migrations, and compliance are not simulated.
9
9
  * Supply an artifact catalog to isolate a scenario from process-wide decorator discovery.
10
10
  */
11
11
  export declare class ReadModelScenario<TReadModel extends object> {
12
- private readonly _readModelType;
13
- private readonly _reducerType;
14
- private readonly _dispatcher;
12
+ private readonly _processor;
13
+ private readonly _modelName;
15
14
  private readonly _events;
16
15
  private _results;
17
- /** Selects the reducer associated with the read model type. */
16
+ /** Selects the reducer (when present) or a single applicable compiled projection. */
18
17
  constructor(readModelType: Constructor<TReadModel>, artifacts?: ScenarioArtifacts);
19
18
  /** Fluent entry point for event history. */
20
19
  get given(): ReadModelScenarioGivenBuilder<TReadModel>;
@@ -27,7 +26,6 @@ export declare class ReadModelScenario<TReadModel extends object> {
27
26
  /** Collects events for a source; subsequent reads replay the complete seeded history. */
28
27
  collectEventsFor(id: string, events: readonly object[]): void;
29
28
  private process;
30
- private reduce;
31
29
  }
32
30
  export {};
33
31
  //# sourceMappingURL=ReadModelScenario.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReadModelScenario.d.ts","sourceRoot":"","sources":["../../testing/ReadModelScenario.ts"],"names":[],"mappings":"AAGA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AAczF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAEnF,KAAK,iBAAiB,GAAG,IAAI,CAAC,wBAAwB,EAAE,UAAU,GAAG,YAAY,GAAG,aAAa,CAAC,CAAC;AAKnG;;;;GAIG;AACH,qBAAa,iBAAiB,CAAC,UAAU,SAAS,MAAM;IACpD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA0B;IACzD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAc;IAC3C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAyB;IACrD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAC7C,OAAO,CAAC,QAAQ,CAA6D;IAE7E,+DAA+D;IAC/D,YAAY,aAAa,EAAE,WAAW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CAA+D;IAE/E,qFAAqF;IACrF,YAAY,aAAa,EAAE,WAAW,CAAC,UAAU,CAAC,EAAE,SAAS,CAAC,EAAE,iBAAiB,EAwChF;IAED,4CAA4C;IAC5C,IAAI,KAAK,IAAI,6BAA6B,CAAC,UAAU,CAAC,CAErD;IAED,yEAAyE;IACzE,IAAI,QAAQ,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAQzC;IAED,4FAA4F;IACtF,wBAAwB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAErE;IAED,yEAAyE;IACnE,0BAA0B,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE7D;IAED,yFAAyF;IACzF,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CA0B5D;IAED,OAAO,CAAC,OAAO;CAUlB"}
@@ -2,6 +2,7 @@
2
2
  // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
  import 'reflect-metadata';
4
4
  import { JsonSerializer } from '@cratis/fundamentals';
5
+ import { DefaultClientArtifactsProvider } from '../artifacts/DefaultClientArtifactsProvider.js';
5
6
  import { getEventTypeMetadata } from '../events/eventTypeDecorator.js';
6
7
  import { getFromEventMetadata } from '../projections/modelBound/fromEvent.js';
7
8
  import { getRemovedWithClassMetadata } from '../projections/modelBound/removedWith.js';
@@ -10,47 +11,65 @@ import { getClearWithClassMetadata } from '../projections/modelBound/clearWith.j
10
11
  import { getVariantOfMetadata } from '../projections/modelBound/variantOf.js';
11
12
  import { getEntersOnMetadata } from '../projections/modelBound/entersOn.js';
12
13
  import { getProjectionMetadata } from '../projections/declarative/projection.js';
14
+ import { ProjectionDefinitionCompiler } from '../projections/ProjectionDefinitionCompiler.js';
15
+ import { getReadModelId } from '../readModels/readModel.js';
13
16
  import { getReducerMetadata } from '../reducers/reducer.js';
14
- import { ReducerEventDispatcher } from '../reducers/ReducerEventDispatcher.js';
15
- import { DecoratorType } from '../types/DecoratorType.js';
16
17
  import { hasModelBoundProperties, TypeDiscoverer } from '../types/TypeDiscoverer.js';
17
18
  import { ReadModelScenarioGivenBuilder } from './ReadModelScenarioGivenBuilder.js';
19
+ import { ReducerReadModelProcessor } from './ReducerReadModelProcessor.js';
20
+ import { ProjectionReadModelProcessor } from './projections/ProjectionReadModelProcessor.js';
21
+ import { UnsupportedProjectionOperation } from './projections/UnsupportedProjectionOperation.js';
18
22
  /**
19
- * Folds seeded events through a reducer in-process, without a Chronicle kernel.
20
- * Projections, observer scheduling, storage, migrations, and compliance are not simulated.
23
+ * Folds seeded events through a reducer or a validated flat projection, without a Chronicle kernel.
24
+ * Observer scheduling, storage, migrations, and compliance are not simulated.
21
25
  * Supply an artifact catalog to isolate a scenario from process-wide decorator discovery.
22
26
  */
23
27
  export class ReadModelScenario {
24
- _readModelType;
25
- _reducerType;
26
- _dispatcher;
28
+ _processor;
29
+ _modelName;
27
30
  _events = [];
28
31
  _results;
29
- /** Selects the reducer associated with the read model type. */
32
+ /** Selects the reducer (when present) or a single applicable compiled projection. */
30
33
  constructor(readModelType, artifacts) {
31
- this._readModelType = readModelType;
32
- const registered = artifacts ?? {
33
- reducers: TypeDiscoverer.default.getTypesByDecoratorType(DecoratorType.Reducer),
34
- eventTypes: TypeDiscoverer.default.getTypesByDecoratorType(DecoratorType.EventType),
35
- projections: TypeDiscoverer.default.getTypesByDecoratorType(DecoratorType.Projection)
36
- };
34
+ this._modelName = readModelType.name;
35
+ const registered = artifacts ?? new DefaultClientArtifactsProvider(TypeDiscoverer.default);
37
36
  const reducerTypes = registered.reducers.filter(type => getReducerMetadata(type)?.readModel === readModelType);
38
37
  if (reducerTypes.length > 1) {
39
38
  throw new Error(`Multiple reducers found for read model '${readModelType.name}'.`);
40
39
  }
41
- if (reducerTypes.length === 0) {
42
- const projected = getFromEventMetadata(readModelType).length > 0 || hasModelBoundProperties(readModelType) ||
43
- getRemovedWithClassMetadata(readModelType).length > 0 || getRemovedWithJoinClassMetadata(readModelType).length > 0 ||
44
- getClearWithClassMetadata(readModelType).length > 0 || getVariantOfMetadata(readModelType) !== undefined ||
45
- getEntersOnMetadata(readModelType).length > 0 ||
46
- registered.projections.some(type => getProjectionMetadata(type)?.readModelType === readModelType);
47
- if (projected) {
48
- throw new Error(`Projection-backed read model '${readModelType.name}' is not supported yet; use a kernel-backed test.`);
49
- }
50
- throw new Error(`No reducer found for read model '${readModelType.name}'. Pass the read model type to @reducer; projections are not supported yet (use a kernel-backed test).`);
40
+ if (reducerTypes.length) {
41
+ this._processor = new ReducerReadModelProcessor(readModelType, reducerTypes[0], registered.eventTypes);
42
+ return;
43
+ }
44
+ const modelBound = getFromEventMetadata(readModelType).length > 0 || hasModelBoundProperties(readModelType) ||
45
+ getRemovedWithClassMetadata(readModelType).length > 0 || getRemovedWithJoinClassMetadata(readModelType).length > 0 ||
46
+ getClearWithClassMetadata(readModelType).length > 0 || getVariantOfMetadata(readModelType) !== undefined ||
47
+ getEntersOnMetadata(readModelType).length > 0;
48
+ // Definitions without a declared model can be associated by the registration compiler's
49
+ // unambiguous schema inference; never guess their association from decorators here.
50
+ const declarative = registered.projections.filter(type => {
51
+ const metadata = getProjectionMetadata(type);
52
+ return metadata !== undefined && (metadata.readModelType === readModelType ||
53
+ (metadata.readModelType === undefined && registered.readModels?.includes(readModelType)));
54
+ });
55
+ if (Number(modelBound) + declarative.filter(type => getProjectionMetadata(type)?.readModelType === readModelType).length > 1) {
56
+ throw new Error(`Multiple projections found for read model '${readModelType.name}'.`);
57
+ }
58
+ if (!modelBound && !declarative.length) {
59
+ throw new Error(`No reducer or projection found for read model '${readModelType.name}'.`);
60
+ }
61
+ const catalog = {
62
+ eventTypes: registered.eventTypes, reducers: registered.reducers, projections: declarative,
63
+ readModels: [...new Set([...(registered.readModels ?? []), readModelType])],
64
+ globalForHandlers: artifacts?.globalForHandlers ?? [], reactors: [], seeders: [], constraints: [],
65
+ webhooks: [], eventTypeMigrations: []
66
+ };
67
+ const compiled = new ProjectionDefinitionCompiler(catalog, 'scenario').compile(declarative, modelBound ? [readModelType] : []);
68
+ const definitions = compiled.definitions.filter(definition => definition.ReadModel === getReadModelId(readModelType));
69
+ if (definitions.length !== 1) {
70
+ throw new Error(`Expected one projection for read model '${readModelType.name}', found ${definitions.length}.`);
51
71
  }
52
- this._reducerType = reducerTypes[0];
53
- this._dispatcher = new ReducerEventDispatcher(this._reducerType, registered.eventTypes);
72
+ this._processor = new ProjectionReadModelProcessor(readModelType, compiled, definitions[0]);
54
73
  }
55
74
  /** Fluent entry point for event history. */
56
75
  get given() {
@@ -106,32 +125,13 @@ export class ReadModelScenario {
106
125
  process() {
107
126
  if (!this._results) {
108
127
  const events = [...this._events];
109
- this._results = this.reduce(events);
110
- }
111
- return this._results;
112
- }
113
- async reduce(events) {
114
- const results = new Map();
115
- const reducer = new this._reducerType();
116
- for (const event of events) {
117
- const handler = this._dispatcher.handlerFor(event.context.eventType.id.value);
118
- if (!handler)
119
- continue;
120
- const prior = results.get(event.sourceId);
121
- const previous = prior?.deleted ? undefined : prior?.instance;
122
- let next;
123
- try {
124
- next = await this._dispatcher.invoke(reducer, handler, event.content, previous, event.context);
125
- }
126
- catch (cause) {
127
- throw new Error(`Reducer '${this._reducerType.name}' for read model '${this._readModelType.name}' failed`, { cause });
128
- }
129
- results.set(event.sourceId, {
130
- instance: next === undefined ? null : next,
131
- deleted: next === undefined
128
+ this._results = this._processor.process(events).catch(error => {
129
+ if (!(this._processor instanceof ProjectionReadModelProcessor) || error instanceof UnsupportedProjectionOperation)
130
+ throw error;
131
+ throw new Error(`Projection replay for read model '${this._modelName}' failed: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
132
132
  });
133
133
  }
134
- return results;
134
+ return this._results;
135
135
  }
136
136
  }
137
137
  //# sourceMappingURL=ReadModelScenario.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReadModelScenario.js","sourceRoot":"","sources":["../../testing/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AAY,4BAA4B,CAAC,IAAI,KAAK,YAAY,8BAA8B;oBAAE,MAAM,KAAK,CAAC;gBAC/H,MAAM,IAAI,KAAK,CAAC,qCAAqC,IAAI,CAAC,UAAU,aAAa,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;YACjK,CAAC,CAAC,CAAC;QACP,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;CACJ"}
@@ -0,0 +1,6 @@
1
+ /** Materialized state and explicit removal status for one source. */
2
+ export type ReadModelState<T> = {
3
+ instance: T | null;
4
+ deleted: boolean;
5
+ };
6
+ //# sourceMappingURL=ReadModelState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadModelState.d.ts","sourceRoot":"","sources":["../../testing/ReadModelState.ts"],"names":[],"mappings":"AAGA,qEAAqE;AACrE,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC"}
@@ -0,0 +1,4 @@
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 {};
4
+ //# sourceMappingURL=ReadModelState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadModelState.js","sourceRoot":"","sources":["../../testing/ReadModelState.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG"}
@@ -0,0 +1,13 @@
1
+ import type { Constructor } from '@cratis/fundamentals';
2
+ import type { IReadModelProcessor } from './IReadModelProcessor.js';
3
+ import type { ReadModelState } from './ReadModelState.js';
4
+ import type { ScenarioEvent } from './ScenarioEvent.js';
5
+ /** Preserves the SDK reducer dispatch and the scenario's null-versus-deletion semantics. */
6
+ export declare class ReducerReadModelProcessor<TReadModel extends object> implements IReadModelProcessor<TReadModel> {
7
+ private readonly _readModelType;
8
+ private readonly _reducerType;
9
+ private readonly _dispatcher;
10
+ constructor(_readModelType: Constructor<TReadModel>, _reducerType: Constructor, eventTypes: Constructor[]);
11
+ process(events: readonly ScenarioEvent[]): Promise<Map<string, ReadModelState<TReadModel>>>;
12
+ }
13
+ //# sourceMappingURL=ReducerReadModelProcessor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReducerReadModelProcessor.d.ts","sourceRoot":"","sources":["../../testing/ReducerReadModelProcessor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,4FAA4F;AAC5F,qBAAa,yBAAyB,CAAC,UAAU,SAAS,MAAM,CAAE,YAAW,mBAAmB,CAAC,UAAU,CAAC;IAG5F,OAAO,CAAC,QAAQ,CAAC,cAAc;IAA2B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAFnG,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAyB;IAErD,YAA6B,cAAc,EAAE,WAAW,CAAC,UAAU,CAAC,EAAmB,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,EAE1I;IAEK,OAAO,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,CAoBhG;CACJ"}