@reventlessdev/reventless-gwt 1.0.0-alpha.291 → 1.0.0-alpha.293

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 CHANGED
@@ -3,6 +3,23 @@
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
+ # 1.0.0-alpha.293 (2026-11-21)
7
+
8
+ ### Features
9
+
10
+ * **gwt:** a flow runs what was sent, states rows and acceptance, and keeps time ([0d418c9](https://github.com/ReventlessDev/reventless-core/commit/0d418c9f890a4255d5b906f1246ccb705d3a9a6a))
11
+ * **gwt:** a flow says who acts, reacts once, and starts after another ([1cae4fc](https://github.com/ReventlessDev/reventless-core/commit/1cae4fcc3d0a3c2743efaba0ea876ff3e02664ec))
12
+ * **gwt:** a plugin's flow steps come ready-made, and a failure names its step ([861bb08](https://github.com/ReventlessDev/reventless-core/commit/861bb08cea20b006fd44f08b6c10c51774487faf))
13
+ * **gwt:** a system's boundary is tested without a test written, and a flow reaches every part ([9475f85](https://github.com/ReventlessDev/reventless-core/commit/9475f858027b55a819b5132b25b9d2e186ade934))
14
+
15
+
16
+ # 1.0.0-alpha.292 (2026-11-20)
17
+
18
+ ### Features
19
+
20
+ * **spec:** a translation tells one thing something through a devices capability ([548f28b](https://github.com/ReventlessDev/reventless-core/commit/548f28bcff1caa6f40273619826a387f0bcf9b70))
21
+
22
+
6
23
  # 1.0.0-alpha.291 (2026-11-19)
7
24
 
8
25
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reventlessdev/reventless-gwt",
3
- "version": "1.0.0-alpha.291",
3
+ "version": "1.0.0-alpha.293",
4
4
  "description": "Given-When-Then DSLs and test harness for Reventless slice testing",
5
5
  "license": "Apache-2.0",
6
6
  "jest": {
@@ -14,17 +14,17 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "sury": "11.1.0",
17
- "@reventlessdev/rescript-effect": "1.0.0-alpha.3",
18
- "@reventlessdev/rescript-jest": "1.0.0-alpha.13",
17
+ "@reventlessdev/rescript-effect": "1.0.0-alpha.4",
19
18
  "@reventlessdev/rescript-node": "2.0.0-alpha.26",
20
- "@reventlessdev/reventless-core": "3.0.0-alpha.342",
21
- "@reventlessdev/reventless-infra": "3.0.0-alpha.235",
22
- "@reventlessdev/reventless-spec": "3.0.0-alpha.204"
19
+ "@reventlessdev/reventless-infra": "3.0.0-alpha.237",
20
+ "@reventlessdev/reventless-spec": "3.0.0-alpha.206",
21
+ "@reventlessdev/rescript-jest": "1.0.0-alpha.14",
22
+ "@reventlessdev/reventless-core": "3.0.0-alpha.344"
23
23
  },
24
24
  "devDependencies": {
25
25
  "rescript": "12.3.1",
26
26
  "sury-ppx": "11.1.0",
27
- "@reventlessdev/reventless-ppx": "1.0.0-alpha.114"
27
+ "@reventlessdev/reventless-ppx": "1.0.0-alpha.116"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "rescript": "^12.3.1"
@@ -0,0 +1,57 @@
1
+ // Whether a DCB consistency boundary derives its tag scope over all its slices.
2
+ //
3
+ // One slice's own test cannot show this: a single slice always resolves, so the
4
+ // all-or-nothing fallback in `deriveEffectiveScope` (one unresolvable slice
5
+ // discarding the derived scope for every slice beside it) has no per-slice
6
+ // symptom. The slices keep passing their own tests while the platform rejects
7
+ // valid commands. `generate-plugin` writes this test for every system, over its
8
+ // `Plugin.dcbSliceSchemas`, so the boundary is checked as deployed with no test
9
+ // written for it.
10
+
11
+ let resolves = (~name: string, slices: array<Reventless.DcbTag.sliceSchemas>): Outcome.outcome => {
12
+ let scope = Reventless.DcbTag.deriveEffectiveScope(slices)
13
+ // Deploy and boot derive the storage partition from the same slices and refuse
14
+ // the boundary when it fails, so the test fails with their reasons.
15
+ let partitionReasons = {
16
+ let shapes = slices->Array.map(Reventless.DcbTag.sliceShape)
17
+ let hints = Reventless.DcbValidation.validatePartitionHintsVsInference(~shapes)
18
+ let arms = Reventless.DcbValidation.validateCrossPartitionArms(
19
+ ~shapes,
20
+ ~inferred=Reventless.DcbScopeInference.infer(shapes),
21
+ )
22
+ let contradictions =
23
+ hints.contradictions
24
+ ->Array.concat(arms.contradictions)
25
+ ->Array.map(e => `${e.sliceName}: ${e.message}`)
26
+ switch Reventless.DcbTag.deriveBoundaryPartition(slices) {
27
+ | _ => contradictions
28
+ | exception JsExn(err) =>
29
+ contradictions->Array.concat([
30
+ JsExn.message(err)->Option.getOr("partition derivation failed"),
31
+ ])
32
+ }
33
+ }
34
+
35
+ // Beyond that, an ambiguity that costs nothing is not a failure: a boundary whose
36
+ // fallback carries every derived key reads exactly as the derivation would. What
37
+ // fails is losing a key, because that is the case where the runtime answers wrongly.
38
+ if partitionReasons->Array.length > 0 {
39
+ Outcome.fail(PartitionUnresolved({boundary: name, reasons: partitionReasons}))
40
+ } else if scope.droppedCrossPartitionTagKeys->Array.length > 0 {
41
+ Outcome.fail(
42
+ ScopeDegraded({
43
+ boundary: name,
44
+ dropped: scope.droppedCrossPartitionTagKeys,
45
+ ambiguities: scope.ambiguities->Array.map(((slice, reason)) => `${slice}: ${reason}`),
46
+ }),
47
+ )
48
+ } else {
49
+ Outcome.pass
50
+ }
51
+ }
52
+
53
+ /** The test of one system's boundary, named for the system. */
54
+ let test = (~system: string, slices: array<Reventless.DcbTag.sliceSchemas>) =>
55
+ JestBind.test(~slice=system, `the ${system} boundary derives its DCB scope`, () =>
56
+ resolves(~name=system, slices)
57
+ )
@@ -0,0 +1,56 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.js";
4
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
5
+ import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
6
+ import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
7
+ import * as Outcome$ReventlessGwt from "./Outcome.res.mjs";
8
+ import * as JestBind$ReventlessGwt from "./JestBind.res.mjs";
9
+ import * as DcbValidation$Reventless from "@reventlessdev/reventless-spec/src/components/DcbValidation.res.mjs";
10
+ import * as DcbScopeInference$Reventless from "@reventlessdev/reventless-spec/src/components/DcbScopeInference.res.mjs";
11
+
12
+ function resolves(name, slices) {
13
+ let scope = DcbTag$Reventless.deriveEffectiveScope(slices);
14
+ let shapes = slices.map(DcbTag$Reventless.sliceShape);
15
+ let hints = DcbValidation$Reventless.validatePartitionHintsVsInference(shapes);
16
+ let arms = DcbValidation$Reventless.validateCrossPartitionArms(shapes, DcbScopeInference$Reventless.infer(shapes));
17
+ let contradictions = hints.contradictions.concat(arms.contradictions).map(e => e.sliceName + `: ` + e.message);
18
+ let partitionReasons;
19
+ try {
20
+ DcbTag$Reventless.deriveBoundaryPartition(slices);
21
+ partitionReasons = contradictions;
22
+ } catch (raw_err) {
23
+ let err = Primitive_exceptions.internalToException(raw_err);
24
+ if (err.RE_EXN_ID === "JsExn") {
25
+ partitionReasons = contradictions.concat([Stdlib_Option.getOr(Stdlib_JsExn.message(err._1), "partition derivation failed")]);
26
+ } else {
27
+ throw err;
28
+ }
29
+ }
30
+ if (partitionReasons.length !== 0) {
31
+ return Outcome$ReventlessGwt.fail({
32
+ TAG: "PartitionUnresolved",
33
+ boundary: name,
34
+ reasons: partitionReasons
35
+ });
36
+ } else if (scope.droppedCrossPartitionTagKeys.length !== 0) {
37
+ return Outcome$ReventlessGwt.fail({
38
+ TAG: "ScopeDegraded",
39
+ boundary: name,
40
+ dropped: scope.droppedCrossPartitionTagKeys,
41
+ ambiguities: scope.ambiguities.map(param => param[0] + `: ` + param[1])
42
+ });
43
+ } else {
44
+ return Outcome$ReventlessGwt.pass;
45
+ }
46
+ }
47
+
48
+ function test(system, slices) {
49
+ JestBind$ReventlessGwt.test(system, `the ` + system + ` boundary derives its DCB scope`, () => resolves(system, slices));
50
+ }
51
+
52
+ export {
53
+ resolves,
54
+ test,
55
+ }
56
+ /* Stdlib_JsExn Not a pure module */
@@ -28,6 +28,8 @@ type call =
28
28
  assert which secret was handed over — a fake has no log to keep it out of. */
29
29
  | Stashed({key: string, value: string, ttl: Reventless.Duration.t})
30
30
  | Taken({key: string})
31
+ /** A thing told something, by kind and instance. */
32
+ | Told({kind: string, instance: string, message: string, body: JSON.t})
31
33
 
32
34
  type t = {
33
35
  capabilities: Capabilities.t,
@@ -43,7 +45,8 @@ that prefixes `"hash:"`. `~secrets` replaces the secret source whole, e.g. with
43
45
  `Secrets.unavailable`; its calls are still recorded. The stash holds what is put
44
46
  in it and hands each value over once, starting from `~stashed`; `~stash`
45
47
  replaces it whole, e.g. with `Stash.unavailable`. `~text` is the deployment's
46
- languages and catalogue; without it every message is in its English.
48
+ languages and catalogue; without it every message is in its English. A thing told
49
+ something accepts it unless `~tell` answers otherwise.
47
50
  */
48
51
  let make = (
49
52
  ~geocode: option<Geocoding.search>=?,
@@ -63,6 +66,14 @@ let make = (
63
66
  ~stashed: array<(string, string)>=[],
64
67
  ~stash: option<Stash.t>=?,
65
68
  ~text: Text.t=Text.sourceOnly,
69
+ ~tell: option<
70
+ (
71
+ ~kind: string,
72
+ ~instance: string,
73
+ ~message: string,
74
+ ~body: JSON.t,
75
+ ) => promise<Reventless.Devices.answer>,
76
+ >=?,
66
77
  (),
67
78
  ): t => {
68
79
  let log: array<call> = []
@@ -151,6 +162,15 @@ let make = (
151
162
  },
152
163
  },
153
164
  text,
165
+ devices: {
166
+ tell: async (~kind, ~instance, ~message, ~body) => {
167
+ record(Told({kind, instance, message, body}))
168
+ switch tell {
169
+ | Some(f) => await f(~kind, ~instance, ~message, ~body)
170
+ | None => Accepted
171
+ }
172
+ },
173
+ },
154
174
  }
155
175
  {capabilities, calls: () => log->Array.copy}
156
176
  }
@@ -196,5 +216,10 @@ let toJson = (c: call): JSON.t => {
196
216
  | Hashed({input}) => obj("Hashed", [("input", str(input))])
197
217
  | Stashed({key, ttl, _}) => obj("Stashed", [("key", str(key)), ("ttl", JSON.Encode.int(ttl))])
198
218
  | Taken({key}) => obj("Taken", [("key", str(key))])
219
+ | Told({kind, instance, message, body}) =>
220
+ obj(
221
+ "Told",
222
+ [("kind", str(kind)), ("instance", str(instance)), ("message", str(message)), ("body", body)],
223
+ )
199
224
  }
200
225
  }
@@ -8,7 +8,7 @@ import * as Secrets$Reventless from "@reventlessdev/reventless-spec/src/semantic
8
8
  import * as Messaging$Reventless from "@reventlessdev/reventless-spec/src/semantic/Messaging.res.mjs";
9
9
  import * as IdentityProvider$Reventless from "@reventlessdev/reventless-spec/src/semantic/IdentityProvider.res.mjs";
10
10
 
11
- function make(geocode, send, channelsOpt, pushServicesOpt, createPrincipal, token, hash, secrets, stashedOpt, stash, textOpt, param) {
11
+ function make(geocode, send, channelsOpt, pushServicesOpt, createPrincipal, token, hash, secrets, stashedOpt, stash, textOpt, tell, param) {
12
12
  let channels = channelsOpt !== undefined ? channelsOpt : [
13
13
  "Email",
14
14
  "Sms"
@@ -178,13 +178,30 @@ function make(geocode, send, channelsOpt, pushServicesOpt, createPrincipal, toke
178
178
  };
179
179
  }
180
180
  };
181
+ let capabilities_devices = {
182
+ tell: async (kind, instance, message, body) => {
183
+ log.push({
184
+ TAG: "Told",
185
+ kind: kind,
186
+ instance: instance,
187
+ message: message,
188
+ body: body
189
+ });
190
+ if (tell !== undefined) {
191
+ return await tell(kind, instance, message, body);
192
+ } else {
193
+ return "Accepted";
194
+ }
195
+ }
196
+ };
181
197
  let capabilities = {
182
198
  geocode: geocode$1,
183
199
  messaging: capabilities_messaging,
184
200
  identityProvider: capabilities_identityProvider,
185
201
  secrets: capabilities_secrets,
186
202
  stash: capabilities_stash,
187
- text: text
203
+ text: text,
204
+ devices: capabilities_devices
188
205
  };
189
206
  return {
190
207
  capabilities: capabilities,
@@ -301,6 +318,25 @@ function toJson(c) {
301
318
  "key",
302
319
  c.key
303
320
  ]]);
321
+ case "Told" :
322
+ return obj("Told", [
323
+ [
324
+ "kind",
325
+ c.kind
326
+ ],
327
+ [
328
+ "instance",
329
+ c.instance
330
+ ],
331
+ [
332
+ "message",
333
+ c.message
334
+ ],
335
+ [
336
+ "body",
337
+ c.body
338
+ ]
339
+ ]);
304
340
  }
305
341
  }
306
342
 
@@ -93,6 +93,34 @@ module Caller = {
93
93
  }
94
94
  /** A caller with no identity. */
95
95
  let anonymous: t = {claim: Unidentified, roles: [], signedIn: false}
96
+
97
+ /** The group a test's operator holds, elevated in every read the test makes. */
98
+ let operatorGroup = "reventless-gwt-operator"
99
+
100
+ /** The caller as the read rules take them. */
101
+ let identity = (who: t): Reventless.Identity.t => {
102
+ let groups = who.roles->Array.map(Reventless.Role.groupOf)
103
+ switch who.claim {
104
+ | Owned({userId}) => {userId, username: userId, groups, provider: InMemory}
105
+ | Exempt => {
106
+ userId: "operator",
107
+ username: "operator",
108
+ groups: groups->Array.concat([operatorGroup]),
109
+ provider: InMemory,
110
+ }
111
+ | Unidentified => Reventless.Identity.anonymous
112
+ }
113
+ }
114
+
115
+ /** The claim a command carries: an owner holding a role whose group is elevated
116
+ acts for anyone, as the platform classifies them. */
117
+ let claimWith = (who: t, ~elevated: array<string>): Message.CallerClaim.t =>
118
+ switch who.claim {
119
+ | Owned(_)
120
+ if who.roles->Array.some(role => elevated->Array.includes(Reventless.Role.groupOf(role))) =>
121
+ Exempt
122
+ | claim => claim
123
+ }
96
124
  }
97
125
 
98
126
  /** `Caller` as a scenario sees it: roles typed by the spec's own `role`, so they
@@ -3,11 +3,13 @@
3
3
  import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
4
4
  import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
5
5
  import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
6
+ import * as Role$Reventless from "@reventlessdev/reventless-spec/src/types/Role.res.mjs";
6
7
  import * as Owner$Reventless from "@reventlessdev/reventless-spec/src/components/Owner.res.mjs";
7
8
  import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js";
8
9
  import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
9
10
  import * as Primitive_string from "@rescript/runtime/lib/es6/Primitive_string.js";
10
11
  import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
12
+ import * as Identity$Reventless from "@reventlessdev/reventless-spec/src/types/Identity.res.mjs";
11
13
  import * as DcbDecode$Reventless from "@reventlessdev/reventless-spec/src/components/DcbDecode.res.mjs";
12
14
  import * as Outcome$ReventlessGwt from "./Outcome.res.mjs";
13
15
  import * as OwnerScope$Reventless from "@reventlessdev/reventless-spec/src/types/OwnerScope.res.mjs";
@@ -80,13 +82,51 @@ let anonymous = {
80
82
  signedIn: false
81
83
  };
82
84
 
85
+ let operatorGroup = "reventless-gwt-operator";
86
+
87
+ function identity(who) {
88
+ let groups = who.roles.map(Role$Reventless.groupOf);
89
+ let match = who.claim;
90
+ if (typeof match !== "object") {
91
+ if (match === "Exempt") {
92
+ return {
93
+ userId: "operator",
94
+ username: "operator",
95
+ groups: groups.concat([operatorGroup]),
96
+ provider: "InMemory"
97
+ };
98
+ } else {
99
+ return Identity$Reventless.anonymous;
100
+ }
101
+ }
102
+ let userId = match.userId;
103
+ return {
104
+ userId: userId,
105
+ username: userId,
106
+ groups: groups,
107
+ provider: "InMemory"
108
+ };
109
+ }
110
+
111
+ function claimWith(who, elevated) {
112
+ let claim = who.claim;
113
+ if (typeof claim !== "object" || !who.roles.some(role => elevated.includes(Role$Reventless.groupOf(role)))) {
114
+ return claim;
115
+ } else {
116
+ return "Exempt";
117
+ }
118
+ }
119
+
83
120
  let Caller = {
84
121
  roleNames: roleNames,
85
122
  owner: owner,
86
123
  inRoles: inRoles,
87
124
  operator: operator,
88
125
  operatorIn: operatorIn,
89
- anonymous: anonymous
126
+ anonymous: anonymous,
127
+ operatorGroup: operatorGroup,
128
+ identity: identity,
129
+ claimWith: claimWith
90
130
  };
91
131
 
92
132
  function Callers(R) {
@@ -1012,4 +1052,4 @@ export {
1012
1052
  Make,
1013
1053
  MakeFromAggregate,
1014
1054
  }
1015
- /* Owner-Reventless Not a pure module */
1055
+ /* Role-Reventless Not a pure module */