@reventlessdev/reventless-core 3.0.0-alpha.341 → 3.0.0-alpha.343
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 +23 -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 +156 -107
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Callback.res.mjs +174 -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
|
@@ -8,7 +8,7 @@ globalThis.describe("Logger.debugLazy", () => {
|
|
|
8
8
|
contents: false
|
|
9
9
|
};
|
|
10
10
|
let log = Logger$ReventlessCore.makeLogger("INFO");
|
|
11
|
-
log.debugLazy("Test", () => {
|
|
11
|
+
log.debugLazy("Test", undefined, () => {
|
|
12
12
|
called.contents = true;
|
|
13
13
|
return "should never be built";
|
|
14
14
|
});
|
|
@@ -19,7 +19,7 @@ globalThis.describe("Logger.debugLazy", () => {
|
|
|
19
19
|
contents: false
|
|
20
20
|
};
|
|
21
21
|
let log = Logger$ReventlessCore.makeLogger("DEBUG");
|
|
22
|
-
log.debugLazy("Test", () => {
|
|
22
|
+
log.debugLazy("Test", undefined, () => {
|
|
23
23
|
called.contents = true;
|
|
24
24
|
return "built";
|
|
25
25
|
});
|
|
@@ -29,7 +29,7 @@ globalThis.describe("Logger.debugLazy", () => {
|
|
|
29
29
|
let called = {
|
|
30
30
|
contents: false
|
|
31
31
|
};
|
|
32
|
-
Logger$ReventlessCore.silent.debugLazy("Test", () => {
|
|
32
|
+
Logger$ReventlessCore.silent.debugLazy("Test", undefined, () => {
|
|
33
33
|
called.contents = true;
|
|
34
34
|
return "x";
|
|
35
35
|
});
|
|
@@ -19,7 +19,7 @@ let Decision = {
|
|
|
19
19
|
moduleUrl: PsGatedCommands$ReventlessCore.moduleUrl
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
function make(param, param$1, param$2, param$3, param$4, param$5, param$6) {
|
|
22
|
+
function make(param, param$1, param$2, param$3, param$4, param$5, param$6, param$7) {
|
|
23
23
|
return 0;
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -32,6 +32,7 @@ module PsPlaceOrderSlice: ReventlessInfra.StateChangeSlice.T = {
|
|
|
32
32
|
~publishJsons as _,
|
|
33
33
|
~tagKeysByEventType as _=?,
|
|
34
34
|
~crossPartitionTagKeys as _=?,
|
|
35
|
+
~crossPartitionPairs as _=?,
|
|
35
36
|
~partitionTag as _=?,
|
|
36
37
|
~runtime as _=?,
|
|
37
38
|
~opts as _=?,
|
|
@@ -53,6 +54,7 @@ module PsShipOrderSlice: ReventlessInfra.StateChangeSlice.T = {
|
|
|
53
54
|
~publishJsons as _,
|
|
54
55
|
~tagKeysByEventType as _=?,
|
|
55
56
|
~crossPartitionTagKeys as _=?,
|
|
57
|
+
~crossPartitionPairs as _=?,
|
|
56
58
|
~partitionTag as _=?,
|
|
57
59
|
~runtime as _=?,
|
|
58
60
|
~opts as _=?,
|
|
@@ -138,6 +140,30 @@ module PsAttachInvoiceSlice: ReventlessInfra.StateChangeSlice.T = {
|
|
|
138
140
|
~publishJsons as _,
|
|
139
141
|
~tagKeysByEventType as _=?,
|
|
140
142
|
~crossPartitionTagKeys as _=?,
|
|
143
|
+
~crossPartitionPairs as _=?,
|
|
144
|
+
~partitionTag as _=?,
|
|
145
|
+
~runtime as _=?,
|
|
146
|
+
~opts as _=?,
|
|
147
|
+
): component => Obj.magic(0)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
module PsRateSessionSlice: ReventlessInfra.StateChangeSlice.T = {
|
|
151
|
+
module Spec = PsRateSession
|
|
152
|
+
module Decision = {
|
|
153
|
+
type state = PsRateSession.state
|
|
154
|
+
let initialState = PsRateSession.initialState
|
|
155
|
+
let evolve = PsRateSession.evolve
|
|
156
|
+
let decide = PsRateSession.decide
|
|
157
|
+
let moduleUrl = PsRateSession.moduleUrl
|
|
158
|
+
}
|
|
159
|
+
let isAsync = false
|
|
160
|
+
type component = scsComponent
|
|
161
|
+
let make = (
|
|
162
|
+
~dcbEventLog as _,
|
|
163
|
+
~publishJsons as _,
|
|
164
|
+
~tagKeysByEventType as _=?,
|
|
165
|
+
~crossPartitionTagKeys as _=?,
|
|
166
|
+
~crossPartitionPairs as _=?,
|
|
141
167
|
~partitionTag as _=?,
|
|
142
168
|
~runtime as _=?,
|
|
143
169
|
~opts as _=?,
|
|
@@ -160,6 +186,7 @@ module PsUploadAvatarSlice: ReventlessInfra.StateChangeSlice.T = {
|
|
|
160
186
|
~publishJsons as _,
|
|
161
187
|
~tagKeysByEventType as _=?,
|
|
162
188
|
~crossPartitionTagKeys as _=?,
|
|
189
|
+
~crossPartitionPairs as _=?,
|
|
163
190
|
~partitionTag as _=?,
|
|
164
191
|
~runtime as _=?,
|
|
165
192
|
~opts as _=?,
|
|
@@ -182,6 +209,7 @@ module PsUploadImagesSlice: ReventlessInfra.StateChangeSlice.T = {
|
|
|
182
209
|
~publishJsons as _,
|
|
183
210
|
~tagKeysByEventType as _=?,
|
|
184
211
|
~crossPartitionTagKeys as _=?,
|
|
212
|
+
~crossPartitionPairs as _=?,
|
|
185
213
|
~partitionTag as _=?,
|
|
186
214
|
~runtime as _=?,
|
|
187
215
|
~opts as _=?,
|
|
@@ -204,6 +232,7 @@ module PsTypoStoreSlice: ReventlessInfra.StateChangeSlice.T = {
|
|
|
204
232
|
~publishJsons as _,
|
|
205
233
|
~tagKeysByEventType as _=?,
|
|
206
234
|
~crossPartitionTagKeys as _=?,
|
|
235
|
+
~crossPartitionPairs as _=?,
|
|
207
236
|
~partitionTag as _=?,
|
|
208
237
|
~runtime as _=?,
|
|
209
238
|
~opts as _=?,
|
|
@@ -226,6 +255,7 @@ module PsChangePhotoSlice: ReventlessInfra.StateChangeSlice.T = {
|
|
|
226
255
|
~publishJsons as _,
|
|
227
256
|
~tagKeysByEventType as _=?,
|
|
228
257
|
~crossPartitionTagKeys as _=?,
|
|
258
|
+
~crossPartitionPairs as _=?,
|
|
229
259
|
~partitionTag as _=?,
|
|
230
260
|
~runtime as _=?,
|
|
231
261
|
~opts as _=?,
|
|
@@ -248,6 +278,7 @@ module PsReserveStockSlice: ReventlessInfra.StateChangeSlice.T = {
|
|
|
248
278
|
~publishJsons as _,
|
|
249
279
|
~tagKeysByEventType as _=?,
|
|
250
280
|
~crossPartitionTagKeys as _=?,
|
|
281
|
+
~crossPartitionPairs as _=?,
|
|
251
282
|
~partitionTag as _=?,
|
|
252
283
|
~runtime as _=?,
|
|
253
284
|
~opts as _=?,
|
|
@@ -270,6 +301,7 @@ module PsDispatchShipmentSlice: ReventlessInfra.StateChangeSlice.T = {
|
|
|
270
301
|
~publishJsons as _,
|
|
271
302
|
~tagKeysByEventType as _=?,
|
|
272
303
|
~crossPartitionTagKeys as _=?,
|
|
304
|
+
~crossPartitionPairs as _=?,
|
|
273
305
|
~partitionTag as _=?,
|
|
274
306
|
~runtime as _=?,
|
|
275
307
|
~opts as _=?,
|
|
@@ -291,6 +323,7 @@ module PsTransitionSwitchSlice: ReventlessInfra.StateChangeSlice.T = {
|
|
|
291
323
|
~publishJsons as _,
|
|
292
324
|
~tagKeysByEventType as _=?,
|
|
293
325
|
~crossPartitionTagKeys as _=?,
|
|
326
|
+
~crossPartitionPairs as _=?,
|
|
294
327
|
~partitionTag as _=?,
|
|
295
328
|
~runtime as _=?,
|
|
296
329
|
~opts as _=?,
|
|
@@ -2030,6 +2063,34 @@ describe("Plugin_Structure.make — Phase 2 graph fields", () => {
|
|
|
2030
2063
|
// A field typed as a storage ref states that the deployment needs that store
|
|
2031
2064
|
// to exist. Collecting the requirement onto the structure is what lets the
|
|
2032
2065
|
// deploy read it without re-walking every component's schema.
|
|
2066
|
+
// A field names its quantity and unit; the structure lists each quantity once,
|
|
2067
|
+
// with its units and factors, so a reader converting between units finds them.
|
|
2068
|
+
describe("quantities", () => {
|
|
2069
|
+
let rated = Plugin_Structure.make(
|
|
2070
|
+
~name="TestPlugin",
|
|
2071
|
+
~stateChangeSlices=[module(PsRateSessionSlice)],
|
|
2072
|
+
)
|
|
2073
|
+
|
|
2074
|
+
testSync(
|
|
2075
|
+
"each quantity the fields measure or price is listed once, nested ones too",
|
|
2076
|
+
() =>
|
|
2077
|
+
expect(rated.quantities)->toEqual(
|
|
2078
|
+
Some([Reventless.Quantity.energy, Reventless.Quantity.power]),
|
|
2079
|
+
),
|
|
2080
|
+
)
|
|
2081
|
+
|
|
2082
|
+
testSync(
|
|
2083
|
+
"a plugin with no quantity lists none",
|
|
2084
|
+
() =>
|
|
2085
|
+
expect(
|
|
2086
|
+
Plugin_Structure.make(
|
|
2087
|
+
~name="TestPlugin",
|
|
2088
|
+
~stateChangeSlices=[module(PsAttachInvoiceSlice)],
|
|
2089
|
+
).quantities,
|
|
2090
|
+
)->toEqual(None),
|
|
2091
|
+
)
|
|
2092
|
+
})
|
|
2093
|
+
|
|
2033
2094
|
describe("requiredStores", () => {
|
|
2034
2095
|
let withStores = Plugin_Structure.make(
|
|
2035
2096
|
~name="TestPlugin",
|
|
@@ -9,6 +9,7 @@ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
|
9
9
|
import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js";
|
|
10
10
|
import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
|
|
11
11
|
import * as DateTime$Reventless from "@reventlessdev/reventless-spec/src/semantic/DateTime.res.mjs";
|
|
12
|
+
import * as Quantity$Reventless from "@reventlessdev/reventless-spec/src/semantic/Quantity.res.mjs";
|
|
12
13
|
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
13
14
|
import * as Reference$Reventless from "@reventlessdev/reventless-spec/src/components/Reference.res.mjs";
|
|
14
15
|
import * as Sensitive$Reventless from "@reventlessdev/reventless-spec/src/components/Sensitive.res.mjs";
|
|
@@ -22,6 +23,7 @@ import * as PsPlaceOrder$ReventlessCore from "./StateChange/PsPlaceOrder.res.mjs
|
|
|
22
23
|
import * as PsStatusView$ReventlessCore from "./StateView/PsStatusView.res.mjs";
|
|
23
24
|
import * as StateAnnotations$Reventless from "@reventlessdev/reventless-spec/src/components/StateAnnotations.res.mjs";
|
|
24
25
|
import * as PsChangePhoto$ReventlessCore from "./StateChange/PsChangePhoto.res.mjs";
|
|
26
|
+
import * as PsRateSession$ReventlessCore from "./StateChange/PsRateSession.res.mjs";
|
|
25
27
|
import * as CapabilityManifest$Reventless from "@reventlessdev/reventless-spec/src/components/CapabilityManifest.res.mjs";
|
|
26
28
|
import * as PsReserveStock$ReventlessCore from "./StateChange/PsReserveStock.res.mjs";
|
|
27
29
|
import * as PsUploadAvatar$ReventlessCore from "./StateChange/PsUploadAvatar.res.mjs";
|
|
@@ -44,7 +46,7 @@ let Decision = {
|
|
|
44
46
|
moduleUrl: PsPlaceOrder$ReventlessCore.moduleUrl
|
|
45
47
|
};
|
|
46
48
|
|
|
47
|
-
function make(param, param$1, param$2, param$3, param$4, param$5, param$6) {
|
|
49
|
+
function make(param, param$1, param$2, param$3, param$4, param$5, param$6, param$7) {
|
|
48
50
|
return 0;
|
|
49
51
|
}
|
|
50
52
|
|
|
@@ -75,7 +77,7 @@ let Decision$1 = {
|
|
|
75
77
|
moduleUrl: PsShipOrder$ReventlessCore.moduleUrl
|
|
76
78
|
};
|
|
77
79
|
|
|
78
|
-
function make$1(param, param$1, param$2, param$3, param$4, param$5, param$6) {
|
|
80
|
+
function make$1(param, param$1, param$2, param$3, param$4, param$5, param$6, param$7) {
|
|
79
81
|
return 0;
|
|
80
82
|
}
|
|
81
83
|
|
|
@@ -337,7 +339,7 @@ let Decision$2 = {
|
|
|
337
339
|
moduleUrl: PsAttachInvoice$ReventlessCore.moduleUrl
|
|
338
340
|
};
|
|
339
341
|
|
|
340
|
-
function make$9(param, param$1, param$2, param$3, param$4, param$5, param$6) {
|
|
342
|
+
function make$9(param, param$1, param$2, param$3, param$4, param$5, param$6, param$7) {
|
|
341
343
|
return 0;
|
|
342
344
|
}
|
|
343
345
|
|
|
@@ -362,13 +364,44 @@ let PsAttachInvoiceSlice = {
|
|
|
362
364
|
};
|
|
363
365
|
|
|
364
366
|
let Decision$3 = {
|
|
367
|
+
initialState: false,
|
|
368
|
+
evolve: PsRateSession$ReventlessCore.evolve,
|
|
369
|
+
decide: PsRateSession$ReventlessCore.decide,
|
|
370
|
+
moduleUrl: PsRateSession$ReventlessCore.moduleUrl
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
function make$10(param, param$1, param$2, param$3, param$4, param$5, param$6, param$7) {
|
|
374
|
+
return 0;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
let PsRateSessionSlice_Spec = {
|
|
378
|
+
name: PsRateSession$ReventlessCore.name,
|
|
379
|
+
moduleUrl: PsRateSession$ReventlessCore.moduleUrl,
|
|
380
|
+
consumedEventSchema: PsRateSession$ReventlessCore.consumedEventSchema,
|
|
381
|
+
errorSchema: PsRateSession$ReventlessCore.errorSchema,
|
|
382
|
+
eventSchema: PsRateSession$ReventlessCore.eventSchema,
|
|
383
|
+
commandSchema: PsRateSession$ReventlessCore.commandSchema,
|
|
384
|
+
authorizationOf: PsRateSession$ReventlessCore.authorizationOf,
|
|
385
|
+
commandTransition: PsRateSession$ReventlessCore.commandTransition,
|
|
386
|
+
traits: PsRateSession$ReventlessCore.traits,
|
|
387
|
+
readConsistency: PsRateSession$ReventlessCore.readConsistency
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
let PsRateSessionSlice = {
|
|
391
|
+
Spec: PsRateSessionSlice_Spec,
|
|
392
|
+
Decision: Decision$3,
|
|
393
|
+
isAsync: false,
|
|
394
|
+
make: make$10
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
let Decision$4 = {
|
|
365
398
|
initialState: false,
|
|
366
399
|
evolve: PsUploadAvatar$ReventlessCore.evolve,
|
|
367
400
|
decide: PsUploadAvatar$ReventlessCore.decide,
|
|
368
401
|
moduleUrl: PsUploadAvatar$ReventlessCore.moduleUrl
|
|
369
402
|
};
|
|
370
403
|
|
|
371
|
-
function make$
|
|
404
|
+
function make$11(param, param$1, param$2, param$3, param$4, param$5, param$6, param$7) {
|
|
372
405
|
return 0;
|
|
373
406
|
}
|
|
374
407
|
|
|
@@ -387,19 +420,19 @@ let PsUploadAvatarSlice_Spec = {
|
|
|
387
420
|
|
|
388
421
|
let PsUploadAvatarSlice = {
|
|
389
422
|
Spec: PsUploadAvatarSlice_Spec,
|
|
390
|
-
Decision: Decision$
|
|
423
|
+
Decision: Decision$4,
|
|
391
424
|
isAsync: false,
|
|
392
|
-
make: make$
|
|
425
|
+
make: make$11
|
|
393
426
|
};
|
|
394
427
|
|
|
395
|
-
let Decision$
|
|
428
|
+
let Decision$5 = {
|
|
396
429
|
initialState: false,
|
|
397
430
|
evolve: PsUploadImages$ReventlessCore.evolve,
|
|
398
431
|
decide: PsUploadImages$ReventlessCore.decide,
|
|
399
432
|
moduleUrl: PsUploadImages$ReventlessCore.moduleUrl
|
|
400
433
|
};
|
|
401
434
|
|
|
402
|
-
function make$
|
|
435
|
+
function make$12(param, param$1, param$2, param$3, param$4, param$5, param$6, param$7) {
|
|
403
436
|
return 0;
|
|
404
437
|
}
|
|
405
438
|
|
|
@@ -418,19 +451,19 @@ let PsUploadImagesSlice_Spec = {
|
|
|
418
451
|
|
|
419
452
|
let PsUploadImagesSlice = {
|
|
420
453
|
Spec: PsUploadImagesSlice_Spec,
|
|
421
|
-
Decision: Decision$
|
|
454
|
+
Decision: Decision$5,
|
|
422
455
|
isAsync: false,
|
|
423
|
-
make: make$
|
|
456
|
+
make: make$12
|
|
424
457
|
};
|
|
425
458
|
|
|
426
|
-
let Decision$
|
|
459
|
+
let Decision$6 = {
|
|
427
460
|
initialState: false,
|
|
428
461
|
evolve: PsTypoStore$ReventlessCore.evolve,
|
|
429
462
|
decide: PsTypoStore$ReventlessCore.decide,
|
|
430
463
|
moduleUrl: PsTypoStore$ReventlessCore.moduleUrl
|
|
431
464
|
};
|
|
432
465
|
|
|
433
|
-
function make$
|
|
466
|
+
function make$13(param, param$1, param$2, param$3, param$4, param$5, param$6, param$7) {
|
|
434
467
|
return 0;
|
|
435
468
|
}
|
|
436
469
|
|
|
@@ -449,19 +482,19 @@ let PsTypoStoreSlice_Spec = {
|
|
|
449
482
|
|
|
450
483
|
let PsTypoStoreSlice = {
|
|
451
484
|
Spec: PsTypoStoreSlice_Spec,
|
|
452
|
-
Decision: Decision$
|
|
485
|
+
Decision: Decision$6,
|
|
453
486
|
isAsync: false,
|
|
454
|
-
make: make$
|
|
487
|
+
make: make$13
|
|
455
488
|
};
|
|
456
489
|
|
|
457
|
-
let Decision$
|
|
490
|
+
let Decision$7 = {
|
|
458
491
|
initialState: false,
|
|
459
492
|
evolve: PsChangePhoto$ReventlessCore.evolve,
|
|
460
493
|
decide: PsChangePhoto$ReventlessCore.decide,
|
|
461
494
|
moduleUrl: PsChangePhoto$ReventlessCore.moduleUrl
|
|
462
495
|
};
|
|
463
496
|
|
|
464
|
-
function make$
|
|
497
|
+
function make$14(param, param$1, param$2, param$3, param$4, param$5, param$6, param$7) {
|
|
465
498
|
return 0;
|
|
466
499
|
}
|
|
467
500
|
|
|
@@ -480,19 +513,19 @@ let PsChangePhotoSlice_Spec = {
|
|
|
480
513
|
|
|
481
514
|
let PsChangePhotoSlice = {
|
|
482
515
|
Spec: PsChangePhotoSlice_Spec,
|
|
483
|
-
Decision: Decision$
|
|
516
|
+
Decision: Decision$7,
|
|
484
517
|
isAsync: false,
|
|
485
|
-
make: make$
|
|
518
|
+
make: make$14
|
|
486
519
|
};
|
|
487
520
|
|
|
488
|
-
let Decision$
|
|
521
|
+
let Decision$8 = {
|
|
489
522
|
initialState: false,
|
|
490
523
|
evolve: PsReserveStock$ReventlessCore.evolve,
|
|
491
524
|
decide: PsReserveStock$ReventlessCore.decide,
|
|
492
525
|
moduleUrl: PsReserveStock$ReventlessCore.moduleUrl
|
|
493
526
|
};
|
|
494
527
|
|
|
495
|
-
function make$
|
|
528
|
+
function make$15(param, param$1, param$2, param$3, param$4, param$5, param$6, param$7) {
|
|
496
529
|
return 0;
|
|
497
530
|
}
|
|
498
531
|
|
|
@@ -511,19 +544,19 @@ let PsReserveStockSlice_Spec = {
|
|
|
511
544
|
|
|
512
545
|
let PsReserveStockSlice = {
|
|
513
546
|
Spec: PsReserveStockSlice_Spec,
|
|
514
|
-
Decision: Decision$
|
|
547
|
+
Decision: Decision$8,
|
|
515
548
|
isAsync: false,
|
|
516
|
-
make: make$
|
|
549
|
+
make: make$15
|
|
517
550
|
};
|
|
518
551
|
|
|
519
|
-
let Decision$
|
|
552
|
+
let Decision$9 = {
|
|
520
553
|
initialState: false,
|
|
521
554
|
evolve: PsDispatchShipment$ReventlessCore.evolve,
|
|
522
555
|
decide: PsDispatchShipment$ReventlessCore.decide,
|
|
523
556
|
moduleUrl: PsDispatchShipment$ReventlessCore.moduleUrl
|
|
524
557
|
};
|
|
525
558
|
|
|
526
|
-
function make$
|
|
559
|
+
function make$16(param, param$1, param$2, param$3, param$4, param$5, param$6, param$7) {
|
|
527
560
|
return 0;
|
|
528
561
|
}
|
|
529
562
|
|
|
@@ -542,19 +575,19 @@ let PsDispatchShipmentSlice_Spec = {
|
|
|
542
575
|
|
|
543
576
|
let PsDispatchShipmentSlice = {
|
|
544
577
|
Spec: PsDispatchShipmentSlice_Spec,
|
|
545
|
-
Decision: Decision$
|
|
578
|
+
Decision: Decision$9,
|
|
546
579
|
isAsync: false,
|
|
547
|
-
make: make$
|
|
580
|
+
make: make$16
|
|
548
581
|
};
|
|
549
582
|
|
|
550
|
-
let Decision$
|
|
583
|
+
let Decision$10 = {
|
|
551
584
|
initialState: false,
|
|
552
585
|
evolve: PsTransitionSwitch$ReventlessCore.evolve,
|
|
553
586
|
decide: PsTransitionSwitch$ReventlessCore.decide,
|
|
554
587
|
moduleUrl: PsTransitionSwitch$ReventlessCore.moduleUrl
|
|
555
588
|
};
|
|
556
589
|
|
|
557
|
-
function make$
|
|
590
|
+
function make$17(param, param$1, param$2, param$3, param$4, param$5, param$6, param$7) {
|
|
558
591
|
return 0;
|
|
559
592
|
}
|
|
560
593
|
|
|
@@ -573,9 +606,9 @@ let PsTransitionSwitchSlice_Spec = {
|
|
|
573
606
|
|
|
574
607
|
let PsTransitionSwitchSlice = {
|
|
575
608
|
Spec: PsTransitionSwitchSlice_Spec,
|
|
576
|
-
Decision: Decision$
|
|
609
|
+
Decision: Decision$10,
|
|
577
610
|
isAsync: false,
|
|
578
|
-
make: make$
|
|
611
|
+
make: make$17
|
|
579
612
|
};
|
|
580
613
|
|
|
581
614
|
let Projection$7 = {
|
|
@@ -583,7 +616,7 @@ let Projection$7 = {
|
|
|
583
616
|
moduleUrl: PsShipmentsView$ReventlessCore.moduleUrl
|
|
584
617
|
};
|
|
585
618
|
|
|
586
|
-
function make$
|
|
619
|
+
function make$18(param, param$1, param$2) {
|
|
587
620
|
return 0;
|
|
588
621
|
}
|
|
589
622
|
|
|
@@ -608,7 +641,7 @@ let PsShipmentsViewSlice_Spec = {
|
|
|
608
641
|
let PsShipmentsViewSlice = {
|
|
609
642
|
Spec: PsShipmentsViewSlice_Spec,
|
|
610
643
|
Projection: Projection$7,
|
|
611
|
-
make: make$
|
|
644
|
+
make: make$18
|
|
612
645
|
};
|
|
613
646
|
|
|
614
647
|
let structure = Plugin_Structure$ReventlessCore.make("TestPlugin", undefined, undefined, [
|
|
@@ -1773,6 +1806,18 @@ globalThis.describe("Plugin_Structure.make — Phase 2 graph fields", () => {
|
|
|
1773
1806
|
globalThis.expect(placeOrder.chapter).toEqual(undefined);
|
|
1774
1807
|
});
|
|
1775
1808
|
});
|
|
1809
|
+
globalThis.describe("quantities", () => {
|
|
1810
|
+
let rated = Plugin_Structure$ReventlessCore.make("TestPlugin", undefined, undefined, undefined, [PsRateSessionSlice], undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
|
|
1811
|
+
globalThis.test("each quantity the fields measure or price is listed once, nested ones too", () => {
|
|
1812
|
+
globalThis.expect(rated.quantities).toEqual([
|
|
1813
|
+
Quantity$Reventless.energy,
|
|
1814
|
+
Quantity$Reventless.power
|
|
1815
|
+
]);
|
|
1816
|
+
});
|
|
1817
|
+
globalThis.test("a plugin with no quantity lists none", () => {
|
|
1818
|
+
globalThis.expect(Plugin_Structure$ReventlessCore.make("TestPlugin", undefined, undefined, undefined, [PsAttachInvoiceSlice], undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined).quantities).toEqual(undefined);
|
|
1819
|
+
});
|
|
1820
|
+
});
|
|
1776
1821
|
globalThis.describe("requiredStores", () => {
|
|
1777
1822
|
let withStores = Plugin_Structure$ReventlessCore.make("TestPlugin", undefined, undefined, undefined, [PsAttachInvoiceSlice], undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
|
|
1778
1823
|
let stores = Stdlib_Option.getOr(withStores.requiredStores, []);
|
|
@@ -2482,6 +2527,7 @@ export {
|
|
|
2482
2527
|
PsPeopleViewSlice,
|
|
2483
2528
|
PsStatusViewSlice,
|
|
2484
2529
|
PsAttachInvoiceSlice,
|
|
2530
|
+
PsRateSessionSlice,
|
|
2485
2531
|
PsUploadAvatarSlice,
|
|
2486
2532
|
PsUploadImagesSlice,
|
|
2487
2533
|
PsTypoStoreSlice,
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Test fixture spec for collecting quantities onto the structure.
|
|
2
|
+
//
|
|
3
|
+
// Energy twice (command and event) and in two units, a price per kWh, and power
|
|
4
|
+
// inside a list of records, so the structure lists each quantity once, finds one
|
|
5
|
+
// nested in a list, and counts a price's quantity as one the plugin uses.
|
|
6
|
+
|
|
7
|
+
@@reventless.spec("RateSession")
|
|
8
|
+
|
|
9
|
+
type state = bool
|
|
10
|
+
let initialState = false
|
|
11
|
+
|
|
12
|
+
@schema
|
|
13
|
+
type consumedEvent = SessionStarted
|
|
14
|
+
|
|
15
|
+
let evolve = (_state, _event) => true
|
|
16
|
+
|
|
17
|
+
@schema
|
|
18
|
+
type reading = {at: string, power: @s.matches(Reventless.Power.kilowatt) float}
|
|
19
|
+
|
|
20
|
+
@schema
|
|
21
|
+
type command =
|
|
22
|
+
| RateSession({
|
|
23
|
+
sessionId: string,
|
|
24
|
+
delivered: @s.matches(Reventless.Energy.kilowattHour) float,
|
|
25
|
+
price: @s.matches(Reventless.PricePer.unit(Reventless.Energy.kilowattHour))
|
|
26
|
+
Reventless.Money.t,
|
|
27
|
+
readings: array<reading>,
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
@schema
|
|
31
|
+
type error = SessionNotFound
|
|
32
|
+
|
|
33
|
+
@schema
|
|
34
|
+
type event =
|
|
35
|
+
SessionRated({sessionId: string, delivered: @s.matches(Reventless.Energy.megawattHour) float})
|
|
36
|
+
|
|
37
|
+
let decide = (_state, _command): result<array<event>, error> => Ok([])
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Sury from "sury";
|
|
4
|
+
import * as Power$Reventless from "@reventlessdev/reventless-spec/src/semantic/Power.res.mjs";
|
|
5
|
+
import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
|
|
6
|
+
import * as Energy$Reventless from "@reventlessdev/reventless-spec/src/semantic/Energy.res.mjs";
|
|
7
|
+
import * as PricePer$Reventless from "@reventlessdev/reventless-spec/src/semantic/PricePer.res.mjs";
|
|
8
|
+
|
|
9
|
+
let consumedEventSchema = Sury.literal("SessionStarted");
|
|
10
|
+
|
|
11
|
+
function evolve(_state, _event) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let readingSchema = Sury.$schema(s => ({
|
|
16
|
+
at: s.m(Sury.string),
|
|
17
|
+
power: s.m(Power$Reventless.kilowatt)
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
let commandSchema = Sury.$schema(s => ({
|
|
21
|
+
TAG: "RateSession",
|
|
22
|
+
sessionId: s.m(DcbTag$Reventless.string),
|
|
23
|
+
delivered: s.m(Energy$Reventless.kilowattHour),
|
|
24
|
+
price: s.m(PricePer$Reventless.unit(Energy$Reventless.kilowattHour)),
|
|
25
|
+
readings: s.m(Sury.array(readingSchema))
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
let errorSchema = Sury.literal("SessionNotFound");
|
|
29
|
+
|
|
30
|
+
let eventSchema = Sury.$schema(s => ({
|
|
31
|
+
TAG: "SessionRated",
|
|
32
|
+
sessionId: s.m(DcbTag$Reventless.string),
|
|
33
|
+
delivered: s.m(Energy$Reventless.megawattHour)
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
function decide(_state, _command) {
|
|
37
|
+
return {
|
|
38
|
+
TAG: "Ok",
|
|
39
|
+
_0: []
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function authorizationOf(param) {
|
|
44
|
+
return "AllowAuthenticated";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function commandTransition(param) {
|
|
48
|
+
return "Undeclared";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
let traits = [];
|
|
52
|
+
|
|
53
|
+
let name = "RateSession";
|
|
54
|
+
|
|
55
|
+
let Id;
|
|
56
|
+
|
|
57
|
+
let initialState = false;
|
|
58
|
+
|
|
59
|
+
let moduleUrl = "@reventlessdev/reventless-core/tests/plugin/StateChange/PsRateSession.res.mjs";
|
|
60
|
+
|
|
61
|
+
let readConsistency = "EscalateOnRetry";
|
|
62
|
+
|
|
63
|
+
export {
|
|
64
|
+
name,
|
|
65
|
+
Id,
|
|
66
|
+
initialState,
|
|
67
|
+
consumedEventSchema,
|
|
68
|
+
evolve,
|
|
69
|
+
readingSchema,
|
|
70
|
+
commandSchema,
|
|
71
|
+
errorSchema,
|
|
72
|
+
eventSchema,
|
|
73
|
+
decide,
|
|
74
|
+
moduleUrl,
|
|
75
|
+
authorizationOf,
|
|
76
|
+
readConsistency,
|
|
77
|
+
commandTransition,
|
|
78
|
+
traits,
|
|
79
|
+
}
|
|
80
|
+
/* consumedEventSchema Not a pure module */
|
|
@@ -112,6 +112,16 @@
|
|
|
112
112
|
.structure.outboundTranslationSlices[].consumedSources[]: string
|
|
113
113
|
.structure.outboundTranslationSlices[].inboundCommandTypes[]: string
|
|
114
114
|
.structure.outboundTranslationSlices[].name: string
|
|
115
|
+
# `quantities` is itself optional and is NEW, so no persisted payload carries the
|
|
116
|
+
# array: a stored structure heals to `None` and these six are never reached.
|
|
117
|
+
# Required inside it because a quantity is its name and its units' factors; a
|
|
118
|
+
# fabricated `0` factor would convert every stored number to nothing.
|
|
119
|
+
.structure.quantities[].adds: boolean
|
|
120
|
+
.structure.quantities[].name: string
|
|
121
|
+
.structure.quantities[].units[].code: string
|
|
122
|
+
.structure.quantities[].units[].factor: number
|
|
123
|
+
.structure.quantities[].units[].plural: string
|
|
124
|
+
.structure.quantities[].units[].words: string
|
|
115
125
|
.structure.readModels[].consumedEventTypes[]: string
|
|
116
126
|
.structure.readModels[].labelField: string
|
|
117
127
|
.structure.readModels[].linkedWriteSide[]: string
|
|
@@ -170,4 +170,36 @@ describe("ViewChange", () => {
|
|
|
170
170
|
->Option.mapOr(false, s => s->String.includes("new-secret")),
|
|
171
171
|
)->toBe(true)
|
|
172
172
|
})
|
|
173
|
+
|
|
174
|
+
testPromise("the action line carries the ids of the event it came from", async () => {
|
|
175
|
+
let actionLines = async sources => {
|
|
176
|
+
let lines = []
|
|
177
|
+
let removeSink = Logger.addSink(r => lines->Array.push(r))
|
|
178
|
+
Logger.setDefaultMinLevel(Debug)
|
|
179
|
+
let (_, ops) = makeOps()
|
|
180
|
+
let _ = await Projection.handleAction(
|
|
181
|
+
~sources,
|
|
182
|
+
Set("a", {name: "A", total: 1, token: "t"}),
|
|
183
|
+
ops,
|
|
184
|
+
None,
|
|
185
|
+
)
|
|
186
|
+
Logger.setDefaultMinLevel(Info)
|
|
187
|
+
removeSink()
|
|
188
|
+
lines->Array.filter(r => r.message->String.startsWith("handling action"))
|
|
189
|
+
}
|
|
190
|
+
let one = await actionLines([source("m-1")])
|
|
191
|
+
expect(
|
|
192
|
+
one->Array.map(
|
|
193
|
+
r =>
|
|
194
|
+
["msgId", "correlationId", "entityId", "entityType"]->Array.map(
|
|
195
|
+
k => r.annotations->Dict.get(k),
|
|
196
|
+
),
|
|
197
|
+
),
|
|
198
|
+
)->toEqual([[Some("m-1"), Some("flow-1"), Some("order-1"), Some("Order")]])
|
|
199
|
+
// Several events: only the flow they share.
|
|
200
|
+
let merged = await actionLines([source("m-1"), source("m-2")])
|
|
201
|
+
expect(merged->Array.map(r => r.annotations))->toEqual([
|
|
202
|
+
Dict.fromArray([("correlationId", "flow-1")]),
|
|
203
|
+
])
|
|
204
|
+
})
|
|
173
205
|
})
|