@cratis/chronicle 6.41.0 → 6.41.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/compliance/for_PIIManager/against_a_kernel/when_erasing_a_subject.integration.spec.ts +4 -4
- package/compliance/resolveEventSubject.ts +19 -0
- package/compliance/subject.ts +2 -2
- package/dist/compliance/resolveEventSubject.d.ts +3 -0
- package/dist/compliance/resolveEventSubject.d.ts.map +1 -0
- package/dist/compliance/resolveEventSubject.js +21 -0
- package/dist/compliance/resolveEventSubject.js.map +1 -0
- package/dist/compliance/subject.d.ts +2 -2
- package/dist/compliance/subject.js +2 -2
- package/dist/eventSequences/AppendOptions.d.ts +1 -1
- package/dist/eventSequences/AppendOptions.d.ts.map +1 -1
- package/dist/eventSequences/EventForEventSourceId.d.ts +1 -1
- package/dist/eventSequences/EventForEventSourceId.d.ts.map +1 -1
- package/dist/eventSequences/EventSequence.js +2 -2
- package/dist/eventSequences/EventSequence.js.map +1 -1
- package/dist/eventSequences/prepareBatchAppend.d.ts.map +1 -1
- package/dist/eventSequences/prepareBatchAppend.js +2 -1
- package/dist/eventSequences/prepareBatchAppend.js.map +1 -1
- package/dist/eventSequences/prepareSingleAppend.d.ts +1 -0
- package/dist/eventSequences/prepareSingleAppend.d.ts.map +1 -1
- package/dist/eventSequences/prepareSingleAppend.js +3 -1
- package/dist/eventSequences/prepareSingleAppend.js.map +1 -1
- package/dist/testing/InProcessEventSequence.d.ts.map +1 -1
- package/dist/testing/InProcessEventSequence.js +16 -6
- package/dist/testing/InProcessEventSequence.js.map +1 -1
- package/dist/testing/ReadModelScenario.d.ts.map +1 -1
- package/dist/testing/ReadModelScenario.js +4 -0
- package/dist/testing/ReadModelScenario.js.map +1 -1
- package/dist/testing/singleAppendRoute.d.ts +1 -1
- package/dist/testing/singleAppendRoute.d.ts.map +1 -1
- package/dist/testing/singleAppendRoute.js +8 -4
- package/dist/testing/singleAppendRoute.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/eventSequences/AppendOptions.ts +1 -1
- package/eventSequences/EventForEventSourceId.ts +1 -1
- package/eventSequences/EventSequence.ts +2 -2
- package/eventSequences/for_EventSequence/when_appending/subject_behaviors.fixture.ts +239 -0
- package/eventSequences/for_EventSequence/when_appending/with_subject_annotations.spec.ts +34 -0
- package/eventSequences/for_EventSequence/when_appending/with_subject_annotations.standard.spec.ts +38 -0
- package/eventSequences/prepareBatchAppend.ts +2 -1
- package/eventSequences/prepareSingleAppend.ts +3 -1
- package/package.json +2 -2
- package/testing/EventScenario.batches.spec.ts +2 -2
- package/testing/EventScenario.fixtures.spec.ts +2 -2
- package/testing/EventScenario.rejections.spec.ts +2 -2
- package/testing/InProcessEventSequence.ts +17 -6
- package/testing/ReadModelScenario.spec.ts +31 -0
- package/testing/ReadModelScenario.ts +4 -0
- package/testing/for_EventScenario/when_appending_scoped_constraints/with_unproven_operations.spec.ts +1 -1
- package/testing/for_ReadModelScenario/when_seeding_with_options/with_route_validation.spec.ts +11 -1
- package/testing/singleAppendRoute.spec.ts +19 -0
- package/testing/singleAppendRoute.ts +9 -4
|
@@ -6,16 +6,21 @@ import { UnsupportedEventSequenceOperation } from './UnsupportedEventSequenceOpe
|
|
|
6
6
|
|
|
7
7
|
/** The fixture-proven single-append route boundary, shared with read-model setup. */
|
|
8
8
|
export function singleAppendRoute(options: AppendOptions | undefined, artifact: string,
|
|
9
|
-
unsupported = (operation: string, artifact: string, reason: string) => new UnsupportedEventSequenceOperation(operation, artifact, reason)
|
|
9
|
+
unsupported = (operation: string, artifact: string, reason: string) => new UnsupportedEventSequenceOperation(operation, artifact, reason),
|
|
10
|
+
allowSubject = false
|
|
10
11
|
): { sourceType: string; streamType: string; streamId: string } {
|
|
11
12
|
if (options !== undefined && (!options || typeof options !== 'object' || Array.isArray(options))) {
|
|
12
13
|
throw unsupported('append.options', artifact, 'Append options must be an object.');
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
const allowed = ['sourceType', 'streamType', 'streamId', ...(allowSubject ? ['subject'] : [])];
|
|
16
|
+
if (options && (Reflect.ownKeys(options).some(key => !allowed.includes(String(key))) ||
|
|
17
|
+
options.correlationId !== undefined || (!allowSubject && options.subject !== undefined) || options.occurred !== undefined ||
|
|
16
18
|
options.eventSourceId !== undefined || options.concurrencyScope !== undefined || options.tags !== undefined ||
|
|
17
19
|
options.concurrencyScopes !== undefined)) {
|
|
18
|
-
throw unsupported('append.options', artifact,
|
|
20
|
+
throw unsupported('append.options', artifact, `Only ${allowed.join(', ')} options are supported for single append.`);
|
|
21
|
+
}
|
|
22
|
+
if (options?.subject !== undefined && options.subject !== null && typeof options.subject !== 'string') {
|
|
23
|
+
throw unsupported('append.subject', artifact, 'Subject must be a string.');
|
|
19
24
|
}
|
|
20
25
|
const route = { sourceType: options?.sourceType, streamType: options?.streamType, streamId: options?.streamId };
|
|
21
26
|
for (const [name, value] of Object.entries(route)) {
|