@reventlessdev/reventless-core 3.0.0-alpha.341 → 3.0.0-alpha.342
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 +16 -0
- package/package.json +7 -7
- package/src/Projection.res +32 -4
- package/src/Projection.res.mjs +51 -4
- package/src/ViewChange.res +1 -9
- package/src/ViewChange.res.mjs +2 -13
- package/src/admin/Platform_ComponentDefinitionsApi.res +29 -1
- package/src/admin/Platform_ComponentDefinitionsApi.res.mjs +47 -1
- package/src/admin/Platform_PluginStructuresApi.res +4 -3
- package/src/admin/Platform_PluginStructuresApi.res.mjs +5 -1
- package/src/components/Api/SuryToJsonSchema.res +7 -0
- package/src/components/Api/SuryToJsonSchema.res.mjs +18 -0
- package/src/components/Dcb/Dcb_Builder.res +59 -0
- package/src/components/Dcb/Dcb_Builder.res.mjs +48 -3
- package/src/components/DcbEventLog/DcbEventLog.res +2 -0
- package/src/components/DcbEventLog/DcbEventLog_Adapter.res +7 -0
- package/src/components/DcbEventLog/DcbEventLog_Builder.res +12 -3
- package/src/components/DcbEventLog/DcbEventLog_Builder.res.mjs +5 -3
- package/src/components/DcbEventLog/DcbEventLog_Operations.res +3 -0
- package/src/components/DcbEventLog/DcbEventLog_Operations.res.mjs +3 -1
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Builder.res.mjs +2 -2
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Callback.res +158 -107
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Callback.res.mjs +178 -154
- package/src/components/StateChangeSlice/StateChangeSlice.res +3 -0
- package/src/components/StateChangeSlice/StateChangeSlice_Builder.res +6 -0
- package/src/components/StateChangeSlice/StateChangeSlice_Builder.res.mjs +5 -4
- package/src/components/StateChangeSlice/StateChangeSlice_Callback.res +369 -279
- package/src/components/StateChangeSlice/StateChangeSlice_Callback.res.mjs +210 -166
- package/src/plugin/component/Plugin_Structure.res +45 -0
- package/src/plugin/component/Plugin_Structure.res.mjs +42 -1
- package/src/util/Logger.res +5 -5
- package/src/util/Logger.res.mjs +3 -3
- package/tests/admin/AdminApiSchemaDriftTest.res +23 -0
- package/tests/admin/AdminApiSchemaDriftTest.res.mjs +21 -1
- package/tests/admin/Platform_ComponentDefinitionsApiTest.res +1 -0
- package/tests/admin/Platform_ComponentDefinitionsApiTest.res.mjs +1 -0
- package/tests/admin/Platform_PluginStructuresApiTest.res +1 -0
- package/tests/admin/Platform_PluginStructuresApiTest.res.mjs +1 -0
- package/tests/api/QuantitySemanticTest.res +68 -0
- package/tests/api/QuantitySemanticTest.res.mjs +68 -0
- package/tests/commandgenerator/OwnerActingTest.res.mjs +1 -1
- package/tests/commandtopic/CommandOutcomeHookTest.res.mjs +1 -1
- package/tests/dcb/DcbFenceCountReadTest.res +213 -0
- package/tests/dcb/DcbFenceCountReadTest.res.mjs +358 -0
- package/tests/dcb/DcbPiiSliceTest.res.mjs +1 -1
- package/tests/dcb/DcbReadsNothingTest.res.mjs +1 -1
- package/tests/dcb/DcbScopeInferenceTest.res +143 -2
- package/tests/dcb/DcbScopeInferenceTest.res.mjs +192 -2
- package/tests/dcb/DcbStateChangeSliceTest.res.mjs +22 -22
- package/tests/dcb/DcbTagTest.res +68 -0
- package/tests/dcb/DcbTagTest.res.mjs +86 -10
- package/tests/dcb/DcbValidationTest.res.mjs +1 -1
- package/tests/logger/LoggerLazyTest.res.mjs +3 -3
- package/tests/plugin/PluginStructureAccessTest.res +1 -0
- package/tests/plugin/PluginStructureAccessTest.res.mjs +1 -1
- package/tests/plugin/PluginStructureTest.res +61 -0
- package/tests/plugin/PluginStructureTest.res.mjs +78 -32
- package/tests/plugin/StateChange/PsRateSession.res +37 -0
- package/tests/plugin/StateChange/PsRateSession.res.mjs +80 -0
- package/tests/plugin/pluginDefinitionRequiredScalars.txt +10 -0
- package/tests/projection/ViewChangeTest.res +32 -0
- package/tests/projection/ViewChangeTest.res.mjs +57 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 3.0.0-alpha.342 (2026-11-19)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **aws:** an outbound translation's row is claimed before it is translated ([8c4390f](https://github.com/ReventlessDev/reventless-core/commit/8c4390f8433e326166329005322c81eab9c0faf9))
|
|
11
|
+
* **core:** a projection's action line carries the ids of the event it came from ([b7c35a3](https://github.com/ReventlessDev/reventless-core/commit/b7c35a3cd14c3f61f92a9d70e8fac4f9e7427dec))
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* **dcb:** a cross-partition read checks it saw every event its fence counted ([3c9f343](https://github.com/ReventlessDev/reventless-core/commit/3c9f34374c49834923a17432aab9c41672232108))
|
|
15
|
+
* **dcb:** a pair's events are read across partitions, its hits fetched in batches ([636b9e7](https://github.com/ReventlessDev/reventless-core/commit/636b9e7cdc85c31fe2aa9ca8909fc439f446536d))
|
|
16
|
+
* **dcb:** a pair's writers keep a fence of the reader's, and the reader checks it ([a347a14](https://github.com/ReventlessDev/reventless-core/commit/a347a1412da4db3ecbf2c68cfb8dc1377f9a5bc2))
|
|
17
|
+
* **dcb:** a slice can mark its own key on a consumed event to read it across partitions ([bf380ee](https://github.com/ReventlessDev/reventless-core/commit/bf380eeffeed7a1d29ef114c8f8e500a6af306d4))
|
|
18
|
+
* **dcb:** an append checks a cross-partition fence's count, not its position ([86f60cd](https://github.com/ReventlessDev/reventless-core/commit/86f60cd889a2a70346223a8669224d4d756f6455))
|
|
19
|
+
* **spec:** a field holds a quantity in its unit, and a price per unit is money ([b35c911](https://github.com/ReventlessDev/reventless-core/commit/b35c911b5c18e5c973e18494887e19a1dcd622d3))
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# 3.0.0-alpha.341 (2026-11-16)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @reventlessdev/reventless-core
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reventlessdev/reventless-core",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.342",
|
|
4
4
|
"description": "Core package for Reventless framework",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"jest": {
|
|
@@ -28,17 +28,17 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"sury": "11.1.0",
|
|
30
30
|
"uuid": "^13.0.0",
|
|
31
|
-
"@reventlessdev/rescript-effect": "1.0.0-alpha.3",
|
|
32
|
-
"@reventlessdev/rescript-hash-object": "1.2.0-alpha.15",
|
|
33
31
|
"@reventlessdev/rescript-fast-csv": "2.0.0-alpha.26",
|
|
34
32
|
"@reventlessdev/rescript-jest": "1.0.0-alpha.13",
|
|
33
|
+
"@reventlessdev/rescript-hash-object": "1.2.0-alpha.15",
|
|
35
34
|
"@reventlessdev/rescript-node": "2.0.0-alpha.26",
|
|
36
35
|
"@reventlessdev/rescript-pulumi-pulumi": "3.0.0-alpha.0",
|
|
37
|
-
"@reventlessdev/rescript-ssh2": "2.0.0-alpha.27",
|
|
38
|
-
"@reventlessdev/reventless-infra": "3.0.0-alpha.234",
|
|
39
36
|
"@reventlessdev/rescript-uuid": "2.0.0-alpha.1",
|
|
40
|
-
"@reventlessdev/reventless-
|
|
41
|
-
"@reventlessdev/
|
|
37
|
+
"@reventlessdev/reventless-infra": "3.0.0-alpha.235",
|
|
38
|
+
"@reventlessdev/rescript-ssh2": "2.0.0-alpha.27",
|
|
39
|
+
"@reventlessdev/rescript-effect": "1.0.0-alpha.3",
|
|
40
|
+
"@reventlessdev/reventless-interop": "3.0.0-alpha.43",
|
|
41
|
+
"@reventlessdev/reventless-spec": "3.0.0-alpha.204"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"rescript": "12.3.1",
|
package/src/Projection.res
CHANGED
|
@@ -199,6 +199,34 @@ type changeSource = {
|
|
|
199
199
|
entityType?: string,
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
+
/** The correlation id every source shares, if they share one. */
|
|
203
|
+
let sharedCorrelationId = (sources: array<changeSource>): option<string> =>
|
|
204
|
+
switch sources->Array.map(s => s.correlationId) {
|
|
205
|
+
| [] => None
|
|
206
|
+
| ids =>
|
|
207
|
+
let first = ids->Array.getUnsafe(0)
|
|
208
|
+
ids->Array.every(id => id == first) ? first : None
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** The ids a log line about these sources carries: all of one source's, or the
|
|
212
|
+
correlation id several share. */
|
|
213
|
+
let sourceIds = (sources: array<changeSource>): dict<string> =>
|
|
214
|
+
switch sources {
|
|
215
|
+
| [{msgId, ?correlationId, ?entityId, ?entityType}] =>
|
|
216
|
+
[
|
|
217
|
+
("msgId", Some(msgId)),
|
|
218
|
+
("correlationId", correlationId),
|
|
219
|
+
("entityId", entityId),
|
|
220
|
+
("entityType", entityType),
|
|
221
|
+
]
|
|
222
|
+
->Array.filterMap(((name, value)) => value->Option.map(v => (name, v)))
|
|
223
|
+
->Dict.fromArray
|
|
224
|
+
| _ =>
|
|
225
|
+
sharedCorrelationId(sources)->Option.mapOr(Dict.make(), id =>
|
|
226
|
+
Dict.fromArray([("correlationId", id)])
|
|
227
|
+
)
|
|
228
|
+
}
|
|
229
|
+
|
|
202
230
|
/** One row a projection created, changed or removed. `before` is there where the
|
|
203
231
|
row was loaded first; `Set` and `Delete` write without loading, so theirs is
|
|
204
232
|
absent. `sources` are the events whose actions were applied to the row, all of
|
|
@@ -335,10 +363,10 @@ let applyAction = async (
|
|
|
335
363
|
result
|
|
336
364
|
}
|
|
337
365
|
// Log each applied action at Debug with the full state it creates/changes,
|
|
338
|
-
// attributed to the owning component. Debug-lazy so
|
|
339
|
-
// serialized when debug logging is enabled
|
|
340
|
-
|
|
341
|
-
|
|
366
|
+
// attributed to the owning component and the events it came from. Debug-lazy so
|
|
367
|
+
// the state is only serialized when debug logging is enabled.
|
|
368
|
+
let logAction = makeStr =>
|
|
369
|
+
log.debugLazy(~comp, ~ids=sourceIds(sources), () => `handling action: ${makeStr()}`)
|
|
342
370
|
let loadAtMost = (n, id) =>
|
|
343
371
|
loadStream(id)
|
|
344
372
|
->Stream.take(n)
|
package/src/Projection.res.mjs
CHANGED
|
@@ -25,7 +25,7 @@ import * as RowChange$ReventlessCore from "./RowChange.res.mjs";
|
|
|
25
25
|
let log = Logger$ReventlessCore.fromEnv();
|
|
26
26
|
|
|
27
27
|
function logAction(makeStr) {
|
|
28
|
-
log.debugLazy("Projection", makeStr);
|
|
28
|
+
log.debugLazy("Projection", undefined, makeStr);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
function overlaysFor(stateSchema) {
|
|
@@ -207,6 +207,51 @@ function rewriteJsonAction(action, at, stateSchema) {
|
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
+
function sharedCorrelationId(sources) {
|
|
211
|
+
let ids = sources.map(s => s.correlationId);
|
|
212
|
+
if (ids.length === 0) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
let first = ids[0];
|
|
216
|
+
if (ids.every(id => Primitive_object.equal(id, first))) {
|
|
217
|
+
return first;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function sourceIds(sources) {
|
|
222
|
+
if (sources.length !== 1) {
|
|
223
|
+
return Stdlib_Option.mapOr(sharedCorrelationId(sources), {}, id => Object.fromEntries([[
|
|
224
|
+
"correlationId",
|
|
225
|
+
id
|
|
226
|
+
]]));
|
|
227
|
+
}
|
|
228
|
+
let match = sources[0];
|
|
229
|
+
return Object.fromEntries(Stdlib_Array.filterMap([
|
|
230
|
+
[
|
|
231
|
+
"msgId",
|
|
232
|
+
match.msgId
|
|
233
|
+
],
|
|
234
|
+
[
|
|
235
|
+
"correlationId",
|
|
236
|
+
match.correlationId
|
|
237
|
+
],
|
|
238
|
+
[
|
|
239
|
+
"entityId",
|
|
240
|
+
match.entityId
|
|
241
|
+
],
|
|
242
|
+
[
|
|
243
|
+
"entityType",
|
|
244
|
+
match.entityType
|
|
245
|
+
]
|
|
246
|
+
], param => {
|
|
247
|
+
let name = param[0];
|
|
248
|
+
return Stdlib_Option.map(param[1], v => [
|
|
249
|
+
name,
|
|
250
|
+
v
|
|
251
|
+
]);
|
|
252
|
+
}));
|
|
253
|
+
}
|
|
254
|
+
|
|
210
255
|
function mergeSources(a, b) {
|
|
211
256
|
return a.concat(b.filter(s => !a.some(other => other.msgId === s.msgId)));
|
|
212
257
|
}
|
|
@@ -251,7 +296,7 @@ async function applyChanges(action, id, beforeStates, afterStates, param, param$
|
|
|
251
296
|
]
|
|
252
297
|
]);
|
|
253
298
|
let deletedCount = batchToDelete.length;
|
|
254
|
-
|
|
299
|
+
logAction(() => action + `(` + id + `): beforeStates:` + beforeCount.toString() + ` afterStates:` + afterCount.toString() + ` added:` + addedCount.toString() + ` changed:` + changedCount.toString() + ` deleted:` + deletedCount.toString());
|
|
255
300
|
let result = await Promise.all([
|
|
256
301
|
param.deleteBatch(batchToDelete),
|
|
257
302
|
param.saveBatch(batchToSave)
|
|
@@ -320,7 +365,7 @@ async function applyAction($staropt$star, $staropt$star$1, onChange, action, ope
|
|
|
320
365
|
}
|
|
321
366
|
return result;
|
|
322
367
|
};
|
|
323
|
-
let logAction = makeStr => log.debugLazy(comp, () => `handling action: ` + makeStr());
|
|
368
|
+
let logAction = makeStr => log.debugLazy(comp, sourceIds(sources), () => `handling action: ` + makeStr());
|
|
324
369
|
let loadAtMost = (n, id) => Effect.runPromise(Effect$1.catch(Effect$1.map(Stream.runCollect(Stream.take(loadStream(id), n)), states => ({
|
|
325
370
|
TAG: "Ok",
|
|
326
371
|
_0: states
|
|
@@ -585,7 +630,7 @@ function actionsWithId(action) {
|
|
|
585
630
|
action
|
|
586
631
|
]];
|
|
587
632
|
}
|
|
588
|
-
|
|
633
|
+
logAction(() => "Error: Action not yet supported !");
|
|
589
634
|
return [];
|
|
590
635
|
}
|
|
591
636
|
|
|
@@ -909,6 +954,8 @@ export {
|
|
|
909
954
|
trailOverlays,
|
|
910
955
|
rewriteTrail,
|
|
911
956
|
rewriteJsonAction,
|
|
957
|
+
sharedCorrelationId,
|
|
958
|
+
sourceIds,
|
|
912
959
|
mergeSources,
|
|
913
960
|
applyChanges,
|
|
914
961
|
stateToString,
|
package/src/ViewChange.res
CHANGED
|
@@ -70,14 +70,6 @@ let changedFields = (~before: option<JSON.t>, ~after: option<JSON.t>): array<str
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
let sharedCorrelationId = (sources: array<Projection.changeSource>): option<string> =>
|
|
74
|
-
switch sources->Array.map(s => s.correlationId) {
|
|
75
|
-
| [] => None
|
|
76
|
-
| ids =>
|
|
77
|
-
let first = ids->Array.getUnsafe(0)
|
|
78
|
-
ids->Array.every(id => id == first) ? first : None
|
|
79
|
-
}
|
|
80
|
-
|
|
81
73
|
let sourceToJson = (s: Projection.changeSource): JSON.t =>
|
|
82
74
|
[("msgId", JSON.Encode.string(s.msgId))]
|
|
83
75
|
->Array.concat(s.correlationId->Option.mapOr([], c => [("correlationId", JSON.Encode.string(c))]))
|
|
@@ -144,7 +136,7 @@ let reporter = (~comp: string, ~view: string, ~stateToJson: 'state => JSON.t): (
|
|
|
144
136
|
?before,
|
|
145
137
|
?after,
|
|
146
138
|
sources: change.sources,
|
|
147
|
-
correlationId: ?sharedCorrelationId(change.sources),
|
|
139
|
+
correlationId: ?Projection.sharedCorrelationId(change.sources),
|
|
148
140
|
}
|
|
149
141
|
if logs {
|
|
150
142
|
logLine(~comp, c)
|
package/src/ViewChange.res.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
|
6
6
|
import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js";
|
|
7
7
|
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
8
8
|
import * as Logger$ReventlessCore from "./util/Logger.res.mjs";
|
|
9
|
+
import * as Projection$ReventlessCore from "./Projection.res.mjs";
|
|
9
10
|
|
|
10
11
|
let listeners = {
|
|
11
12
|
contents: []
|
|
@@ -65,17 +66,6 @@ function changedFields(before, after) {
|
|
|
65
66
|
return names.filter(name => Primitive_object.notequal(match[name], match$1[name]));
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
function sharedCorrelationId(sources) {
|
|
69
|
-
let ids = sources.map(s => s.correlationId);
|
|
70
|
-
if (ids.length === 0) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
let first = ids[0];
|
|
74
|
-
if (ids.every(id => Primitive_object.equal(id, first))) {
|
|
75
|
-
return first;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
69
|
function sourceToJson(s) {
|
|
80
70
|
return Object.fromEntries([[
|
|
81
71
|
"msgId",
|
|
@@ -165,7 +155,7 @@ function reporter(comp, view, stateToJson) {
|
|
|
165
155
|
let c_subId = change.subId;
|
|
166
156
|
let c_kind = change.kind;
|
|
167
157
|
let c_sources = change.sources;
|
|
168
|
-
let c_correlationId = sharedCorrelationId(change.sources);
|
|
158
|
+
let c_correlationId = Projection$ReventlessCore.sharedCorrelationId(change.sources);
|
|
169
159
|
let c = {
|
|
170
160
|
view: view,
|
|
171
161
|
key: c_key,
|
|
@@ -224,7 +214,6 @@ export {
|
|
|
224
214
|
clear,
|
|
225
215
|
kindLabel,
|
|
226
216
|
changedFields,
|
|
227
|
-
sharedCorrelationId,
|
|
228
217
|
sourceToJson,
|
|
229
218
|
summaryFields,
|
|
230
219
|
logLine,
|
|
@@ -45,7 +45,12 @@ let sdlTypes: array<string> = [
|
|
|
45
45
|
// resolving a reference target reads all three. Keeping it a separate field is
|
|
46
46
|
// what makes that separation structural rather than a filter every enumeration
|
|
47
47
|
// site has to remember.
|
|
48
|
-
`type Platform_ComponentDefinitionEntry {\n pluginId: String!\n readModels: [Platform_ReadSideDef!]!\n stateViewSlices: [Platform_ReadSideDef!]!\n internalQueryables: [Platform_ReadSideDef!]!\n stateChangeSlices: [Platform_WriteSideDef!]!\n aggregates: [Platform_WriteSideDef!]!\n automationSlices: [Platform_AutomationSliceDef!]!\n outboundTranslationSlices: [Platform_OutboundTranslationSliceDef!]!\n inboundTranslationSlices: [Platform_InboundTranslationSliceDef!]!\n extensions: [Platform_ExtensionDef!]!\n}`,
|
|
48
|
+
`type Platform_ComponentDefinitionEntry {\n pluginId: String!\n readModels: [Platform_ReadSideDef!]!\n stateViewSlices: [Platform_ReadSideDef!]!\n internalQueryables: [Platform_ReadSideDef!]!\n stateChangeSlices: [Platform_WriteSideDef!]!\n aggregates: [Platform_WriteSideDef!]!\n automationSlices: [Platform_AutomationSliceDef!]!\n outboundTranslationSlices: [Platform_OutboundTranslationSliceDef!]!\n inboundTranslationSlices: [Platform_InboundTranslationSliceDef!]!\n extensions: [Platform_ExtensionDef!]!\n quantities: [Platform_QuantityDef!]\n}`,
|
|
49
|
+
// A quantity the plugin's fields measure or price, with its units' factors, so a
|
|
50
|
+
// page converts between units. A field names only the quantity and the unit.
|
|
51
|
+
// Nullable on the entry, as a structure written before it cannot say.
|
|
52
|
+
`type Platform_QuantityUnitDef {\n code: String!\n factor: Float!\n words: String!\n plural: String!\n}`,
|
|
53
|
+
`type Platform_QuantityDef {\n name: String!\n adds: Boolean!\n units: [Platform_QuantityUnitDef!]!\n}`,
|
|
49
54
|
]
|
|
50
55
|
|
|
51
56
|
let sdlQueryField: string = ` Platform_ComponentDefinitions: [Platform_ComponentDefinitionEntry!]!`
|
|
@@ -53,6 +58,28 @@ let sdlQueryField: string = ` Platform_ComponentDefinitions: [Platform_Componen
|
|
|
53
58
|
let encodeStrings = (ss: array<string>): JSON.t =>
|
|
54
59
|
ss->Array.map(JSON.Encode.string)->JSON.Encode.array
|
|
55
60
|
|
|
61
|
+
let encodeQuantityDef = (q: Reventless.Quantity.def): JSON.t =>
|
|
62
|
+
Dict.fromArray([
|
|
63
|
+
("name", JSON.Encode.string(q.name)),
|
|
64
|
+
("adds", JSON.Encode.bool(q.adds)),
|
|
65
|
+
(
|
|
66
|
+
"units",
|
|
67
|
+
q.units
|
|
68
|
+
->Array.map(u =>
|
|
69
|
+
Dict.fromArray([
|
|
70
|
+
("code", JSON.Encode.string(u.code)),
|
|
71
|
+
("factor", JSON.Encode.float(u.factor)),
|
|
72
|
+
("words", JSON.Encode.string(u.words)),
|
|
73
|
+
("plural", JSON.Encode.string(u.plural)),
|
|
74
|
+
])->JSON.Encode.object
|
|
75
|
+
)
|
|
76
|
+
->JSON.Encode.array,
|
|
77
|
+
),
|
|
78
|
+
])->JSON.Encode.object
|
|
79
|
+
|
|
80
|
+
let encodeQuantities = (qs: option<array<Reventless.Quantity.def>>): JSON.t =>
|
|
81
|
+
qs->Option.mapOr(JSON.Encode.null, qs => qs->Array.map(encodeQuantityDef)->JSON.Encode.array)
|
|
82
|
+
|
|
56
83
|
let encodeFieldReference = (r: fieldReference): JSON.t =>
|
|
57
84
|
Dict.fromArray([
|
|
58
85
|
("fieldName", JSON.Encode.string(r.fieldName)),
|
|
@@ -292,6 +319,7 @@ let encodePluginStructureEntry = (
|
|
|
292
319
|
->JSON.Encode.array,
|
|
293
320
|
),
|
|
294
321
|
("extensions", def.extensions->Array.map(encodeExtensionDef)->JSON.Encode.array),
|
|
322
|
+
("quantities", encodeQuantities(def.quantities)),
|
|
295
323
|
])
|
|
296
324
|
derived->Option.forEach(kinds =>
|
|
297
325
|
entry->Dict.set("derivedPages", kinds->Array.map(JSON.Encode.string)->JSON.Encode.array)
|
|
@@ -16,13 +16,53 @@ let sdlTypes = [
|
|
|
16
16
|
`type Platform_HandledEventDef {\n name: String!\n toCommandTypes: [String!]!\n}`,
|
|
17
17
|
`type Platform_IssuedCommandDef {\n name: String!\n fromEventTypes: [String!]!\n}`,
|
|
18
18
|
`type Platform_ExtensionDef {\n name: String!\n delegateNames: [String!]!\n eventTypes: [String!]!\n commandTypes: [String!]!\n handledEvents: [Platform_HandledEventDef!]\n issuedCommands: [Platform_IssuedCommandDef!]\n}`,
|
|
19
|
-
`type Platform_ComponentDefinitionEntry {\n pluginId: String!\n readModels: [Platform_ReadSideDef!]!\n stateViewSlices: [Platform_ReadSideDef!]!\n internalQueryables: [Platform_ReadSideDef!]!\n stateChangeSlices: [Platform_WriteSideDef!]!\n aggregates: [Platform_WriteSideDef!]!\n automationSlices: [Platform_AutomationSliceDef!]!\n outboundTranslationSlices: [Platform_OutboundTranslationSliceDef!]!\n inboundTranslationSlices: [Platform_InboundTranslationSliceDef!]!\n extensions: [Platform_ExtensionDef!]!\n}
|
|
19
|
+
`type Platform_ComponentDefinitionEntry {\n pluginId: String!\n readModels: [Platform_ReadSideDef!]!\n stateViewSlices: [Platform_ReadSideDef!]!\n internalQueryables: [Platform_ReadSideDef!]!\n stateChangeSlices: [Platform_WriteSideDef!]!\n aggregates: [Platform_WriteSideDef!]!\n automationSlices: [Platform_AutomationSliceDef!]!\n outboundTranslationSlices: [Platform_OutboundTranslationSliceDef!]!\n inboundTranslationSlices: [Platform_InboundTranslationSliceDef!]!\n extensions: [Platform_ExtensionDef!]!\n quantities: [Platform_QuantityDef!]\n}`,
|
|
20
|
+
`type Platform_QuantityUnitDef {\n code: String!\n factor: Float!\n words: String!\n plural: String!\n}`,
|
|
21
|
+
`type Platform_QuantityDef {\n name: String!\n adds: Boolean!\n units: [Platform_QuantityUnitDef!]!\n}`
|
|
20
22
|
];
|
|
21
23
|
|
|
22
24
|
function encodeStrings(ss) {
|
|
23
25
|
return ss.map(prim => prim);
|
|
24
26
|
}
|
|
25
27
|
|
|
28
|
+
function encodeQuantityDef(q) {
|
|
29
|
+
return Object.fromEntries([
|
|
30
|
+
[
|
|
31
|
+
"name",
|
|
32
|
+
q.name
|
|
33
|
+
],
|
|
34
|
+
[
|
|
35
|
+
"adds",
|
|
36
|
+
q.adds
|
|
37
|
+
],
|
|
38
|
+
[
|
|
39
|
+
"units",
|
|
40
|
+
q.units.map(u => Object.fromEntries([
|
|
41
|
+
[
|
|
42
|
+
"code",
|
|
43
|
+
u.code
|
|
44
|
+
],
|
|
45
|
+
[
|
|
46
|
+
"factor",
|
|
47
|
+
u.factor
|
|
48
|
+
],
|
|
49
|
+
[
|
|
50
|
+
"words",
|
|
51
|
+
u.words
|
|
52
|
+
],
|
|
53
|
+
[
|
|
54
|
+
"plural",
|
|
55
|
+
u.plural
|
|
56
|
+
]
|
|
57
|
+
]))
|
|
58
|
+
]
|
|
59
|
+
]);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function encodeQuantities(qs) {
|
|
63
|
+
return Stdlib_Option.mapOr(qs, null, qs => qs.map(encodeQuantityDef));
|
|
64
|
+
}
|
|
65
|
+
|
|
26
66
|
function encodeFieldReference(r) {
|
|
27
67
|
return Object.fromEntries([
|
|
28
68
|
[
|
|
@@ -441,6 +481,10 @@ function encodePluginStructureEntry(pluginId, derived, def) {
|
|
|
441
481
|
[
|
|
442
482
|
"extensions",
|
|
443
483
|
def.extensions.map(encodeExtensionDef)
|
|
484
|
+
],
|
|
485
|
+
[
|
|
486
|
+
"quantities",
|
|
487
|
+
encodeQuantities(def.quantities)
|
|
444
488
|
]
|
|
445
489
|
]);
|
|
446
490
|
Stdlib_Option.forEach(derived, kinds => {
|
|
@@ -455,6 +499,8 @@ export {
|
|
|
455
499
|
sdlTypes,
|
|
456
500
|
sdlQueryField,
|
|
457
501
|
encodeStrings,
|
|
502
|
+
encodeQuantityDef,
|
|
503
|
+
encodeQuantities,
|
|
458
504
|
encodeFieldReference,
|
|
459
505
|
encodeCommandDef,
|
|
460
506
|
isPublicReadSide,
|
|
@@ -52,13 +52,13 @@ let sdlTypes: array<string> = [
|
|
|
52
52
|
// A door into the admission flow, and which part of it the door serves.
|
|
53
53
|
`type Platform_AdmissionDoorDef {\n component: String!\n part: String!\n}`,
|
|
54
54
|
// `extensionPoints` / `requiredStores` / `requiredStoreDeclarations` /
|
|
55
|
-
// `requiredCapabilities` / `traitDeclarations` / `admission` / `admissionDoors`
|
|
56
|
-
// nullable lists, not `[T!]!`: all
|
|
55
|
+
// `requiredCapabilities` / `traitDeclarations` / `admission` / `admissionDoors` /
|
|
56
|
+
// `quantities` are nullable lists, not `[T!]!`: all eight are optional on
|
|
57
57
|
// `pluginStructure` so that plugin definitions persisted before the field existed
|
|
58
58
|
// still decode. A structure written by an older deploy sends null, and null is the
|
|
59
59
|
// honest answer — an empty list would claim the plugin has no extension points when
|
|
60
60
|
// the truth is that the deployment cannot say.
|
|
61
|
-
`type Platform_PluginStructureEntry {\n pluginId: String!\n readModels: [Platform_ReadSideDef!]!\n stateViewSlices: [Platform_ReadSideDef!]!\n stateChangeSlices: [Platform_WriteSideDef!]!\n aggregates: [Platform_WriteSideDef!]!\n automationSlices: [Platform_AutomationSliceDef!]!\n outboundTranslationSlices: [Platform_OutboundTranslationSliceDef!]!\n inboundTranslationSlices: [Platform_InboundTranslationSliceDef!]!\n extensions: [Platform_ExtensionDef!]!\n extensionPoints: [Platform_ExtensionPointDef!]\n requiredStores: [String!]\n requiredStoreDeclarations: [Platform_RequiredStoreDeclaration!]\n requiredCapabilities: [Platform_RequiredCapabilityDeclaration!]\n traitDeclarations: [Platform_TraitDeclaration!]\n admission: [Platform_AdmissionDef!]\n admissionDoors: [Platform_AdmissionDoorDef!]\n}`,
|
|
61
|
+
`type Platform_PluginStructureEntry {\n pluginId: String!\n readModels: [Platform_ReadSideDef!]!\n stateViewSlices: [Platform_ReadSideDef!]!\n stateChangeSlices: [Platform_WriteSideDef!]!\n aggregates: [Platform_WriteSideDef!]!\n automationSlices: [Platform_AutomationSliceDef!]!\n outboundTranslationSlices: [Platform_OutboundTranslationSliceDef!]!\n inboundTranslationSlices: [Platform_InboundTranslationSliceDef!]!\n extensions: [Platform_ExtensionDef!]!\n extensionPoints: [Platform_ExtensionPointDef!]\n requiredStores: [String!]\n requiredStoreDeclarations: [Platform_RequiredStoreDeclaration!]\n requiredCapabilities: [Platform_RequiredCapabilityDeclaration!]\n traitDeclarations: [Platform_TraitDeclaration!]\n admission: [Platform_AdmissionDef!]\n admissionDoors: [Platform_AdmissionDoorDef!]\n quantities: [Platform_QuantityDef!]\n}`,
|
|
62
62
|
]
|
|
63
63
|
|
|
64
64
|
let sdlQueryField: string = ` Platform_PluginStructures: [Platform_PluginStructureEntry!]!`
|
|
@@ -238,4 +238,5 @@ let encodePluginStructureEntry = (~pluginId: string, def: pluginStructure): JSON
|
|
|
238
238
|
ds->Array.map(encodeAdmissionDoorDef)->JSON.Encode.array
|
|
239
239
|
),
|
|
240
240
|
),
|
|
241
|
+
("quantities", Platform_ComponentDefinitionsApi.encodeQuantities(def.quantities)),
|
|
241
242
|
])->JSON.Encode.object
|
|
@@ -13,7 +13,7 @@ let sdlTypes = [
|
|
|
13
13
|
`type Platform_TraitDeclaration {\n trait: String!\n version: String!\n posture: String!\n component: String!\n}`,
|
|
14
14
|
`type Platform_AdmissionDef {\n role: String!\n strategy: String!\n invitedBy: [String!]\n}`,
|
|
15
15
|
`type Platform_AdmissionDoorDef {\n component: String!\n part: String!\n}`,
|
|
16
|
-
`type Platform_PluginStructureEntry {\n pluginId: String!\n readModels: [Platform_ReadSideDef!]!\n stateViewSlices: [Platform_ReadSideDef!]!\n stateChangeSlices: [Platform_WriteSideDef!]!\n aggregates: [Platform_WriteSideDef!]!\n automationSlices: [Platform_AutomationSliceDef!]!\n outboundTranslationSlices: [Platform_OutboundTranslationSliceDef!]!\n inboundTranslationSlices: [Platform_InboundTranslationSliceDef!]!\n extensions: [Platform_ExtensionDef!]!\n extensionPoints: [Platform_ExtensionPointDef!]\n requiredStores: [String!]\n requiredStoreDeclarations: [Platform_RequiredStoreDeclaration!]\n requiredCapabilities: [Platform_RequiredCapabilityDeclaration!]\n traitDeclarations: [Platform_TraitDeclaration!]\n admission: [Platform_AdmissionDef!]\n admissionDoors: [Platform_AdmissionDoorDef!]\n}`
|
|
16
|
+
`type Platform_PluginStructureEntry {\n pluginId: String!\n readModels: [Platform_ReadSideDef!]!\n stateViewSlices: [Platform_ReadSideDef!]!\n stateChangeSlices: [Platform_WriteSideDef!]!\n aggregates: [Platform_WriteSideDef!]!\n automationSlices: [Platform_AutomationSliceDef!]!\n outboundTranslationSlices: [Platform_OutboundTranslationSliceDef!]!\n inboundTranslationSlices: [Platform_InboundTranslationSliceDef!]!\n extensions: [Platform_ExtensionDef!]!\n extensionPoints: [Platform_ExtensionPointDef!]\n requiredStores: [String!]\n requiredStoreDeclarations: [Platform_RequiredStoreDeclaration!]\n requiredCapabilities: [Platform_RequiredCapabilityDeclaration!]\n traitDeclarations: [Platform_TraitDeclaration!]\n admission: [Platform_AdmissionDef!]\n admissionDoors: [Platform_AdmissionDoorDef!]\n quantities: [Platform_QuantityDef!]\n}`
|
|
17
17
|
];
|
|
18
18
|
|
|
19
19
|
function encodeTraitDeclaration(d) {
|
|
@@ -213,6 +213,10 @@ function encodePluginStructureEntry(pluginId, def) {
|
|
|
213
213
|
[
|
|
214
214
|
"admissionDoors",
|
|
215
215
|
Stdlib_Option.mapOr(def.admissionDoors, null, ds => ds.map(encodeAdmissionDoorDef))
|
|
216
|
+
],
|
|
217
|
+
[
|
|
218
|
+
"quantities",
|
|
219
|
+
Platform_ComponentDefinitionsApi$ReventlessCore.encodeQuantities(def.quantities)
|
|
216
220
|
]
|
|
217
221
|
]);
|
|
218
222
|
}
|
|
@@ -346,6 +346,13 @@ and withSemantic = (fieldSchema: JSON.t, sem: Reventless.Semantic.t): JSON.t =>
|
|
|
346
346
|
->optional("content", content),
|
|
347
347
|
),
|
|
348
348
|
)
|
|
349
|
+
// Its own key, not `-target`: a unit is not something the value points at.
|
|
350
|
+
// The quantity's units and factors are listed once in the plugin's structure.
|
|
351
|
+
| InUnit({quantity, unit}) | PerUnit({quantity, unit}) =>
|
|
352
|
+
obj->Dict.set(
|
|
353
|
+
"x-reventless-semantic-unit",
|
|
354
|
+
jsonObject([("quantity", str(quantity)), ("unit", str(unit))]),
|
|
355
|
+
)
|
|
349
356
|
}
|
|
350
357
|
JSON.Encode.object(obj)
|
|
351
358
|
}
|
|
@@ -342,6 +342,7 @@ function withSemantic(fieldSchema, sem) {
|
|
|
342
342
|
obj["x-reventless-semantic"] = sem.id;
|
|
343
343
|
obj["x-reventless-semantic-source"] = "type";
|
|
344
344
|
let match = sem.payload;
|
|
345
|
+
let exit = 0;
|
|
345
346
|
if (typeof match === "object") {
|
|
346
347
|
switch (match.TAG) {
|
|
347
348
|
case "ReferenceTo" :
|
|
@@ -387,8 +388,25 @@ function withSemantic(fieldSchema, sem) {
|
|
|
387
388
|
match.key
|
|
388
389
|
]]);
|
|
389
390
|
break;
|
|
391
|
+
case "InUnit" :
|
|
392
|
+
case "PerUnit" :
|
|
393
|
+
exit = 1;
|
|
394
|
+
break;
|
|
390
395
|
}
|
|
391
396
|
}
|
|
397
|
+
if (exit === 1) {
|
|
398
|
+
let match$4 = match._0;
|
|
399
|
+
obj["x-reventless-semantic-unit"] = Object.fromEntries([
|
|
400
|
+
[
|
|
401
|
+
"quantity",
|
|
402
|
+
match$4.quantity
|
|
403
|
+
],
|
|
404
|
+
[
|
|
405
|
+
"unit",
|
|
406
|
+
match$4.unit
|
|
407
|
+
]
|
|
408
|
+
]);
|
|
409
|
+
}
|
|
392
410
|
return obj;
|
|
393
411
|
}
|
|
394
412
|
|
|
@@ -375,6 +375,23 @@ module Make = (
|
|
|
375
375
|
log.info(~comp="Dcb_Builder", `DCB scope (${e.sliceName}): ${e.message}`)
|
|
376
376
|
)
|
|
377
377
|
|
|
378
|
+
// A `@crossPartition` on a consumed arm reads the slice's own key across
|
|
379
|
+
// partitions. On another key it says nothing the build could act on.
|
|
380
|
+
let armIssues = Reventless.DcbValidation.validateCrossPartitionArms(
|
|
381
|
+
~shapes=inferenceShapes,
|
|
382
|
+
~inferred,
|
|
383
|
+
)
|
|
384
|
+
armIssues.redundancies->Array.forEach(e =>
|
|
385
|
+
log.info(~comp="Dcb_Builder", `DCB scope (${e.sliceName}): ${e.message}`)
|
|
386
|
+
)
|
|
387
|
+
if armIssues.contradictions->Array.length > 0 {
|
|
388
|
+
let detail =
|
|
389
|
+
armIssues.contradictions
|
|
390
|
+
->Array.map(e => `${e.sliceName}: ${e.message}`)
|
|
391
|
+
->Array.join(" | ")
|
|
392
|
+
log.error(~comp="Dcb_Builder", `DCB scope contradiction (${name}): ${detail}`)
|
|
393
|
+
JsError.throwWithMessage(`DCB scope contradiction (${name}): ${detail}`)
|
|
394
|
+
}
|
|
378
395
|
// All-or-nothing: thread the derived scope only when every slice resolved.
|
|
379
396
|
// An ambiguous boundary keeps the annotated values (no partial inference).
|
|
380
397
|
// Both this builder and the deployed command-handler entry point
|
|
@@ -385,6 +402,45 @@ module Make = (
|
|
|
385
402
|
let effectiveCrossPartitionTagKeys = effective.crossPartitionTagKeys
|
|
386
403
|
let effectiveTagKeysByEventType = effective.tagKeysByEventType
|
|
387
404
|
|
|
405
|
+
// A pair puts a cost on slices whose specs did not change: each writer of the
|
|
406
|
+
// pair's event now updates a fence of the reader's. Said once per writer, and
|
|
407
|
+
// as a warning where its transaction already carries other such fences, since
|
|
408
|
+
// each adds an item to a transaction capped at 100.
|
|
409
|
+
effective.crossPartitionPairs->Array.forEach(pair =>
|
|
410
|
+
pair.writers->Array.forEach(writer => {
|
|
411
|
+
let writes = (s: Reventless.DcbScopeInference.sliceShape) => s.sliceName == writer
|
|
412
|
+
let otherPairs =
|
|
413
|
+
effective.crossPartitionPairs->Array.some(
|
|
414
|
+
p =>
|
|
415
|
+
p.writers->Array.includes(writer) &&
|
|
416
|
+
(p.eventType != pair.eventType || p.key != pair.key),
|
|
417
|
+
)
|
|
418
|
+
let carriesCrossPartition =
|
|
419
|
+
inferenceShapes
|
|
420
|
+
->Array.find(writes)
|
|
421
|
+
->Option.mapOr(
|
|
422
|
+
false,
|
|
423
|
+
s =>
|
|
424
|
+
s
|
|
425
|
+
->Reventless.DcbScopeInference.producedKeys
|
|
426
|
+
->Array.some(k => effectiveCrossPartitionTagKeys->Array.includes(k)),
|
|
427
|
+
)
|
|
428
|
+
let composite = switch partitionTagOf(writer) {
|
|
429
|
+
| Some(Reventless.DcbTag.Composite(_)) => true
|
|
430
|
+
| _ => false
|
|
431
|
+
}
|
|
432
|
+
let message = `DCB pair (${name}): ${writer} now updates fence ${pair.key} for ${pair.reader}, which reads ${pair.eventType} by ${pair.key} across partitions`
|
|
433
|
+
if otherPairs || carriesCrossPartition || composite {
|
|
434
|
+
log.warn(
|
|
435
|
+
~comp="Dcb_Builder",
|
|
436
|
+
`${message}; its appends already carry other cross-partition, composite or pair fences, and each adds an item to a transaction capped at 100`,
|
|
437
|
+
)
|
|
438
|
+
} else {
|
|
439
|
+
log.info(~comp="Dcb_Builder", message)
|
|
440
|
+
}
|
|
441
|
+
})
|
|
442
|
+
)
|
|
443
|
+
|
|
388
444
|
// Warn on composite (multi-tag) decision reads that would silently miss an
|
|
389
445
|
// event carrying extra tags (the tag_composite key is the event's full tag
|
|
390
446
|
// set, so composite reads are exact-match). Non-fatal — today's slices are
|
|
@@ -436,6 +492,7 @@ module Make = (
|
|
|
436
492
|
~indexes,
|
|
437
493
|
~partitionTag,
|
|
438
494
|
~crossPartitionTagKeys=effectiveCrossPartitionTagKeys,
|
|
495
|
+
~pairFenceTypes=effective.crossPartitionPairs->Reventless.DcbScopeInference.pairFenceTypes,
|
|
439
496
|
~opts,
|
|
440
497
|
)
|
|
441
498
|
|
|
@@ -505,6 +562,7 @@ module Make = (
|
|
|
505
562
|
~publishJsons,
|
|
506
563
|
~tagKeysByEventType=effectiveTagKeysByEventType,
|
|
507
564
|
~crossPartitionTagKeys=effectiveCrossPartitionTagKeys,
|
|
565
|
+
~crossPartitionPairs=effective.crossPartitionPairs,
|
|
508
566
|
~partitionTag=?partitionTagOf(StateChangeSlice.Spec.name),
|
|
509
567
|
~runtime=?componentRuntime->Dict.get(StateChangeSlice.Spec.name),
|
|
510
568
|
~opts,
|
|
@@ -526,6 +584,7 @@ module Make = (
|
|
|
526
584
|
~publishJsons=asyncPublishJsons,
|
|
527
585
|
~tagKeysByEventType=effectiveTagKeysByEventType,
|
|
528
586
|
~crossPartitionTagKeys=effectiveCrossPartitionTagKeys,
|
|
587
|
+
~crossPartitionPairs=effective.crossPartitionPairs,
|
|
529
588
|
~partitionTag=?partitionTagOf(StateChangeSlice.Spec.name),
|
|
530
589
|
~runtime=?componentRuntime->Dict.get(StateChangeSlice.Spec.name),
|
|
531
590
|
~opts,
|