@reventlessdev/reventless-registration 1.0.0-alpha.4 → 1.0.0-alpha.41

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 (30) hide show
  1. package/README.md +10 -0
  2. package/i18n/en.json +8 -0
  3. package/package.json +7 -6
  4. package/src/Registration/ContactAddressId.res +27 -3
  5. package/src/Registration/ContactAddressId.res.mjs +26 -2
  6. package/src/Registration/InboundTranslation/CompleteRegistration.res +2 -2
  7. package/src/Registration/InboundTranslation/CompleteRegistration.res.mjs +3 -3
  8. package/src/Registration/InboundTranslation/CompleteRegistration_Translation.res +9 -6
  9. package/src/Registration/InboundTranslation/CompleteRegistration_Translation.res.mjs +16 -9
  10. package/src/Registration/InboundTranslation/SignUp.res +19 -8
  11. package/src/Registration/InboundTranslation/SignUp.res.mjs +15 -6
  12. package/src/Registration/InboundTranslation/SignUp_Translation.res +51 -15
  13. package/src/Registration/InboundTranslation/SignUp_Translation.res.mjs +50 -8
  14. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal.res +9 -3
  15. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal.res.mjs +7 -3
  16. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal_Translation.res +10 -7
  17. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal_Translation.res.mjs +17 -8
  18. package/src/Registration/OutboundTranslation/SendRegistrationChallenge.res +39 -7
  19. package/src/Registration/OutboundTranslation/SendRegistrationChallenge.res.mjs +27 -11
  20. package/src/Registration/OutboundTranslation/SendRegistrationChallenge_Translation.res +115 -44
  21. package/src/Registration/OutboundTranslation/SendRegistrationChallenge_Translation.res.mjs +203 -61
  22. package/src/Registration/StateChange/RegistrationPolicy.res +3 -0
  23. package/src/Registration/StateChange/RegistrationPolicy.res.mjs +3 -0
  24. package/src/Registration/StateChange/RegistrationPolicy_Decision.res +6 -5
  25. package/src/Registration/StateChange/RegistrationPolicy_Decision.res.mjs +22 -15
  26. package/src/Registration/StateChange/Registrations.res +79 -27
  27. package/src/Registration/StateChange/Registrations.res.mjs +85 -39
  28. package/src/Registration/StateChange/Registrations_Decision.res +96 -36
  29. package/src/Registration/StateChange/Registrations_Decision.res.mjs +119 -52
  30. package/src/Registration/StateViewStream/RegistrationWindows.res.mjs +1 -1
@@ -1,5 +1,6 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
3
4
  import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js";
4
5
  import * as DateTime$Reventless from "@reventlessdev/reventless-spec/src/semantic/DateTime.res.mjs";
5
6
  import * as Admission$Reventless from "@reventlessdev/reventless-spec/src/types/Admission.res.mjs";
@@ -14,6 +15,13 @@ let initialState = {
14
15
  lastNoticeAt: undefined
15
16
  };
16
17
 
18
+ function contactOf(emailId) {
19
+ return {
20
+ TAG: "ByEmail",
21
+ _0: ContactAddressId$ReventlessRegistration.toString(emailId)
22
+ };
23
+ }
24
+
17
25
  function purposeOf(p) {
18
26
  return RegistrationChallenge$ReventlessRegistration.purposeOf(p.invitedBy);
19
27
  }
