@cratis/chronicle 6.70.1 → 6.71.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/dist/projections/IProjections.d.ts +27 -1
- package/dist/projections/IProjections.d.ts.map +1 -1
- package/dist/projections/ProjectionDefinitionCompiler.d.ts +11 -0
- package/dist/projections/ProjectionDefinitionCompiler.d.ts.map +1 -1
- package/dist/projections/ProjectionDefinitionCompiler.js +42 -18
- package/dist/projections/ProjectionDefinitionCompiler.js.map +1 -1
- package/dist/projections/Projections.d.ts +9 -0
- package/dist/projections/Projections.d.ts.map +1 -1
- package/dist/projections/Projections.js +62 -11
- package/dist/projections/Projections.js.map +1 -1
- package/dist/projections/RuntimeProjectionDefinitions.d.ts +26 -0
- package/dist/projections/RuntimeProjectionDefinitions.d.ts.map +1 -0
- package/dist/projections/RuntimeProjectionDefinitions.js +55 -0
- package/dist/projections/RuntimeProjectionDefinitions.js.map +1 -0
- package/dist/testing/for_ReadModelScenario/when_counting_with_children/given/compiled_projection.d.ts +42 -0
- package/dist/testing/for_ReadModelScenario/when_counting_with_children/given/compiled_projection.d.ts.map +1 -0
- package/dist/testing/for_ReadModelScenario/when_counting_with_children/given/compiled_projection.js +115 -0
- package/dist/testing/for_ReadModelScenario/when_counting_with_children/given/compiled_projection.js.map +1 -0
- package/dist/testing/for_ReadModelScenario/when_counting_with_children/given/lifecycle.d.ts +20 -0
- package/dist/testing/for_ReadModelScenario/when_counting_with_children/given/lifecycle.d.ts.map +1 -0
- package/dist/testing/for_ReadModelScenario/when_counting_with_children/given/lifecycle.js +20 -0
- package/dist/testing/for_ReadModelScenario/when_counting_with_children/given/lifecycle.js.map +1 -0
- package/dist/testing/projections/ProjectionCountChildrenCapabilities.d.ts +15 -0
- package/dist/testing/projections/ProjectionCountChildrenCapabilities.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionCountChildrenCapabilities.js +62 -0
- package/dist/testing/projections/ProjectionCountChildrenCapabilities.js.map +1 -0
- package/dist/testing/projections/ProjectionRootCapabilities.d.ts.map +1 -1
- package/dist/testing/projections/ProjectionRootCapabilities.js +6 -1
- package/dist/testing/projections/ProjectionRootCapabilities.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/projections/IProjections.ts +30 -1
- package/projections/ProjectionDefinitionCompiler.ts +46 -17
- package/projections/Projections.ts +72 -12
- package/projections/RuntimeProjectionDefinitions.ts +68 -0
- package/projections/for_Projections/given/default_runtime_registration.fixture.ts +53 -0
- package/projections/for_Projections/given/runtime_registration.fixture.ts +51 -0
- package/projections/for_Projections/when_mixing_runtime_registration_styles.spec.ts +73 -0
- package/projections/for_Projections/when_reconnecting_with_runtime_projections.spec.ts +36 -0
- package/projections/for_Projections/when_registering_at_runtime.spec.ts +72 -0
- package/projections/for_Projections/when_registering_with_the_default_provider.spec.ts +116 -0
- package/projections/for_Projections/when_runtime_registration_fails.spec.ts +106 -0
- package/testing/for_ReadModelScenario/when_counting_with_children/given/compiled_projection.ts +55 -0
- package/testing/for_ReadModelScenario/when_counting_with_children/given/lifecycle.ts +24 -0
- package/testing/for_ReadModelScenario/when_counting_with_children/with_a_fluent_projection.spec.ts +94 -0
- package/testing/for_ReadModelScenario/when_counting_with_children/with_legacy_decorators.legacy.spec.ts +39 -0
- package/testing/for_ReadModelScenario/when_counting_with_children/with_standard_decorators.standard.spec.ts +40 -0
- package/testing/projections/ProjectionCountChildrenCapabilities.ts +71 -0
- package/testing/projections/ProjectionRootCapabilities.ts +4 -1
- package/testing/projections/for_ProjectionCapabilities/when_validating_count_with_children.spec.ts +87 -0
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
/** Keeps acknowledged runtime definitions independent of artifact discovery. */
|
|
4
|
+
export class RuntimeProjectionDefinitions {
|
|
5
|
+
_registered = new Map();
|
|
6
|
+
_pending = new Map();
|
|
7
|
+
/** Gets the retained contracts to send again after reconnecting. */
|
|
8
|
+
get registrations() {
|
|
9
|
+
return Array.from(this._registered.values(), entry => entry.compiled);
|
|
10
|
+
}
|
|
11
|
+
/** Gets read models with retained or in-flight runtime registrations. */
|
|
12
|
+
get readModelTypes() {
|
|
13
|
+
return [...Array.from(this._registered.values(), entry => entry.readModelType), ...this._pending.values()];
|
|
14
|
+
}
|
|
15
|
+
/** Checks acknowledged definitions by identifier. */
|
|
16
|
+
has(identifier) {
|
|
17
|
+
return this._registered.has(identifier);
|
|
18
|
+
}
|
|
19
|
+
/** Checks acknowledged model-bound registrations by constructor and identifier. */
|
|
20
|
+
hasModelBoundFor(readModelType, identifier) {
|
|
21
|
+
const registration = this._registered.get(identifier);
|
|
22
|
+
return registration?.readModelType === readModelType && registration.kind === 'modelBound';
|
|
23
|
+
}
|
|
24
|
+
/** Refuses discovery or registration that would overwrite a runtime definition. */
|
|
25
|
+
assertAvailable(identifier) {
|
|
26
|
+
if (this._registered.has(identifier) || this._pending.has(identifier)) {
|
|
27
|
+
throw new Error(`Projection id '${identifier}' is already registered at runtime.`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** Finds the acknowledged projection maintaining a read model. */
|
|
31
|
+
findForModel(readModelType) {
|
|
32
|
+
return Array.from(this._registered).find(([, entry]) => entry.readModelType === readModelType)?.[0];
|
|
33
|
+
}
|
|
34
|
+
/** Gets the event sequence used by an acknowledged runtime projection. */
|
|
35
|
+
eventSequenceIdFor(identifier) {
|
|
36
|
+
return this._registered.get(identifier)?.compiled.definitions[0].EventSequenceId;
|
|
37
|
+
}
|
|
38
|
+
/** Reserves the identity until the kernel acknowledges it, retaining nothing on failure. */
|
|
39
|
+
async register(readModelType, compiled, kind, send) {
|
|
40
|
+
const identifier = compiled.definitions[0].Identifier;
|
|
41
|
+
this.assertAvailable(identifier);
|
|
42
|
+
if (this.readModelTypes.includes(readModelType)) {
|
|
43
|
+
throw new Error(`Read model '${readModelType.name}' already has a runtime projection.`);
|
|
44
|
+
}
|
|
45
|
+
this._pending.set(identifier, readModelType);
|
|
46
|
+
try {
|
|
47
|
+
await send(compiled);
|
|
48
|
+
this._registered.set(identifier, { readModelType, compiled, kind });
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
this._pending.delete(identifier);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=RuntimeProjectionDefinitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RuntimeProjectionDefinitions.js","sourceRoot":"","sources":["../../projections/RuntimeProjectionDefinitions.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAOrG,gFAAgF;AAChF,MAAM,OAAO,4BAA4B;IACpB,WAAW,GAAG,IAAI,GAAG,EAAgH,CAAC;IACtI,QAAQ,GAAG,IAAI,GAAG,EAAuB,CAAC;IAE3D,oEAAoE;IACpE,IAAI,aAAa;QACb,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1E,CAAC;IAED,yEAAyE;IACzE,IAAI,cAAc;QACd,OAAO,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/G,CAAC;IAED,qDAAqD;IACrD,GAAG,CAAC,UAAkB;QAClB,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC5C,CAAC;IAED,mFAAmF;IACnF,gBAAgB,CAAC,aAA0B,EAAE,UAAkB;QAC3D,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,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,EAAE,aAAa,CAAC,CAAC;QAC7C,IAAI,CAAC;YACD,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC;YACrB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACxE,CAAC;gBAAS,CAAC;YACP,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACrC,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { IProjectionBuilderFor } from '../../../../projections/declarative/IProjectionBuilderFor.js';
|
|
2
|
+
export declare class Counted {
|
|
3
|
+
readonly total: number;
|
|
4
|
+
constructor(total: number);
|
|
5
|
+
}
|
|
6
|
+
export declare class ItemChanged {
|
|
7
|
+
readonly itemId: string;
|
|
8
|
+
readonly name: string;
|
|
9
|
+
constructor(itemId: string, name: string);
|
|
10
|
+
}
|
|
11
|
+
export declare class ItemRemoved {
|
|
12
|
+
readonly itemId: string;
|
|
13
|
+
constructor(itemId: string);
|
|
14
|
+
}
|
|
15
|
+
export declare class Removed {
|
|
16
|
+
}
|
|
17
|
+
export declare class Item {
|
|
18
|
+
itemId: string;
|
|
19
|
+
name: string;
|
|
20
|
+
}
|
|
21
|
+
export declare class Totals {
|
|
22
|
+
id: string;
|
|
23
|
+
total: number;
|
|
24
|
+
items: Item[];
|
|
25
|
+
}
|
|
26
|
+
export declare class TotalsProjection {
|
|
27
|
+
define(builder: IProjectionBuilderFor<Totals>): void;
|
|
28
|
+
}
|
|
29
|
+
export declare const artifacts: {
|
|
30
|
+
readModels: (typeof Totals)[];
|
|
31
|
+
projections: (typeof TotalsProjection)[];
|
|
32
|
+
eventTypes: (typeof Counted | typeof ItemChanged | typeof ItemRemoved | typeof Removed)[];
|
|
33
|
+
globalForHandlers: never[];
|
|
34
|
+
reducers: never[];
|
|
35
|
+
reactors: never[];
|
|
36
|
+
seeders: never[];
|
|
37
|
+
constraints: never[];
|
|
38
|
+
webhooks: never[];
|
|
39
|
+
eventTypeMigrations: never[];
|
|
40
|
+
};
|
|
41
|
+
export declare function compile(): import("../../../../projections/CompiledProjectionDefinitions.js").CompiledProjectionDefinitions;
|
|
42
|
+
//# sourceMappingURL=compiled_projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiled_projection.d.ts","sourceRoot":"","sources":["../../../../../testing/for_ReadModelScenario/when_counting_with_children/given/compiled_projection.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8DAA8D,CAAC;AAI1G,qBACa,OAAO;IACD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACtC,YAAY,KAAK,EAAE,MAAM,EAAyB;CACrD;AACD,qBACa,WAAW;IACL,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACrC,YAAY,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAA6C;CACxF;AACD,qBACa,WAAW;IACL,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACvC,YAAY,MAAM,EAAE,MAAM,EAA2B;CACxD;AACD,qBACa,OAAO;CAAG;AACvB,qBAAa,IAAI;IACE,MAAM,EAAG,MAAM,CAAC;IAChB,IAAI,EAAG,MAAM,CAAC;CAChC;AACD,qBAAa,MAAM;IACA,EAAE,EAAG,MAAM,CAAC;IACZ,KAAK,EAAG,MAAM,CAAC;IACc,KAAK,EAAG,IAAI,EAAE,CAAC;CAC9D;AACD,qBACa,gBAAgB;IACzB,MAAM,CAAC,OAAO,EAAE,qBAAqB,CAAC,MAAM,CAAC,GAAG,IAAI,CAMnD;CACJ;AACD,eAAO,MAAM,SAAS;;;;;;;;;;;CAGc,CAAC;AAErC,wBAAgB,OAAO,qGAEtB"}
|
package/dist/testing/for_ReadModelScenario/when_counting_with_children/given/compiled_projection.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
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
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8
|
+
};
|
|
9
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
10
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
11
|
+
};
|
|
12
|
+
import { field } from '@cratis/fundamentals';
|
|
13
|
+
import { eventType } from '../../../../events/eventTypeDecorator.js';
|
|
14
|
+
import { projection } from '../../../../projections/declarative/projection.js';
|
|
15
|
+
import { ProjectionDefinitionCompiler } from '../../../../projections/ProjectionDefinitionCompiler.js';
|
|
16
|
+
let Counted = class Counted {
|
|
17
|
+
total;
|
|
18
|
+
constructor(total) { this.total = total; }
|
|
19
|
+
};
|
|
20
|
+
__decorate([
|
|
21
|
+
field(Number),
|
|
22
|
+
__metadata("design:type", Number)
|
|
23
|
+
], Counted.prototype, "total", void 0);
|
|
24
|
+
Counted = __decorate([
|
|
25
|
+
eventType('Counted'),
|
|
26
|
+
__metadata("design:paramtypes", [Number])
|
|
27
|
+
], Counted);
|
|
28
|
+
export { Counted };
|
|
29
|
+
let ItemChanged = class ItemChanged {
|
|
30
|
+
itemId;
|
|
31
|
+
name;
|
|
32
|
+
constructor(itemId, name) { this.itemId = itemId; this.name = name; }
|
|
33
|
+
};
|
|
34
|
+
__decorate([
|
|
35
|
+
field(String),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], ItemChanged.prototype, "itemId", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
field(String),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], ItemChanged.prototype, "name", void 0);
|
|
42
|
+
ItemChanged = __decorate([
|
|
43
|
+
eventType('ItemChanged'),
|
|
44
|
+
__metadata("design:paramtypes", [String, String])
|
|
45
|
+
], ItemChanged);
|
|
46
|
+
export { ItemChanged };
|
|
47
|
+
let ItemRemoved = class ItemRemoved {
|
|
48
|
+
itemId;
|
|
49
|
+
constructor(itemId) { this.itemId = itemId; }
|
|
50
|
+
};
|
|
51
|
+
__decorate([
|
|
52
|
+
field(String),
|
|
53
|
+
__metadata("design:type", String)
|
|
54
|
+
], ItemRemoved.prototype, "itemId", void 0);
|
|
55
|
+
ItemRemoved = __decorate([
|
|
56
|
+
eventType('ItemRemoved'),
|
|
57
|
+
__metadata("design:paramtypes", [String])
|
|
58
|
+
], ItemRemoved);
|
|
59
|
+
export { ItemRemoved };
|
|
60
|
+
let Removed = class Removed {
|
|
61
|
+
};
|
|
62
|
+
Removed = __decorate([
|
|
63
|
+
eventType('Removed')
|
|
64
|
+
], Removed);
|
|
65
|
+
export { Removed };
|
|
66
|
+
export class Item {
|
|
67
|
+
itemId;
|
|
68
|
+
name;
|
|
69
|
+
}
|
|
70
|
+
__decorate([
|
|
71
|
+
field(String),
|
|
72
|
+
__metadata("design:type", String)
|
|
73
|
+
], Item.prototype, "itemId", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
field(String),
|
|
76
|
+
__metadata("design:type", String)
|
|
77
|
+
], Item.prototype, "name", void 0);
|
|
78
|
+
export class Totals {
|
|
79
|
+
id;
|
|
80
|
+
total;
|
|
81
|
+
items;
|
|
82
|
+
}
|
|
83
|
+
__decorate([
|
|
84
|
+
field(String),
|
|
85
|
+
__metadata("design:type", String)
|
|
86
|
+
], Totals.prototype, "id", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
field(Number),
|
|
89
|
+
__metadata("design:type", Number)
|
|
90
|
+
], Totals.prototype, "total", void 0);
|
|
91
|
+
__decorate([
|
|
92
|
+
field(Array, { genericArguments: [Item] }),
|
|
93
|
+
__metadata("design:type", Array)
|
|
94
|
+
], Totals.prototype, "items", void 0);
|
|
95
|
+
let TotalsProjection = class TotalsProjection {
|
|
96
|
+
define(builder) {
|
|
97
|
+
builder.from(Counted, from => from.count(model => model.total))
|
|
98
|
+
.children(model => model.items, child => child.identifiedBy(item => item.itemId)
|
|
99
|
+
.from(ItemChanged, from => from.usingKey(event => event.itemId))
|
|
100
|
+
.removedWith(ItemRemoved, removal => removal.usingKey(event => event.itemId)))
|
|
101
|
+
.removedWith(Removed);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
TotalsProjection = __decorate([
|
|
105
|
+
projection('count-children', Totals)
|
|
106
|
+
], TotalsProjection);
|
|
107
|
+
export { TotalsProjection };
|
|
108
|
+
export const artifacts = {
|
|
109
|
+
readModels: [Totals], projections: [TotalsProjection], eventTypes: [Counted, ItemChanged, ItemRemoved, Removed],
|
|
110
|
+
globalForHandlers: [], reducers: [], reactors: [], seeders: [], constraints: [], webhooks: [], eventTypeMigrations: []
|
|
111
|
+
};
|
|
112
|
+
export function compile() {
|
|
113
|
+
return new ProjectionDefinitionCompiler(artifacts, 'test').compile([TotalsProjection], []);
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=compiled_projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiled_projection.js","sourceRoot":"","sources":["../../../../../testing/for_ReadModelScenario/when_counting_with_children/given/compiled_projection.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;;;;;;;;;;AAErG,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAErE,OAAO,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E,OAAO,CAAC;IAC/G,iBAAiB,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,mBAAmB,EAAE,EAAE;CACtF,CAAC;AAErC,MAAM,UAAU,OAAO;IACnB,OAAO,IAAI,4BAA4B,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,gBAAgB,CAAC,EAAE,EAAE,CAAC,CAAC;AAC/F,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ReadModelScenario } from '../../../ReadModelScenario.js';
|
|
2
|
+
type CountedParent = {
|
|
3
|
+
id: string;
|
|
4
|
+
total: number;
|
|
5
|
+
items: Array<{
|
|
6
|
+
itemId: string;
|
|
7
|
+
name: string;
|
|
8
|
+
}>;
|
|
9
|
+
};
|
|
10
|
+
export declare function lifecycle<T extends CountedParent>(scenario: ReadModelScenario<T>): Promise<{
|
|
11
|
+
first: T;
|
|
12
|
+
other: T;
|
|
13
|
+
remaining: T;
|
|
14
|
+
removed: T | null;
|
|
15
|
+
surviving: T;
|
|
16
|
+
recreated: T;
|
|
17
|
+
repeated: T;
|
|
18
|
+
}>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=lifecycle.d.ts.map
|
package/dist/testing/for_ReadModelScenario/when_counting_with_children/given/lifecycle.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../../../testing/for_ReadModelScenario/when_counting_with_children/given/lifecycle.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAGvE,KAAK,aAAa,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC;AAEnG,wBAAsB,SAAS,CAAC,CAAC,SAAS,aAAa,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC;;;;;;;;GAetF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 { Counted, ItemChanged, ItemRemoved, Removed } from './compiled_projection.js';
|
|
4
|
+
export async function lifecycle(scenario) {
|
|
5
|
+
scenario.given.forEventSource('A').events(new Counted(9000), new Counted(8000));
|
|
6
|
+
scenario.given.forEventSource('A').events(new ItemChanged('one', 'first'), new ItemChanged('two', 'second'), new ItemChanged('one', 'updated'), new Counted(7000));
|
|
7
|
+
scenario.given.forEventSource('B').events(new Counted(6000), new ItemChanged('one', 'independent'));
|
|
8
|
+
const first = (await scenario.instanceForEventSourceId('A'));
|
|
9
|
+
const other = (await scenario.instanceForEventSourceId('B'));
|
|
10
|
+
scenario.given.forEventSource('A').events(new ItemRemoved('one'), new ItemRemoved('unknown'));
|
|
11
|
+
const remaining = (await scenario.instanceForEventSourceId('A'));
|
|
12
|
+
scenario.given.forEventSource('A').events(new Removed());
|
|
13
|
+
const removed = await scenario.instanceForEventSourceId('A');
|
|
14
|
+
const surviving = (await scenario.instanceForEventSourceId('B'));
|
|
15
|
+
scenario.given.forEventSource('A').events(new Counted(5000), new ItemChanged('new', 'recreated'));
|
|
16
|
+
const recreated = (await scenario.instanceForEventSourceId('A'));
|
|
17
|
+
const repeated = (await scenario.instanceForEventSourceId('A'));
|
|
18
|
+
return { first, other, remaining, removed, surviving, recreated, repeated };
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=lifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.js","sourceRoot":"","s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E,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC;IACzD,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC;IAC7D,MAAM,SAAS,GAAG,CAAC,MAAM,QAAQ,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAE,CAAC;IAClE,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;IAClG,MAAM,SAAS,GAAG,CAAC,MAAM,QAAQ,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAE,CAAC;IAClE,MAAM,QAAQ,GAAG,CAAC,MAAM,QAAQ,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAE,CAAC;IACjE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { JsonSchema } from '../../schemas/JsonSchema.js';
|
|
2
|
+
/** The measured intersection of root counting and independent typed children. */
|
|
3
|
+
export declare class ProjectionCountChildrenCapabilities {
|
|
4
|
+
static supports(schema: JsonSchema, wire: Record<string, unknown>): boolean;
|
|
5
|
+
private static singleCount;
|
|
6
|
+
private static rootShape;
|
|
7
|
+
private static exactRootMembers;
|
|
8
|
+
private static countTarget;
|
|
9
|
+
private static plainString;
|
|
10
|
+
private static childShape;
|
|
11
|
+
private static stringItems;
|
|
12
|
+
private static independentEvents;
|
|
13
|
+
private static noInteractions;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ProjectionCountChildrenCapabilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectionCountChildrenCapabilities.d.ts","sourceRoot":"","sources":["../../../testing/projections/ProjectionCountChildrenCapabilities.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D,iFAAiF;AACjF,qBAAa,mCAAmC;IAC5C,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAS1E;IAED,OAAO,CAAC,MAAM,CAAC,WAAW;IAM1B,OAAO,CAAC,MAAM,CAAC,SAAS;IAMxB,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAM/B,OAAO,CAAC,MAAM,CAAC,WAAW;IAI1B,OAAO,CAAC,MAAM,CAAC,WAAW;IAI1B,OAAO,CAAC,MAAM,CAAC,UAAU;IAKzB,OAAO,CAAC,MAAM,CAAC,WAAW;IAM1B,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAShC,OAAO,CAAC,MAAM,CAAC,cAAc;CAIhC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
/** The measured intersection of root counting and independent typed children. */
|
|
4
|
+
export class ProjectionCountChildrenCapabilities {
|
|
5
|
+
static supports(schema, wire) {
|
|
6
|
+
const from = wire.From ?? [];
|
|
7
|
+
const children = Object.entries(wire.Children ?? {});
|
|
8
|
+
if (!this.singleCount(from) || children.length !== 1)
|
|
9
|
+
return false;
|
|
10
|
+
const [collection, child] = children[0];
|
|
11
|
+
const count = Object.keys(from[0].Value.Properties)[0];
|
|
12
|
+
return this.rootShape(schema, count, collection)
|
|
13
|
+
&& this.childShape(schema.properties?.[collection], child)
|
|
14
|
+
&& this.independentEvents(from, wire, child) && this.noInteractions(wire);
|
|
15
|
+
}
|
|
16
|
+
static singleCount(from) {
|
|
17
|
+
if (from.length !== 1)
|
|
18
|
+
return false;
|
|
19
|
+
const expressions = Object.values(from[0].Value.Properties ?? {});
|
|
20
|
+
return expressions.length === 1 && expressions[0] === '$count';
|
|
21
|
+
}
|
|
22
|
+
static rootShape(schema, count, collection) {
|
|
23
|
+
const properties = schema.properties ?? {};
|
|
24
|
+
return this.exactRootMembers(properties, count, collection)
|
|
25
|
+
&& this.plainString(properties.id) && this.countTarget(properties[count]);
|
|
26
|
+
}
|
|
27
|
+
static exactRootMembers(properties, count, collection) {
|
|
28
|
+
const allowed = new Set(['id', count, collection]);
|
|
29
|
+
const names = Object.keys(properties);
|
|
30
|
+
return allowed.size === 3 && names.length === 3 && names.every(property => allowed.has(property));
|
|
31
|
+
}
|
|
32
|
+
static countTarget(schema) {
|
|
33
|
+
return schema?.type === 'number' && [undefined, '', 'double'].includes(schema.format);
|
|
34
|
+
}
|
|
35
|
+
static plainString(schema) {
|
|
36
|
+
return schema?.type === 'string' && !schema.format;
|
|
37
|
+
}
|
|
38
|
+
static childShape(collection, child) {
|
|
39
|
+
return collection?.type === 'array' && this.stringItems(collection.items, child.IdentifiedBy)
|
|
40
|
+
&& child.From.length > 0 && child.Join.length === 0;
|
|
41
|
+
}
|
|
42
|
+
static stringItems(items, identifier) {
|
|
43
|
+
if (items?.type !== 'object' || !items.properties)
|
|
44
|
+
return false;
|
|
45
|
+
return this.plainString(items.properties[identifier])
|
|
46
|
+
&& Object.values(items.properties).every(property => this.plainString(property));
|
|
47
|
+
}
|
|
48
|
+
static independentEvents(from, wire, child) {
|
|
49
|
+
const removals = wire.RemovedWith ?? [];
|
|
50
|
+
const rootEvents = new Set([...from, ...removals].map(entry => entry.Key.Id));
|
|
51
|
+
return [...child.From, ...child.RemovedWith].every(entry => {
|
|
52
|
+
if (!entry.Key)
|
|
53
|
+
return false;
|
|
54
|
+
return !rootEvents.has(entry.Key.Id);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
static noInteractions(wire) {
|
|
58
|
+
return (wire.InitialModelState ?? '{}') === '{}'
|
|
59
|
+
&& (wire.Join ?? []).length === 0;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=ProjectionCountChildrenCapabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectionCountChildrenCapabilities.js","sourceRoot":"","sources":["../../../testing/projections/ProjectionCountChildrenCapabilities.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAMrG,iFAAiF;AACjF,MAAM,OAAO,mCAAmC;IAC5C,MAAM,CAAC,QAAQ,CAAC,MAAkB,EAAE,IAA6B;QAC7D,MAAM,IAAI,GAAG,IAAI,CAAC,IAAoB,IAAI,EAAE,CAAC;QAC7C,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,QAA8C,IAAI,EAAE,CAAC,CAAC;QAC3F,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QACnE,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QACxC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC;eACzC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC;eACvD,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAClF,CAAC;IAEO,MAAM,CAAC,WAAW,CAAC,IAAkB;QACzC,IAAI,IAAI,CAAC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AAC,GAAG;gBAAE,OAAO,KAAK,CAAC;YAC7B,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,MAAM,CAAC,cAAc,CAAC,IAA6B;QACvD,OAAO,CAAC,IAAI,CAAC,iBAAiB,IAAI,IAAI,CAAC,KAAK,IAAI;eACzC,CAAC,IAAI,CAAC,IAAiB,IAAI,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;IACvD,CAAC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectionRootCapabilities.d.ts","sourceRoot":"","sources":["../../../testing/projections/ProjectionRootCapabilities.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,wDAAwD,CAAC;AAE5G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"ProjectionRootCapabilities.d.ts","sourceRoot":"","sources":["../../../testing/projections/ProjectionRootCapabilities.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,wDAAwD,CAAC;AAE5G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAG9D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAGxF,wFAAwF;AACxF,qBAAa,0BAA0B;IAIvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAAc,OAAO,CAAC,QAAQ,CAAC,IAAI;IAA2B,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHxH,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,iBAAiB,EAAE,CAAC;IAE1C,YAA6B,MAAM,EAAE,UAAU,EAAmB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAmB,MAAM,EAAE,0BAA0B,EAGnJ;IAED,QAAQ,CAAC,QAAQ,EAAE,6BAA6B,GAAG,IAAI,CAQtD;IAED,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,wBAAwB;IAQhC,OAAO,CAAC,wBAAwB;IAShC,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,UAAU;CASrB"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { AutoMap } from '@cratis/chronicle.contracts';
|
|
4
4
|
import { eventContractPath } from '../../projections/eventContractPath.js';
|
|
5
5
|
import { ProjectionArithmetic } from './ProjectionArithmetic.js';
|
|
6
|
+
import { ProjectionCountChildrenCapabilities } from './ProjectionCountChildrenCapabilities.js';
|
|
6
7
|
import { ProjectionMappingCapabilities } from './ProjectionMappingCapabilities.js';
|
|
7
8
|
/** Validates root subscriptions and accumulator interactions before child traversal. */
|
|
8
9
|
export class ProjectionRootCapabilities {
|
|
@@ -37,7 +38,11 @@ export class ProjectionRootCapabilities {
|
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
checkAccumulatorChildren(accumulators) {
|
|
40
|
-
if (accumulators.size
|
|
41
|
+
if (!accumulators.size)
|
|
42
|
+
return;
|
|
43
|
+
if (!Object.keys(this.wire.Children ?? {}).length)
|
|
44
|
+
return;
|
|
45
|
+
if (!ProjectionCountChildrenCapabilities.supports(this.schema, this.wire)) {
|
|
41
46
|
this.reject('Children', 'root arithmetic combined with children requires a kernel-backed test');
|
|
42
47
|
}
|
|
43
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectionRootCapabilities.js","sourceRoot":"","sources":["../../../testing/projections/ProjectionRootCapabilities.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CA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