@reventlessdev/reventless-registration 1.0.0-alpha.5 → 1.0.0-alpha.51

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.
Files changed (48) hide show
  1. package/README.md +87 -2
  2. package/conformance/Registration/InboundTranslation/CompleteRegistration_Conformance_GWT.res +65 -0
  3. package/conformance/Registration/InboundTranslation/CompleteRegistration_Conformance_GWT.res.mjs +123 -0
  4. package/conformance/Registration/InboundTranslation/SignUp_Conformance_GWT.res +136 -0
  5. package/conformance/Registration/InboundTranslation/SignUp_Conformance_GWT.res.mjs +212 -0
  6. package/conformance/Registration/OutboundTranslation/CreateRegisteredPrincipal_Conformance_GWT.res +102 -0
  7. package/conformance/Registration/OutboundTranslation/CreateRegisteredPrincipal_Conformance_GWT.res.mjs +179 -0
  8. package/conformance/Registration/OutboundTranslation/SendRegistrationChallenge_Conformance_GWT.res +312 -0
  9. package/conformance/Registration/OutboundTranslation/SendRegistrationChallenge_Conformance_GWT.res.mjs +360 -0
  10. package/conformance/Registration/Registration_Conformance_Examples.res +58 -0
  11. package/conformance/Registration/Registration_Conformance_Examples.res.mjs +106 -0
  12. package/conformance/Registration/StateChange/RegistrationPolicy_Conformance_GWT.res +108 -0
  13. package/conformance/Registration/StateChange/RegistrationPolicy_Conformance_GWT.res.mjs +161 -0
  14. package/conformance/Registration/StateChange/RegistrationsByInvitation_Conformance_GWT.res +155 -0
  15. package/conformance/Registration/StateChange/RegistrationsByInvitation_Conformance_GWT.res.mjs +216 -0
  16. package/conformance/Registration/StateChange/Registrations_Conformance_GWT.res +469 -0
  17. package/conformance/Registration/StateChange/Registrations_Conformance_GWT.res.mjs +512 -0
  18. package/conformance/Registration/StateViewStream/RegistrationWindows_Conformance_GWT.res +33 -0
  19. package/conformance/Registration/StateViewStream/RegistrationWindows_Conformance_GWT.res.mjs +87 -0
  20. package/i18n/en.json +8 -0
  21. package/package.json +10 -6
  22. package/rescript.json +6 -1
  23. package/src/Registration/InboundTranslation/CompleteRegistration.res +2 -2
  24. package/src/Registration/InboundTranslation/CompleteRegistration.res.mjs +3 -3
  25. package/src/Registration/InboundTranslation/CompleteRegistration_Translation.res +1 -1
  26. package/src/Registration/InboundTranslation/CompleteRegistration_Translation.res.mjs +1 -1
  27. package/src/Registration/InboundTranslation/SignUp.res +19 -9
  28. package/src/Registration/InboundTranslation/SignUp.res.mjs +14 -7
  29. package/src/Registration/InboundTranslation/SignUp_Translation.res +32 -7
  30. package/src/Registration/InboundTranslation/SignUp_Translation.res.mjs +41 -8
  31. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal.res +5 -5
  32. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal.res.mjs +6 -5
  33. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal_Translation.res +10 -8
  34. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal_Translation.res.mjs +18 -10
  35. package/src/Registration/OutboundTranslation/SendRegistrationChallenge.res +24 -13
  36. package/src/Registration/OutboundTranslation/SendRegistrationChallenge.res.mjs +26 -16
  37. package/src/Registration/OutboundTranslation/SendRegistrationChallenge_Translation.res +115 -44
  38. package/src/Registration/OutboundTranslation/SendRegistrationChallenge_Translation.res.mjs +204 -66
  39. package/src/Registration/StateChange/RegistrationPolicy.res +3 -0
  40. package/src/Registration/StateChange/RegistrationPolicy.res.mjs +3 -0
  41. package/src/Registration/StateChange/RegistrationPolicy_Decision.res +6 -5
  42. package/src/Registration/StateChange/RegistrationPolicy_Decision.res.mjs +22 -15
  43. package/src/Registration/StateChange/Registrations.res +67 -41
  44. package/src/Registration/StateChange/Registrations.res.mjs +84 -51
  45. package/src/Registration/StateChange/Registrations_Decision.res +82 -39
  46. package/src/Registration/StateChange/Registrations_Decision.res.mjs +116 -58
  47. package/src/Registration/StateViewStream/RegistrationWindows.res +4 -0
  48. package/src/Registration/StateViewStream/RegistrationWindows.res.mjs +3 -3
