@opencrvs/toolkit 1.8.0-rc.f7a451a → 1.8.0-rc.f7aaf07

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 +14932 -5124
  2. package/dist/commons/conditionals/conditionals.d.ts +6 -2
  3. package/dist/commons/conditionals/validate.d.ts +6 -0
  4. package/dist/commons/events/ActionConfig.d.ts +32976 -12647
  5. package/dist/commons/events/ActionDocument.d.ts +2005 -309
  6. package/dist/commons/events/ActionInput.d.ts +1455 -183
  7. package/dist/commons/events/ActionType.d.ts +6 -0
  8. package/dist/commons/events/AdvancedSearchConfig.d.ts +279 -3
  9. package/dist/commons/events/CompositeFieldValue.d.ts +28 -0
  10. package/dist/commons/events/Constants.d.ts +3 -0
  11. package/dist/commons/events/CountryConfigQueryInput.d.ts +314 -254
  12. package/dist/commons/events/CreatedAtLocation.d.ts +3 -0
  13. package/dist/commons/events/Draft.d.ts +127 -21
  14. package/dist/commons/events/EventConfig.d.ts +22415 -12245
  15. package/dist/commons/events/EventDocument.d.ts +1308 -232
  16. package/dist/commons/events/EventIndex.d.ts +616 -423
  17. package/dist/commons/events/EventMetadata.d.ts +104 -81
  18. package/dist/commons/events/FieldConfig.d.ts +2082 -1191
  19. package/dist/commons/events/FieldType.d.ts +4 -1
  20. package/dist/commons/events/FieldTypeMapping.d.ts +94 -52
  21. package/dist/commons/events/FieldValue.d.ts +43 -5
  22. package/dist/commons/events/FormConfig.d.ts +10259 -4769
  23. package/dist/commons/events/PageConfig.d.ts +3480 -2134
  24. package/dist/commons/events/SummaryConfig.d.ts +0 -5
  25. package/dist/commons/events/WorkqueueColumnConfig.d.ts +17 -6
  26. package/dist/commons/events/WorkqueueConfig.d.ts +2589 -1640
  27. package/dist/commons/events/defineConfig.d.ts +2439 -679
  28. package/dist/commons/events/event.d.ts +2 -2
  29. package/dist/commons/events/field.d.ts +10 -10
  30. package/dist/commons/events/index.d.ts +2 -0
  31. package/dist/commons/events/scopes.d.ts +1 -2
  32. package/dist/commons/events/test.utils.d.ts +158 -40
  33. package/dist/commons/events/utils.d.ts +10021 -326
  34. package/dist/conditionals/index.js +26 -6
  35. package/dist/events/index.js +2401 -1217
  36. package/dist/scopes/index.d.ts +6 -2
  37. package/dist/scopes/index.js +70 -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,
