@cratis/chronicle 6.67.1 → 6.67.3
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/testing/EventScenario.d.ts.map +1 -1
- package/dist/testing/EventScenario.js +55 -24
- package/dist/testing/EventScenario.js.map +1 -1
- package/package.json +1 -1
- package/testing/EventScenario.constraint-composite.spec.ts +1 -1
- package/testing/EventScenario.fixtures.spec.ts +2 -1
- package/testing/EventScenario.ts +63 -28
- package/testing/for_EventScenario/when_appending_field_combinations/combination_behaviors.fixture.ts +122 -0
- package/testing/for_EventScenario/when_appending_field_combinations/definition_rejection_behaviors.fixture.ts +112 -0
- package/testing/for_EventScenario/when_appending_field_combinations/with_legacy_decorators.legacy.spec.ts +35 -0
- package/testing/for_EventScenario/when_appending_field_combinations/with_standard_decorators.standard.spec.ts +34 -0
- package/testing/for_EventScenario/when_appending_field_types/with_unproven_schemas.legacy.spec.ts +2 -4
- package/testing/for_EventScenario/when_appending_scoped_constraints/scope_scenario_behaviors.fixture.ts +4 -2
- package/testing/for_EventScenario/when_appending_scoped_constraints/with_legacy_decorators.legacy.spec.ts +14 -4
- package/testing/for_EventScenario/when_appending_scoped_constraints/with_standard_decorators.standard.spec.ts +14 -4
- package/testing/for_EventScenario/when_appending_scoped_constraints/with_unproven_operations.spec.ts +13 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventScenario.d.ts","sourceRoot":"","sources":["../../testing/EventScenario.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACxF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAC1E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CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IAO9F,IAAI,OAAO,IAAI,SAAS,YAAY,EAAE,CAAmE;IACzG,IAAI,cAAc,IAAI,SAAS,aAAa,EAAE,CAA0E;IAExH,+DAA+D;IAC/D,IAAI,IAAI,IAAI;QAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,CAAC;QAAC,QAAQ,CAAC,cAAc,EAAE,SAAS,aAAa,EAAE,CAAA;KAAE,CAE3G;CACJ"}
|
|
@@ -15,6 +15,56 @@ import { EventScenarioWhenBuilder } from './EventScenarioWhenBuilder.js';
|
|
|
15
15
|
import { InProcessEventSequence } from './InProcessEventSequence.js';
|
|
16
16
|
import { registerScenarioSeed } from './EventScenarioSeed.js';
|
|
17
17
|
import { UnsupportedEventSequenceOperation } from './UnsupportedEventSequenceOperation.js';
|
|
18
|
+
function hasPlainScalarSchemas(schemas) {
|
|
19
|
+
return schemas.every(schema => ['string', 'boolean'].includes(schema?.type ?? '') && schema?.format === undefined);
|
|
20
|
+
}
|
|
21
|
+
function hasCombinedKeySchemas(schemas) {
|
|
22
|
+
return schemas.every(schema => schema?.type === 'string' && (schema.format === undefined || schema.format === 'guid') ||
|
|
23
|
+
schema?.type === 'number' && schema.format === undefined);
|
|
24
|
+
}
|
|
25
|
+
function isGuidOrNumericKey(schema) {
|
|
26
|
+
return schema?.format === 'guid' || schema?.type === 'number';
|
|
27
|
+
}
|
|
28
|
+
function validateExtendedDefinition(name, unique, constructors) {
|
|
29
|
+
if (!unique)
|
|
30
|
+
return;
|
|
31
|
+
const schemas = unique.eventDefinitions.flatMap(entry => entry.properties.map(property => getEventTypeMetadata(constructors.get(entry.eventTypeId))?.schema.properties?.[property]));
|
|
32
|
+
if (!schemas.some(isGuidOrNumericKey))
|
|
33
|
+
return;
|
|
34
|
+
if (schemas.some(schema => schema?.type === 'boolean')) {
|
|
35
|
+
throw new UnsupportedEventSequenceOperation('artifacts.constraints', name, 'Boolean keys mixed with Guid or numeric keys in one definition are not fixture-backed.');
|
|
36
|
+
}
|
|
37
|
+
const removers = [unique.removedWithEventTypeId, ...(unique.removedWithEventTypeIds ?? [])].filter(id => id !== undefined);
|
|
38
|
+
if (unique.eventDefinitions.some(entry => removers.includes(entry.eventTypeId))) {
|
|
39
|
+
throw new UnsupportedEventSequenceOperation('artifacts.constraints', name, 'Guid and numeric keys with covered-and-removal events are not fixture-backed.');
|
|
40
|
+
}
|
|
41
|
+
if (removers.some(id => Object.keys(getEventTypeMetadata(constructors.get(id))?.schema.properties ?? {}).length === 0)) {
|
|
42
|
+
throw new UnsupportedEventSequenceOperation('artifacts.constraints', name, 'Guid and numeric keys with fieldless removal events are not fixture-backed.');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function validateKeySchemas(name, schemas, options) {
|
|
46
|
+
const fail = (reason) => { throw new UnsupportedEventSequenceOperation('artifacts.constraints', name, reason); };
|
|
47
|
+
const plainStrings = schemas.every(schema => schema?.type === 'string' && schema.format === undefined);
|
|
48
|
+
if (options.scoped && !hasPlainScalarSchemas(schemas) && !hasCombinedKeySchemas(schemas)) {
|
|
49
|
+
fail('Scoped property keys must be schema-backed strings, booleans, Guids or unformatted numbers.');
|
|
50
|
+
}
|
|
51
|
+
for (const schema of schemas) {
|
|
52
|
+
const supported = schema?.type === 'boolean' && schema.format === undefined ||
|
|
53
|
+
schema?.type === 'string' && (schema.format === undefined || schema.format === 'guid') ||
|
|
54
|
+
schema?.type === 'number' && (schema.format === undefined || schema.format === 'double');
|
|
55
|
+
if (!supported)
|
|
56
|
+
fail(`Unique keys with schema ${schema?.type ?? 'missing'}/${schema?.format ?? 'unformatted'} are not fixture-backed; date, object and other numeric formats require a kernel-backed test.`);
|
|
57
|
+
}
|
|
58
|
+
if (schemas.some(isGuidOrNumericKey) &&
|
|
59
|
+
(options.definitions !== 1 || !options.isolated && !hasCombinedKeySchemas(schemas))) {
|
|
60
|
+
fail('Guid and numeric keys require one definition; combined keys require unformatted numbers or Guids.');
|
|
61
|
+
}
|
|
62
|
+
if (options.ignoreCasing && !plainStrings)
|
|
63
|
+
fail('Case-insensitive keys must be schema-backed strings.');
|
|
64
|
+
if (schemas.length > 1 && !hasCombinedKeySchemas(schemas)) {
|
|
65
|
+
fail('Every property of a composite key must be a schema-backed string, Guid or unformatted number.');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
18
68
|
function hasConstraintDecorators(type) {
|
|
19
69
|
return getUniqueEventMetadata(type) !== undefined || getRemovedConstraintNames(type).length > 0 ||
|
|
20
70
|
TypeIntrospector.getTrackedProperties(type).some(property => getUniquePropertyMetadata(type, property) !== undefined);
|
|
@@ -93,33 +143,14 @@ export class EventScenario {
|
|
|
93
143
|
})) {
|
|
94
144
|
throw new UnsupportedEventSequenceOperation('artifacts.constraints', name, 'Scoped fieldless removal events are not fixture-backed.');
|
|
95
145
|
}
|
|
146
|
+
validateExtendedDefinition(name, capture.uniqueConstraint, constructorsById);
|
|
96
147
|
for (const entry of capture.uniqueConstraint?.eventDefinitions ?? []) {
|
|
97
148
|
const type = eventTypes.find(type => getEventTypeFor(type).id.value === entry.eventTypeId);
|
|
98
149
|
const schemas = entry.properties.map(property => getEventTypeMetadata(type)?.schema.properties?.[property]);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
for (const schema of schemas) {
|
|
104
|
-
const supported = schema?.type === 'boolean' && schema.format === undefined ||
|
|
105
|
-
schema?.type === 'string' && (schema.format === undefined || schema.format === 'guid') ||
|
|
106
|
-
schema?.type === 'number' && (schema.format === undefined || schema.format === 'double');
|
|
107
|
-
if (!supported)
|
|
108
|
-
throw new UnsupportedEventSequenceOperation('artifacts.constraints', name, `Unique keys with schema ${schema?.type ?? 'missing'}/${schema?.format ?? 'unformatted'} are not fixture-backed; date, object and other numeric formats require a kernel-backed test.`);
|
|
109
|
-
}
|
|
110
|
-
const extendedKey = schemas.some(schema => schema?.type === 'number' || schema?.format === 'guid');
|
|
111
|
-
if (extendedKey && (applicable.size !== 1 || capture.uniqueConstraint.eventDefinitions.length !== 1 ||
|
|
112
|
-
removedWith.some(id => id !== undefined))) {
|
|
113
|
-
throw new UnsupportedEventSequenceOperation('artifacts.constraints', name, 'Guid and numeric keys require one isolated definition covering one event type without removers; shared definitions and removal combinations are not fixture-backed.');
|
|
114
|
-
}
|
|
115
|
-
// constraints-ignore-casing.json captures folded string keys only.
|
|
116
|
-
if (capture.uniqueConstraint.ignoreCasing && !plainStrings) {
|
|
117
|
-
throw new UnsupportedEventSequenceOperation('artifacts.constraints', name, 'Case-insensitive keys must be schema-backed strings.');
|
|
118
|
-
}
|
|
119
|
-
// constraints-composite.json captures string components only.
|
|
120
|
-
if (entry.properties.length > 1 && !plainStrings) {
|
|
121
|
-
throw new UnsupportedEventSequenceOperation('artifacts.constraints', name, 'Every property of a composite key must be a schema-backed string.');
|
|
122
|
-
}
|
|
150
|
+
validateKeySchemas(name, schemas, { scoped, definitions: applicable.size,
|
|
151
|
+
isolated: !scoped && capture.uniqueConstraint.eventDefinitions.length === 1 &&
|
|
152
|
+
!removedWith.some(id => id !== undefined),
|
|
153
|
+
ignoreCasing: capture.uniqueConstraint.ignoreCasing });
|
|
123
154
|
}
|
|
124
155
|
}
|
|
125
156
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventScenario.js","sourceRoot":"","sources":["../../testing/EventScenario.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,EAAE,8BAA8B,EAAE,MAAM,gDAAgD,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAOhE,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACxF,OAAO,EAAE,kBAAkB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AAI,CAAC,aAAa,CAAC,UAAU,CAAC,cAAc,EAAE,eAA4C,CAAC,CAAC;IACvG,CAAC;IACD,IAAI,OAAO,KAA8B,OAAQ,IAAI,CAAC,aAAwC,CAAC,OAAO,CAAC,CAAC,CAAC;IACzG,IAAI,cAAc,KAA+B,OAAQ,IAAI,CAAC,aAAwC,CAAC,cAAc,CAAC,CAAC,CAAC;IAExH,+DAA+D;IAC/D,IAAI,IAAI;QACJ,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC;IAC1E,CAAC;CACJ"}
|
package/package.json
CHANGED
|
@@ -248,7 +248,7 @@ describe('fixture-backed composite unique-property keys', () => {
|
|
|
248
248
|
constraint('OracleMixed')(Single);
|
|
249
249
|
new EventScenario({ artifacts: { eventTypes: [Mixed], constraints: [Single] } }).should.be.instanceOf(EventScenario);
|
|
250
250
|
await unsupported(() => new EventScenario({ artifacts: { eventTypes: [Mixed], constraints: [Composite] } }),
|
|
251
|
-
'artifacts.constraints (OracleMixed)', 'Every property of a composite key must be a schema-backed string.');
|
|
251
|
+
'artifacts.constraints (OracleMixed)', 'Every property of a composite key must be a schema-backed string, Guid or unformatted number.');
|
|
252
252
|
});
|
|
253
253
|
|
|
254
254
|
it('rejects an unproven component value in a batch and leaves history, results and claims unchanged', async () => {
|
|
@@ -59,7 +59,8 @@ const fixtures = readdirSync(directory).filter(name => name.endsWith('.json') &&
|
|
|
59
59
|
!['batches.json', 'batch-omitted-routes.json', 'batch-rollback.json', 'builders.json', 'constraints.json', 'constraints-isolation.json', 'constraints-key-domain.json',
|
|
60
60
|
'constraints-property-lifecycle.json', 'constraints-property-covered-removal.json', 'constraints-event-type-cycles.json',
|
|
61
61
|
'constraints-event-type-siblings.json', 'constraints-composite.json',
|
|
62
|
-
'constraints-ignore-casing.json', 'constraints-scopes.json', 'constraints-field-types.json', 'constraints-event-sequences.json'
|
|
62
|
+
'constraints-ignore-casing.json', 'constraints-scopes.json', 'constraints-field-types.json', 'constraints-event-sequences.json',
|
|
63
|
+
'constraints-field-combinations.json'].includes(name)).map(name => ({
|
|
63
64
|
name, fixture: JSON.parse(readFileSync(new URL(name, directory), 'utf8')) as Fixture
|
|
64
65
|
}));
|
|
65
66
|
const artifacts = { eventTypes: [OracleEventRecorded, AlternateRecorded, BoundaryRecorded], constraints: [] };
|
package/testing/EventScenario.ts
CHANGED
|
@@ -13,6 +13,7 @@ import type { IEventLog } from '../eventSequences/IEventLog.js';
|
|
|
13
13
|
import { EventSequenceId } from '../eventSequences/EventSequenceId.js';
|
|
14
14
|
import { getEventTypeFor, getEventTypeMetadata } from '../events/eventTypeDecorator.js';
|
|
15
15
|
import { compileConstraints } from '../events/constraints/Constraints.js';
|
|
16
|
+
import type { UniqueConstraintCapture } from '../events/constraints/UniqueConstraintBuilder.js';
|
|
16
17
|
import { getUniqueEventMetadata, getUniquePropertyMetadata } from '../events/constraints/unique.js';
|
|
17
18
|
import { getRemovedConstraintNames } from '../events/constraints/removeConstraint.js';
|
|
18
19
|
import { getConstraintMetadata } from '../events/constraints/constraint.js';
|
|
@@ -24,6 +25,63 @@ import { InProcessEventSequence } from './InProcessEventSequence.js';
|
|
|
24
25
|
import { registerScenarioSeed } from './EventScenarioSeed.js';
|
|
25
26
|
import { UnsupportedEventSequenceOperation } from './UnsupportedEventSequenceOperation.js';
|
|
26
27
|
|
|
28
|
+
function hasPlainScalarSchemas(schemas: ReadonlyArray<{ type?: string; format?: string } | undefined>): boolean {
|
|
29
|
+
return schemas.every(schema => ['string', 'boolean'].includes(schema?.type ?? '') && schema?.format === undefined);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function hasCombinedKeySchemas(schemas: ReadonlyArray<{ type?: string; format?: string } | undefined>): boolean {
|
|
33
|
+
return schemas.every(schema => schema?.type === 'string' && (schema.format === undefined || schema.format === 'guid') ||
|
|
34
|
+
schema?.type === 'number' && schema.format === undefined);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function isGuidOrNumericKey(schema: { type?: string; format?: string } | undefined): boolean {
|
|
38
|
+
return schema?.format === 'guid' || schema?.type === 'number';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function validateExtendedDefinition(name: string, unique: UniqueConstraintCapture | undefined,
|
|
42
|
+
constructors: ReadonlyMap<string, Function>): void {
|
|
43
|
+
if (!unique) return;
|
|
44
|
+
const schemas = unique.eventDefinitions.flatMap(entry => entry.properties.map(property =>
|
|
45
|
+
getEventTypeMetadata(constructors.get(entry.eventTypeId)!)?.schema.properties?.[property]));
|
|
46
|
+
if (!schemas.some(isGuidOrNumericKey)) return;
|
|
47
|
+
if (schemas.some(schema => schema?.type === 'boolean')) {
|
|
48
|
+
throw new UnsupportedEventSequenceOperation('artifacts.constraints', name,
|
|
49
|
+
'Boolean keys mixed with Guid or numeric keys in one definition are not fixture-backed.');
|
|
50
|
+
}
|
|
51
|
+
const removers = [unique.removedWithEventTypeId, ...(unique.removedWithEventTypeIds ?? [])].filter(id => id !== undefined);
|
|
52
|
+
if (unique.eventDefinitions.some(entry => removers.includes(entry.eventTypeId))) {
|
|
53
|
+
throw new UnsupportedEventSequenceOperation('artifacts.constraints', name,
|
|
54
|
+
'Guid and numeric keys with covered-and-removal events are not fixture-backed.');
|
|
55
|
+
}
|
|
56
|
+
if (removers.some(id => Object.keys(getEventTypeMetadata(constructors.get(id)!)?.schema.properties ?? {}).length === 0)) {
|
|
57
|
+
throw new UnsupportedEventSequenceOperation('artifacts.constraints', name,
|
|
58
|
+
'Guid and numeric keys with fieldless removal events are not fixture-backed.');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function validateKeySchemas(name: string, schemas: ReadonlyArray<{ type?: string; format?: string } | undefined>,
|
|
63
|
+
options: { scoped: boolean; isolated: boolean; definitions: number; ignoreCasing: boolean }): void {
|
|
64
|
+
const fail = (reason: string) => { throw new UnsupportedEventSequenceOperation('artifacts.constraints', name, reason); };
|
|
65
|
+
const plainStrings = schemas.every(schema => schema?.type === 'string' && schema.format === undefined);
|
|
66
|
+
if (options.scoped && !hasPlainScalarSchemas(schemas) && !hasCombinedKeySchemas(schemas)) {
|
|
67
|
+
fail('Scoped property keys must be schema-backed strings, booleans, Guids or unformatted numbers.');
|
|
68
|
+
}
|
|
69
|
+
for (const schema of schemas) {
|
|
70
|
+
const supported = schema?.type === 'boolean' && schema.format === undefined ||
|
|
71
|
+
schema?.type === 'string' && (schema.format === undefined || schema.format === 'guid') ||
|
|
72
|
+
schema?.type === 'number' && (schema.format === undefined || schema.format === 'double');
|
|
73
|
+
if (!supported) fail(`Unique keys with schema ${schema?.type ?? 'missing'}/${schema?.format ?? 'unformatted'} are not fixture-backed; date, object and other numeric formats require a kernel-backed test.`);
|
|
74
|
+
}
|
|
75
|
+
if (schemas.some(isGuidOrNumericKey) &&
|
|
76
|
+
(options.definitions !== 1 || !options.isolated && !hasCombinedKeySchemas(schemas))) {
|
|
77
|
+
fail('Guid and numeric keys require one definition; combined keys require unformatted numbers or Guids.');
|
|
78
|
+
}
|
|
79
|
+
if (options.ignoreCasing && !plainStrings) fail('Case-insensitive keys must be schema-backed strings.');
|
|
80
|
+
if (schemas.length > 1 && !hasCombinedKeySchemas(schemas)) {
|
|
81
|
+
fail('Every property of a composite key must be a schema-backed string, Guid or unformatted number.');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
27
85
|
function hasConstraintDecorators(type: Function): boolean {
|
|
28
86
|
return getUniqueEventMetadata(type) !== undefined || getRemovedConstraintNames(type).length > 0 ||
|
|
29
87
|
TypeIntrospector.getTrackedProperties(type).some(property => getUniquePropertyMetadata(type, property) !== undefined);
|
|
@@ -111,37 +169,14 @@ export class EventScenario {
|
|
|
111
169
|
throw new UnsupportedEventSequenceOperation('artifacts.constraints', name,
|
|
112
170
|
'Scoped fieldless removal events are not fixture-backed.');
|
|
113
171
|
}
|
|
172
|
+
validateExtendedDefinition(name, capture.uniqueConstraint, constructorsById);
|
|
114
173
|
for (const entry of capture.uniqueConstraint?.eventDefinitions ?? []) {
|
|
115
174
|
const type = eventTypes.find(type => getEventTypeFor(type).id.value === entry.eventTypeId)!;
|
|
116
175
|
const schemas = entry.properties.map(property => getEventTypeMetadata(type)?.schema.properties?.[property]);
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
for (const schema of schemas) {
|
|
123
|
-
const supported = schema?.type === 'boolean' && schema.format === undefined ||
|
|
124
|
-
schema?.type === 'string' && (schema.format === undefined || schema.format === 'guid') ||
|
|
125
|
-
schema?.type === 'number' && (schema.format === undefined || schema.format === 'double');
|
|
126
|
-
if (!supported) throw new UnsupportedEventSequenceOperation('artifacts.constraints', name,
|
|
127
|
-
`Unique keys with schema ${schema?.type ?? 'missing'}/${schema?.format ?? 'unformatted'} are not fixture-backed; date, object and other numeric formats require a kernel-backed test.`);
|
|
128
|
-
}
|
|
129
|
-
const extendedKey = schemas.some(schema => schema?.type === 'number' || schema?.format === 'guid');
|
|
130
|
-
if (extendedKey && (applicable.size !== 1 || capture.uniqueConstraint!.eventDefinitions.length !== 1 ||
|
|
131
|
-
removedWith.some(id => id !== undefined))) {
|
|
132
|
-
throw new UnsupportedEventSequenceOperation('artifacts.constraints', name,
|
|
133
|
-
'Guid and numeric keys require one isolated definition covering one event type without removers; shared definitions and removal combinations are not fixture-backed.');
|
|
134
|
-
}
|
|
135
|
-
// constraints-ignore-casing.json captures folded string keys only.
|
|
136
|
-
if (capture.uniqueConstraint!.ignoreCasing && !plainStrings) {
|
|
137
|
-
throw new UnsupportedEventSequenceOperation('artifacts.constraints', name,
|
|
138
|
-
'Case-insensitive keys must be schema-backed strings.');
|
|
139
|
-
}
|
|
140
|
-
// constraints-composite.json captures string components only.
|
|
141
|
-
if (entry.properties.length > 1 && !plainStrings) {
|
|
142
|
-
throw new UnsupportedEventSequenceOperation('artifacts.constraints', name,
|
|
143
|
-
'Every property of a composite key must be a schema-backed string.');
|
|
144
|
-
}
|
|
176
|
+
validateKeySchemas(name, schemas, { scoped, definitions: applicable.size,
|
|
177
|
+
isolated: !scoped && capture.uniqueConstraint!.eventDefinitions.length === 1 &&
|
|
178
|
+
!removedWith.some(id => id !== undefined),
|
|
179
|
+
ignoreCasing: capture.uniqueConstraint!.ignoreCasing });
|
|
145
180
|
}
|
|
146
181
|
}
|
|
147
182
|
} catch (error) {
|
package/testing/for_EventScenario/when_appending_field_combinations/combination_behaviors.fixture.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
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 { readFileSync } from 'node:fs';
|
|
5
|
+
import { chai, describe, it, vi, type Assertion } from 'vitest';
|
|
6
|
+
import { constraint } from '../../../events/constraints/constraint.js';
|
|
7
|
+
import type { IConstraint } from '../../../events/constraints/IConstraint.js';
|
|
8
|
+
import type { IConstraintBuilder } from '../../../events/constraints/IConstraintBuilder.js';
|
|
9
|
+
import { getEventTypeMetadata } from '../../../events/eventTypeDecorator.js';
|
|
10
|
+
import { EventScenario } from '../../EventScenario.js';
|
|
11
|
+
import { InProcessConstraints } from '../../InProcessConstraints.js';
|
|
12
|
+
import { UnsupportedEventSequenceOperation } from '../../UnsupportedEventSequenceOperation.js';
|
|
13
|
+
|
|
14
|
+
chai.should();
|
|
15
|
+
const should = (value: unknown): Assertion => (value as { should: Assertion }).should;
|
|
16
|
+
type Constructor = new () => object;
|
|
17
|
+
type Alias = 'number' | 'guid' | 'string' | 'removed';
|
|
18
|
+
type Entry = { source: string; type: Alias; value?: string; values?: Record<string, unknown> };
|
|
19
|
+
type Operation = { mode: string; overload?: string; options?: { sourceType: string; streamType: string; streamId: string }; events: Entry[] };
|
|
20
|
+
type Definition = { events: { type: Alias; properties: string[] }[]; name: string; message: string };
|
|
21
|
+
interface Fixture {
|
|
22
|
+
fieldCombinationCases: { name: string; eventSchemas: Record<Alias, { eventTypeId: string; properties: Record<string, string> }>;
|
|
23
|
+
constraintDefinitions: Definition[]; isolatedConstraintOperations: Operation[] }[];
|
|
24
|
+
expected: { cases: { name: string; outcomes: { success: boolean; sequences: string[]; wireViolations: unknown[]; next: string }[] }[] };
|
|
25
|
+
}
|
|
26
|
+
const fixture = JSON.parse(readFileSync(new URL('../../fixtures/constraints-field-combinations.json', import.meta.url), 'utf8')) as Fixture;
|
|
27
|
+
|
|
28
|
+
function definition(types: Record<Alias, Constructor>, declaration: Definition, mask: number, ignoreCasing = false): Constructor {
|
|
29
|
+
class Key implements IConstraint {
|
|
30
|
+
define(builder: IConstraintBuilder) {
|
|
31
|
+
if (mask & 1) builder.perEventSourceType();
|
|
32
|
+
if (mask & 2) builder.perEventStreamType();
|
|
33
|
+
if (mask & 4) builder.perEventStreamId();
|
|
34
|
+
builder.unique(key => {
|
|
35
|
+
key.withMessage(declaration.message);
|
|
36
|
+
for (const event of declaration.events) {
|
|
37
|
+
key.on(types[event.type], ...event.properties.map(property => (value: object) => (value as Record<string, unknown>)[property]));
|
|
38
|
+
}
|
|
39
|
+
key.removedWith(types.removed);
|
|
40
|
+
if (ignoreCasing) key.ignoreCasing();
|
|
41
|
+
return key;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
constraint(declaration.name)(Key);
|
|
46
|
+
return Key;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function eventFor(entry: Entry, types: Record<Alias, Constructor>): object {
|
|
50
|
+
return Object.assign(new types[entry.type](), entry.values ?? { [entry.type === 'removed' ? 'label' : 'key']: entry.value });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function append(scenario: EventScenario, operation: Operation, types: Record<Alias, Constructor>) {
|
|
54
|
+
const events = operation.events.map(entry => ({ eventSourceId: entry.source, event: eventFor(entry, types) }));
|
|
55
|
+
if (operation.mode === 'single') return [await scenario.append(events[0].eventSourceId, events[0].event, operation.options)];
|
|
56
|
+
if (operation.overload === 'source') return scenario.appendMany(events[0].eventSourceId, events.map(entry => entry.event), operation.options);
|
|
57
|
+
return scenario.appendMany(events, operation.options);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function combinationBehaviors(types: Record<Alias, Constructor>): void {
|
|
61
|
+
it('should replay a nonempty, uniquely named oracle matrix', () => {
|
|
62
|
+
should(fixture.fieldCombinationCases.length).equal(3);
|
|
63
|
+
should(fixture.expected.cases.length).equal(24);
|
|
64
|
+
should(new Set(fixture.expected.cases.map(test => test.name)).size).equal(24);
|
|
65
|
+
});
|
|
66
|
+
for (const template of fixture.fieldCombinationCases) {
|
|
67
|
+
for (let mask = 0; mask < 8; mask++) {
|
|
68
|
+
describe(`when replaying ${template.name} Guid/numeric keys under scope mask ${mask}`, () => {
|
|
69
|
+
const constraints = [definition(types, template.constraintDefinitions[0], mask)];
|
|
70
|
+
const artifacts = { eventTypes: Object.values(types), constraints };
|
|
71
|
+
it('should match raw violations, sequences, history and failed-batch atomicity', async () => {
|
|
72
|
+
const expected = fixture.expected.cases.find(test => test.name === `${template.name}-${mask}`)!;
|
|
73
|
+
should(expected.outcomes.length).equal(template.isolatedConstraintOperations.length);
|
|
74
|
+
for (const alias of Object.keys(types) as Alias[]) {
|
|
75
|
+
const schema = getEventTypeMetadata(types[alias])!;
|
|
76
|
+
should(schema.eventType.id.value).equal(template.eventSchemas[alias].eventTypeId);
|
|
77
|
+
should(Object.keys(schema.schema.properties!).sort()).deep.equal(Object.keys(template.eventSchemas[alias].properties).sort());
|
|
78
|
+
}
|
|
79
|
+
const scenario = new EventScenario({ artifacts });
|
|
80
|
+
const validate = vi.spyOn(InProcessConstraints.prototype, 'validate');
|
|
81
|
+
try {
|
|
82
|
+
for (const [index, operation] of template.isolatedConstraintOperations.entries()) {
|
|
83
|
+
const before = [...scenario.appendedEvents];
|
|
84
|
+
const results = await append(scenario, operation, types);
|
|
85
|
+
const outcome = expected.outcomes[index];
|
|
86
|
+
should(results.every(result => result.isSuccess === outcome.success)).equal(true);
|
|
87
|
+
should(results.map(result => result.sequenceNumber.value.toString())).deep.equal(
|
|
88
|
+
outcome.success ? outcome.sequences : results.map(() => '0'));
|
|
89
|
+
const raw = validate.mock.results.at(-1)!.value as ReturnType<InProcessConstraints['validate']>;
|
|
90
|
+
should(raw.map(({ SequenceNumber, ...violation }) => ({ ...violation, SequenceNumber: SequenceNumber.toString() })))
|
|
91
|
+
.deep.equal(outcome.wireViolations);
|
|
92
|
+
if (!outcome.success) should(scenario.appendedEvents).deep.equal(before);
|
|
93
|
+
else should(scenario.appendedEvents.slice(before.length).map(entry => entry.context.eventSourceId))
|
|
94
|
+
.deep.equal(operation.events.map(entry => entry.source));
|
|
95
|
+
should((await scenario.eventSequence.getNextSequenceNumber()).value.toString()).equal(outcome.next);
|
|
96
|
+
}
|
|
97
|
+
} finally { validate.mockRestore(); }
|
|
98
|
+
});
|
|
99
|
+
it('should keep numeric, Guid and definition rejections atomic', async () => {
|
|
100
|
+
const scenario = new EventScenario({ artifacts });
|
|
101
|
+
for (const entry of [
|
|
102
|
+
{ source: 'A', type: 'number', values: { key: 1.5 } },
|
|
103
|
+
{ source: 'A', type: 'number', values: { key: Number.MAX_SAFE_INTEGER + 1 } },
|
|
104
|
+
{ source: 'A', type: 'guid', values: { key: 'not-a-guid' } }
|
|
105
|
+
] as Entry[]) {
|
|
106
|
+
const error = await append(scenario, { mode: 'batch', events: [template.isolatedConstraintOperations[0].events[0], entry] }, types)
|
|
107
|
+
.then(() => undefined, error => error);
|
|
108
|
+
should(error).instanceOf(UnsupportedEventSequenceOperation);
|
|
109
|
+
should(scenario.appendedEvents).deep.equal([]);
|
|
110
|
+
should(scenario.results).deep.equal([]);
|
|
111
|
+
}
|
|
112
|
+
const other = definition(types, { ...template.constraintDefinitions[0], name: 'OracleOtherKey' }, mask);
|
|
113
|
+
should(() => new EventScenario({ artifacts: { ...artifacts, constraints: [...constraints, other] } }))
|
|
114
|
+
.throw(UnsupportedEventSequenceOperation);
|
|
115
|
+
const cased = definition(types, template.constraintDefinitions[0], mask, true);
|
|
116
|
+
should(() => new EventScenario({ artifacts: { ...artifacts, constraints: [cased] } }))
|
|
117
|
+
.throw(UnsupportedEventSequenceOperation, 'Case-insensitive keys');
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
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 type { Constructor } from '@cratis/fundamentals';
|
|
5
|
+
import { chai, describe, it } from 'vitest';
|
|
6
|
+
import { constraint } from '../../../events/constraints/constraint.js';
|
|
7
|
+
import type { IConstraintBuilder } from '../../../events/constraints/IConstraintBuilder.js';
|
|
8
|
+
import { EventScenario } from '../../EventScenario.js';
|
|
9
|
+
import { UnsupportedEventSequenceOperation } from '../../UnsupportedEventSequenceOperation.js';
|
|
10
|
+
|
|
11
|
+
chai.should();
|
|
12
|
+
|
|
13
|
+
function definition(configure: (builder: IConstraintBuilder) => void, name = 'UnprovenCombinedKey'): Constructor {
|
|
14
|
+
class Definition { define(builder: IConstraintBuilder) { configure(builder); } }
|
|
15
|
+
constraint(name)(Definition);
|
|
16
|
+
return Definition;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function rejectWithoutMutation(eventTypes: Constructor[], Claim: new () => { key: unknown }, invalid: Constructor, reason: string): Promise<void> {
|
|
20
|
+
const supported = definition(builder => builder.unique(key => key.on(Claim, event => event.key)), 'SupportedCombinedKey');
|
|
21
|
+
const scenario = new EventScenario({ artifacts: { eventTypes: [Claim], constraints: [supported] } });
|
|
22
|
+
(await scenario.append('A', new Claim())).isSuccess.should.be.true;
|
|
23
|
+
const history = [...scenario.appendedEvents];
|
|
24
|
+
const results = [...scenario.results];
|
|
25
|
+
(() => new EventScenario({ artifacts: { eventTypes, constraints: [invalid] } }))
|
|
26
|
+
.should.throw(UnsupportedEventSequenceOperation, reason);
|
|
27
|
+
scenario.appendedEvents.should.deep.equal(history);
|
|
28
|
+
scenario.results.should.deep.equal(results);
|
|
29
|
+
(await scenario.eventSequence.getNextSequenceNumber()).value.should.equal(1n);
|
|
30
|
+
(await scenario.append('B', new Claim())).isSuccess.should.be.false;
|
|
31
|
+
(await scenario.eventSequence.getNextSequenceNumber()).value.should.equal(1n);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function definitionRejectionBehaviors(types: {
|
|
35
|
+
guid: new () => { key: unknown };
|
|
36
|
+
number: new () => { key: unknown };
|
|
37
|
+
text: new () => { key: string };
|
|
38
|
+
flag: new () => { key: boolean };
|
|
39
|
+
fieldless: new () => object;
|
|
40
|
+
removed: new () => { label: string };
|
|
41
|
+
}): void {
|
|
42
|
+
for (const [kind, Claim] of [['Guid', types.guid], ['numeric', types.number]] as const) {
|
|
43
|
+
describe(`when configuring unmeasured ${kind} definition combinations`, () => {
|
|
44
|
+
it('should reject an unscoped fieldless remover without mutating claims or advancing a sequence', async () => {
|
|
45
|
+
const invalid = definition(builder => builder.unique(key => key.on(Claim, event => event.key).removedWith(types.fieldless)));
|
|
46
|
+
await rejectWithoutMutation([Claim, types.fieldless], Claim, invalid, 'fieldless removal events');
|
|
47
|
+
});
|
|
48
|
+
it('should reject an unscoped covered-and-removal event without mutating claims or advancing a sequence', async () => {
|
|
49
|
+
const invalid = definition(builder => builder.unique(key => key.on(Claim, event => event.key).removedWith(Claim)));
|
|
50
|
+
await rejectWithoutMutation([Claim], Claim, invalid, 'covered-and-removal events');
|
|
51
|
+
});
|
|
52
|
+
it('should reject a string covered-and-removal event shared with an extended key', async () => {
|
|
53
|
+
const invalid = definition(builder => builder.unique(key => key.on(Claim, event => event.key)
|
|
54
|
+
.on(types.removed, event => event.label).removedWith(types.removed)));
|
|
55
|
+
await rejectWithoutMutation([Claim, types.removed], Claim, invalid, 'covered-and-removal events');
|
|
56
|
+
});
|
|
57
|
+
for (let mask = 0; mask < 8; mask++) {
|
|
58
|
+
for (const flagFirst of [false, true]) {
|
|
59
|
+
it(`should reject a shared Boolean/${kind} definition under scope ${mask}, Boolean first: ${flagFirst}`, async () => {
|
|
60
|
+
const invalid = definition(builder => {
|
|
61
|
+
if (mask & 1) builder.perEventSourceType();
|
|
62
|
+
if (mask & 2) builder.perEventStreamType();
|
|
63
|
+
if (mask & 4) builder.perEventStreamId();
|
|
64
|
+
builder.unique(key => {
|
|
65
|
+
if (flagFirst) key.on(types.flag, event => event.key);
|
|
66
|
+
key.on(Claim, event => event.key);
|
|
67
|
+
if (!flagFirst) key.on(types.flag, event => event.key);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
await rejectWithoutMutation([Claim, types.flag], Claim, invalid, 'Boolean keys mixed with Guid or numeric keys');
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
describe('when configuring existing string-key lifecycle shapes', () => {
|
|
78
|
+
it('should retain unscoped fieldless-remover release and reclaim', async () => {
|
|
79
|
+
const constraints = [definition(builder => builder.unique(key => key.on(types.text, event => event.key).removedWith(types.fieldless)))];
|
|
80
|
+
const scenario = new EventScenario({ artifacts: { eventTypes: [types.text, types.fieldless], constraints } });
|
|
81
|
+
const claim = () => Object.assign(new types.text(), { key: 'Alpha' });
|
|
82
|
+
(await scenario.append('A', claim())).isSuccess.should.be.true;
|
|
83
|
+
(await scenario.append('B', claim())).isSuccess.should.be.false;
|
|
84
|
+
(await scenario.append('A', new types.fieldless())).isSuccess.should.be.true;
|
|
85
|
+
(await scenario.append('B', claim())).sequenceNumber.value.should.equal(2n);
|
|
86
|
+
(await scenario.eventSequence.getNextSequenceNumber()).value.should.equal(3n);
|
|
87
|
+
});
|
|
88
|
+
it('should retain unscoped string covered-and-removal events', async () => {
|
|
89
|
+
const constraints = [definition(builder => builder.unique(key => key.on(types.text, event => event.key)
|
|
90
|
+
.on(types.removed, event => event.label).removedWith(types.removed)))];
|
|
91
|
+
const scenario = new EventScenario({ artifacts: { eventTypes: [types.text, types.removed], constraints } });
|
|
92
|
+
const claim = () => Object.assign(new types.text(), { key: 'Alpha' });
|
|
93
|
+
(await scenario.append('A', claim())).isSuccess.should.be.true;
|
|
94
|
+
(await scenario.append('A', Object.assign(new types.removed(), { label: 'Alpha' }))).isSuccess.should.be.true;
|
|
95
|
+
(await scenario.append('B', claim())).sequenceNumber.value.should.equal(2n);
|
|
96
|
+
(await scenario.eventSequence.getNextSequenceNumber()).value.should.equal(3n);
|
|
97
|
+
});
|
|
98
|
+
for (const scoped of [false, true]) {
|
|
99
|
+
it(`should retain a shared Boolean/string definition, scoped: ${scoped}`, async () => {
|
|
100
|
+
const constraints = [definition(builder => {
|
|
101
|
+
if (scoped) builder.perEventStreamId();
|
|
102
|
+
builder.unique(key => key.on(types.flag, event => event.key).on(types.text, event => event.key));
|
|
103
|
+
})];
|
|
104
|
+
const scenario = new EventScenario({ artifacts: { eventTypes: [types.flag, types.text], constraints } });
|
|
105
|
+
(await scenario.append('A', new types.flag())).isSuccess.should.be.true;
|
|
106
|
+
(await scenario.append('B', Object.assign(new types.text(), { key: 'True' }))).isSuccess.should.be.false;
|
|
107
|
+
(await scenario.append('B', Object.assign(new types.text(), { key: 'true' }))).sequenceNumber.value.should.equal(1n);
|
|
108
|
+
(await scenario.eventSequence.getNextSequenceNumber()).value.should.equal(2n);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
import { field, Guid } from '@cratis/fundamentals';
|
|
6
|
+
import { describe } from 'vitest';
|
|
7
|
+
import { eventType } from '../../../events/eventTypeDecorator.js';
|
|
8
|
+
import { combinationBehaviors } from './combination_behaviors.fixture.js';
|
|
9
|
+
import { definitionRejectionBehaviors } from './definition_rejection_behaviors.fixture.js';
|
|
10
|
+
|
|
11
|
+
@eventType('OracleCombinedNumber')
|
|
12
|
+
class NumberKey {
|
|
13
|
+
@field(Number) key = -7;
|
|
14
|
+
@field(String) suffix = 'Alpha';
|
|
15
|
+
@field(Guid) identifier = Guid.parse('abcdef01-abcd-abcd-abcd-abcdef012345');
|
|
16
|
+
}
|
|
17
|
+
@eventType('OracleCombinedGuid')
|
|
18
|
+
class GuidKey {
|
|
19
|
+
@field(Guid) key = Guid.parse('abcdef01-abcd-abcd-abcd-abcdef012345');
|
|
20
|
+
@field(String) suffix = 'Alpha';
|
|
21
|
+
@field(Number) amount = -7;
|
|
22
|
+
}
|
|
23
|
+
@eventType('OracleCombinedText')
|
|
24
|
+
class TextKey { @field(String) key = ''; }
|
|
25
|
+
@eventType('OracleCombinedRemoved')
|
|
26
|
+
class Removed { @field(String) label = ''; }
|
|
27
|
+
@eventType('OracleCombinedBoolean')
|
|
28
|
+
class Flag { @field(Boolean) key = true; }
|
|
29
|
+
@eventType('OracleCombinedFieldless')
|
|
30
|
+
class Fieldless { }
|
|
31
|
+
|
|
32
|
+
describe('when appending combined Guid/numeric keys with legacy decorators', () => {
|
|
33
|
+
combinationBehaviors({ number: NumberKey, guid: GuidKey, string: TextKey, removed: Removed });
|
|
34
|
+
definitionRejectionBehaviors({ number: NumberKey, guid: GuidKey, text: TextKey, removed: Removed, flag: Flag, fieldless: Fieldless });
|
|
35
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
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 { field, Guid } from '@cratis/fundamentals';
|
|
5
|
+
import { describe } from 'vitest';
|
|
6
|
+
import { eventType } from '../../../events/eventTypeDecorator.js';
|
|
7
|
+
import { combinationBehaviors } from './combination_behaviors.fixture.js';
|
|
8
|
+
import { definitionRejectionBehaviors } from './definition_rejection_behaviors.fixture.js';
|
|
9
|
+
|
|
10
|
+
@eventType('OracleCombinedNumber')
|
|
11
|
+
class NumberKey {
|
|
12
|
+
@field(Number) key = -7;
|
|
13
|
+
@field(String) suffix = 'Alpha';
|
|
14
|
+
@field(Guid) identifier = Guid.parse('abcdef01-abcd-abcd-abcd-abcdef012345');
|
|
15
|
+
}
|
|
16
|
+
@eventType('OracleCombinedGuid')
|
|
17
|
+
class GuidKey {
|
|
18
|
+
@field(Guid) key = Guid.parse('abcdef01-abcd-abcd-abcd-abcdef012345');
|
|
19
|
+
@field(String) suffix = 'Alpha';
|
|
20
|
+
@field(Number) amount = -7;
|
|
21
|
+
}
|
|
22
|
+
@eventType('OracleCombinedText')
|
|
23
|
+
class TextKey { @field(String) key = ''; }
|
|
24
|
+
@eventType('OracleCombinedRemoved')
|
|
25
|
+
class Removed { @field(String) label = ''; }
|
|
26
|
+
@eventType('OracleCombinedBoolean')
|
|
27
|
+
class Flag { @field(Boolean) key = true; }
|
|
28
|
+
@eventType('OracleCombinedFieldless')
|
|
29
|
+
class Fieldless { }
|
|
30
|
+
|
|
31
|
+
describe('when appending combined Guid/numeric keys with standard decorators', () => {
|
|
32
|
+
combinationBehaviors({ number: NumberKey, guid: GuidKey, string: TextKey, removed: Removed });
|
|
33
|
+
definitionRejectionBehaviors({ number: NumberKey, guid: GuidKey, text: TextKey, removed: Removed, flag: Flag, fieldless: Fieldless });
|
|
34
|
+
});
|
package/testing/for_EventScenario/when_appending_field_types/with_unproven_schemas.legacy.spec.ts
CHANGED
|
@@ -33,17 +33,15 @@ for (const schema of [
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
for (const mode of ['
|
|
36
|
+
for (const mode of ['ignoreCasing']) {
|
|
37
37
|
describe(`when registering a ${mode} Guid key without fixture evidence`, () => {
|
|
38
38
|
it('should reject instead of inheriting plain-string constraint support', () => {
|
|
39
39
|
class Recorded { @field(Guid) key = Guid.empty; @field(String) label = ''; }
|
|
40
40
|
eventType(`UnprovenGuid${mode}`)(Recorded);
|
|
41
41
|
class Definition {
|
|
42
42
|
define(builder: IConstraintBuilder) {
|
|
43
|
-
if (mode === 'scoped') builder.perEventSourceType();
|
|
44
43
|
builder.unique(key => {
|
|
45
|
-
|
|
46
|
-
else key.on(Recorded, event => event.key);
|
|
44
|
+
key.on(Recorded, event => event.key);
|
|
47
45
|
if (mode === 'ignoreCasing') key.ignoreCasing();
|
|
48
46
|
});
|
|
49
47
|
}
|
|
@@ -15,7 +15,7 @@ import { InProcessConstraints } from '../../InProcessConstraints.js';
|
|
|
15
15
|
chai.should();
|
|
16
16
|
function should(value: unknown): Assertion { return (value as { should: Assertion }).should; }
|
|
17
17
|
|
|
18
|
-
type Entry = { source: string; type: string; value?: string; values?: Record<string, string>; sourceType?: string; streamType?: string; streamId?: string };
|
|
18
|
+
type Entry = { source: string; type: string; value?: string | boolean; values?: Record<string, string>; sourceType?: string; streamType?: string; streamId?: string };
|
|
19
19
|
type ScopeEvents = Record<string, new (value: string) => object>;
|
|
20
20
|
type Definition = { kind: string; name: string; scope: ConstraintScopeCapture; events?: Array<{ type: string; properties: string[] }>;
|
|
21
21
|
eventTypes?: string[]; ignoreCasing?: boolean; removedWithEventTypeIds: string[]; message: string };
|
|
@@ -49,7 +49,8 @@ function assertArtifacts(types: ScopeEvents, constraints: Constructor[], test: S
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
function eventOf(types: ScopeEvents, entry: Entry): object {
|
|
52
|
-
|
|
52
|
+
const event = new types[entry.type](typeof entry.value === 'string' ? entry.value : '');
|
|
53
|
+
return Object.assign(event, typeof entry.value === 'boolean' ? { key: entry.value } : entry.values);
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
export function scopeScenarioBehaviors(
|
|
@@ -64,6 +65,7 @@ export function scopeScenarioBehaviors(
|
|
|
64
65
|
}));
|
|
65
66
|
it('should retain all seven scope combinations for property shapes, both constraint kinds and the alias guards', () => {
|
|
66
67
|
should(fixture.scopeCases.map(test => test.name)).deep.equal([
|
|
68
|
+
...Array.from({ length: 7 }, (_, index) => `boolean-${index + 1}`),
|
|
67
69
|
...Array.from({ length: 7 }, (_, index) => `composite-${index + 1}`),
|
|
68
70
|
...Array.from({ length: 7 }, (_, index) => `folded-${index + 1}`),
|
|
69
71
|
...Array.from({ length: 7 }, (_, index) => ['property', 'cycle', 'once'].map(kind => `${kind}-${index + 1}`)).flat(),
|
|
@@ -14,11 +14,13 @@ import { scopeScenarioBehaviors } from './scope_scenario_behaviors.fixture.js';
|
|
|
14
14
|
@eventType('OracleDomainText')
|
|
15
15
|
class Text { @field(String) key: string; constructor(key: string) { this.key = key; } }
|
|
16
16
|
@eventType('OracleCompositeName')
|
|
17
|
-
class Name { @field(String) first
|
|
17
|
+
class Name { @field(String) first = ''; @field(String) last = ''; }
|
|
18
18
|
@eventType('OracleCompositeAlias')
|
|
19
|
-
class Alias { @field(String) given
|
|
19
|
+
class Alias { @field(String) given = ''; @field(String) family = ''; }
|
|
20
20
|
@eventType('OracleCompositeTriple')
|
|
21
|
-
class Triple { @field(String) first
|
|
21
|
+
class Triple { @field(String) first = ''; @field(String) middle = ''; @field(String) last = ''; }
|
|
22
|
+
@eventType('OracleDomainFlag')
|
|
23
|
+
class Flag { @field(Boolean) key = false; }
|
|
22
24
|
@eventType('OracleDomainShared')
|
|
23
25
|
class Shared { @field(String) key: string; constructor(key: string) { this.key = key; } }
|
|
24
26
|
@eventType('OracleDomainRemoved')
|
|
@@ -50,6 +52,13 @@ function constraints(scope: ConstraintScopeCapture, kind: string): Constructor[]
|
|
|
50
52
|
.removedWith(Removed).removedWith(Expired).withMessage('Taken: {PropertyValue}'));
|
|
51
53
|
}
|
|
52
54
|
}
|
|
55
|
+
@constraint('OracleScopedFlag')
|
|
56
|
+
class BooleanKey {
|
|
57
|
+
define(builder: IConstraintBuilder) {
|
|
58
|
+
apply(builder).unique(key => key.on(Text, event => event.key).on(Flag, event => event.key)
|
|
59
|
+
.removedWith(Removed).withMessage('Taken: {PropertyName}={PropertyValue}'));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
53
62
|
@constraint('OracleScopedName')
|
|
54
63
|
class Composite {
|
|
55
64
|
define(builder: IConstraintBuilder) {
|
|
@@ -72,12 +81,13 @@ function constraints(scope: ConstraintScopeCapture, kind: string): Constructor[]
|
|
|
72
81
|
class FirstCycle { define(builder: IConstraintBuilder) { apply(builder).uniqueFor(First, 'Cycle occupied', 'OracleScopedCycle'); } }
|
|
73
82
|
@constraint('OracleScopedSibling')
|
|
74
83
|
class SiblingCycle { define(builder: IConstraintBuilder) { apply(builder).uniqueFor(Sibling, 'Cycle occupied', 'OracleScopedCycle'); } }
|
|
84
|
+
if (kind === 'boolean') return [BooleanKey];
|
|
75
85
|
if (kind === 'composite') return [Composite];
|
|
76
86
|
if (kind === 'folded') return [Folded];
|
|
77
87
|
return kind === 'property' ? [Key] : kind === 'once' ? [FirstCycle] : [FirstCycle, SiblingCycle];
|
|
78
88
|
}
|
|
79
89
|
|
|
80
90
|
describe('when appending scoped constraints with legacy decorators', () => {
|
|
81
|
-
scopeScenarioBehaviors({ string: Text, name: Name, alias: Alias, triple: Triple, shared: Shared, removed: Removed, expired: Expired,
|
|
91
|
+
scopeScenarioBehaviors({ string: Text, boolean: Flag, name: Name, alias: Alias, triple: Triple, shared: Shared, removed: Removed, expired: Expired,
|
|
82
92
|
first: First, sibling: Sibling, cycleRemoved: CycleRemoved, cycleExpired: CycleExpired }, constraints);
|
|
83
93
|
});
|
|
@@ -13,11 +13,13 @@ import { scopeScenarioBehaviors } from './scope_scenario_behaviors.fixture.js';
|
|
|
13
13
|
@eventType('OracleDomainText')
|
|
14
14
|
class Text { @field(String) key: string; constructor(key: string) { this.key = key; } }
|
|
15
15
|
@eventType('OracleCompositeName')
|
|
16
|
-
class Name { @field(String) first
|
|
16
|
+
class Name { @field(String) first = ''; @field(String) last = ''; }
|
|
17
17
|
@eventType('OracleCompositeAlias')
|
|
18
|
-
class Alias { @field(String) given
|
|
18
|
+
class Alias { @field(String) given = ''; @field(String) family = ''; }
|
|
19
19
|
@eventType('OracleCompositeTriple')
|
|
20
|
-
class Triple { @field(String) first
|
|
20
|
+
class Triple { @field(String) first = ''; @field(String) middle = ''; @field(String) last = ''; }
|
|
21
|
+
@eventType('OracleDomainFlag')
|
|
22
|
+
class Flag { @field(Boolean) key = false; }
|
|
21
23
|
@eventType('OracleDomainShared')
|
|
22
24
|
class Shared { @field(String) key: string; constructor(key: string) { this.key = key; } }
|
|
23
25
|
@eventType('OracleDomainRemoved')
|
|
@@ -49,6 +51,13 @@ function constraints(scope: ConstraintScopeCapture, kind: string): Constructor[]
|
|
|
49
51
|
.removedWith(Removed).removedWith(Expired).withMessage('Taken: {PropertyValue}'));
|
|
50
52
|
}
|
|
51
53
|
}
|
|
54
|
+
@constraint('OracleScopedFlag')
|
|
55
|
+
class BooleanKey {
|
|
56
|
+
define(builder: IConstraintBuilder) {
|
|
57
|
+
apply(builder).unique(key => key.on(Text, event => event.key).on(Flag, event => event.key)
|
|
58
|
+
.removedWith(Removed).withMessage('Taken: {PropertyName}={PropertyValue}'));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
52
61
|
@constraint('OracleScopedName')
|
|
53
62
|
class Composite {
|
|
54
63
|
define(builder: IConstraintBuilder) {
|
|
@@ -71,12 +80,13 @@ function constraints(scope: ConstraintScopeCapture, kind: string): Constructor[]
|
|
|
71
80
|
class FirstCycle { define(builder: IConstraintBuilder) { apply(builder).uniqueFor(First, 'Cycle occupied', 'OracleScopedCycle'); } }
|
|
72
81
|
@constraint('OracleScopedSibling')
|
|
73
82
|
class SiblingCycle { define(builder: IConstraintBuilder) { apply(builder).uniqueFor(Sibling, 'Cycle occupied', 'OracleScopedCycle'); } }
|
|
83
|
+
if (kind === 'boolean') return [BooleanKey];
|
|
74
84
|
if (kind === 'composite') return [Composite];
|
|
75
85
|
if (kind === 'folded') return [Folded];
|
|
76
86
|
return kind === 'property' ? [Key] : kind === 'once' ? [FirstCycle] : [FirstCycle, SiblingCycle];
|
|
77
87
|
}
|
|
78
88
|
|
|
79
89
|
describe('when appending scoped constraints with standard decorators', () => {
|
|
80
|
-
scopeScenarioBehaviors({ string: Text, name: Name, alias: Alias, triple: Triple, shared: Shared, removed: Removed, expired: Expired,
|
|
90
|
+
scopeScenarioBehaviors({ string: Text, boolean: Flag, name: Name, alias: Alias, triple: Triple, shared: Shared, removed: Removed, expired: Expired,
|
|
81
91
|
first: First, sibling: Sibling, cycleRemoved: CycleRemoved, cycleExpired: CycleExpired }, constraints);
|
|
82
92
|
});
|
package/testing/for_EventScenario/when_appending_scoped_constraints/with_unproven_operations.spec.ts
CHANGED
|
@@ -15,7 +15,7 @@ chai.should();
|
|
|
15
15
|
@eventType('ScopedGuardClaim')
|
|
16
16
|
class Claim { @field(String) key: string; @field(String) other = 'Other'; constructor(key: string) { this.key = key; } }
|
|
17
17
|
@eventType('ScopedGuardFlag')
|
|
18
|
-
class Flag { @field(Boolean) key = true; }
|
|
18
|
+
class Flag { @field(Boolean) key = true; @field(Boolean) other = false; }
|
|
19
19
|
@eventType('ScopedGuardRemoval')
|
|
20
20
|
class Removed { @field(String) label = 'release'; }
|
|
21
21
|
@eventType('ScopedGuardFieldless')
|
|
@@ -38,7 +38,6 @@ async function unsupported(action: () => unknown, reason: string): Promise<void>
|
|
|
38
38
|
|
|
39
39
|
describe('when configuring unproven scoped property shapes', () => {
|
|
40
40
|
for (const [name, configure, reason] of [
|
|
41
|
-
['boolean', (builder: IConstraintBuilder) => builder.unique(value => value.on(Flag, event => event.key)), 'Scoped property keys must be schema-backed strings'],
|
|
42
41
|
['covered removal', (builder: IConstraintBuilder) => builder.unique(value => value.on(Claim, event => event.key).removedWith(Claim)), 'Scoped covered-and-removal property events'],
|
|
43
42
|
['fieldless removal', (builder: IConstraintBuilder) => builder.unique(value => value.on(Claim, event => event.key).removedWith(Fieldless)), 'Scoped fieldless removal events']
|
|
44
43
|
] as const) {
|
|
@@ -50,6 +49,18 @@ describe('when configuring unproven scoped property shapes', () => {
|
|
|
50
49
|
});
|
|
51
50
|
}
|
|
52
51
|
|
|
52
|
+
for (const [name, configure, reason] of [
|
|
53
|
+
['boolean casing', (builder: IConstraintBuilder) => builder.unique(value => value.on(Flag, event => event.key).ignoreCasing()),
|
|
54
|
+
'Case-insensitive keys must be schema-backed strings'],
|
|
55
|
+
['boolean composite', (builder: IConstraintBuilder) => builder.unique(value => value.on(Flag, event => event.key, event => event.other)),
|
|
56
|
+
'Every property of a composite key must be a schema-backed string']
|
|
57
|
+
] as const) {
|
|
58
|
+
it(`should retain rejection of scoped ${name}`, async () => {
|
|
59
|
+
await unsupported(() => new EventScenario({ artifacts: { eventTypes: [Flag],
|
|
60
|
+
constraints: [definition(builder => { builder.perEventSourceType(); configure(builder); })] } }), reason);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
53
64
|
it('should reject a scoped definition alongside another nonoverlapping definition', async () => {
|
|
54
65
|
const other = definition(builder => builder.unique(value => value.on(Flag, event => event.key)), 'OtherGuard');
|
|
55
66
|
await unsupported(() => new EventScenario({ artifacts: { eventTypes: [Claim, Flag, Removed], constraints: [scopedConstraint, other] } }),
|