@reventlessdev/reventless-gwt 1.0.0-alpha.292 → 1.0.0-alpha.294
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/CHANGELOG.md +18 -0
- package/package.json +5 -5
- package/src/Boundary_GWT.res +57 -0
- package/src/Boundary_GWT.res.mjs +56 -0
- package/src/Decision_GWT.res +28 -0
- package/src/Decision_GWT.res.mjs +42 -2
- package/src/Flow_GWT.res +1176 -381
- package/src/Flow_GWT.res.mjs +1678 -339
- package/src/Hint.res +41 -5
- package/src/Hint.res.mjs +43 -5
- package/src/Outcome.res +90 -12
- package/src/Outcome.res.mjs +47 -0
- package/src/Projection_GWT.res +56 -5
- package/src/Projection_GWT.res.mjs +33 -7
- package/src/Query_GWT.res +39 -0
- package/src/Query_GWT.res.mjs +22 -14
- package/tests/BoundaryGwtTest.res +73 -0
- package/tests/BoundaryGwtTest.res.mjs +128 -0
- package/tests/FlowAggregateGwtTest.res +3 -3
- package/tests/FlowAggregateGwtTest.res.mjs +17 -17
- package/tests/FlowCrossPluginGwtTest.res +14 -12
- package/tests/FlowCrossPluginGwtTest.res.mjs +26 -28
- package/tests/FlowGwtTest.res +562 -34
- package/tests/FlowGwtTest.res.mjs +794 -69
- package/tests/HintTest.res.mjs +2 -1
- package/tests/QueryGwtTest.res +48 -0
- package/tests/QueryGwtTest.res.mjs +75 -0
- package/tests/StateViewSliceGwtTest.res.mjs +14 -1
package/src/Query_GWT.res.mjs
CHANGED
|
@@ -3,18 +3,24 @@
|
|
|
3
3
|
import * as Stdlib_JSON from "@rescript/runtime/lib/es6/Stdlib_JSON.js";
|
|
4
4
|
import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
|
|
5
5
|
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
6
|
+
import * as Owner$Reventless from "@reventlessdev/reventless-spec/src/components/Owner.res.mjs";
|
|
6
7
|
import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js";
|
|
7
8
|
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
|
|
8
9
|
import * as Util_Sury$Reventless from "@reventlessdev/reventless-spec/src/util/Util_Sury.res.mjs";
|
|
9
10
|
import * as Outcome$ReventlessGwt from "./Outcome.res.mjs";
|
|
11
|
+
import * as OwnerScope$Reventless from "@reventlessdev/reventless-spec/src/types/OwnerScope.res.mjs";
|
|
10
12
|
import * as JestBind$ReventlessGwt from "./JestBind.res.mjs";
|
|
13
|
+
import * as Authorization$Reventless from "@reventlessdev/reventless-spec/src/types/Authorization.res.mjs";
|
|
14
|
+
import * as Decision_GWT$ReventlessGwt from "./Decision_GWT.res.mjs";
|
|
15
|
+
import * as StateAnnotations$Reventless from "@reventlessdev/reventless-spec/src/components/StateAnnotations.res.mjs";
|
|
11
16
|
|
|
12
17
|
function FromReadModel(Spec) {
|
|
13
18
|
return {
|
|
14
19
|
name: Spec.name,
|
|
15
20
|
stateSchema: Spec.stateSchema,
|
|
16
21
|
config: Spec.config,
|
|
17
|
-
subIdConfig: Spec.subIdConfig
|
|
22
|
+
subIdConfig: Spec.subIdConfig,
|
|
23
|
+
authorization: Spec.authorization
|
|
18
24
|
};
|
|
19
25
|
}
|
|
20
26
|
|
|
@@ -23,7 +29,8 @@ function FromStateViewSlice(Spec) {
|
|
|
23
29
|
name: Spec.name,
|
|
24
30
|
stateSchema: Spec.stateSchema,
|
|
25
31
|
config: Spec.config,
|
|
26
|
-
subIdConfig: Spec.subIdConfig
|
|
32
|
+
subIdConfig: Spec.subIdConfig,
|
|
33
|
+
authorization: Spec.authorization
|
|
27
34
|
};
|
|
28
35
|
}
|
|
29
36
|
|
|
@@ -40,6 +47,13 @@ function Make(Spec) {
|
|
|
40
47
|
subId: param[1],
|
|
41
48
|
state: param[2]
|
|
42
49
|
}));
|
|
50
|
+
let Caller = Decision_GWT$ReventlessGwt.Callers({});
|
|
51
|
+
let ownerField = Owner$Reventless.fieldNames(Spec.stateSchema)[0];
|
|
52
|
+
let retired = Stdlib_Option.flatMap(StateAnnotations$Reventless.getSpec(Spec.stateSchema), spec => spec.retired);
|
|
53
|
+
let asCaller = (s, who) => {
|
|
54
|
+
let identity = Decision_GWT$ReventlessGwt.Caller.identity(who);
|
|
55
|
+
return s.filter(r => OwnerScope$Reventless.mayReadRow(identity, Util_Sury$Reventless.toJson(r.state, Spec.stateSchema), Authorization$Reventless.named(Spec.authorization), ownerField, Stdlib_Option.map(retired, r => r.field), Stdlib_Option.flatMap(retired, r => r.values), undefined, [Decision_GWT$ReventlessGwt.Caller.operatorGroup]));
|
|
56
|
+
};
|
|
43
57
|
let whenQueryById = (s, id) => Stdlib_Array.findMap(s, r => {
|
|
44
58
|
if (r.id === id) {
|
|
45
59
|
return Primitive_option.some(r.state);
|
|
@@ -189,7 +203,9 @@ function Make(Spec) {
|
|
|
189
203
|
thenRow: thenRow,
|
|
190
204
|
thenRows: thenRows,
|
|
191
205
|
thenRowCount: thenRowCount,
|
|
192
|
-
thenRowFromComposite: thenRowFromComposite
|
|
206
|
+
thenRowFromComposite: thenRowFromComposite,
|
|
207
|
+
Caller: Caller,
|
|
208
|
+
asCaller: asCaller
|
|
193
209
|
};
|
|
194
210
|
}
|
|
195
211
|
|
|
@@ -231,11 +247,7 @@ function MakeResolver(Primary) {
|
|
|
231
247
|
if (match === undefined) {
|
|
232
248
|
return {
|
|
233
249
|
TAG: "Error",
|
|
234
|
-
_0:
|
|
235
|
-
TAG: "QueryRowsMismatch",
|
|
236
|
-
expected: [`@resolves on field "` + field + `" is missing from ` + Primary.name + `.config.idResolvers`],
|
|
237
|
-
actual: []
|
|
238
|
-
}
|
|
250
|
+
_0: missing(`@resolves on field "` + field + `" is missing from ` + Primary.name + `.config.idResolvers`)
|
|
239
251
|
};
|
|
240
252
|
}
|
|
241
253
|
let pstate = Stdlib_Array.findMap(scenario.primary, param => {
|
|
@@ -267,11 +279,7 @@ function MakeResolver(Primary) {
|
|
|
267
279
|
if (match === undefined) {
|
|
268
280
|
return {
|
|
269
281
|
TAG: "Error",
|
|
270
|
-
_0:
|
|
271
|
-
TAG: "QueryRowsMismatch",
|
|
272
|
-
expected: [`@resolvesMany on field "` + field + `" is missing from ` + Primary.name + `.config.idsResolvers`],
|
|
273
|
-
actual: []
|
|
274
|
-
}
|
|
282
|
+
_0: missing(`@resolvesMany on field "` + field + `" is missing from ` + Primary.name + `.config.idsResolvers`)
|
|
275
283
|
};
|
|
276
284
|
}
|
|
277
285
|
let pstate = Stdlib_Array.findMap(scenario.primary, param => {
|
|
@@ -362,4 +370,4 @@ export {
|
|
|
362
370
|
Make,
|
|
363
371
|
MakeResolver,
|
|
364
372
|
}
|
|
365
|
-
/*
|
|
373
|
+
/* Owner-Reventless Not a pure module */
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// The boundary test `generate-plugin` writes for every system. A boundary with a
|
|
2
|
+
// slice that cannot derive its partition fails it, with the reasons, though every
|
|
3
|
+
// slice in it still passes its own test.
|
|
4
|
+
|
|
5
|
+
open JestGlobals
|
|
6
|
+
|
|
7
|
+
@schema
|
|
8
|
+
type addCategoryCommand = AddCategory({categoryId: string})
|
|
9
|
+
@schema
|
|
10
|
+
type addCategoryConsumed = CategoryAdded({categoryId: string})
|
|
11
|
+
@schema
|
|
12
|
+
type categoryAddedEvent = CategoryAdded({categoryId: string})
|
|
13
|
+
|
|
14
|
+
@schema
|
|
15
|
+
type addProductCommand = AddProduct({productId: string, categoryId: string})
|
|
16
|
+
@schema
|
|
17
|
+
type addProductConsumed =
|
|
18
|
+
| ProductAdded({productId: string})
|
|
19
|
+
| CategoryAdded({categoryId: string})
|
|
20
|
+
| CategoryArchived({categoryId: string})
|
|
21
|
+
@schema
|
|
22
|
+
type productAddedEvent = ProductAdded({productId: string, categoryId: string})
|
|
23
|
+
|
|
24
|
+
let catalog: array<Reventless.DcbTag.sliceSchemas> = [
|
|
25
|
+
{
|
|
26
|
+
name: "AddCategory",
|
|
27
|
+
commandSchema: addCategoryCommandSchema->S.castToUnknown,
|
|
28
|
+
consumedEventSchema: addCategoryConsumedSchema->S.castToUnknown,
|
|
29
|
+
eventSchema: categoryAddedEventSchema->S.castToUnknown,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "AddProduct",
|
|
33
|
+
commandSchema: addProductCommandSchema->S.castToUnknown,
|
|
34
|
+
consumedEventSchema: addProductConsumedSchema->S.castToUnknown,
|
|
35
|
+
eventSchema: productAddedEventSchema->S.castToUnknown,
|
|
36
|
+
},
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
// Writes two ids and reads both off an event nothing in the boundary writes, which
|
|
40
|
+
// leaves it no partition.
|
|
41
|
+
@schema
|
|
42
|
+
type imagesCommand = AttachProductImage({productId: string, uploadId: string})
|
|
43
|
+
@schema
|
|
44
|
+
type imagesConsumed =
|
|
45
|
+
| ImageUploaded({productId: string, uploadId: string})
|
|
46
|
+
| ProductImageAttached({uploadId: string})
|
|
47
|
+
@schema
|
|
48
|
+
type imagesEvent = ProductImageAttached({productId: string, uploadId: string})
|
|
49
|
+
|
|
50
|
+
let withUnresolvableSlice = catalog->Array.concat([
|
|
51
|
+
{
|
|
52
|
+
Reventless.DcbTag.name: "ProductImages",
|
|
53
|
+
commandSchema: imagesCommandSchema->S.castToUnknown,
|
|
54
|
+
consumedEventSchema: imagesConsumedSchema->S.castToUnknown,
|
|
55
|
+
eventSchema: imagesEventSchema->S.castToUnknown,
|
|
56
|
+
},
|
|
57
|
+
])
|
|
58
|
+
|
|
59
|
+
describe("a system's boundary test", () => {
|
|
60
|
+
testSync("a boundary whose slices all derive their partition passes", () =>
|
|
61
|
+
expect(Boundary_GWT.resolves(~name="Catalog", catalog))->toEqual(Outcome.pass)
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
testSync("one slice with no partition fails the boundary, naming it", () =>
|
|
65
|
+
switch Boundary_GWT.resolves(~name="Catalog", withUnresolvableSlice) {
|
|
66
|
+
| Error(PartitionUnresolved({boundary, reasons})) => {
|
|
67
|
+
expect(boundary)->toBe("Catalog")
|
|
68
|
+
expect(reasons->Array.some(r => r->String.includes("ProductImages")))->toBe(true)
|
|
69
|
+
}
|
|
70
|
+
| other => expect(other)->toEqual(Outcome.pass)
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
})
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Sury from "sury";
|
|
4
|
+
import * as Outcome$ReventlessGwt from "../src/Outcome.res.mjs";
|
|
5
|
+
import * as Boundary_GWT$ReventlessGwt from "../src/Boundary_GWT.res.mjs";
|
|
6
|
+
|
|
7
|
+
let addCategoryCommandSchema = Sury.$schema(s => ({
|
|
8
|
+
TAG: "AddCategory",
|
|
9
|
+
categoryId: s.m(Sury.string)
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
let addCategoryConsumedSchema = Sury.$schema(s => ({
|
|
13
|
+
TAG: "CategoryAdded",
|
|
14
|
+
categoryId: s.m(Sury.string)
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
let categoryAddedEventSchema = Sury.$schema(s => ({
|
|
18
|
+
TAG: "CategoryAdded",
|
|
19
|
+
categoryId: s.m(Sury.string)
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
let addProductCommandSchema = Sury.$schema(s => ({
|
|
23
|
+
TAG: "AddProduct",
|
|
24
|
+
productId: s.m(Sury.string),
|
|
25
|
+
categoryId: s.m(Sury.string)
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
let addProductConsumedSchema = Sury.union([
|
|
29
|
+
Sury.$schema(s => ({
|
|
30
|
+
TAG: "ProductAdded",
|
|
31
|
+
productId: s.m(Sury.string)
|
|
32
|
+
})),
|
|
33
|
+
Sury.$schema(s => ({
|
|
34
|
+
TAG: "CategoryAdded",
|
|
35
|
+
categoryId: s.m(Sury.string)
|
|
36
|
+
})),
|
|
37
|
+
Sury.$schema(s => ({
|
|
38
|
+
TAG: "CategoryArchived",
|
|
39
|
+
categoryId: s.m(Sury.string)
|
|
40
|
+
}))
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
let productAddedEventSchema = Sury.$schema(s => ({
|
|
44
|
+
TAG: "ProductAdded",
|
|
45
|
+
productId: s.m(Sury.string),
|
|
46
|
+
categoryId: s.m(Sury.string)
|
|
47
|
+
}));
|
|
48
|
+
|
|
49
|
+
let catalog = [
|
|
50
|
+
{
|
|
51
|
+
name: "AddCategory",
|
|
52
|
+
commandSchema: addCategoryCommandSchema,
|
|
53
|
+
consumedEventSchema: addCategoryConsumedSchema,
|
|
54
|
+
eventSchema: categoryAddedEventSchema
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "AddProduct",
|
|
58
|
+
commandSchema: addProductCommandSchema,
|
|
59
|
+
consumedEventSchema: addProductConsumedSchema,
|
|
60
|
+
eventSchema: productAddedEventSchema
|
|
61
|
+
}
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
let imagesCommandSchema = Sury.$schema(s => ({
|
|
65
|
+
TAG: "AttachProductImage",
|
|
66
|
+
productId: s.m(Sury.string),
|
|
67
|
+
uploadId: s.m(Sury.string)
|
|
68
|
+
}));
|
|
69
|
+
|
|
70
|
+
let imagesConsumedSchema = Sury.union([
|
|
71
|
+
Sury.$schema(s => ({
|
|
72
|
+
TAG: "ImageUploaded",
|
|
73
|
+
productId: s.m(Sury.string),
|
|
74
|
+
uploadId: s.m(Sury.string)
|
|
75
|
+
})),
|
|
76
|
+
Sury.$schema(s => ({
|
|
77
|
+
TAG: "ProductImageAttached",
|
|
78
|
+
uploadId: s.m(Sury.string)
|
|
79
|
+
}))
|
|
80
|
+
]);
|
|
81
|
+
|
|
82
|
+
let imagesEventSchema = Sury.$schema(s => ({
|
|
83
|
+
TAG: "ProductImageAttached",
|
|
84
|
+
productId: s.m(Sury.string),
|
|
85
|
+
uploadId: s.m(Sury.string)
|
|
86
|
+
}));
|
|
87
|
+
|
|
88
|
+
let withUnresolvableSlice = catalog.concat([{
|
|
89
|
+
name: "ProductImages",
|
|
90
|
+
commandSchema: imagesCommandSchema,
|
|
91
|
+
consumedEventSchema: imagesConsumedSchema,
|
|
92
|
+
eventSchema: imagesEventSchema
|
|
93
|
+
}]);
|
|
94
|
+
|
|
95
|
+
globalThis.describe("a system's boundary test", () => {
|
|
96
|
+
globalThis.test("a boundary whose slices all derive their partition passes", () => {
|
|
97
|
+
globalThis.expect(Boundary_GWT$ReventlessGwt.resolves("Catalog", catalog)).toEqual(Outcome$ReventlessGwt.pass);
|
|
98
|
+
});
|
|
99
|
+
globalThis.test("one slice with no partition fails the boundary, naming it", () => {
|
|
100
|
+
let other = Boundary_GWT$ReventlessGwt.resolves("Catalog", withUnresolvableSlice);
|
|
101
|
+
if (other.TAG === "Ok") {
|
|
102
|
+
globalThis.expect(other).toEqual(Outcome$ReventlessGwt.pass);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
let match = other._0;
|
|
106
|
+
if (match.TAG === "PartitionUnresolved") {
|
|
107
|
+
globalThis.expect(match.boundary).toBe("Catalog");
|
|
108
|
+
globalThis.expect(match.reasons.some(r => r.includes("ProductImages"))).toBe(true);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
globalThis.expect(other).toEqual(Outcome$ReventlessGwt.pass);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
export {
|
|
116
|
+
addCategoryCommandSchema,
|
|
117
|
+
addCategoryConsumedSchema,
|
|
118
|
+
categoryAddedEventSchema,
|
|
119
|
+
addProductCommandSchema,
|
|
120
|
+
addProductConsumedSchema,
|
|
121
|
+
productAddedEventSchema,
|
|
122
|
+
catalog,
|
|
123
|
+
imagesCommandSchema,
|
|
124
|
+
imagesConsumedSchema,
|
|
125
|
+
imagesEventSchema,
|
|
126
|
+
withUnresolvableSlice,
|
|
127
|
+
}
|
|
128
|
+
/* addCategoryCommandSchema Not a pure module */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Worked example for Flow_GWT.
|
|
1
|
+
// Worked example for Flow_GWT.AggregateStep — two aggregate-style
|
|
2
2
|
// command steps threaded through one shared log. Verifies the framework's
|
|
3
3
|
// new aggregate-ID partitioning:
|
|
4
4
|
//
|
|
@@ -103,8 +103,8 @@ module OrderDecision = {
|
|
|
103
103
|
|
|
104
104
|
// -- Step modules -------------------------------------------------------------
|
|
105
105
|
|
|
106
|
-
module Sync =
|
|
107
|
-
module Place =
|
|
106
|
+
module Sync = AggregateStep(CatalogProductAggregate, CatalogProductDecision)
|
|
107
|
+
module Place = AggregateStep(OrderAggregate, OrderDecision)
|
|
108
108
|
|
|
109
109
|
// -- Flows --------------------------------------------------------------------
|
|
110
110
|
|
|
@@ -180,7 +180,7 @@ let OrderDecision = {
|
|
|
180
180
|
moduleUrl: moduleUrl$1
|
|
181
181
|
};
|
|
182
182
|
|
|
183
|
-
let Sync = Flow_GWT$ReventlessGwt.
|
|
183
|
+
let Sync = Flow_GWT$ReventlessGwt.AggregateStep(CatalogProductAggregate)({
|
|
184
184
|
Spec: CatalogProductAggregate,
|
|
185
185
|
initialState: "NotSynced",
|
|
186
186
|
evolve: evolve,
|
|
@@ -189,7 +189,7 @@ let Sync = Flow_GWT$ReventlessGwt.AggregateCommandStep(CatalogProductAggregate)(
|
|
|
189
189
|
moduleUrl: moduleUrl
|
|
190
190
|
});
|
|
191
191
|
|
|
192
|
-
let Place = Flow_GWT$ReventlessGwt.
|
|
192
|
+
let Place = Flow_GWT$ReventlessGwt.AggregateStep(OrderAggregate)({
|
|
193
193
|
Spec: OrderAggregate,
|
|
194
194
|
initialState: initialState,
|
|
195
195
|
evolve: evolve$1,
|
|
@@ -199,7 +199,7 @@ let Place = Flow_GWT$ReventlessGwt.AggregateCommandStep(OrderAggregate)({
|
|
|
199
199
|
});
|
|
200
200
|
|
|
201
201
|
Flow_GWT$ReventlessGwt.describe("Aggregate flow (single plugin)", () => {
|
|
202
|
-
Flow_GWT$ReventlessGwt.test("sync product → place order → ship order, threaded through aggregate-ID", undefined, () => Place.thenEvent(Place.whenCommand(Place.thenEvent(Place.whenCommand(Sync.thenEvent(Sync.whenCommand(Flow_GWT$ReventlessGwt.start, "p1", {
|
|
202
|
+
Flow_GWT$ReventlessGwt.test("sync product → place order → ship order, threaded through aggregate-ID", undefined, undefined, undefined, () => Place.thenEvent(Place.whenCommand(Place.thenEvent(Place.whenCommand(Sync.thenEvent(Sync.whenCommand(Flow_GWT$ReventlessGwt.start, "p1", undefined, {
|
|
203
203
|
TAG: "SyncNewProduct",
|
|
204
204
|
productId: "p1",
|
|
205
205
|
name: "Book"
|
|
@@ -207,7 +207,7 @@ Flow_GWT$ReventlessGwt.describe("Aggregate flow (single plugin)", () => {
|
|
|
207
207
|
TAG: "CatalogProductSynced",
|
|
208
208
|
productId: "p1",
|
|
209
209
|
name: "Book"
|
|
210
|
-
}), "o1", {
|
|
210
|
+
}), "o1", undefined, {
|
|
211
211
|
TAG: "Place",
|
|
212
212
|
customerId: "c1",
|
|
213
213
|
productIds: ["p1"]
|
|
@@ -215,17 +215,17 @@ Flow_GWT$ReventlessGwt.describe("Aggregate flow (single plugin)", () => {
|
|
|
215
215
|
TAG: "Placed",
|
|
216
216
|
customerId: "c1",
|
|
217
217
|
productIds: ["p1"]
|
|
218
|
-
}), "o1", "Ship"), "Shipped"));
|
|
219
|
-
Flow_GWT$ReventlessGwt.test("re-placing the same order is rejected (per-aggregate state replay)", undefined, () => Place.thenError(Place.whenCommand(Place.whenCommand(Flow_GWT$ReventlessGwt.start, "o1", {
|
|
218
|
+
}), "o1", undefined, "Ship"), "Shipped"));
|
|
219
|
+
Flow_GWT$ReventlessGwt.test("re-placing the same order is rejected (per-aggregate state replay)", undefined, undefined, undefined, () => Place.thenError(Place.whenCommand(Place.whenCommand(Flow_GWT$ReventlessGwt.start, "o1", undefined, {
|
|
220
220
|
TAG: "Place",
|
|
221
221
|
customerId: "c1",
|
|
222
222
|
productIds: ["p1"]
|
|
223
|
-
}), "o1", {
|
|
223
|
+
}), "o1", undefined, {
|
|
224
224
|
TAG: "Place",
|
|
225
225
|
customerId: "c1",
|
|
226
226
|
productIds: ["p1"]
|
|
227
227
|
}), "AlreadyPlaced"));
|
|
228
|
-
Flow_GWT$ReventlessGwt.test("a different order is not blocked by the first (~id isolation)", undefined, () => Place.thenEvent(Place.whenCommand(Place.thenEvent(Place.whenCommand(Flow_GWT$ReventlessGwt.start, "o1", {
|
|
228
|
+
Flow_GWT$ReventlessGwt.test("a different order is not blocked by the first (~id isolation)", undefined, undefined, undefined, () => Place.thenEvent(Place.whenCommand(Place.thenEvent(Place.whenCommand(Flow_GWT$ReventlessGwt.start, "o1", undefined, {
|
|
229
229
|
TAG: "Place",
|
|
230
230
|
customerId: "c1",
|
|
231
231
|
productIds: ["p1"]
|
|
@@ -233,7 +233,7 @@ Flow_GWT$ReventlessGwt.describe("Aggregate flow (single plugin)", () => {
|
|
|
233
233
|
TAG: "Placed",
|
|
234
234
|
customerId: "c1",
|
|
235
235
|
productIds: ["p1"]
|
|
236
|
-
}), "o2", {
|
|
236
|
+
}), "o2", undefined, {
|
|
237
237
|
TAG: "Place",
|
|
238
238
|
customerId: "c2",
|
|
239
239
|
productIds: ["p2"]
|
|
@@ -242,18 +242,18 @@ Flow_GWT$ReventlessGwt.describe("Aggregate flow (single plugin)", () => {
|
|
|
242
242
|
customerId: "c2",
|
|
243
243
|
productIds: ["p2"]
|
|
244
244
|
}));
|
|
245
|
-
Flow_GWT$ReventlessGwt.test("ship before place returns NotPlaced", undefined, () => Place.thenError(Place.whenCommand(Flow_GWT$ReventlessGwt.start, "o1", "Ship"), "NotPlaced"));
|
|
246
|
-
Flow_GWT$ReventlessGwt.test("givenEvents seeds history for an ~id starting mid-stream", undefined, () => Place.thenEvent(Place.whenCommand(Place.givenEvents(Flow_GWT$ReventlessGwt.start, "o1", [{
|
|
245
|
+
Flow_GWT$ReventlessGwt.test("ship before place returns NotPlaced", undefined, undefined, undefined, () => Place.thenError(Place.whenCommand(Flow_GWT$ReventlessGwt.start, "o1", undefined, "Ship"), "NotPlaced"));
|
|
246
|
+
Flow_GWT$ReventlessGwt.test("givenEvents seeds history for an ~id starting mid-stream", undefined, undefined, undefined, () => Place.thenEvent(Place.whenCommand(Place.givenEvents(Flow_GWT$ReventlessGwt.start, "o1", undefined, [{
|
|
247
247
|
TAG: "Placed",
|
|
248
248
|
customerId: "c1",
|
|
249
249
|
productIds: ["p1"]
|
|
250
|
-
}]), "o1", "Ship"), "Shipped"));
|
|
251
|
-
Flow_GWT$ReventlessGwt.test("ship after ship is idempotent (no events emitted)", undefined, () => Place.thenNoEvent(Place.whenCommand(Place.whenCommand(Place.whenCommand(Flow_GWT$ReventlessGwt.start, "o1", {
|
|
250
|
+
}]), "o1", undefined, "Ship"), "Shipped"));
|
|
251
|
+
Flow_GWT$ReventlessGwt.test("ship after ship is idempotent (no events emitted)", undefined, undefined, undefined, () => Place.thenNoEvent(Place.whenCommand(Place.whenCommand(Place.whenCommand(Flow_GWT$ReventlessGwt.start, "o1", undefined, {
|
|
252
252
|
TAG: "Place",
|
|
253
253
|
customerId: "c1",
|
|
254
254
|
productIds: ["p1"]
|
|
255
|
-
}), "o1", "Ship"), "o1", "Ship")));
|
|
256
|
-
Flow_GWT$ReventlessGwt.test("two independent aggregates evolve their own state in parallel", undefined, () => Sync.thenError(Sync.whenCommand(Sync.thenEvent(Sync.whenCommand(Sync.thenEvent(Sync.whenCommand(Flow_GWT$ReventlessGwt.start, "p1", {
|
|
255
|
+
}), "o1", undefined, "Ship"), "o1", undefined, "Ship")));
|
|
256
|
+
Flow_GWT$ReventlessGwt.test("two independent aggregates evolve their own state in parallel", undefined, undefined, undefined, () => Sync.thenError(Sync.whenCommand(Sync.thenEvent(Sync.whenCommand(Sync.thenEvent(Sync.whenCommand(Flow_GWT$ReventlessGwt.start, "p1", undefined, {
|
|
257
257
|
TAG: "SyncNewProduct",
|
|
258
258
|
productId: "p1",
|
|
259
259
|
name: "Book"
|
|
@@ -261,7 +261,7 @@ Flow_GWT$ReventlessGwt.describe("Aggregate flow (single plugin)", () => {
|
|
|
261
261
|
TAG: "CatalogProductSynced",
|
|
262
262
|
productId: "p1",
|
|
263
263
|
name: "Book"
|
|
264
|
-
}), "p2", {
|
|
264
|
+
}), "p2", undefined, {
|
|
265
265
|
TAG: "SyncNewProduct",
|
|
266
266
|
productId: "p2",
|
|
267
267
|
name: "Pen"
|
|
@@ -269,7 +269,7 @@ Flow_GWT$ReventlessGwt.describe("Aggregate flow (single plugin)", () => {
|
|
|
269
269
|
TAG: "CatalogProductSynced",
|
|
270
270
|
productId: "p2",
|
|
271
271
|
name: "Pen"
|
|
272
|
-
}), "p1", {
|
|
272
|
+
}), "p1", undefined, {
|
|
273
273
|
TAG: "SyncNewProduct",
|
|
274
274
|
productId: "p1",
|
|
275
275
|
name: "Book"
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
// Proves the property no single-component test can: a product added in Catalog
|
|
14
14
|
// becomes orderable in Ordering only via the cross-plugin sync, and a batch
|
|
15
15
|
// order fans out into one demand command per product across the boundary.
|
|
16
|
-
// See `docs/plans/done/gwt-flow-and-extension-test-kinds.md` Phase 3.
|
|
17
16
|
|
|
18
17
|
open Flow_GWT
|
|
19
18
|
|
|
@@ -308,14 +307,14 @@ module PlaceOrderDecision = {
|
|
|
308
307
|
// Step modules
|
|
309
308
|
// ===========================================================================
|
|
310
309
|
|
|
311
|
-
module AddProduct =
|
|
310
|
+
module AddProduct = DecisionStep(AddProductSlice, AddProductDecision)
|
|
312
311
|
module ProductsEp = ExtensionPointStep(ProductsEpMapping)
|
|
313
312
|
module ProductsExt = ExtensionStep(ProductsExtMapping)
|
|
314
|
-
module Sync =
|
|
315
|
-
module Place =
|
|
313
|
+
module Sync = DecisionStep(SyncProductSlice, SyncProductDecision)
|
|
314
|
+
module Place = DecisionStep(PlaceOrderSlice, PlaceOrderDecision)
|
|
316
315
|
module OrdersEp = ExtensionPointStep(OrdersEpMapping)
|
|
317
316
|
module OrdersExt = ExtensionStep(OrdersExtMapping)
|
|
318
|
-
module Demand =
|
|
317
|
+
module Demand = DecisionStep(RecordDemandSlice, RecordDemandDecision)
|
|
319
318
|
|
|
320
319
|
// ===========================================================================
|
|
321
320
|
// Flows
|
|
@@ -330,15 +329,15 @@ describe("Cross-plugin flow", () => {
|
|
|
330
329
|
->AddProduct.thenEvent(
|
|
331
330
|
AddProductSlice.ProductAdded({productId: "p1", name: "Book", price: 9.99}),
|
|
332
331
|
)
|
|
333
|
-
->ProductsEp.
|
|
332
|
+
->ProductsEp.whenPublished
|
|
334
333
|
->ProductsEp.thenPublicEvent(
|
|
335
334
|
ProductsEpSpec.ProductBecameAvailable({productId: "p1", name: "Book", price: 9.99}),
|
|
336
335
|
)
|
|
337
|
-
->ProductsExt.
|
|
336
|
+
->ProductsExt.whenReacts
|
|
338
337
|
->ProductsExt.thenIssuesCommand(
|
|
339
338
|
SyncProductSlice.SyncProduct({productId: "p1", name: "Book", price: 9.99}),
|
|
340
339
|
)
|
|
341
|
-
->Sync.
|
|
340
|
+
->Sync.whenIssued
|
|
342
341
|
->Sync.thenEvent(SyncProductSlice.ProductSynced({productId: "p1", name: "Book", price: 9.99}))
|
|
343
342
|
->Place.whenCommand(PlaceOrderSlice.PlaceOrder({orderId: "o1", productIds: ["p1"]}))
|
|
344
343
|
->Place.thenEvent(PlaceOrderSlice.OrderPlaced({orderId: "o1", productIds: ["p1"]}))
|
|
@@ -360,17 +359,20 @@ describe("Cross-plugin flow", () => {
|
|
|
360
359
|
])
|
|
361
360
|
->Place.whenCommand(PlaceOrderSlice.PlaceOrder({orderId: "o1", productIds: ["p1", "p2"]}))
|
|
362
361
|
->Place.thenEvent(PlaceOrderSlice.OrderPlaced({orderId: "o1", productIds: ["p1", "p2"]}))
|
|
363
|
-
->OrdersEp.
|
|
362
|
+
->OrdersEp.whenPublished
|
|
364
363
|
->OrdersEp.thenPublicEvents([
|
|
365
364
|
OrdersEpSpec.ItemOrdered({productId: "p1", orderId: "o1"}),
|
|
366
365
|
OrdersEpSpec.ItemOrdered({productId: "p2", orderId: "o1"}),
|
|
367
366
|
])
|
|
368
|
-
->OrdersExt.
|
|
367
|
+
->OrdersExt.whenReacts
|
|
369
368
|
->OrdersExt.thenIssuesCommands([
|
|
370
369
|
RecordDemandSlice.RecordDemand({productId: "p1", orderId: "o1"}),
|
|
371
370
|
RecordDemandSlice.RecordDemand({productId: "p2", orderId: "o1"}),
|
|
372
371
|
])
|
|
373
|
-
->Demand.
|
|
374
|
-
->Demand.
|
|
372
|
+
->Demand.whenIssued
|
|
373
|
+
->Demand.thenEvents([
|
|
374
|
+
RecordDemandSlice.DemandRecorded({productId: "p1", orderId: "o1"}),
|
|
375
|
+
RecordDemandSlice.DemandRecorded({productId: "p2", orderId: "o1"}),
|
|
376
|
+
]),
|
|
375
377
|
)
|
|
376
378
|
})
|
|
@@ -627,7 +627,7 @@ let PlaceOrderDecision = {
|
|
|
627
627
|
decide: decide$3
|
|
628
628
|
};
|
|
629
629
|
|
|
630
|
-
let AddProduct = Flow_GWT$ReventlessGwt.
|
|
630
|
+
let AddProduct = Flow_GWT$ReventlessGwt.DecisionStep(AddProductSlice)({
|
|
631
631
|
initialState: initialState,
|
|
632
632
|
evolve: evolve,
|
|
633
633
|
decide: decide
|
|
@@ -686,7 +686,7 @@ let ProductsExt = Flow_GWT$ReventlessGwt.ExtensionStep({
|
|
|
686
686
|
issuedCommands: issuedCommands$1
|
|
687
687
|
});
|
|
688
688
|
|
|
689
|
-
let Sync = Flow_GWT$ReventlessGwt.
|
|
689
|
+
let Sync = Flow_GWT$ReventlessGwt.DecisionStep({
|
|
690
690
|
name: name$3,
|
|
691
691
|
consumedEventSchema: consumedEventSchema$2,
|
|
692
692
|
commandSchema: commandSchema$6,
|
|
@@ -699,7 +699,7 @@ let Sync = Flow_GWT$ReventlessGwt.CommandStep({
|
|
|
699
699
|
decide: decide$2
|
|
700
700
|
});
|
|
701
701
|
|
|
702
|
-
let Place = Flow_GWT$ReventlessGwt.
|
|
702
|
+
let Place = Flow_GWT$ReventlessGwt.DecisionStep(PlaceOrderSlice)({
|
|
703
703
|
initialState: initialState$3,
|
|
704
704
|
evolve: evolve$3,
|
|
705
705
|
decide: decide$3
|
|
@@ -758,7 +758,7 @@ let OrdersExt = Flow_GWT$ReventlessGwt.ExtensionStep({
|
|
|
758
758
|
issuedCommands: issuedCommands
|
|
759
759
|
});
|
|
760
760
|
|
|
761
|
-
let Demand = Flow_GWT$ReventlessGwt.
|
|
761
|
+
let Demand = Flow_GWT$ReventlessGwt.DecisionStep({
|
|
762
762
|
name: name$2,
|
|
763
763
|
consumedEventSchema: consumedEventSchema$1,
|
|
764
764
|
commandSchema: commandSchema$5,
|
|
@@ -772,7 +772,7 @@ let Demand = Flow_GWT$ReventlessGwt.CommandStep({
|
|
|
772
772
|
});
|
|
773
773
|
|
|
774
774
|
Flow_GWT$ReventlessGwt.describe("Cross-plugin flow", () => {
|
|
775
|
-
Flow_GWT$ReventlessGwt.test("Tier 2 — a product added in Catalog becomes orderable in Ordering via sync", undefined, () => Place.thenEvent(Place.whenCommand(Sync.thenEvent(Sync.
|
|
775
|
+
Flow_GWT$ReventlessGwt.test("Tier 2 — a product added in Catalog becomes orderable in Ordering via sync", undefined, undefined, undefined, () => Place.thenEvent(Place.whenCommand(Sync.thenEvent(Sync.whenIssued(ProductsExt.thenIssuesCommand(ProductsExt.whenReacts(ProductsEp.thenPublicEvent(ProductsEp.whenPublished(AddProduct.thenEvent(AddProduct.whenCommand(Flow_GWT$ReventlessGwt.start, undefined, {
|
|
776
776
|
TAG: "AddProduct",
|
|
777
777
|
productId: "p1",
|
|
778
778
|
name: "Book",
|
|
@@ -782,27 +782,22 @@ Flow_GWT$ReventlessGwt.describe("Cross-plugin flow", () => {
|
|
|
782
782
|
productId: "p1",
|
|
783
783
|
name: "Book",
|
|
784
784
|
price: 9.99
|
|
785
|
-
})), {
|
|
785
|
+
}), undefined), {
|
|
786
786
|
TAG: "ProductBecameAvailable",
|
|
787
787
|
productId: "p1",
|
|
788
788
|
name: "Book",
|
|
789
789
|
price: 9.99
|
|
790
|
-
})), {
|
|
790
|
+
}), undefined), {
|
|
791
791
|
TAG: "SyncProduct",
|
|
792
792
|
productId: "p1",
|
|
793
793
|
name: "Book",
|
|
794
794
|
price: 9.99
|
|
795
|
-
}), {
|
|
796
|
-
TAG: "SyncProduct",
|
|
797
|
-
productId: "p1",
|
|
798
|
-
name: "Book",
|
|
799
|
-
price: 9.99
|
|
800
|
-
}), {
|
|
795
|
+
}), undefined, undefined), {
|
|
801
796
|
TAG: "ProductSynced",
|
|
802
797
|
productId: "p1",
|
|
803
798
|
name: "Book",
|
|
804
799
|
price: 9.99
|
|
805
|
-
}), {
|
|
800
|
+
}), undefined, {
|
|
806
801
|
TAG: "PlaceOrder",
|
|
807
802
|
orderId: "o1",
|
|
808
803
|
productIds: ["p1"]
|
|
@@ -811,7 +806,7 @@ Flow_GWT$ReventlessGwt.describe("Cross-plugin flow", () => {
|
|
|
811
806
|
orderId: "o1",
|
|
812
807
|
productIds: ["p1"]
|
|
813
808
|
}));
|
|
814
|
-
Flow_GWT$ReventlessGwt.test("Tier 2 — placing an order without the cross-plugin sync is rejected", undefined, () => Place.thenError(Place.whenCommand(Flow_GWT$ReventlessGwt.start, {
|
|
809
|
+
Flow_GWT$ReventlessGwt.test("Tier 2 — placing an order without the cross-plugin sync is rejected", undefined, undefined, undefined, () => Place.thenError(Place.whenCommand(Flow_GWT$ReventlessGwt.start, undefined, {
|
|
815
810
|
TAG: "PlaceOrder",
|
|
816
811
|
orderId: "o1",
|
|
817
812
|
productIds: ["p1"]
|
|
@@ -819,7 +814,7 @@ Flow_GWT$ReventlessGwt.describe("Cross-plugin flow", () => {
|
|
|
819
814
|
TAG: "ProductsNotAvailable",
|
|
820
815
|
missing: ["p1"]
|
|
821
816
|
}));
|
|
822
|
-
Flow_GWT$ReventlessGwt.test("Tier 3 — a batch order fans out to one demand command per product across the boundary", undefined, () => Demand.
|
|
817
|
+
Flow_GWT$ReventlessGwt.test("Tier 3 — a batch order fans out to one demand command per product across the boundary", undefined, undefined, undefined, () => Demand.thenEvents(Demand.whenIssued(OrdersExt.thenIssuesCommands(OrdersExt.whenReacts(OrdersEp.thenPublicEvents(OrdersEp.whenPublished(Place.thenEvent(Place.whenCommand(Sync.givenEvents(Flow_GWT$ReventlessGwt.start, undefined, [
|
|
823
818
|
{
|
|
824
819
|
TAG: "ProductSynced",
|
|
825
820
|
productId: "p1",
|
|
@@ -832,7 +827,7 @@ Flow_GWT$ReventlessGwt.describe("Cross-plugin flow", () => {
|
|
|
832
827
|
name: "Pen",
|
|
833
828
|
price: 1.5
|
|
834
829
|
}
|
|
835
|
-
]), {
|
|
830
|
+
]), undefined, {
|
|
836
831
|
TAG: "PlaceOrder",
|
|
837
832
|
orderId: "o1",
|
|
838
833
|
productIds: [
|
|
@@ -846,7 +841,7 @@ Flow_GWT$ReventlessGwt.describe("Cross-plugin flow", () => {
|
|
|
846
841
|
"p1",
|
|
847
842
|
"p2"
|
|
848
843
|
]
|
|
849
|
-
})), [
|
|
844
|
+
}), undefined), [
|
|
850
845
|
{
|
|
851
846
|
TAG: "ItemOrdered",
|
|
852
847
|
productId: "p1",
|
|
@@ -857,7 +852,7 @@ Flow_GWT$ReventlessGwt.describe("Cross-plugin flow", () => {
|
|
|
857
852
|
productId: "p2",
|
|
858
853
|
orderId: "o1"
|
|
859
854
|
}
|
|
860
|
-
])), [
|
|
855
|
+
]), undefined), [
|
|
861
856
|
{
|
|
862
857
|
TAG: "RecordDemand",
|
|
863
858
|
productId: "p1",
|
|
@@ -868,15 +863,18 @@ Flow_GWT$ReventlessGwt.describe("Cross-plugin flow", () => {
|
|
|
868
863
|
productId: "p2",
|
|
869
864
|
orderId: "o1"
|
|
870
865
|
}
|
|
871
|
-
]),
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
866
|
+
]), undefined, undefined), [
|
|
867
|
+
{
|
|
868
|
+
TAG: "DemandRecorded",
|
|
869
|
+
productId: "p1",
|
|
870
|
+
orderId: "o1"
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
TAG: "DemandRecorded",
|
|
874
|
+
productId: "p2",
|
|
875
|
+
orderId: "o1"
|
|
876
|
+
}
|
|
877
|
+
]));
|
|
880
878
|
});
|
|
881
879
|
|
|
882
880
|
let EPM;
|