@reventlessdev/reventless-gwt 1.0.0-alpha.74
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 +698 -0
- package/LICENSE +202 -0
- package/bin/reventless-dev.mjs +21 -0
- package/package.json +54 -0
- package/rescript.json +36 -0
- package/src/.gwtignore +10 -0
- package/src/Automation_GWT.res +207 -0
- package/src/Automation_GWT.res.mjs +160 -0
- package/src/Behavior_GWT.res +603 -0
- package/src/Behavior_GWT.res.mjs +426 -0
- package/src/Bind.res +29 -0
- package/src/Bind.res.mjs +22 -0
- package/src/BuildClassifier.res +137 -0
- package/src/BuildClassifier.res.mjs +136 -0
- package/src/Cancellation.res +31 -0
- package/src/Cancellation.res.mjs +45 -0
- package/src/ChildProcess.res +84 -0
- package/src/ChildProcess.res.mjs +92 -0
- package/src/Cli.res +671 -0
- package/src/Cli.res.mjs +754 -0
- package/src/Collector.res +201 -0
- package/src/Collector.res.mjs +215 -0
- package/src/ComponentMeta.res +104 -0
- package/src/ComponentMeta.res.mjs +120 -0
- package/src/ComponentScan.res +103 -0
- package/src/ComponentScan.res.mjs +105 -0
- package/src/Delegate_GWT.res +303 -0
- package/src/Delegate_GWT.res.mjs +372 -0
- package/src/Diff.res +91 -0
- package/src/Diff.res.mjs +98 -0
- package/src/Discovery.res +105 -0
- package/src/Discovery.res.mjs +103 -0
- package/src/DomainDeadCode.res +93 -0
- package/src/DomainDeadCode.res.mjs +69 -0
- package/src/DomainGraph.res +0 -0
- package/src/DomainGraph.res.mjs +0 -0
- package/src/EventMapping_GWT.res +29 -0
- package/src/EventMapping_GWT.res.mjs +44 -0
- package/src/Filter.res +36 -0
- package/src/Filter.res.mjs +40 -0
- package/src/Flow_GWT.res +664 -0
- package/src/Flow_GWT.res.mjs +604 -0
- package/src/FormatterHuman.res +138 -0
- package/src/FormatterHuman.res.mjs +122 -0
- package/src/FormatterJson.res +257 -0
- package/src/FormatterJson.res.mjs +320 -0
- package/src/FormatterJunit.res +93 -0
- package/src/FormatterJunit.res.mjs +90 -0
- package/src/FormatterTap.res +139 -0
- package/src/FormatterTap.res.mjs +149 -0
- package/src/FormatterVsCode.res +362 -0
- package/src/FormatterVsCode.res.mjs +564 -0
- package/src/Hint.res +119 -0
- package/src/Hint.res.mjs +124 -0
- package/src/InboundTranslation_GWT.res +83 -0
- package/src/InboundTranslation_GWT.res.mjs +94 -0
- package/src/JestBind.res +70 -0
- package/src/JestBind.res.mjs +63 -0
- package/src/Loader.res +24 -0
- package/src/Loader.res.mjs +23 -0
- package/src/LocalHost.res +135 -0
- package/src/LocalHost.res.mjs +127 -0
- package/src/Mapping_GWT.res +474 -0
- package/src/Mapping_GWT.res.mjs +322 -0
- package/src/MultiSourceProjection_GWT.res +316 -0
- package/src/MultiSourceProjection_GWT.res.mjs +354 -0
- package/src/OutboundTranslation_GWT.res +238 -0
- package/src/OutboundTranslation_GWT.res.mjs +186 -0
- package/src/Outcome.res +161 -0
- package/src/Outcome.res.mjs +140 -0
- package/src/PackageScan.res +80 -0
- package/src/PackageScan.res.mjs +81 -0
- package/src/PlatformRunner.res +160 -0
- package/src/PlatformRunner.res.mjs +155 -0
- package/src/PlatformScan.res +138 -0
- package/src/PlatformScan.res.mjs +131 -0
- package/src/ProcessManager.res +91 -0
- package/src/ProcessManager.res.mjs +80 -0
- package/src/Projection_GWT.res +312 -0
- package/src/Projection_GWT.res.mjs +332 -0
- package/src/Query_GWT.res +379 -0
- package/src/Query_GWT.res.mjs +367 -0
- package/src/RenderRescript.res +125 -0
- package/src/RenderRescript.res.mjs +141 -0
- package/src/RunnerTypes.res +68 -0
- package/src/RunnerTypes.res.mjs +60 -0
- package/src/SideEffect_GWT.res +157 -0
- package/src/SideEffect_GWT.res.mjs +113 -0
- package/src/StateChange/ExternalAddCategorySlice.res +25 -0
- package/src/StateChange/ExternalAddCategorySlice.res.mjs +34 -0
- package/src/StateChange/ExternalAddCategorySlice_Behavior.res +19 -0
- package/src/StateChange/ExternalAddCategorySlice_Behavior.res.mjs +46 -0
- package/src/StateChange/WithFixtures.res +22 -0
- package/src/StateChange/WithFixtures.res.mjs +31 -0
- package/src/StateChange/WithFixtures_Behavior.res +17 -0
- package/src/StateChange/WithFixtures_Behavior.res.mjs +37 -0
- package/src/StateChange/WithManualOpen.res +23 -0
- package/src/StateChange/WithManualOpen.res.mjs +31 -0
- package/src/StateChange/WithManualOpen_Behavior.res +17 -0
- package/src/StateChange/WithManualOpen_Behavior.res.mjs +37 -0
- package/src/StubRuntime.res +53 -0
- package/src/StubRuntime.res.mjs +54 -0
- package/src/TestFixtures.res +16 -0
- package/src/TestFixtures.res.mjs +34 -0
- package/src/Watch.res +92 -0
- package/src/Watch.res.mjs +83 -0
- package/src/WatcherProbe.res +48 -0
- package/src/WatcherProbe.res.mjs +46 -0
- package/tests/AutomationGwtTest.res +71 -0
- package/tests/AutomationGwtTest.res.mjs +189 -0
- package/tests/BuildClassifierTest.res +94 -0
- package/tests/BuildClassifierTest.res.mjs +132 -0
- package/tests/ComponentMetaTest.res +52 -0
- package/tests/ComponentMetaTest.res.mjs +57 -0
- package/tests/DelegateGwtTest.res +487 -0
- package/tests/DelegateGwtTest.res.mjs +891 -0
- package/tests/DiscoveryTest.res +42 -0
- package/tests/DiscoveryTest.res.mjs +43 -0
- package/tests/DomainDeadCodeTest.res +116 -0
- package/tests/DomainDeadCodeTest.res.mjs +155 -0
- package/tests/DomainGraphTest.res +365 -0
- package/tests/DomainGraphTest.res.mjs +413 -0
- package/tests/FlowAggregateGwtTest.res +169 -0
- package/tests/FlowAggregateGwtTest.res.mjs +269 -0
- package/tests/FlowCrossPluginGwtTest.res +340 -0
- package/tests/FlowCrossPluginGwtTest.res.mjs +798 -0
- package/tests/FlowGwtTest.res +222 -0
- package/tests/FlowGwtTest.res.mjs +432 -0
- package/tests/FormatterVsCodeMessageTest.res +41 -0
- package/tests/FormatterVsCodeMessageTest.res.mjs +42 -0
- package/tests/InboundTranslationGwtTest.res +34 -0
- package/tests/InboundTranslationGwtTest.res.mjs +98 -0
- package/tests/LocalHostIntegration.res +70 -0
- package/tests/LocalHostIntegration.res.mjs +64 -0
- package/tests/LocalHostTest.res +71 -0
- package/tests/LocalHostTest.res.mjs +63 -0
- package/tests/MappingGwtTest.res +348 -0
- package/tests/MappingGwtTest.res.mjs +592 -0
- package/tests/OutboundTranslationGwtTest.res +59 -0
- package/tests/OutboundTranslationGwtTest.res.mjs +138 -0
- package/tests/PlatformRunnerTest.res +66 -0
- package/tests/PlatformRunnerTest.res.mjs +85 -0
- package/tests/PlatformScanTest.res +61 -0
- package/tests/PlatformScanTest.res.mjs +56 -0
- package/tests/QueryGwtTest.res +161 -0
- package/tests/QueryGwtTest.res.mjs +314 -0
- package/tests/QueryResolverGwtTest.res +71 -0
- package/tests/QueryResolverGwtTest.res.mjs +136 -0
- package/tests/RunnerUnitTest.res +219 -0
- package/tests/RunnerUnitTest.res.mjs +244 -0
- package/tests/SideEffect/FakeOrderNotification.res +23 -0
- package/tests/SideEffect/FakeOrderNotification.res.mjs +36 -0
- package/tests/SideEffect/FakeOrderNotificationGwtTest.res +35 -0
- package/tests/SideEffect/FakeOrderNotificationGwtTest.res.mjs +73 -0
- package/tests/SideEffect/MockEmail.res +18 -0
- package/tests/SideEffect/MockEmail.res.mjs +47 -0
- package/tests/StateChange/ExternalAddCategorySlice_GWT.res +27 -0
- package/tests/StateChange/ExternalAddCategorySlice_GWT.res.mjs +70 -0
- package/tests/StateChange/WithFixtures_Fixtures.res +9 -0
- package/tests/StateChange/WithFixtures_Fixtures.res.mjs +20 -0
- package/tests/StateChange/WithFixtures_GWT.res +23 -0
- package/tests/StateChange/WithFixtures_GWT.res.mjs +56 -0
- package/tests/StateChange/WithManualOpen_Fixtures.res +7 -0
- package/tests/StateChange/WithManualOpen_Fixtures.res.mjs +20 -0
- package/tests/StateChange/WithManualOpen_GWT.res +17 -0
- package/tests/StateChange/WithManualOpen_GWT.res.mjs +56 -0
- package/tests/StateChangeSliceGwtTest.res +160 -0
- package/tests/StateChangeSliceGwtTest.res.mjs +280 -0
- package/tests/StateViewSliceGwtTest.res +64 -0
- package/tests/StateViewSliceGwtTest.res.mjs +161 -0
- package/tests/WatchDebounceTest.res +78 -0
- package/tests/WatchDebounceTest.res.mjs +97 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as S from "sury/src/S.res.mjs";
|
|
4
|
+
import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
|
|
5
|
+
import * as Id$Reventless from "@reventlessdev/reventless-spec/src/types/Id.res.mjs";
|
|
6
|
+
import * as ReadModel$Reventless from "@reventlessdev/reventless-spec/src/components/ReadModel.res.mjs";
|
|
7
|
+
import * as Outcome$ReventlessGwt from "../src/Outcome.res.mjs";
|
|
8
|
+
import * as Query_GWT$ReventlessGwt from "../src/Query_GWT.res.mjs";
|
|
9
|
+
|
|
10
|
+
S.enableJson();
|
|
11
|
+
|
|
12
|
+
let name = "Categories";
|
|
13
|
+
|
|
14
|
+
let moduleUrl = "";
|
|
15
|
+
|
|
16
|
+
let stateSchema = S.schema(s => ({
|
|
17
|
+
categoryId: s.m(S.string),
|
|
18
|
+
name: s.m(S.string),
|
|
19
|
+
archived: s.m(S.bool)
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
let config = ReadModel$Reventless.config(undefined, undefined, [{
|
|
23
|
+
index: "byName",
|
|
24
|
+
type_: "S",
|
|
25
|
+
idField: "name",
|
|
26
|
+
projectionType: "ALL"
|
|
27
|
+
}]);
|
|
28
|
+
|
|
29
|
+
let CategoriesReadModel = {
|
|
30
|
+
Id: undefined,
|
|
31
|
+
name: name,
|
|
32
|
+
moduleUrl: moduleUrl,
|
|
33
|
+
stateSchema: stateSchema,
|
|
34
|
+
config: config,
|
|
35
|
+
subIdConfig: undefined,
|
|
36
|
+
authorization: "AllowAuthenticated",
|
|
37
|
+
visibility: "Public"
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
let CategoriesQuery = Query_GWT$ReventlessGwt.Make(Query_GWT$ReventlessGwt.FromReadModel({
|
|
41
|
+
Id: {
|
|
42
|
+
schema: Id$Reventless.StringPure.schema,
|
|
43
|
+
make: prim => prim,
|
|
44
|
+
makeFromString: prim => prim,
|
|
45
|
+
toString: prim => prim,
|
|
46
|
+
cmp: Id$Reventless.StringPure.cmp
|
|
47
|
+
},
|
|
48
|
+
name: name,
|
|
49
|
+
moduleUrl: moduleUrl,
|
|
50
|
+
stateSchema: stateSchema,
|
|
51
|
+
config: config,
|
|
52
|
+
subIdConfig: undefined,
|
|
53
|
+
authorization: "AllowAuthenticated",
|
|
54
|
+
visibility: "Public"
|
|
55
|
+
}));
|
|
56
|
+
|
|
57
|
+
CategoriesQuery.describe("Categories ReadModel queries", () => {
|
|
58
|
+
CategoriesQuery.test("primary-id lookup returns the row", () => CategoriesQuery.thenRow(CategoriesQuery.whenQueryById(CategoriesQuery.givenStore([
|
|
59
|
+
[
|
|
60
|
+
"c1",
|
|
61
|
+
{
|
|
62
|
+
categoryId: "c1",
|
|
63
|
+
name: "Electronics",
|
|
64
|
+
archived: false
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
"c2",
|
|
69
|
+
{
|
|
70
|
+
categoryId: "c2",
|
|
71
|
+
name: "Books",
|
|
72
|
+
archived: true
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
]), "c1"), {
|
|
76
|
+
categoryId: "c1",
|
|
77
|
+
name: "Electronics",
|
|
78
|
+
archived: false
|
|
79
|
+
}));
|
|
80
|
+
CategoriesQuery.test("by-name (GSI) returns matching rows", () => CategoriesQuery.thenRows(CategoriesQuery.whenQuery(CategoriesQuery.givenStore([
|
|
81
|
+
[
|
|
82
|
+
"c1",
|
|
83
|
+
{
|
|
84
|
+
categoryId: "c1",
|
|
85
|
+
name: "Electronics",
|
|
86
|
+
archived: false
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
[
|
|
90
|
+
"c2",
|
|
91
|
+
{
|
|
92
|
+
categoryId: "c2",
|
|
93
|
+
name: "Books",
|
|
94
|
+
archived: true
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
]), {
|
|
98
|
+
by: "name",
|
|
99
|
+
value: "Electronics",
|
|
100
|
+
index: "byName"
|
|
101
|
+
}), [{
|
|
102
|
+
categoryId: "c1",
|
|
103
|
+
name: "Electronics",
|
|
104
|
+
archived: false
|
|
105
|
+
}]));
|
|
106
|
+
CategoriesQuery.test("missing index produces QueryRowsMismatch", () => {
|
|
107
|
+
let outcome = CategoriesQuery.thenRows(CategoriesQuery.whenQuery(CategoriesQuery.givenStore([[
|
|
108
|
+
"c1",
|
|
109
|
+
{
|
|
110
|
+
categoryId: "c1",
|
|
111
|
+
name: "Electronics",
|
|
112
|
+
archived: false
|
|
113
|
+
}
|
|
114
|
+
]]), {
|
|
115
|
+
by: "name",
|
|
116
|
+
value: "Electronics",
|
|
117
|
+
index: "byArchived"
|
|
118
|
+
}), []);
|
|
119
|
+
if (outcome.TAG === "Ok") {
|
|
120
|
+
return Outcome$ReventlessGwt.fail({
|
|
121
|
+
TAG: "Throw",
|
|
122
|
+
error: "expected failure, got pass",
|
|
123
|
+
stack: ""
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
let other = outcome._0;
|
|
127
|
+
if (other.TAG === "QueryRowsMismatch") {
|
|
128
|
+
return Outcome$ReventlessGwt.pass;
|
|
129
|
+
} else {
|
|
130
|
+
return Outcome$ReventlessGwt.fail({
|
|
131
|
+
TAG: "Throw",
|
|
132
|
+
error: "expected QueryRowsMismatch, got: " + Outcome$ReventlessGwt.kindName(other),
|
|
133
|
+
stack: ""
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
CategoriesQuery.test("filter narrows results after the index scan", () => CategoriesQuery.thenRows(CategoriesQuery.whenQuery(CategoriesQuery.givenStore([
|
|
138
|
+
[
|
|
139
|
+
"c1",
|
|
140
|
+
{
|
|
141
|
+
categoryId: "c1",
|
|
142
|
+
name: "Books",
|
|
143
|
+
archived: false
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
[
|
|
147
|
+
"c2",
|
|
148
|
+
{
|
|
149
|
+
categoryId: "c2",
|
|
150
|
+
name: "Books",
|
|
151
|
+
archived: true
|
|
152
|
+
}
|
|
153
|
+
]
|
|
154
|
+
]), {
|
|
155
|
+
by: "name",
|
|
156
|
+
value: "Books",
|
|
157
|
+
index: "byName",
|
|
158
|
+
filter: r => !r.archived
|
|
159
|
+
}), [{
|
|
160
|
+
categoryId: "c1",
|
|
161
|
+
name: "Books",
|
|
162
|
+
archived: false
|
|
163
|
+
}]));
|
|
164
|
+
CategoriesQuery.test("limit truncates results and thenRowCount verifies", () => CategoriesQuery.thenRowCount(CategoriesQuery.whenQuery(CategoriesQuery.givenStore(Stdlib_Array.fromInitializer(10, i => {
|
|
165
|
+
let id = "c" + i.toString();
|
|
166
|
+
let state = {
|
|
167
|
+
categoryId: id,
|
|
168
|
+
name: "Books",
|
|
169
|
+
archived: false
|
|
170
|
+
};
|
|
171
|
+
return [
|
|
172
|
+
id,
|
|
173
|
+
state
|
|
174
|
+
];
|
|
175
|
+
})), {
|
|
176
|
+
by: "name",
|
|
177
|
+
value: "Books",
|
|
178
|
+
index: "byName",
|
|
179
|
+
limit: 3
|
|
180
|
+
}), 3));
|
|
181
|
+
CategoriesQuery.test("composite-id lookup without subIdConfig fails", () => {
|
|
182
|
+
let outcome = CategoriesQuery.thenRowFromComposite(CategoriesQuery.whenQueryByCompositeId(CategoriesQuery.givenStore([]), {
|
|
183
|
+
id: "c1",
|
|
184
|
+
subId: "v1"
|
|
185
|
+
}), undefined);
|
|
186
|
+
if (outcome.TAG === "Ok") {
|
|
187
|
+
return Outcome$ReventlessGwt.fail({
|
|
188
|
+
TAG: "Throw",
|
|
189
|
+
error: "expected failure, got pass",
|
|
190
|
+
stack: ""
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
let other = outcome._0;
|
|
194
|
+
if (other.TAG === "QueryRowsMismatch") {
|
|
195
|
+
return Outcome$ReventlessGwt.pass;
|
|
196
|
+
} else {
|
|
197
|
+
return Outcome$ReventlessGwt.fail({
|
|
198
|
+
TAG: "Throw",
|
|
199
|
+
error: "expected QueryRowsMismatch, got: " + Outcome$ReventlessGwt.kindName(other),
|
|
200
|
+
stack: ""
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
let name$1 = "OrdersView";
|
|
207
|
+
|
|
208
|
+
let moduleUrl$1 = "";
|
|
209
|
+
|
|
210
|
+
let stateSchema$1 = S.schema(s => ({
|
|
211
|
+
orderId: s.m(S.string),
|
|
212
|
+
customerId: s.m(S.string),
|
|
213
|
+
total: s.m(S.int)
|
|
214
|
+
}));
|
|
215
|
+
|
|
216
|
+
let consumedEventSchema = S.schema(s => ({
|
|
217
|
+
TAG: "OrderPlaced",
|
|
218
|
+
orderId: s.m(S.string),
|
|
219
|
+
customerId: s.m(S.string),
|
|
220
|
+
total: s.m(S.int)
|
|
221
|
+
}));
|
|
222
|
+
|
|
223
|
+
function project(event) {
|
|
224
|
+
let orderId = event.orderId;
|
|
225
|
+
return [{
|
|
226
|
+
TAG: "Set",
|
|
227
|
+
_0: orderId,
|
|
228
|
+
_1: {
|
|
229
|
+
orderId: orderId,
|
|
230
|
+
customerId: event.customerId,
|
|
231
|
+
total: event.total
|
|
232
|
+
}
|
|
233
|
+
}];
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
let config$1 = ReadModel$Reventless.config(undefined, undefined, undefined);
|
|
237
|
+
|
|
238
|
+
let subIdConfig = {
|
|
239
|
+
subIdField: "customerId",
|
|
240
|
+
getSubId: s => s.customerId
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
let OrdersView = {
|
|
244
|
+
name: name$1,
|
|
245
|
+
moduleUrl: moduleUrl$1,
|
|
246
|
+
stateSchema: stateSchema$1,
|
|
247
|
+
consumedEventSchema: consumedEventSchema,
|
|
248
|
+
project: project,
|
|
249
|
+
config: config$1,
|
|
250
|
+
subIdConfig: subIdConfig,
|
|
251
|
+
authorization: "AllowAuthenticated",
|
|
252
|
+
visibility: "Public"
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
let OrdersQuery = Query_GWT$ReventlessGwt.Make(Query_GWT$ReventlessGwt.FromStateViewSlice({
|
|
256
|
+
name: name$1,
|
|
257
|
+
moduleUrl: moduleUrl$1,
|
|
258
|
+
stateSchema: stateSchema$1,
|
|
259
|
+
consumedEventSchema: consumedEventSchema,
|
|
260
|
+
config: config$1,
|
|
261
|
+
subIdConfig: subIdConfig,
|
|
262
|
+
authorization: "AllowAuthenticated",
|
|
263
|
+
visibility: "Public"
|
|
264
|
+
}));
|
|
265
|
+
|
|
266
|
+
OrdersQuery.describe("OrdersView StateViewSlice queries", () => {
|
|
267
|
+
OrdersQuery.test("composite-id lookup returns the row", () => OrdersQuery.thenRowFromComposite(OrdersQuery.whenQueryByCompositeId(OrdersQuery.givenCompositeStore([
|
|
268
|
+
[
|
|
269
|
+
"ord-1",
|
|
270
|
+
"cust-a",
|
|
271
|
+
{
|
|
272
|
+
orderId: "ord-1",
|
|
273
|
+
customerId: "cust-a",
|
|
274
|
+
total: 100
|
|
275
|
+
}
|
|
276
|
+
],
|
|
277
|
+
[
|
|
278
|
+
"ord-2",
|
|
279
|
+
"cust-b",
|
|
280
|
+
{
|
|
281
|
+
orderId: "ord-2",
|
|
282
|
+
customerId: "cust-b",
|
|
283
|
+
total: 200
|
|
284
|
+
}
|
|
285
|
+
]
|
|
286
|
+
]), {
|
|
287
|
+
id: "ord-1",
|
|
288
|
+
subId: "cust-a"
|
|
289
|
+
}), {
|
|
290
|
+
orderId: "ord-1",
|
|
291
|
+
customerId: "cust-a",
|
|
292
|
+
total: 100
|
|
293
|
+
}));
|
|
294
|
+
OrdersQuery.test("composite-id lookup with wrong subId returns None", () => OrdersQuery.thenRowFromComposite(OrdersQuery.whenQueryByCompositeId(OrdersQuery.givenCompositeStore([[
|
|
295
|
+
"ord-1",
|
|
296
|
+
"cust-a",
|
|
297
|
+
{
|
|
298
|
+
orderId: "ord-1",
|
|
299
|
+
customerId: "cust-a",
|
|
300
|
+
total: 100
|
|
301
|
+
}
|
|
302
|
+
]]), {
|
|
303
|
+
id: "ord-1",
|
|
304
|
+
subId: "cust-z"
|
|
305
|
+
}), undefined));
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
export {
|
|
309
|
+
CategoriesReadModel,
|
|
310
|
+
CategoriesQuery,
|
|
311
|
+
OrdersView,
|
|
312
|
+
OrdersQuery,
|
|
313
|
+
}
|
|
314
|
+
/* Not a pure module */
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Worked example for Query_GWT.MakeResolver — cross-spec (`@resolves` /
|
|
2
|
+
// `@resolvesMany`) GraphQL resolvers. An Orders read model carries a foreign
|
|
3
|
+
// productId (and a productIds array) that resolve into a Products read model;
|
|
4
|
+
// the resolver DSL follows those keys across the spec boundary.
|
|
5
|
+
|
|
6
|
+
S.enableJson()
|
|
7
|
+
|
|
8
|
+
module RM = Reventless.ReadModel
|
|
9
|
+
|
|
10
|
+
module ProductRow = {
|
|
11
|
+
let name = "ProductRow"
|
|
12
|
+
|
|
13
|
+
@schema
|
|
14
|
+
type state = {productId: string, name: string, price: float}
|
|
15
|
+
|
|
16
|
+
let config = RM.config()
|
|
17
|
+
let subIdConfig = None
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module OrderRow = {
|
|
21
|
+
let name = "OrderRow"
|
|
22
|
+
|
|
23
|
+
@schema
|
|
24
|
+
type state = {orderId: string, productId: string, productIds: array<string>}
|
|
25
|
+
|
|
26
|
+
let config = RM.config(
|
|
27
|
+
~idResolvers=[
|
|
28
|
+
{
|
|
29
|
+
source: {RM.idField: "productId", subId: NoSubId, resolvedField: Single("product")},
|
|
30
|
+
target: {RM.tableName: "ProductRow", idField: Id},
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
~idsResolvers=[
|
|
34
|
+
{
|
|
35
|
+
source: {RM.idsField: "productIds", resolvedField: "products"},
|
|
36
|
+
target: {RM.tableName: "ProductRow"},
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
)
|
|
40
|
+
let subIdConfig = None
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module R = Query_GWT.MakeResolver(OrderRow, ProductRow)
|
|
44
|
+
|
|
45
|
+
let book: ProductRow.state = {productId: "p1", name: "Book", price: 9.99}
|
|
46
|
+
let pen: ProductRow.state = {productId: "p2", name: "Pen", price: 1.5}
|
|
47
|
+
let order: OrderRow.state = {orderId: "order1", productId: "p1", productIds: ["p1", "p2"]}
|
|
48
|
+
|
|
49
|
+
let stores = () => R.givenStores([("order1", order)], [("p1", book), ("p2", pen)])
|
|
50
|
+
|
|
51
|
+
R.describe("Cross-spec resolvers (MakeResolver)", () => {
|
|
52
|
+
R.test("@resolves follows productId into the Products table", () =>
|
|
53
|
+
stores()
|
|
54
|
+
->R.whenResolve(~field="productId", "order1")
|
|
55
|
+
->R.thenResolved(Some(book))
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
R.test("@resolvesMany follows productIds into multiple Products rows", () =>
|
|
59
|
+
stores()
|
|
60
|
+
->R.whenResolveMany(~field="productIds", "order1")
|
|
61
|
+
->R.thenResolvedMany([book, pen])
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
R.test("resolving an unknown foreign key returns no row", () =>
|
|
65
|
+
R.givenStores([("order2", {OrderRow.orderId: "order2", productId: "px", productIds: []})], [
|
|
66
|
+
("p1", book),
|
|
67
|
+
])
|
|
68
|
+
->R.whenResolve(~field="productId", "order2")
|
|
69
|
+
->R.thenResolved(None)
|
|
70
|
+
)
|
|
71
|
+
})
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as S from "sury/src/S.res.mjs";
|
|
4
|
+
import * as ReadModel$Reventless from "@reventlessdev/reventless-spec/src/components/ReadModel.res.mjs";
|
|
5
|
+
import * as Query_GWT$ReventlessGwt from "../src/Query_GWT.res.mjs";
|
|
6
|
+
|
|
7
|
+
S.enableJson();
|
|
8
|
+
|
|
9
|
+
let stateSchema = S.schema(s => ({
|
|
10
|
+
productId: s.m(S.string),
|
|
11
|
+
name: s.m(S.string),
|
|
12
|
+
price: s.m(S.float)
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
let config = ReadModel$Reventless.config(undefined, undefined, undefined);
|
|
16
|
+
|
|
17
|
+
let ProductRow = {
|
|
18
|
+
name: "ProductRow",
|
|
19
|
+
stateSchema: stateSchema,
|
|
20
|
+
config: config,
|
|
21
|
+
subIdConfig: undefined,
|
|
22
|
+
authorization: "AllowAuthenticated",
|
|
23
|
+
visibility: "Public"
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
let stateSchema$1 = S.schema(s => ({
|
|
27
|
+
orderId: s.m(S.string),
|
|
28
|
+
productId: s.m(S.string),
|
|
29
|
+
productIds: s.m(S.array(S.string))
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
let config$1 = ReadModel$Reventless.config([{
|
|
33
|
+
source: {
|
|
34
|
+
idField: "productId",
|
|
35
|
+
subId: "NoSubId",
|
|
36
|
+
resolvedField: {
|
|
37
|
+
TAG: "Single",
|
|
38
|
+
_0: "product"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
target: {
|
|
42
|
+
tableName: "ProductRow",
|
|
43
|
+
idField: "Id"
|
|
44
|
+
}
|
|
45
|
+
}], [{
|
|
46
|
+
source: {
|
|
47
|
+
idsField: "productIds",
|
|
48
|
+
resolvedField: "products"
|
|
49
|
+
},
|
|
50
|
+
target: {
|
|
51
|
+
tableName: "ProductRow"
|
|
52
|
+
}
|
|
53
|
+
}], undefined);
|
|
54
|
+
|
|
55
|
+
let OrderRow = {
|
|
56
|
+
name: "OrderRow",
|
|
57
|
+
stateSchema: stateSchema$1,
|
|
58
|
+
config: config$1,
|
|
59
|
+
subIdConfig: undefined,
|
|
60
|
+
authorization: "AllowAuthenticated",
|
|
61
|
+
visibility: "Public"
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
let R = Query_GWT$ReventlessGwt.MakeResolver(OrderRow)(ProductRow);
|
|
65
|
+
|
|
66
|
+
let book = {
|
|
67
|
+
productId: "p1",
|
|
68
|
+
name: "Book",
|
|
69
|
+
price: 9.99
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
let pen = {
|
|
73
|
+
productId: "p2",
|
|
74
|
+
name: "Pen",
|
|
75
|
+
price: 1.5
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
let order_productIds = [
|
|
79
|
+
"p1",
|
|
80
|
+
"p2"
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
let order = {
|
|
84
|
+
orderId: "order1",
|
|
85
|
+
productId: "p1",
|
|
86
|
+
productIds: order_productIds
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
function stores() {
|
|
90
|
+
return R.givenStores([[
|
|
91
|
+
"order1",
|
|
92
|
+
order
|
|
93
|
+
]], [
|
|
94
|
+
[
|
|
95
|
+
"p1",
|
|
96
|
+
book
|
|
97
|
+
],
|
|
98
|
+
[
|
|
99
|
+
"p2",
|
|
100
|
+
pen
|
|
101
|
+
]
|
|
102
|
+
]);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
R.describe("Cross-spec resolvers (MakeResolver)", () => {
|
|
106
|
+
R.test("@resolves follows productId into the Products table", () => R.thenResolved(R.whenResolve(stores(), "productId", "order1"), book));
|
|
107
|
+
R.test("@resolvesMany follows productIds into multiple Products rows", () => R.thenResolvedMany(R.whenResolveMany(stores(), "productIds", "order1"), [
|
|
108
|
+
book,
|
|
109
|
+
pen
|
|
110
|
+
]));
|
|
111
|
+
R.test("resolving an unknown foreign key returns no row", () => R.thenResolved(R.whenResolve(R.givenStores([[
|
|
112
|
+
"order2",
|
|
113
|
+
{
|
|
114
|
+
orderId: "order2",
|
|
115
|
+
productId: "px",
|
|
116
|
+
productIds: []
|
|
117
|
+
}
|
|
118
|
+
]], [[
|
|
119
|
+
"p1",
|
|
120
|
+
book
|
|
121
|
+
]]), "productId", "order2"), undefined));
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
let RM;
|
|
125
|
+
|
|
126
|
+
export {
|
|
127
|
+
RM,
|
|
128
|
+
ProductRow,
|
|
129
|
+
OrderRow,
|
|
130
|
+
R,
|
|
131
|
+
book,
|
|
132
|
+
pen,
|
|
133
|
+
order,
|
|
134
|
+
stores,
|
|
135
|
+
}
|
|
136
|
+
/* Not a pure module */
|