@@ -0,0 +1,360 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
4
+ import * as Text$Reventless from "@reventlessdev/reventless-spec/src/i18n/Text.res.mjs";
5
+ import * as Outcome$ReventlessGwt from "@reventlessdev/reventless-gwt/src/Outcome.res.mjs";
6
+ import * as OutboundTranslation_GWT$ReventlessGwt from "@reventlessdev/reventless-gwt/src/OutboundTranslation_GWT.res.mjs";
7
+ import * as ContactAddressId$ReventlessRegistration from "../../../src/Registration/ContactAddressId.res.mjs";
8
+ import * as ContactVerification$ReventlessRegistration from "../../../src/ContactVerification.res.mjs";
9
+ import * as SendRegistrationChallenge$ReventlessRegistration from "../../../src/Registration/OutboundTranslation/SendRegistrationChallenge.res.mjs";
10
+ import * as Registration_Conformance_Examples$ReventlessRegistration from "../Registration_Conformance_Examples.res.mjs";
11
+ import * as SendRegistrationChallenge_Translation$ReventlessRegistration from "../../../src/Registration/OutboundTranslation/SendRegistrationChallenge_Translation.res.mjs";
12
+
13
+ function Make(App) {
14
+ let include = OutboundTranslation_GWT$ReventlessGwt.FromSlice({
15
+ name: SendRegistrationChallenge$ReventlessRegistration.name,
16
+ moduleUrl: SendRegistrationChallenge$ReventlessRegistration.moduleUrl,
17
+ consumedEventSchema: SendRegistrationChallenge$ReventlessRegistration.consumedEventSchema,
18
+ outboundItemSchema: SendRegistrationChallenge$ReventlessRegistration.outboundItemSchema,
19
+ inboundCommandSchema: SendRegistrationChallenge$ReventlessRegistration.inboundCommandSchema,
20
+ maxRetries: SendRegistrationChallenge$ReventlessRegistration.maxRetries,
21
+ targetName: SendRegistrationChallenge$ReventlessRegistration.targetName,
22
+ sourceNames: SendRegistrationChallenge$ReventlessRegistration.sourceNames,
23
+ externalSystem: undefined,
24
+ capabilityNeeds: SendRegistrationChallenge$ReventlessRegistration.capabilityNeeds,
25
+ traits: SendRegistrationChallenge$ReventlessRegistration.traits
26
+ })({
27
+ collect: SendRegistrationChallenge_Translation$ReventlessRegistration.collect,
28
+ translate: SendRegistrationChallenge_Translation$ReventlessRegistration.translate,
29
+ onExhausted: SendRegistrationChallenge_Translation$ReventlessRegistration.onExhausted,
30
+ moduleUrl: SendRegistrationChallenge_Translation$ReventlessRegistration.moduleUrl
31
+ });
32
+ let describe = include.describe;
33
+ let test = include.test;
34
+ let testSync = include.testSync;
35
+ let givenEvent = include.givenEvent;
36
+ let whenCollect = include.whenCollect;
37
+ let thenTodos = include.thenTodos;
38
+ let givenTodo = include.givenTodo;
39
+ let fakes = include.fakes;
40
+ let givenCapabilities = include.givenCapabilities;
41
+ let whenTranslated = include.whenTranslated;
42
+ let thenNoCommand = include.thenNoCommand;
43
+ let thenSent = include.thenSent;
44
+ let staffName = "Merchandiser";
45
+ let fresh = {
46
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.aliceId,
47
+ email: Registration_Conformance_Examples$ReventlessRegistration.aliceMail,
48
+ alreadyRegistered: false
49
+ };
50
+ let taken = {
51
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.aliceId,
52
+ email: Registration_Conformance_Examples$ReventlessRegistration.aliceMail,
53
+ alreadyRegistered: true
54
+ };
55
+ let invitation_invited = true;
56
+ let invitation_roles = [staffName];
57
+ let invitation = {
58
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.aliceId,
59
+ email: Registration_Conformance_Examples$ReventlessRegistration.aliceMail,
60
+ alreadyRegistered: false,
61
+ invited: invitation_invited,
62
+ roles: invitation_roles
63
+ };
64
+ let reissuedInvitation_invited = true;
65
+ let reissuedInvitation = {
66
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.aliceId,
67
+ email: Registration_Conformance_Examples$ReventlessRegistration.aliceMail,
68
+ alreadyRegistered: false,
69
+ invited: reissuedInvitation_invited
70
+ };
71
+ let withSecrets = () => fakes(undefined, undefined, ["Email"], undefined, undefined, "known-secret", t => `hashed:` + t, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
72
+ let thenLedgerTold = async (pending, expected) => {
73
+ let match = (await pending).result;
74
+ if (match.TAG !== "Ok") {
75
+ return Outcome$ReventlessGwt.fail({
76
+ TAG: "TranslateError",
77
+ expected: expected,
78
+ actual: undefined
79
+ });
80
+ }
81
+ let match$1 = match._0;
82
+ if (match$1 === undefined) {
83
+ return Outcome$ReventlessGwt.fail({
84
+ TAG: "TranslateError",
85
+ expected: expected,
86
+ actual: undefined
87
+ });
88
+ }
89
+ let match$2 = match$1[1];
90
+ let actual = ContactAddressId$ReventlessRegistration.toString(match$2.emailId) + `|` + match$2.proofHash;
91
+ if (actual === expected) {
92
+ return Outcome$ReventlessGwt.pass;
93
+ } else {
94
+ return Outcome$ReventlessGwt.fail({
95
+ TAG: "TranslateError",
96
+ expected: expected,
97
+ actual: actual
98
+ });
99
+ }
100
+ };
101
+ let thenMailRecorded = async (pending, expected) => {
102
+ let match = (await pending).result;
103
+ if (match.TAG !== "Ok") {
104
+ return Outcome$ReventlessGwt.fail({
105
+ TAG: "TranslateError",
106
+ expected: expected,
107
+ actual: undefined
108
+ });
109
+ }
110
+ let match$1 = match._0;
111
+ if (match$1 === undefined) {
112
+ return Outcome$ReventlessGwt.fail({
113
+ TAG: "TranslateError",
114
+ expected: expected,
115
+ actual: undefined
116
+ });
117
+ }
118
+ let match$2 = match$1[1];
119
+ let actual = Stdlib_Option.getOr(match$2.language, "") + `|` + Stdlib_Option.getOr(match$2.messageKey, "");
120
+ if (actual === expected) {
121
+ return Outcome$ReventlessGwt.pass;
122
+ } else {
123
+ return Outcome$ReventlessGwt.fail({
124
+ TAG: "TranslateError",
125
+ expected: expected,
126
+ actual: actual
127
+ });
128
+ }
129
+ };
130
+ let mail = (subject, body, languageOpt) => {
131
+ let language = languageOpt !== undefined ? languageOpt : "en";
132
+ return {
133
+ TAG: "Sent",
134
+ recipient: {
135
+ TAG: "ToEmail",
136
+ _0: Registration_Conformance_Examples$ReventlessRegistration.aliceAddress
137
+ },
138
+ message: {
139
+ subject: subject,
140
+ body: body,
141
+ language: language
142
+ }
143
+ };
144
+ };
145
+ let german = Text$Reventless.fromCatalogues("de", undefined, {
146
+ de: {
147
+ "registration.challenge.subject": "Registrierung abschließen",
148
+ "registration.challenge.body": "Ihr Code lautet {token}. Er läuft in {expiresIn} ab.",
149
+ "registration.invited.body": "Sie sind eingeladen{hasRoles, select, yes {, als {roles}} other {}}. Ihr Code lautet {token}."
150
+ }
151
+ });
152
+ let offersGerman = Text$Reventless.fromCatalogues("en", undefined, {
153
+ de: {
154
+ "registration.challenge.subject": "Registrierung abschließen",
155
+ "registration.challenge.body": "Ihr Code lautet {token}. Er läuft in {expiresIn} ab."
156
+ }
157
+ });
158
+ describe("SendRegistrationChallenge OutboundTranslationSlice", () => {
159
+ testSync("a request is collected once per address and time", () => thenTodos(whenCollect(givenEvent({
160
+ TAG: "RegistrationRequested",
161
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.aliceId,
162
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
163
+ requestedAt: "2026-10-24T09:00:00.000Z"
164
+ }), undefined), [[
165
+ "fp:contactAddress:alice@example.com:2026-10-24T09:00:00.000Z",
166
+ fresh
167
+ ]]));
168
+ testSync("an erased address is not written to", () => thenTodos(whenCollect(givenEvent({
169
+ TAG: "RegistrationRequested",
170
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.aliceId,
171
+ email: "Erased",
172
+ requestedAt: "2026-10-24T09:00:00.000Z"
173
+ }), undefined), []));
174
+ testSync("an invitation is collected as one, apart from a sign-up at the same time", () => thenTodos(whenCollect(givenEvent({
175
+ TAG: "RegistrationInvited",
176
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.aliceId,
177
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
178
+ roles: [staffName],
179
+ invitedBy: "u_inviter",
180
+ invitedAt: "2026-10-24T09:00:00.000Z"
181
+ }), undefined), [[
182
+ "fp:contactAddress:alice@example.com:invited:2026-10-24T09:00:00.000Z",
183
+ invitation
184
+ ]]));
185
+ testSync("a reissued invitation's code is collected as an invitation", () => thenTodos(whenCollect(givenEvent({
186
+ TAG: "RegistrationChallengeReissued",
187
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.aliceId,
188
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
189
+ reissuedAt: "2026-10-25T09:00:00.000Z",
190
+ invitedBy: "u_inviter"
191
+ }), undefined), [[
192
+ "fp:contactAddress:alice@example.com:reissued:2026-10-25T09:00:00.000Z",
193
+ reissuedInvitation
194
+ ]]));
195
+ testSync("a reissued sign-up's code is collected as a sign-up", () => thenTodos(whenCollect(givenEvent({
196
+ TAG: "RegistrationChallengeReissued",
197
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.aliceId,
198
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
199
+ reissuedAt: "2026-10-25T09:00:00.000Z"
200
+ }), undefined), [[
201
+ "fp:contactAddress:alice@example.com:reissued:2026-10-25T09:00:00.000Z",
202
+ {
203
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.aliceId,
204
+ email: Registration_Conformance_Examples$ReventlessRegistration.aliceMail,
205
+ alreadyRegistered: false,
206
+ invited: false
207
+ }
208
+ ]]));
209
+ test("a challenge is opened against the hash, never the secret", undefined, () => thenLedgerTold(whenTranslated(givenCapabilities(givenTodo("t1", fresh), withSecrets())), "fp:contactAddress:alice@example.com|hashed:known-secret"));
210
+ test("the secret itself is what goes to the address", undefined, () => thenSent(whenTranslated(givenCapabilities(givenTodo("t1", fresh), withSecrets())), [
211
+ {
212
+ TAG: "TokenDrawn",
213
+ length: ContactVerification$ReventlessRegistration.emailPolicy.proofLength,
214
+ alphabet: ContactVerification$ReventlessRegistration.emailPolicy.proofAlphabet
215
+ },
216
+ {
217
+ TAG: "Hashed",
218
+ input: "known-secret"
219
+ },
220
+ mail("Finish your registration", SendRegistrationChallenge_Translation$ReventlessRegistration.challengeBody("known-secret"), undefined)
221
+ ]));
222
+ test("an invitation's secret goes out worded as an invitation, naming the roles", undefined, () => thenSent(whenTranslated(givenCapabilities(givenTodo("t3", invitation), withSecrets())), [
223
+ {
224
+ TAG: "TokenDrawn",
225
+ length: ContactVerification$ReventlessRegistration.emailPolicy.proofLength,
226
+ alphabet: ContactVerification$ReventlessRegistration.emailPolicy.proofAlphabet
227
+ },
228
+ {
229
+ TAG: "Hashed",
230
+ input: "known-secret"
231
+ },
232
+ mail("You are invited to create an account", SendRegistrationChallenge_Translation$ReventlessRegistration.invitationBody("known-secret", [staffName]), undefined)
233
+ ]));
234
+ test("a reissued invitation's secret is worded as an invitation, with no role to name", undefined, () => thenSent(whenTranslated(givenCapabilities(givenTodo("t4", reissuedInvitation), withSecrets())), [
235
+ {
236
+ TAG: "TokenDrawn",
237
+ length: ContactVerification$ReventlessRegistration.emailPolicy.proofLength,
238
+ alphabet: ContactVerification$ReventlessRegistration.emailPolicy.proofAlphabet
239
+ },
240
+ {
241
+ TAG: "Hashed",
242
+ input: "known-secret"
243
+ },
244
+ mail("You are invited to create an account", SendRegistrationChallenge_Translation$ReventlessRegistration.invitationBody("known-secret", undefined), undefined)
245
+ ]));
246
+ test("a taken address is told someone tried, and no challenge opens", undefined, () => thenSent(whenTranslated(givenCapabilities(givenTodo("t2", taken), withSecrets())), [mail("Someone tried to register with your address", SendRegistrationChallenge_Translation$ReventlessRegistration.noticeBody, undefined)]));
247
+ test("a deployment writing German sends the challenge in German", undefined, () => thenSent(whenTranslated(givenCapabilities(givenTodo("t1", fresh), fakes(undefined, undefined, ["Email"], undefined, undefined, "known-secret", undefined, undefined, undefined, undefined, german, undefined, undefined, undefined, undefined))), [
248
+ {
249
+ TAG: "TokenDrawn",
250
+ length: ContactVerification$ReventlessRegistration.emailPolicy.proofLength,
251
+ alphabet: ContactVerification$ReventlessRegistration.emailPolicy.proofAlphabet
252
+ },
253
+ {
254
+ TAG: "Hashed",
255
+ input: "known-secret"
256
+ },
257
+ mail("Registrierung abschließen", "Ihr Code lautet known-secret. Er läuft in 1 Tag ab.", "de")
258
+ ]));
259
+ test("a key the catalogue lacks is sent in the code's English, labeled so", undefined, () => thenSent(whenTranslated(givenCapabilities(givenTodo("t3", invitation), fakes(undefined, undefined, ["Email"], undefined, undefined, "known-secret", undefined, undefined, undefined, undefined, german, undefined, undefined, undefined, undefined))), [
260
+ {
261
+ TAG: "TokenDrawn",
262
+ length: ContactVerification$ReventlessRegistration.emailPolicy.proofLength,
263
+ alphabet: ContactVerification$ReventlessRegistration.emailPolicy.proofAlphabet
264
+ },
265
+ {
266
+ TAG: "Hashed",
267
+ input: "known-secret"
268
+ },
269
+ {
270
+ TAG: "Sent",
271
+ recipient: {
272
+ TAG: "ToEmail",
273
+ _0: Registration_Conformance_Examples$ReventlessRegistration.aliceAddress
274
+ },
275
+ message: {
276
+ subject: "You are invited to create an account",
277
+ body: `Sie sind eingeladen, als ` + staffName + `. Ihr Code lautet known-secret.`,
278
+ language: "de"
279
+ }
280
+ }
281
+ ]));
282
+ test("a visitor's language writes the code, and the ledger is told so", undefined, () => {
283
+ let newrecord = {...fresh};
284
+ return thenMailRecorded(whenTranslated(givenCapabilities(givenTodo("t1", (newrecord.language = "de-AT", newrecord)), fakes(undefined, undefined, ["Email"], undefined, undefined, "known-secret", undefined, undefined, undefined, undefined, offersGerman, undefined, undefined, undefined, undefined))), "de|registration.challenge.body");
285
+ });
286
+ test("an account's own language wins over the request's", undefined, () => {
287
+ let newrecord = {...taken};
288
+ return thenSent(whenTranslated(givenCapabilities(givenTodo("t2", (newrecord.language = "de", newrecord)), fakes(undefined, undefined, ["Email"], undefined, undefined, undefined, undefined, undefined, undefined, undefined, Text$Reventless.fromCatalogues("en", async param => "en", {
289
+ de: {
290
+ "registration.taken.subject": "Jemand wollte sich registrieren"
291
+ }
292
+ }), undefined, undefined, undefined, undefined))), [mail("Someone tried to register with your address", SendRegistrationChallenge_Translation$ReventlessRegistration.noticeBody, undefined)]);
293
+ });
294
+ test("a catalogue that cannot be read sends nothing, so the mail is tried again", undefined, () => thenSent(whenTranslated(givenCapabilities(givenTodo("t1", fresh), fakes(undefined, undefined, ["Email"], undefined, undefined, "known-secret", undefined, undefined, undefined, undefined, {
295
+ default: german.default,
296
+ languageFor: german.languageFor,
297
+ catalogue: async param => ({
298
+ TAG: "Error",
299
+ _0: "the catalogue did not load"
300
+ })
301
+ }, undefined, undefined, undefined, undefined))), [
302
+ {
303
+ TAG: "TokenDrawn",
304
+ length: ContactVerification$ReventlessRegistration.emailPolicy.proofLength,
305
+ alphabet: ContactVerification$ReventlessRegistration.emailPolicy.proofAlphabet
306
+ },
307
+ {
308
+ TAG: "Hashed",
309
+ input: "known-secret"
310
+ }
311
+ ]));
312
+ test("a notice sends nothing back to the ledger", undefined, () => thenNoCommand(whenTranslated(givenCapabilities(givenTodo("t2", taken), withSecrets()))));
313
+ });
314
+ return {
315
+ describe: describe,
316
+ test: test,
317
+ testSync: testSync,
318
+ encItems: include.encItems,
319
+ commandPairJson: include.commandPairJson,
320
+ errorOf: include.errorOf,
321
+ givenEvent: givenEvent,
322
+ whenCollect: whenCollect,
323
+ thenTodos: thenTodos,
324
+ givenTodo: givenTodo,
325
+ fakes: fakes,
326
+ givenCapabilities: givenCapabilities,
327
+ attemptWith: include.attemptWith,
328
+ attempts: include.attempts,
329
+ whenTranslated: whenTranslated,
330
+ whenTranslateMocked: include.whenTranslateMocked,
331
+ whenTranslateRetrying: include.whenTranslateRetrying,
332
+ whenExhausted: include.whenExhausted,
333
+ thenCommand: include.thenCommand,
334
+ thenNoCommand: thenNoCommand,
335
+ thenSent: thenSent,
336
+ thenNothingSent: include.thenNothingSent,
337
+ thenRetryRecorded: include.thenRetryRecorded,
338
+ current: include.current,
339
+ statusName: include.statusName,
340
+ thenTodoStatus: include.thenTodoStatus,
341
+ Outcome: undefined,
342
+ staffName: staffName,
343
+ fresh: fresh,
344
+ taken: taken,
345
+ invitation: invitation,
346
+ reissuedInvitation: reissuedInvitation,
347
+ policy: ContactVerification$ReventlessRegistration.emailPolicy,
348
+ withSecrets: withSecrets,
349
+ thenLedgerTold: thenLedgerTold,
350
+ thenMailRecorded: thenMailRecorded,
351
+ mail: mail,
352
+ german: german,
353
+ offersGerman: offersGerman
354
+ };
355
+ }
356
+
357
+ export {
358
+ Make,
359
+ }
360
+ /* Text-Reventless Not a pure module */
@@ -0,0 +1,58 @@
1
+ // What the conformance suites share: one address, and the roles of each kind a scenario needs,
2
+ // read off the app's table. A scenario needing a kind the table lacks is listed, not run.
3
+
4
+ let alice = ContactAddressId.makeFromString("fp:contactAddress:alice@example.com")
5
+ /** The ledger's id for the address, as the test secrets fingerprint it. */
6
+ let aliceId = "fp:contactAddress:alice@example.com"
7
+ let aliceAddress = "alice@example.com"
8
+ let aliceMail = Reventless.Email.unsafe(aliceAddress)
9
+ let personal = Reventless.Pii.Value(aliceMail)
10
+ let goodPassword = "correct horse battery"
11
+ let secretHash = "hash-of-the-secret"
12
+
13
+ let nameOf = (role: Reventless.Role.name): string => (role :> string)
14
+
15
+ /** The roles a visitor may sign up for. */
16
+ let selfService = (table: Reventless.Admission.t) => table->Reventless.Admission.selfService
17
+
18
+ /** The roles a person is invited to. */
19
+ let byInvitation = (table: Reventless.Admission.t): array<Reventless.Role.name> =>
20
+ table->Array.filterMap(e =>
21
+ switch e.strategy {
22
+ | Invitation(_) => Some(e.role)
23
+ | SelfService | Provisioned => None
24
+ }
25
+ )
26
+
27
+ /** The roles the table declares and no visitor may sign up for. */
28
+ let notSelfService = (table: Reventless.Admission.t): array<Reventless.Role.name> =>
29
+ table->Array.filterMap(e =>
30
+ switch e.strategy {
31
+ | SelfService => None
32
+ | Invitation(_) | Provisioned => Some(e.role)
33
+ }
34
+ )
35
+
36
+ /** A role the table does not declare. */
37
+ let unknownRole = (table: Reventless.Admission.t): Reventless.Role.name => {
38
+ let rec find = name => table->Array.some(e => nameOf(e.role) == name) ? find(name ++ "X") : name
39
+ Reventless.Role.make(find("Stranger"))
40
+ }
41
+
42
+ /** A need a scenario has of the table: present, or the reason it cannot run. */
43
+ type need = option<string>
44
+
45
+ let has = (roles: array<Reventless.Role.name>, ~kind: string): need =>
46
+ roles == [] ? Some(`the table declares no ${kind} role`) : None
47
+
48
+ let hasOne = (roles: array<Reventless.Role.name>, ~kind: string): need =>
49
+ Array.length(roles) == 1 ? None : Some(`the table does not declare exactly one ${kind} role`)
50
+
51
+ /** The first of the needs that is not met. */
52
+ let unmet = (needs: array<need>): option<string> =>
53
+ needs->Array.find(Option.isSome)->Option.flatMap(n => n)
54
+
55
+ /** A role to put in a scenario's values: the first of its kind, or a stand-in when the table
56
+ has none, in which case the scenario is listed rather than run. */
57
+ let first = (roles: array<Reventless.Role.name>): Reventless.Role.name =>
58
+ roles->Array.get(0)->Option.getOr(Reventless.Role.make("Absent"))
@@ -0,0 +1,106 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
4
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
5
+ import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js";
6
+ import * as Admission$Reventless from "@reventlessdev/reventless-spec/src/types/Admission.res.mjs";
7
+ import * as ContactAddressId$ReventlessRegistration from "../../src/Registration/ContactAddressId.res.mjs";
8
+
9
+ let alice = ContactAddressId$ReventlessRegistration.makeFromString("fp:contactAddress:alice@example.com");
10
+
11
+ let aliceAddress = "alice@example.com";
12
+
13
+ let personal = {
14
+ TAG: "Value",
15
+ _0: aliceAddress
16
+ };
17
+
18
+ function nameOf(role) {
19
+ return role;
20
+ }
21
+
22
+ let selfService = Admission$Reventless.selfService;
23
+
24
+ function byInvitation(table) {
25
+ return Stdlib_Array.filterMap(table, e => {
26
+ let match = e.strategy;
27
+ if (typeof match !== "object") {
28
+ return;
29
+ } else {
30
+ return e.role;
31
+ }
32
+ });
33
+ }
34
+
35
+ function notSelfService(table) {
36
+ return Stdlib_Array.filterMap(table, e => {
37
+ let match = e.strategy;
38
+ if (typeof match !== "object" && match === "SelfService") {
39
+ return;
40
+ } else {
41
+ return e.role;
42
+ }
43
+ });
44
+ }
45
+
46
+ function unknownRole(table) {
47
+ let _name = "Stranger";
48
+ while (true) {
49
+ let name = _name;
50
+ if (!table.some(e => e.role === name)) {
51
+ return name;
52
+ }
53
+ _name = name + "X";
54
+ continue;
55
+ };
56
+ }
57
+
58
+ function has(roles, kind) {
59
+ if (Primitive_object.equal(roles, [])) {
60
+ return `the table declares no ` + kind + ` role`;
61
+ }
62
+ }
63
+
64
+ function hasOne(roles, kind) {
65
+ if (roles.length === 1) {
66
+ return;
67
+ } else {
68
+ return `the table does not declare exactly one ` + kind + ` role`;
69
+ }
70
+ }
71
+
72
+ function unmet(needs) {
73
+ return Stdlib_Option.flatMap(needs.find(Stdlib_Option.isSome), n => n);
74
+ }
75
+
76
+ function first(roles) {
77
+ return Stdlib_Option.getOr(roles[0], "Absent");
78
+ }
79
+
80
+ let aliceId = "fp:contactAddress:alice@example.com";
81
+
82
+ let aliceMail = aliceAddress;
83
+
84
+ let goodPassword = "correct horse battery";
85
+
86
+ let secretHash = "hash-of-the-secret";
87
+
88
+ export {
89
+ alice,
90
+ aliceId,
91
+ aliceAddress,
92
+ aliceMail,
93
+ personal,
94
+ goodPassword,
95
+ secretHash,
96
+ nameOf,
97
+ selfService,
98
+ byInvitation,
99
+ notSelfService,
100
+ unknownRole,
101
+ has,
102
+ hasOne,
103
+ unmet,
104
+ first,
105
+ }
106
+ /* alice Not a pure module */
@@ -0,0 +1,108 @@
1
+ // Whether visitors may sign up for a role right now, for any admission table. A role declared
2
+ // self-service is open until an administrator closes it; a role not declared self-service has no
3
+ // policy to open, whatever an administrator says. Opening an open role or closing a closed one
4
+ // records nothing.
5
+
6
+ module Make = (App: Reventless.Admission.Declaration) => {
7
+ module Policy = RegistrationPolicy
8
+ module AppPolicy = RegistrationPolicy_Decision.Make(App)
9
+ open Policy
10
+ include ReventlessGwt.Decision_GWT.Make(Policy, AppPolicy)
11
+ open Registration_Conformance_Examples
12
+
13
+ let needing = needs =>
14
+ (name, body) =>
15
+ switch unmet(needs) {
16
+ | None => test(name, body)
17
+ | Some(why) => todo(`${name} (${why})`)
18
+ }
19
+
20
+ let selfServiceRoles = selfService(App.table)
21
+ let otherRoles = notSelfService(App.table)
22
+ let role = first(selfServiceRoles)
23
+ let other = first(otherRoles)
24
+ let until = "2026-10-31T00:00:00.000Z"
25
+
26
+ describe("RegistrationPolicy StateChangeSlice", () => {
27
+ let test = needing([has(selfServiceRoles, ~kind="self-service")])
28
+
29
+ // Nothing recorded is the deployment's starting state, which this slice does not know, so
30
+ // opening from it records.
31
+ // scenario-id: 1df7c562-74b8-4405-b080-e0a2b673552b
32
+ test("opening a role nothing is recorded about records it", () =>
33
+ givenEvents([])
34
+ ->whenCmd(OpenRegistration({role: role}))
35
+ ->thenEvent(RegistrationOpened({role: role}))
36
+ )
37
+
38
+ // And so does closing from it: a deployment that starts open is closed this way.
39
+ // scenario-id: 58eabbd4-126a-471b-bc4e-d51dd2ae6dc2
40
+ test("closing a role nothing is recorded about records it", () =>
41
+ givenEvents([])
42
+ ->whenCmd(CloseRegistration({role: role}))
43
+ ->thenEvent(RegistrationClosed({role: role}))
44
+ )
45
+
46
+ // scenario-id: af58e483-9fc1-41a1-8534-9d3df3b4d230
47
+ test("an open window carries its end", () =>
48
+ givenEvents([])
49
+ ->whenCmd(OpenRegistration({role, until}))
50
+ ->thenEvent(RegistrationOpened({role, until}))
51
+ )
52
+
53
+ // scenario-id: 794cc4eb-60f9-4bba-a7e2-6bd2675b9cbd
54
+ test("opening an open role again records nothing", () =>
55
+ givenEvents([RegistrationOpened({role: role})])
56
+ ->whenCmd(OpenRegistration({role: role}))
57
+ ->thenNoEvent
58
+ )
59
+
60
+ // Moving the end of a window is a change, so it is recorded.
61
+ // scenario-id: 93cb2b9a-f220-4433-bfcc-34076b6c62a0
62
+ test("giving an open role an end records it", () =>
63
+ givenEvents([RegistrationOpened({role: role})])
64
+ ->whenCmd(OpenRegistration({role, until}))
65
+ ->thenEvent(RegistrationOpened({role, until}))
66
+ )
67
+
68
+ // scenario-id: b0700a95-4bcd-4018-8e5d-902dc784bc33
69
+ test("closing an open role records it", () =>
70
+ givenEvents([])
71
+ ->whenCmd(CloseRegistration({role: role}))
72
+ ->thenEvent(RegistrationClosed({role: role}))
73
+ )
74
+
75
+ // scenario-id: 6d20339a-e89b-445b-9df2-5b0464f2d1e7
76
+ test("closing a closed role records nothing", () =>
77
+ givenEvents([RegistrationClosed({role: role})])
78
+ ->whenCmd(CloseRegistration({role: role}))
79
+ ->thenNoEvent
80
+ )
81
+
82
+ // scenario-id: 3f0b6e2a-6c1d-4f7e-9a2b-5d8c1e4f7a90
83
+ test("a closed role is opened again", () =>
84
+ givenEvents([RegistrationClosed({role: role})])
85
+ ->whenCmd(OpenRegistration({role: role}))
86
+ ->thenEvent(RegistrationOpened({role: role}))
87
+ )
88
+
89
+ // scenario-id: 87ea8d6f-fa39-43f9-8eb2-60fc1de38fa3
90
+ test("only an administrator closes registration", () =>
91
+ givenEvents([])
92
+ ->asCaller(Caller.inRoles([]))
93
+ ->whenCmd(CloseRegistration({role: role}))
94
+ ->thenForbidden
95
+ )
96
+
97
+ let test = needing([has(otherRoles, ~kind="non-self-service")])
98
+
99
+ // The declaration is the hard cap: no command opens a role it does not declare
100
+ // self-service.
101
+ // scenario-id: 8d2c4b7e-1a3f-4e5d-b6c7-9f0a1b2c3d4e
102
+ test("a role not declared self-service cannot be opened", () =>
103
+ givenEvents([])
104
+ ->whenCmd(OpenRegistration({role: other}))
105
+ ->thenError(NotSelfService({role: other}))
106
+ )
107
+ })
108
+ }