@opencrvs/toolkit 1.8.0-rc.fe87a15 → 1.8.0-rc.fe8c092

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 (38) hide show
  1. package/dist/commons/api/router.d.ts +6884 -614
  2. package/dist/commons/conditionals/conditionals.d.ts +4 -0
  3. package/dist/commons/conditionals/validate.d.ts +6 -0
  4. package/dist/commons/events/ActionConfig.d.ts +18678 -6326
  5. package/dist/commons/events/ActionDocument.d.ts +1923 -414
  6. package/dist/commons/events/ActionInput.d.ts +1504 -304
  7. package/dist/commons/events/ActionType.d.ts +6 -0
  8. package/dist/commons/events/AdvancedSearchConfig.d.ts +75 -3
  9. package/dist/commons/events/CompositeFieldValue.d.ts +28 -0
  10. package/dist/commons/events/Constants.d.ts +1 -0
  11. package/dist/commons/events/CountryConfigQueryInput.d.ts +254 -168
  12. package/dist/commons/events/CreatedAtLocation.d.ts +2 -1
  13. package/dist/commons/events/Draft.d.ts +134 -33
  14. package/dist/commons/events/EventConfig.d.ts +8242 -2365
  15. package/dist/commons/events/EventDocument.d.ts +1242 -298
  16. package/dist/commons/events/EventIndex.d.ts +798 -123
  17. package/dist/commons/events/EventMetadata.d.ts +62 -59
  18. package/dist/commons/events/FieldConfig.d.ts +1572 -746
  19. package/dist/commons/events/FieldType.d.ts +4 -1
  20. package/dist/commons/events/FieldTypeMapping.d.ts +89 -50
  21. package/dist/commons/events/FieldValue.d.ts +41 -5
  22. package/dist/commons/events/FormConfig.d.ts +7640 -2444
  23. package/dist/commons/events/PageConfig.d.ts +2816 -1540
  24. package/dist/commons/events/SummaryConfig.d.ts +0 -5
  25. package/dist/commons/events/WorkqueueColumnConfig.d.ts +11 -11
  26. package/dist/commons/events/WorkqueueConfig.d.ts +3277 -1512
  27. package/dist/commons/events/defineConfig.d.ts +959 -13
  28. package/dist/commons/events/field.d.ts +4 -0
  29. package/dist/commons/events/index.d.ts +1 -0
  30. package/dist/commons/events/scopes.d.ts +1 -2
  31. package/dist/commons/events/test.utils.d.ts +138 -40
  32. package/dist/commons/events/transactions.d.ts +1 -1
  33. package/dist/commons/events/utils.d.ts +9666 -16
  34. package/dist/conditionals/index.js +18 -1
  35. package/dist/events/index.js +1592 -1011
  36. package/dist/scopes/index.d.ts +4 -1
  37. package/dist/scopes/index.js +67 -17
  38. package/package.json +1 -1
