@cratis/chronicle 6.71.1 → 6.71.2
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/for_ReadModelScenario/when_adding_with_children/given/compiled_projection.d.ts +142 -0
- package/dist/testing/for_ReadModelScenario/when_adding_with_children/given/compiled_projection.d.ts.map +1 -0
- package/dist/testing/for_ReadModelScenario/when_adding_with_children/given/compiled_projection.js +142 -0
- package/dist/testing/for_ReadModelScenario/when_adding_with_children/given/compiled_projection.js.map +1 -0
- package/dist/testing/for_ReadModelScenario/when_adding_with_children/given/lifecycle.d.ts +24 -0
- package/dist/testing/for_ReadModelScenario/when_adding_with_children/given/lifecycle.d.ts.map +1 -0
- package/dist/testing/for_ReadModelScenario/when_adding_with_children/given/lifecycle.js +34 -0
- package/dist/testing/for_ReadModelScenario/when_adding_with_children/given/lifecycle.js.map +1 -0
- package/dist/testing/projections/ProjectionArithmeticChildrenCapabilities.d.ts +17 -0
- package/dist/testing/projections/ProjectionArithmeticChildrenCapabilities.d.ts.map +1 -0
- package/dist/testing/projections/{ProjectionCountChildrenCapabilities.js → ProjectionArithmeticChildrenCapabilities.js} +24 -12
- package/dist/testing/projections/ProjectionArithmeticChildrenCapabilities.js.map +1 -0
- package/dist/testing/projections/ProjectionRootCapabilities.js +4 -4
- package/dist/testing/projections/ProjectionRootCapabilities.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/testing/for_ReadModelScenario/when_adding_with_children/given/compiled_projection.ts +71 -0
- package/testing/for_ReadModelScenario/when_adding_with_children/given/lifecycle.ts +38 -0
- package/testing/for_ReadModelScenario/when_adding_with_children/with_a_fluent_projection.spec.ts +64 -0
- package/testing/for_ReadModelScenario/when_adding_with_children/with_legacy_decorators.legacy.spec.ts +41 -0
- package/testing/for_ReadModelScenario/when_adding_with_children/with_standard_decorators.standard.spec.ts +42 -0
- package/testing/projections/{ProjectionCountChildrenCapabilities.ts → ProjectionArithmeticChildrenCapabilities.ts} +22 -11
- package/testing/projections/ProjectionRootCapabilities.ts +4 -4
- package/testing/projections/for_ProjectionCapabilities/when_validating_add_with_children.spec.ts +91 -0
- package/testing/projections/for_ProjectionCapabilities/when_validating_count_with_children.spec.ts +12 -2
- package/dist/testing/projections/ProjectionCountChildrenCapabilities.d.ts +0 -15
- package/dist/testing/projections/ProjectionCountChildrenCapabilities.d.ts.map +0 -1
- package/dist/testing/projections/ProjectionCountChildrenCapabilities.js.map +0 -1
package/dist/testing/for_ReadModelScenario/when_adding_with_children/given/compiled_projection.d.ts
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { IProjectionBuilderFor } from '../../../../projections/declarative/IProjectionBuilderFor.js';
|
|
2
|
+
export declare class Added {
|
|
3
|
+
readonly amount: number;
|
|
4
|
+
constructor(amount: number);
|
|
5
|
+
}
|
|
6
|
+
declare class TotalAdded {
|
|
7
|
+
readonly total: number;
|
|
8
|
+
constructor(total: number);
|
|
9
|
+
}
|
|
10
|
+
declare class UnderscoreAdded {
|
|
11
|
+
readonly _amount: number;
|
|
12
|
+
constructor(_amount: number);
|
|
13
|
+
}
|
|
14
|
+
export declare class ItemChanged {
|
|
15
|
+
readonly itemId: string;
|
|
16
|
+
readonly name: string;
|
|
17
|
+
constructor(itemId: string, name: string);
|
|
18
|
+
}
|
|
19
|
+
export declare class ItemRemoved {
|
|
20
|
+
readonly itemId: string;
|
|
21
|
+
constructor(itemId: string);
|
|
22
|
+
}
|
|
23
|
+
export declare class Removed {
|
|
24
|
+
}
|
|
25
|
+
export declare class Item {
|
|
26
|
+
itemId: string;
|
|
27
|
+
name: string;
|
|
28
|
+
}
|
|
29
|
+
export declare class Totals {
|
|
30
|
+
id: string;
|
|
31
|
+
total: number;
|
|
32
|
+
items: Item[];
|
|
33
|
+
}
|
|
34
|
+
export declare const variants: ({
|
|
35
|
+
name: string;
|
|
36
|
+
event: new (amount: number) => Added;
|
|
37
|
+
artifacts: {
|
|
38
|
+
readModels: (typeof Totals)[];
|
|
39
|
+
projections: {
|
|
40
|
+
new (): {
|
|
41
|
+
define(builder: IProjectionBuilderFor<Totals>): void;
|
|
42
|
+
};
|
|
43
|
+
}[];
|
|
44
|
+
eventTypes: (typeof ItemChanged | typeof ItemRemoved | typeof Removed | (new (amount: number) => Added))[];
|
|
45
|
+
globalForHandlers: never[];
|
|
46
|
+
reducers: never[];
|
|
47
|
+
reactors: never[];
|
|
48
|
+
seeders: never[];
|
|
49
|
+
constraints: never[];
|
|
50
|
+
webhooks: never[];
|
|
51
|
+
eventTypeMigrations: never[];
|
|
52
|
+
};
|
|
53
|
+
compile: () => import("../../../../projections/CompiledProjectionDefinitions.js").CompiledProjectionDefinitions;
|
|
54
|
+
} | {
|
|
55
|
+
name: string;
|
|
56
|
+
event: new (amount: number) => TotalAdded;
|
|
57
|
+
artifacts: {
|
|
58
|
+
readModels: (typeof Totals)[];
|
|
59
|
+
projections: {
|
|
60
|
+
new (): {
|
|
61
|
+
define(builder: IProjectionBuilderFor<Totals>): void;
|
|
62
|
+
};
|
|
63
|
+
}[];
|
|
64
|
+
eventTypes: (typeof ItemChanged | typeof ItemRemoved | typeof Removed | (new (amount: number) => TotalAdded))[];
|
|
65
|
+
globalForHandlers: never[];
|
|
66
|
+
reducers: never[];
|
|
67
|
+
reactors: never[];
|
|
68
|
+
seeders: never[];
|
|
69
|
+
constraints: never[];
|
|
70
|
+
webhooks: never[];
|
|
71
|
+
eventTypeMigrations: never[];
|
|
72
|
+
};
|
|
73
|
+
compile: () => import("../../../../projections/CompiledProjectionDefinitions.js").CompiledProjectionDefinitions;
|
|
74
|
+
} | {
|
|
75
|
+
name: string;
|
|
76
|
+
event: new (amount: number) => UnderscoreAdded;
|
|
77
|
+
artifacts: {
|
|
78
|
+
readModels: (typeof Totals)[];
|
|
79
|
+
projections: {
|
|
80
|
+
new (): {
|
|
81
|
+
define(builder: IProjectionBuilderFor<Totals>): void;
|
|
82
|
+
};
|
|
83
|
+
}[];
|
|
84
|
+
eventTypes: (typeof ItemChanged | typeof ItemRemoved | typeof Removed | (new (amount: number) => UnderscoreAdded))[];
|
|
85
|
+
globalForHandlers: never[];
|
|
86
|
+
reducers: never[];
|
|
87
|
+
reactors: never[];
|
|
88
|
+
seeders: never[];
|
|
89
|
+
constraints: never[];
|
|
90
|
+
webhooks: never[];
|
|
91
|
+
eventTypeMigrations: never[];
|
|
92
|
+
};
|
|
93
|
+
compile: () => import("../../../../projections/CompiledProjectionDefinitions.js").CompiledProjectionDefinitions;
|
|
94
|
+
})[];
|
|
95
|
+
export declare const artifacts: {
|
|
96
|
+
readModels: (typeof Totals)[];
|
|
97
|
+
projections: {
|
|
98
|
+
new (): {
|
|
99
|
+
define(builder: IProjectionBuilderFor<Totals>): void;
|
|
100
|
+
};
|
|
101
|
+
}[];
|
|
102
|
+
eventTypes: (typeof ItemChanged | typeof ItemRemoved | typeof Removed | (new (amount: number) => Added))[];
|
|
103
|
+
globalForHandlers: never[];
|
|
104
|
+
reducers: never[];
|
|
105
|
+
reactors: never[];
|
|
106
|
+
seeders: never[];
|
|
107
|
+
constraints: never[];
|
|
108
|
+
webhooks: never[];
|
|
109
|
+
eventTypeMigrations: never[];
|
|
110
|
+
} | {
|
|
111
|
+
readModels: (typeof Totals)[];
|
|
112
|
+
projections: {
|
|
113
|
+
new (): {
|
|
114
|
+
define(builder: IProjectionBuilderFor<Totals>): void;
|
|
115
|
+
};
|
|
116
|
+
}[];
|
|
117
|
+
eventTypes: (typeof ItemChanged | typeof ItemRemoved | typeof Removed | (new (amount: number) => TotalAdded))[];
|
|
118
|
+
globalForHandlers: never[];
|
|
119
|
+
reducers: never[];
|
|
120
|
+
reactors: never[];
|
|
121
|
+
seeders: never[];
|
|
122
|
+
constraints: never[];
|
|
123
|
+
webhooks: never[];
|
|
124
|
+
eventTypeMigrations: never[];
|
|
125
|
+
} | {
|
|
126
|
+
readModels: (typeof Totals)[];
|
|
127
|
+
projections: {
|
|
128
|
+
new (): {
|
|
129
|
+
define(builder: IProjectionBuilderFor<Totals>): void;
|
|
130
|
+
};
|
|
131
|
+
}[];
|
|
132
|
+
eventTypes: (typeof ItemChanged | typeof ItemRemoved | typeof Removed | (new (amount: number) => UnderscoreAdded))[];
|
|
133
|
+
globalForHandlers: never[];
|
|
134
|
+
reducers: never[];
|
|
135
|
+
reactors: never[];
|
|
136
|
+
seeders: never[];
|
|
137
|
+
constraints: never[];
|
|
138
|
+
webhooks: never[];
|
|
139
|
+
eventTypeMigrations: never[];
|
|
140
|
+
}, compile: (() => import("../../../../projections/CompiledProjectionDefinitions.js").CompiledProjectionDefinitions) | (() => import("../../../../projections/CompiledProjectionDefinitions.js").CompiledProjectionDefinitions) | (() => import("../../../../projections/CompiledProjectionDefinitions.js").CompiledProjectionDefinitions);
|
|
141
|
+
export {};
|
|
142
|
+
//# sourceMappingURL=compiled_projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiled_projection.d.ts","sourceRoot":"","sources":["../../../../../testing/for_ReadModelScenario/when_adding_with_children/given/compiled_projection.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8DAA8D,CAAC;AAI1G,qBACa,KAAK;IACC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACvC,YAAY,MAAM,EAAE,MAAM,EAA2B;CACxD;AACD,cACM,UAAU;IACG,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACtC,YAAY,KAAK,EAAE,MAAM,EAAyB;CACrD;AACD,cACM,eAAe;IACF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACxC,YAAY,OAAO,EAAE,MAAM,EAA6B;CAC3D;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;AAmBD,eAAO,MAAM,QAAQ;;wBAjBgD,MAAM;;;;;gCAEnD,qBAAqB,CAAC,MAAM,CAAC,GAAG,IAAI;;;;;;;;;;;;;;;wBAFS,MAAM;;;;;gCAEnD,qBAAqB,CAAC,MAAM,CAAC,GAAG,IAAI;;;;;;;;;;;;;;;wBAFS,MAAM;;;;;gCAEnD,qBAAqB,CAAC,MAAM,CAAC,GAAG,IAAI;;;;;;;;;;;;;IAmB3D,CAAC;AACF,eAAO,MAAQ,SAAS;;;;4BApBA,qBAAqB,CAAC,MAAM,CAAC,GAAG,IAAI;;;0FAFS,MAAM;;;;;;;;;;;;4BAEnD,qBAAqB,CAAC,MAAM,CAAC,GAAG,IAAI;;;0FAFS,MAAM;;;;;;;;;;;;4BAEnD,qBAAqB,CAAC,MAAM,CAAC,GAAG,IAAI;;;0FAFS,MAAM;;;;;;;;GAsBjD,OAAO,gUAAgB,CAAC"}
|
package/dist/testing/for_ReadModelScenario/when_adding_with_children/given/compiled_projection.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
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 Added = class Added {
|
|
17
|
+
amount;
|
|
18
|
+
constructor(amount) { this.amount = amount; }
|
|
19
|
+
};
|
|
20
|
+
__decorate([
|
|
21
|
+
field(Number),
|
|
22
|
+
__metadata("design:type", Number)
|
|
23
|
+
], Added.prototype, "amount", void 0);
|
|
24
|
+
Added = __decorate([
|
|
25
|
+
eventType('Added'),
|
|
26
|
+
__metadata("design:paramtypes", [Number])
|
|
27
|
+
], Added);
|
|
28
|
+
export { Added };
|
|
29
|
+
let TotalAdded = class TotalAdded {
|
|
30
|
+
total;
|
|
31
|
+
constructor(total) { this.total = total; }
|
|
32
|
+
};
|
|
33
|
+
__decorate([
|
|
34
|
+
field(Number),
|
|
35
|
+
__metadata("design:type", Number)
|
|
36
|
+
], TotalAdded.prototype, "total", void 0);
|
|
37
|
+
TotalAdded = __decorate([
|
|
38
|
+
eventType('TotalAdded'),
|
|
39
|
+
__metadata("design:paramtypes", [Number])
|
|
40
|
+
], TotalAdded);
|
|
41
|
+
let UnderscoreAdded = class UnderscoreAdded {
|
|
42
|
+
_amount;
|
|
43
|
+
constructor(_amount) { this._amount = _amount; }
|
|
44
|
+
};
|
|
45
|
+
__decorate([
|
|
46
|
+
field(Number),
|
|
47
|
+
__metadata("design:type", Number)
|
|
48
|
+
], UnderscoreAdded.prototype, "_amount", void 0);
|
|
49
|
+
UnderscoreAdded = __decorate([
|
|
50
|
+
eventType('UnderscoreAdded'),
|
|
51
|
+
__metadata("design:paramtypes", [Number])
|
|
52
|
+
], UnderscoreAdded);
|
|
53
|
+
let ItemChanged = class ItemChanged {
|
|
54
|
+
itemId;
|
|
55
|
+
name;
|
|
56
|
+
constructor(itemId, name) { this.itemId = itemId; this.name = name; }
|
|
57
|
+
};
|
|
58
|
+
__decorate([
|
|
59
|
+
field(String),
|
|
60
|
+
__metadata("design:type", String)
|
|
61
|
+
], ItemChanged.prototype, "itemId", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
field(String),
|
|
64
|
+
__metadata("design:type", String)
|
|
65
|
+
], ItemChanged.prototype, "name", void 0);
|
|
66
|
+
ItemChanged = __decorate([
|
|
67
|
+
eventType('ItemChanged'),
|
|
68
|
+
__metadata("design:paramtypes", [String, String])
|
|
69
|
+
], ItemChanged);
|
|
70
|
+
export { ItemChanged };
|
|
71
|
+
let ItemRemoved = class ItemRemoved {
|
|
72
|
+
itemId;
|
|
73
|
+
constructor(itemId) { this.itemId = itemId; }
|
|
74
|
+
};
|
|
75
|
+
__decorate([
|
|
76
|
+
field(String),
|
|
77
|
+
__metadata("design:type", String)
|
|
78
|
+
], ItemRemoved.prototype, "itemId", void 0);
|
|
79
|
+
ItemRemoved = __decorate([
|
|
80
|
+
eventType('ItemRemoved'),
|
|
81
|
+
__metadata("design:paramtypes", [String])
|
|
82
|
+
], ItemRemoved);
|
|
83
|
+
export { ItemRemoved };
|
|
84
|
+
let Removed = class Removed {
|
|
85
|
+
};
|
|
86
|
+
Removed = __decorate([
|
|
87
|
+
eventType('Removed')
|
|
88
|
+
], Removed);
|
|
89
|
+
export { Removed };
|
|
90
|
+
export class Item {
|
|
91
|
+
itemId;
|
|
92
|
+
name;
|
|
93
|
+
}
|
|
94
|
+
__decorate([
|
|
95
|
+
field(String),
|
|
96
|
+
__metadata("design:type", String)
|
|
97
|
+
], Item.prototype, "itemId", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
field(String),
|
|
100
|
+
__metadata("design:type", String)
|
|
101
|
+
], Item.prototype, "name", void 0);
|
|
102
|
+
export class Totals {
|
|
103
|
+
id;
|
|
104
|
+
total;
|
|
105
|
+
items;
|
|
106
|
+
}
|
|
107
|
+
__decorate([
|
|
108
|
+
field(String),
|
|
109
|
+
__metadata("design:type", String)
|
|
110
|
+
], Totals.prototype, "id", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
field(Number),
|
|
113
|
+
__metadata("design:type", Number)
|
|
114
|
+
], Totals.prototype, "total", void 0);
|
|
115
|
+
__decorate([
|
|
116
|
+
field(Array, { genericArguments: [Item] }),
|
|
117
|
+
__metadata("design:type", Array)
|
|
118
|
+
], Totals.prototype, "items", void 0);
|
|
119
|
+
function variant(name, event, operand) {
|
|
120
|
+
class TotalsProjection {
|
|
121
|
+
define(builder) {
|
|
122
|
+
builder.from(event, from => from.add(model => model.total).with(operand))
|
|
123
|
+
.children(model => model.items, child => child.identifiedBy(item => item.itemId)
|
|
124
|
+
.from(ItemChanged, from => from.usingKey(value => value.itemId))
|
|
125
|
+
.removedWith(ItemRemoved, removal => removal.usingKey(value => value.itemId)))
|
|
126
|
+
.removedWith(Removed);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
projection(name, Totals)(TotalsProjection);
|
|
130
|
+
const artifacts = {
|
|
131
|
+
readModels: [Totals], projections: [TotalsProjection], eventTypes: [event, ItemChanged, ItemRemoved, Removed],
|
|
132
|
+
globalForHandlers: [], reducers: [], reactors: [], seeders: [], constraints: [], webhooks: [], eventTypeMigrations: []
|
|
133
|
+
};
|
|
134
|
+
return { name, event, artifacts, compile: () => new ProjectionDefinitionCompiler(artifacts, 'test').compile([TotalsProjection], []) };
|
|
135
|
+
}
|
|
136
|
+
export const variants = [
|
|
137
|
+
variant('add-children-lifecycle', Added, event => event.amount),
|
|
138
|
+
variant('add-children-same-property', TotalAdded, event => event.total),
|
|
139
|
+
variant('add-children-leading-underscore', UnderscoreAdded, event => event._amount)
|
|
140
|
+
];
|
|
141
|
+
export const { artifacts, compile } = variants[0];
|
|
142
|
+
//# sourceMappingURL=compiled_projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiled_projection.js","sourceRoot":"","sources":["../../../../../testing/for_ReadModelScenario/when_adding_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,EAAE,UAAU,EAAE,MAAM,mDAAmD,CAAC;AAC/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,yDAAyD,CAAC;AAGhG,IAAM,KAAK,GAAX,MAAM,KAAK;IACU,MAAM,CAAS;IACvC,YAAY,MAAc,IAAI,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;CACxD,CAAA;AAF2B;IAAvB,KAAK,CAAC,MAAM,CAAC;;qCAAyB;AAD9B,KAAK;IADjB,SAAS,CAAC,OAAO,CAAC;;GACN,KAAK,CAGjB;;AACD,IACM,UAAU,GADhB,MACM,UAAU;IACY,KAAK,CAAS;IACtC,YAAY,KAAa,IAAI,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC;CACrD,CAAA;AAF2B;IAAvB,KAAK,CAAC,MAAM,CAAC;;yCAAwB;AADpC,UAAU;IADf,SAAS,CAAC,YAAY,CAAC;;GAClB,UAAU,CAGf;AACD,IACM,eAAe,GADrB,MACM,eAAe;IACO,OAAO,CAAS;IACxC,YAAY,OAAe,IAAI,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;CAC3D,CAAA;AAF2B;IA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C;IACrC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,4BAA4B,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,gBAAgB,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;AAC1I,CAAC;AACD,MAAM,CAAC,MAAM,QAAQ,GAAG;IACpB,OAAO,CAAC,wBAAwB,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC;IAC/D,OAAO,CAAC,4BAA4B,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC;IACvE,OAAO,CAAC,iCAAiC,EAAE,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC;CACtF,CAAC;AACF,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReadModelScenario } from '../../../ReadModelScenario.js';
|
|
2
|
+
type AddedParent = {
|
|
3
|
+
id: string;
|
|
4
|
+
total: number;
|
|
5
|
+
items: Array<{
|
|
6
|
+
itemId: string;
|
|
7
|
+
name: string;
|
|
8
|
+
}>;
|
|
9
|
+
};
|
|
10
|
+
export declare function history(add?: (amount: number) => object): {
|
|
11
|
+
source: string;
|
|
12
|
+
event: object;
|
|
13
|
+
}[];
|
|
14
|
+
export declare function lifecycle<T extends AddedParent>(scenario: ReadModelScenario<T>): Promise<{
|
|
15
|
+
first: T;
|
|
16
|
+
other: T;
|
|
17
|
+
remaining: T;
|
|
18
|
+
removed: T | null;
|
|
19
|
+
surviving: T;
|
|
20
|
+
recreated: T;
|
|
21
|
+
repeated: T;
|
|
22
|
+
}>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../../../testing/for_ReadModelScenario/when_adding_with_children/given/lifecycle.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAGvE,KAAK,WAAW,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;AAEjG,wBAAgB,OAAO,CAAC,GAAG,GAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAoC;;;IAUpF;AAED,wBAAsB,SAAS,CAAC,CAAC,SAAS,WAAW,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC;;;;;;;;GAiBpF"}
|
|
@@ -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
|
+
import { Added, ItemChanged, ItemRemoved, Removed } from './compiled_projection.js';
|
|
4
|
+
export function history(add = amount => new Added(amount)) {
|
|
5
|
+
return [
|
|
6
|
+
{ source: 'A', event: add(2.5) }, { source: 'A', event: add(-1) },
|
|
7
|
+
{ source: 'A', event: new ItemChanged('one', 'first') }, { source: 'A', event: new ItemChanged('two', 'second') },
|
|
8
|
+
{ source: 'A', event: new ItemChanged('one', 'updated') }, { source: 'A', event: add(0) },
|
|
9
|
+
{ source: 'B', event: add(8) }, { source: 'B', event: new ItemChanged('one', 'independent') },
|
|
10
|
+
{ source: 'A', event: new ItemRemoved('one') }, { source: 'A', event: new ItemRemoved('unknown') },
|
|
11
|
+
{ source: 'A', event: new Removed() }, { source: 'A', event: add(4.5) },
|
|
12
|
+
{ source: 'A', event: new ItemChanged('new', 'recreated') }
|
|
13
|
+
];
|
|
14
|
+
}
|
|
15
|
+
export async function lifecycle(scenario) {
|
|
16
|
+
const events = history();
|
|
17
|
+
const seed = (start, end) => {
|
|
18
|
+
for (const { source, event } of events.slice(start, end))
|
|
19
|
+
scenario.given.forEventSource(source).events(event);
|
|
20
|
+
};
|
|
21
|
+
seed(0, 8);
|
|
22
|
+
const first = (await scenario.instanceForEventSourceId('A'));
|
|
23
|
+
const other = (await scenario.instanceForEventSourceId('B'));
|
|
24
|
+
seed(8, 10);
|
|
25
|
+
const remaining = (await scenario.instanceForEventSourceId('A'));
|
|
26
|
+
seed(10, 11);
|
|
27
|
+
const removed = await scenario.instanceForEventSourceId('A');
|
|
28
|
+
const surviving = (await scenario.instanceForEventSourceId('B'));
|
|
29
|
+
seed(11, 13);
|
|
30
|
+
const recreated = (await scenario.instanceForEventSourceId('A'));
|
|
31
|
+
const repeated = (await scenario.instanceForEventSourceId('A'));
|
|
32
|
+
return { first, other, remaining, removed, surviving, recreated, repeated };
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=lifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../../../../testing/for_ReadModelScenario/when_adding_with_children/given/lifecycle.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAGrG,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAIpF,MAAM,UAAU,OAAO,CAAC,GAAG,GAA+B,MAAM,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC;IACjF,OAAO;QACH,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE;QACjE,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE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,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAClH,CAAC,CAAC;IACF,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACX,MAAM,KAAK,GAAG,CAAC,MAAM,QAAQ,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAE,CAAC;IAC9D,MAAM,KAAK,GAAG,CAAC,MAAM,QAAQ,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAE,CAAC;IAC9D,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACZ,MAAM,SAAS,GAAG,CAAC,MAAM,QAAQ,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAE,CAAC;IAClE,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACb,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,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACb,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,17 @@
|
|
|
1
|
+
import type { JsonSchema } from '../../schemas/JsonSchema.js';
|
|
2
|
+
import type { ProjectionEventSchemaResolver } from './ProjectionEventSchemaResolver.js';
|
|
3
|
+
/** The measured intersection of one root accumulator and independent typed children. */
|
|
4
|
+
export declare class ProjectionArithmeticChildrenCapabilities {
|
|
5
|
+
static supports(schema: JsonSchema, wire: Record<string, unknown>, require: ProjectionEventSchemaResolver['require']): boolean;
|
|
6
|
+
private static accumulator;
|
|
7
|
+
private static unformattedNumber;
|
|
8
|
+
private static rootShape;
|
|
9
|
+
private static exactRootMembers;
|
|
10
|
+
private static countTarget;
|
|
11
|
+
private static plainString;
|
|
12
|
+
private static childShape;
|
|
13
|
+
private static stringItems;
|
|
14
|
+
private static independentEvents;
|
|
15
|
+
private static noInteractions;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=ProjectionArithmeticChildrenCapabilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectionArithmeticChildrenCapabilities.d.ts","sourceRoot":"","sources":["../../../testing/projections/ProjectionArithmeticChildrenCapabilities.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAExF,wFAAwF;AACxF,qBAAa,wCAAwC;IACjD,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,6BAA6B,CAAC,SAAS,CAAC,GAAG,OAAO,CAY7H;IAED,OAAO,CAAC,MAAM,CAAC,WAAW;IAQ1B,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAIhC,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"}
|
|
@@ -1,28 +1,40 @@
|
|
|
1
1
|
// Copyright (c) Cratis. All rights reserved.
|
|
2
2
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { eventContractPath } from '../../projections/eventContractPath.js';
|
|
4
|
+
/** The measured intersection of one root accumulator and independent typed children. */
|
|
5
|
+
export class ProjectionArithmeticChildrenCapabilities {
|
|
6
|
+
static supports(schema, wire, require) {
|
|
6
7
|
const from = wire.From ?? [];
|
|
7
8
|
const children = Object.entries(wire.Children ?? {});
|
|
8
|
-
if (
|
|
9
|
+
if (from.length !== 1 || children.length !== 1)
|
|
10
|
+
return false;
|
|
11
|
+
const mappings = Object.entries(from[0].Value.Properties ?? {});
|
|
12
|
+
if (mappings.length !== 1)
|
|
13
|
+
return false;
|
|
14
|
+
const [accumulator, expression] = mappings[0];
|
|
15
|
+
if (!this.accumulator(schema.properties?.[accumulator], expression, from[0], require))
|
|
9
16
|
return false;
|
|
10
17
|
const [collection, child] = children[0];
|
|
11
|
-
|
|
12
|
-
return this.rootShape(schema, count, collection)
|
|
18
|
+
return this.rootShape(schema, accumulator, collection)
|
|
13
19
|
&& this.childShape(schema.properties?.[collection], child)
|
|
14
20
|
&& this.independentEvents(from, wire, child) && this.noInteractions(wire);
|
|
15
21
|
}
|
|
16
|
-
static
|
|
17
|
-
if (
|
|
22
|
+
static accumulator(target, expression, from, require) {
|
|
23
|
+
if (expression === '$count')
|
|
24
|
+
return this.countTarget(target);
|
|
25
|
+
const operand = /^\$add\(([A-Za-z_][A-Za-z0-9]*)\)$/.exec(expression)?.[1];
|
|
26
|
+
if (!operand || !this.unformattedNumber(target))
|
|
18
27
|
return false;
|
|
19
|
-
const
|
|
20
|
-
return
|
|
28
|
+
const event = require(from.Key, eventContractPath('From', from.Key));
|
|
29
|
+
return this.unformattedNumber(event.properties?.[operand]);
|
|
30
|
+
}
|
|
31
|
+
static unformattedNumber(schema) {
|
|
32
|
+
return schema?.type === 'number' && schema.format === undefined;
|
|
21
33
|
}
|
|
22
34
|
static rootShape(schema, count, collection) {
|
|
23
35
|
const properties = schema.properties ?? {};
|
|
24
36
|
return this.exactRootMembers(properties, count, collection)
|
|
25
|
-
&& this.plainString(properties.id)
|
|
37
|
+
&& this.plainString(properties.id);
|
|
26
38
|
}
|
|
27
39
|
static exactRootMembers(properties, count, collection) {
|
|
28
40
|
const allowed = new Set(['id', count, collection]);
|
|
@@ -59,4 +71,4 @@ export class ProjectionCountChildrenCapabilities {
|
|
|
59
71
|
&& (wire.Join ?? []).length === 0;
|
|
60
72
|
}
|
|
61
73
|
}
|
|
62
|
-
//# sourceMappingURL=
|
|
74
|
+
//# sourceMappingURL=ProjectionArithmeticChildrenCapabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectionArithmeticChildrenCapabilities.js","sourceRoot":"","sources":["../../../testing/projections/ProjectionArithmeticChildrenCapabilities.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAKrG,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAG3E,wFAAwF;AACxF,MAAM,OAAO,wCAAwC;IACjD,MAAM,CAAC,QAAQ,CAAC,MAAkB,EAAE,IAA6B,EAAE,OAAiD;QAChH,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,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QAC7D,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;QAChE,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QACxC,MAA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,iBAAiB,IAAI,IAAI,CAAC,KAAK,IAAI;eACzC,CAAC,IAAI,CAAC,IAAiB,IAAI,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;IACvD,CAAC;CACJ"}
|
|
@@ -3,7 +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 {
|
|
6
|
+
import { ProjectionArithmeticChildrenCapabilities } from './ProjectionArithmeticChildrenCapabilities.js';
|
|
7
7
|
import { ProjectionMappingCapabilities } from './ProjectionMappingCapabilities.js';
|
|
8
8
|
/** Validates root subscriptions and accumulator interactions before child traversal. */
|
|
9
9
|
export class ProjectionRootCapabilities {
|
|
@@ -23,7 +23,7 @@ export class ProjectionRootCapabilities {
|
|
|
23
23
|
this.checkOverlaps();
|
|
24
24
|
const accumulators = new Set(this.from.flatMap(entry => Object.entries(entry.Value.Properties ?? {})
|
|
25
25
|
.filter(([, expression]) => ProjectionArithmetic.isArithmetic(expression)).map(([property]) => property)));
|
|
26
|
-
this.checkAccumulatorChildren(accumulators);
|
|
26
|
+
this.checkAccumulatorChildren(accumulators, resolver);
|
|
27
27
|
for (const entry of this.from)
|
|
28
28
|
this.checkClearedAccumulators(entry, accumulators);
|
|
29
29
|
const mappings = new ProjectionMappingCapabilities(this.schema, this.reject, accumulators);
|
|
@@ -37,12 +37,12 @@ export class ProjectionRootCapabilities {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
checkAccumulatorChildren(accumulators) {
|
|
40
|
+
checkAccumulatorChildren(accumulators, resolver) {
|
|
41
41
|
if (!accumulators.size)
|
|
42
42
|
return;
|
|
43
43
|
if (!Object.keys(this.wire.Children ?? {}).length)
|
|
44
44
|
return;
|
|
45
|
-
if (!
|
|
45
|
+
if (!ProjectionArithmeticChildrenCapabilities.supports(this.schema, this.wire, resolver.require)) {
|
|
46
46
|
this.reject('Children', 'root arithmetic combined with children requires a kernel-backed test');
|
|
47
47
|
}
|
|
48
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,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAE3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,
|
|
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,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAE3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,wCAAwC,EAAE,MAAM,+CAA+C,CAAC;AAGzG,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAEnF,wFAAwF;AACxF,MAAM,OAAO,0BAA0B;IAIN,MAAM;IAA+B,IAAI;IAA4C,MAAM;IAH/G,IAAI,CAAe;IACnB,WAAW,CAAsB;IAE1C,YAA6B,MAAkB,EAAmB,IAA6B,EAAmB,MAAkC;sBAAvH,MAAM;oBAA+B,IAAI;sBAA4C,MAAM;QACpH,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAoB,IAAI,EAAE,CAAC;QAC5C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAkC,IAAI,EAAE,CAAC;IACrE,CAAC;IAED,QAAQ,CAAC,QAAuC;QAC5C,IAAI,C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