@@ -50,11 +51,15 @@ __export(events_exports, {
50
51
  AddressType: () => AddressType,
51
52
  AdministrativeAreas: () => AdministrativeAreas,
52
53
  AdvancedSearchConfig: () => AdvancedSearchConfig,
54
+ AnyOf: () => AnyOf,
55
+ AnyOfStatus: () => AnyOfStatus,
53
56
  ApproveCorrectionActionInput: () => ApproveCorrectionActionInput,
54
57
  ArchiveActionInput: () => ArchiveActionInput,
55
58
  AssignActionInput: () => AssignActionInput,
56
59
  AsyncRejectActionDocument: () => AsyncRejectActionDocument,
60
+ BIRTH_EVENT: () => BIRTH_EVENT,
57
61
  BaseActionInput: () => BaseActionInput,
62
+ BearerTokenByUserType: () => BearerTokenByUserType,
58
63
  CONFIG_GET_ALLOWED_SCOPES: () => CONFIG_GET_ALLOWED_SCOPES,
59
64
  CONFIG_SEARCH_ALLOWED_SCOPES: () => CONFIG_SEARCH_ALLOWED_SCOPES,
60
65
  CertificateConfig: () => CertificateConfig,
@@ -68,6 +73,7 @@ __export(events_exports, {
68
73
  DEFAULT_DATE_OF_EVENT_PROPERTY: () => DEFAULT_DATE_OF_EVENT_PROPERTY,
69
74
  DataEntry: () => DataEntry,
70
75
  DataFieldValue: () => DataFieldValue,
76
+ DateCondition: () => DateCondition,
71
77
  DateRangeFieldValue: () => DateRangeFieldValue,
72
78
  DateValue: () => DateValue,
73
79
  DatetimeValue: () => DatetimeValue,
@@ -93,15 +99,17 @@ __export(events_exports, {
93
99
  EventInput: () => EventInput,
94
100
  EventMetadata: () => EventMetadata,
95
101
  EventMetadataKeys: () => EventMetadataKeys,
96
- EventMetadataParameter: () => EventMetadataParameter,
102
+ EventMetadataKeysArray: () => EventMetadataKeysArray,
97
103
  EventSearchIndex: () => EventSearchIndex,
98
104
  EventState: () => EventState,
99
105
  EventStatus: () => EventStatus,
100
- EventStatusEnum: () => EventStatusEnum,
101
- EventStatuses: () => EventStatuses,
106
+ Exact: () => Exact,
107
+ ExactDate: () => ExactDate,
108
+ ExactStatus: () => ExactStatus,
102
109
  FieldConditional: () => FieldConditional,
103
110
  FieldConfig: () => FieldConfig,
104
111
  FieldConfigSchema: () => FieldConfigSchema,
112
+ FieldReference: () => FieldReference,
105
113
  FieldType: () => FieldType,
106
114
  FieldUpdateValue: () => FieldUpdateValue,
107
115
  FieldValue: () => FieldValue,
@@ -111,6 +119,7 @@ __export(events_exports, {
111
119
  Flag: () => Flag,
112
120
  FormConfig: () => FormConfig,
113
121
  FormPageConfig: () => FormPageConfig,
122
+ Fuzzy: () => Fuzzy,
114
123
  GenericAddressUpdateValue: () => GenericAddressUpdateValue,
115
124
  GenericAddressValue: () => GenericAddressValue,
116
125
  GeographicalArea: () => GeographicalArea,
@@ -119,21 +128,27 @@ __export(events_exports, {
119
128
  LegalStatuses: () => LegalStatuses,
120
129
  MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
121
130
  MimeType: () => MimeType,
131
+ NameFieldUpdateValue: () => NameFieldUpdateValue,
132
+ NameFieldValue: () => NameFieldValue,
122
133
  NonEmptyTextValue: () => NonEmptyTextValue,
134
+ Not: () => Not,
123
135
  NotifyActionInput: () => NotifyActionInput,
124
136
  NumberFieldValue: () => NumberFieldValue,
125
137
  PageConfig: () => PageConfig,
126
138
  PageTypes: () => PageTypes,
127
139
  PrintCertificateActionInput: () => PrintCertificateActionInput,
128
140
  QueryExpression: () => QueryExpression,
129
- QueryInput: () => QueryInput2,
141
+ QueryInput: () => QueryInput,
130
142
  QueryType: () => QueryType,
143
+ Range: () => Range,
144
+ RangeDate: () => RangeDate,
131
145
  ReadActionInput: () => ReadActionInput,
132
146
  RegisterAction: () => RegisterAction,
133
147
  RegisterActionInput: () => RegisterActionInput,
134
148
  RegistrationCreationMetadata: () => RegistrationCreationMetadata,
135
149
  RejectCorrectionActionInput: () => RejectCorrectionActionInput,
136
150
  RejectDeclarationActionInput: () => RejectDeclarationActionInput,
151
+ RejectionReason: () => RejectionReason,
137
152
  RequestCorrectionActionInput: () => RequestCorrectionActionInput,
138
153
  ResolvedUser: () => ResolvedUser,
139
154
  RuralAddressUpdateValue: () => RuralAddressUpdateValue,
@@ -142,7 +157,11 @@ __export(events_exports, {
142
157
  SearchQueryParams: () => SearchQueryParams,
143
158
  SelectOption: () => SelectOption,
144
159
  ShowConditional: () => ShowConditional,
160
+ SignatureFieldValue: () => SignatureFieldValue,
161
+ StatusChangingActions: () => StatusChangingActions,
145
162
  SummaryConfig: () => SummaryConfig,
163
+ TENNIS_CLUB_MEMBERSHIP: () => TENNIS_CLUB_MEMBERSHIP,
164
+ TestUserRole: () => TestUserRole,
146
165
  TextValue: () => TextValue,
147
166
  TranslationConfig: () => TranslationConfig,
148
167
  UnassignActionInput: () => UnassignActionInput,
@@ -150,11 +169,19 @@ __export(events_exports, {
150
169
  UrbanAddressValue: () => UrbanAddressValue,
151
170
  User: () => User,
152
171
  ValidateActionInput: () => ValidateActionInput,
172
+ ValidationConfig: () => ValidationConfig,
153
173
  VerificationActionConfig: () => VerificationActionConfig,
154
174
  VerificationPageConfig: () => VerificationPageConfig,
175
+ WRITE_ACTION_SCOPES: () => WRITE_ACTION_SCOPES,
176
+ Within: () => Within,
177
+ WorkqueueActionsWithDefault: () => WorkqueueActionsWithDefault,
155
178
  WorkqueueColumn: () => WorkqueueColumn,
179
+ WorkqueueColumnKeys: () => WorkqueueColumnKeys,
180
+ WorkqueueColumnKeysArray: () => WorkqueueColumnKeysArray,
181
+ WorkqueueColumnValue: () => WorkqueueColumnValue,
156
182
  WorkqueueConfig: () => WorkqueueConfig,
157
183
  WorkqueueConfigInput: () => WorkqueueConfigInput,
184
+ WorkqueueConfigWithoutQuery: () => WorkqueueConfigWithoutQuery,
158
185
  WorkqueueCountInput: () => WorkqueueCountInput,
159
186
  WorkqueueCountOutput: () => WorkqueueCountOutput,
160
187
  ZodDate: () => ZodDate,
@@ -167,10 +194,10 @@ __export(events_exports, {
167
194
  createEmptyDraft: () => createEmptyDraft,
168
195
  createEventConditionals: () => createEventConditionals,
169
196
  createFieldConditionals: () => createFieldConditionals,
197
+ createPrng: () => createPrng,
170
198
  createValidationSchema: () => createValidationSchema,
171
199
  deepDropNulls: () => deepDropNulls,
172
200
  deepMerge: () => deepMerge,
173
- defaultThirdColumn: () => defaultThirdColumn,
174
201
  defaultWorkqueueColumns: () => defaultWorkqueueColumns,
175
202
  defineActionForm: () => defineActionForm,
176
203
  defineConditional: () => defineConditional,
@@ -188,10 +215,8 @@ __export(events_exports, {
188
215
  eventMetadataLabelMap: () => eventMetadataLabelMap,
189
216
  eventPayloadGenerator: () => eventPayloadGenerator,
190
217
  eventQueryDataGenerator: () => eventQueryDataGenerator,
191
- eventStatuses: () => eventStatuses,
192
218
  field: () => field,
193
219
  fieldTypes: () => fieldTypes,
194
- filterUnallowedActions: () => filterUnallowedActions,
195
220
  findActiveDrafts: () => findActiveDrafts,
196
221
  findAllFields: () => findAllFields,
197
222
  findLastAssignmentAction: () => findLastAssignmentAction,
@@ -201,6 +226,8 @@ __export(events_exports, {
201
226
  generateActionDocument: () => generateActionDocument,
202
227
  generateEventDocument: () => generateEventDocument,
203
228
  generateEventDraftDocument: () => generateEventDraftDocument,
229
+ generateRandomName: () => generateRandomName,
230
+ generateRandomSignature: () => generateRandomSignature,
204
231
  generateTransactionId: () => generateTransactionId,
205
232
  generateTranslationConfig: () => generateTranslationConfig,
206
233
  generateWorkqueues: () => generateWorkqueues,
@@ -210,15 +237,22 @@ __export(events_exports, {
210
237
  getActionReview: () => getActionReview,
211
238
  getActionReviewFields: () => getActionReviewFields,
212
239
  getActionVerificationPageIds: () => getActionVerificationPageIds,
240
+ getAllUniqueFields: () => getAllUniqueFields,
213
241
  getAnnotationFromDrafts: () => getAnnotationFromDrafts,
214
242
  getAssignedUserFromActions: () => getAssignedUserFromActions,
243
+ getAssignedUserSignatureFromActions: () => getAssignedUserSignatureFromActions,
215
244
  getCurrentEventState: () => getCurrentEventState,
216
245
  getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
217
246
  getDeclaration: () => getDeclaration,
247
+ getDeclarationFieldById: () => getDeclarationFieldById,
218
248
  getDeclarationFields: () => getDeclarationFields,
219
249
  getDeclarationPages: () => getDeclarationPages,
250
+ getEventConfigById: () => getEventConfigById,
220
251
  getMixedPath: () => getMixedPath,
252
+ getRandomDate: () => getRandomDate,
253
+ getRandomDatetime: () => getRandomDatetime,
221
254
  getStatusFromActions: () => getStatusFromActions,
255
+ getValidatorsForField: () => getValidatorsForField,
222
256
  getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
223
257
  hasAnyOfScopes: () => hasAnyOfScopes,
224
258
  isAddressFieldType: () => isAddressFieldType,
@@ -241,12 +275,17 @@ __export(events_exports, {
241
275
  isFieldVisible: () => isFieldVisible,
242
276
  isFileFieldType: () => isFileFieldType,
243
277
  isFileFieldWithOptionType: () => isFileFieldWithOptionType,
278
+ isIdFieldType: () => isIdFieldType,
244
279
  isLocationFieldType: () => isLocationFieldType,
280
+ isMetaAction: () => isMetaAction,
281
+ isNameFieldType: () => isNameFieldType,
282
+ isNonInteractiveFieldType: () => isNonInteractiveFieldType,
245
283
  isNumberFieldType: () => isNumberFieldType,
246
284
  isOfficeFieldType: () => isOfficeFieldType,
247
285
  isPageHeaderFieldType: () => isPageHeaderFieldType,
248
286
  isPageVisible: () => isPageVisible,
249
287
  isParagraphFieldType: () => isParagraphFieldType,
288
+ isPhoneFieldType: () => isPhoneFieldType,
250
289
  isRadioGroupFieldType: () => isRadioGroupFieldType,
251
290
  isSelectFieldType: () => isSelectFieldType,
252
291
  isSignatureFieldType: () => isSignatureFieldType,
@@ -256,6 +295,7 @@ __export(events_exports, {
256
295
  isUndeclaredDraft: () => isUndeclaredDraft,
257
296
  isVerificationPage: () => isVerificationPage,
258
297
  isWriteAction: () => isWriteAction,
298
+ mandatoryColumns: () => mandatoryColumns,
259
299
  mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
260
300
  mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
261
301
  mapFieldTypeToZod: () => mapFieldTypeToZod,
@@ -269,10 +309,15 @@ __export(events_exports, {
269
309
  user: () => user,
270
310
  validate: () => validate,
271
311
  validateFieldInput: () => validateFieldInput,
312
+ workqueueActions: () => workqueueActions,
272
313
  writeActions: () => writeActions
273
314
  });
274
315
  module.exports = __toCommonJS(events_exports);
275
316
 
317
+ // ../commons/src/events/Constants.ts
318
+ var TENNIS_CLUB_MEMBERSHIP = "tennis-club-membership";
319
+ var BIRTH_EVENT = "v2-birth";
320
+
276
321
  // ../commons/src/events/ActionConfig.ts
277
322
  var import_zod9 = require("zod");
278
323
 
@@ -350,6 +395,9 @@ var TranslationConfig = import_zod2.z.object({
350
395
 
351
396
  // ../commons/src/events/FieldType.ts
352
397
  var FieldType = {
398
+ NAME: "NAME",
399
+ PHONE: "PHONE",
400
+ ID: "ID",
353
401
  ADDRESS: "ADDRESS",
354
402
  TEXT: "TEXT",
355
403
  NUMBER: "NUMBER",
@@ -426,6 +474,16 @@ var UrbanAddressUpdateValue = AdminStructure.extend({
426
474
  number: import_zod3.z.string().nullish(),
427
475
  zipCode: import_zod3.z.string().nullish()
428
476
  });
477
+ var NameFieldValue = import_zod3.z.object({
478
+ firstname: import_zod3.z.string(),
479
+ surname: import_zod3.z.string(),
480
+ middlename: import_zod3.z.string().optional()
481
+ });
482
+ var NameFieldUpdateValue = import_zod3.z.object({
483
+ firstname: import_zod3.z.string(),
484
+ surname: import_zod3.z.string(),
485
+ middlename: import_zod3.z.string().nullish()
486
+ }).or(import_zod3.z.null()).or(import_zod3.z.undefined());
429
487
  var RuralAddressUpdateValue = AdminStructure.extend({
430
488
  urbanOrRural: import_zod3.z.literal(GeographicalArea.RURAL),
431
489
  village: import_zod3.z.string().nullish()
@@ -475,6 +533,7 @@ var EmailValue = import_zod4.z.string().email();
475
533
  var CheckboxFieldValue = import_zod4.z.boolean();
476
534
  var NumberFieldValue = import_zod4.z.number();
477
535
  var DataFieldValue = import_zod4.z.undefined();
536
+ var SignatureFieldValue = import_zod4.z.string();
478
537
  var FieldValue = import_zod4.z.union([
479
538
  TextValue,
480
539
  DateValue,
@@ -486,7 +545,9 @@ var FieldValue = import_zod4.z.union([
486
545
  UrbanAddressValue,
487
546
  RuralAddressValue,
488
547
  DataFieldValue,
489
- GenericAddressValue
548
+ GenericAddressValue,
549
+ NameFieldValue,
550
+ NameFieldUpdateValue
490
551
  ]);
491
552
  var FieldUpdateValue = import_zod4.z.union([
492
553
  TextValue,
@@ -499,35 +560,29 @@ var FieldUpdateValue = import_zod4.z.union([
499
560
  UrbanAddressUpdateValue,
500
561
  RuralAddressUpdateValue,
501
562
  DataFieldValue,
502
- GenericAddressUpdateValue
563
+ GenericAddressUpdateValue,
564
+ NameFieldUpdateValue
503
565
  ]);
504
566
 
505
567
  // ../commons/src/events/FieldConfig.ts
506
568
  var import_zod_openapi3 = require("zod-openapi");
507
569
  (0, import_zod_openapi3.extendZodWithOpenApi)(import_zod5.z);
508
- var FieldId = import_zod5.z.string();
509
- var ParentReference = import_zod5.z.object({
510
- _fieldId: FieldId.optional()
511
- }).optional();
570
+ var FieldId = import_zod5.z.string().describe("Unique identifier for the field");
571
+ var FieldReference = import_zod5.z.object({
572
+ $$field: FieldId
573
+ }).describe("Reference to a field by its ID");
574
+ var ParentReference = FieldReference.optional();
575
+ var ValidationConfig = import_zod5.z.object({
576
+ validator: Conditional,
577
+ message: TranslationConfig
578
+ });
512
579
  var BaseField = import_zod5.z.object({
513
580
  id: FieldId,
514
- defaultValue: import_zod5.z.union([
515
- TextValue,
516
- NonEmptyTextValue,
517
- DateValue,
518
- NumberFieldValue,
519
- CheckboxFieldValue
520
- ]).optional(),
521
581
  parent: ParentReference,
522
582
  conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
523
583
  required: import_zod5.z.boolean().default(false).optional(),
524
584
  placeholder: TranslationConfig.optional(),
525
- validation: import_zod5.z.array(
526
- import_zod5.z.object({
527
- validator: Conditional,
528
- message: TranslationConfig
529
- })
530
- ).default([]).optional(),
585
+ validation: import_zod5.z.array(ValidationConfig).default([]).optional(),
531
586
  label: TranslationConfig,
532
587
  helperText: TranslationConfig.optional(),
533
588
  hideLabel: import_zod5.z.boolean().default(false).optional()
@@ -579,6 +634,7 @@ var SignatureField = BaseField.extend({
579
634
  signaturePromptLabel: TranslationConfig.describe(
580
635
  "Title of the signature modal"
581
636
  ),
637
+ defaultValue: SignatureFieldValue.optional(),
582
638
  configuration: import_zod5.z.object({
583
639
  maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
584
640
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
@@ -638,6 +694,7 @@ var PageHeader = BaseField.extend({
638
694
  }).describe("A read-only header component for form pages");
639
695
  var File = BaseField.extend({
640
696
  type: import_zod5.z.literal(FieldType.FILE),
697
+ defaultValue: FileFieldValue.optional(),
641
698
  configuration: import_zod5.z.object({
642
699
  maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
643
700
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
@@ -680,6 +737,26 @@ var Select = BaseField.extend({
680
737
  defaultValue: TextValue.optional(),
681
738
  options: import_zod5.z.array(SelectOption).describe("A list of options")
682
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");
683
760
  var Checkbox = BaseField.extend({
684
761
  type: import_zod5.z.literal(FieldType.CHECKBOX),
685
762
  defaultValue: CheckboxFieldValue.optional()
@@ -711,6 +788,7 @@ var Location = BaseField.extend({
711
788
  var FileUploadWithOptions = BaseField.extend({
712
789
  type: import_zod5.z.literal(FieldType.FILE_WITH_OPTIONS),
713
790
  options: import_zod5.z.array(SelectOption).describe("A list of options"),
791
+ defaultValue: FileFieldWithOptionValue.optional(),
714
792
  configuration: import_zod5.z.object({
715
793
  maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
716
794
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
@@ -758,6 +836,9 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
758
836
  BulletList,
759
837
  PageHeader,
760
838
  Select,
839
+ NameField,
840
+ PhoneField,
841
+ IdField,
761
842
  Checkbox,
762
843
  File,
763
844
  Country,
@@ -891,6 +972,35 @@ var writeActions = ActionTypes.exclude([
891
972
  ActionType.ASSIGN,
892
973
  ActionType.UNASSIGN
893
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
+ }
894
1004
 
895
1005
  // ../commons/src/events/FormConfig.ts
896
1006
  var import_zod8 = require("zod");
@@ -922,6 +1032,12 @@ var ActionConfigBase = import_zod9.z.object({
922
1032
  conditionals: import_zod9.z.array(ActionConditional2).optional().default([]),
923
1033
  draft: import_zod9.z.boolean().optional()
924
1034
  });
1035
+ var ReadActionConfig = ActionConfigBase.merge(
1036
+ import_zod9.z.object({
1037
+ type: import_zod9.z.literal(ActionType.READ),
1038
+ review: DeclarationReviewConfig
1039
+ })
1040
+ );
925
1041
  var DeclareConfig = ActionConfigBase.merge(
926
1042
  import_zod9.z.object({
927
1043
  type: import_zod9.z.literal(ActionType.DECLARE),
@@ -988,6 +1104,7 @@ var ActionConfig = import_zod9.z.discriminatedUnion("type", [
988
1104
  * OpenAPI references are defined here so our generated OpenAPI spec knows to reuse the models
989
1105
  * and treat them as "models" instead of duplicating the data structure in each endpoint.
990
1106
  */
1107
+ ReadActionConfig.openapi({ ref: "ReadActionConfig" }),
991
1108
  DeclareConfig.openapi({ ref: "DeclareActionConfig" }),
992
1109
  ValidateConfig.openapi({ ref: "ValidateActionConfig" }),
993
1110
  RejectDeclarationConfig.openapi({ ref: "RejectDeclarationActionConfig" }),
@@ -1045,13 +1162,13 @@ var LanguageConfig = import_zod11.z.object({
1045
1162
  });
1046
1163
 
1047
1164
  // ../commons/src/events/EventConfig.ts
1048
- var import_zod17 = require("zod");
1165
+ var import_zod20 = require("zod");
1049
1166
 
1050
1167
  // ../commons/src/events/DeduplicationConfig.ts
1051
1168
  var import_zod12 = require("zod");
1052
1169
  var import_zod_openapi6 = require("zod-openapi");
1053
1170
  (0, import_zod_openapi6.extendZodWithOpenApi)(import_zod12.z);
1054
- var FieldReference = import_zod12.z.string();
1171
+ var FieldReference2 = import_zod12.z.string();
1055
1172
  var Matcher = import_zod12.z.object({
1056
1173
  fieldId: import_zod12.z.string(),
1057
1174
  options: import_zod12.z.object({
@@ -1080,7 +1197,7 @@ var DateRangeMatcher = Matcher.extend({
1080
1197
  type: import_zod12.z.literal("dateRange"),
1081
1198
  options: import_zod12.z.object({
1082
1199
  days: import_zod12.z.number(),
1083
- origin: FieldReference,
1200
+ origin: FieldReference2,
1084
1201
  boost: import_zod12.z.number().optional().default(1)
1085
1202
  })
1086
1203
  });
@@ -1088,7 +1205,7 @@ var DateDistanceMatcher = Matcher.extend({
1088
1205
  type: import_zod12.z.literal("dateDistance"),
1089
1206
  options: import_zod12.z.object({
1090
1207
  days: import_zod12.z.number(),
1091
- origin: FieldReference,
1208
+ origin: FieldReference2,
1092
1209
  boost: import_zod12.z.number().optional().default(1)
1093
1210
  })
1094
1211
  });
@@ -1137,8 +1254,7 @@ var Field = BaseField2.extend({
1137
1254
  value: TranslationConfig.describe(
1138
1255
  "Summary field value. Can utilise values defined in configuration and EventMetadata"
1139
1256
  ),
1140
- label: TranslationConfig,
1141
- emptyValueMessage: TranslationConfig.optional()
1257
+ label: TranslationConfig
1142
1258
  }).describe("Custom configured field");
1143
1259
  var SummaryConfig = import_zod13.z.object({
1144
1260
  fields: import_zod13.z.array(import_zod13.z.union([Field, ReferenceField])).describe("Fields rendered in summary view.")
@@ -1154,37 +1270,40 @@ var BaseField3 = import_zod14.z.object({
1154
1270
  options: import_zod14.z.array(SelectOption).optional(),
1155
1271
  searchCriteriaLabelPrefix: TranslationConfig.optional().describe(
1156
1272
  `
1157
- 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
1158
1274
  when rendering search parameter labels \u2014 for example, in the search results page to indicate which fields were used in the search.
1159
1275
 
1160
- 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.
1161
1277
 
1162
1278
  A field config like { id: "mother.firstname", label: { defaultMessage: "First Name(s)" } } would also render as "First Name(s)" by default.
1163
1279
 
1164
- 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)",
1165
1281
  which is ambiguous.
1166
1282
 
1167
- Now, if we treat the field ID prefix as a label (e.g., "applicant.firstname" \u2192 "Applicant"), and the field label is already
1168
- 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
1169
1285
  label would be "Applicant Applicant's First Name", which is redundant and awkward.
1170
1286
 
1171
- 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
1172
1288
  in the country-config > event.advancedSearch configuration. For example: field("child.dob", { searchCriteriaLabelPrefix: TranslationConfig }).
1173
1289
  `
1174
1290
  ),
1175
1291
  conditionals: import_zod14.z.array(FieldConditional).default([]).optional().describe(
1176
1292
  `
1177
1293
  In advanced search, we sometimes need to override the default field visibility conditionals.
1178
-
1179
- For example, Informant fields in the declaration form may have conditional logic
1180
- 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
1181
1297
  the declaration form config, those same conditionals would apply by default.
1182
-
1298
+
1183
1299
  However, in advanced search we often want to make all Informant fields searchable,
1184
- regardless of their original visibility logic. To do this, we explicitly set their
1185
- '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
1186
1302
  are always rendered in the advanced search form.
1187
1303
  `
1304
+ ),
1305
+ validations: import_zod14.z.array(ValidationConfig).default([]).optional().describe(
1306
+ `In advanced search, we sometimes need to override the default field validations.`
1188
1307
  )
1189
1308
  });
1190
1309
  var SearchQueryParams = import_zod14.z.object({
@@ -1220,114 +1339,552 @@ var AdvancedSearchConfig = import_zod14.z.object({
1220
1339
  var import_lodash = require("lodash");
1221
1340
 
1222
1341
  // ../commons/src/events/ActionDocument.ts
1223
- var import_zod15 = require("zod");
1342
+ var import_zod18 = require("zod");
1224
1343
  var import_zod_openapi7 = require("zod-openapi");
1225
- (0, import_zod_openapi7.extendZodWithOpenApi)(import_zod15.z);
1226
- var ActionUpdate = import_zod15.z.record(import_zod15.z.string(), FieldUpdateValue);
1227
- var EventState = import_zod15.z.record(import_zod15.z.string(), FieldValue);
1344
+
1345
+ // ../commons/src/events/CreatedAtLocation.ts
1346
+ var import_zod15 = require("zod");
1347
+ var CreatedAtLocation = import_zod15.z.string().nullish();
1348
+
1349
+ // ../commons/src/authentication.ts
1350
+ var import_jwt_decode = __toESM(require("jwt-decode"));
1351
+ var import_zod17 = require("zod");
1352
+
1353
+ // ../commons/src/scopes.ts
1354
+ var import_zod16 = require("zod");
1355
+ var SCOPES = {
1356
+ // TODO v1.8 legacy scopes
1357
+ NATLSYSADMIN: "natlsysadmin",
1358
+ BYPASSRATELIMIT: "bypassratelimit",
1359
+ DECLARE: "declare",
1360
+ REGISTER: "register",
1361
+ VALIDATE: "validate",
1362
+ DEMO: "demo",
1363
+ CERTIFY: "certify",
1364
+ PERFORMANCE: "performance",
1365
+ SYSADMIN: "sysadmin",
1366
+ TEAMS: "teams",
1367
+ CONFIG: "config",
1368
+ // systems / integrations
1369
+ WEBHOOK: "webhook",
1370
+ NATIONALID: "nationalId",
1371
+ NOTIFICATION_API: "notification-api",
1372
+ RECORDSEARCH: "recordsearch",
1373
+ /**
1374
+ * @TODO This is a temporary scope to be used for V2 Events custom events declaration
1375
+ */
1376
+ RECORD_DECLARE: "record.declare-birth",
1377
+ // declare
1378
+ RECORD_IMPORT: "record.import",
1379
+ // declare
1380
+ RECORD_DECLARE_BIRTH: "record.declare-birth",
1381
+ RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
1382
+ RECORD_DECLARE_DEATH: "record.declare-death",
1383
+ RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction",
1384
+ RECORD_DECLARE_MARRIAGE: "record.declare-marriage",
1385
+ RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction",
1386
+ RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete",
1387
+ RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review",
1388
+ RECORD_UNASSIGN_OTHERS: "record.unassign-others",
1389
+ // validate
1390
+ RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval",
1391
+ RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates",
1392
+ RECORD_DECLARATION_EDIT: "record.declaration-edit",
1393
+ RECORD_REVIEW_DUPLICATES: "record.review-duplicates",
1394
+ RECORD_DECLARATION_ARCHIVE: "record.declaration-archive",
1395
+ RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate",
1396
+ // register
1397
+ RECORD_REGISTER: "record.register",
1398
+ // certify
1399
+ RECORD_EXPORT_RECORDS: "record.export-records",
1400
+ RECORD_DECLARATION_PRINT: "record.declaration-print",
1401
+ RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS: "record.declaration-print-supporting-documents",
1402
+ RECORD_REGISTRATION_PRINT: "record.registration-print",
1403
+ // v1.8
1404
+ /**
1405
+ * This scope is used to **print and **issue certified copies of a record
1406
+ * after it has been registered. Previously Registrars had this permission.
1407
+ */
1408
+ RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies",
1409
+ RECORD_PRINT_CERTIFIED_COPIES: "record.registration-print-certified-copies",
1410
+ // v1.8
1411
+ RECORD_BULK_PRINT_CERTIFIED_COPIES: "record.registration-bulk-print-certified-copies",
1412
+ // v1.8
1413
+ RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES: "record.registration-verify-certified-copies",
1414
+ // v1.8
1415
+ // correct
1416
+ RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction",
1417
+ RECORD_REGISTRATION_CORRECT: "record.registration-correct",
1418
+ RECORD_REGISTRATION_REQUEST_REVOCATION: "record.registration-request-revocation",
1419
+ // v1.8
1420
+ RECORD_REGISTRATION_REVOKE: "record.registration-revoke",
1421
+ // v1.8
1422
+ RECORD_REGISTRATION_REQUEST_REINSTATEMENT: "record.registration-request-reinstatement",
1423
+ // v1.8
1424
+ RECORD_REGISTRATION_REINSTATE: "record.registration-reinstate",
1425
+ // v1.8
1426
+ RECORD_CONFIRM_REGISTRATION: "record.confirm-registration",
1427
+ RECORD_REJECT_REGISTRATION: "record.reject-registration",
1428
+ // search
1429
+ SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction",
1430
+ SEARCH_BIRTH: "search.birth",
1431
+ SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction",
1432
+ SEARCH_DEATH: "search.death",
1433
+ SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction",
1434
+ SEARCH_MARRIAGE: "search.marriage",
1435
+ // audit v1.8
1436
+ RECORD_READ: "record.read",
1437
+ RECORD_READ_AUDIT: "record.read-audit",
1438
+ RECORD_READ_COMMENTS: "record.read-comments",
1439
+ RECORD_CREATE_COMMENTS: "record.create-comments",
1440
+ // profile
1441
+ PROFILE_UPDATE: "profile.update",
1442
+ //v1.8
1443
+ PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
1444
+ // performance
1445
+ PERFORMANCE_READ: "performance.read",
1446
+ PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
1447
+ PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
1448
+ // organisation
1449
+ ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all",
1450
+ ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
1451
+ ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
1452
+ // user
1453
+ USER_READ: "user.read:all",
1454
+ USER_READ_MY_OFFICE: "user.read:my-office",
1455
+ USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
1456
+ USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
1457
+ //v1.8
1458
+ USER_CREATE: "user.create:all",
1459
+ USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
1460
+ USER_UPDATE: "user.update:all",
1461
+ USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction",
1462
+ // config
1463
+ CONFIG_UPDATE_ALL: "config.update:all",
1464
+ // data seeding
1465
+ USER_DATA_SEEDING: "user.data-seeding"
1466
+ };
1467
+ var LegacyScopes = import_zod16.z.union([
1468
+ import_zod16.z.literal(SCOPES.NATLSYSADMIN),
1469
+ import_zod16.z.literal(SCOPES.BYPASSRATELIMIT),
1470
+ import_zod16.z.literal(SCOPES.DECLARE),
1471
+ import_zod16.z.literal(SCOPES.REGISTER),
1472
+ import_zod16.z.literal(SCOPES.VALIDATE),
1473
+ import_zod16.z.literal(SCOPES.DEMO),
1474
+ import_zod16.z.literal(SCOPES.CERTIFY),
1475
+ import_zod16.z.literal(SCOPES.PERFORMANCE),
1476
+ import_zod16.z.literal(SCOPES.SYSADMIN),
1477
+ import_zod16.z.literal(SCOPES.TEAMS),
1478
+ import_zod16.z.literal(SCOPES.CONFIG)
1479
+ ]);
1480
+ var IntegrationScopes = import_zod16.z.union([
1481
+ import_zod16.z.literal(SCOPES.WEBHOOK),
1482
+ import_zod16.z.literal(SCOPES.NATIONALID),
1483
+ import_zod16.z.literal(SCOPES.NOTIFICATION_API),
1484
+ import_zod16.z.literal(SCOPES.RECORDSEARCH)
1485
+ ]);
1486
+ var DeclareScopes = import_zod16.z.union([
1487
+ import_zod16.z.literal(SCOPES.RECORD_DECLARE),
1488
+ import_zod16.z.literal(SCOPES.RECORD_IMPORT),
1489
+ import_zod16.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
1490
+ import_zod16.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
1491
+ import_zod16.z.literal(SCOPES.RECORD_DECLARE_DEATH),
1492
+ import_zod16.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
1493
+ import_zod16.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
1494
+ import_zod16.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
1495
+ import_zod16.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
1496
+ import_zod16.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW)
1497
+ ]);
1498
+ var UnassignScope = import_zod16.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS);
1499
+ var ValidateScopes = import_zod16.z.union([
1500
+ import_zod16.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
1501
+ import_zod16.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
1502
+ import_zod16.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
1503
+ import_zod16.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
1504
+ import_zod16.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
1505
+ import_zod16.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE)
1506
+ ]);
1507
+ var RegisterScope = import_zod16.z.literal(SCOPES.RECORD_REGISTER);
1508
+ var CertifyScopes = import_zod16.z.union([
1509
+ import_zod16.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
1510
+ import_zod16.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
1511
+ import_zod16.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
1512
+ import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
1513
+ import_zod16.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
1514
+ import_zod16.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
1515
+ import_zod16.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
1516
+ import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES)
1517
+ ]);
1518
+ var CorrectionScopes = import_zod16.z.union([
1519
+ import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
1520
+ import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
1521
+ import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
1522
+ import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
1523
+ import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
1524
+ import_zod16.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
1525
+ import_zod16.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
1526
+ import_zod16.z.literal(SCOPES.RECORD_REJECT_REGISTRATION)
1527
+ ]);
1528
+ var SearchScopes = import_zod16.z.union([
1529
+ import_zod16.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
1530
+ import_zod16.z.literal(SCOPES.SEARCH_BIRTH),
1531
+ import_zod16.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
1532
+ import_zod16.z.literal(SCOPES.SEARCH_DEATH),
1533
+ import_zod16.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
1534
+ import_zod16.z.literal(SCOPES.SEARCH_MARRIAGE)
1535
+ ]);
1536
+ var AuditScopes = import_zod16.z.union([
1537
+ import_zod16.z.literal(SCOPES.RECORD_READ),
1538
+ import_zod16.z.literal(SCOPES.RECORD_READ_AUDIT),
1539
+ import_zod16.z.literal(SCOPES.RECORD_READ_COMMENTS),
1540
+ import_zod16.z.literal(SCOPES.RECORD_CREATE_COMMENTS)
1541
+ ]);
1542
+ var ProfileScopes = import_zod16.z.union([
1543
+ import_zod16.z.literal(SCOPES.PROFILE_UPDATE),
1544
+ import_zod16.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE)
1545
+ ]);
1546
+ var PerformanceScopes = import_zod16.z.union([
1547
+ import_zod16.z.literal(SCOPES.PERFORMANCE_READ),
1548
+ import_zod16.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
1549
+ import_zod16.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS)
1550
+ ]);
1551
+ var OrganisationScopes = import_zod16.z.union([
1552
+ import_zod16.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
1553
+ import_zod16.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
1554
+ import_zod16.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION)
1555
+ ]);
1556
+ var UserScopes = import_zod16.z.union([
1557
+ import_zod16.z.literal(SCOPES.USER_READ),
1558
+ import_zod16.z.literal(SCOPES.USER_READ_MY_OFFICE),
1559
+ import_zod16.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
1560
+ import_zod16.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
1561
+ import_zod16.z.literal(SCOPES.USER_CREATE),
1562
+ import_zod16.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
1563
+ import_zod16.z.literal(SCOPES.USER_UPDATE),
1564
+ import_zod16.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION)
1565
+ ]);
1566
+ var ConfigScope = import_zod16.z.literal(SCOPES.CONFIG_UPDATE_ALL);
1567
+ var DataSeedingScope = import_zod16.z.literal(SCOPES.USER_DATA_SEEDING);
1568
+ var LiteralScopes = import_zod16.z.union([
1569
+ LegacyScopes,
1570
+ IntegrationScopes,
1571
+ UnassignScope,
1572
+ DeclareScopes,
1573
+ ValidateScopes,
1574
+ RegisterScope,
1575
+ CertifyScopes,
1576
+ CorrectionScopes,
1577
+ SearchScopes,
1578
+ AuditScopes,
1579
+ ProfileScopes,
1580
+ PerformanceScopes,
1581
+ OrganisationScopes,
1582
+ UserScopes,
1583
+ ConfigScope,
1584
+ DataSeedingScope
1585
+ ]);
1586
+ var rawConfigurableScopeRegex = /^([a-zA-Z\.]+)\[((?:\w+=[\w.-]+(?:\|[\w.-]+)*)(?:,[\w]+=[\w.-]+(?:\|[\w.-]+)*)*)\]$/;
1587
+ var rawConfigurableScope = import_zod16.z.string().regex(rawConfigurableScopeRegex);
1588
+ var CreateUserScope = import_zod16.z.object({
1589
+ type: import_zod16.z.literal("user.create"),
1590
+ options: import_zod16.z.object({
1591
+ role: import_zod16.z.array(import_zod16.z.string())
1592
+ })
1593
+ });
1594
+ var EditUserScope = import_zod16.z.object({
1595
+ type: import_zod16.z.literal("user.edit"),
1596
+ options: import_zod16.z.object({
1597
+ role: import_zod16.z.array(import_zod16.z.string())
1598
+ })
1599
+ });
1600
+ var WorkqueueScope = import_zod16.z.object({
1601
+ type: import_zod16.z.literal("workqueue"),
1602
+ options: import_zod16.z.object({
1603
+ id: import_zod16.z.array(import_zod16.z.string())
1604
+ })
1605
+ });
1606
+ var NotifyRecordScope = import_zod16.z.object({
1607
+ type: import_zod16.z.literal("record.notify"),
1608
+ options: import_zod16.z.object({
1609
+ event: import_zod16.z.array(import_zod16.z.string())
1610
+ })
1611
+ });
1612
+ var ConfigurableScopes = import_zod16.z.discriminatedUnion("type", [
1613
+ CreateUserScope,
1614
+ EditUserScope,
1615
+ WorkqueueScope,
1616
+ NotifyRecordScope
1617
+ ]);
1618
+ var scopes = Object.values(SCOPES);
1619
+ var ActionScopes = import_zod16.z.union([
1620
+ DeclareScopes,
1621
+ ValidateScopes,
1622
+ RegisterScope,
1623
+ CertifyScopes,
1624
+ CorrectionScopes
1625
+ ]);
1626
+
1627
+ // ../commons/src/authentication.ts
1628
+ var DEFAULT_ROLES_DEFINITION = [
1629
+ {
1630
+ id: "FIELD_AGENT",
1631
+ label: {
1632
+ defaultMessage: "Field Agent",
1633
+ description: "Name for user role Field Agent",
1634
+ id: "userRole.fieldAgent"
1635
+ },
1636
+ scopes: [
1637
+ // new scopes
1638
+ SCOPES.RECORD_DECLARE_BIRTH,
1639
+ SCOPES.RECORD_DECLARE_DEATH,
1640
+ SCOPES.RECORD_DECLARE_MARRIAGE,
1641
+ SCOPES.RECORD_SUBMIT_INCOMPLETE,
1642
+ SCOPES.RECORD_SUBMIT_FOR_REVIEW,
1643
+ SCOPES.SEARCH_BIRTH,
1644
+ SCOPES.SEARCH_DEATH,
1645
+ SCOPES.SEARCH_MARRIAGE
1646
+ ]
1647
+ },
1648
+ {
1649
+ id: "REGISTRATION_AGENT",
1650
+ label: {
1651
+ defaultMessage: "Registration Agent",
1652
+ description: "Name for user role Registration Agent",
1653
+ id: "userRole.registrationAgent"
1654
+ },
1655
+ scopes: [
1656
+ SCOPES.PERFORMANCE,
1657
+ SCOPES.CERTIFY,
1658
+ SCOPES.RECORD_DECLARE_BIRTH,
1659
+ SCOPES.RECORD_DECLARE_DEATH,
1660
+ SCOPES.RECORD_DECLARE_MARRIAGE,
1661
+ SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
1662
+ SCOPES.RECORD_SUBMIT_FOR_UPDATES,
1663
+ SCOPES.RECORD_DECLARATION_ARCHIVE,
1664
+ SCOPES.RECORD_DECLARATION_REINSTATE,
1665
+ SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION,
1666
+ SCOPES.RECORD_REGISTRATION_PRINT,
1667
+ SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS,
1668
+ SCOPES.RECORD_EXPORT_RECORDS,
1669
+ SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES,
1670
+ SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES,
1671
+ SCOPES.RECORD_CREATE_COMMENTS,
1672
+ SCOPES.PERFORMANCE_READ,
1673
+ SCOPES.PERFORMANCE_READ_DASHBOARDS,
1674
+ SCOPES.ORGANISATION_READ_LOCATIONS,
1675
+ SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE,
1676
+ SCOPES.SEARCH_BIRTH,
1677
+ SCOPES.SEARCH_DEATH,
1678
+ SCOPES.SEARCH_MARRIAGE
1679
+ ]
1680
+ },
1681
+ {
1682
+ id: "LOCAL_REGISTRAR",
1683
+ label: {
1684
+ defaultMessage: "Local Registrar",
1685
+ description: "Name for user role Local Registrar",
1686
+ id: "userRole.localRegistrar"
1687
+ },
1688
+ scopes: [
1689
+ SCOPES.PERFORMANCE,
1690
+ SCOPES.CERTIFY,
1691
+ SCOPES.RECORD_DECLARE_BIRTH,
1692
+ SCOPES.RECORD_DECLARE_DEATH,
1693
+ SCOPES.RECORD_DECLARE_MARRIAGE,
1694
+ SCOPES.RECORD_SUBMIT_FOR_UPDATES,
1695
+ SCOPES.RECORD_REVIEW_DUPLICATES,
1696
+ SCOPES.RECORD_DECLARATION_ARCHIVE,
1697
+ SCOPES.RECORD_DECLARATION_REINSTATE,
1698
+ SCOPES.RECORD_REGISTER,
1699
+ SCOPES.RECORD_REGISTRATION_CORRECT,
1700
+ SCOPES.RECORD_REGISTRATION_PRINT,
1701
+ SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS,
1702
+ SCOPES.RECORD_EXPORT_RECORDS,
1703
+ SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES,
1704
+ SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES,
1705
+ SCOPES.RECORD_CREATE_COMMENTS,
1706
+ SCOPES.PERFORMANCE_READ,
1707
+ SCOPES.PERFORMANCE_READ_DASHBOARDS,
1708
+ SCOPES.ORGANISATION_READ_LOCATIONS,
1709
+ SCOPES.PROFILE_ELECTRONIC_SIGNATURE,
1710
+ SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE,
1711
+ SCOPES.SEARCH_BIRTH,
1712
+ SCOPES.SEARCH_DEATH,
1713
+ SCOPES.SEARCH_MARRIAGE
1714
+ ]
1715
+ },
1716
+ {
1717
+ id: "LOCAL_SYSTEM_ADMIN",
1718
+ label: {
1719
+ defaultMessage: "Local System Admin",
1720
+ description: "Name for user role Local System Admin",
1721
+ id: "userRole.localSystemAdmin"
1722
+ },
1723
+ scopes: [
1724
+ SCOPES.SYSADMIN,
1725
+ SCOPES.USER_READ_MY_OFFICE,
1726
+ SCOPES.USER_CREATE_MY_JURISDICTION,
1727
+ SCOPES.USER_UPDATE_MY_JURISDICTION,
1728
+ SCOPES.ORGANISATION_READ_LOCATIONS,
1729
+ SCOPES.PERFORMANCE_READ,
1730
+ SCOPES.PERFORMANCE_READ_DASHBOARDS,
1731
+ SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS
1732
+ // 'organisation.read-users' ?
1733
+ ]
1734
+ },
1735
+ {
1736
+ id: "NATIONAL_SYSTEM_ADMIN",
1737
+ label: {
1738
+ defaultMessage: "National System Admin",
1739
+ description: "Name for user role National System Admin",
1740
+ id: "userRole.nationalSystemAdmin"
1741
+ },
1742
+ scopes: [
1743
+ SCOPES.SYSADMIN,
1744
+ SCOPES.NATLSYSADMIN,
1745
+ SCOPES.USER_CREATE,
1746
+ SCOPES.USER_READ,
1747
+ SCOPES.USER_UPDATE,
1748
+ SCOPES.ORGANISATION_READ_LOCATIONS,
1749
+ SCOPES.PERFORMANCE_READ,
1750
+ SCOPES.PERFORMANCE_READ_DASHBOARDS,
1751
+ SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS
1752
+ // 'organisation.read-users' ?
1753
+ ]
1754
+ },
1755
+ {
1756
+ id: "PERFORMANCE_MANAGER",
1757
+ label: {
1758
+ defaultMessage: "Performance Manager",
1759
+ description: "Name for user role Performance Manager",
1760
+ id: "userRole.performanceManager"
1761
+ },
1762
+ scopes: [
1763
+ SCOPES.PERFORMANCE,
1764
+ SCOPES.PERFORMANCE_READ,
1765
+ SCOPES.PERFORMANCE_READ_DASHBOARDS,
1766
+ SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS
1767
+ ]
1768
+ }
1769
+ ];
1770
+ var TokenUserType = import_zod17.z.enum(["user", "system"]);
1771
+ var TokenWithBearer = import_zod17.z.string().regex(/^Bearer\s/);
1772
+
1773
+ // ../commons/src/events/ActionDocument.ts
1774
+ (0, import_zod_openapi7.extendZodWithOpenApi)(import_zod18.z);
1775
+ var ActionUpdate = import_zod18.z.record(import_zod18.z.string(), FieldUpdateValue);
1776
+ var EventState = import_zod18.z.record(import_zod18.z.string(), FieldValue);
1228
1777
  var ActionStatus = {
1229
1778
  Requested: "Requested",
1230
1779
  Accepted: "Accepted",
1231
1780
  Rejected: "Rejected"
1232
1781
  };
1233
- var ActionBase = import_zod15.z.object({
1234
- id: import_zod15.z.string(),
1235
- transactionId: import_zod15.z.string(),
1236
- createdAt: import_zod15.z.string().datetime(),
1237
- createdBy: import_zod15.z.string(),
1238
- createdByRole: import_zod15.z.string(),
1782
+ var ActionBase = import_zod18.z.object({
1783
+ id: import_zod18.z.string(),
1784
+ transactionId: import_zod18.z.string(),
1785
+ createdByUserType: TokenUserType,
1786
+ createdAt: import_zod18.z.string().datetime(),
1787
+ createdBy: import_zod18.z.string(),
1788
+ createdByRole: import_zod18.z.string(),
1789
+ createdBySignature: import_zod18.z.string().nullish().describe("Reference to signature of the user who created the action"),
1790
+ createdAtLocation: CreatedAtLocation,
1239
1791
  declaration: ActionUpdate,
1240
1792
  annotation: ActionUpdate.optional(),
1241
- createdAtLocation: import_zod15.z.string(),
1242
- status: import_zod15.z.enum([
1793
+ status: import_zod18.z.enum([
1243
1794
  ActionStatus.Requested,
1244
1795
  ActionStatus.Accepted,
1245
1796
  ActionStatus.Rejected
1246
1797
  ]),
1247
1798
  // If the action is an asynchronous confirmation for another action, we will save the original action id here.
1248
- originalActionId: import_zod15.z.string().optional()
1799
+ originalActionId: import_zod18.z.string().optional()
1249
1800
  });
1250
1801
  var AssignedAction = ActionBase.merge(
1251
- import_zod15.z.object({
1252
- type: import_zod15.z.literal(ActionType.ASSIGN),
1253
- assignedTo: import_zod15.z.string()
1802
+ import_zod18.z.object({
1803
+ type: import_zod18.z.literal(ActionType.ASSIGN),
1804
+ assignedTo: import_zod18.z.string()
1254
1805
  })
1255
1806
  );
1256
1807
  var UnassignedAction = ActionBase.merge(
1257
- import_zod15.z.object({
1258
- type: import_zod15.z.literal(ActionType.UNASSIGN),
1259
- assignedTo: import_zod15.z.literal(null)
1808
+ import_zod18.z.object({
1809
+ type: import_zod18.z.literal(ActionType.UNASSIGN),
1810
+ assignedTo: import_zod18.z.literal(null)
1260
1811
  })
1261
1812
  );
1262
1813
  var RegisterAction = ActionBase.merge(
1263
- import_zod15.z.object({
1264
- type: import_zod15.z.literal(ActionType.REGISTER),
1265
- registrationNumber: import_zod15.z.string().optional()
1814
+ import_zod18.z.object({
1815
+ type: import_zod18.z.literal(ActionType.REGISTER),
1816
+ registrationNumber: import_zod18.z.string().optional()
1266
1817
  })
1267
1818
  );
1268
1819
  var DeclareAction = ActionBase.merge(
1269
- import_zod15.z.object({
1270
- type: import_zod15.z.literal(ActionType.DECLARE)
1820
+ import_zod18.z.object({
1821
+ type: import_zod18.z.literal(ActionType.DECLARE)
1271
1822
  })
1272
1823
  );
1273
1824
  var ValidateAction = ActionBase.merge(
1274
- import_zod15.z.object({
1275
- type: import_zod15.z.literal(ActionType.VALIDATE)
1825
+ import_zod18.z.object({
1826
+ type: import_zod18.z.literal(ActionType.VALIDATE)
1276
1827
  })
1277
1828
  );
1829
+ var RejectionReason = import_zod18.z.object({
1830
+ message: import_zod18.z.string().min(1, { message: "Message cannot be empty" }).describe("Message describing reason for rejection or archiving"),
1831
+ isDuplicate: import_zod18.z.boolean().optional().describe("If a declaration is duplicated")
1832
+ });
1278
1833
  var RejectAction = ActionBase.merge(
1279
- import_zod15.z.object({
1280
- type: import_zod15.z.literal(ActionType.REJECT)
1834
+ import_zod18.z.object({
1835
+ type: import_zod18.z.literal(ActionType.REJECT),
1836
+ reason: RejectionReason
1281
1837
  })
1282
1838
  );
1283
1839
  var MarkAsDuplicateAction = ActionBase.merge(
1284
- import_zod15.z.object({
1285
- type: import_zod15.z.literal(ActionType.MARKED_AS_DUPLICATE)
1840
+ import_zod18.z.object({
1841
+ type: import_zod18.z.literal(ActionType.MARKED_AS_DUPLICATE)
1286
1842
  })
1287
1843
  );
1288
1844
  var ArchiveAction = ActionBase.merge(
1289
- import_zod15.z.object({
1290
- type: import_zod15.z.literal(ActionType.ARCHIVE)
1845
+ import_zod18.z.object({
1846
+ type: import_zod18.z.literal(ActionType.ARCHIVE),
1847
+ reason: RejectionReason
1291
1848
  })
1292
1849
  );
1293
1850
  var CreatedAction = ActionBase.merge(
1294
- import_zod15.z.object({
1295
- type: import_zod15.z.literal(ActionType.CREATE)
1851
+ import_zod18.z.object({
1852
+ type: import_zod18.z.literal(ActionType.CREATE)
1296
1853
  })
1297
1854
  );
1298
1855
  var NotifiedAction = ActionBase.merge(
1299
- import_zod15.z.object({
1300
- type: import_zod15.z.literal(ActionType.NOTIFY)
1856
+ import_zod18.z.object({
1857
+ type: import_zod18.z.literal(ActionType.NOTIFY)
1301
1858
  })
1302
1859
  );
1303
1860
  var PrintCertificateAction = ActionBase.merge(
1304
- import_zod15.z.object({
1305
- type: import_zod15.z.literal(ActionType.PRINT_CERTIFICATE)
1861
+ import_zod18.z.object({
1862
+ type: import_zod18.z.literal(ActionType.PRINT_CERTIFICATE)
1306
1863
  })
1307
1864
  );
1308
1865
  var RequestedCorrectionAction = ActionBase.merge(
1309
- import_zod15.z.object({
1310
- type: import_zod15.z.literal(ActionType.REQUEST_CORRECTION)
1866
+ import_zod18.z.object({
1867
+ type: import_zod18.z.literal(ActionType.REQUEST_CORRECTION)
1311
1868
  })
1312
1869
  );
1313
1870
  var ApprovedCorrectionAction = ActionBase.merge(
1314
- import_zod15.z.object({
1315
- type: import_zod15.z.literal(ActionType.APPROVE_CORRECTION),
1316
- requestId: import_zod15.z.string()
1871
+ import_zod18.z.object({
1872
+ type: import_zod18.z.literal(ActionType.APPROVE_CORRECTION),
1873
+ requestId: import_zod18.z.string()
1317
1874
  })
1318
1875
  );
1319
1876
  var RejectedCorrectionAction = ActionBase.merge(
1320
- import_zod15.z.object({
1321
- type: import_zod15.z.literal(ActionType.REJECT_CORRECTION),
1322
- requestId: import_zod15.z.string()
1877
+ import_zod18.z.object({
1878
+ type: import_zod18.z.literal(ActionType.REJECT_CORRECTION),
1879
+ requestId: import_zod18.z.string()
1323
1880
  })
1324
1881
  );
1325
1882
  var ReadAction = ActionBase.merge(
1326
- import_zod15.z.object({
1327
- type: import_zod15.z.literal(ActionType.READ)
1883
+ import_zod18.z.object({
1884
+ type: import_zod18.z.literal(ActionType.READ)
1328
1885
  })
1329
1886
  );
1330
- var ActionDocument = import_zod15.z.discriminatedUnion("type", [
1887
+ var ActionDocument = import_zod18.z.discriminatedUnion("type", [
1331
1888
  CreatedAction.openapi({ ref: "CreatedAction" }),
1332
1889
  ValidateAction.openapi({ ref: "ValidateAction" }),
1333
1890
  RejectAction.openapi({ ref: "RejectAction" }),
@@ -1350,20 +1907,20 @@ var AsyncRejectActionDocument = ActionBase.omit({
1350
1907
  declaration: true,
1351
1908
  annotation: true
1352
1909
  }).merge(
1353
- import_zod15.z.object({
1354
- type: import_zod15.z.enum(ConfirmableActions),
1355
- status: import_zod15.z.literal(ActionStatus.Rejected)
1910
+ import_zod18.z.object({
1911
+ type: import_zod18.z.enum(ConfirmableActions),
1912
+ status: import_zod18.z.literal(ActionStatus.Rejected)
1356
1913
  })
1357
1914
  );
1358
- var Action = import_zod15.z.union([ActionDocument, AsyncRejectActionDocument]);
1359
- var ResolvedUser = import_zod15.z.object({
1360
- id: import_zod15.z.string(),
1361
- role: import_zod15.z.string(),
1362
- name: import_zod15.z.array(
1363
- import_zod15.z.object({
1364
- use: import_zod15.z.string(),
1365
- given: import_zod15.z.array(import_zod15.z.string()),
1366
- family: import_zod15.z.string()
1915
+ var Action = import_zod18.z.union([ActionDocument, AsyncRejectActionDocument]);
1916
+ var ResolvedUser = import_zod18.z.object({
1917
+ id: import_zod18.z.string(),
1918
+ role: import_zod18.z.string(),
1919
+ name: import_zod18.z.array(
1920
+ import_zod18.z.object({
1921
+ use: import_zod18.z.string(),
1922
+ given: import_zod18.z.array(import_zod18.z.string()),
1923
+ family: import_zod18.z.string()
1367
1924
  })
1368
1925
  )
1369
1926
  });
@@ -1374,7 +1931,7 @@ var import_ajv_formats = __toESM(require("ajv-formats"));
1374
1931
  var import_date_fns = require("date-fns");
1375
1932
 
1376
1933
  // ../commons/src/events/FieldTypeMapping.ts
1377
- var import_zod16 = require("zod");
1934
+ var import_zod19 = require("zod");
1378
1935
  function mapFieldTypeToZod(type, required) {
1379
1936
  let schema;
1380
1937
  switch (type) {
@@ -1400,7 +1957,8 @@ function mapFieldTypeToZod(type, required) {
1400
1957
  case FieldType.ADMINISTRATIVE_AREA:
1401
1958
  case FieldType.FACILITY:
1402
1959
  case FieldType.OFFICE:
1403
- case FieldType.SIGNATURE:
1960
+ case FieldType.PHONE:
1961
+ case FieldType.ID:
1404
1962
  schema = required ? NonEmptyTextValue : TextValue;
1405
1963
  break;
1406
1964
  case FieldType.NUMBER:
@@ -1409,6 +1967,7 @@ function mapFieldTypeToZod(type, required) {
1409
1967
  case FieldType.CHECKBOX:
1410
1968
  schema = CheckboxFieldValue;
1411
1969
  break;
1970
+ case FieldType.SIGNATURE:
1412
1971
  case FieldType.FILE:
1413
1972
  schema = FileFieldValue;
1414
1973
  break;
@@ -1421,6 +1980,9 @@ function mapFieldTypeToZod(type, required) {
1421
1980
  case FieldType.DATA:
1422
1981
  schema = DataFieldValue;
1423
1982
  break;
1983
+ case FieldType.NAME:
1984
+ schema = required ? NameFieldValue : NameFieldUpdateValue;
1985
+ break;
1424
1986
  }
1425
1987
  return required ? schema : schema.nullish();
1426
1988
  }
@@ -1429,9 +1991,9 @@ function createValidationSchema(config) {
1429
1991
  for (const field2 of config) {
1430
1992
  shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
1431
1993
  }
1432
- return import_zod16.z.object(shape);
1994
+ return import_zod19.z.object(shape);
1433
1995
  }
1434
- function mapFieldTypeToMockValue(field2, i) {
1996
+ function mapFieldTypeToEmptyValue(field2) {
1435
1997
  switch (field2.type) {
1436
1998
  case FieldType.DIVIDER:
1437
1999
  case FieldType.TEXT:
@@ -1442,84 +2004,35 @@ function mapFieldTypeToMockValue(field2, i) {
1442
2004
  case FieldType.SELECT:
1443
2005
  case FieldType.COUNTRY:
1444
2006
  case FieldType.RADIO_GROUP:
1445
- case FieldType.SIGNATURE:
1446
2007
  case FieldType.PARAGRAPH:
1447
2008
  case FieldType.ADMINISTRATIVE_AREA:
1448
2009
  case FieldType.FACILITY:
1449
2010
  case FieldType.OFFICE:
1450
- return `${field2.id}-${field2.type}-${i}`;
1451
2011
  case FieldType.NUMBER:
1452
- return 19;
1453
2012
  case FieldType.EMAIL:
1454
- return "test@opencrvs.org";
2013
+ case FieldType.DATE:
2014
+ case FieldType.CHECKBOX:
2015
+ case FieldType.DATE_RANGE:
2016
+ case FieldType.DATA:
2017
+ case FieldType.NAME:
2018
+ case FieldType.PHONE:
2019
+ case FieldType.ID:
2020
+ return null;
1455
2021
  case FieldType.ADDRESS:
1456
2022
  return {
1457
- country: "FAR",
2023
+ country: null,
1458
2024
  addressType: AddressType.DOMESTIC,
1459
- province: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
1460
- district: "5ef450bc-712d-48ad-93f3-8da0fa453baa",
2025
+ province: null,
2026
+ district: null,
1461
2027
  urbanOrRural: "URBAN",
1462
- town: "Example Town",
1463
- residentialArea: "Example Residential Area",
1464
- street: "Example Street",
1465
- number: "55",
1466
- zipCode: "123456"
2028
+ // Default to urban needed for validation
2029
+ town: null,
2030
+ residentialArea: null,
2031
+ street: null,
2032
+ number: null,
2033
+ zipCode: null
1467
2034
  };
1468
- case FieldType.DATE:
1469
- return "2021-01-01";
1470
- case FieldType.DATE_RANGE:
1471
- return ["2021-01-01", "2021-01-02"];
1472
- case FieldType.CHECKBOX:
1473
- return true;
1474
- case FieldType.FILE:
1475
- return {
1476
- filename: "4f095fc4-4312-4de2-aa38-86dcc0f71044.png",
1477
- originalFilename: "abcd.png",
1478
- type: "image/png"
1479
- };
1480
- case FieldType.FILE_WITH_OPTIONS:
1481
- return null;
1482
- case FieldType.DATA:
1483
- return {};
1484
- }
1485
- }
1486
- function mapFieldTypeToEmptyValue(field2) {
1487
- switch (field2.type) {
1488
- case FieldType.DIVIDER:
1489
- case FieldType.TEXT:
1490
- case FieldType.TEXTAREA:
1491
- case FieldType.BULLET_LIST:
1492
- case FieldType.PAGE_HEADER:
1493
- case FieldType.LOCATION:
1494
- case FieldType.SELECT:
1495
- case FieldType.COUNTRY:
1496
- case FieldType.RADIO_GROUP:
1497
2035
  case FieldType.SIGNATURE:
1498
- case FieldType.PARAGRAPH:
1499
- case FieldType.ADMINISTRATIVE_AREA:
1500
- case FieldType.FACILITY:
1501
- case FieldType.OFFICE:
1502
- case FieldType.NUMBER:
1503
- case FieldType.EMAIL:
1504
- case FieldType.DATE:
1505
- case FieldType.CHECKBOX:
1506
- case FieldType.DATE_RANGE:
1507
- case FieldType.DATA:
1508
- return null;
1509
- case FieldType.ADDRESS:
1510
- return {
1511
- country: null,
1512
- addressType: AddressType.DOMESTIC,
1513
- province: null,
1514
- district: null,
1515
- urbanOrRural: "URBAN",
1516
- // Default to urban needed for validation
1517
- town: null,
1518
- residentialArea: null,
1519
- street: null,
1520
- number: null,
1521
- zipCode: null
1522
- };
1523
2036
  case FieldType.FILE:
1524
2037
  return {
1525
2038
  filename: "",
@@ -1548,6 +2061,15 @@ var isTextFieldType = (field2) => {
1548
2061
  var isNumberFieldType = (field2) => {
1549
2062
  return field2.config.type === FieldType.NUMBER;
1550
2063
  };
2064
+ var isNameFieldType = (field2) => {
2065
+ return field2.config.type === FieldType.NAME;
2066
+ };
2067
+ var isPhoneFieldType = (field2) => {
2068
+ return field2.config.type === FieldType.PHONE;
2069
+ };
2070
+ var isIdFieldType = (field2) => {
2071
+ return field2.config.type === FieldType.ID;
2072
+ };
1551
2073
  var isTextAreaFieldType = (field2) => {
1552
2074
  return field2.config.type === FieldType.TEXTAREA;
1553
2075
  };
@@ -1599,6 +2121,9 @@ var isOfficeFieldType = (field2) => {
1599
2121
  var isDataFieldType = (field2) => {
1600
2122
  return field2.config.type === FieldType.DATA;
1601
2123
  };
2124
+ var isNonInteractiveFieldType = (field2) => {
2125
+ return field2.type === FieldType.DIVIDER || field2.type === FieldType.PAGE_HEADER || field2.type === FieldType.PARAGRAPH || field2.type === FieldType.BULLET_LIST || field2.type === FieldType.DATA;
2126
+ };
1602
2127
 
1603
2128
  // ../commons/src/conditionals/validate.ts
1604
2129
  var ajv = new import_ajv.default({
@@ -1679,6 +2204,11 @@ var errorMessages = {
1679
2204
  defaultMessage: "Invalid input",
1680
2205
  description: "Error message when generic field is invalid",
1681
2206
  id: "v2.error.invalid"
2207
+ },
2208
+ unexpectedField: {
2209
+ defaultMessage: "Unexpected field",
2210
+ description: "Error message when field is not expected",
2211
+ id: "v2.error.unexpectedField"
1682
2212
  }
1683
2213
  };
1684
2214
  function createIntlError(message) {
@@ -1774,6 +2304,45 @@ function runFieldValidations({
1774
2304
  errors: [...fieldValidationResult, ...customValidationResults]
1775
2305
  };
1776
2306
  }
2307
+ function getValidatorsForField(fieldId, validations) {
2308
+ return validations.map(({ validator, message }) => {
2309
+ const jsonSchema = validator;
2310
+ const $form = jsonSchema.properties.$form;
2311
+ if ($form.properties?.[fieldId]?.type === "object") {
2312
+ return {
2313
+ message,
2314
+ validator: {
2315
+ ...jsonSchema,
2316
+ properties: {
2317
+ $form: {
2318
+ type: "object",
2319
+ properties: $form.properties?.[fieldId]?.properties || {},
2320
+ required: $form.properties?.[fieldId]?.required || []
2321
+ }
2322
+ }
2323
+ }
2324
+ };
2325
+ }
2326
+ if (!$form.properties?.[fieldId]) {
2327
+ return null;
2328
+ }
2329
+ return {
2330
+ message,
2331
+ validator: {
2332
+ ...jsonSchema,
2333
+ properties: {
2334
+ $form: {
2335
+ type: "object",
2336
+ properties: {
2337
+ [fieldId]: $form.properties?.[fieldId]
2338
+ },
2339
+ required: $form.required?.includes(fieldId) ? [fieldId] : []
2340
+ }
2341
+ }
2342
+ }
2343
+ };
2344
+ }).filter((x) => x !== null);
2345
+ }
1777
2346
 
1778
2347
  // ../commons/src/uuid.ts
1779
2348
  var import_uuid = require("uuid");
@@ -1820,6 +2389,13 @@ var getActionAnnotationFields = (actionConfig) => {
1820
2389
  function getAllAnnotationFields(config) {
1821
2390
  return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
1822
2391
  }
2392
+ function getAllUniqueFields(eventConfig) {
2393
+ return (0, import_lodash.uniqBy)(getDeclarationFields(eventConfig), (field2) => field2.id);
2394
+ }
2395
+ function getDeclarationFieldById(config, fieldId) {
2396
+ const field2 = getAllUniqueFields(config).find((f) => f.id === fieldId);
2397
+ return getOrThrow(field2, `Field with id ${fieldId} not found in event config`);
2398
+ }
1823
2399
  var findRecordActionPages = (config, actionType) => {
1824
2400
  const action = config.actions.find((a) => a.type === actionType);
1825
2401
  if (action?.type === ActionType.REQUEST_CORRECTION) {
@@ -1880,6 +2456,7 @@ function createEmptyDraft(eventId, draftId, actionType) {
1880
2456
  declaration: {},
1881
2457
  annotation: {},
1882
2458
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2459
+ createdByUserType: TokenUserType.Enum.user,
1883
2460
  createdBy: "@todo",
1884
2461
  createdAtLocation: "@todo",
1885
2462
  status: ActionStatus.Accepted,
@@ -1925,8 +2502,9 @@ function omitHiddenAnnotationFields(actionConfig, declaration, annotation) {
1925
2502
  );
1926
2503
  }
1927
2504
  function deepMerge(currentDocument, actionDocument) {
2505
+ const currentDocumentClone = (0, import_lodash.cloneDeep)(currentDocument);
1928
2506
  return (0, import_lodash.mergeWith)(
1929
- currentDocument,
2507
+ (0, import_lodash.cloneDeep)(currentDocumentClone),
1930
2508
  actionDocument,
1931
2509
  (previousValue, incomingValue) => {
1932
2510
  if (incomingValue === void 0) {
@@ -1974,25 +2552,31 @@ function getMixedPath(obj, path, defaultValue) {
1974
2552
  const result = resolve(obj, parts);
1975
2553
  return (0, import_lodash.isNil)(result) ? defaultValue : result;
1976
2554
  }
2555
+ function getEventConfigById(eventConfigs, id) {
2556
+ const eventConfig = eventConfigs.find(
2557
+ (eventConfiguration) => eventConfiguration.id === id
2558
+ );
2559
+ return getOrThrow(eventConfig, `Event config for ${id} not found`);
2560
+ }
1977
2561
 
1978
2562
  // ../commons/src/events/EventConfig.ts
1979
2563
  var import_zod_openapi8 = require("zod-openapi");
1980
- (0, import_zod_openapi8.extendZodWithOpenApi)(import_zod17.z);
1981
- var EventConfig = import_zod17.z.object({
1982
- id: import_zod17.z.string().describe(
2564
+ (0, import_zod_openapi8.extendZodWithOpenApi)(import_zod20.z);
2565
+ var EventConfig = import_zod20.z.object({
2566
+ id: import_zod20.z.string().describe(
1983
2567
  'A machine-readable identifier for the event, e.g. "birth" or "death"'
1984
2568
  ),
1985
- dateOfEvent: import_zod17.z.object({ fieldId: import_zod17.z.string() }).optional(),
2569
+ dateOfEvent: FieldReference.optional(),
1986
2570
  title: TranslationConfig,
1987
2571
  fallbackTitle: TranslationConfig.optional().describe(
1988
2572
  "This is a fallback title if actual title resolves to empty string"
1989
2573
  ),
1990
2574
  summary: SummaryConfig,
1991
2575
  label: TranslationConfig,
1992
- actions: import_zod17.z.array(ActionConfig),
2576
+ actions: import_zod20.z.array(ActionConfig),
1993
2577
  declaration: DeclarationFormConfig,
1994
- deduplication: import_zod17.z.array(DeduplicationConfig).optional().default([]),
1995
- advancedSearch: import_zod17.z.array(AdvancedSearchConfig).optional().default([])
2578
+ deduplication: import_zod20.z.array(DeduplicationConfig).optional().default([]),
2579
+ advancedSearch: import_zod20.z.array(AdvancedSearchConfig).optional().default([])
1996
2580
  }).superRefine((event2, ctx) => {
1997
2581
  const allFields = findAllFields(event2);
1998
2582
  const fieldIds = allFields.map((field2) => field2.id);
@@ -2026,13 +2610,13 @@ var EventConfig = import_zod17.z.object({
2026
2610
  }
2027
2611
  if (event2.dateOfEvent) {
2028
2612
  const eventDateFieldId = getDeclarationFields(event2).find(
2029
- ({ id }) => id === event2.dateOfEvent?.fieldId
2613
+ ({ id }) => id === event2.dateOfEvent?.$$field
2030
2614
  );
2031
2615
  if (!eventDateFieldId) {
2032
2616
  ctx.addIssue({
2033
2617
  code: "custom",
2034
2618
  message: `Date of event field id must match a field id in fields array.
2035
- Invalid date of event field ID for event ${event2.id}: ${event2.dateOfEvent.fieldId}`,
2619
+ Invalid date of event field ID for event ${event2.id}: ${event2.dateOfEvent.$$field}`,
2036
2620
  path: ["dateOfEvent"]
2037
2621
  });
2038
2622
  } else if (eventDateFieldId.type !== FieldType.DATE) {
@@ -2054,12 +2638,12 @@ var definePage = (page) => PageConfig.parse(page);
2054
2638
  var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
2055
2639
 
2056
2640
  // ../commons/src/events/WorkqueueConfig.ts
2057
- var import_zod24 = require("zod");
2641
+ var import_zod27 = require("zod");
2058
2642
 
2059
2643
  // ../commons/src/events/serializers/user/serializer.ts
2060
- var import_zod18 = require("zod");
2061
- var SerializedUserField = import_zod18.z.object({
2062
- $userField: import_zod18.z.enum([
2644
+ var import_zod21 = require("zod");
2645
+ var SerializedUserField = import_zod21.z.object({
2646
+ $userField: import_zod21.z.enum([
2063
2647
  "id",
2064
2648
  "name",
2065
2649
  "role",
@@ -2185,7 +2769,7 @@ function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
2185
2769
  };
2186
2770
  }
2187
2771
  function isFieldReference(value) {
2188
- return typeof value === "object" && value !== null && "_fieldId" in value;
2772
+ return typeof value === "object" && value !== null && "$$field" in value;
2189
2773
  }
2190
2774
  function createFieldConditionals(fieldId) {
2191
2775
  const getDateRange = (date, clause) => ({
@@ -2200,6 +2784,10 @@ function createFieldConditionals(fieldId) {
2200
2784
  required: [fieldId]
2201
2785
  });
2202
2786
  return {
2787
+ /**
2788
+ * @private Internal property used for field reference tracking.
2789
+ */
2790
+ $$field: fieldId,
2203
2791
  isAfter: () => ({
2204
2792
  days: (days) => ({
2205
2793
  inPast: () => defineFormConditional(
@@ -2211,7 +2799,7 @@ function createFieldConditionals(fieldId) {
2211
2799
  }),
2212
2800
  date: (date) => {
2213
2801
  if (isFieldReference(date)) {
2214
- const comparedFieldId = date._fieldId;
2802
+ const comparedFieldId = date.$$field;
2215
2803
  return defineFormConditional(
2216
2804
  getDateRangeToFieldReference(
2217
2805
  fieldId,
@@ -2235,7 +2823,7 @@ function createFieldConditionals(fieldId) {
2235
2823
  }),
2236
2824
  date: (date) => {
2237
2825
  if (isFieldReference(date)) {
2238
- const comparedFieldId = date._fieldId;
2826
+ const comparedFieldId = date.$$field;
2239
2827
  return defineFormConditional(
2240
2828
  getDateRangeToFieldReference(
2241
2829
  fieldId,
@@ -2250,13 +2838,13 @@ function createFieldConditionals(fieldId) {
2250
2838
  }),
2251
2839
  isEqualTo: (value) => {
2252
2840
  if (isFieldReference(value)) {
2253
- const comparedFieldId = value._fieldId;
2841
+ const comparedFieldId = value.$$field;
2254
2842
  return defineFormConditional({
2255
2843
  type: "object",
2256
2844
  properties: {
2257
2845
  [fieldId]: {
2258
2846
  type: ["string", "boolean"],
2259
- const: { $data: `1/${comparedFieldId}` }
2847
+ const: { $data: `/$form/${comparedFieldId}` }
2260
2848
  },
2261
2849
  [comparedFieldId]: { type: ["string", "boolean"] }
2262
2850
  },
@@ -2367,7 +2955,23 @@ function createFieldConditionals(fieldId) {
2367
2955
  },
2368
2956
  required: [fieldId]
2369
2957
  }),
2370
- getId: () => ({ fieldId })
2958
+ getId: () => ({ fieldId }),
2959
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2960
+ object: (options) => defineFormConditional({
2961
+ type: "object",
2962
+ properties: {
2963
+ [fieldId]: {
2964
+ type: "object",
2965
+ properties: Object.fromEntries(
2966
+ Object.entries(options).map(([key, value]) => {
2967
+ return [key, value.properties.$form.properties[key]];
2968
+ })
2969
+ ),
2970
+ required: Object.keys(options)
2971
+ }
2972
+ },
2973
+ required: [fieldId]
2974
+ })
2371
2975
  };
2372
2976
  }
2373
2977
 
@@ -2442,89 +3046,87 @@ var event = Object.assign(eventFn, {
2442
3046
  });
2443
3047
 
2444
3048
  // ../commons/src/events/WorkqueueColumnConfig.ts
2445
- var import_zod20 = require("zod");
3049
+ var import_zod23 = require("zod");
2446
3050
 
2447
3051
  // ../commons/src/events/EventMetadata.ts
2448
- var import_zod19 = require("zod");
2449
- var EventStatus = {
2450
- CREATED: "CREATED",
2451
- NOTIFIED: "NOTIFIED",
2452
- DECLARED: "DECLARED",
2453
- VALIDATED: "VALIDATED",
2454
- REGISTERED: "REGISTERED",
2455
- CERTIFIED: "CERTIFIED",
2456
- REJECTED: "REJECTED",
2457
- ARCHIVED: "ARCHIVED"
2458
- };
2459
- var eventStatusValues = [
2460
- EventStatus.CREATED,
2461
- EventStatus.NOTIFIED,
2462
- EventStatus.DECLARED,
2463
- EventStatus.VALIDATED,
2464
- EventStatus.REGISTERED,
2465
- EventStatus.CERTIFIED,
2466
- EventStatus.REJECTED,
2467
- EventStatus.ARCHIVED
2468
- ];
2469
- var EventStatusEnum = import_zod19.z.enum(eventStatusValues);
3052
+ var import_zod22 = require("zod");
3053
+ var EventStatus = import_zod22.z.enum([
3054
+ "CREATED",
3055
+ "NOTIFIED",
3056
+ "DECLARED",
3057
+ "VALIDATED",
3058
+ "REGISTERED",
3059
+ "CERTIFIED",
3060
+ "REJECTED",
3061
+ "ARCHIVED"
3062
+ ]);
2470
3063
  var CustomFlags = {
2471
3064
  CERTIFICATE_PRINTED: "certificate-printed"
2472
3065
  };
2473
- var Flag = import_zod19.z.string().regex(
3066
+ var Flag = import_zod22.z.string().regex(
2474
3067
  new RegExp(
2475
- `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(ActionStatus).join("|").toLowerCase()})$`
3068
+ `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
3069
+ ActionStatus
3070
+ ).join("|").toLowerCase()})$`
2476
3071
  ),
2477
3072
  "Flag must be in the format ActionType:ActionStatus (lowerCase)"
2478
- ).or(import_zod19.z.nativeEnum(CustomFlags));
2479
- var eventStatuses = Object.values(EventStatus);
2480
- var EventStatuses = import_zod19.z.nativeEnum(EventStatus);
2481
- var ZodDate = import_zod19.z.string().date();
2482
- var ActionCreationMetadata = import_zod19.z.object({
2483
- createdAt: import_zod19.z.string().datetime().describe("The timestamp when the action request was created."),
2484
- createdBy: import_zod19.z.string().describe("ID of the user who created the action request."),
2485
- createdAtLocation: import_zod19.z.string().describe("Location of the user who created the action request."),
2486
- acceptedAt: import_zod19.z.string().datetime().describe("Timestamp when the action request was accepted."),
2487
- createdByRole: import_zod19.z.string().describe("Role of the user at the time of action request creation.")
3073
+ ).or(import_zod22.z.nativeEnum(CustomFlags));
3074
+ var ZodDate = import_zod22.z.string().date();
3075
+ var ActionCreationMetadata = import_zod22.z.object({
3076
+ createdAt: import_zod22.z.string().datetime().describe("The timestamp when the action request was created."),
3077
+ createdBy: import_zod22.z.string().describe("ID of the user who created the action request."),
3078
+ createdAtLocation: CreatedAtLocation.describe(
3079
+ "Location of the user who created the action request."
3080
+ ),
3081
+ createdByUserType: import_zod22.z.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
3082
+ acceptedAt: import_zod22.z.string().datetime().describe("Timestamp when the action request was accepted."),
3083
+ createdByRole: import_zod22.z.string().describe("Role of the user at the time of action request creation."),
3084
+ createdBySignature: import_zod22.z.string().nullish().describe("Signature of the user who created the action request.")
2488
3085
  });
2489
3086
  var RegistrationCreationMetadata = ActionCreationMetadata.extend({
2490
- registrationNumber: import_zod19.z.string().describe(
3087
+ registrationNumber: import_zod22.z.string().describe(
2491
3088
  "Registration number of the event. Always present for accepted registrations."
2492
3089
  )
2493
3090
  });
2494
- var LegalStatuses = import_zod19.z.object({
2495
- [EventStatus.DECLARED]: ActionCreationMetadata.nullish(),
2496
- [EventStatus.REGISTERED]: RegistrationCreationMetadata.nullish()
3091
+ var LegalStatuses = import_zod22.z.object({
3092
+ [EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
3093
+ [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
2497
3094
  });
2498
- var EventMetadata = import_zod19.z.object({
2499
- id: import_zod19.z.string(),
2500
- title: import_zod19.z.string(),
2501
- type: import_zod19.z.string().describe("The type of event, such as birth, death, or marriage."),
2502
- status: EventStatuses,
3095
+ var EventMetadata = import_zod22.z.object({
3096
+ id: import_zod22.z.string(),
3097
+ type: import_zod22.z.string().describe("The type of event, such as birth, death, or marriage."),
3098
+ status: EventStatus,
2503
3099
  legalStatuses: LegalStatuses.describe(
2504
3100
  "Metadata related to the legal registration of the event, such as who registered it and when."
2505
3101
  ),
2506
- createdAt: import_zod19.z.string().datetime().describe("The timestamp when the event was first created and saved."),
3102
+ createdAt: import_zod22.z.string().datetime().describe("The timestamp when the event was first created and saved."),
2507
3103
  dateOfEvent: ZodDate.nullish(),
2508
- createdBy: import_zod19.z.string().describe("ID of the user who created the event."),
2509
- updatedByUserRole: import_zod19.z.string().describe("Role of the user who last updated the declaration."),
2510
- createdAtLocation: import_zod19.z.string().describe("Location of the user who created the event."),
2511
- updatedAtLocation: import_zod19.z.string().nullish().describe("Location of the user who last updated the declaration."),
2512
- updatedAt: import_zod19.z.string().datetime().describe("Timestamp of the most recent declaration update."),
2513
- assignedTo: import_zod19.z.string().nullish().describe("ID of the user currently assigned to the event."),
2514
- updatedBy: import_zod19.z.string().nullish().describe("ID of the user who last updated the declaration."),
2515
- trackingId: import_zod19.z.string().describe(
3104
+ createdBy: import_zod22.z.string().describe("ID of the user who created the event."),
3105
+ createdByUserType: import_zod22.z.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
3106
+ updatedByUserRole: import_zod22.z.string().describe("Role of the user who last changed the status."),
3107
+ createdAtLocation: CreatedAtLocation.describe(
3108
+ "Location of the user who created the event."
3109
+ ),
3110
+ createdBySignature: import_zod22.z.string().nullish().describe("Signature of the user who created the event."),
3111
+ updatedAtLocation: import_zod22.z.string().nullish().describe("Location of the user who last changed the status."),
3112
+ updatedAt: import_zod22.z.string().datetime().describe(
3113
+ "Timestamp of the most recent *accepted* status change. Possibly 3rd party update, if action is validation asynchronously."
3114
+ ),
3115
+ assignedTo: import_zod22.z.string().nullish().describe("ID of the user currently assigned to the event."),
3116
+ updatedBy: import_zod22.z.string().nullish().describe("ID of the user who last changed the status."),
3117
+ trackingId: import_zod22.z.string().describe(
2516
3118
  "System-generated tracking ID used by informants or registrars to look up the event."
2517
3119
  ),
2518
- flags: import_zod19.z.array(Flag)
3120
+ flags: import_zod22.z.array(Flag)
2519
3121
  });
2520
- var EventMetadataKeys = import_zod19.z.enum([
3122
+ var EventMetadataKeysArray = [
2521
3123
  "id",
2522
- "title",
2523
3124
  "type",
2524
3125
  "status",
2525
3126
  "createdAt",
2526
3127
  "dateOfEvent",
2527
3128
  "createdBy",
3129
+ "createdByUserType",
2528
3130
  "updatedByUserRole",
2529
3131
  "createdAtLocation",
2530
3132
  "updatedAtLocation",
@@ -2534,27 +3136,24 @@ var EventMetadataKeys = import_zod19.z.enum([
2534
3136
  "trackingId",
2535
3137
  "legalStatuses",
2536
3138
  "flags"
2537
- ]);
2538
- var EventMetadataParameter = import_zod19.z.object({
2539
- // @TODO: Reconcile with the event metadata definition. How could we derive one from the other?
2540
- $event: EventMetadataKeys
2541
- });
3139
+ ];
3140
+ var EventMetadataKeys = import_zod22.z.enum(EventMetadataKeysArray);
2542
3141
  var eventMetadataLabelMap = {
2543
3142
  "event.assignedTo": {
2544
3143
  id: "event.assignedTo.label",
2545
3144
  defaultMessage: "Assigned To",
2546
3145
  description: "Assigned To"
2547
3146
  },
2548
- "event.title": {
2549
- id: "event.title.label",
2550
- defaultMessage: "Title",
2551
- description: "Title"
2552
- },
2553
3147
  "event.createdAt": {
2554
3148
  id: "event.createdAt.label",
2555
3149
  defaultMessage: "Created",
2556
3150
  description: "Created At"
2557
3151
  },
3152
+ "event.createdByUserType": {
3153
+ id: "event.createdByUserType.label",
3154
+ defaultMessage: "createdByUserType",
3155
+ description: "createdByUserType:user or system"
3156
+ },
2558
3157
  "event.dateOfEvent": {
2559
3158
  id: "event.dateOfEvent.label",
2560
3159
  defaultMessage: "Date of Event",
@@ -2618,9 +3217,18 @@ var eventMetadataLabelMap = {
2618
3217
  };
2619
3218
 
2620
3219
  // ../commons/src/events/WorkqueueColumnConfig.ts
2621
- var WorkqueueColumn = import_zod20.z.object({
3220
+ var WorkqueueColumnKeysArray = [
3221
+ ...EventMetadataKeysArray,
3222
+ "title",
3223
+ "outbox"
3224
+ ];
3225
+ var WorkqueueColumnKeys = import_zod23.z.enum(WorkqueueColumnKeysArray);
3226
+ var WorkqueueColumnValue = import_zod23.z.object({
3227
+ $event: WorkqueueColumnKeys
3228
+ });
3229
+ var WorkqueueColumn = import_zod23.z.object({
2622
3230
  label: TranslationConfig,
2623
- value: EventMetadataParameter
3231
+ value: WorkqueueColumnValue
2624
3232
  });
2625
3233
  function defineWorkqueuesColumns(workqueueColumns) {
2626
3234
  return workqueueColumns.map(
@@ -2629,80 +3237,189 @@ function defineWorkqueuesColumns(workqueueColumns) {
2629
3237
  }
2630
3238
 
2631
3239
  // ../commons/src/events/CountryConfigQueryInput.ts
2632
- var import_zod21 = require("zod");
2633
- var Fuzzy = import_zod21.z.object({ type: import_zod21.z.literal("fuzzy"), term: import_zod21.z.string() });
2634
- var Exact = import_zod21.z.object({ type: import_zod21.z.literal("exact"), term: import_zod21.z.string() });
2635
- var AnyOf = import_zod21.z.object({
2636
- type: import_zod21.z.literal("anyOf"),
2637
- terms: import_zod21.z.array(import_zod21.z.string())
3240
+ var import_zod25 = require("zod");
3241
+
3242
+ // ../commons/src/events/EventIndex.ts
3243
+ var import_zod24 = require("zod");
3244
+ var import_zod_openapi9 = require("zod-openapi");
3245
+ (0, import_zod_openapi9.extendZodWithOpenApi)(import_zod24.z);
3246
+ var EventIndex = EventMetadata.extend({
3247
+ declaration: EventState
3248
+ }).openapi({
3249
+ ref: "EventIndex"
3250
+ });
3251
+ var EventSearchIndex = import_zod24.z.record(import_zod24.z.string(), import_zod24.z.any()).and(
3252
+ import_zod24.z.object({
3253
+ type: import_zod24.z.string()
3254
+ // Ensures "type" (event-id) exists and is a string
3255
+ })
3256
+ ).openapi({
3257
+ ref: "EventSearchIndex"
3258
+ });
3259
+ var Fuzzy = import_zod24.z.object({ type: import_zod24.z.literal("fuzzy"), term: import_zod24.z.string() }).openapi({
3260
+ ref: "Fuzzy"
2638
3261
  });
2639
- var AnyOfStatus = import_zod21.z.object({
2640
- type: import_zod21.z.literal("anyOf"),
2641
- terms: import_zod21.z.array(EventStatusEnum)
3262
+ var Exact = import_zod24.z.object({ type: import_zod24.z.literal("exact"), term: import_zod24.z.string() }).openapi({
3263
+ ref: "Exact"
2642
3264
  });
2643
- var SerializableExact = import_zod21.z.object({
2644
- type: import_zod21.z.literal("exact"),
2645
- term: import_zod21.z.union([import_zod21.z.string(), SerializedUserField])
3265
+ var ExactStatus = import_zod24.z.object({
3266
+ type: import_zod24.z.literal("exact"),
3267
+ term: EventStatus
3268
+ }).openapi({
3269
+ ref: "ExactStatus"
3270
+ });
3271
+ var AnyOf = import_zod24.z.object({
3272
+ type: import_zod24.z.literal("anyOf"),
3273
+ terms: import_zod24.z.array(import_zod24.z.string())
3274
+ }).openapi({
3275
+ ref: "AnyOf"
3276
+ });
3277
+ var AnyOfStatus = import_zod24.z.object({
3278
+ type: import_zod24.z.literal("anyOf"),
3279
+ terms: import_zod24.z.array(EventStatus)
3280
+ }).openapi({
3281
+ ref: "AnyOfStatus"
3282
+ });
3283
+ var Range = import_zod24.z.object({
3284
+ type: import_zod24.z.literal("range"),
3285
+ gte: import_zod24.z.string(),
3286
+ lte: import_zod24.z.string()
3287
+ }).openapi({
3288
+ ref: "Range"
3289
+ });
3290
+ var Not = import_zod24.z.object({ type: import_zod24.z.literal("not"), term: import_zod24.z.string() }).openapi({
3291
+ ref: "Not"
2646
3292
  });
2647
- var ExactStatus = import_zod21.z.object({
2648
- type: import_zod21.z.literal("exact"),
2649
- term: EventStatusEnum
3293
+ var Within = import_zod24.z.object({ type: import_zod24.z.literal("within"), location: import_zod24.z.string() }).openapi({
3294
+ ref: "Within"
2650
3295
  });
2651
- var Range = import_zod21.z.object({
2652
- type: import_zod21.z.literal("range"),
2653
- gte: import_zod21.z.string(),
2654
- lte: import_zod21.z.string()
3296
+ var RangeDate = Range.extend({
3297
+ gte: import_zod24.z.string().date().or(import_zod24.z.string().datetime()),
3298
+ lte: import_zod24.z.string().date().or(import_zod24.z.string().datetime())
3299
+ }).openapi({
3300
+ ref: "RangeDate"
3301
+ });
3302
+ var ExactDate = Exact.extend({
3303
+ term: import_zod24.z.string().date().or(import_zod24.z.string().datetime())
3304
+ }).openapi({
3305
+ ref: "ExactDate"
2655
3306
  });
2656
- var Not = import_zod21.z.object({ type: import_zod21.z.literal("not"), term: import_zod21.z.string() });
2657
- var Within = import_zod21.z.object({ type: import_zod21.z.literal("within"), location: import_zod21.z.string() });
2658
- var SerializableWithin = import_zod21.z.object({
2659
- type: import_zod21.z.literal("within"),
2660
- location: import_zod21.z.union([import_zod21.z.string(), SerializedUserField])
3307
+ var DateCondition = import_zod24.z.union([ExactDate, RangeDate]).openapi({
3308
+ ref: "DateCondition"
2661
3309
  });
2662
- var DateCondition = import_zod21.z.union([Exact, Range]);
2663
- var QueryInput = import_zod21.z.lazy(
2664
- () => import_zod21.z.union([
2665
- import_zod21.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf, Not]),
2666
- import_zod21.z.record(import_zod21.z.string(), QueryInput)
3310
+ var QueryInput = import_zod24.z.lazy(
3311
+ () => import_zod24.z.union([
3312
+ import_zod24.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf, Not]),
3313
+ import_zod24.z.record(import_zod24.z.string(), QueryInput)
2667
3314
  ])
2668
- );
2669
- var SerializedQueryExpression = import_zod21.z.object({
2670
- title: import_zod21.z.string(),
2671
- eventType: import_zod21.z.string(),
2672
- status: import_zod21.z.optional(import_zod21.z.union([AnyOfStatus, ExactStatus])),
2673
- createdAt: import_zod21.z.optional(DateCondition),
2674
- updatedAt: import_zod21.z.optional(DateCondition),
2675
- createdAtLocation: import_zod21.z.optional(
2676
- import_zod21.z.union([SerializableWithin, SerializableExact])
3315
+ ).openapi({
3316
+ ref: "QueryInput"
3317
+ });
3318
+ var QueryExpression = import_zod24.z.object({
3319
+ id: import_zod24.z.optional(import_zod24.z.string()),
3320
+ eventType: import_zod24.z.string(),
3321
+ status: import_zod24.z.optional(import_zod24.z.union([AnyOfStatus, ExactStatus])),
3322
+ createdAt: import_zod24.z.optional(DateCondition),
3323
+ updatedAt: import_zod24.z.optional(DateCondition),
3324
+ "legalStatus.REGISTERED.createdAt": import_zod24.z.optional(DateCondition),
3325
+ "legalStatus.REGISTERED.createdAtLocation": import_zod24.z.optional(
3326
+ import_zod24.z.union([Within, Exact])
3327
+ ),
3328
+ "legalStatus.REGISTERED.registrationNumber": import_zod24.z.optional(Exact),
3329
+ createdAtLocation: import_zod24.z.optional(import_zod24.z.union([Within, Exact])),
3330
+ updatedAtLocation: import_zod24.z.optional(import_zod24.z.union([Within, Exact])),
3331
+ assignedTo: import_zod24.z.optional(Exact),
3332
+ createdByUserType: TokenUserType,
3333
+ createdBy: import_zod24.z.optional(Exact),
3334
+ updatedBy: import_zod24.z.optional(Exact),
3335
+ trackingId: import_zod24.z.optional(Exact),
3336
+ flags: import_zod24.z.optional(import_zod24.z.array(import_zod24.z.union([AnyOf, Not]))),
3337
+ data: QueryInput
3338
+ }).partial().refine((obj) => Object.values(obj).some((val) => val !== void 0), {
3339
+ message: "At least one query field must be specified."
3340
+ }).openapi({
3341
+ ref: "QueryExpression"
3342
+ });
3343
+ var QueryType = import_zod24.z.object({
3344
+ type: import_zod24.z.literal("and").or(import_zod24.z.literal("or")).openapi({ default: "and" }),
3345
+ clauses: import_zod24.z.preprocess(
3346
+ (val) => {
3347
+ if (typeof val === "string") {
3348
+ return [JSON.parse(val)];
3349
+ }
3350
+ if (Array.isArray(val)) {
3351
+ return val.map((v) => typeof v === "string" ? JSON.parse(v) : v);
3352
+ }
3353
+ return val;
3354
+ },
3355
+ import_zod24.z.array(QueryExpression).nonempty("At least one clause is required.").openapi({
3356
+ default: [
3357
+ {
3358
+ eventType: TENNIS_CLUB_MEMBERSHIP,
3359
+ status: {
3360
+ type: "anyOf",
3361
+ terms: EventStatus.options
3362
+ },
3363
+ updatedAt: {
3364
+ type: "range",
3365
+ gte: "2025-05-22",
3366
+ lte: "2025-05-29"
3367
+ },
3368
+ data: {}
3369
+ }
3370
+ ]
3371
+ })
3372
+ )
3373
+ }).openapi({
3374
+ ref: "QueryType"
3375
+ });
3376
+
3377
+ // ../commons/src/events/CountryConfigQueryInput.ts
3378
+ var SerializableExact = import_zod25.z.object({
3379
+ type: import_zod25.z.literal("exact"),
3380
+ term: import_zod25.z.union([import_zod25.z.string(), SerializedUserField])
3381
+ });
3382
+ var SerializableWithin = import_zod25.z.object({
3383
+ type: import_zod25.z.literal("within"),
3384
+ location: import_zod25.z.union([import_zod25.z.string(), SerializedUserField])
3385
+ });
3386
+ var SerializedQueryExpression = import_zod25.z.object({
3387
+ eventType: import_zod25.z.string(),
3388
+ status: import_zod25.z.optional(import_zod25.z.union([AnyOfStatus, ExactStatus])),
3389
+ createdAt: import_zod25.z.optional(DateCondition),
3390
+ updatedAt: import_zod25.z.optional(DateCondition),
3391
+ createdAtLocation: import_zod25.z.optional(
3392
+ import_zod25.z.union([SerializableWithin, SerializableExact])
2677
3393
  ),
2678
- updatedAtLocation: import_zod21.z.optional(
2679
- import_zod21.z.union([SerializableWithin, SerializableExact])
3394
+ updatedAtLocation: import_zod25.z.optional(
3395
+ import_zod25.z.union([SerializableWithin, SerializableExact])
2680
3396
  ),
2681
- assignedTo: import_zod21.z.optional(SerializableExact),
2682
- createdBy: import_zod21.z.optional(SerializableExact),
2683
- updatedBy: import_zod21.z.optional(SerializableExact),
2684
- trackingId: import_zod21.z.optional(Exact),
2685
- flags: import_zod21.z.optional(import_zod21.z.array(import_zod21.z.union([AnyOf, Not]))),
3397
+ assignedTo: import_zod25.z.optional(SerializableExact),
3398
+ createdBy: import_zod25.z.optional(SerializableExact),
3399
+ createdByUserType: TokenUserType,
3400
+ updatedBy: import_zod25.z.optional(SerializableExact),
3401
+ trackingId: import_zod25.z.optional(Exact),
3402
+ flags: import_zod25.z.optional(import_zod25.z.array(import_zod25.z.union([AnyOf, Not]))),
2686
3403
  data: QueryInput
2687
3404
  }).partial();
2688
- var Or2 = import_zod21.z.object({
2689
- type: import_zod21.z.literal("or"),
2690
- clauses: import_zod21.z.array(SerializedQueryExpression)
3405
+ var Or2 = import_zod25.z.object({
3406
+ type: import_zod25.z.literal("or"),
3407
+ clauses: import_zod25.z.array(SerializedQueryExpression)
2691
3408
  });
2692
- var And2 = import_zod21.z.object({
2693
- type: import_zod21.z.literal("and"),
2694
- clauses: import_zod21.z.array(SerializedQueryExpression)
3409
+ var And2 = import_zod25.z.object({
3410
+ type: import_zod25.z.literal("and"),
3411
+ clauses: import_zod25.z.array(SerializedQueryExpression)
2695
3412
  });
2696
- var CountryConfigQueryType = import_zod21.z.discriminatedUnion("type", [And2, Or2]);
2697
- var CountryConfigQueryInputType = import_zod21.z.union([
3413
+ var CountryConfigQueryType = import_zod25.z.discriminatedUnion("type", [And2, Or2]);
3414
+ var CountryConfigQueryInputType = import_zod25.z.union([
2698
3415
  SerializedQueryExpression,
2699
3416
  And2,
2700
3417
  Or2
2701
3418
  ]);
2702
3419
 
2703
3420
  // ../commons/src/icons.ts
2704
- var import_zod22 = require("zod");
2705
- var AvailableIcons = import_zod22.z.enum([
3421
+ var import_zod26 = require("zod");
3422
+ var AvailableIcons = import_zod26.z.enum([
2706
3423
  "Archived",
2707
3424
  "Assigned",
2708
3425
  "Certified",
@@ -2805,76 +3522,8 @@ var AvailableIcons = import_zod22.z.enum([
2805
3522
  "Timer"
2806
3523
  ]);
2807
3524
 
2808
- // ../commons/src/events/EventIndex.ts
2809
- var import_zod23 = require("zod");
2810
- var EventIndex = EventMetadata.extend({
2811
- declaration: EventState
2812
- });
2813
- var EventSearchIndex = import_zod23.z.record(import_zod23.z.string(), import_zod23.z.any()).and(
2814
- import_zod23.z.object({
2815
- type: import_zod23.z.string()
2816
- // Ensures "type" (event-id) exists and is a string
2817
- })
2818
- );
2819
- var Fuzzy2 = import_zod23.z.object({ type: import_zod23.z.literal("fuzzy"), term: import_zod23.z.string() });
2820
- var Exact2 = import_zod23.z.object({ type: import_zod23.z.literal("exact"), term: import_zod23.z.string() });
2821
- var AnyOf2 = import_zod23.z.object({
2822
- type: import_zod23.z.literal("anyOf"),
2823
- terms: import_zod23.z.array(import_zod23.z.string())
2824
- });
2825
- var ExactStatus2 = import_zod23.z.object({
2826
- type: import_zod23.z.literal("exact"),
2827
- term: EventStatusEnum
2828
- });
2829
- var AnyOfStatus2 = import_zod23.z.object({
2830
- type: import_zod23.z.literal("anyOf"),
2831
- terms: import_zod23.z.array(EventStatusEnum)
2832
- });
2833
- var Range2 = import_zod23.z.object({
2834
- type: import_zod23.z.literal("range"),
2835
- gte: import_zod23.z.string(),
2836
- lte: import_zod23.z.string()
2837
- });
2838
- var Not2 = import_zod23.z.object({ type: import_zod23.z.literal("not"), term: import_zod23.z.string() });
2839
- var Within2 = import_zod23.z.object({ type: import_zod23.z.literal("within"), location: import_zod23.z.string() });
2840
- var DateCondition2 = import_zod23.z.union([Exact2, Range2]);
2841
- var QueryInput2 = import_zod23.z.lazy(
2842
- () => import_zod23.z.union([
2843
- import_zod23.z.discriminatedUnion("type", [Fuzzy2, Exact2, Range2, Within2, AnyOf2, Not2]),
2844
- import_zod23.z.record(import_zod23.z.string(), QueryInput2)
2845
- ])
2846
- );
2847
- var QueryExpression = import_zod23.z.object({
2848
- title: import_zod23.z.string(),
2849
- eventType: import_zod23.z.string(),
2850
- status: import_zod23.z.optional(import_zod23.z.union([AnyOfStatus2, ExactStatus2])),
2851
- createdAt: import_zod23.z.optional(DateCondition2),
2852
- updatedAt: import_zod23.z.optional(DateCondition2),
2853
- "legalStatus.REGISTERED.createdAt": import_zod23.z.optional(DateCondition2),
2854
- "legalStatus.REGISTERED.createdAtLocation": import_zod23.z.optional(
2855
- import_zod23.z.union([Within2, Exact2])
2856
- ),
2857
- createdAtLocation: import_zod23.z.optional(import_zod23.z.union([Within2, Exact2])),
2858
- updatedAtLocation: import_zod23.z.optional(import_zod23.z.union([Within2, Exact2])),
2859
- assignedTo: import_zod23.z.optional(Exact2),
2860
- createdBy: import_zod23.z.optional(Exact2),
2861
- updatedBy: import_zod23.z.optional(Exact2),
2862
- trackingId: import_zod23.z.optional(Exact2),
2863
- flags: import_zod23.z.optional(import_zod23.z.array(import_zod23.z.union([AnyOf2, Not2]))),
2864
- data: QueryInput2
2865
- }).partial();
2866
- var Or3 = import_zod23.z.object({
2867
- type: import_zod23.z.literal("or"),
2868
- clauses: import_zod23.z.array(QueryExpression)
2869
- });
2870
- var And3 = import_zod23.z.object({
2871
- type: import_zod23.z.literal("and"),
2872
- clauses: import_zod23.z.array(QueryExpression)
2873
- });
2874
- var QueryType = import_zod23.z.discriminatedUnion("type", [Or3, And3]);
2875
-
2876
3525
  // ../commons/src/events/WorkqueueConfig.ts
2877
- var defaultThirdColumn = defineWorkqueuesColumns([
3526
+ var mandatoryColumns = defineWorkqueuesColumns([
2878
3527
  {
2879
3528
  label: {
2880
3529
  id: "workqueues.dateOfEvent",
@@ -2882,36 +3531,52 @@ var defaultThirdColumn = defineWorkqueuesColumns([
2882
3531
  description: "Label for workqueue column: dateOfEvent"
2883
3532
  },
2884
3533
  value: event.field("dateOfEvent")
3534
+ },
3535
+ {
3536
+ label: {
3537
+ defaultMessage: "Last updated",
3538
+ description: "This is the label for the workqueue column",
3539
+ id: "workqueue.default.column.modifiedAt"
3540
+ },
3541
+ value: event.field("updatedAt")
2885
3542
  }
2886
3543
  ]);
2887
- var WorkqueueConfig = import_zod24.z.object({
2888
- slug: import_zod24.z.string().describe("Determines the url of the workqueue."),
3544
+ var WorkqueueActionsWithDefault = import_zod27.z.enum([
3545
+ ...workqueueActions.options,
3546
+ "DEFAULT"
3547
+ ]);
3548
+ var WorkqueueConfig = import_zod27.z.object({
3549
+ slug: import_zod27.z.string().describe("Determines the url of the workqueue."),
2889
3550
  name: TranslationConfig.describe(
2890
3551
  "Title of the workflow (both in navigation and on the page)"
2891
3552
  ),
2892
3553
  query: CountryConfigQueryType,
2893
- actions: import_zod24.z.array(
2894
- import_zod24.z.object({
2895
- type: import_zod24.z.string(),
2896
- conditionals: import_zod24.z.array(Conditional).optional()
3554
+ actions: import_zod27.z.array(
3555
+ import_zod27.z.object({
3556
+ type: WorkqueueActionsWithDefault,
3557
+ conditionals: import_zod27.z.array(Conditional).optional()
2897
3558
  })
2898
3559
  ),
2899
- columns: import_zod24.z.array(WorkqueueColumn).default(defaultThirdColumn),
3560
+ columns: import_zod27.z.array(WorkqueueColumn).default(mandatoryColumns),
2900
3561
  icon: AvailableIcons
2901
3562
  }).describe("Configuration for workqueue.");
2902
- var WorkqueueConfigInput = import_zod24.z.object({
2903
- slug: import_zod24.z.string().describe("Determines the url of the workqueue."),
3563
+ var WorkqueueConfigWithoutQuery = WorkqueueConfig.omit({
3564
+ query: true,
3565
+ columns: true
3566
+ });
3567
+ var WorkqueueConfigInput = import_zod27.z.object({
3568
+ slug: import_zod27.z.string().describe("Determines the url of the workqueue."),
2904
3569
  name: TranslationConfig.describe(
2905
3570
  "Title of the workflow (both in navigation and on the page)"
2906
3571
  ),
2907
3572
  query: CountryConfigQueryInputType,
2908
- actions: import_zod24.z.array(
2909
- import_zod24.z.object({
2910
- type: import_zod24.z.string(),
2911
- conditionals: import_zod24.z.array(Conditional).optional()
3573
+ actions: import_zod27.z.array(
3574
+ import_zod27.z.object({
3575
+ type: WorkqueueActionsWithDefault,
3576
+ conditionals: import_zod27.z.array(Conditional).optional()
2912
3577
  })
2913
3578
  ),
2914
- columns: import_zod24.z.array(WorkqueueColumn).default(defaultThirdColumn),
3579
+ columns: import_zod27.z.array(WorkqueueColumn).default(mandatoryColumns),
2915
3580
  icon: AvailableIcons
2916
3581
  });
2917
3582
  function defineWorkqueue(workqueueInput) {
@@ -2922,10 +3587,10 @@ function defineWorkqueue(workqueueInput) {
2922
3587
  function defineWorkqueues(workqueues) {
2923
3588
  return workqueues.map((workqueue) => defineWorkqueue(workqueue));
2924
3589
  }
2925
- var WorkqueueCountInput = import_zod24.z.array(
2926
- import_zod24.z.object({ slug: import_zod24.z.string(), query: QueryType })
3590
+ var WorkqueueCountInput = import_zod27.z.array(
3591
+ import_zod27.z.object({ slug: import_zod27.z.string(), query: QueryType })
2927
3592
  );
2928
- var WorkqueueCountOutput = import_zod24.z.record(import_zod24.z.string(), import_zod24.z.number());
3593
+ var WorkqueueCountOutput = import_zod27.z.record(import_zod27.z.string(), import_zod27.z.number());
2929
3594
 
2930
3595
  // ../commons/src/events/workqueueDefaultColumns.ts
2931
3596
  var defaultWorkqueueColumns = [
@@ -2944,116 +3609,119 @@ var defaultWorkqueueColumns = [
2944
3609
  id: "workqueue.default.column.event"
2945
3610
  },
2946
3611
  value: event.field("type")
2947
- },
2948
- {
2949
- label: {
2950
- defaultMessage: "Last updated",
2951
- description: "This is the label for the workqueue column",
2952
- id: "workqueue.default.column.modifiedAt"
2953
- },
2954
- value: event.field("updatedAt")
2955
3612
  }
2956
3613
  ];
2957
3614
 
2958
3615
  // ../commons/src/events/Draft.ts
2959
- var import_zod26 = require("zod");
3616
+ var import_zod29 = require("zod");
2960
3617
 
2961
3618
  // ../commons/src/events/ActionInput.ts
2962
- var import_zod25 = require("zod");
2963
- var import_zod_openapi9 = require("zod-openapi");
2964
- (0, import_zod_openapi9.extendZodWithOpenApi)(import_zod25.z);
2965
- var BaseActionInput = import_zod25.z.object({
2966
- eventId: import_zod25.z.string(),
2967
- transactionId: import_zod25.z.string(),
3619
+ var import_zod28 = require("zod");
3620
+ var import_zod_openapi10 = require("zod-openapi");
3621
+ var import_uuid3 = require("uuid");
3622
+ (0, import_zod_openapi10.extendZodWithOpenApi)(import_zod28.z);
3623
+ var BaseActionInput = import_zod28.z.object({
3624
+ eventId: import_zod28.z.string(),
3625
+ transactionId: import_zod28.z.string(),
2968
3626
  declaration: ActionUpdate.default({}),
2969
3627
  annotation: ActionUpdate.optional(),
2970
- originalActionId: import_zod25.z.string().optional(),
2971
- keepAssignment: import_zod25.z.boolean().optional()
3628
+ originalActionId: import_zod28.z.string().optional(),
3629
+ keepAssignment: import_zod28.z.boolean().optional()
2972
3630
  });
2973
3631
  var CreateActionInput = BaseActionInput.merge(
2974
- import_zod25.z.object({
2975
- type: import_zod25.z.literal(ActionType.CREATE).default(ActionType.CREATE),
2976
- createdAtLocation: import_zod25.z.string()
3632
+ import_zod28.z.object({
3633
+ type: import_zod28.z.literal(ActionType.CREATE).default(ActionType.CREATE),
3634
+ createdAtLocation: CreatedAtLocation
2977
3635
  })
2978
3636
  );
2979
3637
  var RegisterActionInput = BaseActionInput.merge(
2980
- import_zod25.z.object({
2981
- type: import_zod25.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
2982
- registrationNumber: import_zod25.z.string().optional()
3638
+ import_zod28.z.object({
3639
+ type: import_zod28.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
3640
+ registrationNumber: import_zod28.z.string().optional()
2983
3641
  })
2984
3642
  );
2985
3643
  var ValidateActionInput = BaseActionInput.merge(
2986
- import_zod25.z.object({
2987
- type: import_zod25.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
2988
- duplicates: import_zod25.z.array(import_zod25.z.string())
3644
+ import_zod28.z.object({
3645
+ type: import_zod28.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
3646
+ duplicates: import_zod28.z.array(import_zod28.z.string())
2989
3647
  })
2990
3648
  );
2991
3649
  var NotifyActionInput = BaseActionInput.merge(
2992
- import_zod25.z.object({
2993
- type: import_zod25.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
3650
+ import_zod28.z.object({
3651
+ type: import_zod28.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
2994
3652
  })
2995
- );
3653
+ ).openapi({
3654
+ default: {
3655
+ eventId: "<event-id-here>",
3656
+ transactionId: (0, import_uuid3.v4)(),
3657
+ declaration: {},
3658
+ annotation: {},
3659
+ type: ActionType.NOTIFY
3660
+ }
3661
+ });
2996
3662
  var DeclareActionInput = BaseActionInput.merge(
2997
- import_zod25.z.object({
2998
- type: import_zod25.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
3663
+ import_zod28.z.object({
3664
+ type: import_zod28.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
2999
3665
  })
3000
3666
  );
3001
3667
  var PrintCertificateActionInput = BaseActionInput.merge(
3002
- import_zod25.z.object({
3003
- type: import_zod25.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
3668
+ import_zod28.z.object({
3669
+ type: import_zod28.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
3004
3670
  })
3005
3671
  );
3006
3672
  var RejectDeclarationActionInput = BaseActionInput.merge(
3007
- import_zod25.z.object({
3008
- type: import_zod25.z.literal(ActionType.REJECT).default(ActionType.REJECT)
3673
+ import_zod28.z.object({
3674
+ type: import_zod28.z.literal(ActionType.REJECT).default(ActionType.REJECT),
3675
+ reason: RejectionReason
3009
3676
  })
3010
3677
  );
3011
3678
  var MarkedAsDuplicateActionInput = BaseActionInput.merge(
3012
- import_zod25.z.object({
3013
- type: import_zod25.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
3679
+ import_zod28.z.object({
3680
+ type: import_zod28.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
3014
3681
  })
3015
3682
  );
3016
3683
  var ArchiveActionInput = BaseActionInput.merge(
3017
- import_zod25.z.object({
3018
- type: import_zod25.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
3684
+ import_zod28.z.object({
3685
+ type: import_zod28.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
3686
+ reason: RejectionReason
3019
3687
  })
3020
3688
  );
3021
3689
  var AssignActionInput = BaseActionInput.merge(
3022
- import_zod25.z.object({
3023
- type: import_zod25.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
3024
- assignedTo: import_zod25.z.string()
3690
+ import_zod28.z.object({
3691
+ type: import_zod28.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
3692
+ assignedTo: import_zod28.z.string()
3025
3693
  })
3026
3694
  );
3027
3695
  var UnassignActionInput = BaseActionInput.merge(
3028
- import_zod25.z.object({
3029
- type: import_zod25.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
3030
- assignedTo: import_zod25.z.literal(null).default(null)
3696
+ import_zod28.z.object({
3697
+ type: import_zod28.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
3698
+ assignedTo: import_zod28.z.literal(null).default(null)
3031
3699
  })
3032
3700
  );
3033
3701
  var RequestCorrectionActionInput = BaseActionInput.merge(
3034
- import_zod25.z.object({
3035
- type: import_zod25.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
3702
+ import_zod28.z.object({
3703
+ type: import_zod28.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
3036
3704
  })
3037
3705
  );
3038
3706
  var RejectCorrectionActionInput = BaseActionInput.merge(
3039
- import_zod25.z.object({
3040
- requestId: import_zod25.z.string(),
3041
- type: import_zod25.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
3707
+ import_zod28.z.object({
3708
+ requestId: import_zod28.z.string(),
3709
+ type: import_zod28.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
3042
3710
  })
3043
3711
  );
3044
3712
  var ApproveCorrectionActionInput = BaseActionInput.merge(
3045
- import_zod25.z.object({
3046
- requestId: import_zod25.z.string(),
3047
- type: import_zod25.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
3713
+ import_zod28.z.object({
3714
+ requestId: import_zod28.z.string(),
3715
+ type: import_zod28.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
3048
3716
  })
3049
3717
  );
3050
3718
  var ReadActionInput = BaseActionInput.merge(
3051
- import_zod25.z.object({
3052
- type: import_zod25.z.literal(ActionType.READ).default(ActionType.READ)
3719
+ import_zod28.z.object({
3720
+ type: import_zod28.z.literal(ActionType.READ).default(ActionType.READ)
3053
3721
  })
3054
3722
  );
3055
- var DeleteActionInput = import_zod25.z.object({ eventId: import_zod25.z.string() });
3056
- var ActionInput = import_zod25.z.discriminatedUnion("type", [
3723
+ var DeleteActionInput = import_zod28.z.object({ eventId: import_zod28.z.string() });
3724
+ var ActionInput = import_zod28.z.discriminatedUnion("type", [
3057
3725
  CreateActionInput.openapi({ ref: "CreateActionInput" }),
3058
3726
  ValidateActionInput.openapi({ ref: "ValidateActionInput" }),
3059
3727
  RegisterActionInput.openapi({ ref: "RegisterActionInput" }),
@@ -3082,18 +3750,18 @@ var ActionInput = import_zod25.z.discriminatedUnion("type", [
3082
3750
  });
3083
3751
 
3084
3752
  // ../commons/src/events/Draft.ts
3085
- var Draft = import_zod26.z.object({
3086
- id: import_zod26.z.string(),
3087
- eventId: import_zod26.z.string(),
3088
- transactionId: import_zod26.z.string(),
3089
- createdAt: import_zod26.z.string().datetime(),
3753
+ var Draft = import_zod29.z.object({
3754
+ id: import_zod29.z.string(),
3755
+ eventId: import_zod29.z.string(),
3756
+ transactionId: import_zod29.z.string(),
3757
+ createdAt: import_zod29.z.string().datetime(),
3090
3758
  action: ActionBase.extend({
3091
3759
  type: ActionTypes
3092
3760
  }).omit({ id: true })
3093
3761
  });
3094
3762
  var DraftInput = BaseActionInput.extend({
3095
3763
  type: ActionTypes,
3096
- status: import_zod26.z.enum([
3764
+ status: import_zod29.z.enum([
3097
3765
  ActionStatus.Requested,
3098
3766
  ActionStatus.Accepted,
3099
3767
  ActionStatus.Rejected
@@ -3101,23 +3769,24 @@ var DraftInput = BaseActionInput.extend({
3101
3769
  });
3102
3770
 
3103
3771
  // ../commons/src/events/EventInput.ts
3104
- var import_zod27 = require("zod");
3105
- var EventInput = import_zod27.z.object({
3106
- transactionId: import_zod27.z.string(),
3107
- type: import_zod27.z.string()
3108
- });
3772
+ var import_zod30 = require("zod");
3773
+ var import_uuid4 = require("uuid");
3774
+ var EventInput = import_zod30.z.object({
3775
+ transactionId: import_zod30.z.string(),
3776
+ type: import_zod30.z.string()
3777
+ }).openapi({ default: { transactionId: (0, import_uuid4.v4)(), type: "v2.birth" } });
3109
3778
 
3110
3779
  // ../commons/src/events/EventDocument.ts
3111
- var import_zod28 = require("zod");
3112
- var import_zod_openapi10 = require("zod-openapi");
3113
- (0, import_zod_openapi10.extendZodWithOpenApi)(import_zod28.z);
3114
- var EventDocument = import_zod28.z.object({
3115
- id: import_zod28.z.string(),
3116
- type: import_zod28.z.string(),
3117
- createdAt: import_zod28.z.string().datetime(),
3118
- updatedAt: import_zod28.z.string().datetime(),
3119
- actions: import_zod28.z.array(Action),
3120
- trackingId: import_zod28.z.string()
3780
+ var import_zod31 = require("zod");
3781
+ var import_zod_openapi11 = require("zod-openapi");
3782
+ (0, import_zod_openapi11.extendZodWithOpenApi)(import_zod31.z);
3783
+ var EventDocument = import_zod31.z.object({
3784
+ id: import_zod31.z.string(),
3785
+ type: import_zod31.z.string(),
3786
+ createdAt: import_zod31.z.string().datetime(),
3787
+ updatedAt: import_zod31.z.string().datetime(),
3788
+ actions: import_zod31.z.array(Action),
3789
+ trackingId: import_zod31.z.string()
3121
3790
  }).openapi({ ref: "EventDocument" });
3122
3791
 
3123
3792
  // ../commons/src/events/state/utils.ts
@@ -3151,23 +3820,26 @@ function getDeclarationActionCreationMetadata(actionType, actions) {
3151
3820
  // When 3rd party API returns 200 OK, we assume that the request was accepted, and persist single 'accepted' action.
3152
3821
  createdAt: requestAction?.createdAt ?? acceptAction.createdAt,
3153
3822
  createdBy: requestAction?.createdBy ?? acceptAction.createdBy,
3823
+ createdByUserType: requestAction?.createdByUserType ?? acceptAction.createdByUserType,
3154
3824
  createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
3155
3825
  acceptedAt: acceptAction.createdAt,
3156
3826
  createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
3827
+ createdBySignature: requestAction?.createdBySignature ?? acceptAction.createdBySignature,
3157
3828
  registrationNumber
3158
3829
  };
3159
3830
  }
3160
- function getDeclarationActionUpdateMetadata(actions) {
3831
+ function getActionUpdateMetadata(actions) {
3161
3832
  const createAction = getOrThrow(
3162
3833
  actions.find((action) => action.type === ActionType.CREATE),
3163
3834
  `Event has no ${ActionType.CREATE} action`
3164
3835
  );
3165
- return [ActionType.DECLARE, ActionType.VALIDATE, ActionType.REGISTER].reduce(
3836
+ return StatusChangingActions.options.reduce(
3166
3837
  (metadata, actionType) => {
3167
3838
  const { accept, request } = getActionRequests(actionType, actions);
3168
3839
  return {
3169
3840
  createdAt: request?.createdAt ?? accept?.createdAt ?? metadata.createdAt,
3170
3841
  createdBy: request?.createdBy ?? accept?.createdBy ?? metadata.createdBy,
3842
+ createdByUserType: request?.createdByUserType ?? accept?.createdByUserType ?? metadata.createdByUserType,
3171
3843
  createdAtLocation: request?.createdAtLocation ?? accept?.createdAtLocation ?? metadata.createdAtLocation,
3172
3844
  createdByRole: request?.createdByRole ?? accept?.createdByRole ?? metadata.createdByRole
3173
3845
  };
@@ -3175,6 +3847,7 @@ function getDeclarationActionUpdateMetadata(actions) {
3175
3847
  {
3176
3848
  createdAt: createAction.createdAt,
3177
3849
  createdBy: createAction.createdBy,
3850
+ createdByUserType: createAction.createdByUserType,
3178
3851
  createdAtLocation: createAction.createdAtLocation,
3179
3852
  createdByRole: createAction.createdByRole
3180
3853
  }
@@ -3182,11 +3855,11 @@ function getDeclarationActionUpdateMetadata(actions) {
3182
3855
  }
3183
3856
  function getLegalStatuses(actions) {
3184
3857
  return {
3185
- [EventStatus.DECLARED]: getDeclarationActionCreationMetadata(
3858
+ [EventStatus.enum.DECLARED]: getDeclarationActionCreationMetadata(
3186
3859
  ActionType.DECLARE,
3187
3860
  actions
3188
3861
  ),
3189
- [EventStatus.REGISTERED]: getDeclarationActionCreationMetadata(
3862
+ [EventStatus.enum.REGISTERED]: getDeclarationActionCreationMetadata(
3190
3863
  ActionType.REGISTER,
3191
3864
  actions
3192
3865
  )
@@ -3199,26 +3872,26 @@ function getStatusFromActions(actions) {
3199
3872
  (a) => a.status === ActionStatus.Rejected
3200
3873
  );
3201
3874
  if (hasRejectedAction) {
3202
- return EventStatus.REJECTED;
3875
+ return EventStatus.enum.REJECTED;
3203
3876
  }
3204
3877
  return actions.reduce((status, action) => {
3205
3878
  switch (action.type) {
3206
3879
  case ActionType.CREATE:
3207
- return EventStatus.CREATED;
3880
+ return EventStatus.enum.CREATED;
3208
3881
  case ActionType.DECLARE:
3209
- return EventStatus.DECLARED;
3882
+ return EventStatus.enum.DECLARED;
3210
3883
  case ActionType.VALIDATE:
3211
- return EventStatus.VALIDATED;
3884
+ return EventStatus.enum.VALIDATED;
3212
3885
  case ActionType.REGISTER:
3213
- return EventStatus.REGISTERED;
3886
+ return EventStatus.enum.REGISTERED;
3214
3887
  case ActionType.REJECT:
3215
- return EventStatus.REJECTED;
3888
+ return EventStatus.enum.REJECTED;
3216
3889
  case ActionType.ARCHIVE:
3217
- return EventStatus.ARCHIVED;
3890
+ return EventStatus.enum.ARCHIVED;
3218
3891
  case ActionType.NOTIFY:
3219
- return EventStatus.NOTIFIED;
3892
+ return EventStatus.enum.NOTIFIED;
3220
3893
  case ActionType.PRINT_CERTIFICATE:
3221
- return EventStatus.CERTIFIED;
3894
+ return EventStatus.enum.CERTIFIED;
3222
3895
  case ActionType.ASSIGN:
3223
3896
  case ActionType.UNASSIGN:
3224
3897
  case ActionType.REQUEST_CORRECTION:
@@ -3229,7 +3902,7 @@ function getStatusFromActions(actions) {
3229
3902
  default:
3230
3903
  return status;
3231
3904
  }
3232
- }, EventStatus.CREATED);
3905
+ }, EventStatus.enum.CREATED);
3233
3906
  }
3234
3907
  function getFlagsFromActions(actions) {
3235
3908
  const sortedactions = actions.sort(
@@ -3274,6 +3947,17 @@ function getAssignedUserFromActions(actions) {
3274
3947
  return user2;
3275
3948
  }, null);
3276
3949
  }
3950
+ function getAssignedUserSignatureFromActions(actions) {
3951
+ return actions.reduce((signature, action) => {
3952
+ if (action.type === ActionType.ASSIGN) {
3953
+ return action.createdBySignature || null;
3954
+ }
3955
+ if (action.type === ActionType.UNASSIGN) {
3956
+ return null;
3957
+ }
3958
+ return signature;
3959
+ }, null);
3960
+ }
3277
3961
  function aggregateActionDeclarations(actions) {
3278
3962
  const excludedActions = [
3279
3963
  ActionType.REQUEST_CORRECTION,
@@ -3310,7 +3994,7 @@ function deepDropNulls(obj) {
3310
3994
  return obj;
3311
3995
  }
3312
3996
  function isUndeclaredDraft(status) {
3313
- return status === EventStatus.CREATED;
3997
+ return status === EventStatus.enum.CREATED;
3314
3998
  }
3315
3999
  function getAcceptedActions(event2) {
3316
4000
  return event2.actions.filter(
@@ -3325,15 +4009,16 @@ function getCurrentEventState(event2, config) {
3325
4009
  if (!creationAction) {
3326
4010
  throw new Error(`Event ${event2.id} has no creation action`);
3327
4011
  }
3328
- const acceptedActions = getAcceptedActions(event2);
3329
- const declarationUpdateMetadata = getDeclarationActionUpdateMetadata(
3330
- event2.actions
4012
+ const acceptedActions = getAcceptedActions(event2).sort(
4013
+ (a, b) => a.createdAt.localeCompare(b.createdAt)
3331
4014
  );
4015
+ const requestActionMetadata = getActionUpdateMetadata(event2.actions);
4016
+ const acceptedActionMetadata = getActionUpdateMetadata(acceptedActions);
3332
4017
  const declaration = aggregateActionDeclarations(acceptedActions);
3333
4018
  let dateOfEvent;
3334
- if (config && config.dateOfEvent) {
4019
+ if (config.dateOfEvent) {
3335
4020
  const parsedDate = ZodDate.safeParse(
3336
- declaration[config.dateOfEvent.fieldId]
4021
+ declaration[config.dateOfEvent.$$field]
3337
4022
  );
3338
4023
  if (parsedDate.success) {
3339
4024
  dateOfEvent = parsedDate.data;
@@ -3344,20 +4029,21 @@ function getCurrentEventState(event2, config) {
3344
4029
  return deepDropNulls({
3345
4030
  id: event2.id,
3346
4031
  type: event2.type,
3347
- title: "ToDo",
3348
4032
  status: getStatusFromActions(event2.actions),
3349
4033
  legalStatuses: getLegalStatuses(event2.actions),
3350
4034
  createdAt: creationAction.createdAt,
3351
4035
  createdBy: creationAction.createdBy,
4036
+ createdByUserType: creationAction.createdByUserType,
3352
4037
  createdAtLocation: creationAction.createdAtLocation,
3353
- updatedAt: declarationUpdateMetadata.createdAt,
4038
+ createdBySignature: creationAction.createdBySignature,
4039
+ updatedAt: acceptedActionMetadata.createdAt,
3354
4040
  assignedTo: getAssignedUserFromActions(acceptedActions),
3355
- updatedBy: declarationUpdateMetadata.createdBy,
3356
- updatedAtLocation: declarationUpdateMetadata.createdAtLocation,
4041
+ assignedToSignature: getAssignedUserSignatureFromActions(acceptedActions),
4042
+ updatedBy: requestActionMetadata.createdBy,
4043
+ updatedAtLocation: requestActionMetadata.createdAtLocation,
3357
4044
  declaration,
3358
4045
  trackingId: event2.trackingId,
3359
- // @TODO: unify this with rest of the code. It will trip us if updatedBy has different rules than updatedByUserRole
3360
- updatedByUserRole: declarationUpdateMetadata.createdByRole,
4046
+ updatedByUserRole: requestActionMetadata.createdByRole,
3361
4047
  dateOfEvent,
3362
4048
  flags: getFlagsFromActions(event2.actions)
3363
4049
  });
@@ -3440,22 +4126,23 @@ function generateTransactionId() {
3440
4126
  }
3441
4127
 
3442
4128
  // ../commons/src/events/User.ts
3443
- var import_zod29 = require("zod");
3444
- var User = import_zod29.z.object({
3445
- id: import_zod29.z.string(),
3446
- name: import_zod29.z.array(
3447
- import_zod29.z.object({
3448
- use: import_zod29.z.string(),
3449
- given: import_zod29.z.array(import_zod29.z.string()),
3450
- family: import_zod29.z.string()
4129
+ var import_zod32 = require("zod");
4130
+ var User = import_zod32.z.object({
4131
+ id: import_zod32.z.string(),
4132
+ name: import_zod32.z.array(
4133
+ import_zod32.z.object({
4134
+ use: import_zod32.z.string(),
4135
+ given: import_zod32.z.array(import_zod32.z.string()),
4136
+ family: import_zod32.z.string()
3451
4137
  })
3452
4138
  ),
3453
- role: import_zod29.z.string(),
3454
- signatureFilename: import_zod29.z.string().optional()
4139
+ role: import_zod32.z.string(),
4140
+ signatureFilename: import_zod32.z.string().optional()
3455
4141
  });
3456
4142
 
3457
4143
  // ../commons/src/events/test.utils.ts
3458
4144
  var import_lodash2 = require("lodash");
4145
+ var import_addDays = __toESM(require("date-fns/addDays"));
3459
4146
 
3460
4147
  // ../commons/src/field-config/field-configuration.ts
3461
4148
  function createFieldConfig(fieldId, options) {
@@ -3470,16 +4157,12 @@ function createFieldConfig(fieldId, options) {
3470
4157
  // ../commons/src/events/field.ts
3471
4158
  function field(fieldId, options = {}) {
3472
4159
  return {
3473
- /**
3474
- * @private Internal property used for field reference tracking.
3475
- */
3476
- _fieldId: fieldId,
3477
4160
  ...createFieldConditionals(fieldId),
3478
4161
  ...createFieldConfig(fieldId, options)
3479
4162
  };
3480
4163
  }
3481
4164
 
3482
- // ../commons/src/fixtures/tennis-club-membership-event.ts
4165
+ // ../commons/src/fixtures/forms.ts
3483
4166
  var import_date_fns2 = require("date-fns");
3484
4167
  var PRINT_CERTIFICATE_FORM = defineActionForm({
3485
4168
  label: {
@@ -4139,7 +4822,7 @@ var PRINT_CERTIFICATE_FORM = defineActionForm({
4139
4822
  var TENNIS_CLUB_DECLARATION_REVIEW = {
4140
4823
  title: {
4141
4824
  id: "v2.event.tennis-club-membership.action.declare.form.review.title",
4142
- defaultMessage: "{applicant.firstname, select, __EMPTY__ {Member declaration} other {{applicant.surname, select, __EMPTY__ {Member declaration} other {Member declaration for {applicant.firstname} {applicant.surname}}}}}",
4825
+ 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}}}}}",
4143
4826
  description: "Title of the review page"
4144
4827
  },
4145
4828
  fields: [
@@ -4184,27 +4867,17 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
4184
4867
  },
4185
4868
  fields: [
4186
4869
  {
4187
- id: "applicant.firstname",
4188
- type: FieldType.TEXT,
4870
+ id: "applicant.name",
4871
+ type: FieldType.NAME,
4189
4872
  required: true,
4873
+ hideLabel: true,
4190
4874
  conditionals: [],
4191
4875
  label: {
4192
- defaultMessage: "Applicant's first name",
4876
+ defaultMessage: "Applicant's name",
4193
4877
  description: "This is the label for the field",
4194
4878
  id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.firstname.label"
4195
4879
  }
4196
4880
  },
4197
- {
4198
- id: "applicant.surname",
4199
- type: FieldType.TEXT,
4200
- required: true,
4201
- conditionals: [],
4202
- label: {
4203
- defaultMessage: "Applicant's surname",
4204
- description: "This is the label for the field",
4205
- id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.surname.label"
4206
- }
4207
- },
4208
4881
  {
4209
4882
  id: "applicant.email",
4210
4883
  type: "EMAIL",
@@ -4338,8 +5011,9 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
4338
5011
  }
4339
5012
  },
4340
5013
  {
4341
- id: "recommender.firstname",
4342
- type: FieldType.TEXT,
5014
+ id: "recommender.name",
5015
+ type: FieldType.NAME,
5016
+ hideLabel: true,
4343
5017
  required: true,
4344
5018
  conditionals: [
4345
5019
  {
@@ -4348,13 +5022,13 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
4348
5022
  }
4349
5023
  ],
4350
5024
  label: {
4351
- defaultMessage: "Recommender's first name",
5025
+ defaultMessage: "Recommender's name",
4352
5026
  description: "This is the label for the field",
4353
5027
  id: "v2.event.tennis-club-membership.action.declare.form.section.recommender.field.firstname.label"
4354
5028
  }
4355
5029
  },
4356
5030
  {
4357
- id: "recommender.surname",
5031
+ id: "recommender.id",
4358
5032
  type: FieldType.TEXT,
4359
5033
  required: true,
4360
5034
  conditionals: [
@@ -4364,25 +5038,9 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
4364
5038
  }
4365
5039
  ],
4366
5040
  label: {
4367
- defaultMessage: "Recommender's surname",
5041
+ defaultMessage: "Recommender's membership ID",
4368
5042
  description: "This is the label for the field",
4369
- id: "v2.event.tennis-club-membership.action.declare.form.section.recommender.field.surname.label"
4370
- }
4371
- },
4372
- {
4373
- id: "recommender.id",
4374
- type: FieldType.TEXT,
4375
- required: true,
4376
- conditionals: [
4377
- {
4378
- type: ConditionalType.SHOW,
4379
- conditional: field("recommender.none").isFalsy()
4380
- }
4381
- ],
4382
- label: {
4383
- defaultMessage: "Recommender's membership ID",
4384
- description: "This is the label for the field",
4385
- id: "v2.event.tennis-club-membership.action.declare.form.section.recommender.field.id.label"
5043
+ id: "v2.event.tennis-club-membership.action.declare.form.section.recommender.field.id.label"
4386
5044
  }
4387
5045
  }
4388
5046
  ]
@@ -4399,7 +5057,7 @@ var statusOptions = [
4399
5057
  }
4400
5058
  },
4401
5059
  {
4402
- value: EventStatus.CREATED,
5060
+ value: EventStatus.enum.CREATED,
4403
5061
  label: {
4404
5062
  defaultMessage: "Draft",
4405
5063
  description: "Option for form field: status of record",
@@ -4407,7 +5065,7 @@ var statusOptions = [
4407
5065
  }
4408
5066
  },
4409
5067
  {
4410
- value: EventStatus.NOTIFIED,
5068
+ value: EventStatus.enum.NOTIFIED,
4411
5069
  label: {
4412
5070
  defaultMessage: "Notified",
4413
5071
  description: "Option for form field: status of record",
@@ -4415,7 +5073,7 @@ var statusOptions = [
4415
5073
  }
4416
5074
  },
4417
5075
  {
4418
- value: EventStatus.DECLARED,
5076
+ value: EventStatus.enum.DECLARED,
4419
5077
  label: {
4420
5078
  defaultMessage: "Declared",
4421
5079
  description: "Option for form field: status of record",
@@ -4423,7 +5081,7 @@ var statusOptions = [
4423
5081
  }
4424
5082
  },
4425
5083
  {
4426
- value: EventStatus.VALIDATED,
5084
+ value: EventStatus.enum.VALIDATED,
4427
5085
  label: {
4428
5086
  defaultMessage: "Validated",
4429
5087
  description: "Option for form field: status of record",
@@ -4431,7 +5089,7 @@ var statusOptions = [
4431
5089
  }
4432
5090
  },
4433
5091
  {
4434
- value: EventStatus.REGISTERED,
5092
+ value: EventStatus.enum.REGISTERED,
4435
5093
  label: {
4436
5094
  defaultMessage: "Registered",
4437
5095
  description: "Option for form field: status of record",
@@ -4439,7 +5097,7 @@ var statusOptions = [
4439
5097
  }
4440
5098
  },
4441
5099
  {
4442
- value: EventStatus.CERTIFIED,
5100
+ value: EventStatus.enum.CERTIFIED,
4443
5101
  label: {
4444
5102
  defaultMessage: "Certified",
4445
5103
  description: "Option for form field: status of record",
@@ -4447,7 +5105,7 @@ var statusOptions = [
4447
5105
  }
4448
5106
  },
4449
5107
  {
4450
- value: EventStatus.REJECTED,
5108
+ value: EventStatus.enum.REJECTED,
4451
5109
  label: {
4452
5110
  defaultMessage: "Rejected",
4453
5111
  description: "Option for form field: status of record",
@@ -4455,7 +5113,7 @@ var statusOptions = [
4455
5113
  }
4456
5114
  },
4457
5115
  {
4458
- value: EventStatus.ARCHIVED,
5116
+ value: EventStatus.enum.ARCHIVED,
4459
5117
  label: {
4460
5118
  defaultMessage: "Archived",
4461
5119
  description: "Option for form field: status of record",
@@ -4509,52 +5167,50 @@ var timePeriodOptions = [
4509
5167
  )}`
4510
5168
  }
4511
5169
  ];
5170
+
5171
+ // ../commons/src/fixtures/tennis-club-membership-event.ts
4512
5172
  var tennisClubMembershipEvent = defineConfig({
4513
- id: "tennis-club-membership",
5173
+ id: TENNIS_CLUB_MEMBERSHIP,
4514
5174
  label: {
4515
5175
  defaultMessage: "Tennis club membership application",
4516
5176
  description: "This is what this event is referred as in the system",
4517
- id: "event.tennis-club-membership.label"
5177
+ id: "v2.event.tennis-club-membership.label"
4518
5178
  },
4519
5179
  title: {
4520
- defaultMessage: "{applicant.firstname} {applicant.surname}",
5180
+ defaultMessage: "{applicant.name.firstname} {applicant.name.surname}",
4521
5181
  description: "This is the title of the summary",
4522
5182
  id: "v2.event.tennis-club-membership.title"
4523
5183
  },
4524
5184
  summary: {
4525
5185
  fields: [
4526
5186
  {
4527
- id: "applicant.firstname",
5187
+ fieldId: "applicant.name",
4528
5188
  label: {
4529
- defaultMessage: "Applicant's first name",
5189
+ defaultMessage: "Applicant's name",
4530
5190
  description: "This is the label for the field",
4531
5191
  id: "event.tennis-club-membership.summary.field.firstname.label"
4532
5192
  },
4533
- value: {
4534
- defaultMessage: "{applicant.firstname}",
4535
- description: "This is the value to show in the summary",
4536
- id: "event.tennis-club-membership.summary.field.firstname"
4537
- },
4538
5193
  emptyValueMessage: {
4539
5194
  defaultMessage: "First name is not provided",
4540
5195
  description: "This is the message to show when the field is empty",
4541
5196
  id: "event.tennis-club-membership.summary.field.firstname.empty"
4542
5197
  }
4543
5198
  },
4544
- {
4545
- fieldId: "applicant.surname",
4546
- label: {
4547
- defaultMessage: "Applicant's last name",
4548
- description: "Label for surname",
4549
- id: "v2.event.tennis-club-membership.summary.field.surname.label"
4550
- }
4551
- },
4552
5199
  {
4553
5200
  fieldId: "applicant.email"
4554
5201
  }
4555
5202
  ]
4556
5203
  },
4557
5204
  actions: [
5205
+ {
5206
+ type: ActionType.READ,
5207
+ label: {
5208
+ id: "v2.event.tennis-club-membership.action.read.label",
5209
+ defaultMessage: "Read",
5210
+ description: "Title of the read only page"
5211
+ },
5212
+ review: TENNIS_CLUB_DECLARATION_REVIEW
5213
+ },
4558
5214
  {
4559
5215
  type: ActionType.DECLARE,
4560
5216
  label: {
@@ -4875,8 +5531,7 @@ var tennisClubMembershipEvent = defineConfig({
4875
5531
  id: "v2.event.tennis-club-membership.search.applicants"
4876
5532
  },
4877
5533
  fields: [
4878
- field("applicant.firstname").fuzzy(),
4879
- field("applicant.surname").fuzzy(),
5534
+ field("applicant.name").fuzzy(),
4880
5535
  field("applicant.dob").range(),
4881
5536
  field("applicant.email").exact()
4882
5537
  ]
@@ -4887,329 +5542,1029 @@ var tennisClubMembershipEvent = defineConfig({
4887
5542
  description: "Recommender details search field section title",
4888
5543
  id: "v2.event.tennis-club-membership.search.recommender"
4889
5544
  },
4890
- fields: [
4891
- field("recommender.firstname").fuzzy(),
4892
- field("recommender.surname").fuzzy()
4893
- ]
5545
+ fields: [field("recommender.name").fuzzy()]
4894
5546
  }
4895
5547
  ],
4896
5548
  declaration: TENNIS_CLUB_DECLARATION_FORM
4897
5549
  });
4898
- var WorkqueueFixture = defineWorkqueues([
4899
- {
4900
- columns: [],
4901
- slug: "in-progress",
4902
- name: {
4903
- id: "workqueues.inProgress.title",
4904
- defaultMessage: "In progress",
4905
- description: "Title of in progress workqueue"
4906
- },
4907
- query: {
4908
- type: "and",
4909
- clauses: [{ eventType: tennisClubMembershipEvent.id }]
4910
- },
4911
- actions: [],
4912
- icon: "Draft"
4913
- }
4914
- ]);
4915
5550
 
4916
- // ../commons/src/events/test.utils.ts
4917
- function fieldConfigsToActionPayload(fields) {
4918
- return fields.reduce(
4919
- (acc, field2, i) => ({
4920
- ...acc,
4921
- [field2.id]: mapFieldTypeToMockValue(field2, i)
4922
- }),
4923
- {}
4924
- );
4925
- }
4926
- function generateActionDeclarationInput(configuration, action) {
4927
- const parsed = DeclarationUpdateActions.safeParse(action);
4928
- if (parsed.success) {
4929
- const fields = getDeclarationFields(configuration);
4930
- const declarationConfig = getDeclaration(configuration);
4931
- const declaration = fieldConfigsToActionPayload(fields);
4932
- return omitHiddenPaginatedFields(declarationConfig, declaration);
4933
- }
4934
- console.warn(`${action} is not a declaration action. Setting data as {}.`);
4935
- return {};
4936
- }
4937
- function generateActionAnnotationInput(configuration, action) {
4938
- const actionConfig = configuration.actions.find(
4939
- (ac) => ac.type === action
4940
- );
4941
- const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
4942
- const annotation = fieldConfigsToActionPayload(annotationFields);
4943
- const visibleVerificationPageIds = getVisibleVerificationPageIds(
4944
- findRecordActionPages(configuration, action),
4945
- annotation
4946
- );
4947
- const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
4948
- (acc, pageId) => ({
4949
- ...acc,
4950
- [pageId]: true
4951
- }),
4952
- {}
4953
- );
4954
- const fieldBasedPayload = omitHiddenFields(annotationFields, annotation);
4955
- return {
4956
- ...fieldBasedPayload,
4957
- ...visiblePageVerificationMap
4958
- };
4959
- }
4960
- var eventPayloadGenerator = {
4961
- create: (input = {}) => ({
4962
- transactionId: input.transactionId ?? getUUID(),
4963
- type: input.type ?? "tennis-club-membership"
4964
- }),
4965
- patch: (id, input = {}) => ({
4966
- transactionId: input.transactionId ?? getUUID(),
4967
- type: input.type ?? "tennis-club-membership",
4968
- id
4969
- }),
4970
- draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
4971
- {
4972
- id: getUUID(),
4973
- eventId,
4974
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4975
- transactionId: getUUID(),
4976
- action: {
4977
- transactionId: getUUID(),
4978
- type: actionType,
4979
- status: ActionStatus.Accepted,
4980
- declaration: {
4981
- "applicant.firstname": "Max",
4982
- "applicant.surname": "McLaren",
4983
- "applicant.dob": "2020-01-02",
4984
- "recommender.none": true
5551
+ // ../commons/src/fixtures/football-club-membership-event.ts
5552
+ var footballClubMembershipEvent = defineConfig({
5553
+ id: "FOOTBALL_CLUB_MEMBERSHIP",
5554
+ label: {
5555
+ defaultMessage: "Football club membership application",
5556
+ description: "This is what this event is referred as in the system",
5557
+ id: "event.football-club-membership.label"
5558
+ },
5559
+ title: {
5560
+ defaultMessage: "{applicant.name.firstname} {applicant.name.surname}",
5561
+ description: "This is the title of the summary",
5562
+ id: "v2.event.football-club-membership.title"
5563
+ },
5564
+ summary: {
5565
+ fields: [
5566
+ {
5567
+ id: "applicant.name.firstname",
5568
+ label: {
5569
+ defaultMessage: "Applicant's first name",
5570
+ description: "This is the label for the field",
5571
+ id: "event.football-club-membership.summary.field.firstname.label"
4985
5572
  },
4986
- annotation: {
4987
- "correction.requester.relationship": "ANOTHER_AGENT",
4988
- "correction.request.reason": "Child's name was incorrect"
5573
+ value: {
5574
+ defaultMessage: "{applicant.name.firstname}",
5575
+ description: "This is the value to show in the summary",
5576
+ id: "event.football-club-membership.summary.field.firstname"
4989
5577
  },
4990
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4991
- createdBy: "@todo",
4992
- createdByRole: "@todo",
4993
- createdAtLocation: "@todo"
5578
+ emptyValueMessage: {
5579
+ defaultMessage: "First name is not provided",
5580
+ description: "This is the message to show when the field is empty",
5581
+ id: "event.football-club-membership.summary.field.firstname.empty"
5582
+ }
5583
+ },
5584
+ {
5585
+ fieldId: "applicant.name.surname",
5586
+ label: {
5587
+ defaultMessage: "Applicant's last name",
5588
+ description: "Label for surname",
5589
+ id: "v2.event.football-club-membership.summary.field.surname.label"
5590
+ }
5591
+ },
5592
+ {
5593
+ fieldId: "applicant.email"
4994
5594
  }
5595
+ ]
5596
+ },
5597
+ actions: [
5598
+ {
5599
+ type: ActionType.READ,
5600
+ label: {
5601
+ id: "v2.event.football-club-membership.action.read.label",
5602
+ defaultMessage: "Read",
5603
+ description: "Title of the read only page"
5604
+ },
5605
+ review: TENNIS_CLUB_DECLARATION_REVIEW
4995
5606
  },
4996
- input
4997
- ),
4998
- actions: {
4999
- declare: (eventId, input = {}) => ({
5607
+ {
5000
5608
  type: ActionType.DECLARE,
5001
- transactionId: input.transactionId ?? getUUID(),
5002
- declaration: input.declaration ?? generateActionDeclarationInput(
5003
- tennisClubMembershipEvent,
5004
- ActionType.DECLARE
5005
- ),
5006
- annotation: input.annotation ?? generateActionAnnotationInput(
5007
- tennisClubMembershipEvent,
5008
- ActionType.DECLARE
5009
- ),
5010
- eventId
5011
- }),
5012
- /**
5013
- * Notify allows sending incomplete data. Think it as 'partial declare' for now.
5014
- */
5015
- notify: (eventId, input = {}) => {
5016
- let declaration = input.declaration;
5017
- if (!declaration) {
5018
- const partialDeclaration = (0, import_lodash2.omitBy)(
5019
- generateActionDeclarationInput(
5020
- tennisClubMembershipEvent,
5021
- ActionType.DECLARE
5022
- ),
5023
- import_lodash2.isString
5024
- );
5025
- declaration = partialDeclaration;
5026
- }
5027
- return {
5028
- type: ActionType.NOTIFY,
5029
- transactionId: input.transactionId ?? getUUID(),
5030
- declaration,
5031
- eventId
5032
- };
5609
+ label: {
5610
+ defaultMessage: "Send an application",
5611
+ description: "This is shown as the action name anywhere the user can trigger the action from",
5612
+ id: "event.football-club-membership.action.declare.label"
5613
+ },
5614
+ review: TENNIS_CLUB_DECLARATION_REVIEW
5033
5615
  },
5034
- validate: (eventId, input = {}) => ({
5616
+ {
5035
5617
  type: ActionType.VALIDATE,
5036
- transactionId: input.transactionId ?? getUUID(),
5037
- declaration: input.declaration ?? generateActionDeclarationInput(
5038
- tennisClubMembershipEvent,
5039
- ActionType.VALIDATE
5040
- ),
5041
- annotation: input.annotation ?? generateActionAnnotationInput(
5042
- tennisClubMembershipEvent,
5043
- ActionType.VALIDATE
5044
- ),
5045
- duplicates: [],
5046
- eventId
5047
- }),
5048
- assign: (eventId, input = {}) => ({
5049
- type: ActionType.ASSIGN,
5050
- transactionId: input.transactionId ?? getUUID(),
5051
- declaration: {},
5052
- assignedTo: input.assignedTo ?? getUUID(),
5053
- eventId
5054
- }),
5055
- unassign: (eventId, input = {}) => ({
5056
- type: ActionType.UNASSIGN,
5057
- transactionId: input.transactionId ?? getUUID(),
5058
- declaration: {},
5059
- assignedTo: null,
5060
- eventId
5061
- }),
5062
- archive: (eventId, input = {}, isDuplicate) => ({
5063
- type: ActionType.ARCHIVE,
5064
- transactionId: input.transactionId ?? getUUID(),
5065
- declaration: {},
5066
- // @TODO: Check whether generator is needed?
5067
- annotation: { isDuplicate: isDuplicate ?? false },
5068
- duplicates: [],
5069
- eventId
5070
- }),
5071
- reject: (eventId, input = {}) => ({
5072
- type: ActionType.REJECT,
5073
- transactionId: input.transactionId ?? getUUID(),
5074
- declaration: {},
5075
- annotation: input.annotation ?? generateActionAnnotationInput(
5076
- tennisClubMembershipEvent,
5077
- ActionType.REJECT
5078
- ),
5079
- duplicates: [],
5080
- eventId
5081
- }),
5082
- register: (eventId, input = {}) => ({
5618
+ label: {
5619
+ defaultMessage: "Validate",
5620
+ description: "This is shown as the action name anywhere the user can trigger the action from",
5621
+ id: "event.football-club-membership.action.validate.label"
5622
+ },
5623
+ review: TENNIS_CLUB_DECLARATION_REVIEW
5624
+ },
5625
+ {
5083
5626
  type: ActionType.REGISTER,
5084
- transactionId: input.transactionId ?? getUUID(),
5085
- declaration: input.declaration ?? generateActionDeclarationInput(
5086
- tennisClubMembershipEvent,
5087
- ActionType.REGISTER
5088
- ),
5089
- annotation: input.annotation ?? generateActionAnnotationInput(
5090
- tennisClubMembershipEvent,
5091
- ActionType.REGISTER
5092
- ),
5093
- eventId
5094
- }),
5095
- printCertificate: (eventId, input = {}) => ({
5096
- type: ActionType.PRINT_CERTIFICATE,
5097
- transactionId: input.transactionId ?? getUUID(),
5098
- declaration: {},
5099
- annotation: input.annotation ?? generateActionAnnotationInput(
5100
- tennisClubMembershipEvent,
5101
- ActionType.PRINT_CERTIFICATE
5102
- ),
5103
- eventId
5104
- }),
5105
- correction: {
5106
- request: (eventId, input = {}) => ({
5107
- type: ActionType.REQUEST_CORRECTION,
5108
- transactionId: input.transactionId ?? getUUID(),
5109
- declaration: input.declaration ?? generateActionDeclarationInput(
5110
- tennisClubMembershipEvent,
5111
- ActionType.REQUEST_CORRECTION
5112
- ),
5113
- annotation: input.annotation ?? generateActionAnnotationInput(
5114
- tennisClubMembershipEvent,
5115
- ActionType.REQUEST_CORRECTION
5116
- ),
5117
- eventId
5118
- }),
5119
- approve: (eventId, requestId, input = {}) => ({
5120
- type: ActionType.APPROVE_CORRECTION,
5121
- transactionId: input.transactionId ?? getUUID(),
5122
- declaration: {},
5123
- annotation: input.annotation ?? generateActionAnnotationInput(
5124
- tennisClubMembershipEvent,
5125
- ActionType.APPROVE_CORRECTION
5126
- ),
5127
- eventId,
5128
- requestId
5129
- }),
5130
- reject: (eventId, requestId, input = {}) => ({
5131
- type: ActionType.REJECT_CORRECTION,
5132
- transactionId: input.transactionId ?? getUUID(),
5133
- declaration: {},
5134
- annotation: input.annotation ?? generateActionAnnotationInput(
5135
- tennisClubMembershipEvent,
5136
- ActionType.REJECT_CORRECTION
5137
- ),
5138
- eventId,
5139
- requestId
5140
- })
5141
- }
5142
- }
5143
- };
5144
- function generateActionDocument({
5145
- configuration,
5146
- action,
5147
- defaults = {}
5148
- }) {
5149
- const actionBase = {
5150
- // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
5151
- // @TODO: This should be fixed in the future.
5152
- createdAt: new Date(Date.now() - 500).toISOString(),
5153
- createdBy: getUUID(),
5154
- createdByRole: "FIELD_AGENT",
5155
- id: getUUID(),
5156
- createdAtLocation: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
5157
- declaration: generateActionDeclarationInput(configuration, action),
5158
- annotation: {},
5159
- status: ActionStatus.Accepted,
5160
- transactionId: getUUID(),
5161
- ...defaults
5162
- };
5163
- switch (action) {
5164
- case ActionType.READ:
5165
- return { ...actionBase, type: action };
5166
- case ActionType.MARKED_AS_DUPLICATE:
5167
- return { ...actionBase, type: action };
5168
- case ActionType.DECLARE:
5169
- return { ...actionBase, type: action };
5170
- case ActionType.UNASSIGN:
5171
- return { ...actionBase, type: action, assignedTo: null };
5172
- case ActionType.ASSIGN:
5173
- return { ...actionBase, assignedTo: getUUID(), type: action };
5174
- case ActionType.VALIDATE:
5175
- return { ...actionBase, type: action };
5176
- case ActionType.ARCHIVE:
5177
- return { ...actionBase, type: action };
5178
- case ActionType.REJECT:
5179
- return { ...actionBase, type: action };
5180
- case ActionType.CREATE:
5181
- return { ...actionBase, type: action };
5182
- case ActionType.NOTIFY:
5183
- return { ...actionBase, type: action };
5184
- case ActionType.PRINT_CERTIFICATE:
5185
- return { ...actionBase, type: action };
5186
- case ActionType.REQUEST_CORRECTION:
5187
- return { ...actionBase, type: action };
5188
- case ActionType.APPROVE_CORRECTION:
5189
- return { ...actionBase, requestId: getUUID(), type: action };
5190
- case ActionType.REJECT_CORRECTION:
5191
- return { ...actionBase, requestId: getUUID(), type: action };
5192
- case ActionType.REGISTER:
5193
- return {
5194
- ...actionBase,
5195
- type: action
5196
- };
5197
- case ActionType.DELETE:
5198
- case ActionType.DETECT_DUPLICATE:
5199
- default:
5200
- throw new Error(`Unsupported action type: ${action}`);
5201
- }
5202
- }
5203
- function generateEventDocument({
5204
- configuration,
5205
- actions
5206
- }) {
5207
- return {
5208
- trackingId: getUUID(),
5209
- type: configuration.id,
5210
- actions: actions.map(
5211
- (action) => generateActionDocument({ configuration, action })
5212
- ),
5627
+ label: {
5628
+ defaultMessage: "Register",
5629
+ description: "This is shown as the action name anywhere the user can trigger the action from",
5630
+ id: "event.football-club-membership.action.register.label"
5631
+ },
5632
+ review: TENNIS_CLUB_DECLARATION_REVIEW
5633
+ },
5634
+ {
5635
+ type: ActionType.REQUEST_CORRECTION,
5636
+ label: {
5637
+ defaultMessage: "Request correction",
5638
+ description: "This is shown as the action name anywhere the user can trigger the action from",
5639
+ id: "event.football-club-membership.action.correction.request.label"
5640
+ },
5641
+ onboardingForm: [
5642
+ {
5643
+ id: "correction-requester",
5644
+ type: PageTypes.enum.FORM,
5645
+ title: {
5646
+ id: "event.football-club-membership.action.requestCorrection.form.section.corrector",
5647
+ defaultMessage: "Correction requester",
5648
+ description: "This is the title of the section"
5649
+ },
5650
+ fields: [
5651
+ {
5652
+ id: "correction.requester.relationshop.intro",
5653
+ type: "PAGE_HEADER",
5654
+ label: {
5655
+ id: "correction.requester.relationshop.intro.label",
5656
+ defaultMessage: "Note: In the case that the child is now of legal age (18) then only they should be able to request a change to their birth record.",
5657
+ description: "The title for the corrector form"
5658
+ }
5659
+ },
5660
+ {
5661
+ id: "correction.requester.relationship",
5662
+ type: "RADIO_GROUP",
5663
+ label: {
5664
+ id: "v2.correction.corrector.title",
5665
+ defaultMessage: "Who is requesting a change to this record?",
5666
+ description: "The title for the corrector form"
5667
+ },
5668
+ defaultValue: "",
5669
+ options: [
5670
+ {
5671
+ value: "INFORMANT",
5672
+ label: {
5673
+ id: "v2.correction.corrector.informant",
5674
+ defaultMessage: "Informant",
5675
+ description: "Label for informant option in certificate correction form"
5676
+ }
5677
+ },
5678
+ {
5679
+ value: "ANOTHER_AGENT",
5680
+ label: {
5681
+ id: "v2.correction.corrector.anotherAgent",
5682
+ defaultMessage: "Another registration agent or field agent",
5683
+ description: "Label for another registration or field agent option in certificate correction form"
5684
+ }
5685
+ },
5686
+ {
5687
+ value: "REGISTRAR",
5688
+ label: {
5689
+ id: "v2.correction.corrector.me",
5690
+ defaultMessage: "Me (Registrar)",
5691
+ description: "Label for registrar option in certificate correction form"
5692
+ }
5693
+ },
5694
+ {
5695
+ value: "OTHER",
5696
+ label: {
5697
+ id: "v2.correction.corrector.others",
5698
+ defaultMessage: "Someone else",
5699
+ description: "Label for someone else option in certificate correction form"
5700
+ }
5701
+ }
5702
+ ]
5703
+ }
5704
+ ]
5705
+ },
5706
+ {
5707
+ id: "identity-check",
5708
+ type: PageTypes.enum.FORM,
5709
+ title: {
5710
+ id: "event.football-club-membership.action.requestCorrection.form.section.verify",
5711
+ defaultMessage: "Verify their identity",
5712
+ description: "This is the title of the section"
5713
+ },
5714
+ fields: [
5715
+ {
5716
+ id: "correction.identity-check.instructions",
5717
+ type: "PAGE_HEADER",
5718
+ label: {
5719
+ id: "correction.corrector.identity.instruction",
5720
+ defaultMessage: "Please verify the identity of the person making this request",
5721
+ description: "The title for the corrector form"
5722
+ }
5723
+ },
5724
+ {
5725
+ id: "correction.identity-check.verified",
5726
+ type: "RADIO_GROUP",
5727
+ label: {
5728
+ id: "correction.corrector.identity.verified.label",
5729
+ defaultMessage: "Identity verified",
5730
+ description: "The title for the corrector form"
5731
+ },
5732
+ defaultValue: "",
5733
+ required: true,
5734
+ options: [
5735
+ {
5736
+ value: "VERIFIED",
5737
+ label: {
5738
+ id: "correction.corrector.identity.verified",
5739
+ defaultMessage: "I have verified their identity",
5740
+ description: "Label for verified option in corrector identity check page"
5741
+ }
5742
+ }
5743
+ ]
5744
+ }
5745
+ ]
5746
+ }
5747
+ ],
5748
+ additionalDetailsForm: [
5749
+ {
5750
+ id: "correction-request.supporting-documents",
5751
+ type: PageTypes.enum.FORM,
5752
+ title: {
5753
+ id: "event.football-club-membership.action.requestCorrection.form.section.verify",
5754
+ defaultMessage: "Upload supporting documents",
5755
+ description: "This is the title of the section"
5756
+ },
5757
+ fields: [
5758
+ {
5759
+ id: "correction.supportingDocs.introduction",
5760
+ type: "PAGE_HEADER",
5761
+ label: {
5762
+ id: "correction.corrector.paragraph.title",
5763
+ defaultMessage: "For all record corrections at a minimum an affidavit must be provided. For material errors and omissions eg. in paternity cases, a court order must also be provided.",
5764
+ description: "The title for the corrector form"
5765
+ }
5766
+ },
5767
+ {
5768
+ id: "correction.supportingDocs",
5769
+ type: FieldType.FILE,
5770
+ label: {
5771
+ id: "correction.corrector.title",
5772
+ defaultMessage: "Upload supporting documents",
5773
+ description: "The title for the corrector form"
5774
+ }
5775
+ },
5776
+ {
5777
+ id: "correction.request.supportingDocuments",
5778
+ type: "RADIO_GROUP",
5779
+ label: {
5780
+ id: "correction.corrector.title",
5781
+ defaultMessage: "Who is requesting a change to this record?",
5782
+ description: "The title for the corrector form"
5783
+ },
5784
+ defaultValue: "",
5785
+ configuration: {
5786
+ styles: {
5787
+ size: "NORMAL"
5788
+ }
5789
+ },
5790
+ options: [
5791
+ {
5792
+ value: "ATTEST",
5793
+ label: {
5794
+ id: "correction.supportingDocuments.attest.label",
5795
+ defaultMessage: "I attest to seeing supporting documentation and have a copy filed at my office",
5796
+ description: ""
5797
+ }
5798
+ },
5799
+ {
5800
+ value: "NOT_NEEDED",
5801
+ label: {
5802
+ id: "correction.supportingDocuments.notNeeded.label",
5803
+ defaultMessage: "No supporting documents required",
5804
+ description: ""
5805
+ }
5806
+ }
5807
+ ]
5808
+ }
5809
+ ]
5810
+ },
5811
+ {
5812
+ id: "correction-request.additional-details",
5813
+ type: PageTypes.enum.FORM,
5814
+ title: {
5815
+ id: "event.football-club-membership.action.requestCorrection.form.section.corrector",
5816
+ defaultMessage: "Reason for correction",
5817
+ description: "This is the title of the section"
5818
+ },
5819
+ fields: [
5820
+ {
5821
+ id: "correction.request.reason",
5822
+ type: FieldType.TEXT,
5823
+ label: {
5824
+ id: "correction.reason.title",
5825
+ defaultMessage: "Reason for correction?",
5826
+ description: "The title for the corrector form"
5827
+ }
5828
+ }
5829
+ ]
5830
+ }
5831
+ ]
5832
+ },
5833
+ {
5834
+ type: ActionType.APPROVE_CORRECTION,
5835
+ label: {
5836
+ defaultMessage: "Approve correction",
5837
+ description: "This is shown as the action name anywhere the user can trigger the action from",
5838
+ id: "event.football-club-membership.action.correction.approve.label"
5839
+ }
5840
+ },
5841
+ {
5842
+ type: ActionType.PRINT_CERTIFICATE,
5843
+ label: {
5844
+ id: "v2.event.football-club-membership.action.collect-certificate.label",
5845
+ defaultMessage: "Print certificate",
5846
+ description: "This is shown as the action name anywhere the user can trigger the action from"
5847
+ },
5848
+ printForm: PRINT_CERTIFICATE_FORM,
5849
+ conditionals: [
5850
+ {
5851
+ type: "SHOW",
5852
+ conditional: defineConditional({
5853
+ type: "object",
5854
+ properties: {
5855
+ $event: {
5856
+ type: "object",
5857
+ properties: {
5858
+ actions: {
5859
+ type: "array",
5860
+ contains: {
5861
+ type: "object",
5862
+ properties: {
5863
+ type: {
5864
+ const: "REGISTER"
5865
+ },
5866
+ draft: {
5867
+ type: "boolean"
5868
+ }
5869
+ },
5870
+ required: ["type"],
5871
+ not: {
5872
+ properties: {
5873
+ draft: {
5874
+ const: true
5875
+ }
5876
+ }
5877
+ }
5878
+ }
5879
+ }
5880
+ },
5881
+ required: ["actions"]
5882
+ }
5883
+ },
5884
+ required: ["$event"]
5885
+ })
5886
+ }
5887
+ ]
5888
+ },
5889
+ {
5890
+ type: ActionType.ARCHIVE,
5891
+ label: {
5892
+ id: "v2.event.football-club-membership.action.archive.label",
5893
+ defaultMessage: "Archive",
5894
+ description: "This is shown as the action name anywhere the user can trigger the action from"
5895
+ }
5896
+ },
5897
+ {
5898
+ type: ActionType.REJECT,
5899
+ label: {
5900
+ id: "v2.event.football-club-membership.action.reject.label",
5901
+ defaultMessage: "Reject",
5902
+ description: "This is shown as the action name anywhere the user can trigger the action from"
5903
+ }
5904
+ }
5905
+ ],
5906
+ advancedSearch: [
5907
+ {
5908
+ title: {
5909
+ defaultMessage: "Registration details",
5910
+ description: "The title of Registration details accordion",
5911
+ id: "v2.advancedSearch.form.registrationDetails"
5912
+ },
5913
+ fields: [
5914
+ event("legalStatus.REGISTERED.createdAtLocation").exact(),
5915
+ event("legalStatus.REGISTERED.createdAt").range(),
5916
+ event("status", statusOptions).exact(),
5917
+ event("updatedAt", timePeriodOptions).range()
5918
+ ]
5919
+ },
5920
+ {
5921
+ title: {
5922
+ defaultMessage: "Applicant's details",
5923
+ description: "Applicant details search field section title",
5924
+ id: "v2.event.football-club-membership.search.applicants"
5925
+ },
5926
+ fields: [
5927
+ field("applicant.name").fuzzy(),
5928
+ field("applicant.dob").range(),
5929
+ field("applicant.email").exact()
5930
+ ]
5931
+ },
5932
+ {
5933
+ title: {
5934
+ defaultMessage: "Recommender's details",
5935
+ description: "Recommender details search field section title",
5936
+ id: "v2.event.football-club-membership.search.recommender"
5937
+ },
5938
+ fields: [field("recommender.name").fuzzy()]
5939
+ }
5940
+ ],
5941
+ declaration: TENNIS_CLUB_DECLARATION_FORM
5942
+ });
5943
+
5944
+ // ../commons/src/fixtures/library-membership-event.ts
5945
+ var libraryMembershipForm = defineDeclarationForm({
5946
+ label: {
5947
+ id: "v2.event.library-membership.action.declare.form.label",
5948
+ defaultMessage: "Library membership application",
5949
+ description: "This is what this form is referred as in the system"
5950
+ },
5951
+ pages: [
5952
+ {
5953
+ id: "member",
5954
+ title: {
5955
+ id: "v2.event.library-membership.action.declare.form.section.who.title",
5956
+ defaultMessage: "Who is applying for the membership?",
5957
+ description: "This is the title of the section"
5958
+ },
5959
+ fields: [
5960
+ {
5961
+ id: "member.firstname",
5962
+ type: FieldType.TEXT,
5963
+ required: true,
5964
+ conditionals: [],
5965
+ label: {
5966
+ defaultMessage: "Member's first name",
5967
+ description: "This is the label for the field",
5968
+ id: "v2.event.library-membership.action.declare.form.section.who.field.firstname.label"
5969
+ }
5970
+ },
5971
+ {
5972
+ id: "member.surname",
5973
+ type: FieldType.TEXT,
5974
+ required: true,
5975
+ conditionals: [],
5976
+ label: {
5977
+ defaultMessage: "Member's surname",
5978
+ description: "This is the label for the field",
5979
+ id: "v2.event.library-membership.action.declare.form.section.who.field.surname.label"
5980
+ }
5981
+ }
5982
+ ]
5983
+ }
5984
+ ]
5985
+ });
5986
+ var libraryMembershipEvent = defineConfig({
5987
+ id: "library-membership",
5988
+ label: {
5989
+ defaultMessage: "Library membership application",
5990
+ description: "This is what this event is referred as in the system",
5991
+ id: "event.library-membership.label"
5992
+ },
5993
+ title: {
5994
+ defaultMessage: "{member.firstname} {member.surname}",
5995
+ description: "This is the title of the summary",
5996
+ id: "v2.event.library-membership.title"
5997
+ },
5998
+ summary: { fields: [] },
5999
+ actions: [],
6000
+ declaration: libraryMembershipForm
6001
+ });
6002
+
6003
+ // ../commons/src/fixtures/v2-birth-event.ts
6004
+ var child = defineFormPage({
6005
+ id: "child",
6006
+ type: PageTypes.enum.FORM,
6007
+ title: {
6008
+ defaultMessage: "Child's details",
6009
+ description: "Form section title for Child",
6010
+ id: "v2.form.birth.child.title"
6011
+ },
6012
+ fields: [
6013
+ {
6014
+ id: "child.firstNames",
6015
+ type: FieldType.TEXT,
6016
+ required: true,
6017
+ configuration: { maxLength: 32 },
6018
+ hideLabel: true,
6019
+ label: {
6020
+ defaultMessage: "Child's first name",
6021
+ description: "This is the label for the field",
6022
+ id: "v2.event.birth.action.declare.form.section.child.field.name.label"
6023
+ }
6024
+ },
6025
+ {
6026
+ id: "child.familyName",
6027
+ type: FieldType.TEXT,
6028
+ required: true,
6029
+ configuration: { maxLength: 32 },
6030
+ hideLabel: true,
6031
+ label: {
6032
+ defaultMessage: "Child's last name",
6033
+ description: "This is the label for the field",
6034
+ id: "v2.event.birth.action.declare.form.section.child.field.name.label"
6035
+ }
6036
+ },
6037
+ {
6038
+ id: "child.DoB",
6039
+ type: "DATE",
6040
+ required: true,
6041
+ label: {
6042
+ defaultMessage: "Date of birth",
6043
+ description: "This is the label for the field",
6044
+ id: "v2.event.birth.action.declare.form.section.child.field.dob.label"
6045
+ }
6046
+ }
6047
+ ]
6048
+ });
6049
+ var mother = defineFormPage({
6050
+ id: "mother",
6051
+ type: PageTypes.enum.FORM,
6052
+ title: {
6053
+ defaultMessage: "Mother's details",
6054
+ description: "Form section title for mothers details",
6055
+ id: "v2.form.section.mother.title"
6056
+ },
6057
+ fields: [
6058
+ {
6059
+ id: "mother.firstNames",
6060
+ configuration: { maxLength: 32 },
6061
+ type: FieldType.TEXT,
6062
+ required: true,
6063
+ label: {
6064
+ defaultMessage: "First name(s)",
6065
+ description: "This is the label for the field",
6066
+ id: `v2.event.birth.action.declare.form.section.person.field.firstname.label`
6067
+ }
6068
+ },
6069
+ {
6070
+ id: `mother.familyName`,
6071
+ configuration: { maxLength: 32 },
6072
+ type: FieldType.TEXT,
6073
+ required: true,
6074
+ label: {
6075
+ defaultMessage: "Last name",
6076
+ description: "This is the label for the field",
6077
+ id: `v2.event.birth.action.declare.form.section.person.field.surname.label`
6078
+ }
6079
+ },
6080
+ {
6081
+ id: `mother.DoB`,
6082
+ type: "DATE",
6083
+ required: true,
6084
+ label: {
6085
+ defaultMessage: "Date of birth",
6086
+ description: "This is the label for the field",
6087
+ id: `v2.event.birth.action.declare.form.section.person.field.dob.label`
6088
+ }
6089
+ },
6090
+ {
6091
+ id: "mother.identifier",
6092
+ type: FieldType.ID,
6093
+ required: true,
6094
+ label: {
6095
+ defaultMessage: "ID Number",
6096
+ description: "This is the label for the field",
6097
+ id: `v2.event.birth.action.declare.form.section.person.field.nid.label`
6098
+ }
6099
+ }
6100
+ ]
6101
+ });
6102
+ var BIRTH_DECLARATION_FORM = defineDeclarationForm({
6103
+ label: {
6104
+ defaultMessage: "Birth decalration form",
6105
+ id: "v2.event.birth.action.declare.form.label",
6106
+ description: "This is what this form is referred as in the system"
6107
+ },
6108
+ pages: [child, mother]
6109
+ });
6110
+ var v2BirthEvent = defineConfig({
6111
+ id: BIRTH_EVENT,
6112
+ title: {
6113
+ defaultMessage: "{child.name.firstname} {child.name.surname}",
6114
+ description: "This is the title of the summary",
6115
+ id: "v2.event.birth.title"
6116
+ },
6117
+ label: {
6118
+ defaultMessage: "Birth",
6119
+ description: "This is what this event is referred as in the system",
6120
+ id: "v2.event.birth.label"
6121
+ },
6122
+ summary: {
6123
+ fields: []
6124
+ },
6125
+ actions: [],
6126
+ declaration: BIRTH_DECLARATION_FORM
6127
+ });
6128
+
6129
+ // ../commons/src/events/test.utils.ts
6130
+ var import_zod33 = require("zod");
6131
+ var TestUserRole = import_zod33.z.enum([
6132
+ "FIELD_AGENT",
6133
+ "LOCAL_REGISTRAR",
6134
+ "LOCAL_SYSTEM_ADMIN",
6135
+ "NATIONAL_REGISTRAR",
6136
+ "REGISTRATION_AGENT"
6137
+ ]);
6138
+ function pickRandom(rng, items) {
6139
+ return items[Math.floor(rng() * items.length)];
6140
+ }
6141
+ function generateRandomName(rng) {
6142
+ const firstnames = [
6143
+ "Danny",
6144
+ "John",
6145
+ "Jane",
6146
+ "Emily",
6147
+ "Michael",
6148
+ "Sarah",
6149
+ "Chris",
6150
+ "Jessica",
6151
+ "Sara",
6152
+ "Sarachella",
6153
+ "Sarandera",
6154
+ "Zara"
6155
+ ];
6156
+ const surnames = [
6157
+ "Doe",
6158
+ "Smith",
6159
+ "Johnson",
6160
+ "Brown",
6161
+ "Williams",
6162
+ "Jones",
6163
+ "Garcia",
6164
+ "Miller",
6165
+ "Saranen",
6166
+ "Sarajanen",
6167
+ "Sarthua",
6168
+ "Tsarakovski",
6169
+ "Salamander",
6170
+ "Zarathustra"
6171
+ ];
6172
+ return {
6173
+ firstname: pickRandom(rng, firstnames),
6174
+ surname: pickRandom(rng, surnames)
6175
+ };
6176
+ }
6177
+ function mapFieldTypeToMockValue(field2, i, rng) {
6178
+ switch (field2.type) {
6179
+ case FieldType.DIVIDER:
6180
+ case FieldType.TEXT:
6181
+ case FieldType.TEXTAREA:
6182
+ case FieldType.BULLET_LIST:
6183
+ case FieldType.PAGE_HEADER:
6184
+ case FieldType.LOCATION:
6185
+ case FieldType.SELECT:
6186
+ case FieldType.COUNTRY:
6187
+ case FieldType.RADIO_GROUP:
6188
+ case FieldType.PARAGRAPH:
6189
+ case FieldType.ADMINISTRATIVE_AREA:
6190
+ case FieldType.FACILITY:
6191
+ case FieldType.PHONE:
6192
+ case FieldType.ID:
6193
+ case FieldType.OFFICE:
6194
+ return `${field2.id}-${field2.type}-${i}`;
6195
+ case FieldType.NAME:
6196
+ return generateRandomName(rng);
6197
+ case FieldType.NUMBER:
6198
+ return 19;
6199
+ case FieldType.EMAIL:
6200
+ return "test@opencrvs.org";
6201
+ case FieldType.ADDRESS:
6202
+ return {
6203
+ country: "FAR",
6204
+ addressType: AddressType.DOMESTIC,
6205
+ province: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
6206
+ district: "5ef450bc-712d-48ad-93f3-8da0fa453baa",
6207
+ urbanOrRural: "URBAN",
6208
+ town: "Example Town",
6209
+ residentialArea: "Example Residential Area",
6210
+ street: "Example Street",
6211
+ number: "55",
6212
+ zipCode: "123456"
6213
+ };
6214
+ case FieldType.DATE:
6215
+ return "2021-01-01";
6216
+ case FieldType.DATE_RANGE:
6217
+ return ["2021-01-01", "2021-01-02"];
6218
+ case FieldType.CHECKBOX:
6219
+ return true;
6220
+ case FieldType.SIGNATURE:
6221
+ case FieldType.FILE:
6222
+ return {
6223
+ filename: "4f095fc4-4312-4de2-aa38-86dcc0f71044.png",
6224
+ originalFilename: "abcd.png",
6225
+ type: "image/png"
6226
+ };
6227
+ case FieldType.FILE_WITH_OPTIONS:
6228
+ case FieldType.DATA:
6229
+ return void 0;
6230
+ }
6231
+ }
6232
+ function fieldConfigsToActionPayload(fields, rng) {
6233
+ return fields.reduce(
6234
+ (acc, field2, i) => ({
6235
+ ...acc,
6236
+ [field2.id]: mapFieldTypeToMockValue(field2, i, rng)
6237
+ }),
6238
+ {}
6239
+ );
6240
+ }
6241
+ function generateActionDeclarationInput(configuration, action, rng) {
6242
+ const parsed = DeclarationUpdateActions.safeParse(action);
6243
+ if (parsed.success) {
6244
+ const fields = getDeclarationFields(configuration);
6245
+ const declarationConfig = getDeclaration(configuration);
6246
+ const declaration = fieldConfigsToActionPayload(fields, rng);
6247
+ return omitHiddenPaginatedFields(declarationConfig, declaration);
6248
+ }
6249
+ console.warn(`${action} is not a declaration action. Setting data as {}.`);
6250
+ return {};
6251
+ }
6252
+ function generateActionAnnotationInput(configuration, action, rng) {
6253
+ const actionConfig = configuration.actions.find(
6254
+ (ac) => ac.type === action
6255
+ );
6256
+ const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
6257
+ const annotation = fieldConfigsToActionPayload(annotationFields, rng);
6258
+ const visibleVerificationPageIds = getVisibleVerificationPageIds(
6259
+ findRecordActionPages(configuration, action),
6260
+ annotation
6261
+ );
6262
+ const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
6263
+ (acc, pageId) => ({
6264
+ ...acc,
6265
+ [pageId]: true
6266
+ }),
6267
+ {}
6268
+ );
6269
+ const fieldBasedPayload = omitHiddenFields(annotationFields, annotation);
6270
+ return {
6271
+ ...fieldBasedPayload,
6272
+ ...visiblePageVerificationMap
6273
+ };
6274
+ }
6275
+ function eventPayloadGenerator(rng) {
6276
+ return {
6277
+ create: (input = {}) => ({
6278
+ transactionId: input.transactionId ?? getUUID(),
6279
+ type: input.type ?? TENNIS_CLUB_MEMBERSHIP
6280
+ }),
6281
+ patch: (id, input = {}) => ({
6282
+ transactionId: input.transactionId ?? getUUID(),
6283
+ type: input.type ?? TENNIS_CLUB_MEMBERSHIP,
6284
+ id
6285
+ }),
6286
+ draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
6287
+ {
6288
+ id: getUUID(),
6289
+ eventId,
6290
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
6291
+ transactionId: getUUID(),
6292
+ action: {
6293
+ transactionId: getUUID(),
6294
+ type: actionType,
6295
+ status: ActionStatus.Accepted,
6296
+ declaration: {
6297
+ "applicant.name": {
6298
+ firstname: "Max",
6299
+ surname: "McLaren"
6300
+ },
6301
+ "applicant.dob": "2020-01-02",
6302
+ "recommender.none": true
6303
+ },
6304
+ annotation: {
6305
+ "correction.requester.relationship": "ANOTHER_AGENT",
6306
+ "correction.request.reason": "Child's name was incorrect"
6307
+ },
6308
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
6309
+ createdBy: "@todo",
6310
+ createdByUserType: TokenUserType.Enum.user,
6311
+ createdByRole: "@todo",
6312
+ createdAtLocation: "@todo"
6313
+ }
6314
+ },
6315
+ input
6316
+ ),
6317
+ actions: {
6318
+ declare: (eventId, input = {}) => ({
6319
+ type: ActionType.DECLARE,
6320
+ transactionId: input.transactionId ?? getUUID(),
6321
+ declaration: input.declaration ?? generateActionDeclarationInput(
6322
+ tennisClubMembershipEvent,
6323
+ ActionType.DECLARE,
6324
+ rng
6325
+ ),
6326
+ annotation: input.annotation ?? generateActionAnnotationInput(
6327
+ tennisClubMembershipEvent,
6328
+ ActionType.DECLARE,
6329
+ rng
6330
+ ),
6331
+ eventId,
6332
+ ...input
6333
+ }),
6334
+ /**
6335
+ * Notify allows sending incomplete data. Think it as 'partial declare' for now.
6336
+ */
6337
+ notify: (eventId, input = {}) => {
6338
+ let declaration = input.declaration;
6339
+ if (!declaration) {
6340
+ const partialDeclaration = (0, import_lodash2.omitBy)(
6341
+ generateActionDeclarationInput(
6342
+ tennisClubMembershipEvent,
6343
+ ActionType.DECLARE,
6344
+ rng
6345
+ ),
6346
+ import_lodash2.isString
6347
+ );
6348
+ declaration = partialDeclaration;
6349
+ }
6350
+ return {
6351
+ type: ActionType.NOTIFY,
6352
+ transactionId: input.transactionId ?? getUUID(),
6353
+ declaration,
6354
+ eventId,
6355
+ keepAssignment: input.keepAssignment
6356
+ };
6357
+ },
6358
+ validate: (eventId, input = {}) => ({
6359
+ type: ActionType.VALIDATE,
6360
+ transactionId: input.transactionId ?? getUUID(),
6361
+ declaration: input.declaration ?? generateActionDeclarationInput(
6362
+ tennisClubMembershipEvent,
6363
+ ActionType.VALIDATE,
6364
+ rng
6365
+ ),
6366
+ annotation: input.annotation ?? generateActionAnnotationInput(
6367
+ tennisClubMembershipEvent,
6368
+ ActionType.VALIDATE,
6369
+ rng
6370
+ ),
6371
+ duplicates: [],
6372
+ eventId,
6373
+ ...input
6374
+ }),
6375
+ assign: (eventId, input = {}) => ({
6376
+ type: ActionType.ASSIGN,
6377
+ transactionId: input.transactionId ?? getUUID(),
6378
+ declaration: {},
6379
+ assignedTo: input.assignedTo ?? getUUID(),
6380
+ eventId
6381
+ }),
6382
+ unassign: (eventId, input = {}) => ({
6383
+ type: ActionType.UNASSIGN,
6384
+ transactionId: input.transactionId ?? getUUID(),
6385
+ declaration: {},
6386
+ assignedTo: null,
6387
+ eventId
6388
+ }),
6389
+ archive: (eventId, input = {}, isDuplicate) => ({
6390
+ type: ActionType.ARCHIVE,
6391
+ transactionId: input.transactionId ?? getUUID(),
6392
+ declaration: {},
6393
+ // @TODO: Check whether generator is needed?
6394
+ annotation: {},
6395
+ duplicates: [],
6396
+ eventId,
6397
+ reason: {
6398
+ message: `${ActionType.ARCHIVE}`,
6399
+ isDuplicate: isDuplicate ?? false
6400
+ },
6401
+ ...input
6402
+ }),
6403
+ reject: (eventId, input = {}) => ({
6404
+ type: ActionType.REJECT,
6405
+ transactionId: input.transactionId ?? getUUID(),
6406
+ declaration: {},
6407
+ annotation: input.annotation ?? generateActionAnnotationInput(
6408
+ tennisClubMembershipEvent,
6409
+ ActionType.REJECT,
6410
+ rng
6411
+ ),
6412
+ duplicates: [],
6413
+ eventId,
6414
+ reason: { message: `${ActionType.REJECT}` },
6415
+ ...input
6416
+ }),
6417
+ register: (eventId, input = {}) => ({
6418
+ type: ActionType.REGISTER,
6419
+ transactionId: input.transactionId ?? getUUID(),
6420
+ declaration: input.declaration ?? generateActionDeclarationInput(
6421
+ tennisClubMembershipEvent,
6422
+ ActionType.REGISTER,
6423
+ rng
6424
+ ),
6425
+ annotation: input.annotation ?? generateActionAnnotationInput(
6426
+ tennisClubMembershipEvent,
6427
+ ActionType.REGISTER,
6428
+ rng
6429
+ ),
6430
+ eventId,
6431
+ ...input
6432
+ }),
6433
+ printCertificate: (eventId, input = {}) => ({
6434
+ type: ActionType.PRINT_CERTIFICATE,
6435
+ transactionId: input.transactionId ?? getUUID(),
6436
+ declaration: {},
6437
+ annotation: input.annotation ?? generateActionAnnotationInput(
6438
+ tennisClubMembershipEvent,
6439
+ ActionType.PRINT_CERTIFICATE,
6440
+ rng
6441
+ ),
6442
+ eventId,
6443
+ ...input
6444
+ }),
6445
+ correction: {
6446
+ request: (eventId, input = {}) => ({
6447
+ type: ActionType.REQUEST_CORRECTION,
6448
+ transactionId: input.transactionId ?? getUUID(),
6449
+ declaration: input.declaration ?? generateActionDeclarationInput(
6450
+ tennisClubMembershipEvent,
6451
+ ActionType.REQUEST_CORRECTION,
6452
+ rng
6453
+ ),
6454
+ annotation: input.annotation ?? generateActionAnnotationInput(
6455
+ tennisClubMembershipEvent,
6456
+ ActionType.REQUEST_CORRECTION,
6457
+ rng
6458
+ ),
6459
+ eventId,
6460
+ keepAssignment: input.keepAssignment
6461
+ }),
6462
+ approve: (eventId, requestId, input = {}) => ({
6463
+ type: ActionType.APPROVE_CORRECTION,
6464
+ transactionId: input.transactionId ?? getUUID(),
6465
+ declaration: {},
6466
+ annotation: input.annotation ?? generateActionAnnotationInput(
6467
+ tennisClubMembershipEvent,
6468
+ ActionType.APPROVE_CORRECTION,
6469
+ rng
6470
+ ),
6471
+ eventId,
6472
+ requestId,
6473
+ keepAssignment: input.keepAssignment
6474
+ }),
6475
+ reject: (eventId, requestId, input = {}) => ({
6476
+ type: ActionType.REJECT_CORRECTION,
6477
+ transactionId: input.transactionId ?? getUUID(),
6478
+ declaration: {},
6479
+ annotation: input.annotation ?? generateActionAnnotationInput(
6480
+ tennisClubMembershipEvent,
6481
+ ActionType.REJECT_CORRECTION,
6482
+ rng
6483
+ ),
6484
+ eventId,
6485
+ requestId,
6486
+ keepAssignment: input.keepAssignment
6487
+ })
6488
+ }
6489
+ }
6490
+ };
6491
+ }
6492
+ function generateActionDocument({
6493
+ configuration,
6494
+ action,
6495
+ rng = () => 0.1,
6496
+ defaults = {}
6497
+ }) {
6498
+ const actionBase = {
6499
+ // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
6500
+ // @TODO: This should be fixed in the future.
6501
+ createdAt: new Date(Date.now() - 500).toISOString(),
6502
+ createdBy: getUUID(),
6503
+ createdByUserType: TokenUserType.Enum.user,
6504
+ createdByRole: TestUserRole.Enum.FIELD_AGENT,
6505
+ id: getUUID(),
6506
+ createdAtLocation: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
6507
+ declaration: generateActionDeclarationInput(configuration, action, rng),
6508
+ annotation: {},
6509
+ status: ActionStatus.Accepted,
6510
+ transactionId: getUUID(),
6511
+ ...defaults
6512
+ };
6513
+ switch (action) {
6514
+ case ActionType.READ:
6515
+ return { ...actionBase, type: action };
6516
+ case ActionType.MARKED_AS_DUPLICATE:
6517
+ return { ...actionBase, type: action };
6518
+ case ActionType.DECLARE:
6519
+ return { ...actionBase, type: action };
6520
+ case ActionType.UNASSIGN:
6521
+ return { ...actionBase, type: action, assignedTo: null };
6522
+ case ActionType.ASSIGN:
6523
+ return { ...actionBase, assignedTo: getUUID(), type: action };
6524
+ case ActionType.VALIDATE:
6525
+ return { ...actionBase, type: action };
6526
+ case ActionType.ARCHIVE:
6527
+ return { ...actionBase, type: action, reason: { message: "Archive" } };
6528
+ case ActionType.REJECT:
6529
+ return { ...actionBase, type: action, reason: { message: "Reject" } };
6530
+ case ActionType.CREATE:
6531
+ return { ...actionBase, type: action };
6532
+ case ActionType.NOTIFY:
6533
+ return { ...actionBase, type: action };
6534
+ case ActionType.PRINT_CERTIFICATE:
6535
+ return { ...actionBase, type: action };
6536
+ case ActionType.REQUEST_CORRECTION:
6537
+ return { ...actionBase, type: action };
6538
+ case ActionType.APPROVE_CORRECTION:
6539
+ return { ...actionBase, requestId: getUUID(), type: action };
6540
+ case ActionType.REJECT_CORRECTION:
6541
+ return {
6542
+ ...actionBase,
6543
+ requestId: getUUID(),
6544
+ type: action
6545
+ };
6546
+ case ActionType.REGISTER:
6547
+ return {
6548
+ ...actionBase,
6549
+ type: action
6550
+ };
6551
+ case ActionType.DELETE:
6552
+ case ActionType.DETECT_DUPLICATE:
6553
+ default:
6554
+ throw new Error(`Unsupported action type: ${action}`);
6555
+ }
6556
+ }
6557
+ function generateEventDocument({
6558
+ configuration,
6559
+ actions,
6560
+ rng = () => 0.1
6561
+ }) {
6562
+ return {
6563
+ trackingId: getUUID(),
6564
+ type: configuration.id,
6565
+ actions: actions.map(
6566
+ (action) => generateActionDocument({ configuration, action, rng })
6567
+ ),
5213
6568
  // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
5214
6569
  // @TODO: This should be fixed in the future.
5215
6570
  createdAt: new Date(Date.now() - 1e3).toISOString(),
@@ -5219,10 +6574,16 @@ function generateEventDocument({
5219
6574
  updatedAt: new Date(Date.now() - 1e3).toISOString()
5220
6575
  };
5221
6576
  }
5222
- function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
6577
+ function generateEventDraftDocument({
6578
+ eventId,
6579
+ actionType,
6580
+ rng = () => 0.1,
6581
+ declaration = {}
6582
+ }) {
5223
6583
  const action = generateActionDocument({
5224
6584
  configuration: tennisClubMembershipEvent,
5225
- action: actionType
6585
+ action: actionType,
6586
+ rng
5226
6587
  });
5227
6588
  return {
5228
6589
  id: getUUID(),
@@ -5238,83 +6599,90 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, de
5238
6599
  eventId
5239
6600
  };
5240
6601
  }
5241
- function getEventStatus() {
5242
- const statuses = [
5243
- EventStatus.CREATED,
5244
- EventStatus.REGISTERED,
5245
- EventStatus.DECLARED
5246
- ];
5247
- const randomIndex = Math.floor(Math.random() * 3);
5248
- return statuses[randomIndex];
6602
+ function getRandomDatetime(rng, start, end) {
6603
+ const range = end.getTime() - start.getTime();
6604
+ const offset = Math.floor(rng() * range);
6605
+ const randomDate = new Date(start.getTime() + offset);
6606
+ return randomDate.toISOString();
5249
6607
  }
5250
- function getTrackingId() {
5251
- const uuid = getUUID().replace(/-/g, "");
5252
- const trackingId = uuid.slice(0, 6).toUpperCase();
5253
- return trackingId;
6608
+ function getRandomDate(rng, start, end) {
6609
+ const datetime = getRandomDatetime(rng, new Date(start), new Date(end));
6610
+ return datetime.split("T")[0];
5254
6611
  }
5255
- function getRandomApplicant() {
5256
- const firstNames = [
5257
- "Danny",
5258
- "John",
5259
- "Jane",
5260
- "Emily",
5261
- "Michael",
5262
- "Sarah",
5263
- "Chris",
5264
- "Jessica"
5265
- ];
5266
- const surnames = [
5267
- "Doe",
5268
- "Smith",
5269
- "Johnson",
5270
- "Brown",
5271
- "Williams",
5272
- "Jones",
5273
- "Garcia",
5274
- "Miller"
5275
- ];
5276
- function getRandomDate(start, end) {
5277
- const randomDate = new Date(
5278
- start.getTime() + Math.random() * (end.getTime() - start.getTime())
5279
- );
5280
- return randomDate.toISOString().split("T")[0];
5281
- }
5282
- const randomFirstName = firstNames[Math.floor(Math.random() * firstNames.length)];
5283
- const randomSurname = surnames[Math.floor(Math.random() * surnames.length)];
5284
- const randomDob = getRandomDate(
5285
- /* @__PURE__ */ new Date("1990-01-01"),
5286
- /* @__PURE__ */ new Date("2010-12-31")
5287
- );
6612
+ function generateRandomApplicant(rng) {
6613
+ const { firstname, surname } = generateRandomName(rng);
6614
+ const randomDob = getRandomDate(rng, "1990-01-01", "2010-12-31");
5288
6615
  return {
5289
6616
  "recommender.none": true,
5290
- "applicant.firstname": randomFirstName,
5291
- "applicant.surname": randomSurname,
6617
+ "applicant.name": {
6618
+ firstname,
6619
+ surname
6620
+ },
5292
6621
  "applicant.dob": randomDob
5293
6622
  };
5294
6623
  }
5295
- var eventQueryDataGenerator = (overrides = {}) => ({
5296
- id: overrides.id ?? getUUID(),
5297
- title: overrides.title ?? "Danny Doe",
5298
- type: overrides.type ?? "tennis-club-membership",
5299
- status: overrides.status ?? getEventStatus(),
5300
- createdAt: overrides.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
5301
- createdBy: overrides.createdBy ?? getUUID(),
5302
- createdAtLocation: overrides.createdAtLocation ?? getUUID(),
5303
- updatedAtLocation: overrides.updatedAtLocation ?? getUUID(),
5304
- updatedAt: overrides.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
5305
- assignedTo: overrides.assignedTo ?? null,
5306
- updatedBy: overrides.updatedBy ?? getUUID(),
5307
- updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
5308
- flags: [],
5309
- legalStatuses: overrides.legalStatuses ?? {},
5310
- declaration: overrides.declaration ?? getRandomApplicant(),
5311
- trackingId: overrides.trackingId ?? getTrackingId()
5312
- });
6624
+ function createPrng(seed) {
6625
+ const MODULUS = 2 ** 32;
6626
+ const MULTIPLIER = 1664525;
6627
+ const INCREMENT = 1013904223;
6628
+ let state = seed >>> 0;
6629
+ return () => {
6630
+ state = (MULTIPLIER * state + INCREMENT) % MODULUS;
6631
+ return state / MODULUS;
6632
+ };
6633
+ }
6634
+ function generateUuid(rng) {
6635
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
6636
+ const r = Math.floor(rng() * 16);
6637
+ const v = c === "x" ? r : r & 3 | 8;
6638
+ return v.toString(16);
6639
+ });
6640
+ }
6641
+ function generateTrackingId(rng) {
6642
+ const uuid = generateUuid(rng).replace(/-/g, "");
6643
+ const trackingId = uuid.slice(0, 6).toUpperCase();
6644
+ return trackingId;
6645
+ }
6646
+ function generateRandomSignature(rng) {
6647
+ return `/random-bucket/${generateUuid(rng)}.png`;
6648
+ }
6649
+ var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
6650
+ const rng = createPrng(seed);
6651
+ const createdAt = getRandomDatetime(
6652
+ rng,
6653
+ /* @__PURE__ */ new Date("2024-01-01"),
6654
+ /* @__PURE__ */ new Date("2024-12-31")
6655
+ );
6656
+ return {
6657
+ id: overrides.id ?? generateUuid(rng),
6658
+ type: overrides.type ?? TENNIS_CLUB_MEMBERSHIP,
6659
+ status: overrides.status ?? pickRandom(rng, EventStatus.options),
6660
+ createdAt: overrides.createdAt ?? createdAt,
6661
+ createdByUserType: overrides.createdByUserType ?? "user",
6662
+ createdBy: overrides.createdBy ?? generateUuid(rng),
6663
+ createdAtLocation: overrides.createdAtLocation ?? generateUuid(rng),
6664
+ updatedAtLocation: overrides.updatedAtLocation ?? generateUuid(rng),
6665
+ createdBySignature: overrides.createdBySignature ?? generateRandomSignature(rng),
6666
+ updatedAt: overrides.updatedAt ?? (0, import_addDays.default)(new Date(createdAt), 1).toISOString(),
6667
+ assignedTo: overrides.assignedTo ?? null,
6668
+ updatedBy: overrides.updatedBy ?? generateUuid(rng),
6669
+ updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
6670
+ flags: [],
6671
+ legalStatuses: overrides.legalStatuses ?? {},
6672
+ declaration: overrides.declaration ?? generateRandomApplicant(rng),
6673
+ trackingId: overrides.trackingId ?? generateTrackingId(rng)
6674
+ };
6675
+ };
5313
6676
  var generateTranslationConfig = (message) => ({
5314
6677
  defaultMessage: message,
5315
6678
  description: "Description for ${message}",
5316
6679
  id: message
5317
6680
  });
6681
+ var BearerTokenByUserType = {
6682
+ fieldAgent: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJyZWNvcmQuZGVjbGFyZS1iaXJ0aCIsInJlY29yZC5kZWNsYXJlLWRlYXRoIiwicmVjb3JkLmRlY2xhcmUtbWFycmlhZ2UiLCJyZWNvcmQuZGVjbGFyYXRpb24tc3VibWl0LWluY29tcGxldGUiLCJyZWNvcmQuZGVjbGFyYXRpb24tc3VibWl0LWZvci1yZXZpZXciLCJzZWFyY2guYmlydGgiLCJzZWFyY2guZGVhdGgiLCJzZWFyY2gubWFycmlhZ2UiLCJkZW1vIl0sInVzZXJUeXBlIjoidXNlciIsImlhdCI6MTc0ODUyNjQ4OCwiZXhwIjoxNzQ5MTMxMjg4LCJhdWQiOlsib3BlbmNydnM6YXV0aC11c2VyIiwib3BlbmNydnM6dXNlci1tZ250LXVzZXIiLCJvcGVuY3J2czpoZWFydGgtdXNlciIsIm9wZW5jcnZzOmdhdGV3YXktdXNlciIsIm9wZW5jcnZzOm5vdGlmaWNhdGlvbi11c2VyIiwib3BlbmNydnM6d29ya2Zsb3ctdXNlciIsIm9wZW5jcnZzOnNlYXJjaC11c2VyIiwib3BlbmNydnM6bWV0cmljcy11c2VyIiwib3BlbmNydnM6Y291bnRyeWNvbmZpZy11c2VyIiwib3BlbmNydnM6d2ViaG9va3MtdXNlciIsIm9wZW5jcnZzOmNvbmZpZy11c2VyIiwib3BlbmNydnM6ZG9jdW1lbnRzLXVzZXIiXSwiaXNzIjoib3BlbmNydnM6YXV0aC1zZXJ2aWNlIiwic3ViIjoiNjc3ZmIwODYzMGYzYWJmYTMzMDcyNzBmIn0.qLif2TmTPpqfbSUWR3TSfWf5syyCtRRJV-fDOZBtN9th-gdT0sUPZp5PB_t2QHHCLes7JLDlSA9CGNIbVvRR8a7EedXTAf0T7pwiE96PgljHSKI9jLMCYb_rhqnl8BwfsxAU3qv8EBYM9rDlcabl5iKnAOM-YLMv63CRMQxZOZ0O3Wl1Xil82dp6PqW_Lom5Qd-Esftt9BWXk5gxmqq-YegT8qU9n3hDXEsOvmIyYQvPDwmUOB-xp74CKJk_o3eBuq4TVCMYxY-tS9qkkn2A7Txhh-bzWMVNrQjQ1Yumvs8gi_F-XYTi89QbZVz8PzJ9kT8w3jshYwmAy7be9M-EQg",
6683
+ registrationAgent: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJyZWNvcmQucmVhZCIsInJlY29yZC5kZWNsYXJlLWJpcnRoIiwicmVjb3JkLmRlY2xhcmUtZGVhdGgiLCJyZWNvcmQuZGVjbGFyZS1tYXJyaWFnZSIsInJlY29yZC5kZWNsYXJhdGlvbi1lZGl0IiwicmVjb3JkLmRlY2xhcmF0aW9uLXN1Ym1pdC1mb3ItYXBwcm92YWwiLCJyZWNvcmQuZGVjbGFyYXRpb24tc3VibWl0LWZvci11cGRhdGVzIiwicmVjb3JkLmRlY2xhcmF0aW9uLWFyY2hpdmUiLCJyZWNvcmQuZGVjbGFyYXRpb24tcmVpbnN0YXRlIiwicmVjb3JkLnJlZ2lzdHJhdGlvbi1yZXF1ZXN0LWNvcnJlY3Rpb24iLCJyZWNvcmQuZGVjbGFyYXRpb24tcHJpbnQtc3VwcG9ydGluZy1kb2N1bWVudHMiLCJyZWNvcmQuZXhwb3J0LXJlY29yZHMiLCJyZWNvcmQucmVnaXN0cmF0aW9uLXByaW50Jmlzc3VlLWNlcnRpZmllZC1jb3BpZXMiLCJwZXJmb3JtYW5jZS5yZWFkIiwicGVyZm9ybWFuY2UucmVhZC1kYXNoYm9hcmRzIiwib3JnYW5pc2F0aW9uLnJlYWQtbG9jYXRpb25zOm15LW9mZmljZSIsInNlYXJjaC5iaXJ0aCIsInNlYXJjaC5kZWF0aCIsInNlYXJjaC5tYXJyaWFnZSIsImRlbW8iXSwidXNlclR5cGUiOiJ1c2VyIiwiaWF0IjoxNzQ4NTI2NDY4LCJleHAiOjE3NDkxMzEyNjgsImF1ZCI6WyJvcGVuY3J2czphdXRoLXVzZXIiLCJvcGVuY3J2czp1c2VyLW1nbnQtdXNlciIsIm9wZW5jcnZzOmhlYXJ0aC11c2VyIiwib3BlbmNydnM6Z2F0ZXdheS11c2VyIiwib3BlbmNydnM6bm90aWZpY2F0aW9uLXVzZXIiLCJvcGVuY3J2czp3b3JrZmxvdy11c2VyIiwib3BlbmNydnM6c2VhcmNoLXVzZXIiLCJvcGVuY3J2czptZXRyaWNzLXVzZXIiLCJvcGVuY3J2czpjb3VudHJ5Y29uZmlnLXVzZXIiLCJvcGVuY3J2czp3ZWJob29rcy11c2VyIiwib3BlbmNydnM6Y29uZmlnLXVzZXIiLCJvcGVuY3J2czpkb2N1bWVudHMtdXNlciJdLCJpc3MiOiJvcGVuY3J2czphdXRoLXNlcnZpY2UiLCJzdWIiOiI2NzdmYjA4NjMwZjNhYmZhMzMwNzI3MTgifQ.C0R3cda9tczdJyadyJzk_wjVx79yiQ4r2BZbrF5VMTol97CwqMk1cPKVv5xZR1fHW5nhYl1X_vsmTYx-p9oSmcAYVud-4Z24TrA3oZ214zCB8RW_RmmFzJSczwe-9Son-96JOpRJTz2F-F_SSmblF0cjndJ-iXCAbOn1hmQ1q45NqaV-oFaFWigvAaRoBFcEvGufQxss_NjRmG12ooENSfWQl0tYM9BmTw4JQo2xerwJcgaJTrtDgRagkuiR7zhVNjcoT64AQiSRp5KmWRhbU4ozlJ2tfy1ccD9jJkbQTf1AZT2pl1diusjstJYFuM9QPFPOyCO0umaxYfgSer_Hmg",
6684
+ localRegistrar: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJyZWNvcmQucmVhZCIsInJlY29yZC5kZWNsYXJlLWJpcnRoIiwicmVjb3JkLmRlY2xhcmUtZGVhdGgiLCJyZWNvcmQuZGVjbGFyZS1tYXJyaWFnZSIsInJlY29yZC5kZWNsYXJhdGlvbi1lZGl0IiwicmVjb3JkLmRlY2xhcmF0aW9uLXN1Ym1pdC1mb3ItdXBkYXRlcyIsInJlY29yZC5yZXZpZXctZHVwbGljYXRlcyIsInJlY29yZC5kZWNsYXJhdGlvbi1hcmNoaXZlIiwicmVjb3JkLmRlY2xhcmF0aW9uLXJlaW5zdGF0ZSIsInJlY29yZC5yZWdpc3RlciIsInJlY29yZC5yZWdpc3RyYXRpb24tY29ycmVjdCIsInJlY29yZC5kZWNsYXJhdGlvbi1wcmludC1zdXBwb3J0aW5nLWRvY3VtZW50cyIsInJlY29yZC5leHBvcnQtcmVjb3JkcyIsInJlY29yZC51bmFzc2lnbi1vdGhlcnMiLCJyZWNvcmQucmVnaXN0cmF0aW9uLXByaW50Jmlzc3VlLWNlcnRpZmllZC1jb3BpZXMiLCJyZWNvcmQuY29uZmlybS1yZWdpc3RyYXRpb24iLCJyZWNvcmQucmVqZWN0LXJlZ2lzdHJhdGlvbiIsInBlcmZvcm1hbmNlLnJlYWQiLCJwZXJmb3JtYW5jZS5yZWFkLWRhc2hib2FyZHMiLCJwcm9maWxlLmVsZWN0cm9uaWMtc2lnbmF0dXJlIiwib3JnYW5pc2F0aW9uLnJlYWQtbG9jYXRpb25zOm15LW9mZmljZSIsInNlYXJjaC5iaXJ0aCIsInNlYXJjaC5kZWF0aCIsInNlYXJjaC5tYXJyaWFnZSIsImRlbW8iXSwidXNlclR5cGUiOiJ1c2VyIiwiaWF0IjoxNzQ4NTI2NDIwLCJleHAiOjE3NDkxMzEyMjAsImF1ZCI6WyJvcGVuY3J2czphdXRoLXVzZXIiLCJvcGVuY3J2czp1c2VyLW1nbnQtdXNlciIsIm9wZW5jcnZzOmhlYXJ0aC11c2VyIiwib3BlbmNydnM6Z2F0ZXdheS11c2VyIiwib3BlbmNydnM6bm90aWZpY2F0aW9uLXVzZXIiLCJvcGVuY3J2czp3b3JrZmxvdy11c2VyIiwib3BlbmNydnM6c2VhcmNoLXVzZXIiLCJvcGVuY3J2czptZXRyaWNzLXVzZXIiLCJvcGVuY3J2czpjb3VudHJ5Y29uZmlnLXVzZXIiLCJvcGVuY3J2czp3ZWJob29rcy11c2VyIiwib3BlbmNydnM6Y29uZmlnLXVzZXIiLCJvcGVuY3J2czpkb2N1bWVudHMtdXNlciJdLCJpc3MiOiJvcGVuY3J2czphdXRoLXNlcnZpY2UiLCJzdWIiOiI2NzdmYjA4NjMwZjNhYmZhMzMwNzI3MjEifQ.Exwojy_1lsoPmp-kQ79SMWI0eQy8Qt7yO_ynGvb_oIVdqSwTxFkkNr9x4UxhBA-o0P6LkMZ2ELKOlSzBr3PRJ8IQnfMQ7Db8oG8HAPsY8sKqra_L6ryV088NW2e2LqAjoOX0dXRIqYMolUhF_OOuZpHW5K8nvog5SLlnJ1gKysQ1EuWBg2dcKbjkkB16v-9NGz4XHye3vcoZlalyha5OOujzbPhkmr9UGiksSIXFNbanBhkQdt-EJlLX9SXvQ4ACJWPKFb_f4gv8p84jdLiryzQux46zHPpTicZHzg0nZtoKKIH1AyFtqWfBFm4y8qWC3ht9TAk93NAXTfkS0wzxKA"
6685
+ };
5318
6686
  var generateWorkqueues = (slug = "all-events") => defineWorkqueues([
5319
6687
  {
5320
6688
  slug,
@@ -5328,8 +6696,7 @@ var generateWorkqueues = (slug = "all-events") => defineWorkqueues([
5328
6696
  clauses: [{ eventType: tennisClubMembershipEvent.id }]
5329
6697
  },
5330
6698
  actions: [],
5331
- icon: "Draft",
5332
- columns: []
6699
+ icon: "Draft"
5333
6700
  }
5334
6701
  ]);
5335
6702
 
@@ -5344,7 +6711,9 @@ function isFieldValueWithoutTemplates(value) {
5344
6711
  if (isTemplateVariable(value)) {
5345
6712
  return false;
5346
6713
  }
5347
- if (typeof value === "object" && Object.values(value).some((val) => isTemplateVariable(val))) {
6714
+ if (typeof value === "object" && // @todo remove ts-ignore
6715
+ //@ts-ignore
6716
+ Object.values(value).some((val) => isTemplateVariable(val))) {
5348
6717
  return false;
5349
6718
  }
5350
6719
  return true;
@@ -5367,231 +6736,6 @@ function isFieldConfigDefaultValue(value) {
5367
6736
 
5368
6737
  // ../commons/src/events/scopes.ts
5369
6738
  var import_lodash3 = require("lodash");
5370
-
5371
- // ../commons/src/scopes.ts
5372
- var import_zod30 = require("zod");
5373
- var SCOPES = {
5374
- // TODO v1.8 legacy scopes
5375
- NATLSYSADMIN: "natlsysadmin",
5376
- BYPASSRATELIMIT: "bypassratelimit",
5377
- DECLARE: "declare",
5378
- REGISTER: "register",
5379
- VALIDATE: "validate",
5380
- DEMO: "demo",
5381
- CERTIFY: "certify",
5382
- PERFORMANCE: "performance",
5383
- SYSADMIN: "sysadmin",
5384
- TEAMS: "teams",
5385
- CONFIG: "config",
5386
- // systems / integrations
5387
- WEBHOOK: "webhook",
5388
- NATIONALID: "nationalId",
5389
- NOTIFICATION_API: "notification-api",
5390
- RECORDSEARCH: "recordsearch",
5391
- /**
5392
- * @TODO This is a temporary scope to be used for V2 Events custom events declaration
5393
- */
5394
- RECORD_DECLARE: "record.declare-birth",
5395
- // declare
5396
- RECORD_DECLARE_BIRTH: "record.declare-birth",
5397
- RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
5398
- RECORD_DECLARE_DEATH: "record.declare-death",
5399
- RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction",
5400
- RECORD_DECLARE_MARRIAGE: "record.declare-marriage",
5401
- RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction",
5402
- RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete",
5403
- RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review",
5404
- RECORD_UNASSIGN_OTHERS: "record.unassign-others",
5405
- // validate
5406
- RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval",
5407
- RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates",
5408
- RECORD_DECLARATION_EDIT: "record.declaration-edit",
5409
- RECORD_REVIEW_DUPLICATES: "record.review-duplicates",
5410
- RECORD_DECLARATION_ARCHIVE: "record.declaration-archive",
5411
- RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate",
5412
- // register
5413
- RECORD_REGISTER: "record.register",
5414
- // certify
5415
- RECORD_EXPORT_RECORDS: "record.export-records",
5416
- RECORD_DECLARATION_PRINT: "record.declaration-print",
5417
- RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS: "record.declaration-print-supporting-documents",
5418
- RECORD_REGISTRATION_PRINT: "record.registration-print",
5419
- // v1.8
5420
- /**
5421
- * This scope is used to **print and **issue certified copies of a record
5422
- * after it has been registered. Previously Registrars had this permission.
5423
- */
5424
- RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies",
5425
- RECORD_PRINT_CERTIFIED_COPIES: "record.registration-print-certified-copies",
5426
- // v1.8
5427
- RECORD_BULK_PRINT_CERTIFIED_COPIES: "record.registration-bulk-print-certified-copies",
5428
- // v1.8
5429
- RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES: "record.registration-verify-certified-copies",
5430
- // v1.8
5431
- // correct
5432
- RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction",
5433
- RECORD_REGISTRATION_CORRECT: "record.registration-correct",
5434
- RECORD_REGISTRATION_REQUEST_REVOCATION: "record.registration-request-revocation",
5435
- // v1.8
5436
- RECORD_REGISTRATION_REVOKE: "record.registration-revoke",
5437
- // v1.8
5438
- RECORD_REGISTRATION_REQUEST_REINSTATEMENT: "record.registration-request-reinstatement",
5439
- // v1.8
5440
- RECORD_REGISTRATION_REINSTATE: "record.registration-reinstate",
5441
- // v1.8
5442
- RECORD_CONFIRM_REGISTRATION: "record.confirm-registration",
5443
- RECORD_REJECT_REGISTRATION: "record.reject-registration",
5444
- // search
5445
- SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction",
5446
- SEARCH_BIRTH: "search.birth",
5447
- SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction",
5448
- SEARCH_DEATH: "search.death",
5449
- SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction",
5450
- SEARCH_MARRIAGE: "search.marriage",
5451
- // audit v1.8
5452
- RECORD_READ: "record.read",
5453
- RECORD_READ_AUDIT: "record.read-audit",
5454
- RECORD_READ_COMMENTS: "record.read-comments",
5455
- RECORD_CREATE_COMMENTS: "record.create-comments",
5456
- // profile
5457
- PROFILE_UPDATE: "profile.update",
5458
- //v1.8
5459
- PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
5460
- // performance
5461
- PERFORMANCE_READ: "performance.read",
5462
- PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
5463
- PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
5464
- // organisation
5465
- ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all",
5466
- ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
5467
- ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
5468
- // user
5469
- USER_READ: "user.read:all",
5470
- USER_READ_MY_OFFICE: "user.read:my-office",
5471
- USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
5472
- USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
5473
- //v1.8
5474
- USER_CREATE: "user.create:all",
5475
- USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
5476
- USER_UPDATE: "user.update:all",
5477
- USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction",
5478
- // config
5479
- CONFIG_UPDATE_ALL: "config.update:all",
5480
- // data seeding
5481
- USER_DATA_SEEDING: "user.data-seeding"
5482
- };
5483
- var LiteralScopes = import_zod30.z.union([
5484
- import_zod30.z.literal(SCOPES.NATLSYSADMIN),
5485
- import_zod30.z.literal(SCOPES.BYPASSRATELIMIT),
5486
- import_zod30.z.literal(SCOPES.DECLARE),
5487
- import_zod30.z.literal(SCOPES.REGISTER),
5488
- import_zod30.z.literal(SCOPES.VALIDATE),
5489
- import_zod30.z.literal(SCOPES.DEMO),
5490
- import_zod30.z.literal(SCOPES.CERTIFY),
5491
- import_zod30.z.literal(SCOPES.PERFORMANCE),
5492
- import_zod30.z.literal(SCOPES.SYSADMIN),
5493
- import_zod30.z.literal(SCOPES.TEAMS),
5494
- import_zod30.z.literal(SCOPES.CONFIG),
5495
- import_zod30.z.literal(SCOPES.WEBHOOK),
5496
- import_zod30.z.literal(SCOPES.NATIONALID),
5497
- import_zod30.z.literal(SCOPES.NOTIFICATION_API),
5498
- import_zod30.z.literal(SCOPES.RECORDSEARCH),
5499
- import_zod30.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
5500
- import_zod30.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
5501
- import_zod30.z.literal(SCOPES.RECORD_DECLARE_DEATH),
5502
- import_zod30.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
5503
- import_zod30.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
5504
- import_zod30.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
5505
- import_zod30.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
5506
- import_zod30.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW),
5507
- import_zod30.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS),
5508
- import_zod30.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
5509
- import_zod30.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
5510
- import_zod30.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
5511
- import_zod30.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
5512
- import_zod30.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
5513
- import_zod30.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE),
5514
- import_zod30.z.literal(SCOPES.RECORD_REGISTER),
5515
- import_zod30.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
5516
- import_zod30.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
5517
- import_zod30.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
5518
- import_zod30.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
5519
- import_zod30.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
5520
- import_zod30.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
5521
- import_zod30.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
5522
- import_zod30.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES),
5523
- import_zod30.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
5524
- import_zod30.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
5525
- import_zod30.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
5526
- import_zod30.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
5527
- import_zod30.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
5528
- import_zod30.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
5529
- import_zod30.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
5530
- import_zod30.z.literal(SCOPES.RECORD_REJECT_REGISTRATION),
5531
- import_zod30.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
5532
- import_zod30.z.literal(SCOPES.SEARCH_BIRTH),
5533
- import_zod30.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
5534
- import_zod30.z.literal(SCOPES.SEARCH_DEATH),
5535
- import_zod30.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
5536
- import_zod30.z.literal(SCOPES.SEARCH_MARRIAGE),
5537
- import_zod30.z.literal(SCOPES.RECORD_READ),
5538
- import_zod30.z.literal(SCOPES.RECORD_READ_AUDIT),
5539
- import_zod30.z.literal(SCOPES.RECORD_READ_COMMENTS),
5540
- import_zod30.z.literal(SCOPES.RECORD_CREATE_COMMENTS),
5541
- import_zod30.z.literal(SCOPES.PROFILE_UPDATE),
5542
- import_zod30.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE),
5543
- import_zod30.z.literal(SCOPES.PERFORMANCE_READ),
5544
- import_zod30.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
5545
- import_zod30.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS),
5546
- import_zod30.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
5547
- import_zod30.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
5548
- import_zod30.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION),
5549
- import_zod30.z.literal(SCOPES.USER_READ),
5550
- import_zod30.z.literal(SCOPES.USER_READ_MY_OFFICE),
5551
- import_zod30.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
5552
- import_zod30.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
5553
- import_zod30.z.literal(SCOPES.USER_CREATE),
5554
- import_zod30.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
5555
- import_zod30.z.literal(SCOPES.USER_UPDATE),
5556
- import_zod30.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION),
5557
- import_zod30.z.literal(SCOPES.CONFIG_UPDATE_ALL),
5558
- import_zod30.z.literal(SCOPES.USER_DATA_SEEDING)
5559
- ]);
5560
- var rawConfigurableScopeRegex = /^([a-zA-Z\.]+)\[((?:\w+=[\w.-]+(?:\|[\w.-]+)*)(?:,[\w]+=[\w.-]+(?:\|[\w.-]+)*)*)\]$/;
5561
- var rawConfigurableScope = import_zod30.z.string().regex(rawConfigurableScopeRegex);
5562
- var CreateUserScope = import_zod30.z.object({
5563
- type: import_zod30.z.literal("user.create"),
5564
- options: import_zod30.z.object({
5565
- role: import_zod30.z.array(import_zod30.z.string())
5566
- })
5567
- });
5568
- var EditUserScope = import_zod30.z.object({
5569
- type: import_zod30.z.literal("user.edit"),
5570
- options: import_zod30.z.object({
5571
- role: import_zod30.z.array(import_zod30.z.string())
5572
- })
5573
- });
5574
- var WorkqueueScope = import_zod30.z.object({
5575
- type: import_zod30.z.literal("workqueue"),
5576
- options: import_zod30.z.object({
5577
- id: import_zod30.z.array(import_zod30.z.string())
5578
- })
5579
- });
5580
- var NotifyRecordScope = import_zod30.z.object({
5581
- type: import_zod30.z.literal("record.notify"),
5582
- options: import_zod30.z.object({
5583
- event: import_zod30.z.array(import_zod30.z.string())
5584
- })
5585
- });
5586
- var ConfigurableScopes = import_zod30.z.discriminatedUnion("type", [
5587
- CreateUserScope,
5588
- EditUserScope,
5589
- WorkqueueScope,
5590
- NotifyRecordScope
5591
- ]);
5592
- var scopes = Object.values(SCOPES);
5593
-
5594
- // ../commons/src/events/scopes.ts
5595
6739
  var CONFIG_GET_ALLOWED_SCOPES = [
5596
6740
  SCOPES.RECORD_DECLARE,
5597
6741
  SCOPES.RECORD_READ,
@@ -5668,42 +6812,31 @@ var ACTION_ALLOWED_CONFIGURABLE_SCOPES = {
5668
6812
  [ActionType.UNASSIGN]: [],
5669
6813
  [ActionType.DETECT_DUPLICATE]: []
5670
6814
  };
6815
+ var WRITE_ACTION_SCOPES = [
6816
+ ...ACTION_ALLOWED_SCOPES[ActionType.DECLARE],
6817
+ ...ACTION_ALLOWED_SCOPES[ActionType.VALIDATE],
6818
+ ...ACTION_ALLOWED_SCOPES[ActionType.REGISTER],
6819
+ ...ACTION_ALLOWED_SCOPES[ActionType.PRINT_CERTIFICATE]
6820
+ ];
5671
6821
  function hasAnyOfScopes(a, b) {
5672
6822
  return (0, import_lodash3.intersection)(a, b).length > 0;
5673
6823
  }
5674
- function filterUnallowedActions(actions, userScopes) {
5675
- const allowedActions = actions.filter((action) => {
5676
- const requiredScopes = ACTION_ALLOWED_SCOPES[action];
5677
- if (requiredScopes === null) {
5678
- return true;
5679
- }
5680
- return hasAnyOfScopes(userScopes, requiredScopes);
5681
- });
5682
- const hasOtherAllowedActions = allowedActions.some(
5683
- (action) => action !== ActionType.READ && action !== ActionType.ASSIGN && action !== ActionType.UNASSIGN
5684
- );
5685
- if (hasOtherAllowedActions) {
5686
- return allowedActions;
5687
- }
5688
- return [ActionType.READ];
5689
- }
5690
6824
 
5691
6825
  // ../commons/src/events/serializers/user/deserializer.ts
5692
- var import_zod31 = require("zod");
6826
+ var import_zod34 = require("zod");
5693
6827
  var UserWithPrimaryOffice = User.extend({
5694
- primaryOfficeId: import_zod31.z.string()
6828
+ primaryOfficeId: import_zod34.z.string()
5695
6829
  });
5696
6830
  function userDeserializer(serializedUserField, user2) {
5697
6831
  if (typeof serializedUserField === "string") {
5698
6832
  return serializedUserField;
5699
6833
  }
5700
- if (serializedUserField.$userField === "id") {
5701
- return user2[serializedUserField.$userField];
5702
- }
5703
- if (serializedUserField.$userField === "primaryOfficeId") {
5704
- return user2[serializedUserField.$userField];
6834
+ if (serializedUserField.$userField === "name" || serializedUserField.$userField === "signatureFilename") {
6835
+ throw new Error(
6836
+ `Deserializer for ${serializedUserField.$userField} is not implemented yet`
6837
+ );
5705
6838
  }
5706
- return "ToDo";
6839
+ return user2[serializedUserField.$userField];
5707
6840
  }
5708
6841
  function deserializeQueryExpression(expression, user2) {
5709
6842
  return {
@@ -5712,6 +6845,7 @@ function deserializeQueryExpression(expression, user2) {
5712
6845
  ...expression.assignedTo,
5713
6846
  term: userDeserializer(expression.assignedTo.term, user2)
5714
6847
  },
6848
+ createdByUserType: expression.createdByUserType,
5715
6849
  createdBy: expression.createdBy && {
5716
6850
  ...expression.createdBy,
5717
6851
  term: userDeserializer(expression.createdBy.term, user2)
@@ -5747,6 +6881,56 @@ function deserializeQuery(query, user2) {
5747
6881
  ...query,
5748
6882
  clauses: query.clauses.map(
5749
6883
  (clause) => deserializeQueryExpression(clause, user2)
6884
+ // SAFETY: This cast should be safe because `query.clauses` has already been validated as non-empty by the Zod schema.
6885
+ // Without the cast, TypeScript cannot infer the tuple type required by the target interface.
5750
6886
  )
5751
6887
  };
5752
6888
  }
6889
+
6890
+ // ../commons/src/events/state/availableActions.ts
6891
+ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
6892
+ [EventStatus.enum.CREATED]: [
6893
+ ActionType.READ,
6894
+ ActionType.DECLARE,
6895
+ ActionType.NOTIFY,
6896
+ ActionType.DELETE
6897
+ ],
6898
+ [EventStatus.enum.NOTIFIED]: [
6899
+ ActionType.READ,
6900
+ ActionType.DECLARE,
6901
+ ActionType.ARCHIVE,
6902
+ ActionType.REJECT
6903
+ ],
6904
+ [EventStatus.enum.DECLARED]: [
6905
+ ActionType.READ,
6906
+ ActionType.VALIDATE,
6907
+ ActionType.ARCHIVE,
6908
+ ActionType.REJECT
6909
+ ],
6910
+ [EventStatus.enum.VALIDATED]: [
6911
+ ActionType.READ,
6912
+ ActionType.REGISTER,
6913
+ ActionType.ARCHIVE,
6914
+ ActionType.REJECT
6915
+ ],
6916
+ [EventStatus.enum.REJECTED]: [
6917
+ ActionType.READ,
6918
+ ActionType.DECLARE,
6919
+ ActionType.VALIDATE
6920
+ ],
6921
+ [EventStatus.enum.REGISTERED]: [
6922
+ ActionType.READ,
6923
+ ActionType.PRINT_CERTIFICATE,
6924
+ ActionType.REQUEST_CORRECTION
6925
+ ],
6926
+ [EventStatus.enum.CERTIFIED]: [
6927
+ ActionType.READ,
6928
+ ActionType.PRINT_CERTIFICATE,
6929
+ ActionType.REQUEST_CORRECTION
6930
+ ],
6931
+ [EventStatus.enum.ARCHIVED]: [
6932
+ ActionType.READ,
6933
+ ActionType.ASSIGN,
6934
+ ActionType.UNASSIGN
6935
+ ]
6936
+ };