@@ -45,8 +53,10 @@ function evolve(state, event) {
45
53
  stage: {
46
54
  TAG: "Pending",
47
55
  _0: {
56
+ email: event.email,
48
57
  requestedAt: event.requestedAt,
49
58
  roles: event.roles,
59
+ language: event.language,
50
60
  challenge: undefined,
51
61
  proofHash: undefined
52
62
  }
@@ -59,9 +69,11 @@ function evolve(state, event) {
59
69
  stage: {
60
70
  TAG: "Pending",
61
71
  _0: {
72
+ email: event.email,
62
73
  requestedAt: event.invitedAt,
63
74
  roles: event.roles,
64
75
  invitedBy: event.invitedBy,
76
+ language: event.language,
65
77
  challenge: undefined,
66
78
  proofHash: undefined
67
79
  }
@@ -109,7 +121,7 @@ function evolve(state, event) {
109
121
  _0: (newrecord$1.proofHash = event.proofHash, newrecord$1.challenge = {
110
122
  contact: {
111
123
  TAG: "ByEmail",
112
- _0: ContactAddressId$ReventlessRegistration.toString(event.email)
124
+ _0: ContactAddressId$ReventlessRegistration.toString(event.emailId)
113
125
  },
114
126
  purpose: RegistrationChallenge$ReventlessRegistration.purposeOf(p$2.invitedBy),
115
127
  issuedAt: event.issuedAt,
@@ -156,20 +168,33 @@ function evolve(state, event) {
156
168
  stage: "Completed",
157
169
  lastNoticeAt: state.lastNoticeAt
158
170
  };
171
+ case "RegistrationReleased" :
172
+ return {
173
+ admission: state.admission,
174
+ stage: "Unclaimed",
175
+ lastNoticeAt: undefined
176
+ };
159
177
  }
160
178
  }
161
179
 
162
- function admits(admission, table, role, at) {
180
+ function admits(admission, table, role, at, initially) {
181
+ let starting = () => {
182
+ if (Admission$Reventless.isSelfService(table, role)) {
183
+ return Stdlib_Option.getOr(initially, "open") === "open";
184
+ } else {
185
+ return false;
186
+ }
187
+ };
163
188
  if (typeof admission !== "object") {
164
189
  if (admission === "Unset") {
165
- return Admission$Reventless.isSelfService(table, role);
190
+ return starting();
166
191
  } else {
167
192
  return false;
168
193
  }
169
194
  }
170
195
  let until = admission._0;
171
- if (until !== undefined) {
172
- return DateTime$Reventless.isBefore(at, until);
196
+ if (until !== undefined && !DateTime$Reventless.isBefore(at, until)) {
197
+ return starting();
173
198
  } else {
174
199
  return true;
175
200
  }
@@ -208,10 +233,12 @@ function Make(App) {
208
233
  let decide = (state, command) => {
209
234
  switch (command.TAG) {
210
235
  case "Register" :
236
+ let language = command.language;
211
237
  let requestedAt = command.requestedAt;
212
238
  let role = command.role;
213
239
  let email = command.email;
214
- if (!admits(state.admission, App.table, role, requestedAt)) {
240
+ let emailId = command.emailId;
241
+ if (!admits(state.admission, App.table, role, requestedAt, command.initially)) {
215
242
  return {
216
243
  TAG: "Ok",
217
244
  _0: []
@@ -226,13 +253,18 @@ function Make(App) {
226
253
  _0: [
227
254
  {
228
255
  TAG: "RegistrationExpired",
229
- email: email
256
+ emailId: emailId
230
257
  },
231
258
  {
232
259
  TAG: "RegistrationRequested",
233
- email: email,
260
+ emailId: emailId,
261
+ email: {
262
+ TAG: "Value",
263
+ _0: email
264
+ },
234
265
  roles: roles,
235
- requestedAt: requestedAt
266
+ requestedAt: requestedAt,
267
+ language: language
236
268
  }
237
269
  ]
238
270
  };
@@ -249,9 +281,14 @@ function Make(App) {
249
281
  TAG: "Ok",
250
282
  _0: [{
251
283
  TAG: "RegistrationRequested",
252
- email: email,
284
+ emailId: emailId,
285
+ email: {
286
+ TAG: "Value",
287
+ _0: email
288
+ },
253
289
  roles: roles,
254
- requestedAt: requestedAt
290
+ requestedAt: requestedAt,
291
+ language: language
255
292
  }]
256
293
  };
257
294
  case "Verified" :
@@ -261,36 +298,29 @@ function Make(App) {
261
298
  };
262
299
  case "Completed" :
263
300
  let last = state.lastNoticeAt;
264
- if (last !== undefined) {
265
- if (ContactVerification_Guards$ReventlessRegistration.elapsedSeconds(last, requestedAt) < 3600) {
266
- return {
267
- TAG: "Ok",
268
- _0: []
269
- };
270
- } else {
271
- return {
272
- TAG: "Ok",
273
- _0: [{
274
- TAG: "RegistrationAttemptedOnTakenAddress",
275
- email: email,
276
- attemptedAt: requestedAt
277
- }]
278
- };
279
- }
280
- } else {
301
+ if (last !== undefined && ContactVerification_Guards$ReventlessRegistration.elapsedSeconds(last, requestedAt) < 3600) {
281
302
  return {
282
303
  TAG: "Ok",
283
- _0: [{
284
- TAG: "RegistrationAttemptedOnTakenAddress",
285
- email: email,
286
- attemptedAt: requestedAt
287
- }]
304
+ _0: []
288
305
  };
289
306
  }
307
+ return {
308
+ TAG: "Ok",
309
+ _0: [{
310
+ TAG: "RegistrationAttemptedOnTakenAddress",
311
+ emailId: emailId,
312
+ email: {
313
+ TAG: "Value",
314
+ _0: email
315
+ },
316
+ attemptedAt: requestedAt
317
+ }]
318
+ };
290
319
  }
320
+ break;
291
321
  case "IssueRegistrationChallenge" :
292
322
  let issuedAt = command.issuedAt;
293
- let email$1 = command.email;
323
+ let emailId$1 = command.emailId;
294
324
  let p$1 = state.stage;
295
325
  if (typeof p$1 !== "object") {
296
326
  return {
@@ -301,16 +331,18 @@ function Make(App) {
301
331
  let p$2 = p$1._0;
302
332
  let match = ContactVerification_Guards$ReventlessRegistration.onIssueRequested({
303
333
  TAG: "ByEmail",
304
- _0: ContactAddressId$ReventlessRegistration.toString(email$1)
334
+ _0: ContactAddressId$ReventlessRegistration.toString(emailId$1)
305
335
  }, p$2.challenge, issuedAt, RegistrationChallenge$ReventlessRegistration.policyFor(RegistrationChallenge$ReventlessRegistration.purposeOf(p$2.invitedBy)));
306
336
  if (match === "Issue") {
307
337
  return {
308
338
  TAG: "Ok",
309
339
  _0: [{
310
340
  TAG: "RegistrationChallengeIssued",
311
- email: email$1,
341
+ emailId: emailId$1,
312
342
  proofHash: command.proofHash,
313
- issuedAt: issuedAt
343
+ issuedAt: issuedAt,
344
+ language: command.language,
345
+ messageKey: command.messageKey
314
346
  }]
315
347
  };
316
348
  } else {
@@ -321,7 +353,7 @@ function Make(App) {
321
353
  }
322
354
  case "SubmitRegistrationProof" :
323
355
  let proofHash = command.proofHash;
324
- let email$2 = command.email;
356
+ let emailId$2 = command.emailId;
325
357
  let p$3 = state.stage;
326
358
  if (typeof p$3 !== "object") {
327
359
  return {
@@ -350,7 +382,8 @@ function Make(App) {
350
382
  TAG: "Ok",
351
383
  _0: [{
352
384
  TAG: "RegistrationProofAccepted",
353
- email: email$2,
385
+ emailId: emailId$2,
386
+ email: p$4.email,
354
387
  roles: p$4.roles,
355
388
  proofHash: proofHash
356
389
  }]
@@ -360,7 +393,7 @@ function Make(App) {
360
393
  TAG: "Ok",
361
394
  _0: [{
362
395
  TAG: "RegistrationProofRefused",
363
- email: email$2,
396
+ emailId: emailId$2,
364
397
  reason: refusalReason(reason._0)
365
398
  }]
366
399
  };
@@ -373,7 +406,7 @@ function Make(App) {
373
406
  TAG: "Ok",
374
407
  _0: [{
375
408
  TAG: "RegistrationCompleted",
376
- email: command.email
409
+ emailId: command.emailId
377
410
  }]
378
411
  };
379
412
  } else {
@@ -391,7 +424,7 @@ function Make(App) {
391
424
  case "Invite" :
392
425
  let requestedAt$1 = command.requestedAt;
393
426
  let roles$1 = command.roles;
394
- let email$3 = command.email;
427
+ let emailId$3 = command.emailId;
395
428
  let role$1 = roles$1.find(r => !isByInvitation(App.table, r));
396
429
  if (role$1 !== undefined) {
397
430
  return {
@@ -408,14 +441,21 @@ function Make(App) {
408
441
  _0: "NoRoleToGrant"
409
442
  };
410
443
  }
411
- let invited_1 = roles$1.map(r => r);
412
- let invited_2 = command.invitedBy;
444
+ let invited_1 = {
445
+ TAG: "Value",
446
+ _0: command.email
447
+ };
448
+ let invited_2 = roles$1.map(r => r);
449
+ let invited_3 = command.invitedBy;
450
+ let invited_5 = command.language;
413
451
  let invited = {
414
452
  TAG: "RegistrationInvited",
415
- email: email$3,
416
- roles: invited_1,
417
- invitedBy: invited_2,
418
- invitedAt: requestedAt$1
453
+ emailId: emailId$3,
454
+ email: invited_1,
455
+ roles: invited_2,
456
+ invitedBy: invited_3,
457
+ invitedAt: requestedAt$1,
458
+ language: invited_5
419
459
  };
420
460
  let p$5 = state.stage;
421
461
  if (typeof p$5 === "object") {
@@ -425,7 +465,7 @@ function Make(App) {
425
465
  _0: [
426
466
  {
427
467
  TAG: "RegistrationExpired",
428
- email: email$3
468
+ emailId: emailId$3
429
469
  },
430
470
  invited
431
471
  ]
@@ -467,9 +507,11 @@ function Make(App) {
467
507
  TAG: "Ok",
468
508
  _0: [{
469
509
  TAG: "RegistrationChallengeReissued",
470
- email: command.email,
510
+ emailId: command.emailId,
511
+ email: p$7.email,
471
512
  reissuedAt: requestedAt$2,
472
- invitedBy: p$7.invitedBy
513
+ invitedBy: p$7.invitedBy,
514
+ language: p$7.language
473
515
  }]
474
516
  };
475
517
  } else {
@@ -496,11 +538,35 @@ function Make(App) {
496
538
  TAG: "Ok",
497
539
  _0: [{
498
540
  TAG: "RegistrationWithdrawn",
499
- email: command.email,
541
+ emailId: command.emailId,
500
542
  withdrawnAt: command.withdrawnAt
501
543
  }]
502
544
  };
503
545
  }
546
+ case "ReleaseRegistration" :
547
+ let match$3 = state.stage;
548
+ if (typeof match$3 !== "object") {
549
+ if (match$3 === "Completed") {
550
+ return {
551
+ TAG: "Ok",
552
+ _0: [{
553
+ TAG: "RegistrationReleased",
554
+ emailId: command.emailId,
555
+ releasedAt: command.releasedAt
556
+ }]
557
+ };
558
+ } else {
559
+ return {
560
+ TAG: "Ok",
561
+ _0: []
562
+ };
563
+ }
564
+ } else {
565
+ return {
566
+ TAG: "Ok",
567
+ _0: []
568
+ };
569
+ }
504
570
  }
505
571
  };
506
572
  return {
@@ -528,6 +594,7 @@ export {
528
594
  Guards,
529
595
  initialState,
530
596
  noticeCooldown,
597
+ contactOf,
531
598
  purposeOf,
532
599
  policyOf,
533
600
  evolve,
@@ -52,7 +52,7 @@ let stateSchema$1 = Sury.$Metadata_set(stateSchema, StateAnnotations$Reventless.
52
52
 
53
53
  let name = "RegistrationWindows";
54
54
 
55
- let admissionDoor = "OpenRoles";
55
+ let admissionDoor = "openRoles";
56
56
 
57
57
  let Id;
58
58