@reventlessdev/reventless-core 3.0.0-alpha.318 → 3.0.0-alpha.320
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 +15 -0
- package/package.json +7 -7
- package/src/components/EventLog/EventLog_Operations.res +11 -6
- package/src/components/EventLog/EventLog_Operations.res.mjs +5 -3
- package/src/components/StateChangeSlice/StateChangeSlice_Callback.res.mjs +1 -1
- package/tests/eventlog/EventLogFixtures.res +5 -0
- package/tests/eventlog/EventLogFixtures.res.mjs +4 -0
- package/tests/eventlog/EventLogPiiTest.res +18 -0
- package/tests/eventlog/EventLogPiiTest.res.mjs +18 -0
- package/tests/pii/Aggregate/PiiCustomer.res +14 -0
- package/tests/pii/Aggregate/PiiCustomer.res.mjs +57 -0
- package/tests/pii/PiiInstallTest.res +121 -0
- package/tests/pii/PiiInstallTest.res.mjs +173 -0
- package/tests/pii/PiiMember.res +5 -0
- package/tests/pii/PiiMember.res.mjs +9 -0
- package/tests/pii/PiiPpxTest.res +9 -0
- package/tests/pii/PiiPpxTest.res.mjs +9 -0
- package/tests/pii/PiiStreamSubjectTest.res +69 -0
- package/tests/pii/PiiStreamSubjectTest.res.mjs +106 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,21 @@
|
|
|
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.320 (2026-10-30)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **pii:** a consumed event's field needs no subject ([e2b71a7](https://github.com/ReventlessDev/reventless-core/commit/e2b71a7f4cc9b5a34db42501e3bb2ee31712a909))
|
|
11
|
+
* **pii:** in an aggregate's spec, a field that names no subject is about the aggregate ([dc77529](https://github.com/ReventlessDev/reventless-core/commit/dc7752955fb97c34fd9512ac79fbd0242f05ce32))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# 3.0.0-alpha.319 (2026-10-30)
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* **pii:** a provider can be installed while it is built, and a deployment can require one ([3ce346f](https://github.com/ReventlessDev/reventless-core/commit/3ce346f66063af9221800278595abcfb7bf95884))
|
|
19
|
+
|
|
20
|
+
|
|
6
21
|
# 3.0.0-alpha.318 (2026-10-29)
|
|
7
22
|
|
|
8
23
|
* feat(core)!: every reader opens a sealed field, with the keys its batch prepared ([d4ac204](https://github.com/ReventlessDev/reventless-core/commit/d4ac204c307d34617d4e32c556030b44bb55b178))
|
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.320",
|
|
4
4
|
"description": "Core package for Reventless framework",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"jest": {
|
|
@@ -30,20 +30,20 @@
|
|
|
30
30
|
"uuid": "^13.0.0",
|
|
31
31
|
"@reventlessdev/rescript-effect": "1.0.0-alpha.1",
|
|
32
32
|
"@reventlessdev/rescript-hash-object": "1.2.0-alpha.15",
|
|
33
|
+
"@reventlessdev/rescript-node": "2.0.0-alpha.24",
|
|
33
34
|
"@reventlessdev/rescript-jest": "1.0.0-alpha.13",
|
|
34
35
|
"@reventlessdev/rescript-fast-csv": "2.0.0-alpha.24",
|
|
35
|
-
"@reventlessdev/rescript-node": "2.0.0-alpha.24",
|
|
36
|
-
"@reventlessdev/rescript-pulumi-pulumi": "3.0.0-alpha.0",
|
|
37
36
|
"@reventlessdev/rescript-ssh2": "2.0.0-alpha.25",
|
|
38
37
|
"@reventlessdev/rescript-uuid": "2.0.0-alpha.1",
|
|
39
|
-
"@reventlessdev/reventless-infra": "3.0.0-alpha.
|
|
40
|
-
"@reventlessdev/reventless-
|
|
41
|
-
"@reventlessdev/
|
|
38
|
+
"@reventlessdev/reventless-infra": "3.0.0-alpha.217",
|
|
39
|
+
"@reventlessdev/reventless-spec": "3.0.0-alpha.188",
|
|
40
|
+
"@reventlessdev/rescript-pulumi-pulumi": "3.0.0-alpha.0",
|
|
41
|
+
"@reventlessdev/reventless-interop": "3.0.0-alpha.42"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"rescript": "12.3.1",
|
|
45
45
|
"sury-ppx": "11.0.0",
|
|
46
|
-
"@reventlessdev/reventless-ppx": "1.0.0-alpha.
|
|
46
|
+
"@reventlessdev/reventless-ppx": "1.0.0-alpha.109"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"rescript": "^12.3.1"
|
|
@@ -72,11 +72,11 @@ module Make = (Spec: ReventlessInfra.EventLog.T, Ops: Ops with module Spec = Spe
|
|
|
72
72
|
let failure = ref(None)
|
|
73
73
|
for i in 0 to events'->Array.length - 1 {
|
|
74
74
|
if failure.contents->Option.isNone {
|
|
75
|
-
let (
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
switch await Reventless.Pii.sealData(Spec.eventSchema, ~eventType, data) {
|
|
75
|
+
let event' = events'->Array.getUnsafe(i)
|
|
76
|
+
let (eventType, data) = event'.event->Message.encode(Spec.eventSchema)->Message.splitMessage
|
|
77
|
+
// The aggregate is the subject of a field that names none.
|
|
78
|
+
let streamId = event'.id->Spec.Id.toString
|
|
79
|
+
switch await Reventless.Pii.sealData(Spec.eventSchema, ~eventType, ~streamId, data) {
|
|
80
80
|
| Error(e) => failure := Some(`cannot seal ${eventType}: ${e->Reventless.Pii.errorMessage}`)
|
|
81
81
|
| Ok(sealed) =>
|
|
82
82
|
switch Reventless.Pii.unsealedField(Spec.eventSchema, ~eventType, sealed) {
|
|
@@ -360,7 +360,12 @@ module Make = (Spec: ReventlessInfra.EventLog.T, Ops: Ops with module Spec = Spe
|
|
|
360
360
|
stream->Stream.mapEffect(event =>
|
|
361
361
|
Effect.promise(async () => {
|
|
362
362
|
let (eventType, data) = event->Message.encode(Spec.eventSchema)->Message.splitMessage
|
|
363
|
-
let sealed = switch await Reventless.Pii.sealData(
|
|
363
|
+
let sealed = switch await Reventless.Pii.sealData(
|
|
364
|
+
Spec.eventSchema,
|
|
365
|
+
~eventType,
|
|
366
|
+
~streamId=id->Spec.Id.toString,
|
|
367
|
+
data,
|
|
368
|
+
) {
|
|
364
369
|
| Ok(sealed) => sealed
|
|
365
370
|
| Error(e) =>
|
|
366
371
|
JsError.throwWithMessage(
|
|
@@ -40,9 +40,11 @@ function Make(Spec) {
|
|
|
40
40
|
let failure;
|
|
41
41
|
for (let i = 0, i_finish = events$p.length; i < i_finish; ++i) {
|
|
42
42
|
if (Stdlib_Option.isNone(failure)) {
|
|
43
|
-
let
|
|
43
|
+
let event$p = events$p[i];
|
|
44
|
+
let match = Message$ReventlessCore.splitMessage(Message$ReventlessCore.encode(event$p.event, Spec.eventSchema));
|
|
44
45
|
let eventType = match[0];
|
|
45
|
-
let
|
|
46
|
+
let streamId = Spec.Id.toString(event$p.id);
|
|
47
|
+
let e = await Pii$Reventless.sealData(Spec.eventSchema, eventType, streamId, match[1]);
|
|
46
48
|
if (e.TAG === "Ok") {
|
|
47
49
|
let sealed = e._0;
|
|
48
50
|
let field = Pii$Reventless.unsealedField(Spec.eventSchema, eventType, sealed);
|
|
@@ -316,7 +318,7 @@ function Make(Spec) {
|
|
|
316
318
|
let appendStream = (startingSeqNr, id, stream) => Ops.storage.appendStream(startingSeqNr, Spec.Id.toString(id), Stream.mapEffect(stream, event => Effect$1.promise(async () => {
|
|
317
319
|
let match = Message$ReventlessCore.splitMessage(Message$ReventlessCore.encode(event, Spec.eventSchema));
|
|
318
320
|
let eventType = match[0];
|
|
319
|
-
let sealed = await Pii$Reventless.sealData(Spec.eventSchema, eventType, match[1]);
|
|
321
|
+
let sealed = await Pii$Reventless.sealData(Spec.eventSchema, eventType, Spec.Id.toString(id), match[1]);
|
|
320
322
|
let sealed$1;
|
|
321
323
|
sealed$1 = sealed.TAG === "Ok" ? sealed._0 : Stdlib_JsError.throwWithMessage(`EventLog.appendStream: cannot seal ` + eventType + `: ` + Pii$Reventless.errorMessage(sealed._0));
|
|
322
324
|
return Object.fromEntries([
|
|
@@ -41,7 +41,7 @@ function Make(Spec) {
|
|
|
41
41
|
let match$1 = raw.data;
|
|
42
42
|
if (match === undefined) {
|
|
43
43
|
if (typeof match$1 === "object" && match$1 !== null && !Array.isArray(match$1)) {
|
|
44
|
-
let e = await Pii$Reventless.sealData(Spec.eventSchema, raw.eventType, match$1);
|
|
44
|
+
let e = await Pii$Reventless.sealData(Spec.eventSchema, raw.eventType, undefined, match$1);
|
|
45
45
|
if (e.TAG === "Ok") {
|
|
46
46
|
let sealed = e._0;
|
|
47
47
|
let field = Pii$Reventless.unsealedField(Spec.eventSchema, raw.eventType, sealed);
|
|
@@ -15,6 +15,11 @@ module ItemEventLogSpec = {
|
|
|
15
15
|
name: @s.matches(Reventless.Pii.marked(~subject="personId", S.string))
|
|
16
16
|
Reventless.Pii.t<string>,
|
|
17
17
|
})
|
|
18
|
+
// An aggregate's field that names no subject: the aggregate is it.
|
|
19
|
+
| PersonEmailed({
|
|
20
|
+
email: @s.matches(Reventless.Pii.marked(~subject=Reventless.Pii.streamSubject, S.string))
|
|
21
|
+
Reventless.Pii.t<string>,
|
|
22
|
+
})
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
// ─────────────────────────────────────────────────────────────
|
|
@@ -20,6 +20,10 @@ let eventSchema = Sury.union([
|
|
|
20
20
|
TAG: "PersonNamed",
|
|
21
21
|
personId: s.m(Sury.string),
|
|
22
22
|
name: s.m(Pii$Reventless.marked("personId", undefined, Sury.string))
|
|
23
|
+
})),
|
|
24
|
+
Sury.$schema(s => ({
|
|
25
|
+
TAG: "PersonEmailed",
|
|
26
|
+
email: s.m(Pii$Reventless.marked(Pii$Reventless.streamSubject, undefined, Sury.string))
|
|
23
27
|
}))
|
|
24
28
|
]);
|
|
25
29
|
|
|
@@ -73,6 +73,24 @@ describe("EventLog with a personal-data provider", () => {
|
|
|
73
73
|
expect(replayed)->toEqual([named])
|
|
74
74
|
})
|
|
75
75
|
|
|
76
|
+
testPromise("seals a field that names no subject under the aggregate's id", async () => {
|
|
77
|
+
Reventless.Pii.Provider.install(fakeProvider())
|
|
78
|
+
let emailed: ItemEventLogSpec.event = PersonEmailed({email: Value("ada@example.org")})
|
|
79
|
+
let result = await Log.append(0, "p-9", [makeEvent'("p-9", emailed)])
|
|
80
|
+
expect(result)->toEqual(Ok())
|
|
81
|
+
let stored =
|
|
82
|
+
storedEvents.contents
|
|
83
|
+
->Dict.get("p-9")
|
|
84
|
+
->Option.flatMap(a => a->Array.get(0))
|
|
85
|
+
->Option.flatMap(JSON.Decode.object)
|
|
86
|
+
->Option.flatMap(d => d->Dict.get("data"))
|
|
87
|
+
->Option.flatMap(JSON.Decode.object)
|
|
88
|
+
->Option.flatMap(d => d->Dict.get("email"))
|
|
89
|
+
->Option.flatMap(Reventless.Pii.unwrap)
|
|
90
|
+
expect(stored->Option.mapOr(false, s => s->String.startsWith("enc:v1:p-9:")))->toBe(true)
|
|
91
|
+
expect(await Log.replay("p-9"))->toEqual([emailed])
|
|
92
|
+
})
|
|
93
|
+
|
|
76
94
|
testPromise("refuses an append whose personal field comes out unsealed", async () => {
|
|
77
95
|
Reventless.Pii.Provider.install(fakeProvider(~seals=false))
|
|
78
96
|
let result = await Log.append(0, "p-1", [makeEvent'("p-1", named)])
|
|
@@ -171,6 +171,24 @@ globalThis.describe("EventLog with a personal-data provider", () => {
|
|
|
171
171
|
let replayed = await Log.replay("p-1");
|
|
172
172
|
globalThis.expect(replayed).toEqual([named]);
|
|
173
173
|
});
|
|
174
|
+
globalThis.test("seals a field that names no subject under the aggregate's id", async () => {
|
|
175
|
+
Pii$Reventless.Provider.install(fakeProvider(undefined));
|
|
176
|
+
let emailed = {
|
|
177
|
+
TAG: "PersonEmailed",
|
|
178
|
+
email: {
|
|
179
|
+
TAG: "Value",
|
|
180
|
+
_0: "ada@example.org"
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
let result = await Log.append(0, "p-9", [EventLogFixtures$ReventlessCore.makeEvent$p("p-9", emailed)]);
|
|
184
|
+
globalThis.expect(result).toEqual({
|
|
185
|
+
TAG: "Ok",
|
|
186
|
+
_0: undefined
|
|
187
|
+
});
|
|
188
|
+
let stored = Stdlib_Option.flatMap(Stdlib_Option.flatMap(Stdlib_Option.flatMap(Stdlib_Option.flatMap(Stdlib_Option.flatMap(Stdlib_Option.flatMap(EventLogFixtures$ReventlessCore.storedEvents.contents["p-9"], a => a[0]), Stdlib_JSON.Decode.object), d => d["data"]), Stdlib_JSON.Decode.object), d => d["email"]), Pii$Reventless.unwrap);
|
|
189
|
+
globalThis.expect(Stdlib_Option.mapOr(stored, false, s => s.startsWith("enc:v1:p-9:"))).toBe(true);
|
|
190
|
+
globalThis.expect(await Log.replay("p-9")).toEqual([emailed]);
|
|
191
|
+
});
|
|
174
192
|
globalThis.test("refuses an append whose personal field comes out unsealed", async () => {
|
|
175
193
|
Pii$Reventless.Provider.install(fakeProvider(false));
|
|
176
194
|
let result = await Log.append(0, "p-1", [EventLogFixtures$ReventlessCore.makeEvent$p("p-1", named)]);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Fixture: an aggregate's spec, whose events name no subject: the aggregate is it.
|
|
2
|
+
|
|
3
|
+
@@reventless.spec("PiiCustomer")
|
|
4
|
+
|
|
5
|
+
@schema
|
|
6
|
+
type event =
|
|
7
|
+
| Registered({@pii email: Reventless.Email.t, @pii address: string})
|
|
8
|
+
| EmailUpdated({@pii email: Reventless.Email.t})
|
|
9
|
+
// A field about someone else still names them.
|
|
10
|
+
| ReferralSent({friendId: string, @pii("friendId") friendEmail: Reventless.Email.t})
|
|
11
|
+
| Deactivated
|
|
12
|
+
|
|
13
|
+
@schema
|
|
14
|
+
type command = Register({@pii email: Reventless.Email.t, @pii address: string})
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Sury from "sury";
|
|
4
|
+
import * as Pii$Reventless from "@reventlessdev/reventless-spec/src/components/Pii.res.mjs";
|
|
5
|
+
import * as Email$Reventless from "@reventlessdev/reventless-spec/src/semantic/Email.res.mjs";
|
|
6
|
+
|
|
7
|
+
let eventSchema = Sury.union([
|
|
8
|
+
Sury.$schema(s => ({
|
|
9
|
+
TAG: "Registered",
|
|
10
|
+
email: s.m(Pii$Reventless.marked("$stream", undefined, Email$Reventless.schema)),
|
|
11
|
+
address: s.m(Pii$Reventless.marked("$stream", undefined, Sury.string))
|
|
12
|
+
})),
|
|
13
|
+
Sury.$schema(s => ({
|
|
14
|
+
TAG: "EmailUpdated",
|
|
15
|
+
email: s.m(Pii$Reventless.marked("$stream", undefined, Email$Reventless.schema))
|
|
16
|
+
})),
|
|
17
|
+
Sury.$schema(s => ({
|
|
18
|
+
TAG: "ReferralSent",
|
|
19
|
+
friendId: s.m(Sury.string),
|
|
20
|
+
friendEmail: s.m(Pii$Reventless.marked("friendId", undefined, Email$Reventless.schema))
|
|
21
|
+
})),
|
|
22
|
+
Sury.literal("Deactivated")
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
let commandSchema = Sury.$schema(s => ({
|
|
26
|
+
TAG: "Register",
|
|
27
|
+
email: s.m(Pii$Reventless.mark("$stream", undefined, Email$Reventless.schema)),
|
|
28
|
+
address: s.m(Pii$Reventless.mark("$stream", undefined, Sury.string))
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
function authorizationOf(param) {
|
|
32
|
+
return "AllowAuthenticated";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function commandTransition(param) {
|
|
36
|
+
return "Undeclared";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let traits = [];
|
|
40
|
+
|
|
41
|
+
let name = "PiiCustomer";
|
|
42
|
+
|
|
43
|
+
let Id;
|
|
44
|
+
|
|
45
|
+
let moduleUrl = "@reventlessdev/reventless-core/tests/pii/Aggregate/PiiCustomer.res.mjs";
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
name,
|
|
49
|
+
Id,
|
|
50
|
+
eventSchema,
|
|
51
|
+
commandSchema,
|
|
52
|
+
moduleUrl,
|
|
53
|
+
authorizationOf,
|
|
54
|
+
commandTransition,
|
|
55
|
+
traits,
|
|
56
|
+
}
|
|
57
|
+
/* eventSchema Not a pure module */
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// A provider installed while it is still being built is waited for, a failed one
|
|
2
|
+
// refuses, and a deployment that requires encryption never stores a marked field
|
|
3
|
+
// as it is.
|
|
4
|
+
|
|
5
|
+
open JestGlobals
|
|
6
|
+
|
|
7
|
+
module Spec = {
|
|
8
|
+
@schema
|
|
9
|
+
type event =
|
|
10
|
+
| MemberNamed({
|
|
11
|
+
memberId: string,
|
|
12
|
+
name: @s.matches(Reventless.Pii.marked(~subject="memberId", S.string))
|
|
13
|
+
Reventless.Pii.t<string>,
|
|
14
|
+
})
|
|
15
|
+
| MemberLeft({memberId: string})
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let sealing: Reventless.Pii.provider = {
|
|
19
|
+
...Reventless.Pii.plain,
|
|
20
|
+
name: "sealing",
|
|
21
|
+
encrypts: true,
|
|
22
|
+
seal: async (~subject, ~field as _, ~forgettable as _, _json) => Ok(
|
|
23
|
+
Reventless.Pii.wrap(`enc:v1:${subject}:fake:AAAA`),
|
|
24
|
+
),
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let named = () =>
|
|
28
|
+
Dict.fromArray([("memberId", JSON.Encode.string("m-1")), ("name", JSON.Encode.string("Ada"))])
|
|
29
|
+
|
|
30
|
+
let seal = data => Reventless.Pii.sealData(Spec.eventSchema, ~eventType="MemberNamed", data)
|
|
31
|
+
|
|
32
|
+
@val external env: dict<string> = "process.env"
|
|
33
|
+
let variable = "REVENTLESS_PII_REQUIRE_ENCRYPTION"
|
|
34
|
+
|
|
35
|
+
describe("Pii.Provider.installWhen", () => {
|
|
36
|
+
afterEach(() => {
|
|
37
|
+
Reventless.Pii.Provider.install(Reventless.Pii.plain)
|
|
38
|
+
env->Dict.delete(variable)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
test("a write waits for a provider still being built, then seals with it", async () => {
|
|
42
|
+
let (building, finish) = {
|
|
43
|
+
let finish = ref(_ => ())
|
|
44
|
+
let p = Promise.make((resolve, _) => finish := resolve)
|
|
45
|
+
(p, finish)
|
|
46
|
+
}
|
|
47
|
+
Reventless.Pii.Provider.installWhen(building)
|
|
48
|
+
let sealed = seal(named())
|
|
49
|
+
finish.contents(Ok(sealing))
|
|
50
|
+
switch await sealed {
|
|
51
|
+
| Ok(data) =>
|
|
52
|
+
expect(data->Dict.get("name")->Option.flatMap(Reventless.Pii.unwrap))->toEqual(
|
|
53
|
+
Some("enc:v1:m-1:fake:AAAA"),
|
|
54
|
+
)
|
|
55
|
+
| Error(e) => JsError.throwWithMessage(e->Reventless.Pii.errorMessage)
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
test("a failed install refuses the write with its reason", async () => {
|
|
60
|
+
Reventless.Pii.Provider.installWhen(Promise.resolve(Error("KMS is unreachable")))
|
|
61
|
+
switch await seal(named()) {
|
|
62
|
+
| Ok(_) => JsError.throwWithMessage("expected a refusal")
|
|
63
|
+
| Error(e) =>
|
|
64
|
+
expect(e->Reventless.Pii.errorMessage->String.includes("KMS is unreachable"))->toBe(true)
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
test("a failed install refuses a batch that needs keys", async () => {
|
|
69
|
+
Reventless.Pii.Provider.installWhen(Promise.resolve(Error("KMS is unreachable")))
|
|
70
|
+
let batch = [Reventless.Pii.wrap("enc:v1:k-1:A256GCM:AAAA")]
|
|
71
|
+
expect((await Reventless.Pii.prepare(batch))->Result.isError)->toBe(true)
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
test("a later install replaces one still in flight", async () => {
|
|
75
|
+
let (building, finish) = {
|
|
76
|
+
let finish = ref(_ => ())
|
|
77
|
+
let p = Promise.make((resolve, _) => finish := resolve)
|
|
78
|
+
(p, finish)
|
|
79
|
+
}
|
|
80
|
+
Reventless.Pii.Provider.installWhen(building)
|
|
81
|
+
Reventless.Pii.Provider.install(sealing)
|
|
82
|
+
finish.contents(Error("too late"))
|
|
83
|
+
await Promise.resolve()
|
|
84
|
+
expect((await seal(named()))->Result.isOk)->toBe(true)
|
|
85
|
+
expect(Reventless.Pii.Provider.get().name)->toBe("sealing")
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
test("a type without personal fields does not wait", async () => {
|
|
89
|
+
Reventless.Pii.Provider.installWhen(Promise.make((_, _) => ()))
|
|
90
|
+
let data = Dict.fromArray([("memberId", JSON.Encode.string("m-1"))])
|
|
91
|
+
expect(await Reventless.Pii.sealData(Spec.eventSchema, ~eventType="MemberLeft", data))->toEqual(
|
|
92
|
+
Ok(data),
|
|
93
|
+
)
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
describe("REVENTLESS_PII_REQUIRE_ENCRYPTION", () => {
|
|
98
|
+
afterEach(() => {
|
|
99
|
+
Reventless.Pii.Provider.install(Reventless.Pii.plain)
|
|
100
|
+
env->Dict.delete(variable)
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
test("refuses a marked field when no encrypting provider is installed", async () => {
|
|
104
|
+
env->Dict.set(variable, "true")
|
|
105
|
+
switch await seal(named()) {
|
|
106
|
+
| Ok(_) => JsError.throwWithMessage("expected a refusal")
|
|
107
|
+
| Error(e) =>
|
|
108
|
+
expect(e->Reventless.Pii.errorMessage->String.includes("requires an encrypting"))->toBe(true)
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
test("seals when an encrypting provider is installed", async () => {
|
|
113
|
+
env->Dict.set(variable, "true")
|
|
114
|
+
Reventless.Pii.Provider.install(sealing)
|
|
115
|
+
expect((await seal(named()))->Result.isOk)->toBe(true)
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
test("leaves a deployment that does not require it storing as it is", async () => {
|
|
119
|
+
expect(await seal(named()))->toEqual(Ok(named()))
|
|
120
|
+
})
|
|
121
|
+
})
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Sury from "sury";
|
|
4
|
+
import * as Stdlib_Dict from "@rescript/runtime/lib/es6/Stdlib_Dict.js";
|
|
5
|
+
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
6
|
+
import * as Stdlib_Result from "@rescript/runtime/lib/es6/Stdlib_Result.js";
|
|
7
|
+
import * as Pii$Reventless from "@reventlessdev/reventless-spec/src/components/Pii.res.mjs";
|
|
8
|
+
import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
|
|
9
|
+
|
|
10
|
+
let eventSchema = Sury.union([
|
|
11
|
+
Sury.$schema(s => ({
|
|
12
|
+
TAG: "MemberNamed",
|
|
13
|
+
memberId: s.m(Sury.string),
|
|
14
|
+
name: s.m(Pii$Reventless.marked("memberId", undefined, Sury.string))
|
|
15
|
+
})),
|
|
16
|
+
Sury.$schema(s => ({
|
|
17
|
+
TAG: "MemberLeft",
|
|
18
|
+
memberId: s.m(Sury.string)
|
|
19
|
+
}))
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
let Spec = {
|
|
23
|
+
eventSchema: eventSchema
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
async function sealing_seal(subject, param, param$1, _json) {
|
|
27
|
+
return {
|
|
28
|
+
TAG: "Ok",
|
|
29
|
+
_0: Pii$Reventless.wrap(`enc:v1:` + subject + `:fake:AAAA`)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let sealing_prefetch = Pii$Reventless.plain.prefetch;
|
|
34
|
+
|
|
35
|
+
let sealing_openNow = Pii$Reventless.plain.openNow;
|
|
36
|
+
|
|
37
|
+
let sealing_release = Pii$Reventless.plain.release;
|
|
38
|
+
|
|
39
|
+
let sealing = {
|
|
40
|
+
name: "sealing",
|
|
41
|
+
encrypts: true,
|
|
42
|
+
seal: sealing_seal,
|
|
43
|
+
prefetch: sealing_prefetch,
|
|
44
|
+
openNow: sealing_openNow,
|
|
45
|
+
release: sealing_release
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
function named() {
|
|
49
|
+
return Object.fromEntries([
|
|
50
|
+
[
|
|
51
|
+
"memberId",
|
|
52
|
+
"m-1"
|
|
53
|
+
],
|
|
54
|
+
[
|
|
55
|
+
"name",
|
|
56
|
+
"Ada"
|
|
57
|
+
]
|
|
58
|
+
]);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function seal(data) {
|
|
62
|
+
return Pii$Reventless.sealData(eventSchema, "MemberNamed", undefined, data);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
let variable = "REVENTLESS_PII_REQUIRE_ENCRYPTION";
|
|
66
|
+
|
|
67
|
+
globalThis.describe("Pii.Provider.installWhen", () => {
|
|
68
|
+
globalThis.afterEach(() => {
|
|
69
|
+
Pii$Reventless.Provider.install(Pii$Reventless.plain);
|
|
70
|
+
Stdlib_Dict.$$delete(process.env, variable);
|
|
71
|
+
});
|
|
72
|
+
globalThis.test("a write waits for a provider still being built, then seals with it", async () => {
|
|
73
|
+
let finish = {
|
|
74
|
+
contents: param => {}
|
|
75
|
+
};
|
|
76
|
+
let p = new Promise((resolve, param) => {
|
|
77
|
+
finish.contents = resolve;
|
|
78
|
+
});
|
|
79
|
+
Pii$Reventless.Provider.installWhen(p);
|
|
80
|
+
let sealed = seal(named());
|
|
81
|
+
finish.contents({
|
|
82
|
+
TAG: "Ok",
|
|
83
|
+
_0: sealing
|
|
84
|
+
});
|
|
85
|
+
let data = await sealed;
|
|
86
|
+
if (data.TAG !== "Ok") {
|
|
87
|
+
return Stdlib_JsError.throwWithMessage(Pii$Reventless.errorMessage(data._0));
|
|
88
|
+
}
|
|
89
|
+
globalThis.expect(Stdlib_Option.flatMap(data._0["name"], Pii$Reventless.unwrap)).toEqual("enc:v1:m-1:fake:AAAA");
|
|
90
|
+
});
|
|
91
|
+
globalThis.test("a failed install refuses the write with its reason", async () => {
|
|
92
|
+
Pii$Reventless.Provider.installWhen(Promise.resolve({
|
|
93
|
+
TAG: "Error",
|
|
94
|
+
_0: "KMS is unreachable"
|
|
95
|
+
}));
|
|
96
|
+
let e = await seal(named());
|
|
97
|
+
if (e.TAG === "Ok") {
|
|
98
|
+
return Stdlib_JsError.throwWithMessage("expected a refusal");
|
|
99
|
+
}
|
|
100
|
+
globalThis.expect(Pii$Reventless.errorMessage(e._0).includes("KMS is unreachable")).toBe(true);
|
|
101
|
+
});
|
|
102
|
+
globalThis.test("a failed install refuses a batch that needs keys", async () => {
|
|
103
|
+
Pii$Reventless.Provider.installWhen(Promise.resolve({
|
|
104
|
+
TAG: "Error",
|
|
105
|
+
_0: "KMS is unreachable"
|
|
106
|
+
}));
|
|
107
|
+
let batch = [Pii$Reventless.wrap("enc:v1:k-1:A256GCM:AAAA")];
|
|
108
|
+
globalThis.expect(Stdlib_Result.isError(await Pii$Reventless.prepare(batch))).toBe(true);
|
|
109
|
+
});
|
|
110
|
+
globalThis.test("a later install replaces one still in flight", async () => {
|
|
111
|
+
let finish = {
|
|
112
|
+
contents: param => {}
|
|
113
|
+
};
|
|
114
|
+
let p = new Promise((resolve, param) => {
|
|
115
|
+
finish.contents = resolve;
|
|
116
|
+
});
|
|
117
|
+
Pii$Reventless.Provider.installWhen(p);
|
|
118
|
+
Pii$Reventless.Provider.install(sealing);
|
|
119
|
+
finish.contents({
|
|
120
|
+
TAG: "Error",
|
|
121
|
+
_0: "too late"
|
|
122
|
+
});
|
|
123
|
+
await Promise.resolve();
|
|
124
|
+
globalThis.expect(Stdlib_Result.isOk(await seal(named()))).toBe(true);
|
|
125
|
+
globalThis.expect(Pii$Reventless.Provider.get().name).toBe("sealing");
|
|
126
|
+
});
|
|
127
|
+
globalThis.test("a type without personal fields does not wait", async () => {
|
|
128
|
+
Pii$Reventless.Provider.installWhen(new Promise((param, param$1) => {}));
|
|
129
|
+
let data = Object.fromEntries([[
|
|
130
|
+
"memberId",
|
|
131
|
+
"m-1"
|
|
132
|
+
]]);
|
|
133
|
+
globalThis.expect(await Pii$Reventless.sealData(eventSchema, "MemberLeft", undefined, data)).toEqual({
|
|
134
|
+
TAG: "Ok",
|
|
135
|
+
_0: data
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
globalThis.describe("REVENTLESS_PII_REQUIRE_ENCRYPTION", () => {
|
|
141
|
+
globalThis.afterEach(() => {
|
|
142
|
+
Pii$Reventless.Provider.install(Pii$Reventless.plain);
|
|
143
|
+
Stdlib_Dict.$$delete(process.env, variable);
|
|
144
|
+
});
|
|
145
|
+
globalThis.test("refuses a marked field when no encrypting provider is installed", async () => {
|
|
146
|
+
process.env[variable] = "true";
|
|
147
|
+
let e = await seal(named());
|
|
148
|
+
if (e.TAG === "Ok") {
|
|
149
|
+
return Stdlib_JsError.throwWithMessage("expected a refusal");
|
|
150
|
+
}
|
|
151
|
+
globalThis.expect(Pii$Reventless.errorMessage(e._0).includes("requires an encrypting")).toBe(true);
|
|
152
|
+
});
|
|
153
|
+
globalThis.test("seals when an encrypting provider is installed", async () => {
|
|
154
|
+
process.env[variable] = "true";
|
|
155
|
+
Pii$Reventless.Provider.install(sealing);
|
|
156
|
+
globalThis.expect(Stdlib_Result.isOk(await seal(named()))).toBe(true);
|
|
157
|
+
});
|
|
158
|
+
globalThis.test("leaves a deployment that does not require it storing as it is", async () => {
|
|
159
|
+
globalThis.expect(await seal(named())).toEqual({
|
|
160
|
+
TAG: "Ok",
|
|
161
|
+
_0: named()
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
export {
|
|
167
|
+
Spec,
|
|
168
|
+
sealing,
|
|
169
|
+
named,
|
|
170
|
+
seal,
|
|
171
|
+
variable,
|
|
172
|
+
}
|
|
173
|
+
/* eventSchema Not a pure module */
|
package/tests/pii/PiiMember.res
CHANGED
|
@@ -16,3 +16,8 @@ type event =
|
|
|
16
16
|
|
|
17
17
|
@schema
|
|
18
18
|
type command = Join({@owner memberId: string, @pii name: string, @pii address: Reventless.Email.t})
|
|
19
|
+
|
|
20
|
+
// Another slice's view of an aggregate's event, which carries no id of its own:
|
|
21
|
+
// only ever opened, so it needs no subject.
|
|
22
|
+
@schema
|
|
23
|
+
type consumedEvent = CustomerRegistered({@pii email: Reventless.Email.t})
|
|
@@ -30,6 +30,11 @@ let commandSchema = Sury.$schema(s => ({
|
|
|
30
30
|
address: s.m(Pii$Reventless.mark("memberId", undefined, Email$Reventless.schema))
|
|
31
31
|
}));
|
|
32
32
|
|
|
33
|
+
let consumedEventSchema = Sury.$schema(s => ({
|
|
34
|
+
TAG: "CustomerRegistered",
|
|
35
|
+
email: s.m(Pii$Reventless.marked("$stream", undefined, Email$Reventless.schema))
|
|
36
|
+
}));
|
|
37
|
+
|
|
33
38
|
function authorizationOf(param) {
|
|
34
39
|
return "AllowAuthenticated";
|
|
35
40
|
}
|
|
@@ -46,13 +51,17 @@ let Id;
|
|
|
46
51
|
|
|
47
52
|
let moduleUrl = "@reventlessdev/reventless-core/tests/pii/PiiMember.res.mjs";
|
|
48
53
|
|
|
54
|
+
let readConsistency = "EscalateOnRetry";
|
|
55
|
+
|
|
49
56
|
export {
|
|
50
57
|
name,
|
|
51
58
|
Id,
|
|
52
59
|
eventSchema,
|
|
53
60
|
commandSchema,
|
|
61
|
+
consumedEventSchema,
|
|
54
62
|
moduleUrl,
|
|
55
63
|
authorizationOf,
|
|
64
|
+
readConsistency,
|
|
56
65
|
commandTransition,
|
|
57
66
|
traits,
|
|
58
67
|
}
|
package/tests/pii/PiiPpxTest.res
CHANGED
|
@@ -53,6 +53,15 @@ describe("@pii on an event", () => {
|
|
|
53
53
|
])
|
|
54
54
|
})
|
|
55
55
|
|
|
56
|
+
testSync("a consumed field naming no subject is about the aggregate it came from", () =>
|
|
57
|
+
expect(
|
|
58
|
+
M.consumedEventSchema
|
|
59
|
+
->S.castToUnknown
|
|
60
|
+
->Reventless.Pii.variantFields(~variant="CustomerRegistered")
|
|
61
|
+
->Array.map(((name, m)) => (name, m.subject)),
|
|
62
|
+
)->toEqual([("email", Reventless.Pii.streamSubject)])
|
|
63
|
+
)
|
|
64
|
+
|
|
56
65
|
testSync("@pii implies @sensitive", () =>
|
|
57
66
|
expect(
|
|
58
67
|
M.eventSchema
|
|
@@ -110,6 +110,15 @@ globalThis.describe("@pii on an event", () => {
|
|
|
110
110
|
"invitationId"
|
|
111
111
|
]]);
|
|
112
112
|
});
|
|
113
|
+
globalThis.test("a consumed field naming no subject is about the aggregate it came from", () => {
|
|
114
|
+
globalThis.expect(Pii$Reventless.variantFields(PiiMember$ReventlessCore.consumedEventSchema, "CustomerRegistered").map(param => [
|
|
115
|
+
param[0],
|
|
116
|
+
param[1].subject
|
|
117
|
+
])).toEqual([[
|
|
118
|
+
"email",
|
|
119
|
+
Pii$Reventless.streamSubject
|
|
120
|
+
]]);
|
|
121
|
+
});
|
|
113
122
|
globalThis.test("@pii implies @sensitive", () => {
|
|
114
123
|
globalThis.expect(Sensitive$Reventless.variantFieldNames(PiiMember$ReventlessCore.eventSchema, "MemberJoined").includes("name")).toBe(true);
|
|
115
124
|
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// In an aggregate's spec a `@pii` field that names no subject is about the
|
|
2
|
+
// aggregate: the PPX marks it with the stream subject, and the seal pass seals it
|
|
3
|
+
// under the stream id the event log passes.
|
|
4
|
+
|
|
5
|
+
open JestGlobals
|
|
6
|
+
|
|
7
|
+
module C = PiiCustomer
|
|
8
|
+
|
|
9
|
+
let subjects = variant =>
|
|
10
|
+
C.eventSchema
|
|
11
|
+
->S.castToUnknown
|
|
12
|
+
->Reventless.Pii.variantFields(~variant)
|
|
13
|
+
->Array.map(((name, m)) => (name, m.subject))
|
|
14
|
+
|
|
15
|
+
let sealedUnder: ref<array<string>> = ref([])
|
|
16
|
+
let recording: Reventless.Pii.provider = {
|
|
17
|
+
...Reventless.Pii.plain,
|
|
18
|
+
name: "recording",
|
|
19
|
+
encrypts: true,
|
|
20
|
+
seal: async (~subject, ~field as _, ~forgettable as _, _json) => {
|
|
21
|
+
sealedUnder := sealedUnder.contents->Array.concat([subject])
|
|
22
|
+
Ok(Reventless.Pii.wrap(`enc:v1:${subject}:fake:AAAA`))
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let registered = () =>
|
|
27
|
+
Dict.fromArray([
|
|
28
|
+
("email", JSON.Encode.string("ada@example.org")),
|
|
29
|
+
("address", JSON.Encode.string("1 Analytical St")),
|
|
30
|
+
])
|
|
31
|
+
|
|
32
|
+
describe("@pii in an aggregate's spec", () => {
|
|
33
|
+
afterEach(() => {
|
|
34
|
+
Reventless.Pii.Provider.install(Reventless.Pii.plain)
|
|
35
|
+
sealedUnder := []
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
testSync("a field naming no subject is about the aggregate", () =>
|
|
39
|
+
expect(subjects("Registered"))->toEqual([
|
|
40
|
+
("email", Reventless.Pii.streamSubject),
|
|
41
|
+
("address", Reventless.Pii.streamSubject),
|
|
42
|
+
])
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
testSync("a field naming a subject keeps it", () =>
|
|
46
|
+
expect(subjects("ReferralSent"))->toEqual([("friendEmail", "friendId")])
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
testPromise("is sealed under the stream id the event log passes", async () => {
|
|
50
|
+
Reventless.Pii.Provider.install(recording)
|
|
51
|
+
let sealed = await Reventless.Pii.sealData(
|
|
52
|
+
C.eventSchema,
|
|
53
|
+
~eventType="Registered",
|
|
54
|
+
~streamId="c-7",
|
|
55
|
+
registered(),
|
|
56
|
+
)
|
|
57
|
+
expect(sealed->Result.isOk)->toBe(true)
|
|
58
|
+
expect(sealedUnder.contents)->toEqual(["c-7", "c-7"])
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
testPromise("is refused when no stream id is passed", async () => {
|
|
62
|
+
Reventless.Pii.Provider.install(recording)
|
|
63
|
+
switch await Reventless.Pii.sealData(C.eventSchema, ~eventType="Registered", registered()) {
|
|
64
|
+
| Ok(_) => fail("expected a refusal")
|
|
65
|
+
| Error(e) =>
|
|
66
|
+
expect(e->Reventless.Pii.errorMessage->String.includes("no stream id"))->toBe(true)
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
})
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as JestGlobals from "@reventlessdev/rescript-jest/src/JestGlobals.res.mjs";
|
|
4
|
+
import * as Stdlib_Result from "@rescript/runtime/lib/es6/Stdlib_Result.js";
|
|
5
|
+
import * as Pii$Reventless from "@reventlessdev/reventless-spec/src/components/Pii.res.mjs";
|
|
6
|
+
import * as PiiCustomer$ReventlessCore from "./Aggregate/PiiCustomer.res.mjs";
|
|
7
|
+
|
|
8
|
+
function subjects(variant) {
|
|
9
|
+
return Pii$Reventless.variantFields(PiiCustomer$ReventlessCore.eventSchema, variant).map(param => [
|
|
10
|
+
param[0],
|
|
11
|
+
param[1].subject
|
|
12
|
+
]);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let sealedUnder = {
|
|
16
|
+
contents: []
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
async function recording_seal(subject, param, param$1, _json) {
|
|
20
|
+
sealedUnder.contents = sealedUnder.contents.concat([subject]);
|
|
21
|
+
return {
|
|
22
|
+
TAG: "Ok",
|
|
23
|
+
_0: Pii$Reventless.wrap(`enc:v1:` + subject + `:fake:AAAA`)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let recording_prefetch = Pii$Reventless.plain.prefetch;
|
|
28
|
+
|
|
29
|
+
let recording_openNow = Pii$Reventless.plain.openNow;
|
|
30
|
+
|
|
31
|
+
let recording_release = Pii$Reventless.plain.release;
|
|
32
|
+
|
|
33
|
+
let recording = {
|
|
34
|
+
name: "recording",
|
|
35
|
+
encrypts: true,
|
|
36
|
+
seal: recording_seal,
|
|
37
|
+
prefetch: recording_prefetch,
|
|
38
|
+
openNow: recording_openNow,
|
|
39
|
+
release: recording_release
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
function registered() {
|
|
43
|
+
return Object.fromEntries([
|
|
44
|
+
[
|
|
45
|
+
"email",
|
|
46
|
+
"ada@example.org"
|
|
47
|
+
],
|
|
48
|
+
[
|
|
49
|
+
"address",
|
|
50
|
+
"1 Analytical St"
|
|
51
|
+
]
|
|
52
|
+
]);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
globalThis.describe("@pii in an aggregate's spec", () => {
|
|
56
|
+
globalThis.afterEach(() => {
|
|
57
|
+
Pii$Reventless.Provider.install(Pii$Reventless.plain);
|
|
58
|
+
sealedUnder.contents = [];
|
|
59
|
+
});
|
|
60
|
+
globalThis.test("a field naming no subject is about the aggregate", () => {
|
|
61
|
+
globalThis.expect(subjects("Registered")).toEqual([
|
|
62
|
+
[
|
|
63
|
+
"email",
|
|
64
|
+
Pii$Reventless.streamSubject
|
|
65
|
+
],
|
|
66
|
+
[
|
|
67
|
+
"address",
|
|
68
|
+
Pii$Reventless.streamSubject
|
|
69
|
+
]
|
|
70
|
+
]);
|
|
71
|
+
});
|
|
72
|
+
globalThis.test("a field naming a subject keeps it", () => {
|
|
73
|
+
globalThis.expect(subjects("ReferralSent")).toEqual([[
|
|
74
|
+
"friendEmail",
|
|
75
|
+
"friendId"
|
|
76
|
+
]]);
|
|
77
|
+
});
|
|
78
|
+
globalThis.test("is sealed under the stream id the event log passes", async () => {
|
|
79
|
+
Pii$Reventless.Provider.install(recording);
|
|
80
|
+
let sealed = await Pii$Reventless.sealData(PiiCustomer$ReventlessCore.eventSchema, "Registered", "c-7", registered());
|
|
81
|
+
globalThis.expect(Stdlib_Result.isOk(sealed)).toBe(true);
|
|
82
|
+
globalThis.expect(sealedUnder.contents).toEqual([
|
|
83
|
+
"c-7",
|
|
84
|
+
"c-7"
|
|
85
|
+
]);
|
|
86
|
+
});
|
|
87
|
+
globalThis.test("is refused when no stream id is passed", async () => {
|
|
88
|
+
Pii$Reventless.Provider.install(recording);
|
|
89
|
+
let e = await Pii$Reventless.sealData(PiiCustomer$ReventlessCore.eventSchema, "Registered", undefined, registered());
|
|
90
|
+
if (e.TAG === "Ok") {
|
|
91
|
+
return JestGlobals.fail("expected a refusal");
|
|
92
|
+
}
|
|
93
|
+
globalThis.expect(Pii$Reventless.errorMessage(e._0).includes("no stream id")).toBe(true);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
let C;
|
|
98
|
+
|
|
99
|
+
export {
|
|
100
|
+
C,
|
|
101
|
+
subjects,
|
|
102
|
+
sealedUnder,
|
|
103
|
+
recording,
|
|
104
|
+
registered,
|
|
105
|
+
}
|
|
106
|
+
/* Not a pure module */
|