@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.
Files changed (52) hide show
  1. package/compliance/for_PIIManager/against_a_kernel/when_erasing_a_subject.integration.spec.ts +4 -4
  2. package/compliance/resolveEventSubject.ts +19 -0
  3. package/compliance/subject.ts +2 -2
  4. package/dist/compliance/resolveEventSubject.d.ts +3 -0
  5. package/dist/compliance/resolveEventSubject.d.ts.map +1 -0
  6. package/dist/compliance/resolveEventSubject.js +21 -0
  7. package/dist/compliance/resolveEventSubject.js.map +1 -0
  8. package/dist/compliance/subject.d.ts +2 -2
  9. package/dist/compliance/subject.js +2 -2
  10. package/dist/eventSequences/AppendOptions.d.ts +1 -1
  11. package/dist/eventSequences/AppendOptions.d.ts.map +1 -1
  12. package/dist/eventSequences/EventForEventSourceId.d.ts +1 -1
  13. package/dist/eventSequences/EventForEventSourceId.d.ts.map +1 -1
  14. package/dist/eventSequences/EventSequence.js +2 -2
  15. package/dist/eventSequences/EventSequence.js.map +1 -1
  16. package/dist/eventSequences/prepareBatchAppend.d.ts.map +1 -1
  17. package/dist/eventSequences/prepareBatchAppend.js +2 -1
  18. package/dist/eventSequences/prepareBatchAppend.js.map +1 -1
  19. package/dist/eventSequences/prepareSingleAppend.d.ts +1 -0
  20. package/dist/eventSequences/prepareSingleAppend.d.ts.map +1 -1
  21. package/dist/eventSequences/prepareSingleAppend.js +3 -1
  22. package/dist/eventSequences/prepareSingleAppend.js.map +1 -1
  23. package/dist/testing/InProcessEventSequence.d.ts.map +1 -1
  24. package/dist/testing/InProcessEventSequence.js +16 -6
  25. package/dist/testing/InProcessEventSequence.js.map +1 -1
  26. package/dist/testing/ReadModelScenario.d.ts.map +1 -1
  27. package/dist/testing/ReadModelScenario.js +4 -0
  28. package/dist/testing/ReadModelScenario.js.map +1 -1
  29. package/dist/testing/singleAppendRoute.d.ts +1 -1
  30. package/dist/testing/singleAppendRoute.d.ts.map +1 -1
  31. package/dist/testing/singleAppendRoute.js +8 -4
  32. package/dist/testing/singleAppendRoute.js.map +1 -1
  33. package/dist/tsconfig.tsbuildinfo +1 -1
  34. package/eventSequences/AppendOptions.ts +1 -1
  35. package/eventSequences/EventForEventSourceId.ts +1 -1
  36. package/eventSequences/EventSequence.ts +2 -2
  37. package/eventSequences/for_EventSequence/when_appending/subject_behaviors.fixture.ts +239 -0
  38. package/eventSequences/for_EventSequence/when_appending/with_subject_annotations.spec.ts +34 -0
  39. package/eventSequences/for_EventSequence/when_appending/with_subject_annotations.standard.spec.ts +38 -0
  40. package/eventSequences/prepareBatchAppend.ts +2 -1
  41. package/eventSequences/prepareSingleAppend.ts +3 -1
  42. package/package.json +2 -2
  43. package/testing/EventScenario.batches.spec.ts +2 -2
  44. package/testing/EventScenario.fixtures.spec.ts +2 -2
  45. package/testing/EventScenario.rejections.spec.ts +2 -2
  46. package/testing/InProcessEventSequence.ts +17 -6
  47. package/testing/ReadModelScenario.spec.ts +31 -0
  48. package/testing/ReadModelScenario.ts +4 -0
  49. package/testing/for_EventScenario/when_appending_scoped_constraints/with_unproven_operations.spec.ts +1 -1
  50. package/testing/for_ReadModelScenario/when_seeding_with_options/with_route_validation.spec.ts +11 -1
  51. package/testing/singleAppendRoute.spec.ts +19 -0
  52. 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
- if (options && (Reflect.ownKeys(options).some(key => !['sourceType', 'streamType', 'streamId'].includes(String(key))) ||
15
- options.correlationId !== undefined || options.subject !== undefined || options.occurred !== undefined ||
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, 'Only sourceType, streamType and streamId routing options are fixture-backed for single append.');
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)) {