@cratis/chronicle 6.31.4 → 6.32.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 (45) hide show
  1. package/dist/schemas/JsonSchemaGenerator.d.ts +4 -4
  2. package/dist/schemas/JsonSchemaGenerator.d.ts.map +1 -1
  3. package/dist/schemas/JsonSchemaGenerator.js +23 -8
  4. package/dist/schemas/JsonSchemaGenerator.js.map +1 -1
  5. package/dist/testing/ConstraintScope.d.ts +9 -0
  6. package/dist/testing/ConstraintScope.d.ts.map +1 -0
  7. package/dist/testing/ConstraintScope.js +36 -0
  8. package/dist/testing/ConstraintScope.js.map +1 -0
  9. package/dist/testing/EventScenario.d.ts.map +1 -1
  10. package/dist/testing/EventScenario.js +10 -0
  11. package/dist/testing/EventScenario.js.map +1 -1
  12. package/dist/testing/InProcessConstraints.d.ts +1 -1
  13. package/dist/testing/InProcessConstraints.d.ts.map +1 -1
  14. package/dist/testing/InProcessConstraints.js +23 -13
  15. package/dist/testing/InProcessConstraints.js.map +1 -1
  16. package/dist/testing/InProcessEventSequence.d.ts +1 -0
  17. package/dist/testing/InProcessEventSequence.d.ts.map +1 -1
  18. package/dist/testing/InProcessEventSequence.js +23 -8
  19. package/dist/testing/InProcessEventSequence.js.map +1 -1
  20. package/dist/testing/projections/ProjectionChildrenCapabilities.d.ts +2 -1
  21. package/dist/testing/projections/ProjectionChildrenCapabilities.d.ts.map +1 -1
  22. package/dist/testing/projections/ProjectionChildrenCapabilities.js +9 -3
  23. package/dist/testing/projections/ProjectionChildrenCapabilities.js.map +1 -1
  24. package/dist/tsconfig.tsbuildinfo +1 -1
  25. package/package.json +2 -2
  26. package/schemas/JsonSchemaGenerator.ts +22 -7
  27. package/schemas/for_JsonSchemaGenerator/when_generating_children/with_legacy_decorators.legacy.spec.ts +143 -0
  28. package/schemas/for_JsonSchemaGenerator/when_generating_children/with_standard_decorators.standard.spec.ts +66 -0
  29. package/testing/ConstraintScope.ts +32 -0
  30. package/testing/EventScenario.batches.spec.ts +2 -5
  31. package/testing/EventScenario.constraints.spec.ts +1 -4
  32. package/testing/EventScenario.fixtures.spec.ts +1 -1
  33. package/testing/EventScenario.ts +12 -0
  34. package/testing/InProcessConstraints.ts +29 -16
  35. package/testing/InProcessEventSequence.ts +24 -8
  36. package/testing/ReadModelScenario.childrenFrom.spec.ts +70 -3
  37. package/testing/for_EventScenario/when_appending_scoped_constraints/scope_scenario_behaviors.fixture.ts +139 -0
  38. package/testing/for_EventScenario/when_appending_scoped_constraints/with_legacy_decorators.legacy.spec.ts +57 -0
  39. package/testing/for_EventScenario/when_appending_scoped_constraints/with_standard_decorators.standard.spec.ts +56 -0
  40. package/testing/for_EventScenario/when_appending_scoped_constraints/with_unproven_cycles.spec.ts +48 -0
  41. package/testing/for_EventScenario/when_appending_scoped_constraints/with_unproven_operations.spec.ts +119 -0
  42. package/testing/for_ReactorScenario/when_enforcing_scoped_constraints/with_default_input_routes.spec.ts +70 -0
  43. package/testing/for_ReactorScenario/when_enforcing_scoped_constraints/with_routed_service_appends.spec.ts +65 -0
  44. package/testing/projections/ProjectionChildrenCapabilities.ts +9 -2
  45. package/testing/projections/for_ProjectionCapabilities/when_rejecting_unsupported_children_operations.spec.ts +34 -0
@@ -8,6 +8,7 @@ import { chai, describe, it } from 'vitest';
8
8
  import { eventType } from '../../../events/eventTypeDecorator.js';
9
9
  import type { ChildrenDefinitionLike } from '../../../projections/modelBound/childrenAndNestedBuilder.js';
10
10
  import { childrenFrom } from '../../../projections/modelBound/childrenFrom.js';
11
+ import type { JsonSchema } from '../../../schemas/JsonSchema.js';
11
12
  import { ProjectionCapabilities } from '../ProjectionCapabilities.js';
12
13
  import { UnsupportedProjectionOperation } from '../UnsupportedProjectionOperation.js';
13
14
  import { Changed } from './given/Changed.js';
@@ -32,12 +33,45 @@ function compileChildren() {
32
33
  return { ...result, wire, child: wire.Children.labels };
33
34
  }
34
35
 
36
+ function compileTypedChildren() {
37
+ const result = compileChildren();
38
+ result.child.IdentifiedBy = 'itemId';
39
+ result.child.From[0].Value.Properties = {};
40
+ const schema = JSON.parse(result.compiled.readModels[0].Schema) as JsonSchema;
41
+ schema.properties!.labels.items = {
42
+ type: 'object', properties: { itemId: { type: 'string' }, name: { type: 'string' } }
43
+ };
44
+ result.compiled.readModels[0].Schema = JSON.stringify(schema);
45
+ return result;
46
+ }
47
+
35
48
  describe('when rejecting unsupported children operations before any event is seeded', () => {
36
49
  it('should accept the fixture-backed keyed children shape', () => {
37
50
  const { compiled, definition } = compileChildren();
38
51
  (() => ProjectionCapabilities.validate(compiled, definition)).should.not.throw();
39
52
  });
40
53
 
54
+ it('should accept AutoMap into a typed child identifier from the entry key alone', () => {
55
+ const { compiled, definition } = compileTypedChildren();
56
+ (() => ProjectionCapabilities.validate(compiled, definition)).should.not.throw();
57
+ });
58
+
59
+ it('should reject AutoMap into a typed child identifier from a property other than the entry key', () => {
60
+ const { compiled, definition, child } = compileTypedChildren();
61
+ child.From[0].Value.Key = 'name';
62
+ (() => ProjectionCapabilities.validate(compiled, definition)).should.throw(UnsupportedProjectionOperation)
63
+ .with.property('message').that.includes('Children.labels.From[capability-child-added:1].AutoMap.itemId')
64
+ .and.includes('AutoMap into the child identifier');
65
+ });
66
+
67
+ it('should reject ambiguous AutoMap into a typed child identifier even if one candidate is the entry key', () => {
68
+ const { compiled, definition } = compileTypedChildren();
69
+ compiled.eventSchemas.get(definition)!.get('capability-child-added:1:0')!.schema.properties!.ItemId = { type: 'string' };
70
+ (() => ProjectionCapabilities.validate(compiled, definition)).should.throw(UnsupportedProjectionOperation)
71
+ .with.property('message').that.includes('Children.labels.From[capability-child-added:1].AutoMap.itemId')
72
+ .and.includes('AutoMap into the child identifier');
73
+ });
74
+
41
75
  const cases: Array<{ name: string; change: (child: ChildrenDefinitionLike, wire: Wire) => void; path: string; reason: string }> = [
42
76
  { name: 'a join inside children', change: child => { child.Join = [{}]; }, path: 'Children.labels.Join', reason: 'joins require a kernel-backed test' },
43
77
  { name: 'nested children collections', change: child => { child.Children = { inner: child }; }, path: 'Children.labels.Children', reason: 'nested children collections' },