@@ -32,6 +32,7 @@ var events_exports = {};
32
32
  __export(events_exports, {
33
33
  ACTION_ALLOWED_CONFIGURABLE_SCOPES: () => ACTION_ALLOWED_CONFIGURABLE_SCOPES,
34
34
  ACTION_ALLOWED_SCOPES: () => ACTION_ALLOWED_SCOPES,
35
+ AVAILABLE_ACTIONS_BY_EVENT_STATUS: () => AVAILABLE_ACTIONS_BY_EVENT_STATUS,
35
36
  Action: () => Action,
36
37
  ActionBase: () => ActionBase,
37
38
  ActionConditional: () => ActionConditional,
@@ -56,6 +57,7 @@ __export(events_exports, {
56
57
  ArchiveActionInput: () => ArchiveActionInput,
57
58
  AssignActionInput: () => AssignActionInput,
58
59
  AsyncRejectActionDocument: () => AsyncRejectActionDocument,
60
+ BIRTH_EVENT: () => BIRTH_EVENT,
59
61
  BaseActionInput: () => BaseActionInput,
60
62
  BearerTokenByUserType: () => BearerTokenByUserType,
61
63
  CONFIG_GET_ALLOWED_SCOPES: () => CONFIG_GET_ALLOWED_SCOPES,
@@ -101,9 +103,8 @@ __export(events_exports, {
101
103
  EventSearchIndex: () => EventSearchIndex,
102
104
  EventState: () => EventState,
103
105
  EventStatus: () => EventStatus,
104
- EventStatusEnum: () => EventStatusEnum,
105
- EventStatuses: () => EventStatuses,
106
106
  Exact: () => Exact,
107
+ ExactDate: () => ExactDate,
107
108
  ExactStatus: () => ExactStatus,
108
109
  FieldConditional: () => FieldConditional,
109
110
  FieldConfig: () => FieldConfig,
@@ -127,6 +128,8 @@ __export(events_exports, {
127
128
  LegalStatuses: () => LegalStatuses,
128
129
  MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
129
130
  MimeType: () => MimeType,
131
+ NameFieldUpdateValue: () => NameFieldUpdateValue,
132
+ NameFieldValue: () => NameFieldValue,
130
133
  NonEmptyTextValue: () => NonEmptyTextValue,
131
134
  Not: () => Not,
132
135
  NotifyActionInput: () => NotifyActionInput,
@@ -138,6 +141,7 @@ __export(events_exports, {
138
141
  QueryInput: () => QueryInput,
139
142
  QueryType: () => QueryType,
140
143
  Range: () => Range,
144
+ RangeDate: () => RangeDate,
141
145
  ReadActionInput: () => ReadActionInput,
142
146
  RegisterAction: () => RegisterAction,
143
147
  RegisterActionInput: () => RegisterActionInput,
@@ -154,8 +158,10 @@ __export(events_exports, {
154
158
  SelectOption: () => SelectOption,
155
159
  ShowConditional: () => ShowConditional,
156
160
  SignatureFieldValue: () => SignatureFieldValue,
161
+ StatusChangingActions: () => StatusChangingActions,
157
162
  SummaryConfig: () => SummaryConfig,
158
163
  TENNIS_CLUB_MEMBERSHIP: () => TENNIS_CLUB_MEMBERSHIP,
164
+ TestUserRole: () => TestUserRole,
159
165
  TextValue: () => TextValue,
160
166
  TranslationConfig: () => TranslationConfig,
161
167
  UnassignActionInput: () => UnassignActionInput,
@@ -165,13 +171,16 @@ __export(events_exports, {
165
171
  ValidateActionInput: () => ValidateActionInput,
166
172
  VerificationActionConfig: () => VerificationActionConfig,
167
173
  VerificationPageConfig: () => VerificationPageConfig,
174
+ WRITE_ACTION_SCOPES: () => WRITE_ACTION_SCOPES,
168
175
  Within: () => Within,
176
+ WorkqueueActionsWithDefault: () => WorkqueueActionsWithDefault,
169
177
  WorkqueueColumn: () => WorkqueueColumn,
170
178
  WorkqueueColumnKeys: () => WorkqueueColumnKeys,
171
179
  WorkqueueColumnKeysArray: () => WorkqueueColumnKeysArray,
172
180
  WorkqueueColumnValue: () => WorkqueueColumnValue,
173
181
  WorkqueueConfig: () => WorkqueueConfig,
174
182
  WorkqueueConfigInput: () => WorkqueueConfigInput,
183
+ WorkqueueConfigWithoutQuery: () => WorkqueueConfigWithoutQuery,
175
184
  WorkqueueCountInput: () => WorkqueueCountInput,
176
185
  WorkqueueCountOutput: () => WorkqueueCountOutput,
177
186
  ZodDate: () => ZodDate,
@@ -184,9 +193,8 @@ __export(events_exports, {
184
193
  createEmptyDraft: () => createEmptyDraft,
185
194
  createEventConditionals: () => createEventConditionals,
186
195
  createFieldConditionals: () => createFieldConditionals,
187
- createPseudoRandomNumberGenerator: () => createPseudoRandomNumberGenerator,
196
+ createPrng: () => createPrng,
188
197
  createValidationSchema: () => createValidationSchema,
189
- dateOfEventColumn: () => dateOfEventColumn,
190
198
  deepDropNulls: () => deepDropNulls,
191
199
  deepMerge: () => deepMerge,
192
200
  defaultWorkqueueColumns: () => defaultWorkqueueColumns,
@@ -206,10 +214,8 @@ __export(events_exports, {
206
214
  eventMetadataLabelMap: () => eventMetadataLabelMap,
207
215
  eventPayloadGenerator: () => eventPayloadGenerator,
208
216
  eventQueryDataGenerator: () => eventQueryDataGenerator,
209
- eventStatuses: () => eventStatuses,
210
217
  field: () => field,
211
218
  fieldTypes: () => fieldTypes,
212
- filterUnallowedActions: () => filterUnallowedActions,
213
219
  findActiveDrafts: () => findActiveDrafts,
214
220
  findAllFields: () => findAllFields,
215
221
  findLastAssignmentAction: () => findLastAssignmentAction,
@@ -219,6 +225,7 @@ __export(events_exports, {
219
225
  generateActionDocument: () => generateActionDocument,
220
226
  generateEventDocument: () => generateEventDocument,
221
227
  generateEventDraftDocument: () => generateEventDraftDocument,
228
+ generateRandomName: () => generateRandomName,
222
229
  generateRandomSignature: () => generateRandomSignature,
223
230
  generateTransactionId: () => generateTransactionId,
224
231
  generateTranslationConfig: () => generateTranslationConfig,
@@ -229,17 +236,22 @@ __export(events_exports, {
229
236
  getActionReview: () => getActionReview,
230
237
  getActionReviewFields: () => getActionReviewFields,
231
238
  getActionVerificationPageIds: () => getActionVerificationPageIds,
239
+ getAllUniqueFields: () => getAllUniqueFields,
232
240
  getAnnotationFromDrafts: () => getAnnotationFromDrafts,
233
241
  getAssignedUserFromActions: () => getAssignedUserFromActions,
234
242
  getAssignedUserSignatureFromActions: () => getAssignedUserSignatureFromActions,
235
243
  getCurrentEventState: () => getCurrentEventState,
236
244
  getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
237
245
  getDeclaration: () => getDeclaration,
246
+ getDeclarationFieldById: () => getDeclarationFieldById,
238
247
  getDeclarationFields: () => getDeclarationFields,
239
248
  getDeclarationPages: () => getDeclarationPages,
249
+ getEventConfigById: () => getEventConfigById,
240
250
  getMixedPath: () => getMixedPath,
251
+ getRandomDate: () => getRandomDate,
241
252
  getRandomDatetime: () => getRandomDatetime,
242
253
  getStatusFromActions: () => getStatusFromActions,
254
+ getValidatorsForField: () => getValidatorsForField,
243
255
  getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
244
256
  hasAnyOfScopes: () => hasAnyOfScopes,
245
257
  isAddressFieldType: () => isAddressFieldType,
@@ -262,13 +274,17 @@ __export(events_exports, {
262
274
  isFieldVisible: () => isFieldVisible,
263
275
  isFileFieldType: () => isFileFieldType,
264
276
  isFileFieldWithOptionType: () => isFileFieldWithOptionType,
277
+ isIdFieldType: () => isIdFieldType,
265
278
  isLocationFieldType: () => isLocationFieldType,
279
+ isMetaAction: () => isMetaAction,
280
+ isNameFieldType: () => isNameFieldType,
266
281
  isNonInteractiveFieldType: () => isNonInteractiveFieldType,
267
282
  isNumberFieldType: () => isNumberFieldType,
268
283
  isOfficeFieldType: () => isOfficeFieldType,
269
284
  isPageHeaderFieldType: () => isPageHeaderFieldType,
270
285
  isPageVisible: () => isPageVisible,
271
286
  isParagraphFieldType: () => isParagraphFieldType,
287
+ isPhoneFieldType: () => isPhoneFieldType,
272
288
  isRadioGroupFieldType: () => isRadioGroupFieldType,
273
289
  isSelectFieldType: () => isSelectFieldType,
274
290
  isSignatureFieldType: () => isSignatureFieldType,
@@ -278,6 +294,7 @@ __export(events_exports, {
278
294
  isUndeclaredDraft: () => isUndeclaredDraft,
279
295
  isVerificationPage: () => isVerificationPage,
280
296
  isWriteAction: () => isWriteAction,
297
+ mandatoryColumns: () => mandatoryColumns,
281
298
  mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
282
299
  mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
283
300
  mapFieldTypeToZod: () => mapFieldTypeToZod,
@@ -291,12 +308,14 @@ __export(events_exports, {
291
308
  user: () => user,
292
309
  validate: () => validate,
293
310
  validateFieldInput: () => validateFieldInput,
311
+ workqueueActions: () => workqueueActions,
294
312
  writeActions: () => writeActions
295
313
  });
296
314
  module.exports = __toCommonJS(events_exports);
297
315
 
298
316
  // ../commons/src/events/Constants.ts
299
317
  var TENNIS_CLUB_MEMBERSHIP = "tennis-club-membership";
318
+ var BIRTH_EVENT = "v2-birth";
300
319
 
301
320
  // ../commons/src/events/ActionConfig.ts
302
321
  var import_zod9 = require("zod");
@@ -375,6 +394,9 @@ var TranslationConfig = import_zod2.z.object({
375
394
 
376
395
  // ../commons/src/events/FieldType.ts
377
396
  var FieldType = {
397
+ NAME: "NAME",
398
+ PHONE: "PHONE",
399
+ ID: "ID",
378
400
  ADDRESS: "ADDRESS",
379
401
  TEXT: "TEXT",
380
402
  NUMBER: "NUMBER",
@@ -451,6 +473,16 @@ var UrbanAddressUpdateValue = AdminStructure.extend({
451
473
  number: import_zod3.z.string().nullish(),
452
474
  zipCode: import_zod3.z.string().nullish()
453
475
  });
476
+ var NameFieldValue = import_zod3.z.object({
477
+ firstname: import_zod3.z.string(),
478
+ surname: import_zod3.z.string(),
479
+ middlename: import_zod3.z.string().optional()
480
+ });
481
+ var NameFieldUpdateValue = import_zod3.z.object({
482
+ firstname: import_zod3.z.string(),
483
+ surname: import_zod3.z.string(),
484
+ middlename: import_zod3.z.string().nullish()
485
+ }).or(import_zod3.z.null()).or(import_zod3.z.undefined());
454
486
  var RuralAddressUpdateValue = AdminStructure.extend({
455
487
  urbanOrRural: import_zod3.z.literal(GeographicalArea.RURAL),
456
488
  village: import_zod3.z.string().nullish()
@@ -512,7 +544,9 @@ var FieldValue = import_zod4.z.union([
512
544
  UrbanAddressValue,
513
545
  RuralAddressValue,
514
546
  DataFieldValue,
515
- GenericAddressValue
547
+ GenericAddressValue,
548
+ NameFieldValue,
549
+ NameFieldUpdateValue
516
550
  ]);
517
551
  var FieldUpdateValue = import_zod4.z.union([
518
552
  TextValue,
@@ -525,7 +559,8 @@ var FieldUpdateValue = import_zod4.z.union([
525
559
  UrbanAddressUpdateValue,
526
560
  RuralAddressUpdateValue,
527
561
  DataFieldValue,
528
- GenericAddressUpdateValue
562
+ GenericAddressUpdateValue,
563
+ NameFieldUpdateValue
529
564
  ]);
530
565
 
531
566
  // ../commons/src/events/FieldConfig.ts
@@ -702,6 +737,26 @@ var Select = BaseField.extend({
702
737
  defaultValue: TextValue.optional(),
703
738
  options: import_zod5.z.array(SelectOption).describe("A list of options")
704
739
  }).describe("Select input");
740
+ var NameField = BaseField.extend({
741
+ type: import_zod5.z.literal(FieldType.NAME),
742
+ defaultValue: import_zod5.z.object({
743
+ firstname: NonEmptyTextValue,
744
+ surname: NonEmptyTextValue
745
+ }).optional(),
746
+ configuration: import_zod5.z.object({
747
+ maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
748
+ prefix: TranslationConfig.optional(),
749
+ postfix: TranslationConfig.optional()
750
+ }).optional()
751
+ }).describe("Name input field");
752
+ var PhoneField = BaseField.extend({
753
+ defaultValue: NonEmptyTextValue.optional(),
754
+ type: import_zod5.z.literal(FieldType.PHONE)
755
+ }).describe("Phone input field");
756
+ var IdField = BaseField.extend({
757
+ defaultValue: NonEmptyTextValue.optional(),
758
+ type: import_zod5.z.literal(FieldType.ID)
759
+ }).describe("ID input field");
705
760
  var Checkbox = BaseField.extend({
706
761
  type: import_zod5.z.literal(FieldType.CHECKBOX),
707
762
  defaultValue: CheckboxFieldValue.optional()
@@ -781,6 +836,9 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
781
836
  BulletList,
782
837
  PageHeader,
783
838
  Select,
839
+ NameField,
840
+ PhoneField,
841
+ IdField,
784
842
  Checkbox,
785
843
  File,
786
844
  Country,
@@ -914,6 +972,35 @@ var writeActions = ActionTypes.exclude([
914
972
  ActionType.ASSIGN,
915
973
  ActionType.UNASSIGN
916
974
  ]);
975
+ var StatusChangingActions = ActionTypes.extract([
976
+ ActionType.CREATE,
977
+ ActionType.NOTIFY,
978
+ ActionType.DECLARE,
979
+ ActionType.VALIDATE,
980
+ ActionType.REGISTER,
981
+ ActionType.REJECT,
982
+ ActionType.ARCHIVE,
983
+ ActionType.PRINT_CERTIFICATE
984
+ ]);
985
+ var workqueueActions = ActionTypes.exclude([
986
+ ActionType.CREATE,
987
+ ActionType.NOTIFY,
988
+ ActionType.DETECT_DUPLICATE,
989
+ ActionType.REJECT,
990
+ ActionType.MARKED_AS_DUPLICATE,
991
+ ActionType.ARCHIVE,
992
+ ActionType.REQUEST_CORRECTION,
993
+ ActionType.REJECT_CORRECTION,
994
+ ActionType.APPROVE_CORRECTION
995
+ ]);
996
+ var META_ACTIONS = [
997
+ ActionType.ASSIGN,
998
+ ActionType.UNASSIGN,
999
+ ActionType.READ
1000
+ ];
1001
+ function isMetaAction(actionType) {
1002
+ return META_ACTIONS.includes(actionType);
1003
+ }
917
1004
 
918
1005
  // ../commons/src/events/FormConfig.ts
919
1006
  var import_zod8 = require("zod");
@@ -1075,7 +1162,7 @@ var LanguageConfig = import_zod11.z.object({
1075
1162
  });
1076
1163
 
1077
1164
  // ../commons/src/events/EventConfig.ts
1078
- var import_zod18 = require("zod");
1165
+ var import_zod20 = require("zod");
1079
1166
 
1080
1167
  // ../commons/src/events/DeduplicationConfig.ts
1081
1168
  var import_zod12 = require("zod");
@@ -1167,8 +1254,7 @@ var Field = BaseField2.extend({
1167
1254
  value: TranslationConfig.describe(
1168
1255
  "Summary field value. Can utilise values defined in configuration and EventMetadata"
1169
1256
  ),
1170
- label: TranslationConfig,
1171
- emptyValueMessage: TranslationConfig.optional()
1257
+ label: TranslationConfig
1172
1258
  }).describe("Custom configured field");
1173
1259
  var SummaryConfig = import_zod13.z.object({
1174
1260
  fields: import_zod13.z.array(import_zod13.z.union([Field, ReferenceField])).describe("Fields rendered in summary view.")
@@ -1184,35 +1270,35 @@ var BaseField3 = import_zod14.z.object({
1184
1270
  options: import_zod14.z.array(SelectOption).optional(),
1185
1271
  searchCriteriaLabelPrefix: TranslationConfig.optional().describe(
1186
1272
  `
1187
- This property determines whether to add a prefix (such as "Child" or "Applicant") before the field label
1273
+ This property determines whether to add a prefix (such as "Child" or "Applicant") before the field label
1188
1274
  when rendering search parameter labels \u2014 for example, in the search results page to indicate which fields were used in the search.
1189
1275
 
1190
- For example, a field config like { id: "child.firstname", label: { defaultMessage: "First Name(s)" } } would render as "First Name(s)" by default.
1276
+ For example, a field config like { id: "child.name.firstname", label: { defaultMessage: "First Name(s)" } } would render as "First Name(s)" by default.
1191
1277
 
1192
1278
  A field config like { id: "mother.firstname", label: { defaultMessage: "First Name(s)" } } would also render as "First Name(s)" by default.
1193
1279
 
1194
- So, if both child.firstname and mother.firstname are used in a search, the resulting search criteria labels would be "First Name(s)", "First Name(s)",
1280
+ So, if both child.name.firstname and mother.firstname are used in a search, the resulting search criteria labels would be "First Name(s)", "First Name(s)",
1195
1281
  which is ambiguous.
1196
1282
 
1197
- Now, if we treat the field ID prefix as a label (e.g., "applicant.firstname" \u2192 "Applicant"), and the field label is already
1198
- descriptive \u2014 like { id: "applicant.firstname", label: { defaultMessage: "Applicant's First Name" } } \u2014 then the resulting
1283
+ Now, if we treat the field ID prefix as a label (e.g., "applicant.firstname" \u2192 "Applicant"), and the field label is already
1284
+ descriptive \u2014 like { id: "applicant.firstname", label: { defaultMessage: "Applicant's First Name" } } \u2014 then the resulting
1199
1285
  label would be "Applicant Applicant's First Name", which is redundant and awkward.
1200
1286
 
1201
- By setting searchCriteriaLabelPrefix to a translation config object, we can explicitly define the desired prefix
1287
+ By setting searchCriteriaLabelPrefix to a translation config object, we can explicitly define the desired prefix
1202
1288
  in the country-config > event.advancedSearch configuration. For example: field("child.dob", { searchCriteriaLabelPrefix: TranslationConfig }).
1203
1289
  `
1204
1290
  ),
1205
1291
  conditionals: import_zod14.z.array(FieldConditional).default([]).optional().describe(
1206
1292
  `
1207
1293
  In advanced search, we sometimes need to override the default field visibility conditionals.
1208
-
1209
- For example, Informant fields in the declaration form may have conditional logic
1210
- that hides them based on other field values. Since the advanced search form reuses
1294
+
1295
+ For example, Informant fields in the declaration form may have conditional logic
1296
+ that hides them based on other field values. Since the advanced search form reuses
1211
1297
  the declaration form config, those same conditionals would apply by default.
1212
-
1298
+
1213
1299
  However, in advanced search we often want to make all Informant fields searchable,
1214
- regardless of their original visibility logic. To do this, we explicitly set their
1215
- 'conditionals' to an empty array ('[]') in the search config. This ensures they
1300
+ regardless of their original visibility logic. To do this, we explicitly set their
1301
+ 'conditionals' to an empty array ('[]') in the search config. This ensures they
1216
1302
  are always rendered in the advanced search form.
1217
1303
  `
1218
1304
  )
@@ -1250,134 +1336,552 @@ var AdvancedSearchConfig = import_zod14.z.object({
1250
1336
  var import_lodash = require("lodash");
1251
1337
 
1252
1338
  // ../commons/src/events/ActionDocument.ts
1253
- var import_zod16 = require("zod");
1339
+ var import_zod18 = require("zod");
1254
1340
  var import_zod_openapi7 = require("zod-openapi");
1255
1341
 
1256
- // ../commons/src/uuid.ts
1257
- var import_uuid = require("uuid");
1342
+ // ../commons/src/events/CreatedAtLocation.ts
1258
1343
  var import_zod15 = require("zod");
1259
- var UUID = import_zod15.z.string().uuid().brand("UUID");
1260
- function getUUID() {
1261
- return (0, import_uuid.v4)();
1262
- }
1344
+ var CreatedAtLocation = import_zod15.z.string().nullish();
1263
1345
 
1264
- // ../commons/src/events/CreatedAtLocation.ts
1265
- var CreatedAtLocation = UUID.nullish();
1346
+ // ../commons/src/authentication.ts
1347
+ var import_jwt_decode = __toESM(require("jwt-decode"));
1348
+ var import_zod17 = require("zod");
1349
+
1350
+ // ../commons/src/scopes.ts
1351
+ var import_zod16 = require("zod");
1352
+ var SCOPES = {
1353
+ // TODO v1.8 legacy scopes
1354
+ NATLSYSADMIN: "natlsysadmin",
1355
+ BYPASSRATELIMIT: "bypassratelimit",
1356
+ DECLARE: "declare",
1357
+ REGISTER: "register",
1358
+ VALIDATE: "validate",
1359
+ DEMO: "demo",
1360
+ CERTIFY: "certify",
1361
+ PERFORMANCE: "performance",
1362
+ SYSADMIN: "sysadmin",
1363
+ TEAMS: "teams",
1364
+ CONFIG: "config",
1365
+ // systems / integrations
1366
+ WEBHOOK: "webhook",
1367
+ NATIONALID: "nationalId",
1368
+ NOTIFICATION_API: "notification-api",
1369
+ RECORDSEARCH: "recordsearch",
1370
+ /**
1371
+ * @TODO This is a temporary scope to be used for V2 Events custom events declaration
1372
+ */
1373
+ RECORD_DECLARE: "record.declare-birth",
1374
+ // declare
1375
+ RECORD_IMPORT: "record.import",
1376
+ // declare
1377
+ RECORD_DECLARE_BIRTH: "record.declare-birth",
1378
+ RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
1379
+ RECORD_DECLARE_DEATH: "record.declare-death",
1380
+ RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction",
1381
+ RECORD_DECLARE_MARRIAGE: "record.declare-marriage",
1382
+ RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction",
1383
+ RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete",
1384
+ RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review",
1385
+ RECORD_UNASSIGN_OTHERS: "record.unassign-others",
1386
+ // validate
1387
+ RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval",
1388
+ RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates",
1389
+ RECORD_DECLARATION_EDIT: "record.declaration-edit",
1390
+ RECORD_REVIEW_DUPLICATES: "record.review-duplicates",
1391
+ RECORD_DECLARATION_ARCHIVE: "record.declaration-archive",
1392
+ RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate",
1393
+ // register
1394
+ RECORD_REGISTER: "record.register",
1395
+ // certify
1396
+ RECORD_EXPORT_RECORDS: "record.export-records",
1397
+ RECORD_DECLARATION_PRINT: "record.declaration-print",
1398
+ RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS: "record.declaration-print-supporting-documents",
1399
+ RECORD_REGISTRATION_PRINT: "record.registration-print",
1400
+ // v1.8
1401
+ /**
1402
+ * This scope is used to **print and **issue certified copies of a record
1403
+ * after it has been registered. Previously Registrars had this permission.
1404
+ */
1405
+ RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies",
1406
+ RECORD_PRINT_CERTIFIED_COPIES: "record.registration-print-certified-copies",
1407
+ // v1.8
1408
+ RECORD_BULK_PRINT_CERTIFIED_COPIES: "record.registration-bulk-print-certified-copies",
1409
+ // v1.8
1410
+ RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES: "record.registration-verify-certified-copies",
1411
+ // v1.8
1412
+ // correct
1413
+ RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction",
1414
+ RECORD_REGISTRATION_CORRECT: "record.registration-correct",
1415
+ RECORD_REGISTRATION_REQUEST_REVOCATION: "record.registration-request-revocation",
1416
+ // v1.8
1417
+ RECORD_REGISTRATION_REVOKE: "record.registration-revoke",
1418
+ // v1.8
1419
+ RECORD_REGISTRATION_REQUEST_REINSTATEMENT: "record.registration-request-reinstatement",
1420
+ // v1.8
1421
+ RECORD_REGISTRATION_REINSTATE: "record.registration-reinstate",
1422
+ // v1.8
1423
+ RECORD_CONFIRM_REGISTRATION: "record.confirm-registration",
1424
+ RECORD_REJECT_REGISTRATION: "record.reject-registration",
1425
+ // search
1426
+ SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction",
1427
+ SEARCH_BIRTH: "search.birth",
1428
+ SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction",
1429
+ SEARCH_DEATH: "search.death",
1430
+ SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction",
1431
+ SEARCH_MARRIAGE: "search.marriage",
1432
+ // audit v1.8
1433
+ RECORD_READ: "record.read",
1434
+ RECORD_READ_AUDIT: "record.read-audit",
1435
+ RECORD_READ_COMMENTS: "record.read-comments",
1436
+ RECORD_CREATE_COMMENTS: "record.create-comments",
1437
+ // profile
1438
+ PROFILE_UPDATE: "profile.update",
1439
+ //v1.8
1440
+ PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
1441
+ // performance
1442
+ PERFORMANCE_READ: "performance.read",
1443
+ PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
1444
+ PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
1445
+ // organisation
1446
+ ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all",
1447
+ ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
1448
+ ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
1449
+ // user
1450
+ USER_READ: "user.read:all",
1451
+ USER_READ_MY_OFFICE: "user.read:my-office",
1452
+ USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
1453
+ USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
1454
+ //v1.8
1455
+ USER_CREATE: "user.create:all",
1456
+ USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
1457
+ USER_UPDATE: "user.update:all",
1458
+ USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction",
1459
+ // config
1460
+ CONFIG_UPDATE_ALL: "config.update:all",
1461
+ // data seeding
1462
+ USER_DATA_SEEDING: "user.data-seeding"
1463
+ };
1464
+ var LegacyScopes = import_zod16.z.union([
1465
+ import_zod16.z.literal(SCOPES.NATLSYSADMIN),
1466
+ import_zod16.z.literal(SCOPES.BYPASSRATELIMIT),
1467
+ import_zod16.z.literal(SCOPES.DECLARE),
1468
+ import_zod16.z.literal(SCOPES.REGISTER),
1469
+ import_zod16.z.literal(SCOPES.VALIDATE),
1470
+ import_zod16.z.literal(SCOPES.DEMO),
1471
+ import_zod16.z.literal(SCOPES.CERTIFY),
1472
+ import_zod16.z.literal(SCOPES.PERFORMANCE),
1473
+ import_zod16.z.literal(SCOPES.SYSADMIN),
1474
+ import_zod16.z.literal(SCOPES.TEAMS),
1475
+ import_zod16.z.literal(SCOPES.CONFIG)
1476
+ ]);
1477
+ var IntegrationScopes = import_zod16.z.union([
1478
+ import_zod16.z.literal(SCOPES.WEBHOOK),
1479
+ import_zod16.z.literal(SCOPES.NATIONALID),
1480
+ import_zod16.z.literal(SCOPES.NOTIFICATION_API),
1481
+ import_zod16.z.literal(SCOPES.RECORDSEARCH)
1482
+ ]);
1483
+ var DeclareScopes = import_zod16.z.union([
1484
+ import_zod16.z.literal(SCOPES.RECORD_DECLARE),
1485
+ import_zod16.z.literal(SCOPES.RECORD_IMPORT),
1486
+ import_zod16.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
1487
+ import_zod16.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
1488
+ import_zod16.z.literal(SCOPES.RECORD_DECLARE_DEATH),
1489
+ import_zod16.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
1490
+ import_zod16.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
1491
+ import_zod16.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
1492
+ import_zod16.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
1493
+ import_zod16.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW)
1494
+ ]);
1495
+ var UnassignScope = import_zod16.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS);
1496
+ var ValidateScopes = import_zod16.z.union([
1497
+ import_zod16.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
1498
+ import_zod16.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
1499
+ import_zod16.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
1500
+ import_zod16.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
1501
+ import_zod16.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
1502
+ import_zod16.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE)
1503
+ ]);
1504
+ var RegisterScope = import_zod16.z.literal(SCOPES.RECORD_REGISTER);
1505
+ var CertifyScopes = import_zod16.z.union([
1506
+ import_zod16.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
1507
+ import_zod16.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
1508
+ import_zod16.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
1509
+ import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
1510
+ import_zod16.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
1511
+ import_zod16.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
1512
+ import_zod16.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
1513
+ import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES)
1514
+ ]);
1515
+ var CorrectionScopes = import_zod16.z.union([
1516
+ import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
1517
+ import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
1518
+ import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
1519
+ import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
1520
+ import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
1521
+ import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
1522
+ import_zod16.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
1523
+ import_zod16.z.literal(SCOPES.RECORD_REJECT_REGISTRATION)
1524
+ ]);
1525
+ var SearchScopes = import_zod16.z.union([
1526
+ import_zod16.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
1527
+ import_zod16.z.literal(SCOPES.SEARCH_BIRTH),
1528
+ import_zod16.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
1529
+ import_zod16.z.literal(SCOPES.SEARCH_DEATH),
1530
+ import_zod16.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
1531
+ import_zod16.z.literal(SCOPES.SEARCH_MARRIAGE)
1532
+ ]);
1533
+ var AuditScopes = import_zod16.z.union([
1534
+ import_zod16.z.literal(SCOPES.RECORD_READ),
1535
+ import_zod16.z.literal(SCOPES.RECORD_READ_AUDIT),
1536
+ import_zod16.z.literal(SCOPES.RECORD_READ_COMMENTS),
1537
+ import_zod16.z.literal(SCOPES.RECORD_CREATE_COMMENTS)
1538
+ ]);
1539
+ var ProfileScopes = import_zod16.z.union([
1540
+ import_zod16.z.literal(SCOPES.PROFILE_UPDATE),
1541
+ import_zod16.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE)
1542
+ ]);
1543
+ var PerformanceScopes = import_zod16.z.union([
1544
+ import_zod16.z.literal(SCOPES.PERFORMANCE_READ),
1545
+ import_zod16.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
1546
+ import_zod16.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS)
1547
+ ]);
1548
+ var OrganisationScopes = import_zod16.z.union([
1549
+ import_zod16.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
1550
+ import_zod16.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
1551
+ import_zod16.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION)
1552
+ ]);
1553
+ var UserScopes = import_zod16.z.union([
1554
+ import_zod16.z.literal(SCOPES.USER_READ),
1555
+ import_zod16.z.literal(SCOPES.USER_READ_MY_OFFICE),
1556
+ import_zod16.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
1557
+ import_zod16.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
1558
+ import_zod16.z.literal(SCOPES.USER_CREATE),
1559
+ import_zod16.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
1560
+ import_zod16.z.literal(SCOPES.USER_UPDATE),
1561
+ import_zod16.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION)
1562
+ ]);
1563
+ var ConfigScope = import_zod16.z.literal(SCOPES.CONFIG_UPDATE_ALL);
1564
+ var DataSeedingScope = import_zod16.z.literal(SCOPES.USER_DATA_SEEDING);
1565
+ var LiteralScopes = import_zod16.z.union([
1566
+ LegacyScopes,
1567
+ IntegrationScopes,
1568
+ UnassignScope,
1569
+ DeclareScopes,
1570
+ ValidateScopes,
1571
+ RegisterScope,
1572
+ CertifyScopes,
1573
+ CorrectionScopes,
1574
+ SearchScopes,
1575
+ AuditScopes,
1576
+ ProfileScopes,
1577
+ PerformanceScopes,
1578
+ OrganisationScopes,
1579
+ UserScopes,
1580
+ ConfigScope,
1581
+ DataSeedingScope
1582
+ ]);
1583
+ var rawConfigurableScopeRegex = /^([a-zA-Z\.]+)\[((?:\w+=[\w.-]+(?:\|[\w.-]+)*)(?:,[\w]+=[\w.-]+(?:\|[\w.-]+)*)*)\]$/;
1584
+ var rawConfigurableScope = import_zod16.z.string().regex(rawConfigurableScopeRegex);
1585
+ var CreateUserScope = import_zod16.z.object({
1586
+ type: import_zod16.z.literal("user.create"),
1587
+ options: import_zod16.z.object({
1588
+ role: import_zod16.z.array(import_zod16.z.string())
1589
+ })
1590
+ });
1591
+ var EditUserScope = import_zod16.z.object({
1592
+ type: import_zod16.z.literal("user.edit"),
1593
+ options: import_zod16.z.object({
1594
+ role: import_zod16.z.array(import_zod16.z.string())
1595
+ })
1596
+ });
1597
+ var WorkqueueScope = import_zod16.z.object({
1598
+ type: import_zod16.z.literal("workqueue"),
1599
+ options: import_zod16.z.object({
1600
+ id: import_zod16.z.array(import_zod16.z.string())
1601
+ })
1602
+ });
1603
+ var NotifyRecordScope = import_zod16.z.object({
1604
+ type: import_zod16.z.literal("record.notify"),
1605
+ options: import_zod16.z.object({
1606
+ event: import_zod16.z.array(import_zod16.z.string())
1607
+ })
1608
+ });
1609
+ var ConfigurableScopes = import_zod16.z.discriminatedUnion("type", [
1610
+ CreateUserScope,
1611
+ EditUserScope,
1612
+ WorkqueueScope,
1613
+ NotifyRecordScope
1614
+ ]);
1615
+ var scopes = Object.values(SCOPES);
1616
+ var ActionScopes = import_zod16.z.union([
1617
+ DeclareScopes,
1618
+ ValidateScopes,
1619
+ RegisterScope,
1620
+ CertifyScopes,
1621
+ CorrectionScopes
1622
+ ]);
1623
+
1624
+ // ../commons/src/authentication.ts
1625
+ var DEFAULT_ROLES_DEFINITION = [
1626
+ {
1627
+ id: "FIELD_AGENT",
1628
+ label: {
1629
+ defaultMessage: "Field Agent",
1630
+ description: "Name for user role Field Agent",
1631
+ id: "userRole.fieldAgent"
1632
+ },
1633
+ scopes: [
1634
+ // new scopes
1635
+ SCOPES.RECORD_DECLARE_BIRTH,
1636
+ SCOPES.RECORD_DECLARE_DEATH,
1637
+ SCOPES.RECORD_DECLARE_MARRIAGE,
1638
+ SCOPES.RECORD_SUBMIT_INCOMPLETE,
1639
+ SCOPES.RECORD_SUBMIT_FOR_REVIEW,
1640
+ SCOPES.SEARCH_BIRTH,
1641
+ SCOPES.SEARCH_DEATH,
1642
+ SCOPES.SEARCH_MARRIAGE
1643
+ ]
1644
+ },
1645
+ {
1646
+ id: "REGISTRATION_AGENT",
1647
+ label: {
1648
+ defaultMessage: "Registration Agent",
1649
+ description: "Name for user role Registration Agent",
1650
+ id: "userRole.registrationAgent"
1651
+ },
1652
+ scopes: [
1653
+ SCOPES.PERFORMANCE,
1654
+ SCOPES.CERTIFY,
1655
+ SCOPES.RECORD_DECLARE_BIRTH,
1656
+ SCOPES.RECORD_DECLARE_DEATH,
1657
+ SCOPES.RECORD_DECLARE_MARRIAGE,
1658
+ SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
1659
+ SCOPES.RECORD_SUBMIT_FOR_UPDATES,
1660
+ SCOPES.RECORD_DECLARATION_ARCHIVE,
1661
+ SCOPES.RECORD_DECLARATION_REINSTATE,
1662
+ SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION,
1663
+ SCOPES.RECORD_REGISTRATION_PRINT,
1664
+ SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS,
1665
+ SCOPES.RECORD_EXPORT_RECORDS,
1666
+ SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES,
1667
+ SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES,
1668
+ SCOPES.RECORD_CREATE_COMMENTS,
1669
+ SCOPES.PERFORMANCE_READ,
1670
+ SCOPES.PERFORMANCE_READ_DASHBOARDS,
1671
+ SCOPES.ORGANISATION_READ_LOCATIONS,
1672
+ SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE,
1673
+ SCOPES.SEARCH_BIRTH,
1674
+ SCOPES.SEARCH_DEATH,
1675
+ SCOPES.SEARCH_MARRIAGE
1676
+ ]
1677
+ },
1678
+ {
1679
+ id: "LOCAL_REGISTRAR",
1680
+ label: {
1681
+ defaultMessage: "Local Registrar",
1682
+ description: "Name for user role Local Registrar",
1683
+ id: "userRole.localRegistrar"
1684
+ },
1685
+ scopes: [
1686
+ SCOPES.PERFORMANCE,
1687
+ SCOPES.CERTIFY,
1688
+ SCOPES.RECORD_DECLARE_BIRTH,
1689
+ SCOPES.RECORD_DECLARE_DEATH,
1690
+ SCOPES.RECORD_DECLARE_MARRIAGE,
1691
+ SCOPES.RECORD_SUBMIT_FOR_UPDATES,
1692
+ SCOPES.RECORD_REVIEW_DUPLICATES,
1693
+ SCOPES.RECORD_DECLARATION_ARCHIVE,
1694
+ SCOPES.RECORD_DECLARATION_REINSTATE,
1695
+ SCOPES.RECORD_REGISTER,
1696
+ SCOPES.RECORD_REGISTRATION_CORRECT,
1697
+ SCOPES.RECORD_REGISTRATION_PRINT,
1698
+ SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS,
1699
+ SCOPES.RECORD_EXPORT_RECORDS,
1700
+ SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES,
1701
+ SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES,
1702
+ SCOPES.RECORD_CREATE_COMMENTS,
1703
+ SCOPES.PERFORMANCE_READ,
1704
+ SCOPES.PERFORMANCE_READ_DASHBOARDS,
1705
+ SCOPES.ORGANISATION_READ_LOCATIONS,
1706
+ SCOPES.PROFILE_ELECTRONIC_SIGNATURE,
1707
+ SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE,
1708
+ SCOPES.SEARCH_BIRTH,
1709
+ SCOPES.SEARCH_DEATH,
1710
+ SCOPES.SEARCH_MARRIAGE
1711
+ ]
1712
+ },
1713
+ {
1714
+ id: "LOCAL_SYSTEM_ADMIN",
1715
+ label: {
1716
+ defaultMessage: "Local System Admin",
1717
+ description: "Name for user role Local System Admin",
1718
+ id: "userRole.localSystemAdmin"
1719
+ },
1720
+ scopes: [
1721
+ SCOPES.SYSADMIN,
1722
+ SCOPES.USER_READ_MY_OFFICE,
1723
+ SCOPES.USER_CREATE_MY_JURISDICTION,
1724
+ SCOPES.USER_UPDATE_MY_JURISDICTION,
1725
+ SCOPES.ORGANISATION_READ_LOCATIONS,
1726
+ SCOPES.PERFORMANCE_READ,
1727
+ SCOPES.PERFORMANCE_READ_DASHBOARDS,
1728
+ SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS
1729
+ // 'organisation.read-users' ?
1730
+ ]
1731
+ },
1732
+ {
1733
+ id: "NATIONAL_SYSTEM_ADMIN",
1734
+ label: {
1735
+ defaultMessage: "National System Admin",
1736
+ description: "Name for user role National System Admin",
1737
+ id: "userRole.nationalSystemAdmin"
1738
+ },
1739
+ scopes: [
1740
+ SCOPES.SYSADMIN,
1741
+ SCOPES.NATLSYSADMIN,
1742
+ SCOPES.USER_CREATE,
1743
+ SCOPES.USER_READ,
1744
+ SCOPES.USER_UPDATE,
1745
+ SCOPES.ORGANISATION_READ_LOCATIONS,
1746
+ SCOPES.PERFORMANCE_READ,
1747
+ SCOPES.PERFORMANCE_READ_DASHBOARDS,
1748
+ SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS
1749
+ // 'organisation.read-users' ?
1750
+ ]
1751
+ },
1752
+ {
1753
+ id: "PERFORMANCE_MANAGER",
1754
+ label: {
1755
+ defaultMessage: "Performance Manager",
1756
+ description: "Name for user role Performance Manager",
1757
+ id: "userRole.performanceManager"
1758
+ },
1759
+ scopes: [
1760
+ SCOPES.PERFORMANCE,
1761
+ SCOPES.PERFORMANCE_READ,
1762
+ SCOPES.PERFORMANCE_READ_DASHBOARDS,
1763
+ SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS
1764
+ ]
1765
+ }
1766
+ ];
1767
+ var TokenUserType = import_zod17.z.enum(["user", "system"]);
1768
+ var TokenWithBearer = import_zod17.z.string().regex(/^Bearer\s/);
1266
1769
 
1267
1770
  // ../commons/src/events/ActionDocument.ts
1268
- (0, import_zod_openapi7.extendZodWithOpenApi)(import_zod16.z);
1269
- var ActionUpdate = import_zod16.z.record(import_zod16.z.string(), FieldUpdateValue);
1270
- var EventState = import_zod16.z.record(import_zod16.z.string(), FieldValue);
1771
+ (0, import_zod_openapi7.extendZodWithOpenApi)(import_zod18.z);
1772
+ var ActionUpdate = import_zod18.z.record(import_zod18.z.string(), FieldUpdateValue);
1773
+ var EventState = import_zod18.z.record(import_zod18.z.string(), FieldValue);
1271
1774
  var ActionStatus = {
1272
1775
  Requested: "Requested",
1273
1776
  Accepted: "Accepted",
1274
1777
  Rejected: "Rejected"
1275
1778
  };
1276
- var ActionBase = import_zod16.z.object({
1277
- id: import_zod16.z.string(),
1278
- transactionId: import_zod16.z.string(),
1279
- createdAt: import_zod16.z.string().datetime(),
1280
- createdBy: import_zod16.z.string(),
1281
- createdByRole: import_zod16.z.string(),
1282
- createdBySignature: import_zod16.z.string().nullish().describe("Reference to signature of the user who created the action"),
1779
+ var ActionBase = import_zod18.z.object({
1780
+ id: import_zod18.z.string(),
1781
+ transactionId: import_zod18.z.string(),
1782
+ createdByUserType: TokenUserType,
1783
+ createdAt: import_zod18.z.string().datetime(),
1784
+ createdBy: import_zod18.z.string(),
1785
+ createdByRole: import_zod18.z.string(),
1786
+ createdBySignature: import_zod18.z.string().nullish().describe("Reference to signature of the user who created the action"),
1283
1787
  createdAtLocation: CreatedAtLocation,
1284
1788
  declaration: ActionUpdate,
1285
- annotation: ActionUpdate.optional().nullable(),
1286
- status: import_zod16.z.enum([
1789
+ annotation: ActionUpdate.optional(),
1790
+ status: import_zod18.z.enum([
1287
1791
  ActionStatus.Requested,
1288
1792
  ActionStatus.Accepted,
1289
1793
  ActionStatus.Rejected
1290
1794
  ]),
1291
1795
  // If the action is an asynchronous confirmation for another action, we will save the original action id here.
1292
- originalActionId: UUID.optional().nullable()
1796
+ originalActionId: import_zod18.z.string().optional()
1293
1797
  });
1294
1798
  var AssignedAction = ActionBase.merge(
1295
- import_zod16.z.object({
1296
- type: import_zod16.z.literal(ActionType.ASSIGN),
1297
- assignedTo: import_zod16.z.string()
1799
+ import_zod18.z.object({
1800
+ type: import_zod18.z.literal(ActionType.ASSIGN),
1801
+ assignedTo: import_zod18.z.string()
1298
1802
  })
1299
1803
  );
1300
1804
  var UnassignedAction = ActionBase.merge(
1301
- import_zod16.z.object({
1302
- type: import_zod16.z.literal(ActionType.UNASSIGN),
1303
- assignedTo: import_zod16.z.literal(null)
1805
+ import_zod18.z.object({
1806
+ type: import_zod18.z.literal(ActionType.UNASSIGN),
1807
+ assignedTo: import_zod18.z.literal(null)
1304
1808
  })
1305
1809
  );
1306
1810
  var RegisterAction = ActionBase.merge(
1307
- import_zod16.z.object({
1308
- type: import_zod16.z.literal(ActionType.REGISTER),
1309
- registrationNumber: import_zod16.z.string().optional()
1811
+ import_zod18.z.object({
1812
+ type: import_zod18.z.literal(ActionType.REGISTER),
1813
+ registrationNumber: import_zod18.z.string().optional()
1310
1814
  })
1311
1815
  );
1312
1816
  var DeclareAction = ActionBase.merge(
1313
- import_zod16.z.object({
1314
- type: import_zod16.z.literal(ActionType.DECLARE)
1817
+ import_zod18.z.object({
1818
+ type: import_zod18.z.literal(ActionType.DECLARE)
1315
1819
  })
1316
1820
  );
1317
1821
  var ValidateAction = ActionBase.merge(
1318
- import_zod16.z.object({
1319
- type: import_zod16.z.literal(ActionType.VALIDATE)
1822
+ import_zod18.z.object({
1823
+ type: import_zod18.z.literal(ActionType.VALIDATE)
1320
1824
  })
1321
1825
  );
1322
- var RejectionReason = import_zod16.z.object({
1323
- message: import_zod16.z.string().min(1, { message: "Message cannot be empty" }).describe("Message describing reason for rejection or archiving"),
1324
- isDuplicate: import_zod16.z.boolean().optional().describe("If a declaration is duplicated")
1826
+ var RejectionReason = import_zod18.z.object({
1827
+ message: import_zod18.z.string().min(1, { message: "Message cannot be empty" }).describe("Message describing reason for rejection or archiving"),
1828
+ isDuplicate: import_zod18.z.boolean().optional().describe("If a declaration is duplicated")
1325
1829
  });
1326
1830
  var RejectAction = ActionBase.merge(
1327
- import_zod16.z.object({
1328
- type: import_zod16.z.literal(ActionType.REJECT),
1831
+ import_zod18.z.object({
1832
+ type: import_zod18.z.literal(ActionType.REJECT),
1329
1833
  reason: RejectionReason
1330
1834
  })
1331
1835
  );
1332
1836
  var MarkAsDuplicateAction = ActionBase.merge(
1333
- import_zod16.z.object({
1334
- type: import_zod16.z.literal(ActionType.MARKED_AS_DUPLICATE)
1837
+ import_zod18.z.object({
1838
+ type: import_zod18.z.literal(ActionType.MARKED_AS_DUPLICATE)
1335
1839
  })
1336
1840
  );
1337
1841
  var ArchiveAction = ActionBase.merge(
1338
- import_zod16.z.object({
1339
- type: import_zod16.z.literal(ActionType.ARCHIVE),
1842
+ import_zod18.z.object({
1843
+ type: import_zod18.z.literal(ActionType.ARCHIVE),
1340
1844
  reason: RejectionReason
1341
1845
  })
1342
1846
  );
1343
1847
  var CreatedAction = ActionBase.merge(
1344
- import_zod16.z.object({
1345
- type: import_zod16.z.literal(ActionType.CREATE)
1848
+ import_zod18.z.object({
1849
+ type: import_zod18.z.literal(ActionType.CREATE)
1346
1850
  })
1347
1851
  );
1348
1852
  var NotifiedAction = ActionBase.merge(
1349
- import_zod16.z.object({
1350
- type: import_zod16.z.literal(ActionType.NOTIFY)
1853
+ import_zod18.z.object({
1854
+ type: import_zod18.z.literal(ActionType.NOTIFY)
1351
1855
  })
1352
1856
  );
1353
1857
  var PrintCertificateAction = ActionBase.merge(
1354
- import_zod16.z.object({
1355
- type: import_zod16.z.literal(ActionType.PRINT_CERTIFICATE)
1858
+ import_zod18.z.object({
1859
+ type: import_zod18.z.literal(ActionType.PRINT_CERTIFICATE)
1356
1860
  })
1357
1861
  );
1358
1862
  var RequestedCorrectionAction = ActionBase.merge(
1359
- import_zod16.z.object({
1360
- type: import_zod16.z.literal(ActionType.REQUEST_CORRECTION)
1863
+ import_zod18.z.object({
1864
+ type: import_zod18.z.literal(ActionType.REQUEST_CORRECTION)
1361
1865
  })
1362
1866
  );
1363
1867
  var ApprovedCorrectionAction = ActionBase.merge(
1364
- import_zod16.z.object({
1365
- type: import_zod16.z.literal(ActionType.APPROVE_CORRECTION),
1366
- requestId: import_zod16.z.string()
1868
+ import_zod18.z.object({
1869
+ type: import_zod18.z.literal(ActionType.APPROVE_CORRECTION),
1870
+ requestId: import_zod18.z.string()
1367
1871
  })
1368
1872
  );
1369
1873
  var RejectedCorrectionAction = ActionBase.merge(
1370
- import_zod16.z.object({
1371
- type: import_zod16.z.literal(ActionType.REJECT_CORRECTION),
1372
- requestId: import_zod16.z.string()
1874
+ import_zod18.z.object({
1875
+ type: import_zod18.z.literal(ActionType.REJECT_CORRECTION),
1876
+ requestId: import_zod18.z.string()
1373
1877
  })
1374
1878
  );
1375
1879
  var ReadAction = ActionBase.merge(
1376
- import_zod16.z.object({
1377
- type: import_zod16.z.literal(ActionType.READ)
1880
+ import_zod18.z.object({
1881
+ type: import_zod18.z.literal(ActionType.READ)
1378
1882
  })
1379
1883
  );
1380
- var ActionDocument = import_zod16.z.discriminatedUnion("type", [
1884
+ var ActionDocument = import_zod18.z.discriminatedUnion("type", [
1381
1885
  CreatedAction.openapi({ ref: "CreatedAction" }),
1382
1886
  ValidateAction.openapi({ ref: "ValidateAction" }),
1383
1887
  RejectAction.openapi({ ref: "RejectAction" }),
@@ -1400,20 +1904,20 @@ var AsyncRejectActionDocument = ActionBase.omit({
1400
1904
  declaration: true,
1401
1905
  annotation: true
1402
1906
  }).merge(
1403
- import_zod16.z.object({
1404
- type: import_zod16.z.enum(ConfirmableActions),
1405
- status: import_zod16.z.literal(ActionStatus.Rejected)
1907
+ import_zod18.z.object({
1908
+ type: import_zod18.z.enum(ConfirmableActions),
1909
+ status: import_zod18.z.literal(ActionStatus.Rejected)
1406
1910
  })
1407
1911
  );
1408
- var Action = import_zod16.z.union([ActionDocument, AsyncRejectActionDocument]);
1409
- var ResolvedUser = import_zod16.z.object({
1410
- id: import_zod16.z.string(),
1411
- role: import_zod16.z.string(),
1412
- name: import_zod16.z.array(
1413
- import_zod16.z.object({
1414
- use: import_zod16.z.string(),
1415
- given: import_zod16.z.array(import_zod16.z.string()),
1416
- family: import_zod16.z.string()
1912
+ var Action = import_zod18.z.union([ActionDocument, AsyncRejectActionDocument]);
1913
+ var ResolvedUser = import_zod18.z.object({
1914
+ id: import_zod18.z.string(),
1915
+ role: import_zod18.z.string(),
1916
+ name: import_zod18.z.array(
1917
+ import_zod18.z.object({
1918
+ use: import_zod18.z.string(),
1919
+ given: import_zod18.z.array(import_zod18.z.string()),
1920
+ family: import_zod18.z.string()
1417
1921
  })
1418
1922
  )
1419
1923
  });
@@ -1424,7 +1928,7 @@ var import_ajv_formats = __toESM(require("ajv-formats"));
1424
1928
  var import_date_fns = require("date-fns");
1425
1929
 
1426
1930
  // ../commons/src/events/FieldTypeMapping.ts
1427
- var import_zod17 = require("zod");
1931
+ var import_zod19 = require("zod");
1428
1932
  function mapFieldTypeToZod(type, required) {
1429
1933
  let schema;
1430
1934
  switch (type) {
@@ -1450,6 +1954,8 @@ function mapFieldTypeToZod(type, required) {
1450
1954
  case FieldType.ADMINISTRATIVE_AREA:
1451
1955
  case FieldType.FACILITY:
1452
1956
  case FieldType.OFFICE:
1957
+ case FieldType.PHONE:
1958
+ case FieldType.ID:
1453
1959
  schema = required ? NonEmptyTextValue : TextValue;
1454
1960
  break;
1455
1961
  case FieldType.NUMBER:
@@ -1471,6 +1977,9 @@ function mapFieldTypeToZod(type, required) {
1471
1977
  case FieldType.DATA:
1472
1978
  schema = DataFieldValue;
1473
1979
  break;
1980
+ case FieldType.NAME:
1981
+ schema = required ? NameFieldValue : NameFieldUpdateValue;
1982
+ break;
1474
1983
  }
1475
1984
  return required ? schema : schema.nullish();
1476
1985
  }
@@ -1479,9 +1988,9 @@ function createValidationSchema(config) {
1479
1988
  for (const field2 of config) {
1480
1989
  shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
1481
1990
  }
1482
- return import_zod17.z.object(shape);
1991
+ return import_zod19.z.object(shape);
1483
1992
  }
1484
- function mapFieldTypeToMockValue(field2, i) {
1993
+ function mapFieldTypeToEmptyValue(field2) {
1485
1994
  switch (field2.type) {
1486
1995
  case FieldType.DIVIDER:
1487
1996
  case FieldType.TEXT:
@@ -1496,78 +2005,29 @@ function mapFieldTypeToMockValue(field2, i) {
1496
2005
  case FieldType.ADMINISTRATIVE_AREA:
1497
2006
  case FieldType.FACILITY:
1498
2007
  case FieldType.OFFICE:
1499
- return `${field2.id}-${field2.type}-${i}`;
1500
2008
  case FieldType.NUMBER:
1501
- return 19;
1502
2009
  case FieldType.EMAIL:
1503
- return "test@opencrvs.org";
2010
+ case FieldType.DATE:
2011
+ case FieldType.CHECKBOX:
2012
+ case FieldType.DATE_RANGE:
2013
+ case FieldType.DATA:
2014
+ case FieldType.NAME:
2015
+ case FieldType.PHONE:
2016
+ case FieldType.ID:
2017
+ return null;
1504
2018
  case FieldType.ADDRESS:
1505
2019
  return {
1506
- country: "FAR",
2020
+ country: null,
1507
2021
  addressType: AddressType.DOMESTIC,
1508
- province: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
1509
- district: "5ef450bc-712d-48ad-93f3-8da0fa453baa",
2022
+ province: null,
2023
+ district: null,
1510
2024
  urbanOrRural: "URBAN",
1511
- town: "Example Town",
1512
- residentialArea: "Example Residential Area",
1513
- street: "Example Street",
1514
- number: "55",
1515
- zipCode: "123456"
1516
- };
1517
- case FieldType.DATE:
1518
- return "2021-01-01";
1519
- case FieldType.DATE_RANGE:
1520
- return ["2021-01-01", "2021-01-02"];
1521
- case FieldType.CHECKBOX:
1522
- return true;
1523
- case FieldType.SIGNATURE:
1524
- case FieldType.FILE:
1525
- return {
1526
- filename: "4f095fc4-4312-4de2-aa38-86dcc0f71044.png",
1527
- originalFilename: "abcd.png",
1528
- type: "image/png"
1529
- };
1530
- case FieldType.FILE_WITH_OPTIONS:
1531
- return null;
1532
- case FieldType.DATA:
1533
- return {};
1534
- }
1535
- }
1536
- function mapFieldTypeToEmptyValue(field2) {
1537
- switch (field2.type) {
1538
- case FieldType.DIVIDER:
1539
- case FieldType.TEXT:
1540
- case FieldType.TEXTAREA:
1541
- case FieldType.BULLET_LIST:
1542
- case FieldType.PAGE_HEADER:
1543
- case FieldType.LOCATION:
1544
- case FieldType.SELECT:
1545
- case FieldType.COUNTRY:
1546
- case FieldType.RADIO_GROUP:
1547
- case FieldType.PARAGRAPH:
1548
- case FieldType.ADMINISTRATIVE_AREA:
1549
- case FieldType.FACILITY:
1550
- case FieldType.OFFICE:
1551
- case FieldType.NUMBER:
1552
- case FieldType.EMAIL:
1553
- case FieldType.DATE:
1554
- case FieldType.CHECKBOX:
1555
- case FieldType.DATE_RANGE:
1556
- case FieldType.DATA:
1557
- return null;
1558
- case FieldType.ADDRESS:
1559
- return {
1560
- country: null,
1561
- addressType: AddressType.DOMESTIC,
1562
- province: null,
1563
- district: null,
1564
- urbanOrRural: "URBAN",
1565
- // Default to urban needed for validation
1566
- town: null,
1567
- residentialArea: null,
1568
- street: null,
1569
- number: null,
1570
- zipCode: null
2025
+ // Default to urban needed for validation
2026
+ town: null,
2027
+ residentialArea: null,
2028
+ street: null,
2029
+ number: null,
2030
+ zipCode: null
1571
2031
  };
1572
2032
  case FieldType.SIGNATURE:
1573
2033
  case FieldType.FILE:
@@ -1598,6 +2058,15 @@ var isTextFieldType = (field2) => {
1598
2058
  var isNumberFieldType = (field2) => {
1599
2059
  return field2.config.type === FieldType.NUMBER;
1600
2060
  };
2061
+ var isNameFieldType = (field2) => {
2062
+ return field2.config.type === FieldType.NAME;
2063
+ };
2064
+ var isPhoneFieldType = (field2) => {
2065
+ return field2.config.type === FieldType.PHONE;
2066
+ };
2067
+ var isIdFieldType = (field2) => {
2068
+ return field2.config.type === FieldType.ID;
2069
+ };
1601
2070
  var isTextAreaFieldType = (field2) => {
1602
2071
  return field2.config.type === FieldType.TEXTAREA;
1603
2072
  };
@@ -1732,6 +2201,11 @@ var errorMessages = {
1732
2201
  defaultMessage: "Invalid input",
1733
2202
  description: "Error message when generic field is invalid",
1734
2203
  id: "v2.error.invalid"
2204
+ },
2205
+ unexpectedField: {
2206
+ defaultMessage: "Unexpected field",
2207
+ description: "Error message when field is not expected",
2208
+ id: "v2.error.unexpectedField"
1735
2209
  }
1736
2210
  };
1737
2211
  function createIntlError(message) {
@@ -1827,6 +2301,51 @@ function runFieldValidations({
1827
2301
  errors: [...fieldValidationResult, ...customValidationResults]
1828
2302
  };
1829
2303
  }
2304
+ function getValidatorsForField(fieldId, validations) {
2305
+ return validations.map(({ validator, message }) => {
2306
+ const jsonSchema = validator;
2307
+ const $form = jsonSchema.properties.$form;
2308
+ if ($form.properties?.[fieldId]?.type === "object") {
2309
+ return {
2310
+ message,
2311
+ validator: {
2312
+ ...jsonSchema,
2313
+ properties: {
2314
+ $form: {
2315
+ type: "object",
2316
+ properties: $form.properties?.[fieldId]?.properties || {},
2317
+ required: $form.properties?.[fieldId]?.required || []
2318
+ }
2319
+ }
2320
+ }
2321
+ };
2322
+ }
2323
+ if (!$form.properties?.[fieldId]) {
2324
+ return null;
2325
+ }
2326
+ return {
2327
+ message,
2328
+ validator: {
2329
+ ...jsonSchema,
2330
+ properties: {
2331
+ $form: {
2332
+ type: "object",
2333
+ properties: {
2334
+ [fieldId]: $form.properties?.[fieldId]
2335
+ },
2336
+ required: $form.required?.includes(fieldId) ? [fieldId] : []
2337
+ }
2338
+ }
2339
+ }
2340
+ };
2341
+ }).filter((x) => x !== null);
2342
+ }
2343
+
2344
+ // ../commons/src/uuid.ts
2345
+ var import_uuid = require("uuid");
2346
+ function getUUID() {
2347
+ return (0, import_uuid.v4)();
2348
+ }
1830
2349
 
1831
2350
  // ../commons/src/utils.ts
1832
2351
  function getOrThrow(x, message) {
@@ -1867,6 +2386,13 @@ var getActionAnnotationFields = (actionConfig) => {
1867
2386
  function getAllAnnotationFields(config) {
1868
2387
  return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
1869
2388
  }
2389
+ function getAllUniqueFields(eventConfig) {
2390
+ return (0, import_lodash.uniqBy)(getDeclarationFields(eventConfig), (field2) => field2.id);
2391
+ }
2392
+ function getDeclarationFieldById(config, fieldId) {
2393
+ const field2 = getAllUniqueFields(config).find((f) => f.id === fieldId);
2394
+ return getOrThrow(field2, `Field with id ${fieldId} not found in event config`);
2395
+ }
1870
2396
  var findRecordActionPages = (config, actionType) => {
1871
2397
  const action = config.actions.find((a) => a.type === actionType);
1872
2398
  if (action?.type === ActionType.REQUEST_CORRECTION) {
@@ -1927,8 +2453,9 @@ function createEmptyDraft(eventId, draftId, actionType) {
1927
2453
  declaration: {},
1928
2454
  annotation: {},
1929
2455
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2456
+ createdByUserType: TokenUserType.Enum.user,
1930
2457
  createdBy: "@todo",
1931
- createdAtLocation: "00000000-0000-0000-0000-000000000000",
2458
+ createdAtLocation: "@todo",
1932
2459
  status: ActionStatus.Accepted,
1933
2460
  transactionId: "@todo",
1934
2461
  createdByRole: "@todo"
@@ -1972,8 +2499,9 @@ function omitHiddenAnnotationFields(actionConfig, declaration, annotation) {
1972
2499
  );
1973
2500
  }
1974
2501
  function deepMerge(currentDocument, actionDocument) {
2502
+ const currentDocumentClone = (0, import_lodash.cloneDeep)(currentDocument);
1975
2503
  return (0, import_lodash.mergeWith)(
1976
- currentDocument,
2504
+ (0, import_lodash.cloneDeep)(currentDocumentClone),
1977
2505
  actionDocument,
1978
2506
  (previousValue, incomingValue) => {
1979
2507
  if (incomingValue === void 0) {
@@ -2021,12 +2549,18 @@ function getMixedPath(obj, path, defaultValue) {
2021
2549
  const result = resolve(obj, parts);
2022
2550
  return (0, import_lodash.isNil)(result) ? defaultValue : result;
2023
2551
  }
2552
+ function getEventConfigById(eventConfigs, id) {
2553
+ const eventConfig = eventConfigs.find(
2554
+ (eventConfiguration) => eventConfiguration.id === id
2555
+ );
2556
+ return getOrThrow(eventConfig, `Event config for ${id} not found`);
2557
+ }
2024
2558
 
2025
2559
  // ../commons/src/events/EventConfig.ts
2026
2560
  var import_zod_openapi8 = require("zod-openapi");
2027
- (0, import_zod_openapi8.extendZodWithOpenApi)(import_zod18.z);
2028
- var EventConfig = import_zod18.z.object({
2029
- id: import_zod18.z.string().describe(
2561
+ (0, import_zod_openapi8.extendZodWithOpenApi)(import_zod20.z);
2562
+ var EventConfig = import_zod20.z.object({
2563
+ id: import_zod20.z.string().describe(
2030
2564
  'A machine-readable identifier for the event, e.g. "birth" or "death"'
2031
2565
  ),
2032
2566
  dateOfEvent: FieldReference.optional(),
@@ -2036,10 +2570,10 @@ var EventConfig = import_zod18.z.object({
2036
2570
  ),
2037
2571
  summary: SummaryConfig,
2038
2572
  label: TranslationConfig,
2039
- actions: import_zod18.z.array(ActionConfig),
2573
+ actions: import_zod20.z.array(ActionConfig),
2040
2574
  declaration: DeclarationFormConfig,
2041
- deduplication: import_zod18.z.array(DeduplicationConfig).optional().default([]),
2042
- advancedSearch: import_zod18.z.array(AdvancedSearchConfig).optional().default([])
2575
+ deduplication: import_zod20.z.array(DeduplicationConfig).optional().default([]),
2576
+ advancedSearch: import_zod20.z.array(AdvancedSearchConfig).optional().default([])
2043
2577
  }).superRefine((event2, ctx) => {
2044
2578
  const allFields = findAllFields(event2);
2045
2579
  const fieldIds = allFields.map((field2) => field2.id);
@@ -2101,12 +2635,12 @@ var definePage = (page) => PageConfig.parse(page);
2101
2635
  var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
2102
2636
 
2103
2637
  // ../commons/src/events/WorkqueueConfig.ts
2104
- var import_zod25 = require("zod");
2638
+ var import_zod27 = require("zod");
2105
2639
 
2106
2640
  // ../commons/src/events/serializers/user/serializer.ts
2107
- var import_zod19 = require("zod");
2108
- var SerializedUserField = import_zod19.z.object({
2109
- $userField: import_zod19.z.enum([
2641
+ var import_zod21 = require("zod");
2642
+ var SerializedUserField = import_zod21.z.object({
2643
+ $userField: import_zod21.z.enum([
2110
2644
  "id",
2111
2645
  "name",
2112
2646
  "role",
@@ -2307,7 +2841,7 @@ function createFieldConditionals(fieldId) {
2307
2841
  properties: {
2308
2842
  [fieldId]: {
2309
2843
  type: ["string", "boolean"],
2310
- const: { $data: `1/${comparedFieldId}` }
2844
+ const: { $data: `/$form/${comparedFieldId}` }
2311
2845
  },
2312
2846
  [comparedFieldId]: { type: ["string", "boolean"] }
2313
2847
  },
@@ -2417,6 +2951,23 @@ function createFieldConditionals(fieldId) {
2417
2951
  }
2418
2952
  },
2419
2953
  required: [fieldId]
2954
+ }),
2955
+ getId: () => ({ fieldId }),
2956
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2957
+ object: (options) => defineFormConditional({
2958
+ type: "object",
2959
+ properties: {
2960
+ [fieldId]: {
2961
+ type: "object",
2962
+ properties: Object.fromEntries(
2963
+ Object.entries(options).map(([key, value]) => {
2964
+ return [key, value.properties.$form.properties[key]];
2965
+ })
2966
+ ),
2967
+ required: Object.keys(options)
2968
+ }
2969
+ },
2970
+ required: [fieldId]
2420
2971
  })
2421
2972
  };
2422
2973
  }
@@ -2492,89 +3043,78 @@ var event = Object.assign(eventFn, {
2492
3043
  });
2493
3044
 
2494
3045
  // ../commons/src/events/WorkqueueColumnConfig.ts
2495
- var import_zod21 = require("zod");
3046
+ var import_zod23 = require("zod");
2496
3047
 
2497
3048
  // ../commons/src/events/EventMetadata.ts
2498
- var import_zod20 = require("zod");
2499
- var EventStatus = {
2500
- CREATED: "CREATED",
2501
- NOTIFIED: "NOTIFIED",
2502
- DECLARED: "DECLARED",
2503
- VALIDATED: "VALIDATED",
2504
- REGISTERED: "REGISTERED",
2505
- CERTIFIED: "CERTIFIED",
2506
- REJECTED: "REJECTED",
2507
- ARCHIVED: "ARCHIVED"
2508
- };
2509
- var eventStatusValues = [
2510
- EventStatus.CREATED,
2511
- EventStatus.NOTIFIED,
2512
- EventStatus.DECLARED,
2513
- EventStatus.VALIDATED,
2514
- EventStatus.REGISTERED,
2515
- EventStatus.CERTIFIED,
2516
- EventStatus.REJECTED,
2517
- EventStatus.ARCHIVED
2518
- ];
2519
- var EventStatusEnum = import_zod20.z.enum(eventStatusValues);
3049
+ var import_zod22 = require("zod");
3050
+ var EventStatus = import_zod22.z.enum([
3051
+ "CREATED",
3052
+ "NOTIFIED",
3053
+ "DECLARED",
3054
+ "VALIDATED",
3055
+ "REGISTERED",
3056
+ "CERTIFIED",
3057
+ "REJECTED",
3058
+ "ARCHIVED"
3059
+ ]);
2520
3060
  var CustomFlags = {
2521
3061
  CERTIFICATE_PRINTED: "certificate-printed"
2522
3062
  };
2523
- var Flag = import_zod20.z.string().regex(
3063
+ var Flag = import_zod22.z.string().regex(
2524
3064
  new RegExp(
2525
3065
  `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
2526
3066
  ActionStatus
2527
3067
  ).join("|").toLowerCase()})$`
2528
3068
  ),
2529
3069
  "Flag must be in the format ActionType:ActionStatus (lowerCase)"
2530
- ).or(import_zod20.z.nativeEnum(CustomFlags));
2531
- var eventStatuses = Object.values(EventStatus);
2532
- var EventStatuses = import_zod20.z.nativeEnum(EventStatus);
2533
- var ZodDate = import_zod20.z.string().date();
2534
- var ActionCreationMetadata = import_zod20.z.object({
2535
- createdAt: import_zod20.z.string().datetime().describe("The timestamp when the action request was created."),
2536
- createdBy: import_zod20.z.string().describe("ID of the user who created the action request."),
3070
+ ).or(import_zod22.z.nativeEnum(CustomFlags));
3071
+ var ZodDate = import_zod22.z.string().date();
3072
+ var ActionCreationMetadata = import_zod22.z.object({
3073
+ createdAt: import_zod22.z.string().datetime().describe("The timestamp when the action request was created."),
3074
+ createdBy: import_zod22.z.string().describe("ID of the user who created the action request."),
2537
3075
  createdAtLocation: CreatedAtLocation.describe(
2538
3076
  "Location of the user who created the action request."
2539
3077
  ),
2540
- acceptedAt: import_zod20.z.string().datetime().describe("Timestamp when the action request was accepted."),
2541
- createdByRole: import_zod20.z.string().describe("Role of the user at the time of action request creation."),
2542
- createdBySignature: import_zod20.z.string().nullish().describe("Signature of the user who created the action request.")
3078
+ createdByUserType: import_zod22.z.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
3079
+ acceptedAt: import_zod22.z.string().datetime().describe("Timestamp when the action request was accepted."),
3080
+ createdByRole: import_zod22.z.string().describe("Role of the user at the time of action request creation."),
3081
+ createdBySignature: import_zod22.z.string().nullish().describe("Signature of the user who created the action request.")
2543
3082
  });
2544
3083
  var RegistrationCreationMetadata = ActionCreationMetadata.extend({
2545
- registrationNumber: import_zod20.z.string().describe(
3084
+ registrationNumber: import_zod22.z.string().describe(
2546
3085
  "Registration number of the event. Always present for accepted registrations."
2547
3086
  )
2548
3087
  });
2549
- var LegalStatuses = import_zod20.z.object({
2550
- [EventStatus.DECLARED]: ActionCreationMetadata.nullish(),
2551
- [EventStatus.REGISTERED]: RegistrationCreationMetadata.nullish()
3088
+ var LegalStatuses = import_zod22.z.object({
3089
+ [EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
3090
+ [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
2552
3091
  });
2553
- var EventMetadata = import_zod20.z.object({
2554
- id: UUID,
2555
- type: import_zod20.z.string().describe("The type of event, such as birth, death, or marriage."),
2556
- status: EventStatuses,
3092
+ var EventMetadata = import_zod22.z.object({
3093
+ id: import_zod22.z.string(),
3094
+ type: import_zod22.z.string().describe("The type of event, such as birth, death, or marriage."),
3095
+ status: EventStatus,
2557
3096
  legalStatuses: LegalStatuses.describe(
2558
3097
  "Metadata related to the legal registration of the event, such as who registered it and when."
2559
3098
  ),
2560
- createdAt: import_zod20.z.string().datetime().describe("The timestamp when the event was first created and saved."),
3099
+ createdAt: import_zod22.z.string().datetime().describe("The timestamp when the event was first created and saved."),
2561
3100
  dateOfEvent: ZodDate.nullish(),
2562
- createdBy: import_zod20.z.string().describe("ID of the user who created the event."),
2563
- updatedByUserRole: import_zod20.z.string().describe("Role of the user who last updated the declaration."),
3101
+ createdBy: import_zod22.z.string().describe("ID of the user who created the event."),
3102
+ createdByUserType: import_zod22.z.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
3103
+ updatedByUserRole: import_zod22.z.string().describe("Role of the user who last changed the status."),
2564
3104
  createdAtLocation: CreatedAtLocation.describe(
2565
3105
  "Location of the user who created the event."
2566
3106
  ),
2567
- createdBySignature: import_zod20.z.string().nullish().describe("Signature of the user who created the event."),
2568
- updatedAtLocation: UUID.nullish().describe(
2569
- "Location of the user who last updated the declaration."
3107
+ createdBySignature: import_zod22.z.string().nullish().describe("Signature of the user who created the event."),
3108
+ updatedAtLocation: import_zod22.z.string().nullish().describe("Location of the user who last changed the status."),
3109
+ updatedAt: import_zod22.z.string().datetime().describe(
3110
+ "Timestamp of the most recent *accepted* status change. Possibly 3rd party update, if action is validation asynchronously."
2570
3111
  ),
2571
- updatedAt: import_zod20.z.string().datetime().describe("Timestamp of the most recent declaration update."),
2572
- assignedTo: import_zod20.z.string().nullish().describe("ID of the user currently assigned to the event."),
2573
- updatedBy: import_zod20.z.string().nullish().describe("ID of the user who last updated the declaration."),
2574
- trackingId: import_zod20.z.string().describe(
3112
+ assignedTo: import_zod22.z.string().nullish().describe("ID of the user currently assigned to the event."),
3113
+ updatedBy: import_zod22.z.string().nullish().describe("ID of the user who last changed the status."),
3114
+ trackingId: import_zod22.z.string().describe(
2575
3115
  "System-generated tracking ID used by informants or registrars to look up the event."
2576
3116
  ),
2577
- flags: import_zod20.z.array(Flag)
3117
+ flags: import_zod22.z.array(Flag)
2578
3118
  });
2579
3119
  var EventMetadataKeysArray = [
2580
3120
  "id",
@@ -2583,6 +3123,7 @@ var EventMetadataKeysArray = [
2583
3123
  "createdAt",
2584
3124
  "dateOfEvent",
2585
3125
  "createdBy",
3126
+ "createdByUserType",
2586
3127
  "updatedByUserRole",
2587
3128
  "createdAtLocation",
2588
3129
  "updatedAtLocation",
@@ -2593,7 +3134,7 @@ var EventMetadataKeysArray = [
2593
3134
  "legalStatuses",
2594
3135
  "flags"
2595
3136
  ];
2596
- var EventMetadataKeys = import_zod20.z.enum(EventMetadataKeysArray);
3137
+ var EventMetadataKeys = import_zod22.z.enum(EventMetadataKeysArray);
2597
3138
  var eventMetadataLabelMap = {
2598
3139
  "event.assignedTo": {
2599
3140
  id: "event.assignedTo.label",
@@ -2605,6 +3146,11 @@ var eventMetadataLabelMap = {
2605
3146
  defaultMessage: "Created",
2606
3147
  description: "Created At"
2607
3148
  },
3149
+ "event.createdByUserType": {
3150
+ id: "event.createdByUserType.label",
3151
+ defaultMessage: "createdByUserType",
3152
+ description: "createdByUserType:user or system"
3153
+ },
2608
3154
  "event.dateOfEvent": {
2609
3155
  id: "event.dateOfEvent.label",
2610
3156
  defaultMessage: "Date of Event",
@@ -2670,13 +3216,14 @@ var eventMetadataLabelMap = {
2670
3216
  // ../commons/src/events/WorkqueueColumnConfig.ts
2671
3217
  var WorkqueueColumnKeysArray = [
2672
3218
  ...EventMetadataKeysArray,
2673
- "title"
3219
+ "title",
3220
+ "outbox"
2674
3221
  ];
2675
- var WorkqueueColumnKeys = import_zod21.z.enum(WorkqueueColumnKeysArray);
2676
- var WorkqueueColumnValue = import_zod21.z.object({
3222
+ var WorkqueueColumnKeys = import_zod23.z.enum(WorkqueueColumnKeysArray);
3223
+ var WorkqueueColumnValue = import_zod23.z.object({
2677
3224
  $event: WorkqueueColumnKeys
2678
3225
  });
2679
- var WorkqueueColumn = import_zod21.z.object({
3226
+ var WorkqueueColumn = import_zod23.z.object({
2680
3227
  label: TranslationConfig,
2681
3228
  value: WorkqueueColumnValue
2682
3229
  });
@@ -2687,96 +3234,112 @@ function defineWorkqueuesColumns(workqueueColumns) {
2687
3234
  }
2688
3235
 
2689
3236
  // ../commons/src/events/CountryConfigQueryInput.ts
2690
- var import_zod23 = require("zod");
3237
+ var import_zod25 = require("zod");
2691
3238
 
2692
3239
  // ../commons/src/events/EventIndex.ts
2693
- var import_zod22 = require("zod");
3240
+ var import_zod24 = require("zod");
2694
3241
  var import_zod_openapi9 = require("zod-openapi");
2695
- (0, import_zod_openapi9.extendZodWithOpenApi)(import_zod22.z);
3242
+ (0, import_zod_openapi9.extendZodWithOpenApi)(import_zod24.z);
2696
3243
  var EventIndex = EventMetadata.extend({
2697
3244
  declaration: EventState
2698
3245
  }).openapi({
2699
3246
  ref: "EventIndex"
2700
3247
  });
2701
- var EventSearchIndex = import_zod22.z.record(import_zod22.z.string(), import_zod22.z.any()).and(
2702
- import_zod22.z.object({
2703
- type: import_zod22.z.string()
3248
+ var EventSearchIndex = import_zod24.z.record(import_zod24.z.string(), import_zod24.z.any()).and(
3249
+ import_zod24.z.object({
3250
+ type: import_zod24.z.string()
2704
3251
  // Ensures "type" (event-id) exists and is a string
2705
3252
  })
2706
3253
  ).openapi({
2707
3254
  ref: "EventSearchIndex"
2708
3255
  });
2709
- var Fuzzy = import_zod22.z.object({ type: import_zod22.z.literal("fuzzy"), term: import_zod22.z.string() }).openapi({
3256
+ var Fuzzy = import_zod24.z.object({ type: import_zod24.z.literal("fuzzy"), term: import_zod24.z.string() }).openapi({
2710
3257
  ref: "Fuzzy"
2711
3258
  });
2712
- var Exact = import_zod22.z.object({ type: import_zod22.z.literal("exact"), term: import_zod22.z.string() }).openapi({
3259
+ var Exact = import_zod24.z.object({ type: import_zod24.z.literal("exact"), term: import_zod24.z.string() }).openapi({
2713
3260
  ref: "Exact"
2714
3261
  });
2715
- var AnyOf = import_zod22.z.object({
2716
- type: import_zod22.z.literal("anyOf"),
2717
- terms: import_zod22.z.array(import_zod22.z.string())
3262
+ var ExactStatus = import_zod24.z.object({
3263
+ type: import_zod24.z.literal("exact"),
3264
+ term: EventStatus
2718
3265
  }).openapi({
2719
- ref: "AnyOf"
3266
+ ref: "ExactStatus"
2720
3267
  });
2721
- var ExactStatus = import_zod22.z.object({
2722
- type: import_zod22.z.literal("exact"),
2723
- term: EventStatusEnum
3268
+ var AnyOf = import_zod24.z.object({
3269
+ type: import_zod24.z.literal("anyOf"),
3270
+ terms: import_zod24.z.array(import_zod24.z.string())
2724
3271
  }).openapi({
2725
- ref: "ExactStatus"
3272
+ ref: "AnyOf"
2726
3273
  });
2727
- var AnyOfStatus = import_zod22.z.object({
2728
- type: import_zod22.z.literal("anyOf"),
2729
- terms: import_zod22.z.array(EventStatusEnum)
3274
+ var AnyOfStatus = import_zod24.z.object({
3275
+ type: import_zod24.z.literal("anyOf"),
3276
+ terms: import_zod24.z.array(EventStatus)
2730
3277
  }).openapi({
2731
3278
  ref: "AnyOfStatus"
2732
3279
  });
2733
- var Range = import_zod22.z.object({
2734
- type: import_zod22.z.literal("range"),
2735
- gte: import_zod22.z.string(),
2736
- lte: import_zod22.z.string()
3280
+ var Range = import_zod24.z.object({
3281
+ type: import_zod24.z.literal("range"),
3282
+ gte: import_zod24.z.string(),
3283
+ lte: import_zod24.z.string()
2737
3284
  }).openapi({
2738
3285
  ref: "Range"
2739
3286
  });
2740
- var Not = import_zod22.z.object({ type: import_zod22.z.literal("not"), term: import_zod22.z.string() }).openapi({
3287
+ var Not = import_zod24.z.object({ type: import_zod24.z.literal("not"), term: import_zod24.z.string() }).openapi({
2741
3288
  ref: "Not"
2742
3289
  });
2743
- var Within = import_zod22.z.object({ type: import_zod22.z.literal("within"), location: import_zod22.z.string() }).openapi({
3290
+ var Within = import_zod24.z.object({ type: import_zod24.z.literal("within"), location: import_zod24.z.string() }).openapi({
2744
3291
  ref: "Within"
2745
3292
  });
2746
- var DateCondition = import_zod22.z.union([Exact, Range]).openapi({
3293
+ var RangeDate = Range.extend({
3294
+ gte: import_zod24.z.string().date().or(import_zod24.z.string().datetime()),
3295
+ lte: import_zod24.z.string().date().or(import_zod24.z.string().datetime())
3296
+ }).openapi({
3297
+ ref: "RangeDate"
3298
+ });
3299
+ var ExactDate = Exact.extend({
3300
+ term: import_zod24.z.string().date().or(import_zod24.z.string().datetime())
3301
+ }).openapi({
3302
+ ref: "ExactDate"
3303
+ });
3304
+ var DateCondition = import_zod24.z.union([ExactDate, RangeDate]).openapi({
2747
3305
  ref: "DateCondition"
2748
3306
  });
2749
- var QueryInput = import_zod22.z.lazy(
2750
- () => import_zod22.z.union([
2751
- import_zod22.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf, Not]),
2752
- import_zod22.z.record(import_zod22.z.string(), QueryInput)
3307
+ var QueryInput = import_zod24.z.lazy(
3308
+ () => import_zod24.z.union([
3309
+ import_zod24.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf, Not]),
3310
+ import_zod24.z.record(import_zod24.z.string(), QueryInput)
2753
3311
  ])
2754
3312
  ).openapi({
2755
3313
  ref: "QueryInput"
2756
3314
  });
2757
- var QueryExpression = import_zod22.z.object({
2758
- eventType: import_zod22.z.string(),
2759
- status: import_zod22.z.optional(import_zod22.z.union([AnyOfStatus, ExactStatus])),
2760
- createdAt: import_zod22.z.optional(DateCondition),
2761
- updatedAt: import_zod22.z.optional(DateCondition),
2762
- "legalStatus.REGISTERED.createdAt": import_zod22.z.optional(DateCondition),
2763
- "legalStatus.REGISTERED.createdAtLocation": import_zod22.z.optional(
2764
- import_zod22.z.union([Within, Exact])
3315
+ var QueryExpression = import_zod24.z.object({
3316
+ id: import_zod24.z.optional(import_zod24.z.string()),
3317
+ eventType: import_zod24.z.string(),
3318
+ status: import_zod24.z.optional(import_zod24.z.union([AnyOfStatus, ExactStatus])),
3319
+ createdAt: import_zod24.z.optional(DateCondition),
3320
+ updatedAt: import_zod24.z.optional(DateCondition),
3321
+ "legalStatus.REGISTERED.createdAt": import_zod24.z.optional(DateCondition),
3322
+ "legalStatus.REGISTERED.createdAtLocation": import_zod24.z.optional(
3323
+ import_zod24.z.union([Within, Exact])
2765
3324
  ),
2766
- createdAtLocation: import_zod22.z.optional(import_zod22.z.union([Within, Exact])),
2767
- updatedAtLocation: import_zod22.z.optional(import_zod22.z.union([Within, Exact])),
2768
- assignedTo: import_zod22.z.optional(Exact),
2769
- createdBy: import_zod22.z.optional(Exact),
2770
- updatedBy: import_zod22.z.optional(Exact),
2771
- trackingId: import_zod22.z.optional(Exact),
2772
- flags: import_zod22.z.optional(import_zod22.z.array(import_zod22.z.union([AnyOf, Not]))),
3325
+ "legalStatus.REGISTERED.registrationNumber": import_zod24.z.optional(Exact),
3326
+ createdAtLocation: import_zod24.z.optional(import_zod24.z.union([Within, Exact])),
3327
+ updatedAtLocation: import_zod24.z.optional(import_zod24.z.union([Within, Exact])),
3328
+ assignedTo: import_zod24.z.optional(Exact),
3329
+ createdByUserType: TokenUserType,
3330
+ createdBy: import_zod24.z.optional(Exact),
3331
+ updatedBy: import_zod24.z.optional(Exact),
3332
+ trackingId: import_zod24.z.optional(Exact),
3333
+ flags: import_zod24.z.optional(import_zod24.z.array(import_zod24.z.union([AnyOf, Not]))),
2773
3334
  data: QueryInput
2774
- }).partial().openapi({
3335
+ }).partial().refine((obj) => Object.values(obj).some((val) => val !== void 0), {
3336
+ message: "At least one query field must be specified."
3337
+ }).openapi({
2775
3338
  ref: "QueryExpression"
2776
3339
  });
2777
- var QueryType = import_zod22.z.object({
2778
- type: import_zod22.z.literal("and").or(import_zod22.z.literal("or")).openapi({ default: "and" }),
2779
- clauses: import_zod22.z.preprocess(
3340
+ var QueryType = import_zod24.z.object({
3341
+ type: import_zod24.z.literal("and").or(import_zod24.z.literal("or")).openapi({ default: "and" }),
3342
+ clauses: import_zod24.z.preprocess(
2780
3343
  (val) => {
2781
3344
  if (typeof val === "string") {
2782
3345
  return [JSON.parse(val)];
@@ -2786,22 +3349,13 @@ var QueryType = import_zod22.z.object({
2786
3349
  }
2787
3350
  return val;
2788
3351
  },
2789
- import_zod22.z.array(QueryExpression).openapi({
3352
+ import_zod24.z.array(QueryExpression).nonempty("At least one clause is required.").openapi({
2790
3353
  default: [
2791
3354
  {
2792
3355
  eventType: TENNIS_CLUB_MEMBERSHIP,
2793
3356
  status: {
2794
3357
  type: "anyOf",
2795
- terms: [
2796
- "CREATED",
2797
- "NOTIFIED",
2798
- "DECLARED",
2799
- "VALIDATED",
2800
- "REGISTERED",
2801
- "CERTIFIED",
2802
- "REJECTED",
2803
- "ARCHIVED"
2804
- ]
3358
+ terms: EventStatus.options
2805
3359
  },
2806
3360
  updatedAt: {
2807
3361
  type: "range",
@@ -2818,50 +3372,51 @@ var QueryType = import_zod22.z.object({
2818
3372
  });
2819
3373
 
2820
3374
  // ../commons/src/events/CountryConfigQueryInput.ts
2821
- var SerializableExact = import_zod23.z.object({
2822
- type: import_zod23.z.literal("exact"),
2823
- term: import_zod23.z.union([import_zod23.z.string(), SerializedUserField])
3375
+ var SerializableExact = import_zod25.z.object({
3376
+ type: import_zod25.z.literal("exact"),
3377
+ term: import_zod25.z.union([import_zod25.z.string(), SerializedUserField])
2824
3378
  });
2825
- var SerializableWithin = import_zod23.z.object({
2826
- type: import_zod23.z.literal("within"),
2827
- location: import_zod23.z.union([import_zod23.z.string(), SerializedUserField])
3379
+ var SerializableWithin = import_zod25.z.object({
3380
+ type: import_zod25.z.literal("within"),
3381
+ location: import_zod25.z.union([import_zod25.z.string(), SerializedUserField])
2828
3382
  });
2829
- var SerializedQueryExpression = import_zod23.z.object({
2830
- eventType: import_zod23.z.string(),
2831
- status: import_zod23.z.optional(import_zod23.z.union([AnyOfStatus, ExactStatus])),
2832
- createdAt: import_zod23.z.optional(DateCondition),
2833
- updatedAt: import_zod23.z.optional(DateCondition),
2834
- createdAtLocation: import_zod23.z.optional(
2835
- import_zod23.z.union([SerializableWithin, SerializableExact])
3383
+ var SerializedQueryExpression = import_zod25.z.object({
3384
+ eventType: import_zod25.z.string(),
3385
+ status: import_zod25.z.optional(import_zod25.z.union([AnyOfStatus, ExactStatus])),
3386
+ createdAt: import_zod25.z.optional(DateCondition),
3387
+ updatedAt: import_zod25.z.optional(DateCondition),
3388
+ createdAtLocation: import_zod25.z.optional(
3389
+ import_zod25.z.union([SerializableWithin, SerializableExact])
2836
3390
  ),
2837
- updatedAtLocation: import_zod23.z.optional(
2838
- import_zod23.z.union([SerializableWithin, SerializableExact])
3391
+ updatedAtLocation: import_zod25.z.optional(
3392
+ import_zod25.z.union([SerializableWithin, SerializableExact])
2839
3393
  ),
2840
- assignedTo: import_zod23.z.optional(SerializableExact),
2841
- createdBy: import_zod23.z.optional(SerializableExact),
2842
- updatedBy: import_zod23.z.optional(SerializableExact),
2843
- trackingId: import_zod23.z.optional(Exact),
2844
- flags: import_zod23.z.optional(import_zod23.z.array(import_zod23.z.union([AnyOf, Not]))),
3394
+ assignedTo: import_zod25.z.optional(SerializableExact),
3395
+ createdBy: import_zod25.z.optional(SerializableExact),
3396
+ createdByUserType: TokenUserType,
3397
+ updatedBy: import_zod25.z.optional(SerializableExact),
3398
+ trackingId: import_zod25.z.optional(Exact),
3399
+ flags: import_zod25.z.optional(import_zod25.z.array(import_zod25.z.union([AnyOf, Not]))),
2845
3400
  data: QueryInput
2846
3401
  }).partial();
2847
- var Or2 = import_zod23.z.object({
2848
- type: import_zod23.z.literal("or"),
2849
- clauses: import_zod23.z.array(SerializedQueryExpression)
3402
+ var Or2 = import_zod25.z.object({
3403
+ type: import_zod25.z.literal("or"),
3404
+ clauses: import_zod25.z.array(SerializedQueryExpression)
2850
3405
  });
2851
- var And2 = import_zod23.z.object({
2852
- type: import_zod23.z.literal("and"),
2853
- clauses: import_zod23.z.array(SerializedQueryExpression)
3406
+ var And2 = import_zod25.z.object({
3407
+ type: import_zod25.z.literal("and"),
3408
+ clauses: import_zod25.z.array(SerializedQueryExpression)
2854
3409
  });
2855
- var CountryConfigQueryType = import_zod23.z.discriminatedUnion("type", [And2, Or2]);
2856
- var CountryConfigQueryInputType = import_zod23.z.union([
3410
+ var CountryConfigQueryType = import_zod25.z.discriminatedUnion("type", [And2, Or2]);
3411
+ var CountryConfigQueryInputType = import_zod25.z.union([
2857
3412
  SerializedQueryExpression,
2858
3413
  And2,
2859
3414
  Or2
2860
3415
  ]);
2861
3416
 
2862
3417
  // ../commons/src/icons.ts
2863
- var import_zod24 = require("zod");
2864
- var AvailableIcons = import_zod24.z.enum([
3418
+ var import_zod26 = require("zod");
3419
+ var AvailableIcons = import_zod26.z.enum([
2865
3420
  "Archived",
2866
3421
  "Assigned",
2867
3422
  "Certified",
@@ -2965,7 +3520,7 @@ var AvailableIcons = import_zod24.z.enum([
2965
3520
  ]);
2966
3521
 
2967
3522
  // ../commons/src/events/WorkqueueConfig.ts
2968
- var dateOfEventColumn = defineWorkqueuesColumns([
3523
+ var mandatoryColumns = defineWorkqueuesColumns([
2969
3524
  {
2970
3525
  label: {
2971
3526
  id: "workqueues.dateOfEvent",
@@ -2983,34 +3538,42 @@ var dateOfEventColumn = defineWorkqueuesColumns([
2983
3538
  value: event.field("updatedAt")
2984
3539
  }
2985
3540
  ]);
2986
- var WorkqueueConfig = import_zod25.z.object({
2987
- slug: import_zod25.z.string().describe("Determines the url of the workqueue."),
3541
+ var WorkqueueActionsWithDefault = import_zod27.z.enum([
3542
+ ...workqueueActions.options,
3543
+ "DEFAULT"
3544
+ ]);
3545
+ var WorkqueueConfig = import_zod27.z.object({
3546
+ slug: import_zod27.z.string().describe("Determines the url of the workqueue."),
2988
3547
  name: TranslationConfig.describe(
2989
3548
  "Title of the workflow (both in navigation and on the page)"
2990
3549
  ),
2991
3550
  query: CountryConfigQueryType,
2992
- actions: import_zod25.z.array(
2993
- import_zod25.z.object({
2994
- type: import_zod25.z.string(),
2995
- conditionals: import_zod25.z.array(Conditional).optional()
3551
+ actions: import_zod27.z.array(
3552
+ import_zod27.z.object({
3553
+ type: WorkqueueActionsWithDefault,
3554
+ conditionals: import_zod27.z.array(Conditional).optional()
2996
3555
  })
2997
3556
  ),
2998
- columns: import_zod25.z.array(WorkqueueColumn).default(dateOfEventColumn),
3557
+ columns: import_zod27.z.array(WorkqueueColumn).default(mandatoryColumns),
2999
3558
  icon: AvailableIcons
3000
3559
  }).describe("Configuration for workqueue.");
3001
- var WorkqueueConfigInput = import_zod25.z.object({
3002
- slug: import_zod25.z.string().describe("Determines the url of the workqueue."),
3560
+ var WorkqueueConfigWithoutQuery = WorkqueueConfig.omit({
3561
+ query: true,
3562
+ columns: true
3563
+ });
3564
+ var WorkqueueConfigInput = import_zod27.z.object({
3565
+ slug: import_zod27.z.string().describe("Determines the url of the workqueue."),
3003
3566
  name: TranslationConfig.describe(
3004
3567
  "Title of the workflow (both in navigation and on the page)"
3005
3568
  ),
3006
3569
  query: CountryConfigQueryInputType,
3007
- actions: import_zod25.z.array(
3008
- import_zod25.z.object({
3009
- type: import_zod25.z.string(),
3010
- conditionals: import_zod25.z.array(Conditional).optional()
3570
+ actions: import_zod27.z.array(
3571
+ import_zod27.z.object({
3572
+ type: WorkqueueActionsWithDefault,
3573
+ conditionals: import_zod27.z.array(Conditional).optional()
3011
3574
  })
3012
3575
  ),
3013
- columns: import_zod25.z.array(WorkqueueColumn).default(dateOfEventColumn),
3576
+ columns: import_zod27.z.array(WorkqueueColumn).default(mandatoryColumns),
3014
3577
  icon: AvailableIcons
3015
3578
  });
3016
3579
  function defineWorkqueue(workqueueInput) {
@@ -3021,10 +3584,10 @@ function defineWorkqueue(workqueueInput) {
3021
3584
  function defineWorkqueues(workqueues) {
3022
3585
  return workqueues.map((workqueue) => defineWorkqueue(workqueue));
3023
3586
  }
3024
- var WorkqueueCountInput = import_zod25.z.array(
3025
- import_zod25.z.object({ slug: import_zod25.z.string(), query: QueryType })
3587
+ var WorkqueueCountInput = import_zod27.z.array(
3588
+ import_zod27.z.object({ slug: import_zod27.z.string(), query: QueryType })
3026
3589
  );
3027
- var WorkqueueCountOutput = import_zod25.z.record(import_zod25.z.string(), import_zod25.z.number());
3590
+ var WorkqueueCountOutput = import_zod27.z.record(import_zod27.z.string(), import_zod27.z.number());
3028
3591
 
3029
3592
  // ../commons/src/events/workqueueDefaultColumns.ts
3030
3593
  var defaultWorkqueueColumns = [
@@ -3047,114 +3610,115 @@ var defaultWorkqueueColumns = [
3047
3610
  ];
3048
3611
 
3049
3612
  // ../commons/src/events/Draft.ts
3050
- var import_zod27 = require("zod");
3613
+ var import_zod29 = require("zod");
3051
3614
 
3052
3615
  // ../commons/src/events/ActionInput.ts
3053
- var import_zod26 = require("zod");
3616
+ var import_zod28 = require("zod");
3054
3617
  var import_zod_openapi10 = require("zod-openapi");
3055
- (0, import_zod_openapi10.extendZodWithOpenApi)(import_zod26.z);
3056
- var BaseActionInput = import_zod26.z.object({
3057
- eventId: UUID,
3058
- transactionId: import_zod26.z.string(),
3618
+ var import_uuid3 = require("uuid");
3619
+ (0, import_zod_openapi10.extendZodWithOpenApi)(import_zod28.z);
3620
+ var BaseActionInput = import_zod28.z.object({
3621
+ eventId: import_zod28.z.string(),
3622
+ transactionId: import_zod28.z.string(),
3059
3623
  declaration: ActionUpdate.default({}),
3060
3624
  annotation: ActionUpdate.optional(),
3061
- originalActionId: UUID.optional(),
3062
- keepAssignment: import_zod26.z.boolean().optional()
3625
+ originalActionId: import_zod28.z.string().optional(),
3626
+ keepAssignment: import_zod28.z.boolean().optional()
3063
3627
  });
3064
3628
  var CreateActionInput = BaseActionInput.merge(
3065
- import_zod26.z.object({
3066
- type: import_zod26.z.literal(ActionType.CREATE).default(ActionType.CREATE),
3629
+ import_zod28.z.object({
3630
+ type: import_zod28.z.literal(ActionType.CREATE).default(ActionType.CREATE),
3067
3631
  createdAtLocation: CreatedAtLocation
3068
3632
  })
3069
3633
  );
3070
3634
  var RegisterActionInput = BaseActionInput.merge(
3071
- import_zod26.z.object({
3072
- type: import_zod26.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
3073
- registrationNumber: import_zod26.z.string().optional()
3635
+ import_zod28.z.object({
3636
+ type: import_zod28.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
3637
+ registrationNumber: import_zod28.z.string().optional()
3074
3638
  })
3075
3639
  );
3076
3640
  var ValidateActionInput = BaseActionInput.merge(
3077
- import_zod26.z.object({
3078
- type: import_zod26.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
3079
- duplicates: import_zod26.z.array(import_zod26.z.string())
3641
+ import_zod28.z.object({
3642
+ type: import_zod28.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
3643
+ duplicates: import_zod28.z.array(import_zod28.z.string())
3080
3644
  })
3081
3645
  );
3082
3646
  var NotifyActionInput = BaseActionInput.merge(
3083
- import_zod26.z.object({
3084
- type: import_zod26.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
3647
+ import_zod28.z.object({
3648
+ type: import_zod28.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
3085
3649
  })
3086
3650
  ).openapi({
3087
3651
  default: {
3088
3652
  eventId: "<event-id-here>",
3089
- transactionId: getUUID(),
3653
+ transactionId: (0, import_uuid3.v4)(),
3090
3654
  declaration: {},
3091
3655
  annotation: {},
3092
3656
  type: ActionType.NOTIFY
3093
3657
  }
3094
3658
  });
3095
3659
  var DeclareActionInput = BaseActionInput.merge(
3096
- import_zod26.z.object({
3097
- type: import_zod26.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
3660
+ import_zod28.z.object({
3661
+ type: import_zod28.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
3098
3662
  })
3099
3663
  );
3100
3664
  var PrintCertificateActionInput = BaseActionInput.merge(
3101
- import_zod26.z.object({
3102
- type: import_zod26.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
3665
+ import_zod28.z.object({
3666
+ type: import_zod28.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
3103
3667
  })
3104
3668
  );
3105
3669
  var RejectDeclarationActionInput = BaseActionInput.merge(
3106
- import_zod26.z.object({
3107
- type: import_zod26.z.literal(ActionType.REJECT).default(ActionType.REJECT),
3670
+ import_zod28.z.object({
3671
+ type: import_zod28.z.literal(ActionType.REJECT).default(ActionType.REJECT),
3108
3672
  reason: RejectionReason
3109
3673
  })
3110
3674
  );
3111
3675
  var MarkedAsDuplicateActionInput = BaseActionInput.merge(
3112
- import_zod26.z.object({
3113
- type: import_zod26.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
3676
+ import_zod28.z.object({
3677
+ type: import_zod28.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
3114
3678
  })
3115
3679
  );
3116
3680
  var ArchiveActionInput = BaseActionInput.merge(
3117
- import_zod26.z.object({
3118
- type: import_zod26.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
3681
+ import_zod28.z.object({
3682
+ type: import_zod28.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
3119
3683
  reason: RejectionReason
3120
3684
  })
3121
3685
  );
3122
3686
  var AssignActionInput = BaseActionInput.merge(
3123
- import_zod26.z.object({
3124
- type: import_zod26.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
3125
- assignedTo: import_zod26.z.string()
3687
+ import_zod28.z.object({
3688
+ type: import_zod28.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
3689
+ assignedTo: import_zod28.z.string()
3126
3690
  })
3127
3691
  );
3128
3692
  var UnassignActionInput = BaseActionInput.merge(
3129
- import_zod26.z.object({
3130
- type: import_zod26.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
3131
- assignedTo: import_zod26.z.literal(null).default(null)
3693
+ import_zod28.z.object({
3694
+ type: import_zod28.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
3695
+ assignedTo: import_zod28.z.literal(null).default(null)
3132
3696
  })
3133
3697
  );
3134
3698
  var RequestCorrectionActionInput = BaseActionInput.merge(
3135
- import_zod26.z.object({
3136
- type: import_zod26.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
3699
+ import_zod28.z.object({
3700
+ type: import_zod28.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
3137
3701
  })
3138
3702
  );
3139
3703
  var RejectCorrectionActionInput = BaseActionInput.merge(
3140
- import_zod26.z.object({
3141
- requestId: import_zod26.z.string(),
3142
- type: import_zod26.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
3704
+ import_zod28.z.object({
3705
+ requestId: import_zod28.z.string(),
3706
+ type: import_zod28.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
3143
3707
  })
3144
3708
  );
3145
3709
  var ApproveCorrectionActionInput = BaseActionInput.merge(
3146
- import_zod26.z.object({
3147
- requestId: import_zod26.z.string(),
3148
- type: import_zod26.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
3710
+ import_zod28.z.object({
3711
+ requestId: import_zod28.z.string(),
3712
+ type: import_zod28.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
3149
3713
  })
3150
3714
  );
3151
3715
  var ReadActionInput = BaseActionInput.merge(
3152
- import_zod26.z.object({
3153
- type: import_zod26.z.literal(ActionType.READ).default(ActionType.READ)
3716
+ import_zod28.z.object({
3717
+ type: import_zod28.z.literal(ActionType.READ).default(ActionType.READ)
3154
3718
  })
3155
3719
  );
3156
- var DeleteActionInput = import_zod26.z.object({ eventId: UUID });
3157
- var ActionInput = import_zod26.z.discriminatedUnion("type", [
3720
+ var DeleteActionInput = import_zod28.z.object({ eventId: import_zod28.z.string() });
3721
+ var ActionInput = import_zod28.z.discriminatedUnion("type", [
3158
3722
  CreateActionInput.openapi({ ref: "CreateActionInput" }),
3159
3723
  ValidateActionInput.openapi({ ref: "ValidateActionInput" }),
3160
3724
  RegisterActionInput.openapi({ ref: "RegisterActionInput" }),
@@ -3183,18 +3747,18 @@ var ActionInput = import_zod26.z.discriminatedUnion("type", [
3183
3747
  });
3184
3748
 
3185
3749
  // ../commons/src/events/Draft.ts
3186
- var Draft = import_zod27.z.object({
3187
- id: UUID,
3188
- eventId: UUID,
3189
- transactionId: import_zod27.z.string(),
3190
- createdAt: import_zod27.z.string().datetime(),
3750
+ var Draft = import_zod29.z.object({
3751
+ id: import_zod29.z.string(),
3752
+ eventId: import_zod29.z.string(),
3753
+ transactionId: import_zod29.z.string(),
3754
+ createdAt: import_zod29.z.string().datetime(),
3191
3755
  action: ActionBase.extend({
3192
3756
  type: ActionTypes
3193
3757
  }).omit({ id: true })
3194
3758
  });
3195
3759
  var DraftInput = BaseActionInput.extend({
3196
3760
  type: ActionTypes,
3197
- status: import_zod27.z.enum([
3761
+ status: import_zod29.z.enum([
3198
3762
  ActionStatus.Requested,
3199
3763
  ActionStatus.Accepted,
3200
3764
  ActionStatus.Rejected
@@ -3202,24 +3766,24 @@ var DraftInput = BaseActionInput.extend({
3202
3766
  });
3203
3767
 
3204
3768
  // ../commons/src/events/EventInput.ts
3205
- var import_zod28 = require("zod");
3206
- var import_uuid8 = require("uuid");
3207
- var EventInput = import_zod28.z.object({
3208
- transactionId: import_zod28.z.string(),
3209
- type: import_zod28.z.string()
3210
- }).openapi({ default: { transactionId: (0, import_uuid8.v4)(), type: "v2.birth" } });
3769
+ var import_zod30 = require("zod");
3770
+ var import_uuid4 = require("uuid");
3771
+ var EventInput = import_zod30.z.object({
3772
+ transactionId: import_zod30.z.string(),
3773
+ type: import_zod30.z.string()
3774
+ }).openapi({ default: { transactionId: (0, import_uuid4.v4)(), type: "v2.birth" } });
3211
3775
 
3212
3776
  // ../commons/src/events/EventDocument.ts
3213
- var import_zod29 = require("zod");
3777
+ var import_zod31 = require("zod");
3214
3778
  var import_zod_openapi11 = require("zod-openapi");
3215
- (0, import_zod_openapi11.extendZodWithOpenApi)(import_zod29.z);
3216
- var EventDocument = import_zod29.z.object({
3217
- id: UUID,
3218
- type: import_zod29.z.string(),
3219
- createdAt: import_zod29.z.string().datetime(),
3220
- updatedAt: import_zod29.z.string().datetime(),
3221
- actions: import_zod29.z.array(Action),
3222
- trackingId: import_zod29.z.string()
3779
+ (0, import_zod_openapi11.extendZodWithOpenApi)(import_zod31.z);
3780
+ var EventDocument = import_zod31.z.object({
3781
+ id: import_zod31.z.string(),
3782
+ type: import_zod31.z.string(),
3783
+ createdAt: import_zod31.z.string().datetime(),
3784
+ updatedAt: import_zod31.z.string().datetime(),
3785
+ actions: import_zod31.z.array(Action),
3786
+ trackingId: import_zod31.z.string()
3223
3787
  }).openapi({ ref: "EventDocument" });
3224
3788
 
3225
3789
  // ../commons/src/events/state/utils.ts
@@ -3253,6 +3817,7 @@ function getDeclarationActionCreationMetadata(actionType, actions) {
3253
3817
  // When 3rd party API returns 200 OK, we assume that the request was accepted, and persist single 'accepted' action.
3254
3818
  createdAt: requestAction?.createdAt ?? acceptAction.createdAt,
3255
3819
  createdBy: requestAction?.createdBy ?? acceptAction.createdBy,
3820
+ createdByUserType: requestAction?.createdByUserType ?? acceptAction.createdByUserType,
3256
3821
  createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
3257
3822
  acceptedAt: acceptAction.createdAt,
3258
3823
  createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
@@ -3260,17 +3825,18 @@ function getDeclarationActionCreationMetadata(actionType, actions) {
3260
3825
  registrationNumber
3261
3826
  };
3262
3827
  }
3263
- function getDeclarationActionUpdateMetadata(actions) {
3828
+ function getActionUpdateMetadata(actions) {
3264
3829
  const createAction = getOrThrow(
3265
3830
  actions.find((action) => action.type === ActionType.CREATE),
3266
3831
  `Event has no ${ActionType.CREATE} action`
3267
3832
  );
3268
- return [ActionType.DECLARE, ActionType.VALIDATE, ActionType.REGISTER].reduce(
3833
+ return StatusChangingActions.options.reduce(
3269
3834
  (metadata, actionType) => {
3270
3835
  const { accept, request } = getActionRequests(actionType, actions);
3271
3836
  return {
3272
3837
  createdAt: request?.createdAt ?? accept?.createdAt ?? metadata.createdAt,
3273
3838
  createdBy: request?.createdBy ?? accept?.createdBy ?? metadata.createdBy,
3839
+ createdByUserType: request?.createdByUserType ?? accept?.createdByUserType ?? metadata.createdByUserType,
3274
3840
  createdAtLocation: request?.createdAtLocation ?? accept?.createdAtLocation ?? metadata.createdAtLocation,
3275
3841
  createdByRole: request?.createdByRole ?? accept?.createdByRole ?? metadata.createdByRole
3276
3842
  };
@@ -3278,6 +3844,7 @@ function getDeclarationActionUpdateMetadata(actions) {
3278
3844
  {
3279
3845
  createdAt: createAction.createdAt,
3280
3846
  createdBy: createAction.createdBy,
3847
+ createdByUserType: createAction.createdByUserType,
3281
3848
  createdAtLocation: createAction.createdAtLocation,
3282
3849
  createdByRole: createAction.createdByRole
3283
3850
  }
@@ -3285,11 +3852,11 @@ function getDeclarationActionUpdateMetadata(actions) {
3285
3852
  }
3286
3853
  function getLegalStatuses(actions) {
3287
3854
  return {
3288
- [EventStatus.DECLARED]: getDeclarationActionCreationMetadata(
3855
+ [EventStatus.enum.DECLARED]: getDeclarationActionCreationMetadata(
3289
3856
  ActionType.DECLARE,
3290
3857
  actions
3291
3858
  ),
3292
- [EventStatus.REGISTERED]: getDeclarationActionCreationMetadata(
3859
+ [EventStatus.enum.REGISTERED]: getDeclarationActionCreationMetadata(
3293
3860
  ActionType.REGISTER,
3294
3861
  actions
3295
3862
  )
@@ -3302,26 +3869,26 @@ function getStatusFromActions(actions) {
3302
3869
  (a) => a.status === ActionStatus.Rejected
3303
3870
  );
3304
3871
  if (hasRejectedAction) {
3305
- return EventStatus.REJECTED;
3872
+ return EventStatus.enum.REJECTED;
3306
3873
  }
3307
3874
  return actions.reduce((status, action) => {
3308
3875
  switch (action.type) {
3309
3876
  case ActionType.CREATE:
3310
- return EventStatus.CREATED;
3877
+ return EventStatus.enum.CREATED;
3311
3878
  case ActionType.DECLARE:
3312
- return EventStatus.DECLARED;
3879
+ return EventStatus.enum.DECLARED;
3313
3880
  case ActionType.VALIDATE:
3314
- return EventStatus.VALIDATED;
3881
+ return EventStatus.enum.VALIDATED;
3315
3882
  case ActionType.REGISTER:
3316
- return EventStatus.REGISTERED;
3883
+ return EventStatus.enum.REGISTERED;
3317
3884
  case ActionType.REJECT:
3318
- return EventStatus.REJECTED;
3885
+ return EventStatus.enum.REJECTED;
3319
3886
  case ActionType.ARCHIVE:
3320
- return EventStatus.ARCHIVED;
3887
+ return EventStatus.enum.ARCHIVED;
3321
3888
  case ActionType.NOTIFY:
3322
- return EventStatus.NOTIFIED;
3889
+ return EventStatus.enum.NOTIFIED;
3323
3890
  case ActionType.PRINT_CERTIFICATE:
3324
- return EventStatus.CERTIFIED;
3891
+ return EventStatus.enum.CERTIFIED;
3325
3892
  case ActionType.ASSIGN:
3326
3893
  case ActionType.UNASSIGN:
3327
3894
  case ActionType.REQUEST_CORRECTION:
@@ -3332,7 +3899,7 @@ function getStatusFromActions(actions) {
3332
3899
  default:
3333
3900
  return status;
3334
3901
  }
3335
- }, EventStatus.CREATED);
3902
+ }, EventStatus.enum.CREATED);
3336
3903
  }
3337
3904
  function getFlagsFromActions(actions) {
3338
3905
  const sortedactions = actions.sort(
@@ -3424,7 +3991,7 @@ function deepDropNulls(obj) {
3424
3991
  return obj;
3425
3992
  }
3426
3993
  function isUndeclaredDraft(status) {
3427
- return status === EventStatus.CREATED;
3994
+ return status === EventStatus.enum.CREATED;
3428
3995
  }
3429
3996
  function getAcceptedActions(event2) {
3430
3997
  return event2.actions.filter(
@@ -3439,10 +4006,11 @@ function getCurrentEventState(event2, config) {
3439
4006
  if (!creationAction) {
3440
4007
  throw new Error(`Event ${event2.id} has no creation action`);
3441
4008
  }
3442
- const acceptedActions = getAcceptedActions(event2);
3443
- const declarationUpdateMetadata = getDeclarationActionUpdateMetadata(
3444
- event2.actions
4009
+ const acceptedActions = getAcceptedActions(event2).sort(
4010
+ (a, b) => a.createdAt.localeCompare(b.createdAt)
3445
4011
  );
4012
+ const requestActionMetadata = getActionUpdateMetadata(event2.actions);
4013
+ const acceptedActionMetadata = getActionUpdateMetadata(acceptedActions);
3446
4014
  const declaration = aggregateActionDeclarations(acceptedActions);
3447
4015
  let dateOfEvent;
3448
4016
  if (config.dateOfEvent) {
@@ -3462,16 +4030,17 @@ function getCurrentEventState(event2, config) {
3462
4030
  legalStatuses: getLegalStatuses(event2.actions),
3463
4031
  createdAt: creationAction.createdAt,
3464
4032
  createdBy: creationAction.createdBy,
4033
+ createdByUserType: creationAction.createdByUserType,
3465
4034
  createdAtLocation: creationAction.createdAtLocation,
3466
4035
  createdBySignature: creationAction.createdBySignature,
3467
- updatedAt: declarationUpdateMetadata.createdAt,
4036
+ updatedAt: acceptedActionMetadata.createdAt,
3468
4037
  assignedTo: getAssignedUserFromActions(acceptedActions),
3469
4038
  assignedToSignature: getAssignedUserSignatureFromActions(acceptedActions),
3470
- updatedBy: declarationUpdateMetadata.createdBy,
3471
- updatedAtLocation: declarationUpdateMetadata.createdAtLocation,
4039
+ updatedBy: requestActionMetadata.createdBy,
4040
+ updatedAtLocation: requestActionMetadata.createdAtLocation,
3472
4041
  declaration,
3473
4042
  trackingId: event2.trackingId,
3474
- updatedByUserRole: declarationUpdateMetadata.createdByRole,
4043
+ updatedByUserRole: requestActionMetadata.createdByRole,
3475
4044
  dateOfEvent,
3476
4045
  flags: getFlagsFromActions(event2.actions)
3477
4046
  });
@@ -3554,18 +4123,18 @@ function generateTransactionId() {
3554
4123
  }
3555
4124
 
3556
4125
  // ../commons/src/events/User.ts
3557
- var import_zod30 = require("zod");
3558
- var User = import_zod30.z.object({
3559
- id: import_zod30.z.string(),
3560
- name: import_zod30.z.array(
3561
- import_zod30.z.object({
3562
- use: import_zod30.z.string(),
3563
- given: import_zod30.z.array(import_zod30.z.string()),
3564
- family: import_zod30.z.string()
4126
+ var import_zod32 = require("zod");
4127
+ var User = import_zod32.z.object({
4128
+ id: import_zod32.z.string(),
4129
+ name: import_zod32.z.array(
4130
+ import_zod32.z.object({
4131
+ use: import_zod32.z.string(),
4132
+ given: import_zod32.z.array(import_zod32.z.string()),
4133
+ family: import_zod32.z.string()
3565
4134
  })
3566
4135
  ),
3567
- role: import_zod30.z.string(),
3568
- signatureFilename: import_zod30.z.string().optional()
4136
+ role: import_zod32.z.string(),
4137
+ signatureFilename: import_zod32.z.string().optional()
3569
4138
  });
3570
4139
 
3571
4140
  // ../commons/src/events/test.utils.ts
@@ -4250,7 +4819,7 @@ var PRINT_CERTIFICATE_FORM = defineActionForm({
4250
4819
  var TENNIS_CLUB_DECLARATION_REVIEW = {
4251
4820
  title: {
4252
4821
  id: "v2.event.tennis-club-membership.action.declare.form.review.title",
4253
- defaultMessage: "{applicant.firstname, select, __EMPTY__ {Member declaration} other {{applicant.surname, select, __EMPTY__ {Member declaration} other {Member declaration for {applicant.firstname} {applicant.surname}}}}}",
4822
+ defaultMessage: "{applicant.name.firstname, select, __EMPTY__ {Member declaration} other {{applicant.name.surname, select, __EMPTY__ {Member declaration} other {Member declaration for {applicant.name.firstname} {applicant.name.surname}}}}}",
4254
4823
  description: "Title of the review page"
4255
4824
  },
4256
4825
  fields: [
@@ -4295,27 +4864,17 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
4295
4864
  },
4296
4865
  fields: [
4297
4866
  {
4298
- id: "applicant.firstname",
4299
- type: FieldType.TEXT,
4867
+ id: "applicant.name",
4868
+ type: FieldType.NAME,
4300
4869
  required: true,
4870
+ hideLabel: true,
4301
4871
  conditionals: [],
4302
4872
  label: {
4303
- defaultMessage: "Applicant's first name",
4873
+ defaultMessage: "Applicant's name",
4304
4874
  description: "This is the label for the field",
4305
4875
  id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.firstname.label"
4306
4876
  }
4307
4877
  },
4308
- {
4309
- id: "applicant.surname",
4310
- type: FieldType.TEXT,
4311
- required: true,
4312
- conditionals: [],
4313
- label: {
4314
- defaultMessage: "Applicant's surname",
4315
- description: "This is the label for the field",
4316
- id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.surname.label"
4317
- }
4318
- },
4319
4878
  {
4320
4879
  id: "applicant.email",
4321
4880
  type: "EMAIL",
@@ -4449,8 +5008,9 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
4449
5008
  }
4450
5009
  },
4451
5010
  {
4452
- id: "recommender.firstname",
4453
- type: FieldType.TEXT,
5011
+ id: "recommender.name",
5012
+ type: FieldType.NAME,
5013
+ hideLabel: true,
4454
5014
  required: true,
4455
5015
  conditionals: [
4456
5016
  {
@@ -4459,27 +5019,11 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
4459
5019
  }
4460
5020
  ],
4461
5021
  label: {
4462
- defaultMessage: "Recommender's first name",
5022
+ defaultMessage: "Recommender's name",
4463
5023
  description: "This is the label for the field",
4464
5024
  id: "v2.event.tennis-club-membership.action.declare.form.section.recommender.field.firstname.label"
4465
5025
  }
4466
5026
  },
4467
- {
4468
- id: "recommender.surname",
4469
- type: FieldType.TEXT,
4470
- required: true,
4471
- conditionals: [
4472
- {
4473
- type: ConditionalType.SHOW,
4474
- conditional: field("recommender.none").isFalsy()
4475
- }
4476
- ],
4477
- label: {
4478
- defaultMessage: "Recommender's surname",
4479
- description: "This is the label for the field",
4480
- id: "v2.event.tennis-club-membership.action.declare.form.section.recommender.field.surname.label"
4481
- }
4482
- },
4483
5027
  {
4484
5028
  id: "recommender.id",
4485
5029
  type: FieldType.TEXT,
@@ -4510,7 +5054,7 @@ var statusOptions = [
4510
5054
  }
4511
5055
  },
4512
5056
  {
4513
- value: EventStatus.CREATED,
5057
+ value: EventStatus.enum.CREATED,
4514
5058
  label: {
4515
5059
  defaultMessage: "Draft",
4516
5060
  description: "Option for form field: status of record",
@@ -4518,7 +5062,7 @@ var statusOptions = [
4518
5062
  }
4519
5063
  },
4520
5064
  {
4521
- value: EventStatus.NOTIFIED,
5065
+ value: EventStatus.enum.NOTIFIED,
4522
5066
  label: {
4523
5067
  defaultMessage: "Notified",
4524
5068
  description: "Option for form field: status of record",
@@ -4526,7 +5070,7 @@ var statusOptions = [
4526
5070
  }
4527
5071
  },
4528
5072
  {
4529
- value: EventStatus.DECLARED,
5073
+ value: EventStatus.enum.DECLARED,
4530
5074
  label: {
4531
5075
  defaultMessage: "Declared",
4532
5076
  description: "Option for form field: status of record",
@@ -4534,7 +5078,7 @@ var statusOptions = [
4534
5078
  }
4535
5079
  },
4536
5080
  {
4537
- value: EventStatus.VALIDATED,
5081
+ value: EventStatus.enum.VALIDATED,
4538
5082
  label: {
4539
5083
  defaultMessage: "Validated",
4540
5084
  description: "Option for form field: status of record",
@@ -4542,7 +5086,7 @@ var statusOptions = [
4542
5086
  }
4543
5087
  },
4544
5088
  {
4545
- value: EventStatus.REGISTERED,
5089
+ value: EventStatus.enum.REGISTERED,
4546
5090
  label: {
4547
5091
  defaultMessage: "Registered",
4548
5092
  description: "Option for form field: status of record",
@@ -4550,7 +5094,7 @@ var statusOptions = [
4550
5094
  }
4551
5095
  },
4552
5096
  {
4553
- value: EventStatus.CERTIFIED,
5097
+ value: EventStatus.enum.CERTIFIED,
4554
5098
  label: {
4555
5099
  defaultMessage: "Certified",
4556
5100
  description: "Option for form field: status of record",
@@ -4558,7 +5102,7 @@ var statusOptions = [
4558
5102
  }
4559
5103
  },
4560
5104
  {
4561
- value: EventStatus.REJECTED,
5105
+ value: EventStatus.enum.REJECTED,
4562
5106
  label: {
4563
5107
  defaultMessage: "Rejected",
4564
5108
  description: "Option for form field: status of record",
@@ -4566,7 +5110,7 @@ var statusOptions = [
4566
5110
  }
4567
5111
  },
4568
5112
  {
4569
- value: EventStatus.ARCHIVED,
5113
+ value: EventStatus.enum.ARCHIVED,
4570
5114
  label: {
4571
5115
  defaultMessage: "Archived",
4572
5116
  description: "Option for form field: status of record",
@@ -4630,38 +5174,25 @@ var tennisClubMembershipEvent = defineConfig({
4630
5174
  id: "v2.event.tennis-club-membership.label"
4631
5175
  },
4632
5176
  title: {
4633
- defaultMessage: "{applicant.firstname} {applicant.surname}",
5177
+ defaultMessage: "{applicant.name.firstname} {applicant.name.surname}",
4634
5178
  description: "This is the title of the summary",
4635
5179
  id: "v2.event.tennis-club-membership.title"
4636
5180
  },
4637
5181
  summary: {
4638
5182
  fields: [
4639
5183
  {
4640
- id: "applicant.firstname",
5184
+ fieldId: "applicant.name",
4641
5185
  label: {
4642
- defaultMessage: "Applicant's first name",
5186
+ defaultMessage: "Applicant's name",
4643
5187
  description: "This is the label for the field",
4644
5188
  id: "event.tennis-club-membership.summary.field.firstname.label"
4645
5189
  },
4646
- value: {
4647
- defaultMessage: "{applicant.firstname}",
4648
- description: "This is the value to show in the summary",
4649
- id: "event.tennis-club-membership.summary.field.firstname"
4650
- },
4651
5190
  emptyValueMessage: {
4652
5191
  defaultMessage: "First name is not provided",
4653
5192
  description: "This is the message to show when the field is empty",
4654
5193
  id: "event.tennis-club-membership.summary.field.firstname.empty"
4655
5194
  }
4656
5195
  },
4657
- {
4658
- fieldId: "applicant.surname",
4659
- label: {
4660
- defaultMessage: "Applicant's last name",
4661
- description: "Label for surname",
4662
- id: "v2.event.tennis-club-membership.summary.field.surname.label"
4663
- }
4664
- },
4665
5196
  {
4666
5197
  fieldId: "applicant.email"
4667
5198
  }
@@ -4997,8 +5528,7 @@ var tennisClubMembershipEvent = defineConfig({
4997
5528
  id: "v2.event.tennis-club-membership.search.applicants"
4998
5529
  },
4999
5530
  fields: [
5000
- field("applicant.firstname").fuzzy(),
5001
- field("applicant.surname").fuzzy(),
5531
+ field("applicant.name").fuzzy(),
5002
5532
  field("applicant.dob").range(),
5003
5533
  field("applicant.email").exact()
5004
5534
  ]
@@ -5009,10 +5539,7 @@ var tennisClubMembershipEvent = defineConfig({
5009
5539
  description: "Recommender details search field section title",
5010
5540
  id: "v2.event.tennis-club-membership.search.recommender"
5011
5541
  },
5012
- fields: [
5013
- field("recommender.firstname").fuzzy(),
5014
- field("recommender.surname").fuzzy()
5015
- ]
5542
+ fields: [field("recommender.name").fuzzy()]
5016
5543
  }
5017
5544
  ],
5018
5545
  declaration: TENNIS_CLUB_DECLARATION_FORM
@@ -5027,21 +5554,21 @@ var footballClubMembershipEvent = defineConfig({
5027
5554
  id: "event.football-club-membership.label"
5028
5555
  },
5029
5556
  title: {
5030
- defaultMessage: "{applicant.firstname} {applicant.surname}",
5557
+ defaultMessage: "{applicant.name.firstname} {applicant.name.surname}",
5031
5558
  description: "This is the title of the summary",
5032
5559
  id: "v2.event.football-club-membership.title"
5033
5560
  },
5034
5561
  summary: {
5035
5562
  fields: [
5036
5563
  {
5037
- id: "applicant.firstname",
5564
+ id: "applicant.name.firstname",
5038
5565
  label: {
5039
5566
  defaultMessage: "Applicant's first name",
5040
5567
  description: "This is the label for the field",
5041
5568
  id: "event.football-club-membership.summary.field.firstname.label"
5042
5569
  },
5043
5570
  value: {
5044
- defaultMessage: "{applicant.firstname}",
5571
+ defaultMessage: "{applicant.name.firstname}",
5045
5572
  description: "This is the value to show in the summary",
5046
5573
  id: "event.football-club-membership.summary.field.firstname"
5047
5574
  },
@@ -5052,7 +5579,7 @@ var footballClubMembershipEvent = defineConfig({
5052
5579
  }
5053
5580
  },
5054
5581
  {
5055
- fieldId: "applicant.surname",
5582
+ fieldId: "applicant.name.surname",
5056
5583
  label: {
5057
5584
  defaultMessage: "Applicant's last name",
5058
5585
  description: "Label for surname",
@@ -5394,8 +5921,7 @@ var footballClubMembershipEvent = defineConfig({
5394
5921
  id: "v2.event.football-club-membership.search.applicants"
5395
5922
  },
5396
5923
  fields: [
5397
- field("applicant.firstname").fuzzy(),
5398
- field("applicant.surname").fuzzy(),
5924
+ field("applicant.name").fuzzy(),
5399
5925
  field("applicant.dob").range(),
5400
5926
  field("applicant.email").exact()
5401
5927
  ]
@@ -5406,10 +5932,7 @@ var footballClubMembershipEvent = defineConfig({
5406
5932
  description: "Recommender details search field section title",
5407
5933
  id: "v2.event.football-club-membership.search.recommender"
5408
5934
  },
5409
- fields: [
5410
- field("recommender.firstname").fuzzy(),
5411
- field("recommender.surname").fuzzy()
5412
- ]
5935
+ fields: [field("recommender.name").fuzzy()]
5413
5936
  }
5414
5937
  ],
5415
5938
  declaration: TENNIS_CLUB_DECLARATION_FORM
@@ -5474,242 +5997,499 @@ var libraryMembershipEvent = defineConfig({
5474
5997
  declaration: libraryMembershipForm
5475
5998
  });
5476
5999
 
5477
- // ../commons/src/events/test.utils.ts
5478
- function fieldConfigsToActionPayload(fields) {
5479
- return fields.reduce(
5480
- (acc, field2, i) => ({
5481
- ...acc,
5482
- [field2.id]: mapFieldTypeToMockValue(field2, i)
5483
- }),
5484
- {}
5485
- );
5486
- }
5487
- function generateActionDeclarationInput(configuration, action) {
5488
- const parsed = DeclarationUpdateActions.safeParse(action);
5489
- if (parsed.success) {
5490
- const fields = getDeclarationFields(configuration);
5491
- const declarationConfig = getDeclaration(configuration);
5492
- const declaration = fieldConfigsToActionPayload(fields);
5493
- return omitHiddenPaginatedFields(declarationConfig, declaration);
5494
- }
5495
- console.warn(`${action} is not a declaration action. Setting data as {}.`);
5496
- return {};
5497
- }
5498
- function generateActionAnnotationInput(configuration, action) {
5499
- const actionConfig = configuration.actions.find(
5500
- (ac) => ac.type === action
5501
- );
5502
- const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
5503
- const annotation = fieldConfigsToActionPayload(annotationFields);
5504
- const visibleVerificationPageIds = getVisibleVerificationPageIds(
5505
- findRecordActionPages(configuration, action),
5506
- annotation
5507
- );
5508
- const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
5509
- (acc, pageId) => ({
5510
- ...acc,
5511
- [pageId]: true
5512
- }),
5513
- {}
5514
- );
5515
- const fieldBasedPayload = omitHiddenFields(annotationFields, annotation);
5516
- return {
5517
- ...fieldBasedPayload,
5518
- ...visiblePageVerificationMap
5519
- };
5520
- }
5521
- var eventPayloadGenerator = {
5522
- create: (input = {}) => ({
5523
- transactionId: input.transactionId ?? getUUID(),
5524
- type: input.type ?? TENNIS_CLUB_MEMBERSHIP
5525
- }),
5526
- patch: (id, input = {}) => ({
5527
- transactionId: input.transactionId ?? getUUID(),
5528
- type: input.type ?? TENNIS_CLUB_MEMBERSHIP,
5529
- id
5530
- }),
5531
- draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
6000
+ // ../commons/src/fixtures/v2-birth-event.ts
6001
+ var child = defineFormPage({
6002
+ id: "child",
6003
+ type: PageTypes.enum.FORM,
6004
+ title: {
6005
+ defaultMessage: "Child's details",
6006
+ description: "Form section title for Child",
6007
+ id: "v2.form.birth.child.title"
6008
+ },
6009
+ fields: [
5532
6010
  {
5533
- id: getUUID(),
5534
- eventId,
5535
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
5536
- transactionId: getUUID(),
5537
- action: {
5538
- transactionId: getUUID(),
5539
- type: actionType,
5540
- status: ActionStatus.Accepted,
5541
- declaration: {
5542
- "applicant.firstname": "Max",
5543
- "applicant.surname": "McLaren",
5544
- "applicant.dob": "2020-01-02",
5545
- "recommender.none": true
5546
- },
5547
- annotation: {
5548
- "correction.requester.relationship": "ANOTHER_AGENT",
5549
- "correction.request.reason": "Child's name was incorrect"
5550
- },
5551
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
5552
- createdBy: "@todo",
5553
- createdByRole: "@todo",
5554
- createdAtLocation: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c"
6011
+ id: "child.firstNames",
6012
+ type: FieldType.TEXT,
6013
+ required: true,
6014
+ configuration: { maxLength: 32 },
6015
+ hideLabel: true,
6016
+ label: {
6017
+ defaultMessage: "Child's first name",
6018
+ description: "This is the label for the field",
6019
+ id: "v2.event.birth.action.declare.form.section.child.field.name.label"
5555
6020
  }
5556
6021
  },
5557
- input
5558
- ),
5559
- actions: {
5560
- declare: (eventId, input = {}) => ({
5561
- type: ActionType.DECLARE,
5562
- transactionId: input.transactionId ?? getUUID(),
5563
- declaration: input.declaration ?? generateActionDeclarationInput(
5564
- tennisClubMembershipEvent,
5565
- ActionType.DECLARE
5566
- ),
5567
- annotation: input.annotation ?? generateActionAnnotationInput(
5568
- tennisClubMembershipEvent,
5569
- ActionType.DECLARE
5570
- ),
5571
- eventId
5572
- }),
5573
- /**
5574
- * Notify allows sending incomplete data. Think it as 'partial declare' for now.
5575
- */
5576
- notify: (eventId, input = {}) => {
5577
- let declaration = input.declaration;
5578
- if (!declaration) {
5579
- const partialDeclaration = (0, import_lodash2.omitBy)(
5580
- generateActionDeclarationInput(
5581
- tennisClubMembershipEvent,
5582
- ActionType.DECLARE
5583
- ),
5584
- import_lodash2.isString
5585
- );
5586
- declaration = partialDeclaration;
6022
+ {
6023
+ id: "child.familyName",
6024
+ type: FieldType.TEXT,
6025
+ required: true,
6026
+ configuration: { maxLength: 32 },
6027
+ hideLabel: true,
6028
+ label: {
6029
+ defaultMessage: "Child's last name",
6030
+ description: "This is the label for the field",
6031
+ id: "v2.event.birth.action.declare.form.section.child.field.name.label"
5587
6032
  }
5588
- return {
5589
- type: ActionType.NOTIFY,
5590
- transactionId: input.transactionId ?? getUUID(),
5591
- declaration,
5592
- eventId
5593
- };
5594
6033
  },
5595
- validate: (eventId, input = {}) => ({
5596
- type: ActionType.VALIDATE,
5597
- transactionId: input.transactionId ?? getUUID(),
5598
- declaration: input.declaration ?? generateActionDeclarationInput(
5599
- tennisClubMembershipEvent,
5600
- ActionType.VALIDATE
5601
- ),
5602
- annotation: input.annotation ?? generateActionAnnotationInput(
5603
- tennisClubMembershipEvent,
5604
- ActionType.VALIDATE
5605
- ),
5606
- duplicates: [],
5607
- eventId
5608
- }),
5609
- assign: (eventId, input = {}) => ({
5610
- type: ActionType.ASSIGN,
5611
- transactionId: input.transactionId ?? getUUID(),
5612
- declaration: {},
5613
- assignedTo: input.assignedTo ?? getUUID(),
5614
- eventId
5615
- }),
5616
- unassign: (eventId, input = {}) => ({
5617
- type: ActionType.UNASSIGN,
5618
- transactionId: input.transactionId ?? getUUID(),
5619
- declaration: {},
5620
- assignedTo: null,
5621
- eventId
5622
- }),
5623
- archive: (eventId, input = {}, isDuplicate) => ({
5624
- type: ActionType.ARCHIVE,
5625
- transactionId: input.transactionId ?? getUUID(),
5626
- declaration: {},
5627
- // @TODO: Check whether generator is needed?
5628
- annotation: {},
5629
- duplicates: [],
5630
- eventId,
5631
- reason: {
5632
- message: `${ActionType.ARCHIVE}`,
5633
- isDuplicate: isDuplicate ?? false
6034
+ {
6035
+ id: "child.DoB",
6036
+ type: "DATE",
6037
+ required: true,
6038
+ label: {
6039
+ defaultMessage: "Date of birth",
6040
+ description: "This is the label for the field",
6041
+ id: "v2.event.birth.action.declare.form.section.child.field.dob.label"
5634
6042
  }
6043
+ }
6044
+ ]
6045
+ });
6046
+ var mother = defineFormPage({
6047
+ id: "mother",
6048
+ type: PageTypes.enum.FORM,
6049
+ title: {
6050
+ defaultMessage: "Mother's details",
6051
+ description: "Form section title for mothers details",
6052
+ id: "v2.form.section.mother.title"
6053
+ },
6054
+ fields: [
6055
+ {
6056
+ id: "mother.firstNames",
6057
+ configuration: { maxLength: 32 },
6058
+ type: FieldType.TEXT,
6059
+ required: true,
6060
+ label: {
6061
+ defaultMessage: "First name(s)",
6062
+ description: "This is the label for the field",
6063
+ id: `v2.event.birth.action.declare.form.section.person.field.firstname.label`
6064
+ }
6065
+ },
6066
+ {
6067
+ id: `mother.familyName`,
6068
+ configuration: { maxLength: 32 },
6069
+ type: FieldType.TEXT,
6070
+ required: true,
6071
+ label: {
6072
+ defaultMessage: "Last name",
6073
+ description: "This is the label for the field",
6074
+ id: `v2.event.birth.action.declare.form.section.person.field.surname.label`
6075
+ }
6076
+ },
6077
+ {
6078
+ id: `mother.DoB`,
6079
+ type: "DATE",
6080
+ required: true,
6081
+ label: {
6082
+ defaultMessage: "Date of birth",
6083
+ description: "This is the label for the field",
6084
+ id: `v2.event.birth.action.declare.form.section.person.field.dob.label`
6085
+ }
6086
+ },
6087
+ {
6088
+ id: "mother.identifier",
6089
+ type: FieldType.ID,
6090
+ required: true,
6091
+ label: {
6092
+ defaultMessage: "ID Number",
6093
+ description: "This is the label for the field",
6094
+ id: `v2.event.birth.action.declare.form.section.person.field.nid.label`
6095
+ }
6096
+ }
6097
+ ]
6098
+ });
6099
+ var BIRTH_DECLARATION_FORM = defineDeclarationForm({
6100
+ label: {
6101
+ defaultMessage: "Birth decalration form",
6102
+ id: "v2.event.birth.action.declare.form.label",
6103
+ description: "This is what this form is referred as in the system"
6104
+ },
6105
+ pages: [child, mother]
6106
+ });
6107
+ var v2BirthEvent = defineConfig({
6108
+ id: BIRTH_EVENT,
6109
+ title: {
6110
+ defaultMessage: "{child.name.firstname} {child.name.surname}",
6111
+ description: "This is the title of the summary",
6112
+ id: "v2.event.birth.title"
6113
+ },
6114
+ label: {
6115
+ defaultMessage: "Birth",
6116
+ description: "This is what this event is referred as in the system",
6117
+ id: "v2.event.birth.label"
6118
+ },
6119
+ summary: {
6120
+ fields: []
6121
+ },
6122
+ actions: [],
6123
+ declaration: BIRTH_DECLARATION_FORM
6124
+ });
6125
+
6126
+ // ../commons/src/events/test.utils.ts
6127
+ var import_zod33 = require("zod");
6128
+ var TestUserRole = import_zod33.z.enum([
6129
+ "FIELD_AGENT",
6130
+ "LOCAL_REGISTRAR",
6131
+ "LOCAL_SYSTEM_ADMIN",
6132
+ "NATIONAL_REGISTRAR",
6133
+ "REGISTRATION_AGENT"
6134
+ ]);
6135
+ function pickRandom(rng, items) {
6136
+ return items[Math.floor(rng() * items.length)];
6137
+ }
6138
+ function generateRandomName(rng) {
6139
+ const firstnames = [
6140
+ "Danny",
6141
+ "John",
6142
+ "Jane",
6143
+ "Emily",
6144
+ "Michael",
6145
+ "Sarah",
6146
+ "Chris",
6147
+ "Jessica",
6148
+ "Sara",
6149
+ "Sarachella",
6150
+ "Sarandera",
6151
+ "Zara"
6152
+ ];
6153
+ const surnames = [
6154
+ "Doe",
6155
+ "Smith",
6156
+ "Johnson",
6157
+ "Brown",
6158
+ "Williams",
6159
+ "Jones",
6160
+ "Garcia",
6161
+ "Miller",
6162
+ "Saranen",
6163
+ "Sarajanen",
6164
+ "Sarthua",
6165
+ "Tsarakovski",
6166
+ "Salamander",
6167
+ "Zarathustra"
6168
+ ];
6169
+ return {
6170
+ firstname: pickRandom(rng, firstnames),
6171
+ surname: pickRandom(rng, surnames)
6172
+ };
6173
+ }
6174
+ function mapFieldTypeToMockValue(field2, i, rng) {
6175
+ switch (field2.type) {
6176
+ case FieldType.DIVIDER:
6177
+ case FieldType.TEXT:
6178
+ case FieldType.TEXTAREA:
6179
+ case FieldType.BULLET_LIST:
6180
+ case FieldType.PAGE_HEADER:
6181
+ case FieldType.LOCATION:
6182
+ case FieldType.SELECT:
6183
+ case FieldType.COUNTRY:
6184
+ case FieldType.RADIO_GROUP:
6185
+ case FieldType.PARAGRAPH:
6186
+ case FieldType.ADMINISTRATIVE_AREA:
6187
+ case FieldType.FACILITY:
6188
+ case FieldType.PHONE:
6189
+ case FieldType.ID:
6190
+ case FieldType.OFFICE:
6191
+ return `${field2.id}-${field2.type}-${i}`;
6192
+ case FieldType.NAME:
6193
+ return generateRandomName(rng);
6194
+ case FieldType.NUMBER:
6195
+ return 19;
6196
+ case FieldType.EMAIL:
6197
+ return "test@opencrvs.org";
6198
+ case FieldType.ADDRESS:
6199
+ return {
6200
+ country: "FAR",
6201
+ addressType: AddressType.DOMESTIC,
6202
+ province: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
6203
+ district: "5ef450bc-712d-48ad-93f3-8da0fa453baa",
6204
+ urbanOrRural: "URBAN",
6205
+ town: "Example Town",
6206
+ residentialArea: "Example Residential Area",
6207
+ street: "Example Street",
6208
+ number: "55",
6209
+ zipCode: "123456"
6210
+ };
6211
+ case FieldType.DATE:
6212
+ return "2021-01-01";
6213
+ case FieldType.DATE_RANGE:
6214
+ return ["2021-01-01", "2021-01-02"];
6215
+ case FieldType.CHECKBOX:
6216
+ return true;
6217
+ case FieldType.SIGNATURE:
6218
+ case FieldType.FILE:
6219
+ return {
6220
+ filename: "4f095fc4-4312-4de2-aa38-86dcc0f71044.png",
6221
+ originalFilename: "abcd.png",
6222
+ type: "image/png"
6223
+ };
6224
+ case FieldType.FILE_WITH_OPTIONS:
6225
+ case FieldType.DATA:
6226
+ return void 0;
6227
+ }
6228
+ }
6229
+ function fieldConfigsToActionPayload(fields, rng) {
6230
+ return fields.reduce(
6231
+ (acc, field2, i) => ({
6232
+ ...acc,
6233
+ [field2.id]: mapFieldTypeToMockValue(field2, i, rng)
5635
6234
  }),
5636
- reject: (eventId, input = {}) => ({
5637
- type: ActionType.REJECT,
5638
- transactionId: input.transactionId ?? getUUID(),
5639
- declaration: {},
5640
- annotation: input.annotation ?? generateActionAnnotationInput(
5641
- tennisClubMembershipEvent,
5642
- ActionType.REJECT
5643
- ),
5644
- duplicates: [],
5645
- eventId,
5646
- reason: { message: `${ActionType.REJECT}` }
5647
- }),
5648
- register: (eventId, input = {}) => ({
5649
- type: ActionType.REGISTER,
5650
- transactionId: input.transactionId ?? getUUID(),
5651
- declaration: input.declaration ?? generateActionDeclarationInput(
5652
- tennisClubMembershipEvent,
5653
- ActionType.REGISTER
5654
- ),
5655
- annotation: input.annotation ?? generateActionAnnotationInput(
5656
- tennisClubMembershipEvent,
5657
- ActionType.REGISTER
5658
- ),
5659
- eventId
5660
- }),
5661
- printCertificate: (eventId, input = {}) => ({
5662
- type: ActionType.PRINT_CERTIFICATE,
5663
- transactionId: input.transactionId ?? getUUID(),
5664
- declaration: {},
5665
- annotation: input.annotation ?? generateActionAnnotationInput(
5666
- tennisClubMembershipEvent,
5667
- ActionType.PRINT_CERTIFICATE
5668
- ),
5669
- eventId
5670
- }),
5671
- correction: {
5672
- request: (eventId, input = {}) => ({
5673
- type: ActionType.REQUEST_CORRECTION,
6235
+ {}
6236
+ );
6237
+ }
6238
+ function generateActionDeclarationInput(configuration, action, rng) {
6239
+ const parsed = DeclarationUpdateActions.safeParse(action);
6240
+ if (parsed.success) {
6241
+ const fields = getDeclarationFields(configuration);
6242
+ const declarationConfig = getDeclaration(configuration);
6243
+ const declaration = fieldConfigsToActionPayload(fields, rng);
6244
+ return omitHiddenPaginatedFields(declarationConfig, declaration);
6245
+ }
6246
+ console.warn(`${action} is not a declaration action. Setting data as {}.`);
6247
+ return {};
6248
+ }
6249
+ function generateActionAnnotationInput(configuration, action, rng) {
6250
+ const actionConfig = configuration.actions.find(
6251
+ (ac) => ac.type === action
6252
+ );
6253
+ const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
6254
+ const annotation = fieldConfigsToActionPayload(annotationFields, rng);
6255
+ const visibleVerificationPageIds = getVisibleVerificationPageIds(
6256
+ findRecordActionPages(configuration, action),
6257
+ annotation
6258
+ );
6259
+ const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
6260
+ (acc, pageId) => ({
6261
+ ...acc,
6262
+ [pageId]: true
6263
+ }),
6264
+ {}
6265
+ );
6266
+ const fieldBasedPayload = omitHiddenFields(annotationFields, annotation);
6267
+ return {
6268
+ ...fieldBasedPayload,
6269
+ ...visiblePageVerificationMap
6270
+ };
6271
+ }
6272
+ function eventPayloadGenerator(rng) {
6273
+ return {
6274
+ create: (input = {}) => ({
6275
+ transactionId: input.transactionId ?? getUUID(),
6276
+ type: input.type ?? TENNIS_CLUB_MEMBERSHIP
6277
+ }),
6278
+ patch: (id, input = {}) => ({
6279
+ transactionId: input.transactionId ?? getUUID(),
6280
+ type: input.type ?? TENNIS_CLUB_MEMBERSHIP,
6281
+ id
6282
+ }),
6283
+ draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
6284
+ {
6285
+ id: getUUID(),
6286
+ eventId,
6287
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
6288
+ transactionId: getUUID(),
6289
+ action: {
6290
+ transactionId: getUUID(),
6291
+ type: actionType,
6292
+ status: ActionStatus.Accepted,
6293
+ declaration: {
6294
+ "applicant.name": {
6295
+ firstname: "Max",
6296
+ surname: "McLaren"
6297
+ },
6298
+ "applicant.dob": "2020-01-02",
6299
+ "recommender.none": true
6300
+ },
6301
+ annotation: {
6302
+ "correction.requester.relationship": "ANOTHER_AGENT",
6303
+ "correction.request.reason": "Child's name was incorrect"
6304
+ },
6305
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
6306
+ createdBy: "@todo",
6307
+ createdByUserType: TokenUserType.Enum.user,
6308
+ createdByRole: "@todo",
6309
+ createdAtLocation: "@todo"
6310
+ }
6311
+ },
6312
+ input
6313
+ ),
6314
+ actions: {
6315
+ declare: (eventId, input = {}) => ({
6316
+ type: ActionType.DECLARE,
6317
+ transactionId: input.transactionId ?? getUUID(),
6318
+ declaration: input.declaration ?? generateActionDeclarationInput(
6319
+ tennisClubMembershipEvent,
6320
+ ActionType.DECLARE,
6321
+ rng
6322
+ ),
6323
+ annotation: input.annotation ?? generateActionAnnotationInput(
6324
+ tennisClubMembershipEvent,
6325
+ ActionType.DECLARE,
6326
+ rng
6327
+ ),
6328
+ eventId,
6329
+ ...input
6330
+ }),
6331
+ /**
6332
+ * Notify allows sending incomplete data. Think it as 'partial declare' for now.
6333
+ */
6334
+ notify: (eventId, input = {}) => {
6335
+ let declaration = input.declaration;
6336
+ if (!declaration) {
6337
+ const partialDeclaration = (0, import_lodash2.omitBy)(
6338
+ generateActionDeclarationInput(
6339
+ tennisClubMembershipEvent,
6340
+ ActionType.DECLARE,
6341
+ rng
6342
+ ),
6343
+ import_lodash2.isString
6344
+ );
6345
+ declaration = partialDeclaration;
6346
+ }
6347
+ return {
6348
+ type: ActionType.NOTIFY,
6349
+ transactionId: input.transactionId ?? getUUID(),
6350
+ declaration,
6351
+ eventId,
6352
+ keepAssignment: input.keepAssignment
6353
+ };
6354
+ },
6355
+ validate: (eventId, input = {}) => ({
6356
+ type: ActionType.VALIDATE,
5674
6357
  transactionId: input.transactionId ?? getUUID(),
5675
6358
  declaration: input.declaration ?? generateActionDeclarationInput(
5676
6359
  tennisClubMembershipEvent,
5677
- ActionType.REQUEST_CORRECTION
6360
+ ActionType.VALIDATE,
6361
+ rng
5678
6362
  ),
5679
6363
  annotation: input.annotation ?? generateActionAnnotationInput(
5680
6364
  tennisClubMembershipEvent,
5681
- ActionType.REQUEST_CORRECTION
6365
+ ActionType.VALIDATE,
6366
+ rng
5682
6367
  ),
6368
+ duplicates: [],
6369
+ eventId,
6370
+ ...input
6371
+ }),
6372
+ assign: (eventId, input = {}) => ({
6373
+ type: ActionType.ASSIGN,
6374
+ transactionId: input.transactionId ?? getUUID(),
6375
+ declaration: {},
6376
+ assignedTo: input.assignedTo ?? getUUID(),
6377
+ eventId
6378
+ }),
6379
+ unassign: (eventId, input = {}) => ({
6380
+ type: ActionType.UNASSIGN,
6381
+ transactionId: input.transactionId ?? getUUID(),
6382
+ declaration: {},
6383
+ assignedTo: null,
5683
6384
  eventId
5684
6385
  }),
5685
- approve: (eventId, requestId, input = {}) => ({
5686
- type: ActionType.APPROVE_CORRECTION,
6386
+ archive: (eventId, input = {}, isDuplicate) => ({
6387
+ type: ActionType.ARCHIVE,
6388
+ transactionId: input.transactionId ?? getUUID(),
6389
+ declaration: {},
6390
+ // @TODO: Check whether generator is needed?
6391
+ annotation: {},
6392
+ duplicates: [],
6393
+ eventId,
6394
+ reason: {
6395
+ message: `${ActionType.ARCHIVE}`,
6396
+ isDuplicate: isDuplicate ?? false
6397
+ },
6398
+ ...input
6399
+ }),
6400
+ reject: (eventId, input = {}) => ({
6401
+ type: ActionType.REJECT,
5687
6402
  transactionId: input.transactionId ?? getUUID(),
5688
6403
  declaration: {},
5689
6404
  annotation: input.annotation ?? generateActionAnnotationInput(
5690
6405
  tennisClubMembershipEvent,
5691
- ActionType.APPROVE_CORRECTION
6406
+ ActionType.REJECT,
6407
+ rng
5692
6408
  ),
6409
+ duplicates: [],
5693
6410
  eventId,
5694
- requestId
6411
+ reason: { message: `${ActionType.REJECT}` },
6412
+ ...input
5695
6413
  }),
5696
- reject: (eventId, requestId, input = {}) => ({
5697
- type: ActionType.REJECT_CORRECTION,
6414
+ register: (eventId, input = {}) => ({
6415
+ type: ActionType.REGISTER,
6416
+ transactionId: input.transactionId ?? getUUID(),
6417
+ declaration: input.declaration ?? generateActionDeclarationInput(
6418
+ tennisClubMembershipEvent,
6419
+ ActionType.REGISTER,
6420
+ rng
6421
+ ),
6422
+ annotation: input.annotation ?? generateActionAnnotationInput(
6423
+ tennisClubMembershipEvent,
6424
+ ActionType.REGISTER,
6425
+ rng
6426
+ ),
6427
+ eventId,
6428
+ ...input
6429
+ }),
6430
+ printCertificate: (eventId, input = {}) => ({
6431
+ type: ActionType.PRINT_CERTIFICATE,
5698
6432
  transactionId: input.transactionId ?? getUUID(),
5699
6433
  declaration: {},
5700
6434
  annotation: input.annotation ?? generateActionAnnotationInput(
5701
6435
  tennisClubMembershipEvent,
5702
- ActionType.REJECT_CORRECTION
6436
+ ActionType.PRINT_CERTIFICATE,
6437
+ rng
5703
6438
  ),
5704
6439
  eventId,
5705
- requestId
5706
- })
6440
+ ...input
6441
+ }),
6442
+ correction: {
6443
+ request: (eventId, input = {}) => ({
6444
+ type: ActionType.REQUEST_CORRECTION,
6445
+ transactionId: input.transactionId ?? getUUID(),
6446
+ declaration: input.declaration ?? generateActionDeclarationInput(
6447
+ tennisClubMembershipEvent,
6448
+ ActionType.REQUEST_CORRECTION,
6449
+ rng
6450
+ ),
6451
+ annotation: input.annotation ?? generateActionAnnotationInput(
6452
+ tennisClubMembershipEvent,
6453
+ ActionType.REQUEST_CORRECTION,
6454
+ rng
6455
+ ),
6456
+ eventId,
6457
+ keepAssignment: input.keepAssignment
6458
+ }),
6459
+ approve: (eventId, requestId, input = {}) => ({
6460
+ type: ActionType.APPROVE_CORRECTION,
6461
+ transactionId: input.transactionId ?? getUUID(),
6462
+ declaration: {},
6463
+ annotation: input.annotation ?? generateActionAnnotationInput(
6464
+ tennisClubMembershipEvent,
6465
+ ActionType.APPROVE_CORRECTION,
6466
+ rng
6467
+ ),
6468
+ eventId,
6469
+ requestId,
6470
+ keepAssignment: input.keepAssignment
6471
+ }),
6472
+ reject: (eventId, requestId, input = {}) => ({
6473
+ type: ActionType.REJECT_CORRECTION,
6474
+ transactionId: input.transactionId ?? getUUID(),
6475
+ declaration: {},
6476
+ annotation: input.annotation ?? generateActionAnnotationInput(
6477
+ tennisClubMembershipEvent,
6478
+ ActionType.REJECT_CORRECTION,
6479
+ rng
6480
+ ),
6481
+ eventId,
6482
+ requestId,
6483
+ keepAssignment: input.keepAssignment
6484
+ })
6485
+ }
5707
6486
  }
5708
- }
5709
- };
6487
+ };
6488
+ }
5710
6489
  function generateActionDocument({
5711
6490
  configuration,
5712
6491
  action,
6492
+ rng = () => 0.1,
5713
6493
  defaults = {}
5714
6494
  }) {
5715
6495
  const actionBase = {
@@ -5717,10 +6497,11 @@ function generateActionDocument({
5717
6497
  // @TODO: This should be fixed in the future.
5718
6498
  createdAt: new Date(Date.now() - 500).toISOString(),
5719
6499
  createdBy: getUUID(),
5720
- createdByRole: "FIELD_AGENT",
6500
+ createdByUserType: TokenUserType.Enum.user,
6501
+ createdByRole: TestUserRole.Enum.FIELD_AGENT,
5721
6502
  id: getUUID(),
5722
6503
  createdAtLocation: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
5723
- declaration: generateActionDeclarationInput(configuration, action),
6504
+ declaration: generateActionDeclarationInput(configuration, action, rng),
5724
6505
  annotation: {},
5725
6506
  status: ActionStatus.Accepted,
5726
6507
  transactionId: getUUID(),
@@ -5772,13 +6553,14 @@ function generateActionDocument({
5772
6553
  }
5773
6554
  function generateEventDocument({
5774
6555
  configuration,
5775
- actions
6556
+ actions,
6557
+ rng = () => 0.1
5776
6558
  }) {
5777
6559
  return {
5778
6560
  trackingId: getUUID(),
5779
6561
  type: configuration.id,
5780
6562
  actions: actions.map(
5781
- (action) => generateActionDocument({ configuration, action })
6563
+ (action) => generateActionDocument({ configuration, action, rng })
5782
6564
  ),
5783
6565
  // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
5784
6566
  // @TODO: This should be fixed in the future.
@@ -5789,10 +6571,16 @@ function generateEventDocument({
5789
6571
  updatedAt: new Date(Date.now() - 1e3).toISOString()
5790
6572
  };
5791
6573
  }
5792
- function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
6574
+ function generateEventDraftDocument({
6575
+ eventId,
6576
+ actionType,
6577
+ rng = () => 0.1,
6578
+ declaration = {}
6579
+ }) {
5793
6580
  const action = generateActionDocument({
5794
6581
  configuration: tennisClubMembershipEvent,
5795
- action: actionType
6582
+ action: actionType,
6583
+ rng
5796
6584
  });
5797
6585
  return {
5798
6586
  id: getUUID(),
@@ -5808,51 +6596,29 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, de
5808
6596
  eventId
5809
6597
  };
5810
6598
  }
5811
- function pickRandom(rng, items) {
5812
- return items[Math.floor(rng() * items.length)];
5813
- }
5814
6599
  function getRandomDatetime(rng, start, end) {
5815
6600
  const range = end.getTime() - start.getTime();
5816
6601
  const offset = Math.floor(rng() * range);
5817
6602
  const randomDate = new Date(start.getTime() + offset);
5818
6603
  return randomDate.toISOString();
5819
6604
  }
6605
+ function getRandomDate(rng, start, end) {
6606
+ const datetime = getRandomDatetime(rng, new Date(start), new Date(end));
6607
+ return datetime.split("T")[0];
6608
+ }
5820
6609
  function generateRandomApplicant(rng) {
5821
- const firstNames = [
5822
- "Danny",
5823
- "John",
5824
- "Jane",
5825
- "Emily",
5826
- "Michael",
5827
- "Sarah",
5828
- "Chris",
5829
- "Jessica"
5830
- ];
5831
- const surnames = [
5832
- "Doe",
5833
- "Smith",
5834
- "Johnson",
5835
- "Brown",
5836
- "Williams",
5837
- "Jones",
5838
- "Garcia",
5839
- "Miller"
5840
- ];
5841
- const randomFirstName = pickRandom(rng, firstNames);
5842
- const randomSurname = pickRandom(rng, surnames);
5843
- const randomDob = getRandomDatetime(
5844
- rng,
5845
- /* @__PURE__ */ new Date("1990-01-01"),
5846
- /* @__PURE__ */ new Date("2010-12-31")
5847
- ).split("T")[0];
6610
+ const { firstname, surname } = generateRandomName(rng);
6611
+ const randomDob = getRandomDate(rng, "1990-01-01", "2010-12-31");
5848
6612
  return {
5849
6613
  "recommender.none": true,
5850
- "applicant.firstname": randomFirstName,
5851
- "applicant.surname": randomSurname,
6614
+ "applicant.name": {
6615
+ firstname,
6616
+ surname
6617
+ },
5852
6618
  "applicant.dob": randomDob
5853
6619
  };
5854
6620
  }
5855
- function createPseudoRandomNumberGenerator(seed) {
6621
+ function createPrng(seed) {
5856
6622
  const MODULUS = 2 ** 32;
5857
6623
  const MULTIPLIER = 1664525;
5858
6624
  const INCREMENT = 1013904223;
@@ -5878,7 +6644,7 @@ function generateRandomSignature(rng) {
5878
6644
  return `/random-bucket/${generateUuid(rng)}.png`;
5879
6645
  }
5880
6646
  var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
5881
- const rng = createPseudoRandomNumberGenerator(seed);
6647
+ const rng = createPrng(seed);
5882
6648
  const createdAt = getRandomDatetime(
5883
6649
  rng,
5884
6650
  /* @__PURE__ */ new Date("2024-01-01"),
@@ -5887,8 +6653,9 @@ var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
5887
6653
  return {
5888
6654
  id: overrides.id ?? generateUuid(rng),
5889
6655
  type: overrides.type ?? TENNIS_CLUB_MEMBERSHIP,
5890
- status: overrides.status ?? pickRandom(rng, eventStatuses),
6656
+ status: overrides.status ?? pickRandom(rng, EventStatus.options),
5891
6657
  createdAt: overrides.createdAt ?? createdAt,
6658
+ createdByUserType: overrides.createdByUserType ?? "user",
5892
6659
  createdBy: overrides.createdBy ?? generateUuid(rng),
5893
6660
  createdAtLocation: overrides.createdAtLocation ?? generateUuid(rng),
5894
6661
  updatedAtLocation: overrides.updatedAtLocation ?? generateUuid(rng),
@@ -5926,8 +6693,7 @@ var generateWorkqueues = (slug = "all-events") => defineWorkqueues([
5926
6693
  clauses: [{ eventType: tennisClubMembershipEvent.id }]
5927
6694
  },
5928
6695
  actions: [],
5929
- icon: "Draft",
5930
- columns: []
6696
+ icon: "Draft"
5931
6697
  }
5932
6698
  ]);
5933
6699
 
@@ -5942,7 +6708,9 @@ function isFieldValueWithoutTemplates(value) {
5942
6708
  if (isTemplateVariable(value)) {
5943
6709
  return false;
5944
6710
  }
5945
- if (typeof value === "object" && Object.values(value).some((val) => isTemplateVariable(val))) {
6711
+ if (typeof value === "object" && // @todo remove ts-ignore
6712
+ //@ts-ignore
6713
+ Object.values(value).some((val) => isTemplateVariable(val))) {
5946
6714
  return false;
5947
6715
  }
5948
6716
  return true;
@@ -5965,234 +6733,6 @@ function isFieldConfigDefaultValue(value) {
5965
6733
 
5966
6734
  // ../commons/src/events/scopes.ts
5967
6735
  var import_lodash3 = require("lodash");
5968
-
5969
- // ../commons/src/scopes.ts
5970
- var import_zod31 = require("zod");
5971
- var SCOPES = {
5972
- // TODO v1.8 legacy scopes
5973
- NATLSYSADMIN: "natlsysadmin",
5974
- BYPASSRATELIMIT: "bypassratelimit",
5975
- DECLARE: "declare",
5976
- REGISTER: "register",
5977
- VALIDATE: "validate",
5978
- DEMO: "demo",
5979
- CERTIFY: "certify",
5980
- PERFORMANCE: "performance",
5981
- SYSADMIN: "sysadmin",
5982
- TEAMS: "teams",
5983
- CONFIG: "config",
5984
- // systems / integrations
5985
- WEBHOOK: "webhook",
5986
- NATIONALID: "nationalId",
5987
- NOTIFICATION_API: "notification-api",
5988
- RECORDSEARCH: "recordsearch",
5989
- /**
5990
- * @TODO This is a temporary scope to be used for V2 Events custom events declaration
5991
- */
5992
- RECORD_DECLARE: "record.declare-birth",
5993
- // declare
5994
- RECORD_IMPORT: "record.import",
5995
- // declare
5996
- RECORD_DECLARE_BIRTH: "record.declare-birth",
5997
- RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
5998
- RECORD_DECLARE_DEATH: "record.declare-death",
5999
- RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction",
6000
- RECORD_DECLARE_MARRIAGE: "record.declare-marriage",
6001
- RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction",
6002
- RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete",
6003
- RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review",
6004
- RECORD_UNASSIGN_OTHERS: "record.unassign-others",
6005
- // validate
6006
- RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval",
6007
- RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates",
6008
- RECORD_DECLARATION_EDIT: "record.declaration-edit",
6009
- RECORD_REVIEW_DUPLICATES: "record.review-duplicates",
6010
- RECORD_DECLARATION_ARCHIVE: "record.declaration-archive",
6011
- RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate",
6012
- // register
6013
- RECORD_REGISTER: "record.register",
6014
- // certify
6015
- RECORD_EXPORT_RECORDS: "record.export-records",
6016
- RECORD_DECLARATION_PRINT: "record.declaration-print",
6017
- RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS: "record.declaration-print-supporting-documents",
6018
- RECORD_REGISTRATION_PRINT: "record.registration-print",
6019
- // v1.8
6020
- /**
6021
- * This scope is used to **print and **issue certified copies of a record
6022
- * after it has been registered. Previously Registrars had this permission.
6023
- */
6024
- RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies",
6025
- RECORD_PRINT_CERTIFIED_COPIES: "record.registration-print-certified-copies",
6026
- // v1.8
6027
- RECORD_BULK_PRINT_CERTIFIED_COPIES: "record.registration-bulk-print-certified-copies",
6028
- // v1.8
6029
- RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES: "record.registration-verify-certified-copies",
6030
- // v1.8
6031
- // correct
6032
- RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction",
6033
- RECORD_REGISTRATION_CORRECT: "record.registration-correct",
6034
- RECORD_REGISTRATION_REQUEST_REVOCATION: "record.registration-request-revocation",
6035
- // v1.8
6036
- RECORD_REGISTRATION_REVOKE: "record.registration-revoke",
6037
- // v1.8
6038
- RECORD_REGISTRATION_REQUEST_REINSTATEMENT: "record.registration-request-reinstatement",
6039
- // v1.8
6040
- RECORD_REGISTRATION_REINSTATE: "record.registration-reinstate",
6041
- // v1.8
6042
- RECORD_CONFIRM_REGISTRATION: "record.confirm-registration",
6043
- RECORD_REJECT_REGISTRATION: "record.reject-registration",
6044
- // search
6045
- SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction",
6046
- SEARCH_BIRTH: "search.birth",
6047
- SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction",
6048
- SEARCH_DEATH: "search.death",
6049
- SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction",
6050
- SEARCH_MARRIAGE: "search.marriage",
6051
- // audit v1.8
6052
- RECORD_READ: "record.read",
6053
- RECORD_READ_AUDIT: "record.read-audit",
6054
- RECORD_READ_COMMENTS: "record.read-comments",
6055
- RECORD_CREATE_COMMENTS: "record.create-comments",
6056
- // profile
6057
- PROFILE_UPDATE: "profile.update",
6058
- //v1.8
6059
- PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
6060
- // performance
6061
- PERFORMANCE_READ: "performance.read",
6062
- PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
6063
- PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
6064
- // organisation
6065
- ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all",
6066
- ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
6067
- ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
6068
- // user
6069
- USER_READ: "user.read:all",
6070
- USER_READ_MY_OFFICE: "user.read:my-office",
6071
- USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
6072
- USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
6073
- //v1.8
6074
- USER_CREATE: "user.create:all",
6075
- USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
6076
- USER_UPDATE: "user.update:all",
6077
- USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction",
6078
- // config
6079
- CONFIG_UPDATE_ALL: "config.update:all",
6080
- // data seeding
6081
- USER_DATA_SEEDING: "user.data-seeding"
6082
- };
6083
- var LiteralScopes = import_zod31.z.union([
6084
- import_zod31.z.literal(SCOPES.NATLSYSADMIN),
6085
- import_zod31.z.literal(SCOPES.BYPASSRATELIMIT),
6086
- import_zod31.z.literal(SCOPES.DECLARE),
6087
- import_zod31.z.literal(SCOPES.REGISTER),
6088
- import_zod31.z.literal(SCOPES.VALIDATE),
6089
- import_zod31.z.literal(SCOPES.DEMO),
6090
- import_zod31.z.literal(SCOPES.CERTIFY),
6091
- import_zod31.z.literal(SCOPES.PERFORMANCE),
6092
- import_zod31.z.literal(SCOPES.SYSADMIN),
6093
- import_zod31.z.literal(SCOPES.TEAMS),
6094
- import_zod31.z.literal(SCOPES.CONFIG),
6095
- import_zod31.z.literal(SCOPES.WEBHOOK),
6096
- import_zod31.z.literal(SCOPES.NATIONALID),
6097
- import_zod31.z.literal(SCOPES.NOTIFICATION_API),
6098
- import_zod31.z.literal(SCOPES.RECORDSEARCH),
6099
- import_zod31.z.literal(SCOPES.RECORD_IMPORT),
6100
- import_zod31.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
6101
- import_zod31.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
6102
- import_zod31.z.literal(SCOPES.RECORD_DECLARE_DEATH),
6103
- import_zod31.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
6104
- import_zod31.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
6105
- import_zod31.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
6106
- import_zod31.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
6107
- import_zod31.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW),
6108
- import_zod31.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS),
6109
- import_zod31.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
6110
- import_zod31.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
6111
- import_zod31.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
6112
- import_zod31.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
6113
- import_zod31.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
6114
- import_zod31.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE),
6115
- import_zod31.z.literal(SCOPES.RECORD_REGISTER),
6116
- import_zod31.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
6117
- import_zod31.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
6118
- import_zod31.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
6119
- import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
6120
- import_zod31.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
6121
- import_zod31.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
6122
- import_zod31.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
6123
- import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES),
6124
- import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
6125
- import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
6126
- import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
6127
- import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
6128
- import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
6129
- import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
6130
- import_zod31.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
6131
- import_zod31.z.literal(SCOPES.RECORD_REJECT_REGISTRATION),
6132
- import_zod31.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
6133
- import_zod31.z.literal(SCOPES.SEARCH_BIRTH),
6134
- import_zod31.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
6135
- import_zod31.z.literal(SCOPES.SEARCH_DEATH),
6136
- import_zod31.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
6137
- import_zod31.z.literal(SCOPES.SEARCH_MARRIAGE),
6138
- import_zod31.z.literal(SCOPES.RECORD_READ),
6139
- import_zod31.z.literal(SCOPES.RECORD_READ_AUDIT),
6140
- import_zod31.z.literal(SCOPES.RECORD_READ_COMMENTS),
6141
- import_zod31.z.literal(SCOPES.RECORD_CREATE_COMMENTS),
6142
- import_zod31.z.literal(SCOPES.PROFILE_UPDATE),
6143
- import_zod31.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE),
6144
- import_zod31.z.literal(SCOPES.PERFORMANCE_READ),
6145
- import_zod31.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
6146
- import_zod31.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS),
6147
- import_zod31.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
6148
- import_zod31.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
6149
- import_zod31.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION),
6150
- import_zod31.z.literal(SCOPES.USER_READ),
6151
- import_zod31.z.literal(SCOPES.USER_READ_MY_OFFICE),
6152
- import_zod31.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
6153
- import_zod31.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
6154
- import_zod31.z.literal(SCOPES.USER_CREATE),
6155
- import_zod31.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
6156
- import_zod31.z.literal(SCOPES.USER_UPDATE),
6157
- import_zod31.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION),
6158
- import_zod31.z.literal(SCOPES.CONFIG_UPDATE_ALL),
6159
- import_zod31.z.literal(SCOPES.USER_DATA_SEEDING)
6160
- ]);
6161
- var rawConfigurableScopeRegex = /^([a-zA-Z\.]+)\[((?:\w+=[\w.-]+(?:\|[\w.-]+)*)(?:,[\w]+=[\w.-]+(?:\|[\w.-]+)*)*)\]$/;
6162
- var rawConfigurableScope = import_zod31.z.string().regex(rawConfigurableScopeRegex);
6163
- var CreateUserScope = import_zod31.z.object({
6164
- type: import_zod31.z.literal("user.create"),
6165
- options: import_zod31.z.object({
6166
- role: import_zod31.z.array(import_zod31.z.string())
6167
- })
6168
- });
6169
- var EditUserScope = import_zod31.z.object({
6170
- type: import_zod31.z.literal("user.edit"),
6171
- options: import_zod31.z.object({
6172
- role: import_zod31.z.array(import_zod31.z.string())
6173
- })
6174
- });
6175
- var WorkqueueScope = import_zod31.z.object({
6176
- type: import_zod31.z.literal("workqueue"),
6177
- options: import_zod31.z.object({
6178
- id: import_zod31.z.array(import_zod31.z.string())
6179
- })
6180
- });
6181
- var NotifyRecordScope = import_zod31.z.object({
6182
- type: import_zod31.z.literal("record.notify"),
6183
- options: import_zod31.z.object({
6184
- event: import_zod31.z.array(import_zod31.z.string())
6185
- })
6186
- });
6187
- var ConfigurableScopes = import_zod31.z.discriminatedUnion("type", [
6188
- CreateUserScope,
6189
- EditUserScope,
6190
- WorkqueueScope,
6191
- NotifyRecordScope
6192
- ]);
6193
- var scopes = Object.values(SCOPES);
6194
-
6195
- // ../commons/src/events/scopes.ts
6196
6736
  var CONFIG_GET_ALLOWED_SCOPES = [
6197
6737
  SCOPES.RECORD_DECLARE,
6198
6738
  SCOPES.RECORD_READ,
@@ -6269,30 +6809,20 @@ var ACTION_ALLOWED_CONFIGURABLE_SCOPES = {
6269
6809
  [ActionType.UNASSIGN]: [],
6270
6810
  [ActionType.DETECT_DUPLICATE]: []
6271
6811
  };
6812
+ var WRITE_ACTION_SCOPES = [
6813
+ ...ACTION_ALLOWED_SCOPES[ActionType.DECLARE],
6814
+ ...ACTION_ALLOWED_SCOPES[ActionType.VALIDATE],
6815
+ ...ACTION_ALLOWED_SCOPES[ActionType.REGISTER],
6816
+ ...ACTION_ALLOWED_SCOPES[ActionType.PRINT_CERTIFICATE]
6817
+ ];
6272
6818
  function hasAnyOfScopes(a, b) {
6273
6819
  return (0, import_lodash3.intersection)(a, b).length > 0;
6274
6820
  }
6275
- function filterUnallowedActions(actions, userScopes) {
6276
- const allowedActions = actions.filter((action) => {
6277
- const requiredScopes = ACTION_ALLOWED_SCOPES[action];
6278
- if (requiredScopes === null) {
6279
- return true;
6280
- }
6281
- return hasAnyOfScopes(userScopes, requiredScopes);
6282
- });
6283
- const hasOtherAllowedActions = allowedActions.some(
6284
- (action) => action !== ActionType.READ && action !== ActionType.ASSIGN && action !== ActionType.UNASSIGN
6285
- );
6286
- if (hasOtherAllowedActions) {
6287
- return allowedActions;
6288
- }
6289
- return [ActionType.READ];
6290
- }
6291
6821
 
6292
6822
  // ../commons/src/events/serializers/user/deserializer.ts
6293
- var import_zod32 = require("zod");
6823
+ var import_zod34 = require("zod");
6294
6824
  var UserWithPrimaryOffice = User.extend({
6295
- primaryOfficeId: import_zod32.z.string()
6825
+ primaryOfficeId: import_zod34.z.string()
6296
6826
  });
6297
6827
  function userDeserializer(serializedUserField, user2) {
6298
6828
  if (typeof serializedUserField === "string") {
@@ -6312,6 +6842,7 @@ function deserializeQueryExpression(expression, user2) {
6312
6842
  ...expression.assignedTo,
6313
6843
  term: userDeserializer(expression.assignedTo.term, user2)
6314
6844
  },
6845
+ createdByUserType: expression.createdByUserType,
6315
6846
  createdBy: expression.createdBy && {
6316
6847
  ...expression.createdBy,
6317
6848
  term: userDeserializer(expression.createdBy.term, user2)
@@ -6347,6 +6878,56 @@ function deserializeQuery(query, user2) {
6347
6878
  ...query,
6348
6879
  clauses: query.clauses.map(
6349
6880
  (clause) => deserializeQueryExpression(clause, user2)
6881
+ // SAFETY: This cast should be safe because `query.clauses` has already been validated as non-empty by the Zod schema.
6882
+ // Without the cast, TypeScript cannot infer the tuple type required by the target interface.
6350
6883
  )
6351
6884
  };
6352
6885
  }
6886
+
6887
+ // ../commons/src/events/state/availableActions.ts
6888
+ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
6889
+ [EventStatus.enum.CREATED]: [
6890
+ ActionType.READ,
6891
+ ActionType.DECLARE,
6892
+ ActionType.NOTIFY,
6893
+ ActionType.DELETE
6894
+ ],
6895
+ [EventStatus.enum.NOTIFIED]: [
6896
+ ActionType.READ,
6897
+ ActionType.DECLARE,
6898
+ ActionType.ARCHIVE,
6899
+ ActionType.REJECT
6900
+ ],
6901
+ [EventStatus.enum.DECLARED]: [
6902
+ ActionType.READ,
6903
+ ActionType.VALIDATE,
6904
+ ActionType.ARCHIVE,
6905
+ ActionType.REJECT
6906
+ ],
6907
+ [EventStatus.enum.VALIDATED]: [
6908
+ ActionType.READ,
6909
+ ActionType.REGISTER,
6910
+ ActionType.ARCHIVE,
6911
+ ActionType.REJECT
6912
+ ],
6913
+ [EventStatus.enum.REJECTED]: [
6914
+ ActionType.READ,
6915
+ ActionType.DECLARE,
6916
+ ActionType.VALIDATE
6917
+ ],
6918
+ [EventStatus.enum.REGISTERED]: [
6919
+ ActionType.READ,
6920
+ ActionType.PRINT_CERTIFICATE,
6921
+ ActionType.REQUEST_CORRECTION
6922
+ ],
6923
+ [EventStatus.enum.CERTIFIED]: [
6924
+ ActionType.READ,
6925
+ ActionType.PRINT_CERTIFICATE,
6926
+ ActionType.REQUEST_CORRECTION
6927
+ ],
6928
+ [EventStatus.enum.ARCHIVED]: [
6929
+ ActionType.READ,
6930
+ ActionType.ASSIGN,
6931
+ ActionType.UNASSIGN
6932
+ ]
6933
+ };