@opencrvs/toolkit 1.8.0-rc.f9f0941 → 1.8.0-rc.f9f9d64

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 (42) hide show
  1. package/dist/commons/api/router.d.ts +15318 -5028
  2. package/dist/commons/conditionals/conditionals.d.ts +8 -3
  3. package/dist/commons/conditionals/validate.d.ts +6 -0
  4. package/dist/commons/events/ActionConfig.d.ts +56387 -29043
  5. package/dist/commons/events/ActionDocument.d.ts +1900 -309
  6. package/dist/commons/events/ActionInput.d.ts +1455 -183
  7. package/dist/commons/events/ActionType.d.ts +4 -0
  8. package/dist/commons/events/AdvancedSearchConfig.d.ts +675 -12
  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 +2982 -0
  12. package/dist/commons/events/CreatedAtLocation.d.ts +3 -0
  13. package/dist/commons/events/Draft.d.ts +122 -21
  14. package/dist/commons/events/EventConfig.d.ts +27593 -14046
  15. package/dist/commons/events/EventDocument.d.ts +1228 -245
  16. package/dist/commons/events/EventIndex.d.ts +585 -353
  17. package/dist/commons/events/EventInput.d.ts +0 -13
  18. package/dist/commons/events/EventMetadata.d.ts +70 -76
  19. package/dist/commons/events/FieldConfig.d.ts +2500 -1111
  20. package/dist/commons/events/FieldType.d.ts +4 -1
  21. package/dist/commons/events/FieldTypeMapping.d.ts +94 -52
  22. package/dist/commons/events/FieldValue.d.ts +43 -5
  23. package/dist/commons/events/FormConfig.d.ts +18485 -9821
  24. package/dist/commons/events/PageConfig.d.ts +3600 -1472
  25. package/dist/commons/events/SummaryConfig.d.ts +0 -5
  26. package/dist/commons/events/User.d.ts +31 -7
  27. package/dist/commons/events/WorkqueueColumnConfig.d.ts +53 -0
  28. package/dist/commons/events/WorkqueueConfig.d.ts +4205 -538
  29. package/dist/commons/events/defineConfig.d.ts +2639 -635
  30. package/dist/commons/events/event.d.ts +37 -10
  31. package/dist/commons/events/field.d.ts +26 -17
  32. package/dist/commons/events/index.d.ts +4 -0
  33. package/dist/commons/events/scopes.d.ts +20 -1
  34. package/dist/commons/events/serializer.d.ts +2 -0
  35. package/dist/commons/events/test.utils.d.ts +147 -41
  36. package/dist/commons/events/utils.d.ts +10110 -309
  37. package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
  38. package/dist/conditionals/index.js +45 -8
  39. package/dist/events/index.js +2672 -1100
  40. package/dist/scopes/index.d.ts +94 -6
  41. package/dist/scopes/index.js +42 -21
  42. package/package.json +1 -1
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/events/index.ts
31
31
  var events_exports = {};
32
32
  __export(events_exports, {
33
+ ACTION_ALLOWED_CONFIGURABLE_SCOPES: () => ACTION_ALLOWED_CONFIGURABLE_SCOPES,
33
34
  ACTION_ALLOWED_SCOPES: () => ACTION_ALLOWED_SCOPES,
34
35
  Action: () => Action,
35
36
  ActionBase: () => ActionBase,
@@ -49,11 +50,15 @@ __export(events_exports, {
49
50
  AddressType: () => AddressType,
50
51
  AdministrativeAreas: () => AdministrativeAreas,
51
52
  AdvancedSearchConfig: () => AdvancedSearchConfig,
53
+ AnyOf: () => AnyOf,
54
+ AnyOfStatus: () => AnyOfStatus,
52
55
  ApproveCorrectionActionInput: () => ApproveCorrectionActionInput,
53
56
  ArchiveActionInput: () => ArchiveActionInput,
54
57
  AssignActionInput: () => AssignActionInput,
55
58
  AsyncRejectActionDocument: () => AsyncRejectActionDocument,
59
+ BIRTH_EVENT: () => BIRTH_EVENT,
56
60
  BaseActionInput: () => BaseActionInput,
61
+ BearerTokenByUserType: () => BearerTokenByUserType,
57
62
  CONFIG_GET_ALLOWED_SCOPES: () => CONFIG_GET_ALLOWED_SCOPES,
58
63
  CONFIG_SEARCH_ALLOWED_SCOPES: () => CONFIG_SEARCH_ALLOWED_SCOPES,
59
64
  CertificateConfig: () => CertificateConfig,
@@ -67,6 +72,7 @@ __export(events_exports, {
67
72
  DEFAULT_DATE_OF_EVENT_PROPERTY: () => DEFAULT_DATE_OF_EVENT_PROPERTY,
68
73
  DataEntry: () => DataEntry,
69
74
  DataFieldValue: () => DataFieldValue,
75
+ DateCondition: () => DateCondition,
70
76
  DateRangeFieldValue: () => DateRangeFieldValue,
71
77
  DateValue: () => DateValue,
72
78
  DatetimeValue: () => DatetimeValue,
@@ -92,14 +98,16 @@ __export(events_exports, {
92
98
  EventInput: () => EventInput,
93
99
  EventMetadata: () => EventMetadata,
94
100
  EventMetadataKeys: () => EventMetadataKeys,
95
- EventMetadataParameter: () => EventMetadataParameter,
101
+ EventMetadataKeysArray: () => EventMetadataKeysArray,
96
102
  EventSearchIndex: () => EventSearchIndex,
97
103
  EventState: () => EventState,
98
104
  EventStatus: () => EventStatus,
99
- EventStatuses: () => EventStatuses,
105
+ Exact: () => Exact,
106
+ ExactStatus: () => ExactStatus,
100
107
  FieldConditional: () => FieldConditional,
101
108
  FieldConfig: () => FieldConfig,
102
109
  FieldConfigSchema: () => FieldConfigSchema,
110
+ FieldReference: () => FieldReference,
103
111
  FieldType: () => FieldType,
104
112
  FieldUpdateValue: () => FieldUpdateValue,
105
113
  FieldValue: () => FieldValue,
@@ -109,6 +117,7 @@ __export(events_exports, {
109
117
  Flag: () => Flag,
110
118
  FormConfig: () => FormConfig,
111
119
  FormPageConfig: () => FormPageConfig,
120
+ Fuzzy: () => Fuzzy,
112
121
  GenericAddressUpdateValue: () => GenericAddressUpdateValue,
113
122
  GenericAddressValue: () => GenericAddressValue,
114
123
  GeographicalArea: () => GeographicalArea,
@@ -117,37 +126,56 @@ __export(events_exports, {
117
126
  LegalStatuses: () => LegalStatuses,
118
127
  MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
119
128
  MimeType: () => MimeType,
129
+ NameFieldUpdateValue: () => NameFieldUpdateValue,
130
+ NameFieldValue: () => NameFieldValue,
120
131
  NonEmptyTextValue: () => NonEmptyTextValue,
132
+ Not: () => Not,
121
133
  NotifyActionInput: () => NotifyActionInput,
122
134
  NumberFieldValue: () => NumberFieldValue,
123
135
  PageConfig: () => PageConfig,
124
136
  PageTypes: () => PageTypes,
125
137
  PrintCertificateActionInput: () => PrintCertificateActionInput,
138
+ QueryExpression: () => QueryExpression,
126
139
  QueryInput: () => QueryInput,
127
140
  QueryType: () => QueryType,
141
+ Range: () => Range,
128
142
  ReadActionInput: () => ReadActionInput,
129
143
  RegisterAction: () => RegisterAction,
130
144
  RegisterActionInput: () => RegisterActionInput,
131
145
  RegistrationCreationMetadata: () => RegistrationCreationMetadata,
132
146
  RejectCorrectionActionInput: () => RejectCorrectionActionInput,
133
147
  RejectDeclarationActionInput: () => RejectDeclarationActionInput,
148
+ RejectionReason: () => RejectionReason,
134
149
  RequestCorrectionActionInput: () => RequestCorrectionActionInput,
135
150
  ResolvedUser: () => ResolvedUser,
136
151
  RuralAddressUpdateValue: () => RuralAddressUpdateValue,
137
152
  RuralAddressValue: () => RuralAddressValue,
138
153
  SearchField: () => SearchField,
154
+ SearchQueryParams: () => SearchQueryParams,
139
155
  SelectOption: () => SelectOption,
140
156
  ShowConditional: () => ShowConditional,
157
+ SignatureFieldValue: () => SignatureFieldValue,
141
158
  SummaryConfig: () => SummaryConfig,
159
+ TENNIS_CLUB_MEMBERSHIP: () => TENNIS_CLUB_MEMBERSHIP,
142
160
  TextValue: () => TextValue,
143
161
  TranslationConfig: () => TranslationConfig,
144
162
  UnassignActionInput: () => UnassignActionInput,
145
163
  UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
146
164
  UrbanAddressValue: () => UrbanAddressValue,
165
+ User: () => User,
147
166
  ValidateActionInput: () => ValidateActionInput,
148
167
  VerificationActionConfig: () => VerificationActionConfig,
149
168
  VerificationPageConfig: () => VerificationPageConfig,
169
+ Within: () => Within,
170
+ WorkqueueActionsWithDefault: () => WorkqueueActionsWithDefault,
171
+ WorkqueueColumn: () => WorkqueueColumn,
172
+ WorkqueueColumnKeys: () => WorkqueueColumnKeys,
173
+ WorkqueueColumnKeysArray: () => WorkqueueColumnKeysArray,
174
+ WorkqueueColumnValue: () => WorkqueueColumnValue,
150
175
  WorkqueueConfig: () => WorkqueueConfig,
176
+ WorkqueueConfigInput: () => WorkqueueConfigInput,
177
+ WorkqueueCountInput: () => WorkqueueCountInput,
178
+ WorkqueueCountOutput: () => WorkqueueCountOutput,
151
179
  ZodDate: () => ZodDate,
152
180
  alwaysTrue: () => alwaysTrue,
153
181
  and: () => and,
@@ -158,9 +186,11 @@ __export(events_exports, {
158
186
  createEmptyDraft: () => createEmptyDraft,
159
187
  createEventConditionals: () => createEventConditionals,
160
188
  createFieldConditionals: () => createFieldConditionals,
189
+ createPrng: () => createPrng,
161
190
  createValidationSchema: () => createValidationSchema,
162
191
  deepDropNulls: () => deepDropNulls,
163
192
  deepMerge: () => deepMerge,
193
+ defaultWorkqueueColumns: () => defaultWorkqueueColumns,
164
194
  defineActionForm: () => defineActionForm,
165
195
  defineConditional: () => defineConditional,
166
196
  defineConfig: () => defineConfig,
@@ -169,12 +199,14 @@ __export(events_exports, {
169
199
  defineFormPage: () => defineFormPage,
170
200
  definePage: () => definePage,
171
201
  defineWorkqueue: () => defineWorkqueue,
202
+ defineWorkqueues: () => defineWorkqueues,
203
+ defineWorkqueuesColumns: () => defineWorkqueuesColumns,
204
+ deserializeQuery: () => deserializeQuery,
172
205
  errorMessages: () => errorMessages,
173
206
  event: () => event,
174
207
  eventMetadataLabelMap: () => eventMetadataLabelMap,
175
208
  eventPayloadGenerator: () => eventPayloadGenerator,
176
209
  eventQueryDataGenerator: () => eventQueryDataGenerator,
177
- eventStatuses: () => eventStatuses,
178
210
  field: () => field,
179
211
  fieldTypes: () => fieldTypes,
180
212
  filterUnallowedActions: () => filterUnallowedActions,
@@ -187,22 +219,33 @@ __export(events_exports, {
187
219
  generateActionDocument: () => generateActionDocument,
188
220
  generateEventDocument: () => generateEventDocument,
189
221
  generateEventDraftDocument: () => generateEventDraftDocument,
222
+ generateRandomName: () => generateRandomName,
223
+ generateRandomSignature: () => generateRandomSignature,
190
224
  generateTransactionId: () => generateTransactionId,
191
225
  generateTranslationConfig: () => generateTranslationConfig,
226
+ generateWorkqueues: () => generateWorkqueues,
192
227
  getAcceptedActions: () => getAcceptedActions,
193
228
  getActionAnnotation: () => getActionAnnotation,
194
229
  getActionAnnotationFields: () => getActionAnnotationFields,
195
230
  getActionReview: () => getActionReview,
196
231
  getActionReviewFields: () => getActionReviewFields,
197
232
  getActionVerificationPageIds: () => getActionVerificationPageIds,
233
+ getAllUniqueFields: () => getAllUniqueFields,
198
234
  getAnnotationFromDrafts: () => getAnnotationFromDrafts,
199
235
  getAssignedUserFromActions: () => getAssignedUserFromActions,
236
+ getAssignedUserSignatureFromActions: () => getAssignedUserSignatureFromActions,
200
237
  getCurrentEventState: () => getCurrentEventState,
201
238
  getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
202
239
  getDeclaration: () => getDeclaration,
240
+ getDeclarationFieldById: () => getDeclarationFieldById,
203
241
  getDeclarationFields: () => getDeclarationFields,
204
242
  getDeclarationPages: () => getDeclarationPages,
243
+ getEventConfigById: () => getEventConfigById,
205
244
  getMixedPath: () => getMixedPath,
245
+ getRandomDate: () => getRandomDate,
246
+ getRandomDatetime: () => getRandomDatetime,
247
+ getStatusFromActions: () => getStatusFromActions,
248
+ getValidatorsForField: () => getValidatorsForField,
206
249
  getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
207
250
  hasAnyOfScopes: () => hasAnyOfScopes,
208
251
  isAddressFieldType: () => isAddressFieldType,
@@ -225,12 +268,17 @@ __export(events_exports, {
225
268
  isFieldVisible: () => isFieldVisible,
226
269
  isFileFieldType: () => isFileFieldType,
227
270
  isFileFieldWithOptionType: () => isFileFieldWithOptionType,
271
+ isIdFieldType: () => isIdFieldType,
228
272
  isLocationFieldType: () => isLocationFieldType,
273
+ isMetaAction: () => isMetaAction,
274
+ isNameFieldType: () => isNameFieldType,
275
+ isNonInteractiveFieldType: () => isNonInteractiveFieldType,
229
276
  isNumberFieldType: () => isNumberFieldType,
230
277
  isOfficeFieldType: () => isOfficeFieldType,
231
278
  isPageHeaderFieldType: () => isPageHeaderFieldType,
232
279
  isPageVisible: () => isPageVisible,
233
280
  isParagraphFieldType: () => isParagraphFieldType,
281
+ isPhoneFieldType: () => isPhoneFieldType,
234
282
  isRadioGroupFieldType: () => isRadioGroupFieldType,
235
283
  isSelectFieldType: () => isSelectFieldType,
236
284
  isSignatureFieldType: () => isSignatureFieldType,
@@ -240,6 +288,7 @@ __export(events_exports, {
240
288
  isUndeclaredDraft: () => isUndeclaredDraft,
241
289
  isVerificationPage: () => isVerificationPage,
242
290
  isWriteAction: () => isWriteAction,
291
+ mandatoryColumns: () => mandatoryColumns,
243
292
  mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
244
293
  mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
245
294
  mapFieldTypeToZod: () => mapFieldTypeToZod,
@@ -253,18 +302,26 @@ __export(events_exports, {
253
302
  user: () => user,
254
303
  validate: () => validate,
255
304
  validateFieldInput: () => validateFieldInput,
305
+ workqueueActions: () => workqueueActions,
256
306
  writeActions: () => writeActions
257
307
  });
258
308
  module.exports = __toCommonJS(events_exports);
259
309
 
310
+ // ../commons/src/events/Constants.ts
311
+ var TENNIS_CLUB_MEMBERSHIP = "tennis-club-membership";
312
+ var BIRTH_EVENT = "v2-birth";
313
+
260
314
  // ../commons/src/events/ActionConfig.ts
261
315
  var import_zod9 = require("zod");
262
316
 
263
317
  // ../commons/src/events/Conditional.ts
264
318
  var import_zod = require("zod");
265
- var Conditional = import_zod.z.custom(
266
- (val) => typeof val === "object" && val !== null
267
- );
319
+ var import_zod_openapi = require("zod-openapi");
320
+ (0, import_zod_openapi.extendZodWithOpenApi)(import_zod.z);
321
+ var Conditional = import_zod.z.custom((val) => typeof val === "object" && val !== null).openapi({
322
+ description: "JSON schema conditional configuration",
323
+ ref: "Conditional"
324
+ });
268
325
  var ConditionalType = {
269
326
  SHOW: "SHOW",
270
327
  ENABLE: "ENABLE",
@@ -301,7 +358,10 @@ var FieldConditional = import_zod.z.discriminatedUnion("type", [
301
358
  EnableConditional,
302
359
  // Field output can be shown / hidden on the review page
303
360
  DisplayOnReviewConditional
304
- ]);
361
+ ]).openapi({
362
+ description: "Field conditional configuration",
363
+ ref: "FieldConditional"
364
+ });
305
365
 
306
366
  // ../commons/src/events/PageConfig.ts
307
367
  var import_zod6 = require("zod");
@@ -311,6 +371,8 @@ var import_zod5 = require("zod");
311
371
 
312
372
  // ../commons/src/events/TranslationConfig.ts
313
373
  var import_zod2 = require("zod");
374
+ var import_zod_openapi2 = require("zod-openapi");
375
+ (0, import_zod_openapi2.extendZodWithOpenApi)(import_zod2.z);
314
376
  var TranslationConfig = import_zod2.z.object({
315
377
  id: import_zod2.z.string().describe(
316
378
  "The identifier of the translation referred in translation CSV files"
@@ -319,10 +381,16 @@ var TranslationConfig = import_zod2.z.object({
319
381
  description: import_zod2.z.string().describe(
320
382
  "Describe the translation for a translator to be able to identify it."
321
383
  )
384
+ }).openapi({
385
+ description: "Translation configuration",
386
+ ref: "TranslationConfig"
322
387
  });
323
388
 
324
389
  // ../commons/src/events/FieldType.ts
325
390
  var FieldType = {
391
+ NAME: "NAME",
392
+ PHONE: "PHONE",
393
+ ID: "ID",
326
394
  ADDRESS: "ADDRESS",
327
395
  TEXT: "TEXT",
328
396
  NUMBER: "NUMBER",
@@ -399,6 +467,16 @@ var UrbanAddressUpdateValue = AdminStructure.extend({
399
467
  number: import_zod3.z.string().nullish(),
400
468
  zipCode: import_zod3.z.string().nullish()
401
469
  });
470
+ var NameFieldValue = import_zod3.z.object({
471
+ firstname: import_zod3.z.string(),
472
+ surname: import_zod3.z.string(),
473
+ middlename: import_zod3.z.string().optional()
474
+ });
475
+ var NameFieldUpdateValue = import_zod3.z.object({
476
+ firstname: import_zod3.z.string(),
477
+ surname: import_zod3.z.string(),
478
+ middlename: import_zod3.z.string().nullish()
479
+ }).or(import_zod3.z.null()).or(import_zod3.z.undefined());
402
480
  var RuralAddressUpdateValue = AdminStructure.extend({
403
481
  urbanOrRural: import_zod3.z.literal(GeographicalArea.RURAL),
404
482
  village: import_zod3.z.string().nullish()
@@ -448,6 +526,7 @@ var EmailValue = import_zod4.z.string().email();
448
526
  var CheckboxFieldValue = import_zod4.z.boolean();
449
527
  var NumberFieldValue = import_zod4.z.number();
450
528
  var DataFieldValue = import_zod4.z.undefined();
529
+ var SignatureFieldValue = import_zod4.z.string();
451
530
  var FieldValue = import_zod4.z.union([
452
531
  TextValue,
453
532
  DateValue,
@@ -459,7 +538,9 @@ var FieldValue = import_zod4.z.union([
459
538
  UrbanAddressValue,
460
539
  RuralAddressValue,
461
540
  DataFieldValue,
462
- GenericAddressValue
541
+ GenericAddressValue,
542
+ NameFieldValue,
543
+ NameFieldUpdateValue
463
544
  ]);
464
545
  var FieldUpdateValue = import_zod4.z.union([
465
546
  TextValue,
@@ -472,23 +553,20 @@ var FieldUpdateValue = import_zod4.z.union([
472
553
  UrbanAddressUpdateValue,
473
554
  RuralAddressUpdateValue,
474
555
  DataFieldValue,
475
- GenericAddressUpdateValue
556
+ GenericAddressUpdateValue,
557
+ NameFieldUpdateValue
476
558
  ]);
477
559
 
478
560
  // ../commons/src/events/FieldConfig.ts
479
- var FieldId = import_zod5.z.string();
480
- var ParentReference = import_zod5.z.object({
481
- _fieldId: FieldId.optional()
482
- }).optional();
561
+ var import_zod_openapi3 = require("zod-openapi");
562
+ (0, import_zod_openapi3.extendZodWithOpenApi)(import_zod5.z);
563
+ var FieldId = import_zod5.z.string().describe("Unique identifier for the field");
564
+ var FieldReference = import_zod5.z.object({
565
+ $$field: FieldId
566
+ }).describe("Reference to a field by its ID");
567
+ var ParentReference = FieldReference.optional();
483
568
  var BaseField = import_zod5.z.object({
484
569
  id: FieldId,
485
- defaultValue: import_zod5.z.union([
486
- TextValue,
487
- NonEmptyTextValue,
488
- DateValue,
489
- NumberFieldValue,
490
- CheckboxFieldValue
491
- ]).optional(),
492
570
  parent: ParentReference,
493
571
  conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
494
572
  required: import_zod5.z.boolean().default(false).optional(),
@@ -500,6 +578,7 @@ var BaseField = import_zod5.z.object({
500
578
  })
501
579
  ).default([]).optional(),
502
580
  label: TranslationConfig,
581
+ helperText: TranslationConfig.optional(),
503
582
  hideLabel: import_zod5.z.boolean().default(false).optional()
504
583
  });
505
584
  var Divider = BaseField.extend({
@@ -549,6 +628,7 @@ var SignatureField = BaseField.extend({
549
628
  signaturePromptLabel: TranslationConfig.describe(
550
629
  "Title of the signature modal"
551
630
  ),
631
+ defaultValue: SignatureFieldValue.optional(),
552
632
  configuration: import_zod5.z.object({
553
633
  maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
554
634
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
@@ -608,6 +688,7 @@ var PageHeader = BaseField.extend({
608
688
  }).describe("A read-only header component for form pages");
609
689
  var File = BaseField.extend({
610
690
  type: import_zod5.z.literal(FieldType.FILE),
691
+ defaultValue: FileFieldValue.optional(),
611
692
  configuration: import_zod5.z.object({
612
693
  maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
613
694
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
@@ -650,6 +731,26 @@ var Select = BaseField.extend({
650
731
  defaultValue: TextValue.optional(),
651
732
  options: import_zod5.z.array(SelectOption).describe("A list of options")
652
733
  }).describe("Select input");
734
+ var NameField = BaseField.extend({
735
+ type: import_zod5.z.literal(FieldType.NAME),
736
+ defaultValue: import_zod5.z.object({
737
+ firstname: NonEmptyTextValue,
738
+ surname: NonEmptyTextValue
739
+ }).optional(),
740
+ configuration: import_zod5.z.object({
741
+ maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
742
+ prefix: TranslationConfig.optional(),
743
+ postfix: TranslationConfig.optional()
744
+ }).optional()
745
+ }).describe("Name input field");
746
+ var PhoneField = BaseField.extend({
747
+ defaultValue: NonEmptyTextValue.optional(),
748
+ type: import_zod5.z.literal(FieldType.PHONE)
749
+ }).describe("Phone input field");
750
+ var IdField = BaseField.extend({
751
+ defaultValue: NonEmptyTextValue.optional(),
752
+ type: import_zod5.z.literal(FieldType.ID)
753
+ }).describe("ID input field");
653
754
  var Checkbox = BaseField.extend({
654
755
  type: import_zod5.z.literal(FieldType.CHECKBOX),
655
756
  defaultValue: CheckboxFieldValue.optional()
@@ -681,6 +782,7 @@ var Location = BaseField.extend({
681
782
  var FileUploadWithOptions = BaseField.extend({
682
783
  type: import_zod5.z.literal(FieldType.FILE_WITH_OPTIONS),
683
784
  options: import_zod5.z.array(SelectOption).describe("A list of options"),
785
+ defaultValue: FileFieldWithOptionValue.optional(),
684
786
  configuration: import_zod5.z.object({
685
787
  maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
686
788
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
@@ -728,6 +830,9 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
728
830
  BulletList,
729
831
  PageHeader,
730
832
  Select,
833
+ NameField,
834
+ PhoneField,
835
+ IdField,
731
836
  Checkbox,
732
837
  File,
733
838
  Country,
@@ -740,9 +845,14 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
740
845
  EmailField,
741
846
  FileUploadWithOptions,
742
847
  DataField
743
- ]);
848
+ ]).openapi({
849
+ description: "Form field configuration",
850
+ ref: "FieldConfig"
851
+ });
744
852
 
745
853
  // ../commons/src/events/PageConfig.ts
854
+ var import_zod_openapi4 = require("zod-openapi");
855
+ (0, import_zod_openapi4.extendZodWithOpenApi)(import_zod6.z);
746
856
  var PageTypes = import_zod6.z.enum(["FORM", "VERIFICATION"]);
747
857
  var PageConfigBase = import_zod6.z.object({
748
858
  id: import_zod6.z.string().describe("Unique identifier for the page"),
@@ -751,6 +861,9 @@ var PageConfigBase = import_zod6.z.object({
751
861
  conditional: Conditional.optional().describe(
752
862
  "Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
753
863
  )
864
+ }).openapi({
865
+ description: "Form page configuration",
866
+ ref: "FormPageConfig"
754
867
  });
755
868
  var FormPageConfig = PageConfigBase.extend({
756
869
  type: import_zod6.z.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
@@ -764,7 +877,10 @@ var VerificationActionConfig = import_zod6.z.object({
764
877
  body: TranslationConfig
765
878
  })
766
879
  })
767
- }).describe("Actions available on the verification page");
880
+ }).describe("Actions available on the verification page").openapi({
881
+ description: "Verification action configuration",
882
+ ref: "VerificationActionConfig"
883
+ });
768
884
  var VerificationPageConfig = FormPageConfig.extend({
769
885
  type: import_zod6.z.literal(PageTypes.enum.VERIFICATION),
770
886
  actions: VerificationActionConfig
@@ -850,6 +966,25 @@ var writeActions = ActionTypes.exclude([
850
966
  ActionType.ASSIGN,
851
967
  ActionType.UNASSIGN
852
968
  ]);
969
+ var workqueueActions = ActionTypes.exclude([
970
+ ActionType.CREATE,
971
+ ActionType.NOTIFY,
972
+ ActionType.DETECT_DUPLICATE,
973
+ ActionType.REJECT,
974
+ ActionType.MARKED_AS_DUPLICATE,
975
+ ActionType.ARCHIVE,
976
+ ActionType.REQUEST_CORRECTION,
977
+ ActionType.REJECT_CORRECTION,
978
+ ActionType.APPROVE_CORRECTION
979
+ ]);
980
+ var META_ACTIONS = [
981
+ ActionType.ASSIGN,
982
+ ActionType.UNASSIGN,
983
+ ActionType.READ
984
+ ];
985
+ function isMetaAction(actionType) {
986
+ return META_ACTIONS.includes(actionType);
987
+ }
853
988
 
854
989
  // ../commons/src/events/FormConfig.ts
855
990
  var import_zod8 = require("zod");
@@ -864,8 +999,8 @@ var ActionFormConfig = import_zod8.z.object({
864
999
  var FormConfig = import_zod8.z.union([DeclarationFormConfig, ActionFormConfig]);
865
1000
 
866
1001
  // ../commons/src/events/ActionConfig.ts
867
- var import_zod_openapi = require("zod-openapi");
868
- (0, import_zod_openapi.extendZodWithOpenApi)(import_zod9.z);
1002
+ var import_zod_openapi5 = require("zod-openapi");
1003
+ (0, import_zod_openapi5.extendZodWithOpenApi)(import_zod9.z);
869
1004
  var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
870
1005
  /** If conditional is defined, the action is shown to the user only if the condition is met */
871
1006
  ShowConditional,
@@ -881,6 +1016,12 @@ var ActionConfigBase = import_zod9.z.object({
881
1016
  conditionals: import_zod9.z.array(ActionConditional2).optional().default([]),
882
1017
  draft: import_zod9.z.boolean().optional()
883
1018
  });
1019
+ var ReadActionConfig = ActionConfigBase.merge(
1020
+ import_zod9.z.object({
1021
+ type: import_zod9.z.literal(ActionType.READ),
1022
+ review: DeclarationReviewConfig
1023
+ })
1024
+ );
884
1025
  var DeclareConfig = ActionConfigBase.merge(
885
1026
  import_zod9.z.object({
886
1027
  type: import_zod9.z.literal(ActionType.DECLARE),
@@ -947,6 +1088,7 @@ var ActionConfig = import_zod9.z.discriminatedUnion("type", [
947
1088
  * OpenAPI references are defined here so our generated OpenAPI spec knows to reuse the models
948
1089
  * and treat them as "models" instead of duplicating the data structure in each endpoint.
949
1090
  */
1091
+ ReadActionConfig.openapi({ ref: "ReadActionConfig" }),
950
1092
  DeclareConfig.openapi({ ref: "DeclareActionConfig" }),
951
1093
  ValidateConfig.openapi({ ref: "ValidateActionConfig" }),
952
1094
  RejectDeclarationConfig.openapi({ ref: "RejectDeclarationActionConfig" }),
@@ -1004,13 +1146,13 @@ var LanguageConfig = import_zod11.z.object({
1004
1146
  });
1005
1147
 
1006
1148
  // ../commons/src/events/EventConfig.ts
1007
- var import_zod17 = require("zod");
1149
+ var import_zod18 = require("zod");
1008
1150
 
1009
1151
  // ../commons/src/events/DeduplicationConfig.ts
1010
1152
  var import_zod12 = require("zod");
1011
- var import_zod_openapi2 = require("zod-openapi");
1012
- (0, import_zod_openapi2.extendZodWithOpenApi)(import_zod12.z);
1013
- var FieldReference = import_zod12.z.string();
1153
+ var import_zod_openapi6 = require("zod-openapi");
1154
+ (0, import_zod_openapi6.extendZodWithOpenApi)(import_zod12.z);
1155
+ var FieldReference2 = import_zod12.z.string();
1014
1156
  var Matcher = import_zod12.z.object({
1015
1157
  fieldId: import_zod12.z.string(),
1016
1158
  options: import_zod12.z.object({
@@ -1039,7 +1181,7 @@ var DateRangeMatcher = Matcher.extend({
1039
1181
  type: import_zod12.z.literal("dateRange"),
1040
1182
  options: import_zod12.z.object({
1041
1183
  days: import_zod12.z.number(),
1042
- origin: FieldReference,
1184
+ origin: FieldReference2,
1043
1185
  boost: import_zod12.z.number().optional().default(1)
1044
1186
  })
1045
1187
  });
@@ -1047,7 +1189,7 @@ var DateDistanceMatcher = Matcher.extend({
1047
1189
  type: import_zod12.z.literal("dateDistance"),
1048
1190
  options: import_zod12.z.object({
1049
1191
  days: import_zod12.z.number(),
1050
- origin: FieldReference,
1192
+ origin: FieldReference2,
1051
1193
  boost: import_zod12.z.number().optional().default(1)
1052
1194
  })
1053
1195
  });
@@ -1096,8 +1238,7 @@ var Field = BaseField2.extend({
1096
1238
  value: TranslationConfig.describe(
1097
1239
  "Summary field value. Can utilise values defined in configuration and EventMetadata"
1098
1240
  ),
1099
- label: TranslationConfig,
1100
- emptyValueMessage: TranslationConfig.optional()
1241
+ label: TranslationConfig
1101
1242
  }).describe("Custom configured field");
1102
1243
  var SummaryConfig = import_zod13.z.object({
1103
1244
  fields: import_zod13.z.array(import_zod13.z.union([Field, ReferenceField])).describe("Fields rendered in summary view.")
@@ -1110,13 +1251,58 @@ var BaseField3 = import_zod14.z.object({
1110
1251
  config: import_zod14.z.object({
1111
1252
  type: MatchType.describe("Determines the type of field")
1112
1253
  }),
1113
- options: import_zod14.z.array(SelectOption).optional()
1254
+ options: import_zod14.z.array(SelectOption).optional(),
1255
+ searchCriteriaLabelPrefix: TranslationConfig.optional().describe(
1256
+ `
1257
+ This property determines whether to add a prefix (such as "Child" or "Applicant") before the field label
1258
+ when rendering search parameter labels \u2014 for example, in the search results page to indicate which fields were used in the search.
1259
+
1260
+ For example, a field config like { id: "child.name.firstname", label: { defaultMessage: "First Name(s)" } } would render as "First Name(s)" by default.
1261
+
1262
+ A field config like { id: "mother.firstname", label: { defaultMessage: "First Name(s)" } } would also render as "First Name(s)" by default.
1263
+
1264
+ 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)",
1265
+ which is ambiguous.
1266
+
1267
+ Now, if we treat the field ID prefix as a label (e.g., "applicant.firstname" \u2192 "Applicant"), and the field label is already
1268
+ descriptive \u2014 like { id: "applicant.firstname", label: { defaultMessage: "Applicant's First Name" } } \u2014 then the resulting
1269
+ label would be "Applicant Applicant's First Name", which is redundant and awkward.
1270
+
1271
+ By setting searchCriteriaLabelPrefix to a translation config object, we can explicitly define the desired prefix
1272
+ in the country-config > event.advancedSearch configuration. For example: field("child.dob", { searchCriteriaLabelPrefix: TranslationConfig }).
1273
+ `
1274
+ ),
1275
+ conditionals: import_zod14.z.array(FieldConditional).default([]).optional().describe(
1276
+ `
1277
+ In advanced search, we sometimes need to override the default field visibility conditionals.
1278
+
1279
+ For example, Informant fields in the declaration form may have conditional logic
1280
+ that hides them based on other field values. Since the advanced search form reuses
1281
+ the declaration form config, those same conditionals would apply by default.
1282
+
1283
+ However, in advanced search we often want to make all Informant fields searchable,
1284
+ regardless of their original visibility logic. To do this, we explicitly set their
1285
+ 'conditionals' to an empty array ('[]') in the search config. This ensures they
1286
+ are always rendered in the advanced search form.
1287
+ `
1288
+ )
1114
1289
  });
1290
+ var SearchQueryParams = import_zod14.z.object({
1291
+ eventType: import_zod14.z.string().optional().describe(
1292
+ "Defines type of event so that when redirecting to Advanced Search page, appropriate tab can be selected"
1293
+ )
1294
+ }).catchall(FieldValue);
1115
1295
  var FieldConfigSchema = BaseField3.extend({
1116
1296
  fieldId: import_zod14.z.string(),
1117
1297
  fieldType: import_zod14.z.literal("field")
1118
1298
  });
1119
- var EventFieldId = import_zod14.z.enum(["trackingId", "status"]);
1299
+ var EventFieldId = import_zod14.z.enum([
1300
+ "trackingId",
1301
+ "status",
1302
+ "legalStatus.REGISTERED.createdAt",
1303
+ "legalStatus.REGISTERED.createdAtLocation",
1304
+ "updatedAt"
1305
+ ]);
1120
1306
  var EventFieldConfigSchema = BaseField3.extend({
1121
1307
  fieldId: EventFieldId,
1122
1308
  fieldType: import_zod14.z.literal("event")
@@ -1134,114 +1320,127 @@ var AdvancedSearchConfig = import_zod14.z.object({
1134
1320
  var import_lodash = require("lodash");
1135
1321
 
1136
1322
  // ../commons/src/events/ActionDocument.ts
1323
+ var import_zod16 = require("zod");
1324
+ var import_zod_openapi7 = require("zod-openapi");
1325
+
1326
+ // ../commons/src/events/CreatedAtLocation.ts
1137
1327
  var import_zod15 = require("zod");
1138
- var import_zod_openapi3 = require("zod-openapi");
1139
- (0, import_zod_openapi3.extendZodWithOpenApi)(import_zod15.z);
1140
- var ActionUpdate = import_zod15.z.record(import_zod15.z.string(), FieldUpdateValue);
1141
- var EventState = import_zod15.z.record(import_zod15.z.string(), FieldValue);
1328
+ var CreatedAtLocation = import_zod15.z.string().nullish();
1329
+
1330
+ // ../commons/src/events/ActionDocument.ts
1331
+ (0, import_zod_openapi7.extendZodWithOpenApi)(import_zod16.z);
1332
+ var ActionUpdate = import_zod16.z.record(import_zod16.z.string(), FieldUpdateValue);
1333
+ var EventState = import_zod16.z.record(import_zod16.z.string(), FieldValue);
1142
1334
  var ActionStatus = {
1143
1335
  Requested: "Requested",
1144
1336
  Accepted: "Accepted",
1145
1337
  Rejected: "Rejected"
1146
1338
  };
1147
- var ActionBase = import_zod15.z.object({
1148
- id: import_zod15.z.string(),
1149
- transactionId: import_zod15.z.string(),
1150
- createdAt: import_zod15.z.string().datetime(),
1151
- createdBy: import_zod15.z.string(),
1152
- createdByRole: import_zod15.z.string(),
1339
+ var ActionBase = import_zod16.z.object({
1340
+ id: import_zod16.z.string(),
1341
+ transactionId: import_zod16.z.string(),
1342
+ createdAt: import_zod16.z.string().datetime(),
1343
+ createdBy: import_zod16.z.string(),
1344
+ createdByRole: import_zod16.z.string(),
1345
+ createdBySignature: import_zod16.z.string().nullish().describe("Reference to signature of the user who created the action"),
1346
+ createdAtLocation: CreatedAtLocation,
1153
1347
  declaration: ActionUpdate,
1154
1348
  annotation: ActionUpdate.optional(),
1155
- createdAtLocation: import_zod15.z.string(),
1156
- status: import_zod15.z.enum([
1349
+ status: import_zod16.z.enum([
1157
1350
  ActionStatus.Requested,
1158
1351
  ActionStatus.Accepted,
1159
1352
  ActionStatus.Rejected
1160
1353
  ]),
1161
1354
  // If the action is an asynchronous confirmation for another action, we will save the original action id here.
1162
- originalActionId: import_zod15.z.string().optional()
1355
+ originalActionId: import_zod16.z.string().optional()
1163
1356
  });
1164
1357
  var AssignedAction = ActionBase.merge(
1165
- import_zod15.z.object({
1166
- type: import_zod15.z.literal(ActionType.ASSIGN),
1167
- assignedTo: import_zod15.z.string()
1358
+ import_zod16.z.object({
1359
+ type: import_zod16.z.literal(ActionType.ASSIGN),
1360
+ assignedTo: import_zod16.z.string()
1168
1361
  })
1169
1362
  );
1170
1363
  var UnassignedAction = ActionBase.merge(
1171
- import_zod15.z.object({
1172
- type: import_zod15.z.literal(ActionType.UNASSIGN),
1173
- assignedTo: import_zod15.z.literal(null)
1364
+ import_zod16.z.object({
1365
+ type: import_zod16.z.literal(ActionType.UNASSIGN),
1366
+ assignedTo: import_zod16.z.literal(null)
1174
1367
  })
1175
1368
  );
1176
1369
  var RegisterAction = ActionBase.merge(
1177
- import_zod15.z.object({
1178
- type: import_zod15.z.literal(ActionType.REGISTER),
1179
- registrationNumber: import_zod15.z.string().optional()
1370
+ import_zod16.z.object({
1371
+ type: import_zod16.z.literal(ActionType.REGISTER),
1372
+ registrationNumber: import_zod16.z.string().optional()
1180
1373
  })
1181
1374
  );
1182
1375
  var DeclareAction = ActionBase.merge(
1183
- import_zod15.z.object({
1184
- type: import_zod15.z.literal(ActionType.DECLARE)
1376
+ import_zod16.z.object({
1377
+ type: import_zod16.z.literal(ActionType.DECLARE)
1185
1378
  })
1186
1379
  );
1187
1380
  var ValidateAction = ActionBase.merge(
1188
- import_zod15.z.object({
1189
- type: import_zod15.z.literal(ActionType.VALIDATE)
1381
+ import_zod16.z.object({
1382
+ type: import_zod16.z.literal(ActionType.VALIDATE)
1190
1383
  })
1191
1384
  );
1385
+ var RejectionReason = import_zod16.z.object({
1386
+ message: import_zod16.z.string().min(1, { message: "Message cannot be empty" }).describe("Message describing reason for rejection or archiving"),
1387
+ isDuplicate: import_zod16.z.boolean().optional().describe("If a declaration is duplicated")
1388
+ });
1192
1389
  var RejectAction = ActionBase.merge(
1193
- import_zod15.z.object({
1194
- type: import_zod15.z.literal(ActionType.REJECT)
1390
+ import_zod16.z.object({
1391
+ type: import_zod16.z.literal(ActionType.REJECT),
1392
+ reason: RejectionReason
1195
1393
  })
1196
1394
  );
1197
1395
  var MarkAsDuplicateAction = ActionBase.merge(
1198
- import_zod15.z.object({
1199
- type: import_zod15.z.literal(ActionType.MARKED_AS_DUPLICATE)
1396
+ import_zod16.z.object({
1397
+ type: import_zod16.z.literal(ActionType.MARKED_AS_DUPLICATE)
1200
1398
  })
1201
1399
  );
1202
1400
  var ArchiveAction = ActionBase.merge(
1203
- import_zod15.z.object({
1204
- type: import_zod15.z.literal(ActionType.ARCHIVE)
1401
+ import_zod16.z.object({
1402
+ type: import_zod16.z.literal(ActionType.ARCHIVE),
1403
+ reason: RejectionReason
1205
1404
  })
1206
1405
  );
1207
1406
  var CreatedAction = ActionBase.merge(
1208
- import_zod15.z.object({
1209
- type: import_zod15.z.literal(ActionType.CREATE)
1407
+ import_zod16.z.object({
1408
+ type: import_zod16.z.literal(ActionType.CREATE)
1210
1409
  })
1211
1410
  );
1212
1411
  var NotifiedAction = ActionBase.merge(
1213
- import_zod15.z.object({
1214
- type: import_zod15.z.literal(ActionType.NOTIFY)
1412
+ import_zod16.z.object({
1413
+ type: import_zod16.z.literal(ActionType.NOTIFY)
1215
1414
  })
1216
1415
  );
1217
1416
  var PrintCertificateAction = ActionBase.merge(
1218
- import_zod15.z.object({
1219
- type: import_zod15.z.literal(ActionType.PRINT_CERTIFICATE)
1417
+ import_zod16.z.object({
1418
+ type: import_zod16.z.literal(ActionType.PRINT_CERTIFICATE)
1220
1419
  })
1221
1420
  );
1222
1421
  var RequestedCorrectionAction = ActionBase.merge(
1223
- import_zod15.z.object({
1224
- type: import_zod15.z.literal(ActionType.REQUEST_CORRECTION)
1422
+ import_zod16.z.object({
1423
+ type: import_zod16.z.literal(ActionType.REQUEST_CORRECTION)
1225
1424
  })
1226
1425
  );
1227
1426
  var ApprovedCorrectionAction = ActionBase.merge(
1228
- import_zod15.z.object({
1229
- type: import_zod15.z.literal(ActionType.APPROVE_CORRECTION),
1230
- requestId: import_zod15.z.string()
1427
+ import_zod16.z.object({
1428
+ type: import_zod16.z.literal(ActionType.APPROVE_CORRECTION),
1429
+ requestId: import_zod16.z.string()
1231
1430
  })
1232
1431
  );
1233
1432
  var RejectedCorrectionAction = ActionBase.merge(
1234
- import_zod15.z.object({
1235
- type: import_zod15.z.literal(ActionType.REJECT_CORRECTION),
1236
- requestId: import_zod15.z.string()
1433
+ import_zod16.z.object({
1434
+ type: import_zod16.z.literal(ActionType.REJECT_CORRECTION),
1435
+ requestId: import_zod16.z.string()
1237
1436
  })
1238
1437
  );
1239
1438
  var ReadAction = ActionBase.merge(
1240
- import_zod15.z.object({
1241
- type: import_zod15.z.literal(ActionType.READ)
1439
+ import_zod16.z.object({
1440
+ type: import_zod16.z.literal(ActionType.READ)
1242
1441
  })
1243
1442
  );
1244
- var ActionDocument = import_zod15.z.discriminatedUnion("type", [
1443
+ var ActionDocument = import_zod16.z.discriminatedUnion("type", [
1245
1444
  CreatedAction.openapi({ ref: "CreatedAction" }),
1246
1445
  ValidateAction.openapi({ ref: "ValidateAction" }),
1247
1446
  RejectAction.openapi({ ref: "RejectAction" }),
@@ -1264,20 +1463,20 @@ var AsyncRejectActionDocument = ActionBase.omit({
1264
1463
  declaration: true,
1265
1464
  annotation: true
1266
1465
  }).merge(
1267
- import_zod15.z.object({
1268
- type: import_zod15.z.enum(ConfirmableActions),
1269
- status: import_zod15.z.literal(ActionStatus.Rejected)
1466
+ import_zod16.z.object({
1467
+ type: import_zod16.z.enum(ConfirmableActions),
1468
+ status: import_zod16.z.literal(ActionStatus.Rejected)
1270
1469
  })
1271
1470
  );
1272
- var Action = import_zod15.z.union([ActionDocument, AsyncRejectActionDocument]);
1273
- var ResolvedUser = import_zod15.z.object({
1274
- id: import_zod15.z.string(),
1275
- role: import_zod15.z.string(),
1276
- name: import_zod15.z.array(
1277
- import_zod15.z.object({
1278
- use: import_zod15.z.string(),
1279
- given: import_zod15.z.array(import_zod15.z.string()),
1280
- family: import_zod15.z.string()
1471
+ var Action = import_zod16.z.union([ActionDocument, AsyncRejectActionDocument]);
1472
+ var ResolvedUser = import_zod16.z.object({
1473
+ id: import_zod16.z.string(),
1474
+ role: import_zod16.z.string(),
1475
+ name: import_zod16.z.array(
1476
+ import_zod16.z.object({
1477
+ use: import_zod16.z.string(),
1478
+ given: import_zod16.z.array(import_zod16.z.string()),
1479
+ family: import_zod16.z.string()
1281
1480
  })
1282
1481
  )
1283
1482
  });
@@ -1288,7 +1487,7 @@ var import_ajv_formats = __toESM(require("ajv-formats"));
1288
1487
  var import_date_fns = require("date-fns");
1289
1488
 
1290
1489
  // ../commons/src/events/FieldTypeMapping.ts
1291
- var import_zod16 = require("zod");
1490
+ var import_zod17 = require("zod");
1292
1491
  function mapFieldTypeToZod(type, required) {
1293
1492
  let schema;
1294
1493
  switch (type) {
@@ -1314,7 +1513,8 @@ function mapFieldTypeToZod(type, required) {
1314
1513
  case FieldType.ADMINISTRATIVE_AREA:
1315
1514
  case FieldType.FACILITY:
1316
1515
  case FieldType.OFFICE:
1317
- case FieldType.SIGNATURE:
1516
+ case FieldType.PHONE:
1517
+ case FieldType.ID:
1318
1518
  schema = required ? NonEmptyTextValue : TextValue;
1319
1519
  break;
1320
1520
  case FieldType.NUMBER:
@@ -1323,6 +1523,7 @@ function mapFieldTypeToZod(type, required) {
1323
1523
  case FieldType.CHECKBOX:
1324
1524
  schema = CheckboxFieldValue;
1325
1525
  break;
1526
+ case FieldType.SIGNATURE:
1326
1527
  case FieldType.FILE:
1327
1528
  schema = FileFieldValue;
1328
1529
  break;
@@ -1335,6 +1536,9 @@ function mapFieldTypeToZod(type, required) {
1335
1536
  case FieldType.DATA:
1336
1537
  schema = DataFieldValue;
1337
1538
  break;
1539
+ case FieldType.NAME:
1540
+ schema = required ? NameFieldValue : NameFieldUpdateValue;
1541
+ break;
1338
1542
  }
1339
1543
  return required ? schema : schema.nullish();
1340
1544
  }
@@ -1343,59 +1547,7 @@ function createValidationSchema(config) {
1343
1547
  for (const field2 of config) {
1344
1548
  shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
1345
1549
  }
1346
- return import_zod16.z.object(shape);
1347
- }
1348
- function mapFieldTypeToMockValue(field2, i) {
1349
- switch (field2.type) {
1350
- case FieldType.DIVIDER:
1351
- case FieldType.TEXT:
1352
- case FieldType.TEXTAREA:
1353
- case FieldType.BULLET_LIST:
1354
- case FieldType.PAGE_HEADER:
1355
- case FieldType.LOCATION:
1356
- case FieldType.SELECT:
1357
- case FieldType.COUNTRY:
1358
- case FieldType.RADIO_GROUP:
1359
- case FieldType.SIGNATURE:
1360
- case FieldType.PARAGRAPH:
1361
- case FieldType.ADMINISTRATIVE_AREA:
1362
- case FieldType.FACILITY:
1363
- case FieldType.OFFICE:
1364
- return `${field2.id}-${field2.type}-${i}`;
1365
- case FieldType.NUMBER:
1366
- return 19;
1367
- case FieldType.EMAIL:
1368
- return "test@opencrvs.org";
1369
- case FieldType.ADDRESS:
1370
- return {
1371
- country: "FAR",
1372
- addressType: AddressType.DOMESTIC,
1373
- province: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
1374
- district: "5ef450bc-712d-48ad-93f3-8da0fa453baa",
1375
- urbanOrRural: "URBAN",
1376
- town: "Example Town",
1377
- residentialArea: "Example Residential Area",
1378
- street: "Example Street",
1379
- number: "55",
1380
- zipCode: "123456"
1381
- };
1382
- case FieldType.DATE:
1383
- return "2021-01-01";
1384
- case FieldType.DATE_RANGE:
1385
- return ["2021-01-01", "2021-01-02"];
1386
- case FieldType.CHECKBOX:
1387
- return true;
1388
- case FieldType.FILE:
1389
- return {
1390
- filename: "4f095fc4-4312-4de2-aa38-86dcc0f71044.png",
1391
- originalFilename: "abcd.png",
1392
- type: "image/png"
1393
- };
1394
- case FieldType.FILE_WITH_OPTIONS:
1395
- return null;
1396
- case FieldType.DATA:
1397
- return {};
1398
- }
1550
+ return import_zod17.z.object(shape);
1399
1551
  }
1400
1552
  function mapFieldTypeToEmptyValue(field2) {
1401
1553
  switch (field2.type) {
@@ -1408,7 +1560,6 @@ function mapFieldTypeToEmptyValue(field2) {
1408
1560
  case FieldType.SELECT:
1409
1561
  case FieldType.COUNTRY:
1410
1562
  case FieldType.RADIO_GROUP:
1411
- case FieldType.SIGNATURE:
1412
1563
  case FieldType.PARAGRAPH:
1413
1564
  case FieldType.ADMINISTRATIVE_AREA:
1414
1565
  case FieldType.FACILITY:
@@ -1419,6 +1570,9 @@ function mapFieldTypeToEmptyValue(field2) {
1419
1570
  case FieldType.CHECKBOX:
1420
1571
  case FieldType.DATE_RANGE:
1421
1572
  case FieldType.DATA:
1573
+ case FieldType.NAME:
1574
+ case FieldType.PHONE:
1575
+ case FieldType.ID:
1422
1576
  return null;
1423
1577
  case FieldType.ADDRESS:
1424
1578
  return {
@@ -1434,6 +1588,7 @@ function mapFieldTypeToEmptyValue(field2) {
1434
1588
  number: null,
1435
1589
  zipCode: null
1436
1590
  };
1591
+ case FieldType.SIGNATURE:
1437
1592
  case FieldType.FILE:
1438
1593
  return {
1439
1594
  filename: "",
@@ -1462,6 +1617,15 @@ var isTextFieldType = (field2) => {
1462
1617
  var isNumberFieldType = (field2) => {
1463
1618
  return field2.config.type === FieldType.NUMBER;
1464
1619
  };
1620
+ var isNameFieldType = (field2) => {
1621
+ return field2.config.type === FieldType.NAME;
1622
+ };
1623
+ var isPhoneFieldType = (field2) => {
1624
+ return field2.config.type === FieldType.PHONE;
1625
+ };
1626
+ var isIdFieldType = (field2) => {
1627
+ return field2.config.type === FieldType.ID;
1628
+ };
1465
1629
  var isTextAreaFieldType = (field2) => {
1466
1630
  return field2.config.type === FieldType.TEXTAREA;
1467
1631
  };
@@ -1513,6 +1677,9 @@ var isOfficeFieldType = (field2) => {
1513
1677
  var isDataFieldType = (field2) => {
1514
1678
  return field2.config.type === FieldType.DATA;
1515
1679
  };
1680
+ var isNonInteractiveFieldType = (field2) => {
1681
+ return field2.type === FieldType.DIVIDER || field2.type === FieldType.PAGE_HEADER || field2.type === FieldType.PARAGRAPH || field2.type === FieldType.BULLET_LIST || field2.type === FieldType.DATA;
1682
+ };
1516
1683
 
1517
1684
  // ../commons/src/conditionals/validate.ts
1518
1685
  var ajv = new import_ajv.default({
@@ -1593,6 +1760,11 @@ var errorMessages = {
1593
1760
  defaultMessage: "Invalid input",
1594
1761
  description: "Error message when generic field is invalid",
1595
1762
  id: "v2.error.invalid"
1763
+ },
1764
+ unexpectedField: {
1765
+ defaultMessage: "Unexpected field",
1766
+ description: "Error message when field is not expected",
1767
+ id: "v2.error.unexpectedField"
1596
1768
  }
1597
1769
  };
1598
1770
  function createIntlError(message) {
@@ -1688,6 +1860,45 @@ function runFieldValidations({
1688
1860
  errors: [...fieldValidationResult, ...customValidationResults]
1689
1861
  };
1690
1862
  }
1863
+ function getValidatorsForField(fieldId, validations) {
1864
+ return validations.map(({ validator, message }) => {
1865
+ const jsonSchema = validator;
1866
+ const $form = jsonSchema.properties.$form;
1867
+ if ($form.properties?.[fieldId]?.type === "object") {
1868
+ return {
1869
+ message,
1870
+ validator: {
1871
+ ...jsonSchema,
1872
+ properties: {
1873
+ $form: {
1874
+ type: "object",
1875
+ properties: $form.properties?.[fieldId]?.properties || {},
1876
+ required: $form.properties?.[fieldId]?.required || []
1877
+ }
1878
+ }
1879
+ }
1880
+ };
1881
+ }
1882
+ if (!$form.properties?.[fieldId]) {
1883
+ return null;
1884
+ }
1885
+ return {
1886
+ message,
1887
+ validator: {
1888
+ ...jsonSchema,
1889
+ properties: {
1890
+ $form: {
1891
+ type: "object",
1892
+ properties: {
1893
+ [fieldId]: $form.properties?.[fieldId]
1894
+ },
1895
+ required: $form.required?.includes(fieldId) ? [fieldId] : []
1896
+ }
1897
+ }
1898
+ }
1899
+ };
1900
+ }).filter((x) => x !== null);
1901
+ }
1691
1902
 
1692
1903
  // ../commons/src/uuid.ts
1693
1904
  var import_uuid = require("uuid");
@@ -1734,6 +1945,13 @@ var getActionAnnotationFields = (actionConfig) => {
1734
1945
  function getAllAnnotationFields(config) {
1735
1946
  return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
1736
1947
  }
1948
+ function getAllUniqueFields(eventConfig) {
1949
+ return (0, import_lodash.uniqBy)(getDeclarationFields(eventConfig), (field2) => field2.id);
1950
+ }
1951
+ function getDeclarationFieldById(config, fieldId) {
1952
+ const field2 = getAllUniqueFields(config).find((f) => f.id === fieldId);
1953
+ return getOrThrow(field2, `Field with id ${fieldId} not found in event config`);
1954
+ }
1737
1955
  var findRecordActionPages = (config, actionType) => {
1738
1956
  const action = config.actions.find((a) => a.type === actionType);
1739
1957
  if (action?.type === ActionType.REQUEST_CORRECTION) {
@@ -1839,8 +2057,9 @@ function omitHiddenAnnotationFields(actionConfig, declaration, annotation) {
1839
2057
  );
1840
2058
  }
1841
2059
  function deepMerge(currentDocument, actionDocument) {
2060
+ const currentDocumentClone = (0, import_lodash.cloneDeep)(currentDocument);
1842
2061
  return (0, import_lodash.mergeWith)(
1843
- currentDocument,
2062
+ (0, import_lodash.cloneDeep)(currentDocumentClone),
1844
2063
  actionDocument,
1845
2064
  (previousValue, incomingValue) => {
1846
2065
  if (incomingValue === void 0) {
@@ -1888,25 +2107,31 @@ function getMixedPath(obj, path, defaultValue) {
1888
2107
  const result = resolve(obj, parts);
1889
2108
  return (0, import_lodash.isNil)(result) ? defaultValue : result;
1890
2109
  }
2110
+ function getEventConfigById(eventConfigs, id) {
2111
+ const eventConfig = eventConfigs.find(
2112
+ (eventConfiguration) => eventConfiguration.id === id
2113
+ );
2114
+ return getOrThrow(eventConfig, `Event config for ${id} not found`);
2115
+ }
1891
2116
 
1892
2117
  // ../commons/src/events/EventConfig.ts
1893
- var import_zod_openapi4 = require("zod-openapi");
1894
- (0, import_zod_openapi4.extendZodWithOpenApi)(import_zod17.z);
1895
- var EventConfig = import_zod17.z.object({
1896
- id: import_zod17.z.string().describe(
2118
+ var import_zod_openapi8 = require("zod-openapi");
2119
+ (0, import_zod_openapi8.extendZodWithOpenApi)(import_zod18.z);
2120
+ var EventConfig = import_zod18.z.object({
2121
+ id: import_zod18.z.string().describe(
1897
2122
  'A machine-readable identifier for the event, e.g. "birth" or "death"'
1898
2123
  ),
1899
- dateOfEvent: import_zod17.z.object({ fieldId: import_zod17.z.string() }).optional(),
2124
+ dateOfEvent: FieldReference.optional(),
1900
2125
  title: TranslationConfig,
1901
2126
  fallbackTitle: TranslationConfig.optional().describe(
1902
2127
  "This is a fallback title if actual title resolves to empty string"
1903
2128
  ),
1904
2129
  summary: SummaryConfig,
1905
2130
  label: TranslationConfig,
1906
- actions: import_zod17.z.array(ActionConfig),
2131
+ actions: import_zod18.z.array(ActionConfig),
1907
2132
  declaration: DeclarationFormConfig,
1908
- deduplication: import_zod17.z.array(DeduplicationConfig).optional().default([]),
1909
- advancedSearch: import_zod17.z.array(AdvancedSearchConfig).optional().default([])
2133
+ deduplication: import_zod18.z.array(DeduplicationConfig).optional().default([]),
2134
+ advancedSearch: import_zod18.z.array(AdvancedSearchConfig).optional().default([])
1910
2135
  }).superRefine((event2, ctx) => {
1911
2136
  const allFields = findAllFields(event2);
1912
2137
  const fieldIds = allFields.map((field2) => field2.id);
@@ -1940,13 +2165,13 @@ var EventConfig = import_zod17.z.object({
1940
2165
  }
1941
2166
  if (event2.dateOfEvent) {
1942
2167
  const eventDateFieldId = getDeclarationFields(event2).find(
1943
- ({ id }) => id === event2.dateOfEvent?.fieldId
2168
+ ({ id }) => id === event2.dateOfEvent?.$$field
1944
2169
  );
1945
2170
  if (!eventDateFieldId) {
1946
2171
  ctx.addIssue({
1947
2172
  code: "custom",
1948
2173
  message: `Date of event field id must match a field id in fields array.
1949
- Invalid date of event field ID for event ${event2.id}: ${event2.dateOfEvent.fieldId}`,
2174
+ Invalid date of event field ID for event ${event2.id}: ${event2.dateOfEvent.$$field}`,
1950
2175
  path: ["dateOfEvent"]
1951
2176
  });
1952
2177
  } else if (eventDateFieldId.type !== FieldType.DATE) {
@@ -1968,278 +2193,87 @@ var definePage = (page) => PageConfig.parse(page);
1968
2193
  var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
1969
2194
 
1970
2195
  // ../commons/src/events/WorkqueueConfig.ts
1971
- var import_zod20 = require("zod");
2196
+ var import_zod25 = require("zod");
1972
2197
 
1973
- // ../commons/src/events/EventIndex.ts
2198
+ // ../commons/src/events/serializers/user/serializer.ts
1974
2199
  var import_zod19 = require("zod");
1975
-
1976
- // ../commons/src/events/EventMetadata.ts
1977
- var import_zod18 = require("zod");
1978
- var EventStatus = {
1979
- CREATED: "CREATED",
1980
- NOTIFIED: "NOTIFIED",
1981
- DECLARED: "DECLARED",
1982
- VALIDATED: "VALIDATED",
1983
- REGISTERED: "REGISTERED",
1984
- CERTIFIED: "CERTIFIED",
1985
- REJECTED: "REJECTED",
1986
- ARCHIVED: "ARCHIVED"
1987
- };
1988
- var CustomFlags = {
1989
- CERTIFICATE_PRINTED: "certificate-printed"
1990
- };
1991
- var Flag = import_zod18.z.string().regex(
1992
- new RegExp(
1993
- `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(ActionStatus).join("|").toLowerCase()})$`
1994
- ),
1995
- "Flag must be in the format ActionType:ActionStatus (lowerCase)"
1996
- ).or(import_zod18.z.nativeEnum(CustomFlags));
1997
- var eventStatuses = Object.values(EventStatus);
1998
- var EventStatuses = import_zod18.z.nativeEnum(EventStatus);
1999
- var ZodDate = import_zod18.z.string().date();
2000
- var ActionCreationMetadata = import_zod18.z.object({
2001
- createdAt: import_zod18.z.string().datetime().describe("The timestamp when the action request was created."),
2002
- createdBy: import_zod18.z.string().describe("ID of the user who created the action request."),
2003
- createdAtLocation: import_zod18.z.string().describe("Location of the user who created the action request."),
2004
- acceptedAt: import_zod18.z.string().datetime().describe("Timestamp when the action request was accepted."),
2005
- createdByRole: import_zod18.z.string().describe("Role of the user at the time of action request creation.")
2006
- });
2007
- var RegistrationCreationMetadata = ActionCreationMetadata.extend({
2008
- registrationNumber: import_zod18.z.string().describe(
2009
- "Registration number of the event. Always present for accepted registrations."
2010
- )
2011
- });
2012
- var LegalStatuses = import_zod18.z.object({
2013
- [EventStatus.DECLARED]: ActionCreationMetadata.nullish(),
2014
- [EventStatus.REGISTERED]: RegistrationCreationMetadata.nullish()
2015
- });
2016
- var EventMetadata = import_zod18.z.object({
2017
- id: import_zod18.z.string(),
2018
- type: import_zod18.z.string().describe("The type of event, such as birth, death, or marriage."),
2019
- status: EventStatuses,
2020
- legalStatuses: LegalStatuses.describe(
2021
- "Metadata related to the legal registration of the event, such as who registered it and when."
2022
- ),
2023
- createdAt: import_zod18.z.string().datetime().describe("The timestamp when the event was first created and saved."),
2024
- dateOfEvent: ZodDate.nullish(),
2025
- createdBy: import_zod18.z.string().describe("ID of the user who created the event."),
2026
- updatedByUserRole: import_zod18.z.string().describe("Role of the user who last updated the declaration."),
2027
- createdAtLocation: import_zod18.z.string().describe("Location of the user who created the event."),
2028
- updatedAtLocation: import_zod18.z.string().nullish().describe("Location of the user who last updated the declaration."),
2029
- updatedAt: import_zod18.z.string().datetime().describe("Timestamp of the most recent declaration update."),
2030
- assignedTo: import_zod18.z.string().nullish().describe("ID of the user currently assigned to the event."),
2031
- updatedBy: import_zod18.z.string().nullish().describe("ID of the user who last updated the declaration."),
2032
- trackingId: import_zod18.z.string().describe(
2033
- "System-generated tracking ID used by informants or registrars to look up the event."
2034
- ),
2035
- flags: import_zod18.z.array(Flag)
2200
+ var SerializedUserField = import_zod19.z.object({
2201
+ $userField: import_zod19.z.enum([
2202
+ "id",
2203
+ "name",
2204
+ "role",
2205
+ "signatureFilename",
2206
+ "primaryOfficeId"
2207
+ ])
2036
2208
  });
2037
- var EventMetadataKeys = import_zod18.z.enum([
2038
- "id",
2039
- "type",
2040
- "status",
2041
- "createdAt",
2042
- "dateOfEvent",
2043
- "createdBy",
2044
- "updatedByUserRole",
2045
- "createdAtLocation",
2046
- "updatedAtLocation",
2047
- "updatedAt",
2048
- "assignedTo",
2049
- "updatedBy",
2050
- "trackingId",
2051
- "legalStatuses",
2052
- "flags"
2053
- ]);
2054
- var EventMetadataParameter = import_zod18.z.object({
2055
- // @TODO: Reconcile with the event metadata definition. How could we derive one from the other?
2056
- $event: EventMetadataKeys
2209
+ function userSerializer(userField) {
2210
+ return {
2211
+ $userField: userField
2212
+ };
2213
+ }
2214
+
2215
+ // ../commons/src/conditionals/conditionals.ts
2216
+ function defineConditional(schema) {
2217
+ return schema;
2218
+ }
2219
+ function defineFormConditional(schema) {
2220
+ const schemaWithForm = {
2221
+ type: "object",
2222
+ properties: {
2223
+ $form: schema
2224
+ },
2225
+ required: ["$form"]
2226
+ };
2227
+ return defineConditional(schemaWithForm);
2228
+ }
2229
+ function alwaysTrue() {
2230
+ return {};
2231
+ }
2232
+ function and(...conditions) {
2233
+ return defineConditional({
2234
+ type: "object",
2235
+ allOf: conditions,
2236
+ required: []
2237
+ });
2238
+ }
2239
+ function or(...conditions) {
2240
+ return defineConditional({
2241
+ type: "object",
2242
+ anyOf: conditions,
2243
+ required: []
2244
+ });
2245
+ }
2246
+ function not(condition) {
2247
+ return defineConditional({
2248
+ type: "object",
2249
+ not: condition,
2250
+ required: []
2251
+ });
2252
+ }
2253
+ function never() {
2254
+ return not(alwaysTrue());
2255
+ }
2256
+ var user = Object.assign(userSerializer, {
2257
+ hasScope: (scope) => defineConditional({
2258
+ type: "object",
2259
+ properties: {
2260
+ $user: {
2261
+ type: "object",
2262
+ required: ["scope"],
2263
+ properties: {
2264
+ scope: {
2265
+ type: "array",
2266
+ contains: {
2267
+ type: "string",
2268
+ const: scope
2269
+ }
2270
+ }
2271
+ }
2272
+ }
2273
+ },
2274
+ required: ["$user"]
2275
+ })
2057
2276
  });
2058
- var eventMetadataLabelMap = {
2059
- "event.assignedTo": {
2060
- id: "event.assignedTo.label",
2061
- defaultMessage: "Assigned To",
2062
- description: "Assigned To"
2063
- },
2064
- "event.createdAt": {
2065
- id: "event.createdAt.label",
2066
- defaultMessage: "Created",
2067
- description: "Created At"
2068
- },
2069
- "event.dateOfEvent": {
2070
- id: "event.dateOfEvent.label",
2071
- defaultMessage: "Date of Event",
2072
- description: "Date of Event"
2073
- },
2074
- "event.createdAtLocation": {
2075
- id: "event.createdAtLocation.label",
2076
- defaultMessage: "Location",
2077
- description: "Created At Location"
2078
- },
2079
- "event.updatedAtLocation": {
2080
- id: "event.updatedAtLocation.label",
2081
- defaultMessage: "Location",
2082
- description: "Updated At Location"
2083
- },
2084
- "event.createdBy": {
2085
- id: "event.createdBy.label",
2086
- defaultMessage: "Created By",
2087
- description: "Created By"
2088
- },
2089
- "event.updatedByUserRole": {
2090
- id: "event.updatedByUserRole.label",
2091
- defaultMessage: "Updated By Role",
2092
- description: "Updated By Role"
2093
- },
2094
- "event.id": {
2095
- id: "event.id.label",
2096
- defaultMessage: "ID",
2097
- description: "ID"
2098
- },
2099
- "event.updatedAt": {
2100
- id: "event.modifiedAt.label",
2101
- defaultMessage: "Updated",
2102
- description: "Modified At"
2103
- },
2104
- "event.status": {
2105
- id: "event.status.label",
2106
- defaultMessage: "Status",
2107
- description: "Status"
2108
- },
2109
- "event.type": {
2110
- id: "event.type.label",
2111
- defaultMessage: "Type",
2112
- description: "Type"
2113
- },
2114
- "event.updatedBy": {
2115
- id: "event.updatedBy.label",
2116
- defaultMessage: "Updated By",
2117
- description: "Updated By"
2118
- },
2119
- "event.trackingId": {
2120
- id: "event.trackingId.label",
2121
- defaultMessage: "Tracking ID",
2122
- description: "Tracking ID"
2123
- },
2124
- "event.flags": {
2125
- id: "event.flags.label",
2126
- defaultMessage: "Flags",
2127
- description: "Flags"
2128
- }
2129
- };
2130
-
2131
- // ../commons/src/events/EventIndex.ts
2132
- var EventIndex = EventMetadata.extend({
2133
- declaration: EventState
2134
- });
2135
- var EventSearchIndex = import_zod19.z.record(import_zod19.z.string(), import_zod19.z.any()).and(
2136
- import_zod19.z.object({
2137
- type: import_zod19.z.string()
2138
- // Ensures "type" (event-id) exists and is a string
2139
- })
2140
- );
2141
- var Fuzzy = import_zod19.z.object({ type: import_zod19.z.literal("fuzzy"), term: import_zod19.z.string() });
2142
- var Exact = import_zod19.z.object({ type: import_zod19.z.literal("exact"), term: import_zod19.z.string() });
2143
- var AnyOf = import_zod19.z.object({
2144
- type: import_zod19.z.literal("anyOf"),
2145
- terms: import_zod19.z.array(import_zod19.z.string())
2146
- });
2147
- var Range = import_zod19.z.object({
2148
- type: import_zod19.z.literal("range"),
2149
- gte: import_zod19.z.string(),
2150
- lte: import_zod19.z.string()
2151
- });
2152
- var Not = import_zod19.z.object({ type: import_zod19.z.literal("not"), term: import_zod19.z.string() });
2153
- var Within = import_zod19.z.object({ type: import_zod19.z.literal("within"), location: import_zod19.z.string() });
2154
- var DateCondition = import_zod19.z.union([Exact, Range]);
2155
- var QueryInput = import_zod19.z.lazy(
2156
- () => import_zod19.z.union([
2157
- import_zod19.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf, Not]),
2158
- import_zod19.z.record(import_zod19.z.string(), QueryInput)
2159
- ])
2160
- );
2161
- var QueryExpression = import_zod19.z.object({
2162
- type: import_zod19.z.literal("and"),
2163
- eventType: import_zod19.z.string(),
2164
- status: import_zod19.z.optional(import_zod19.z.union([AnyOf, Exact])),
2165
- createdAt: import_zod19.z.optional(DateCondition),
2166
- updatedAt: import_zod19.z.optional(DateCondition),
2167
- createAtLocation: import_zod19.z.optional(import_zod19.z.union([Within, Exact])),
2168
- updatedAtLocation: import_zod19.z.optional(import_zod19.z.union([Within, Exact])),
2169
- createdBy: import_zod19.z.optional(Exact),
2170
- updatedBy: import_zod19.z.optional(Exact),
2171
- trackingId: import_zod19.z.optional(Exact),
2172
- flags: import_zod19.z.optional(import_zod19.z.array(import_zod19.z.union([AnyOf, Not]))),
2173
- data: QueryInput
2174
- }).partial();
2175
- var Or2 = import_zod19.z.object({
2176
- type: import_zod19.z.literal("or"),
2177
- clauses: import_zod19.z.array(QueryExpression)
2178
- });
2179
- var QueryType = import_zod19.z.discriminatedUnion("type", [QueryExpression, Or2]);
2180
-
2181
- // ../commons/src/conditionals/conditionals.ts
2182
- function defineConditional(schema) {
2183
- return schema;
2184
- }
2185
- function defineFormConditional(schema) {
2186
- const schemaWithForm = {
2187
- type: "object",
2188
- properties: {
2189
- $form: schema
2190
- },
2191
- required: ["$form"]
2192
- };
2193
- return defineConditional(schemaWithForm);
2194
- }
2195
- function alwaysTrue() {
2196
- return {};
2197
- }
2198
- function and(...conditions) {
2199
- return defineConditional({
2200
- type: "object",
2201
- allOf: conditions,
2202
- required: []
2203
- });
2204
- }
2205
- function or(...conditions) {
2206
- return defineConditional({
2207
- type: "object",
2208
- anyOf: conditions,
2209
- required: []
2210
- });
2211
- }
2212
- function not(condition) {
2213
- return defineConditional({
2214
- type: "object",
2215
- not: condition,
2216
- required: []
2217
- });
2218
- }
2219
- function never() {
2220
- return not(alwaysTrue());
2221
- }
2222
- var user = {
2223
- hasScope: (scope) => defineConditional({
2224
- type: "object",
2225
- properties: {
2226
- $user: {
2227
- type: "object",
2228
- required: ["scope"],
2229
- properties: {
2230
- scope: {
2231
- type: "array",
2232
- contains: {
2233
- type: "string",
2234
- const: scope
2235
- }
2236
- }
2237
- }
2238
- }
2239
- },
2240
- required: ["$user"]
2241
- })
2242
- };
2243
2277
  function createEventConditionals() {
2244
2278
  return {
2245
2279
  /**
@@ -2290,7 +2324,7 @@ function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
2290
2324
  };
2291
2325
  }
2292
2326
  function isFieldReference(value) {
2293
- return typeof value === "object" && value !== null && "_fieldId" in value;
2327
+ return typeof value === "object" && value !== null && "$$field" in value;
2294
2328
  }
2295
2329
  function createFieldConditionals(fieldId) {
2296
2330
  const getDateRange = (date, clause) => ({
@@ -2305,6 +2339,10 @@ function createFieldConditionals(fieldId) {
2305
2339
  required: [fieldId]
2306
2340
  });
2307
2341
  return {
2342
+ /**
2343
+ * @private Internal property used for field reference tracking.
2344
+ */
2345
+ $$field: fieldId,
2308
2346
  isAfter: () => ({
2309
2347
  days: (days) => ({
2310
2348
  inPast: () => defineFormConditional(
@@ -2316,7 +2354,7 @@ function createFieldConditionals(fieldId) {
2316
2354
  }),
2317
2355
  date: (date) => {
2318
2356
  if (isFieldReference(date)) {
2319
- const comparedFieldId = date._fieldId;
2357
+ const comparedFieldId = date.$$field;
2320
2358
  return defineFormConditional(
2321
2359
  getDateRangeToFieldReference(
2322
2360
  fieldId,
@@ -2340,7 +2378,7 @@ function createFieldConditionals(fieldId) {
2340
2378
  }),
2341
2379
  date: (date) => {
2342
2380
  if (isFieldReference(date)) {
2343
- const comparedFieldId = date._fieldId;
2381
+ const comparedFieldId = date.$$field;
2344
2382
  return defineFormConditional(
2345
2383
  getDateRangeToFieldReference(
2346
2384
  fieldId,
@@ -2355,13 +2393,13 @@ function createFieldConditionals(fieldId) {
2355
2393
  }),
2356
2394
  isEqualTo: (value) => {
2357
2395
  if (isFieldReference(value)) {
2358
- const comparedFieldId = value._fieldId;
2396
+ const comparedFieldId = value.$$field;
2359
2397
  return defineFormConditional({
2360
2398
  type: "object",
2361
2399
  properties: {
2362
2400
  [fieldId]: {
2363
2401
  type: ["string", "boolean"],
2364
- const: { $data: `1/${comparedFieldId}` }
2402
+ const: { $data: `/$form/${comparedFieldId}` }
2365
2403
  },
2366
2404
  [comparedFieldId]: { type: ["string", "boolean"] }
2367
2405
  },
@@ -2472,18 +2510,81 @@ function createFieldConditionals(fieldId) {
2472
2510
  },
2473
2511
  required: [fieldId]
2474
2512
  }),
2475
- getId: () => ({ fieldId })
2513
+ getId: () => ({ fieldId }),
2514
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2515
+ object: (options) => defineFormConditional({
2516
+ type: "object",
2517
+ properties: {
2518
+ [fieldId]: {
2519
+ type: "object",
2520
+ properties: Object.fromEntries(
2521
+ Object.entries(options).map(([key, value]) => {
2522
+ return [key, value.properties.$form.properties[key]];
2523
+ })
2524
+ ),
2525
+ required: Object.keys(options)
2526
+ }
2527
+ },
2528
+ required: [fieldId]
2529
+ })
2530
+ };
2531
+ }
2532
+
2533
+ // ../commons/src/searchConfigs.ts
2534
+ function createSearchConfig(baseField) {
2535
+ return {
2536
+ /**
2537
+ * Creates a range configuration for the specified field.
2538
+ *
2539
+ * @returns An object containing the field ID and a configuration object with a type of 'range'.
2540
+ *
2541
+ * @example event('legalStatus.REGISTERED.createdAt').range()
2542
+ * // {
2543
+ * // ...
2544
+ * // config: { type: 'range' }
2545
+ * // }
2546
+ */
2547
+ range: () => ({
2548
+ ...baseField,
2549
+ config: { type: "range" }
2550
+ }),
2551
+ /**
2552
+ * Creates a configuration for exact matching of the specified field.
2553
+ * @returns An object containing the field ID and a configuration object with a type of 'exact'.
2554
+ * @example field('dob').exact()
2555
+ * // {
2556
+ * // ...
2557
+ * // config: { type: 'exact' }
2558
+ * // }
2559
+ */
2560
+ exact: () => ({
2561
+ ...baseField,
2562
+ config: { type: "exact" }
2563
+ }),
2564
+ /**
2565
+ * Creates a configuration for fuzzy matching of the specified field.
2566
+ * @returns An object containing the field ID and a configuration object with a type of 'exact'.
2567
+ * @example field('name').fuzzy()
2568
+ * // {
2569
+ * // ...
2570
+ * // config: { type: 'fuzzy' }
2571
+ * // }
2572
+ */
2573
+ fuzzy: () => ({
2574
+ ...baseField,
2575
+ config: { type: "fuzzy" }
2576
+ })
2476
2577
  };
2477
2578
  }
2478
2579
 
2479
2580
  // ../commons/src/event-config/event-configuration.ts
2480
2581
  function createEventFieldConfig(fieldId, options) {
2481
- return {
2582
+ const baseField = {
2482
2583
  fieldId,
2483
2584
  options,
2484
- config: { type: "exact" },
2485
2585
  fieldType: "event"
2486
2586
  };
2587
+ return createSearchConfig(baseField);
2487
2588
  }
2488
2589
 
2489
2590
  // ../commons/src/events/event.ts
@@ -2499,135 +2600,652 @@ var event = Object.assign(eventFn, {
2499
2600
  }
2500
2601
  });
2501
2602
 
2502
- // ../commons/src/events/WorkqueueConfig.ts
2503
- var WorkqueueConfig = import_zod20.z.object({
2504
- slug: import_zod20.z.string().describe("Determines the url of the workqueue."),
2505
- name: TranslationConfig.describe(
2506
- "Title of the workflow (both in navigation and on the page)"
2603
+ // ../commons/src/events/WorkqueueColumnConfig.ts
2604
+ var import_zod21 = require("zod");
2605
+
2606
+ // ../commons/src/events/EventMetadata.ts
2607
+ var import_zod20 = require("zod");
2608
+ var EventStatus = import_zod20.z.enum([
2609
+ "CREATED",
2610
+ "NOTIFIED",
2611
+ "DECLARED",
2612
+ "VALIDATED",
2613
+ "REGISTERED",
2614
+ "CERTIFIED",
2615
+ "REJECTED",
2616
+ "ARCHIVED"
2617
+ ]);
2618
+ var CustomFlags = {
2619
+ CERTIFICATE_PRINTED: "certificate-printed"
2620
+ };
2621
+ var Flag = import_zod20.z.string().regex(
2622
+ new RegExp(
2623
+ `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
2624
+ ActionStatus
2625
+ ).join("|").toLowerCase()})$`
2507
2626
  ),
2508
- query: QueryType,
2509
- actions: import_zod20.z.array(
2510
- import_zod20.z.object({
2511
- type: import_zod20.z.string(),
2512
- conditionals: import_zod20.z.array(Conditional).optional()
2513
- })
2627
+ "Flag must be in the format ActionType:ActionStatus (lowerCase)"
2628
+ ).or(import_zod20.z.nativeEnum(CustomFlags));
2629
+ var ZodDate = import_zod20.z.string().date();
2630
+ var ActionCreationMetadata = import_zod20.z.object({
2631
+ createdAt: import_zod20.z.string().datetime().describe("The timestamp when the action request was created."),
2632
+ createdBy: import_zod20.z.string().describe("ID of the user who created the action request."),
2633
+ createdAtLocation: CreatedAtLocation.describe(
2634
+ "Location of the user who created the action request."
2514
2635
  ),
2515
- columns: import_zod20.z.array(
2516
- import_zod20.z.object({ label: TranslationConfig, value: EventMetadataParameter })
2517
- ).default([
2518
- {
2519
- label: {
2520
- id: "workqueues.dateOfEvent",
2521
- defaultMessage: "Date of Event",
2522
- description: "Label for workqueue column: dateOfEvent"
2523
- },
2524
- value: event.field("dateOfEvent")
2525
- }
2526
- ])
2527
- }).describe("Configuration for workqueue.");
2528
- function defineWorkqueue(workqueues) {
2529
- return workqueues.map((workqueue) => WorkqueueConfig.parse(workqueue));
2530
- }
2531
-
2532
- // ../commons/src/events/Draft.ts
2533
- var import_zod22 = require("zod");
2534
-
2535
- // ../commons/src/events/ActionInput.ts
2536
- var import_zod21 = require("zod");
2537
- var import_zod_openapi5 = require("zod-openapi");
2538
- (0, import_zod_openapi5.extendZodWithOpenApi)(import_zod21.z);
2539
- var BaseActionInput = import_zod21.z.object({
2540
- eventId: import_zod21.z.string(),
2541
- transactionId: import_zod21.z.string(),
2542
- declaration: ActionUpdate.default({}),
2543
- annotation: ActionUpdate.optional(),
2544
- originalActionId: import_zod21.z.string().optional(),
2545
- keepAssignment: import_zod21.z.boolean().optional()
2636
+ acceptedAt: import_zod20.z.string().datetime().describe("Timestamp when the action request was accepted."),
2637
+ createdByRole: import_zod20.z.string().describe("Role of the user at the time of action request creation."),
2638
+ createdBySignature: import_zod20.z.string().nullish().describe("Signature of the user who created the action request.")
2546
2639
  });
2547
- var CreateActionInput = BaseActionInput.merge(
2548
- import_zod21.z.object({
2549
- type: import_zod21.z.literal(ActionType.CREATE).default(ActionType.CREATE),
2550
- createdAtLocation: import_zod21.z.string()
2551
- })
2552
- );
2553
- var RegisterActionInput = BaseActionInput.merge(
2554
- import_zod21.z.object({
2555
- type: import_zod21.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
2556
- registrationNumber: import_zod21.z.string().optional()
2557
- })
2558
- );
2559
- var ValidateActionInput = BaseActionInput.merge(
2560
- import_zod21.z.object({
2561
- type: import_zod21.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
2562
- duplicates: import_zod21.z.array(import_zod21.z.string())
2563
- })
2564
- );
2565
- var NotifyActionInput = BaseActionInput.merge(
2566
- import_zod21.z.object({
2567
- type: import_zod21.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
2568
- })
2569
- );
2570
- var DeclareActionInput = BaseActionInput.merge(
2571
- import_zod21.z.object({
2572
- type: import_zod21.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
2573
- })
2574
- );
2575
- var PrintCertificateActionInput = BaseActionInput.merge(
2576
- import_zod21.z.object({
2577
- type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
2578
- })
2579
- );
2580
- var RejectDeclarationActionInput = BaseActionInput.merge(
2581
- import_zod21.z.object({
2582
- type: import_zod21.z.literal(ActionType.REJECT).default(ActionType.REJECT)
2583
- })
2584
- );
2585
- var MarkedAsDuplicateActionInput = BaseActionInput.merge(
2586
- import_zod21.z.object({
2587
- type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
2588
- })
2589
- );
2640
+ var RegistrationCreationMetadata = ActionCreationMetadata.extend({
2641
+ registrationNumber: import_zod20.z.string().describe(
2642
+ "Registration number of the event. Always present for accepted registrations."
2643
+ )
2644
+ });
2645
+ var LegalStatuses = import_zod20.z.object({
2646
+ [EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
2647
+ [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
2648
+ });
2649
+ var EventMetadata = import_zod20.z.object({
2650
+ id: import_zod20.z.string(),
2651
+ type: import_zod20.z.string().describe("The type of event, such as birth, death, or marriage."),
2652
+ status: EventStatus,
2653
+ legalStatuses: LegalStatuses.describe(
2654
+ "Metadata related to the legal registration of the event, such as who registered it and when."
2655
+ ),
2656
+ createdAt: import_zod20.z.string().datetime().describe("The timestamp when the event was first created and saved."),
2657
+ dateOfEvent: ZodDate.nullish(),
2658
+ createdBy: import_zod20.z.string().describe("ID of the user who created the event."),
2659
+ updatedByUserRole: import_zod20.z.string().describe("Role of the user who last updated the declaration."),
2660
+ createdAtLocation: CreatedAtLocation.describe(
2661
+ "Location of the user who created the event."
2662
+ ),
2663
+ createdBySignature: import_zod20.z.string().nullish().describe("Signature of the user who created the event."),
2664
+ updatedAtLocation: import_zod20.z.string().nullish().describe("Location of the user who last updated the declaration."),
2665
+ updatedAt: import_zod20.z.string().datetime().describe("Timestamp of the most recent declaration update."),
2666
+ assignedTo: import_zod20.z.string().nullish().describe("ID of the user currently assigned to the event."),
2667
+ updatedBy: import_zod20.z.string().nullish().describe("ID of the user who last updated the declaration."),
2668
+ trackingId: import_zod20.z.string().describe(
2669
+ "System-generated tracking ID used by informants or registrars to look up the event."
2670
+ ),
2671
+ flags: import_zod20.z.array(Flag)
2672
+ });
2673
+ var EventMetadataKeysArray = [
2674
+ "id",
2675
+ "type",
2676
+ "status",
2677
+ "createdAt",
2678
+ "dateOfEvent",
2679
+ "createdBy",
2680
+ "updatedByUserRole",
2681
+ "createdAtLocation",
2682
+ "updatedAtLocation",
2683
+ "updatedAt",
2684
+ "assignedTo",
2685
+ "updatedBy",
2686
+ "trackingId",
2687
+ "legalStatuses",
2688
+ "flags"
2689
+ ];
2690
+ var EventMetadataKeys = import_zod20.z.enum(EventMetadataKeysArray);
2691
+ var eventMetadataLabelMap = {
2692
+ "event.assignedTo": {
2693
+ id: "event.assignedTo.label",
2694
+ defaultMessage: "Assigned To",
2695
+ description: "Assigned To"
2696
+ },
2697
+ "event.createdAt": {
2698
+ id: "event.createdAt.label",
2699
+ defaultMessage: "Created",
2700
+ description: "Created At"
2701
+ },
2702
+ "event.dateOfEvent": {
2703
+ id: "event.dateOfEvent.label",
2704
+ defaultMessage: "Date of Event",
2705
+ description: "Date of Event"
2706
+ },
2707
+ "event.createdAtLocation": {
2708
+ id: "event.createdAtLocation.label",
2709
+ defaultMessage: "Location",
2710
+ description: "Created At Location"
2711
+ },
2712
+ "event.updatedAtLocation": {
2713
+ id: "event.updatedAtLocation.label",
2714
+ defaultMessage: "Location",
2715
+ description: "Updated At Location"
2716
+ },
2717
+ "event.createdBy": {
2718
+ id: "event.createdBy.label",
2719
+ defaultMessage: "Created By",
2720
+ description: "Created By"
2721
+ },
2722
+ "event.updatedByUserRole": {
2723
+ id: "event.updatedByUserRole.label",
2724
+ defaultMessage: "Updated By Role",
2725
+ description: "Updated By Role"
2726
+ },
2727
+ "event.id": {
2728
+ id: "event.id.label",
2729
+ defaultMessage: "ID",
2730
+ description: "ID"
2731
+ },
2732
+ "event.updatedAt": {
2733
+ id: "event.modifiedAt.label",
2734
+ defaultMessage: "Updated",
2735
+ description: "Modified At"
2736
+ },
2737
+ "event.status": {
2738
+ id: "event.status.label",
2739
+ defaultMessage: "Status",
2740
+ description: "Status"
2741
+ },
2742
+ "event.type": {
2743
+ id: "event.type.label",
2744
+ defaultMessage: "Type",
2745
+ description: "Type"
2746
+ },
2747
+ "event.updatedBy": {
2748
+ id: "event.updatedBy.label",
2749
+ defaultMessage: "Updated By",
2750
+ description: "Updated By"
2751
+ },
2752
+ "event.trackingId": {
2753
+ id: "event.trackingId.label",
2754
+ defaultMessage: "Tracking ID",
2755
+ description: "Tracking ID"
2756
+ },
2757
+ "event.flags": {
2758
+ id: "event.flags.label",
2759
+ defaultMessage: "Flags",
2760
+ description: "Flags"
2761
+ }
2762
+ };
2763
+
2764
+ // ../commons/src/events/WorkqueueColumnConfig.ts
2765
+ var WorkqueueColumnKeysArray = [
2766
+ ...EventMetadataKeysArray,
2767
+ "title"
2768
+ ];
2769
+ var WorkqueueColumnKeys = import_zod21.z.enum(WorkqueueColumnKeysArray);
2770
+ var WorkqueueColumnValue = import_zod21.z.object({
2771
+ $event: WorkqueueColumnKeys
2772
+ });
2773
+ var WorkqueueColumn = import_zod21.z.object({
2774
+ label: TranslationConfig,
2775
+ value: WorkqueueColumnValue
2776
+ });
2777
+ function defineWorkqueuesColumns(workqueueColumns) {
2778
+ return workqueueColumns.map(
2779
+ (workqueueColumn) => WorkqueueColumn.parse(workqueueColumn)
2780
+ );
2781
+ }
2782
+
2783
+ // ../commons/src/events/CountryConfigQueryInput.ts
2784
+ var import_zod23 = require("zod");
2785
+
2786
+ // ../commons/src/events/EventIndex.ts
2787
+ var import_zod22 = require("zod");
2788
+ var import_zod_openapi9 = require("zod-openapi");
2789
+ (0, import_zod_openapi9.extendZodWithOpenApi)(import_zod22.z);
2790
+ var EventIndex = EventMetadata.extend({
2791
+ declaration: EventState
2792
+ }).openapi({
2793
+ ref: "EventIndex"
2794
+ });
2795
+ var EventSearchIndex = import_zod22.z.record(import_zod22.z.string(), import_zod22.z.any()).and(
2796
+ import_zod22.z.object({
2797
+ type: import_zod22.z.string()
2798
+ // Ensures "type" (event-id) exists and is a string
2799
+ })
2800
+ ).openapi({
2801
+ ref: "EventSearchIndex"
2802
+ });
2803
+ var Fuzzy = import_zod22.z.object({ type: import_zod22.z.literal("fuzzy"), term: import_zod22.z.string() }).openapi({
2804
+ ref: "Fuzzy"
2805
+ });
2806
+ var Exact = import_zod22.z.object({ type: import_zod22.z.literal("exact"), term: import_zod22.z.string() }).openapi({
2807
+ ref: "Exact"
2808
+ });
2809
+ var AnyOf = import_zod22.z.object({
2810
+ type: import_zod22.z.literal("anyOf"),
2811
+ terms: import_zod22.z.array(import_zod22.z.string())
2812
+ }).openapi({
2813
+ ref: "AnyOf"
2814
+ });
2815
+ var ExactStatus = import_zod22.z.object({
2816
+ type: import_zod22.z.literal("exact"),
2817
+ term: EventStatus
2818
+ }).openapi({
2819
+ ref: "ExactStatus"
2820
+ });
2821
+ var AnyOfStatus = import_zod22.z.object({
2822
+ type: import_zod22.z.literal("anyOf"),
2823
+ terms: import_zod22.z.array(EventStatus)
2824
+ }).openapi({
2825
+ ref: "AnyOfStatus"
2826
+ });
2827
+ var Range = import_zod22.z.object({
2828
+ type: import_zod22.z.literal("range"),
2829
+ gte: import_zod22.z.string(),
2830
+ lte: import_zod22.z.string()
2831
+ }).openapi({
2832
+ ref: "Range"
2833
+ });
2834
+ var Not = import_zod22.z.object({ type: import_zod22.z.literal("not"), term: import_zod22.z.string() }).openapi({
2835
+ ref: "Not"
2836
+ });
2837
+ var Within = import_zod22.z.object({ type: import_zod22.z.literal("within"), location: import_zod22.z.string() }).openapi({
2838
+ ref: "Within"
2839
+ });
2840
+ var DateCondition = import_zod22.z.union([Exact, Range]).openapi({
2841
+ ref: "DateCondition"
2842
+ });
2843
+ var QueryInput = import_zod22.z.lazy(
2844
+ () => import_zod22.z.union([
2845
+ import_zod22.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf, Not]),
2846
+ import_zod22.z.record(import_zod22.z.string(), QueryInput)
2847
+ ])
2848
+ ).openapi({
2849
+ ref: "QueryInput"
2850
+ });
2851
+ var QueryExpression = import_zod22.z.object({
2852
+ eventType: import_zod22.z.string(),
2853
+ status: import_zod22.z.optional(import_zod22.z.union([AnyOfStatus, ExactStatus])),
2854
+ createdAt: import_zod22.z.optional(DateCondition),
2855
+ updatedAt: import_zod22.z.optional(DateCondition),
2856
+ "legalStatus.REGISTERED.createdAt": import_zod22.z.optional(DateCondition),
2857
+ "legalStatus.REGISTERED.createdAtLocation": import_zod22.z.optional(
2858
+ import_zod22.z.union([Within, Exact])
2859
+ ),
2860
+ "legalStatus.REGISTERED.registrationNumber": import_zod22.z.optional(Exact),
2861
+ createdAtLocation: import_zod22.z.optional(import_zod22.z.union([Within, Exact])),
2862
+ updatedAtLocation: import_zod22.z.optional(import_zod22.z.union([Within, Exact])),
2863
+ assignedTo: import_zod22.z.optional(Exact),
2864
+ createdBy: import_zod22.z.optional(Exact),
2865
+ updatedBy: import_zod22.z.optional(Exact),
2866
+ trackingId: import_zod22.z.optional(Exact),
2867
+ flags: import_zod22.z.optional(import_zod22.z.array(import_zod22.z.union([AnyOf, Not]))),
2868
+ data: QueryInput
2869
+ }).partial().openapi({
2870
+ ref: "QueryExpression"
2871
+ });
2872
+ var QueryType = import_zod22.z.object({
2873
+ type: import_zod22.z.literal("and").or(import_zod22.z.literal("or")).openapi({ default: "and" }),
2874
+ clauses: import_zod22.z.preprocess(
2875
+ (val) => {
2876
+ if (typeof val === "string") {
2877
+ return [JSON.parse(val)];
2878
+ }
2879
+ if (Array.isArray(val)) {
2880
+ return val.map((v) => typeof v === "string" ? JSON.parse(v) : v);
2881
+ }
2882
+ return val;
2883
+ },
2884
+ import_zod22.z.array(QueryExpression).nonempty("At least one clause is required.").openapi({
2885
+ default: [
2886
+ {
2887
+ eventType: TENNIS_CLUB_MEMBERSHIP,
2888
+ status: {
2889
+ type: "anyOf",
2890
+ terms: EventStatus.options
2891
+ },
2892
+ updatedAt: {
2893
+ type: "range",
2894
+ gte: "2025-05-22",
2895
+ lte: "2025-05-29"
2896
+ },
2897
+ data: {}
2898
+ }
2899
+ ]
2900
+ })
2901
+ )
2902
+ }).openapi({
2903
+ ref: "QueryType"
2904
+ });
2905
+
2906
+ // ../commons/src/events/CountryConfigQueryInput.ts
2907
+ var SerializableExact = import_zod23.z.object({
2908
+ type: import_zod23.z.literal("exact"),
2909
+ term: import_zod23.z.union([import_zod23.z.string(), SerializedUserField])
2910
+ });
2911
+ var SerializableWithin = import_zod23.z.object({
2912
+ type: import_zod23.z.literal("within"),
2913
+ location: import_zod23.z.union([import_zod23.z.string(), SerializedUserField])
2914
+ });
2915
+ var SerializedQueryExpression = import_zod23.z.object({
2916
+ eventType: import_zod23.z.string(),
2917
+ status: import_zod23.z.optional(import_zod23.z.union([AnyOfStatus, ExactStatus])),
2918
+ createdAt: import_zod23.z.optional(DateCondition),
2919
+ updatedAt: import_zod23.z.optional(DateCondition),
2920
+ createdAtLocation: import_zod23.z.optional(
2921
+ import_zod23.z.union([SerializableWithin, SerializableExact])
2922
+ ),
2923
+ updatedAtLocation: import_zod23.z.optional(
2924
+ import_zod23.z.union([SerializableWithin, SerializableExact])
2925
+ ),
2926
+ assignedTo: import_zod23.z.optional(SerializableExact),
2927
+ createdBy: import_zod23.z.optional(SerializableExact),
2928
+ updatedBy: import_zod23.z.optional(SerializableExact),
2929
+ trackingId: import_zod23.z.optional(Exact),
2930
+ flags: import_zod23.z.optional(import_zod23.z.array(import_zod23.z.union([AnyOf, Not]))),
2931
+ data: QueryInput
2932
+ }).partial();
2933
+ var Or2 = import_zod23.z.object({
2934
+ type: import_zod23.z.literal("or"),
2935
+ clauses: import_zod23.z.array(SerializedQueryExpression)
2936
+ });
2937
+ var And2 = import_zod23.z.object({
2938
+ type: import_zod23.z.literal("and"),
2939
+ clauses: import_zod23.z.array(SerializedQueryExpression)
2940
+ });
2941
+ var CountryConfigQueryType = import_zod23.z.discriminatedUnion("type", [And2, Or2]);
2942
+ var CountryConfigQueryInputType = import_zod23.z.union([
2943
+ SerializedQueryExpression,
2944
+ And2,
2945
+ Or2
2946
+ ]);
2947
+
2948
+ // ../commons/src/icons.ts
2949
+ var import_zod24 = require("zod");
2950
+ var AvailableIcons = import_zod24.z.enum([
2951
+ "Archived",
2952
+ "Assigned",
2953
+ "Certified",
2954
+ "Close",
2955
+ "Collapse",
2956
+ "Draft",
2957
+ "DuplicateYellow",
2958
+ "Expand",
2959
+ "ExternalValidate",
2960
+ "FilledCheck",
2961
+ "InReview",
2962
+ "Offline",
2963
+ "Registered",
2964
+ "RequiresUpdates",
2965
+ "Sent",
2966
+ "Validated",
2967
+ "WaitingApproval",
2968
+ "ChartActivity",
2969
+ "Activity",
2970
+ "Archive",
2971
+ "ArchiveTray",
2972
+ "ArrowLeft",
2973
+ "ArrowRight",
2974
+ "Buildings",
2975
+ "Circle",
2976
+ "CaretDown",
2977
+ "CaretLeft",
2978
+ "CaretRight",
2979
+ "ChartBar",
2980
+ "ChartLine",
2981
+ "ChatCircle",
2982
+ "CheckSquare",
2983
+ "Compass",
2984
+ "Check",
2985
+ "Copy",
2986
+ "Database",
2987
+ "DotsThreeVertical",
2988
+ "DownloadSimple",
2989
+ "ArrowCounterClockwise",
2990
+ "MagnifyingGlassMinus",
2991
+ "MagnifyingGlassPlus",
2992
+ "Export",
2993
+ "Eye",
2994
+ "EyeSlash",
2995
+ "Envelope",
2996
+ "File",
2997
+ "FileSearch",
2998
+ "FileMinus",
2999
+ "FilePlus",
3000
+ "FileText",
3001
+ "FileX",
3002
+ "Handshake",
3003
+ "Gear",
3004
+ "GitBranch",
3005
+ "IdentificationCard",
3006
+ "List",
3007
+ "ListBullets",
3008
+ "Lock",
3009
+ "MagnifyingGlass",
3010
+ "MapPin",
3011
+ "Medal",
3012
+ "NotePencil",
3013
+ "Paperclip",
3014
+ "PaperPlaneTilt",
3015
+ "Pen",
3016
+ "Pencil",
3017
+ "PencilSimpleLine",
3018
+ "Phone",
3019
+ "Plus",
3020
+ "Printer",
3021
+ "SignOut",
3022
+ "Star",
3023
+ "Target",
3024
+ "TextT",
3025
+ "Trash",
3026
+ "UploadSimple",
3027
+ "User",
3028
+ "UserPlus",
3029
+ "Users",
3030
+ "WarningCircle",
3031
+ "X",
3032
+ "CircleWavyCheck",
3033
+ "CircleWavyQuestion",
3034
+ "ArchiveBox",
3035
+ "ArrowCircleDown",
3036
+ "FileArrowUp",
3037
+ "FileDotted",
3038
+ "Files",
3039
+ "PencilLine",
3040
+ "PencilCircle",
3041
+ "UserCircle",
3042
+ "Clock",
3043
+ "QrCode",
3044
+ "Webcam",
3045
+ "Sun",
3046
+ "DeviceTabletCamera",
3047
+ "Globe",
3048
+ "Fingerprint",
3049
+ "PushPin",
3050
+ "Timer"
3051
+ ]);
3052
+
3053
+ // ../commons/src/events/WorkqueueConfig.ts
3054
+ var mandatoryColumns = defineWorkqueuesColumns([
3055
+ {
3056
+ label: {
3057
+ id: "workqueues.dateOfEvent",
3058
+ defaultMessage: "Date of Event",
3059
+ description: "Label for workqueue column: dateOfEvent"
3060
+ },
3061
+ value: event.field("dateOfEvent")
3062
+ },
3063
+ {
3064
+ label: {
3065
+ defaultMessage: "Last updated",
3066
+ description: "This is the label for the workqueue column",
3067
+ id: "workqueue.default.column.modifiedAt"
3068
+ },
3069
+ value: event.field("updatedAt")
3070
+ }
3071
+ ]);
3072
+ var WorkqueueActionsWithDefault = import_zod25.z.enum([
3073
+ ...workqueueActions.options,
3074
+ "DEFAULT"
3075
+ ]);
3076
+ var WorkqueueConfig = import_zod25.z.object({
3077
+ slug: import_zod25.z.string().describe("Determines the url of the workqueue."),
3078
+ name: TranslationConfig.describe(
3079
+ "Title of the workflow (both in navigation and on the page)"
3080
+ ),
3081
+ query: CountryConfigQueryType,
3082
+ actions: import_zod25.z.array(
3083
+ import_zod25.z.object({
3084
+ type: WorkqueueActionsWithDefault,
3085
+ conditionals: import_zod25.z.array(Conditional).optional()
3086
+ })
3087
+ ),
3088
+ columns: import_zod25.z.array(WorkqueueColumn).default(mandatoryColumns),
3089
+ icon: AvailableIcons
3090
+ }).describe("Configuration for workqueue.");
3091
+ var WorkqueueConfigInput = import_zod25.z.object({
3092
+ slug: import_zod25.z.string().describe("Determines the url of the workqueue."),
3093
+ name: TranslationConfig.describe(
3094
+ "Title of the workflow (both in navigation and on the page)"
3095
+ ),
3096
+ query: CountryConfigQueryInputType,
3097
+ actions: import_zod25.z.array(
3098
+ import_zod25.z.object({
3099
+ type: WorkqueueActionsWithDefault,
3100
+ conditionals: import_zod25.z.array(Conditional).optional()
3101
+ })
3102
+ ),
3103
+ columns: import_zod25.z.array(WorkqueueColumn).default(mandatoryColumns),
3104
+ icon: AvailableIcons
3105
+ });
3106
+ function defineWorkqueue(workqueueInput) {
3107
+ const queryInput = workqueueInput.query;
3108
+ const query = "type" in queryInput ? queryInput : { type: "and", clauses: [queryInput] };
3109
+ return WorkqueueConfig.parse({ ...workqueueInput, query });
3110
+ }
3111
+ function defineWorkqueues(workqueues) {
3112
+ return workqueues.map((workqueue) => defineWorkqueue(workqueue));
3113
+ }
3114
+ var WorkqueueCountInput = import_zod25.z.array(
3115
+ import_zod25.z.object({ slug: import_zod25.z.string(), query: QueryType })
3116
+ );
3117
+ var WorkqueueCountOutput = import_zod25.z.record(import_zod25.z.string(), import_zod25.z.number());
3118
+
3119
+ // ../commons/src/events/workqueueDefaultColumns.ts
3120
+ var defaultWorkqueueColumns = [
3121
+ {
3122
+ label: {
3123
+ defaultMessage: "Title",
3124
+ description: "This is the label for the workqueue column",
3125
+ id: "workqueue.in-reveiw.column.title"
3126
+ },
3127
+ value: event.field("title")
3128
+ },
3129
+ {
3130
+ label: {
3131
+ defaultMessage: "Event",
3132
+ description: "This is the label for the workqueue column",
3133
+ id: "workqueue.default.column.event"
3134
+ },
3135
+ value: event.field("type")
3136
+ }
3137
+ ];
3138
+
3139
+ // ../commons/src/events/Draft.ts
3140
+ var import_zod27 = require("zod");
3141
+
3142
+ // ../commons/src/events/ActionInput.ts
3143
+ var import_zod26 = require("zod");
3144
+ var import_zod_openapi10 = require("zod-openapi");
3145
+ var import_uuid3 = require("uuid");
3146
+ (0, import_zod_openapi10.extendZodWithOpenApi)(import_zod26.z);
3147
+ var BaseActionInput = import_zod26.z.object({
3148
+ eventId: import_zod26.z.string(),
3149
+ transactionId: import_zod26.z.string(),
3150
+ declaration: ActionUpdate.default({}),
3151
+ annotation: ActionUpdate.optional(),
3152
+ originalActionId: import_zod26.z.string().optional(),
3153
+ keepAssignment: import_zod26.z.boolean().optional()
3154
+ });
3155
+ var CreateActionInput = BaseActionInput.merge(
3156
+ import_zod26.z.object({
3157
+ type: import_zod26.z.literal(ActionType.CREATE).default(ActionType.CREATE),
3158
+ createdAtLocation: CreatedAtLocation
3159
+ })
3160
+ );
3161
+ var RegisterActionInput = BaseActionInput.merge(
3162
+ import_zod26.z.object({
3163
+ type: import_zod26.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
3164
+ registrationNumber: import_zod26.z.string().optional()
3165
+ })
3166
+ );
3167
+ var ValidateActionInput = BaseActionInput.merge(
3168
+ import_zod26.z.object({
3169
+ type: import_zod26.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
3170
+ duplicates: import_zod26.z.array(import_zod26.z.string())
3171
+ })
3172
+ );
3173
+ var NotifyActionInput = BaseActionInput.merge(
3174
+ import_zod26.z.object({
3175
+ type: import_zod26.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
3176
+ })
3177
+ ).openapi({
3178
+ default: {
3179
+ eventId: "<event-id-here>",
3180
+ transactionId: (0, import_uuid3.v4)(),
3181
+ declaration: {},
3182
+ annotation: {},
3183
+ type: ActionType.NOTIFY
3184
+ }
3185
+ });
3186
+ var DeclareActionInput = BaseActionInput.merge(
3187
+ import_zod26.z.object({
3188
+ type: import_zod26.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
3189
+ })
3190
+ );
3191
+ var PrintCertificateActionInput = BaseActionInput.merge(
3192
+ import_zod26.z.object({
3193
+ type: import_zod26.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
3194
+ })
3195
+ );
3196
+ var RejectDeclarationActionInput = BaseActionInput.merge(
3197
+ import_zod26.z.object({
3198
+ type: import_zod26.z.literal(ActionType.REJECT).default(ActionType.REJECT),
3199
+ reason: RejectionReason
3200
+ })
3201
+ );
3202
+ var MarkedAsDuplicateActionInput = BaseActionInput.merge(
3203
+ import_zod26.z.object({
3204
+ type: import_zod26.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
3205
+ })
3206
+ );
2590
3207
  var ArchiveActionInput = BaseActionInput.merge(
2591
- import_zod21.z.object({
2592
- type: import_zod21.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
3208
+ import_zod26.z.object({
3209
+ type: import_zod26.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
3210
+ reason: RejectionReason
2593
3211
  })
2594
3212
  );
2595
3213
  var AssignActionInput = BaseActionInput.merge(
2596
- import_zod21.z.object({
2597
- type: import_zod21.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
2598
- assignedTo: import_zod21.z.string()
3214
+ import_zod26.z.object({
3215
+ type: import_zod26.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
3216
+ assignedTo: import_zod26.z.string()
2599
3217
  })
2600
3218
  );
2601
3219
  var UnassignActionInput = BaseActionInput.merge(
2602
- import_zod21.z.object({
2603
- type: import_zod21.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
2604
- assignedTo: import_zod21.z.literal(null).default(null)
3220
+ import_zod26.z.object({
3221
+ type: import_zod26.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
3222
+ assignedTo: import_zod26.z.literal(null).default(null)
2605
3223
  })
2606
3224
  );
2607
3225
  var RequestCorrectionActionInput = BaseActionInput.merge(
2608
- import_zod21.z.object({
2609
- type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
3226
+ import_zod26.z.object({
3227
+ type: import_zod26.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
2610
3228
  })
2611
3229
  );
2612
3230
  var RejectCorrectionActionInput = BaseActionInput.merge(
2613
- import_zod21.z.object({
2614
- requestId: import_zod21.z.string(),
2615
- type: import_zod21.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
3231
+ import_zod26.z.object({
3232
+ requestId: import_zod26.z.string(),
3233
+ type: import_zod26.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
2616
3234
  })
2617
3235
  );
2618
3236
  var ApproveCorrectionActionInput = BaseActionInput.merge(
2619
- import_zod21.z.object({
2620
- requestId: import_zod21.z.string(),
2621
- type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
3237
+ import_zod26.z.object({
3238
+ requestId: import_zod26.z.string(),
3239
+ type: import_zod26.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
2622
3240
  })
2623
3241
  );
2624
3242
  var ReadActionInput = BaseActionInput.merge(
2625
- import_zod21.z.object({
2626
- type: import_zod21.z.literal(ActionType.READ).default(ActionType.READ)
3243
+ import_zod26.z.object({
3244
+ type: import_zod26.z.literal(ActionType.READ).default(ActionType.READ)
2627
3245
  })
2628
3246
  );
2629
- var DeleteActionInput = import_zod21.z.object({ eventId: import_zod21.z.string() });
2630
- var ActionInput = import_zod21.z.discriminatedUnion("type", [
3247
+ var DeleteActionInput = import_zod26.z.object({ eventId: import_zod26.z.string() });
3248
+ var ActionInput = import_zod26.z.discriminatedUnion("type", [
2631
3249
  CreateActionInput.openapi({ ref: "CreateActionInput" }),
2632
3250
  ValidateActionInput.openapi({ ref: "ValidateActionInput" }),
2633
3251
  RegisterActionInput.openapi({ ref: "RegisterActionInput" }),
@@ -2656,18 +3274,18 @@ var ActionInput = import_zod21.z.discriminatedUnion("type", [
2656
3274
  });
2657
3275
 
2658
3276
  // ../commons/src/events/Draft.ts
2659
- var Draft = import_zod22.z.object({
2660
- id: import_zod22.z.string(),
2661
- eventId: import_zod22.z.string(),
2662
- transactionId: import_zod22.z.string(),
2663
- createdAt: import_zod22.z.string().datetime(),
3277
+ var Draft = import_zod27.z.object({
3278
+ id: import_zod27.z.string(),
3279
+ eventId: import_zod27.z.string(),
3280
+ transactionId: import_zod27.z.string(),
3281
+ createdAt: import_zod27.z.string().datetime(),
2664
3282
  action: ActionBase.extend({
2665
3283
  type: ActionTypes
2666
3284
  }).omit({ id: true })
2667
3285
  });
2668
3286
  var DraftInput = BaseActionInput.extend({
2669
3287
  type: ActionTypes,
2670
- status: import_zod22.z.enum([
3288
+ status: import_zod27.z.enum([
2671
3289
  ActionStatus.Requested,
2672
3290
  ActionStatus.Accepted,
2673
3291
  ActionStatus.Rejected
@@ -2675,25 +3293,24 @@ var DraftInput = BaseActionInput.extend({
2675
3293
  });
2676
3294
 
2677
3295
  // ../commons/src/events/EventInput.ts
2678
- var import_zod23 = require("zod");
2679
- var EventInput = import_zod23.z.object({
2680
- transactionId: import_zod23.z.string(),
2681
- type: import_zod23.z.string(),
2682
- dateOfEvent: import_zod23.z.object({ fieldId: import_zod23.z.string() }).optional()
2683
- });
3296
+ var import_zod28 = require("zod");
3297
+ var import_uuid4 = require("uuid");
3298
+ var EventInput = import_zod28.z.object({
3299
+ transactionId: import_zod28.z.string(),
3300
+ type: import_zod28.z.string()
3301
+ }).openapi({ default: { transactionId: (0, import_uuid4.v4)(), type: "v2.birth" } });
2684
3302
 
2685
3303
  // ../commons/src/events/EventDocument.ts
2686
- var import_zod24 = require("zod");
2687
- var import_zod_openapi6 = require("zod-openapi");
2688
- (0, import_zod_openapi6.extendZodWithOpenApi)(import_zod24.z);
2689
- var EventDocument = import_zod24.z.object({
2690
- id: import_zod24.z.string(),
2691
- type: import_zod24.z.string(),
2692
- dateOfEvent: import_zod24.z.object({ fieldId: import_zod24.z.string() }).optional(),
2693
- createdAt: import_zod24.z.string().datetime(),
2694
- updatedAt: import_zod24.z.string().datetime(),
2695
- actions: import_zod24.z.array(Action),
2696
- trackingId: import_zod24.z.string()
3304
+ var import_zod29 = require("zod");
3305
+ var import_zod_openapi11 = require("zod-openapi");
3306
+ (0, import_zod_openapi11.extendZodWithOpenApi)(import_zod29.z);
3307
+ var EventDocument = import_zod29.z.object({
3308
+ id: import_zod29.z.string(),
3309
+ type: import_zod29.z.string(),
3310
+ createdAt: import_zod29.z.string().datetime(),
3311
+ updatedAt: import_zod29.z.string().datetime(),
3312
+ actions: import_zod29.z.array(Action),
3313
+ trackingId: import_zod29.z.string()
2697
3314
  }).openapi({ ref: "EventDocument" });
2698
3315
 
2699
3316
  // ../commons/src/events/state/utils.ts
@@ -2730,6 +3347,7 @@ function getDeclarationActionCreationMetadata(actionType, actions) {
2730
3347
  createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
2731
3348
  acceptedAt: acceptAction.createdAt,
2732
3349
  createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
3350
+ createdBySignature: requestAction?.createdBySignature ?? acceptAction.createdBySignature,
2733
3351
  registrationNumber
2734
3352
  };
2735
3353
  }
@@ -2758,11 +3376,11 @@ function getDeclarationActionUpdateMetadata(actions) {
2758
3376
  }
2759
3377
  function getLegalStatuses(actions) {
2760
3378
  return {
2761
- [EventStatus.DECLARED]: getDeclarationActionCreationMetadata(
3379
+ [EventStatus.enum.DECLARED]: getDeclarationActionCreationMetadata(
2762
3380
  ActionType.DECLARE,
2763
3381
  actions
2764
3382
  ),
2765
- [EventStatus.REGISTERED]: getDeclarationActionCreationMetadata(
3383
+ [EventStatus.enum.REGISTERED]: getDeclarationActionCreationMetadata(
2766
3384
  ActionType.REGISTER,
2767
3385
  actions
2768
3386
  )
@@ -2775,26 +3393,26 @@ function getStatusFromActions(actions) {
2775
3393
  (a) => a.status === ActionStatus.Rejected
2776
3394
  );
2777
3395
  if (hasRejectedAction) {
2778
- return EventStatus.REJECTED;
3396
+ return EventStatus.enum.REJECTED;
2779
3397
  }
2780
3398
  return actions.reduce((status, action) => {
2781
3399
  switch (action.type) {
2782
3400
  case ActionType.CREATE:
2783
- return EventStatus.CREATED;
3401
+ return EventStatus.enum.CREATED;
2784
3402
  case ActionType.DECLARE:
2785
- return EventStatus.DECLARED;
3403
+ return EventStatus.enum.DECLARED;
2786
3404
  case ActionType.VALIDATE:
2787
- return EventStatus.VALIDATED;
3405
+ return EventStatus.enum.VALIDATED;
2788
3406
  case ActionType.REGISTER:
2789
- return EventStatus.REGISTERED;
3407
+ return EventStatus.enum.REGISTERED;
2790
3408
  case ActionType.REJECT:
2791
- return EventStatus.REJECTED;
3409
+ return EventStatus.enum.REJECTED;
2792
3410
  case ActionType.ARCHIVE:
2793
- return EventStatus.ARCHIVED;
3411
+ return EventStatus.enum.ARCHIVED;
2794
3412
  case ActionType.NOTIFY:
2795
- return EventStatus.NOTIFIED;
3413
+ return EventStatus.enum.NOTIFIED;
2796
3414
  case ActionType.PRINT_CERTIFICATE:
2797
- return EventStatus.CERTIFIED;
3415
+ return EventStatus.enum.CERTIFIED;
2798
3416
  case ActionType.ASSIGN:
2799
3417
  case ActionType.UNASSIGN:
2800
3418
  case ActionType.REQUEST_CORRECTION:
@@ -2805,7 +3423,7 @@ function getStatusFromActions(actions) {
2805
3423
  default:
2806
3424
  return status;
2807
3425
  }
2808
- }, EventStatus.CREATED);
3426
+ }, EventStatus.enum.CREATED);
2809
3427
  }
2810
3428
  function getFlagsFromActions(actions) {
2811
3429
  const sortedactions = actions.sort(
@@ -2850,23 +3468,34 @@ function getAssignedUserFromActions(actions) {
2850
3468
  return user2;
2851
3469
  }, null);
2852
3470
  }
3471
+ function getAssignedUserSignatureFromActions(actions) {
3472
+ return actions.reduce((signature, action) => {
3473
+ if (action.type === ActionType.ASSIGN) {
3474
+ return action.createdBySignature || null;
3475
+ }
3476
+ if (action.type === ActionType.UNASSIGN) {
3477
+ return null;
3478
+ }
3479
+ return signature;
3480
+ }, null);
3481
+ }
2853
3482
  function aggregateActionDeclarations(actions) {
2854
3483
  const excludedActions = [
2855
3484
  ActionType.REQUEST_CORRECTION,
2856
3485
  ActionType.PRINT_CERTIFICATE
2857
3486
  ];
2858
- return actions.reduce((status, action) => {
3487
+ return actions.reduce((declaration, action) => {
2859
3488
  if (excludedActions.some((excludedAction) => excludedAction === action.type)) {
2860
- return status;
3489
+ return declaration;
2861
3490
  }
2862
3491
  if (action.type === ActionType.APPROVE_CORRECTION) {
2863
3492
  const requestAction = actions.find(({ id }) => id === action.requestId);
2864
3493
  if (!requestAction) {
2865
- return status;
3494
+ return declaration;
2866
3495
  }
2867
- return deepMerge(status, requestAction.declaration);
3496
+ return deepMerge(declaration, requestAction.declaration);
2868
3497
  }
2869
- return deepMerge(status, action.declaration);
3498
+ return deepMerge(declaration, action.declaration);
2870
3499
  }, {});
2871
3500
  }
2872
3501
  function deepDropNulls(obj) {
@@ -2886,7 +3515,7 @@ function deepDropNulls(obj) {
2886
3515
  return obj;
2887
3516
  }
2888
3517
  function isUndeclaredDraft(status) {
2889
- return status === EventStatus.CREATED;
3518
+ return status === EventStatus.enum.CREATED;
2890
3519
  }
2891
3520
  function getAcceptedActions(event2) {
2892
3521
  return event2.actions.filter(
@@ -2894,7 +3523,7 @@ function getAcceptedActions(event2) {
2894
3523
  );
2895
3524
  }
2896
3525
  var DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
2897
- function getCurrentEventState(event2) {
3526
+ function getCurrentEventState(event2, config) {
2898
3527
  const creationAction = event2.actions.find(
2899
3528
  (action) => action.type === ActionType.CREATE
2900
3529
  );
@@ -2906,9 +3535,17 @@ function getCurrentEventState(event2) {
2906
3535
  event2.actions
2907
3536
  );
2908
3537
  const declaration = aggregateActionDeclarations(acceptedActions);
2909
- const dateOfEvent = ZodDate.safeParse(
2910
- event2.dateOfEvent?.fieldId ? declaration[event2.dateOfEvent.fieldId] : event2[DEFAULT_DATE_OF_EVENT_PROPERTY]
2911
- ).data ?? null;
3538
+ let dateOfEvent;
3539
+ if (config.dateOfEvent) {
3540
+ const parsedDate = ZodDate.safeParse(
3541
+ declaration[config.dateOfEvent.$$field]
3542
+ );
3543
+ if (parsedDate.success) {
3544
+ dateOfEvent = parsedDate.data;
3545
+ }
3546
+ } else {
3547
+ dateOfEvent = event2[DEFAULT_DATE_OF_EVENT_PROPERTY].split("T")[0];
3548
+ }
2912
3549
  return deepDropNulls({
2913
3550
  id: event2.id,
2914
3551
  type: event2.type,
@@ -2917,19 +3554,24 @@ function getCurrentEventState(event2) {
2917
3554
  createdAt: creationAction.createdAt,
2918
3555
  createdBy: creationAction.createdBy,
2919
3556
  createdAtLocation: creationAction.createdAtLocation,
3557
+ createdBySignature: creationAction.createdBySignature,
2920
3558
  updatedAt: declarationUpdateMetadata.createdAt,
2921
3559
  assignedTo: getAssignedUserFromActions(acceptedActions),
3560
+ assignedToSignature: getAssignedUserSignatureFromActions(acceptedActions),
2922
3561
  updatedBy: declarationUpdateMetadata.createdBy,
2923
3562
  updatedAtLocation: declarationUpdateMetadata.createdAtLocation,
2924
3563
  declaration,
2925
3564
  trackingId: event2.trackingId,
2926
- // @TODO: unify this with rest of the code. It will trip us if updatedBy has different rules than updatedByUserRole
2927
3565
  updatedByUserRole: declarationUpdateMetadata.createdByRole,
2928
3566
  dateOfEvent,
2929
3567
  flags: getFlagsFromActions(event2.actions)
2930
3568
  });
2931
3569
  }
2932
- function getCurrentEventStateWithDrafts(event2, drafts) {
3570
+ function getCurrentEventStateWithDrafts({
3571
+ event: event2,
3572
+ drafts,
3573
+ configuration
3574
+ }) {
2933
3575
  const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
2934
3576
  const activeDrafts = findActiveDrafts(event2, drafts).map((draft) => draft.action).flatMap((action) => {
2935
3577
  if (action.type === ActionType.REQUEST_CORRECTION) {
@@ -2948,7 +3590,7 @@ function getCurrentEventStateWithDrafts(event2, drafts) {
2948
3590
  ...event2,
2949
3591
  actions: actionWithDrafts
2950
3592
  };
2951
- return getCurrentEventState(withDrafts);
3593
+ return getCurrentEventState(withDrafts, configuration);
2952
3594
  }
2953
3595
  function applyDraftsToEventIndex(eventIndex, drafts) {
2954
3596
  const indexedAt = eventIndex.updatedAt;
@@ -3002,73 +3644,45 @@ function generateTransactionId() {
3002
3644
  return getUUID();
3003
3645
  }
3004
3646
 
3647
+ // ../commons/src/events/User.ts
3648
+ var import_zod30 = require("zod");
3649
+ var User = import_zod30.z.object({
3650
+ id: import_zod30.z.string(),
3651
+ name: import_zod30.z.array(
3652
+ import_zod30.z.object({
3653
+ use: import_zod30.z.string(),
3654
+ given: import_zod30.z.array(import_zod30.z.string()),
3655
+ family: import_zod30.z.string()
3656
+ })
3657
+ ),
3658
+ role: import_zod30.z.string(),
3659
+ signatureFilename: import_zod30.z.string().optional()
3660
+ });
3661
+
3005
3662
  // ../commons/src/events/test.utils.ts
3006
3663
  var import_lodash2 = require("lodash");
3664
+ var import_addDays = __toESM(require("date-fns/addDays"));
3007
3665
 
3008
3666
  // ../commons/src/field-config/field-configuration.ts
3009
- function createFieldConfigs(fieldId) {
3667
+ function createFieldConfig(fieldId, options) {
3010
3668
  const baseField = {
3011
3669
  fieldId,
3012
- fieldType: "field"
3670
+ fieldType: "field",
3671
+ ...options
3013
3672
  };
3673
+ return createSearchConfig(baseField);
3674
+ }
3675
+
3676
+ // ../commons/src/events/field.ts
3677
+ function field(fieldId, options = {}) {
3014
3678
  return {
3015
- /**
3016
- * Creates a range configuration for the specified field.
3017
- *
3018
- * @returns An object containing the field ID and a configuration object with a type of 'range'.
3019
- *
3020
- * @example field('age').range()
3021
- * // {
3022
- * // fieldId: 'age',
3023
- * // config: { type: 'range' }
3024
- * // }
3025
- */
3026
- range: () => ({
3027
- ...baseField,
3028
- config: { type: "range" }
3029
- }),
3030
- /**
3031
- * Creates a configuration for exact matching of the specified field.
3032
- * @returns An object containing the field ID and a configuration object with a type of 'exact'.
3033
- * @example field('dob').exact()
3034
- * // {
3035
- * // fieldId: 'dob',
3036
- * // config: { type: 'exact' }
3037
- * // }
3038
- */
3039
- exact: () => ({
3040
- ...baseField,
3041
- config: { type: "exact" }
3042
- }),
3043
- /**
3044
- * Creates a configuration for fuzzy matching of the specified field.
3045
- * @returns An object containing the field ID and a configuration object with a type of 'exact'.
3046
- * @example field('name').fuzzy()
3047
- * // {
3048
- * // fieldId: 'name',
3049
- * // config: { type: 'fuzzy' }
3050
- * // }
3051
- */
3052
- fuzzy: () => ({
3053
- ...baseField,
3054
- config: { type: "fuzzy" }
3055
- })
3056
- };
3057
- }
3058
-
3059
- // ../commons/src/events/field.ts
3060
- function field(fieldId) {
3061
- return {
3062
- /**
3063
- * @private Internal property used for field reference tracking.
3064
- */
3065
- _fieldId: fieldId,
3066
3679
  ...createFieldConditionals(fieldId),
3067
- ...createFieldConfigs(fieldId)
3680
+ ...createFieldConfig(fieldId, options)
3068
3681
  };
3069
3682
  }
3070
3683
 
3071
- // ../commons/src/fixtures/tennis-club-membership-event.ts
3684
+ // ../commons/src/fixtures/forms.ts
3685
+ var import_date_fns2 = require("date-fns");
3072
3686
  var PRINT_CERTIFICATE_FORM = defineActionForm({
3073
3687
  label: {
3074
3688
  id: "v2.event.tennis-club-membership.action.certificate.form.label",
@@ -3727,7 +4341,7 @@ var PRINT_CERTIFICATE_FORM = defineActionForm({
3727
4341
  var TENNIS_CLUB_DECLARATION_REVIEW = {
3728
4342
  title: {
3729
4343
  id: "v2.event.tennis-club-membership.action.declare.form.review.title",
3730
- defaultMessage: "{applicant.firstname, select, __EMPTY__ {Member declaration} other {{applicant.surname, select, __EMPTY__ {Member declaration} other {Member declaration for {applicant.firstname} {applicant.surname}}}}}",
4344
+ 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}}}}}",
3731
4345
  description: "Title of the review page"
3732
4346
  },
3733
4347
  fields: [
@@ -3772,27 +4386,17 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
3772
4386
  },
3773
4387
  fields: [
3774
4388
  {
3775
- id: "applicant.firstname",
3776
- type: FieldType.TEXT,
4389
+ id: "applicant.name",
4390
+ type: FieldType.NAME,
3777
4391
  required: true,
4392
+ hideLabel: true,
3778
4393
  conditionals: [],
3779
4394
  label: {
3780
- defaultMessage: "Applicant's first name",
4395
+ defaultMessage: "Applicant's name",
3781
4396
  description: "This is the label for the field",
3782
4397
  id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.firstname.label"
3783
4398
  }
3784
4399
  },
3785
- {
3786
- id: "applicant.surname",
3787
- type: FieldType.TEXT,
3788
- required: true,
3789
- conditionals: [],
3790
- label: {
3791
- defaultMessage: "Applicant's surname",
3792
- description: "This is the label for the field",
3793
- id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.surname.label"
3794
- }
3795
- },
3796
4400
  {
3797
4401
  id: "applicant.email",
3798
4402
  type: "EMAIL",
@@ -3886,135 +4490,622 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
3886
4490
  ]
3887
4491
  },
3888
4492
  {
3889
- id: "senior-pass",
3890
- conditional: field("applicant.dob").isBefore().date("1950-01-01"),
4493
+ id: "senior-pass",
4494
+ conditional: field("applicant.dob").isBefore().date("1950-01-01"),
4495
+ title: {
4496
+ id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.title",
4497
+ defaultMessage: "Assign senior pass for applicant",
4498
+ description: "This is the title of the section"
4499
+ },
4500
+ fields: [
4501
+ {
4502
+ id: "senior-pass.id",
4503
+ type: FieldType.TEXT,
4504
+ required: true,
4505
+ label: {
4506
+ defaultMessage: "Senior pass ID",
4507
+ description: "This is the label for the field",
4508
+ id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.field.id.label"
4509
+ }
4510
+ }
4511
+ ]
4512
+ },
4513
+ {
4514
+ id: "recommender",
4515
+ title: {
4516
+ id: "v2.event.tennis-club-membership.action.declare.form.section.recommender.title",
4517
+ defaultMessage: "Who is recommending the applicant?",
4518
+ description: "This is the title of the section"
4519
+ },
4520
+ fields: [
4521
+ {
4522
+ id: "recommender.none",
4523
+ type: "CHECKBOX",
4524
+ required: false,
4525
+ conditionals: [],
4526
+ label: {
4527
+ defaultMessage: "No recommender",
4528
+ description: "This is the label for the field",
4529
+ id: "v2.event.tennis-club-membership.action.declare.form.section.recommender.field.none.label"
4530
+ }
4531
+ },
4532
+ {
4533
+ id: "recommender.name",
4534
+ type: FieldType.NAME,
4535
+ hideLabel: true,
4536
+ required: true,
4537
+ conditionals: [
4538
+ {
4539
+ type: ConditionalType.SHOW,
4540
+ conditional: field("recommender.none").isFalsy()
4541
+ }
4542
+ ],
4543
+ label: {
4544
+ defaultMessage: "Recommender's name",
4545
+ description: "This is the label for the field",
4546
+ id: "v2.event.tennis-club-membership.action.declare.form.section.recommender.field.firstname.label"
4547
+ }
4548
+ },
4549
+ {
4550
+ id: "recommender.id",
4551
+ type: FieldType.TEXT,
4552
+ required: true,
4553
+ conditionals: [
4554
+ {
4555
+ type: ConditionalType.SHOW,
4556
+ conditional: field("recommender.none").isFalsy()
4557
+ }
4558
+ ],
4559
+ label: {
4560
+ defaultMessage: "Recommender's membership ID",
4561
+ description: "This is the label for the field",
4562
+ id: "v2.event.tennis-club-membership.action.declare.form.section.recommender.field.id.label"
4563
+ }
4564
+ }
4565
+ ]
4566
+ }
4567
+ ]
4568
+ });
4569
+ var statusOptions = [
4570
+ {
4571
+ value: "ALL",
4572
+ label: {
4573
+ defaultMessage: "Any status",
4574
+ description: "Option for form field: status of record",
4575
+ id: "v2.advancedSearch.form.recordStatusAny"
4576
+ }
4577
+ },
4578
+ {
4579
+ value: EventStatus.enum.CREATED,
4580
+ label: {
4581
+ defaultMessage: "Draft",
4582
+ description: "Option for form field: status of record",
4583
+ id: "v2.advancedSearch.form.recordStatusCreated"
4584
+ }
4585
+ },
4586
+ {
4587
+ value: EventStatus.enum.NOTIFIED,
4588
+ label: {
4589
+ defaultMessage: "Notified",
4590
+ description: "Option for form field: status of record",
4591
+ id: "v2.advancedSearch.form.recordStatusNotified"
4592
+ }
4593
+ },
4594
+ {
4595
+ value: EventStatus.enum.DECLARED,
4596
+ label: {
4597
+ defaultMessage: "Declared",
4598
+ description: "Option for form field: status of record",
4599
+ id: "v2.advancedSearch.form.recordStatusDeclared"
4600
+ }
4601
+ },
4602
+ {
4603
+ value: EventStatus.enum.VALIDATED,
4604
+ label: {
4605
+ defaultMessage: "Validated",
4606
+ description: "Option for form field: status of record",
4607
+ id: "v2.advancedSearch.form.recordStatusValidated"
4608
+ }
4609
+ },
4610
+ {
4611
+ value: EventStatus.enum.REGISTERED,
4612
+ label: {
4613
+ defaultMessage: "Registered",
4614
+ description: "Option for form field: status of record",
4615
+ id: "v2.advancedSearch.form.recordStatusRegistered"
4616
+ }
4617
+ },
4618
+ {
4619
+ value: EventStatus.enum.CERTIFIED,
4620
+ label: {
4621
+ defaultMessage: "Certified",
4622
+ description: "Option for form field: status of record",
4623
+ id: "v2.advancedSearch.form.recordStatusCertified"
4624
+ }
4625
+ },
4626
+ {
4627
+ value: EventStatus.enum.REJECTED,
4628
+ label: {
4629
+ defaultMessage: "Rejected",
4630
+ description: "Option for form field: status of record",
4631
+ id: "v2.advancedSearch.form.recordStatusRejected"
4632
+ }
4633
+ },
4634
+ {
4635
+ value: EventStatus.enum.ARCHIVED,
4636
+ label: {
4637
+ defaultMessage: "Archived",
4638
+ description: "Option for form field: status of record",
4639
+ id: "v2.advancedSearch.form.recordStatusArchived"
4640
+ }
4641
+ }
4642
+ ];
4643
+ var timePeriodOptions = [
4644
+ {
4645
+ label: {
4646
+ defaultMessage: "Last 7 days",
4647
+ description: "Label for option of time period select: last 7 days",
4648
+ id: "form.section.label.timePeriodLast7Days"
4649
+ },
4650
+ value: `${(0, import_date_fns2.format)((0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 7), "yyyy-MM-dd")},${(0, import_date_fns2.format)(
4651
+ /* @__PURE__ */ new Date(),
4652
+ "yyyy-MM-dd"
4653
+ )}`
4654
+ },
4655
+ {
4656
+ label: {
4657
+ defaultMessage: "Last 30 days",
4658
+ description: "Label for option of time period select: last 30 days",
4659
+ id: "form.section.label.timePeriodLast30Days"
4660
+ },
4661
+ value: `${(0, import_date_fns2.format)((0, import_date_fns2.subMonths)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns2.format)(
4662
+ /* @__PURE__ */ new Date(),
4663
+ "yyyy-MM-dd"
4664
+ )}`
4665
+ },
4666
+ {
4667
+ label: {
4668
+ defaultMessage: "Last 90 days",
4669
+ description: "Label for option of time period select: last 90 days",
4670
+ id: "form.section.label.timePeriodLast90Days"
4671
+ },
4672
+ value: `${(0, import_date_fns2.format)((0, import_date_fns2.subQuarters)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns2.format)(
4673
+ /* @__PURE__ */ new Date(),
4674
+ "yyyy-MM-dd"
4675
+ )}`
4676
+ },
4677
+ {
4678
+ label: {
4679
+ defaultMessage: "Last year",
4680
+ description: "Label for option of time period select: last year",
4681
+ id: "form.section.label.timePeriodLastYear"
4682
+ },
4683
+ value: `${(0, import_date_fns2.format)((0, import_date_fns2.subYears)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns2.format)(
4684
+ /* @__PURE__ */ new Date(),
4685
+ "yyyy-MM-dd"
4686
+ )}`
4687
+ }
4688
+ ];
4689
+
4690
+ // ../commons/src/fixtures/tennis-club-membership-event.ts
4691
+ var tennisClubMembershipEvent = defineConfig({
4692
+ id: TENNIS_CLUB_MEMBERSHIP,
4693
+ label: {
4694
+ defaultMessage: "Tennis club membership application",
4695
+ description: "This is what this event is referred as in the system",
4696
+ id: "v2.event.tennis-club-membership.label"
4697
+ },
4698
+ title: {
4699
+ defaultMessage: "{applicant.name.firstname} {applicant.name.surname}",
4700
+ description: "This is the title of the summary",
4701
+ id: "v2.event.tennis-club-membership.title"
4702
+ },
4703
+ summary: {
4704
+ fields: [
4705
+ {
4706
+ fieldId: "applicant.name",
4707
+ label: {
4708
+ defaultMessage: "Applicant's name",
4709
+ description: "This is the label for the field",
4710
+ id: "event.tennis-club-membership.summary.field.firstname.label"
4711
+ },
4712
+ emptyValueMessage: {
4713
+ defaultMessage: "First name is not provided",
4714
+ description: "This is the message to show when the field is empty",
4715
+ id: "event.tennis-club-membership.summary.field.firstname.empty"
4716
+ }
4717
+ },
4718
+ {
4719
+ fieldId: "applicant.email"
4720
+ }
4721
+ ]
4722
+ },
4723
+ actions: [
4724
+ {
4725
+ type: ActionType.READ,
4726
+ label: {
4727
+ id: "v2.event.tennis-club-membership.action.read.label",
4728
+ defaultMessage: "Read",
4729
+ description: "Title of the read only page"
4730
+ },
4731
+ review: TENNIS_CLUB_DECLARATION_REVIEW
4732
+ },
4733
+ {
4734
+ type: ActionType.DECLARE,
4735
+ label: {
4736
+ defaultMessage: "Send an application",
4737
+ description: "This is shown as the action name anywhere the user can trigger the action from",
4738
+ id: "event.tennis-club-membership.action.declare.label"
4739
+ },
4740
+ review: TENNIS_CLUB_DECLARATION_REVIEW
4741
+ },
4742
+ {
4743
+ type: ActionType.VALIDATE,
4744
+ label: {
4745
+ defaultMessage: "Validate",
4746
+ description: "This is shown as the action name anywhere the user can trigger the action from",
4747
+ id: "event.tennis-club-membership.action.validate.label"
4748
+ },
4749
+ review: TENNIS_CLUB_DECLARATION_REVIEW
4750
+ },
4751
+ {
4752
+ type: ActionType.REGISTER,
4753
+ label: {
4754
+ defaultMessage: "Register",
4755
+ description: "This is shown as the action name anywhere the user can trigger the action from",
4756
+ id: "event.tennis-club-membership.action.register.label"
4757
+ },
4758
+ review: TENNIS_CLUB_DECLARATION_REVIEW
4759
+ },
4760
+ {
4761
+ type: ActionType.REQUEST_CORRECTION,
4762
+ label: {
4763
+ defaultMessage: "Request correction",
4764
+ description: "This is shown as the action name anywhere the user can trigger the action from",
4765
+ id: "event.tennis-club-membership.action.correction.request.label"
4766
+ },
4767
+ onboardingForm: [
4768
+ {
4769
+ id: "correction-requester",
4770
+ type: PageTypes.enum.FORM,
4771
+ title: {
4772
+ id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
4773
+ defaultMessage: "Correction requester",
4774
+ description: "This is the title of the section"
4775
+ },
4776
+ fields: [
4777
+ {
4778
+ id: "correction.requester.relationshop.intro",
4779
+ type: "PAGE_HEADER",
4780
+ label: {
4781
+ id: "correction.requester.relationshop.intro.label",
4782
+ 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.",
4783
+ description: "The title for the corrector form"
4784
+ }
4785
+ },
4786
+ {
4787
+ id: "correction.requester.relationship",
4788
+ type: "RADIO_GROUP",
4789
+ label: {
4790
+ id: "v2.correction.corrector.title",
4791
+ defaultMessage: "Who is requesting a change to this record?",
4792
+ description: "The title for the corrector form"
4793
+ },
4794
+ defaultValue: "",
4795
+ options: [
4796
+ {
4797
+ value: "INFORMANT",
4798
+ label: {
4799
+ id: "v2.correction.corrector.informant",
4800
+ defaultMessage: "Informant",
4801
+ description: "Label for informant option in certificate correction form"
4802
+ }
4803
+ },
4804
+ {
4805
+ value: "ANOTHER_AGENT",
4806
+ label: {
4807
+ id: "v2.correction.corrector.anotherAgent",
4808
+ defaultMessage: "Another registration agent or field agent",
4809
+ description: "Label for another registration or field agent option in certificate correction form"
4810
+ }
4811
+ },
4812
+ {
4813
+ value: "REGISTRAR",
4814
+ label: {
4815
+ id: "v2.correction.corrector.me",
4816
+ defaultMessage: "Me (Registrar)",
4817
+ description: "Label for registrar option in certificate correction form"
4818
+ }
4819
+ },
4820
+ {
4821
+ value: "OTHER",
4822
+ label: {
4823
+ id: "v2.correction.corrector.others",
4824
+ defaultMessage: "Someone else",
4825
+ description: "Label for someone else option in certificate correction form"
4826
+ }
4827
+ }
4828
+ ]
4829
+ }
4830
+ ]
4831
+ },
4832
+ {
4833
+ id: "identity-check",
4834
+ type: PageTypes.enum.FORM,
4835
+ title: {
4836
+ id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
4837
+ defaultMessage: "Verify their identity",
4838
+ description: "This is the title of the section"
4839
+ },
4840
+ fields: [
4841
+ {
4842
+ id: "correction.identity-check.instructions",
4843
+ type: "PAGE_HEADER",
4844
+ label: {
4845
+ id: "correction.corrector.identity.instruction",
4846
+ defaultMessage: "Please verify the identity of the person making this request",
4847
+ description: "The title for the corrector form"
4848
+ }
4849
+ },
4850
+ {
4851
+ id: "correction.identity-check.verified",
4852
+ type: "RADIO_GROUP",
4853
+ label: {
4854
+ id: "correction.corrector.identity.verified.label",
4855
+ defaultMessage: "Identity verified",
4856
+ description: "The title for the corrector form"
4857
+ },
4858
+ defaultValue: "",
4859
+ required: true,
4860
+ options: [
4861
+ {
4862
+ value: "VERIFIED",
4863
+ label: {
4864
+ id: "correction.corrector.identity.verified",
4865
+ defaultMessage: "I have verified their identity",
4866
+ description: "Label for verified option in corrector identity check page"
4867
+ }
4868
+ }
4869
+ ]
4870
+ }
4871
+ ]
4872
+ }
4873
+ ],
4874
+ additionalDetailsForm: [
4875
+ {
4876
+ id: "correction-request.supporting-documents",
4877
+ type: PageTypes.enum.FORM,
4878
+ title: {
4879
+ id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
4880
+ defaultMessage: "Upload supporting documents",
4881
+ description: "This is the title of the section"
4882
+ },
4883
+ fields: [
4884
+ {
4885
+ id: "correction.supportingDocs.introduction",
4886
+ type: "PAGE_HEADER",
4887
+ label: {
4888
+ id: "correction.corrector.paragraph.title",
4889
+ 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.",
4890
+ description: "The title for the corrector form"
4891
+ }
4892
+ },
4893
+ {
4894
+ id: "correction.supportingDocs",
4895
+ type: FieldType.FILE,
4896
+ label: {
4897
+ id: "correction.corrector.title",
4898
+ defaultMessage: "Upload supporting documents",
4899
+ description: "The title for the corrector form"
4900
+ }
4901
+ },
4902
+ {
4903
+ id: "correction.request.supportingDocuments",
4904
+ type: "RADIO_GROUP",
4905
+ label: {
4906
+ id: "correction.corrector.title",
4907
+ defaultMessage: "Who is requesting a change to this record?",
4908
+ description: "The title for the corrector form"
4909
+ },
4910
+ defaultValue: "",
4911
+ configuration: {
4912
+ styles: {
4913
+ size: "NORMAL"
4914
+ }
4915
+ },
4916
+ options: [
4917
+ {
4918
+ value: "ATTEST",
4919
+ label: {
4920
+ id: "correction.supportingDocuments.attest.label",
4921
+ defaultMessage: "I attest to seeing supporting documentation and have a copy filed at my office",
4922
+ description: ""
4923
+ }
4924
+ },
4925
+ {
4926
+ value: "NOT_NEEDED",
4927
+ label: {
4928
+ id: "correction.supportingDocuments.notNeeded.label",
4929
+ defaultMessage: "No supporting documents required",
4930
+ description: ""
4931
+ }
4932
+ }
4933
+ ]
4934
+ }
4935
+ ]
4936
+ },
4937
+ {
4938
+ id: "correction-request.additional-details",
4939
+ type: PageTypes.enum.FORM,
4940
+ title: {
4941
+ id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
4942
+ defaultMessage: "Reason for correction",
4943
+ description: "This is the title of the section"
4944
+ },
4945
+ fields: [
4946
+ {
4947
+ id: "correction.request.reason",
4948
+ type: FieldType.TEXT,
4949
+ label: {
4950
+ id: "correction.reason.title",
4951
+ defaultMessage: "Reason for correction?",
4952
+ description: "The title for the corrector form"
4953
+ }
4954
+ }
4955
+ ]
4956
+ }
4957
+ ]
4958
+ },
4959
+ {
4960
+ type: ActionType.APPROVE_CORRECTION,
4961
+ label: {
4962
+ defaultMessage: "Approve correction",
4963
+ description: "This is shown as the action name anywhere the user can trigger the action from",
4964
+ id: "event.tennis-club-membership.action.correction.approve.label"
4965
+ }
4966
+ },
4967
+ {
4968
+ type: ActionType.PRINT_CERTIFICATE,
4969
+ label: {
4970
+ id: "v2.event.tennis-club-membership.action.collect-certificate.label",
4971
+ defaultMessage: "Print certificate",
4972
+ description: "This is shown as the action name anywhere the user can trigger the action from"
4973
+ },
4974
+ printForm: PRINT_CERTIFICATE_FORM,
4975
+ conditionals: [
4976
+ {
4977
+ type: "SHOW",
4978
+ conditional: defineConditional({
4979
+ type: "object",
4980
+ properties: {
4981
+ $event: {
4982
+ type: "object",
4983
+ properties: {
4984
+ actions: {
4985
+ type: "array",
4986
+ contains: {
4987
+ type: "object",
4988
+ properties: {
4989
+ type: {
4990
+ const: "REGISTER"
4991
+ },
4992
+ draft: {
4993
+ type: "boolean"
4994
+ }
4995
+ },
4996
+ required: ["type"],
4997
+ not: {
4998
+ properties: {
4999
+ draft: {
5000
+ const: true
5001
+ }
5002
+ }
5003
+ }
5004
+ }
5005
+ }
5006
+ },
5007
+ required: ["actions"]
5008
+ }
5009
+ },
5010
+ required: ["$event"]
5011
+ })
5012
+ }
5013
+ ]
5014
+ },
5015
+ {
5016
+ type: ActionType.ARCHIVE,
5017
+ label: {
5018
+ id: "v2.event.tennis-club-membership.action.archive.label",
5019
+ defaultMessage: "Archive",
5020
+ description: "This is shown as the action name anywhere the user can trigger the action from"
5021
+ }
5022
+ },
5023
+ {
5024
+ type: ActionType.REJECT,
5025
+ label: {
5026
+ id: "v2.event.tennis-club-membership.action.reject.label",
5027
+ defaultMessage: "Reject",
5028
+ description: "This is shown as the action name anywhere the user can trigger the action from"
5029
+ }
5030
+ }
5031
+ ],
5032
+ advancedSearch: [
5033
+ {
3891
5034
  title: {
3892
- id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.title",
3893
- defaultMessage: "Assign senior pass for applicant",
3894
- description: "This is the title of the section"
5035
+ defaultMessage: "Registration details",
5036
+ description: "The title of Registration details accordion",
5037
+ id: "v2.advancedSearch.form.registrationDetails"
3895
5038
  },
3896
5039
  fields: [
3897
- {
3898
- id: "senior-pass.id",
3899
- type: FieldType.TEXT,
3900
- required: true,
3901
- label: {
3902
- defaultMessage: "Senior pass ID",
3903
- description: "This is the label for the field",
3904
- id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.field.id.label"
3905
- }
3906
- }
5040
+ event("legalStatus.REGISTERED.createdAtLocation").exact(),
5041
+ event("legalStatus.REGISTERED.createdAt").range(),
5042
+ event("status", statusOptions).exact(),
5043
+ event("updatedAt", timePeriodOptions).range()
3907
5044
  ]
3908
5045
  },
3909
5046
  {
3910
- id: "recommender",
3911
5047
  title: {
3912
- id: "v2.event.tennis-club-membership.action.declare.form.section.recommender.title",
3913
- defaultMessage: "Who is recommending the applicant?",
3914
- description: "This is the title of the section"
5048
+ defaultMessage: "Applicant's details",
5049
+ description: "Applicant details search field section title",
5050
+ id: "v2.event.tennis-club-membership.search.applicants"
3915
5051
  },
3916
5052
  fields: [
3917
- {
3918
- id: "recommender.none",
3919
- type: "CHECKBOX",
3920
- required: false,
3921
- conditionals: [],
3922
- label: {
3923
- defaultMessage: "No recommender",
3924
- description: "This is the label for the field",
3925
- id: "v2.event.tennis-club-membership.action.declare.form.section.recommender.field.none.label"
3926
- }
3927
- },
3928
- {
3929
- id: "recommender.firstname",
3930
- type: FieldType.TEXT,
3931
- required: true,
3932
- conditionals: [
3933
- {
3934
- type: ConditionalType.SHOW,
3935
- conditional: field("recommender.none").isFalsy()
3936
- }
3937
- ],
3938
- label: {
3939
- defaultMessage: "Recommender's first name",
3940
- description: "This is the label for the field",
3941
- id: "v2.event.tennis-club-membership.action.declare.form.section.recommender.field.firstname.label"
3942
- }
3943
- },
3944
- {
3945
- id: "recommender.surname",
3946
- type: FieldType.TEXT,
3947
- required: true,
3948
- conditionals: [
3949
- {
3950
- type: ConditionalType.SHOW,
3951
- conditional: field("recommender.none").isFalsy()
3952
- }
3953
- ],
3954
- label: {
3955
- defaultMessage: "Recommender's surname",
3956
- description: "This is the label for the field",
3957
- id: "v2.event.tennis-club-membership.action.declare.form.section.recommender.field.surname.label"
3958
- }
3959
- },
3960
- {
3961
- id: "recommender.id",
3962
- type: FieldType.TEXT,
3963
- required: true,
3964
- conditionals: [
3965
- {
3966
- type: ConditionalType.SHOW,
3967
- conditional: field("recommender.none").isFalsy()
3968
- }
3969
- ],
3970
- label: {
3971
- defaultMessage: "Recommender's membership ID",
3972
- description: "This is the label for the field",
3973
- id: "v2.event.tennis-club-membership.action.declare.form.section.recommender.field.id.label"
3974
- }
3975
- }
5053
+ field("applicant.name").fuzzy(),
5054
+ field("applicant.dob").range(),
5055
+ field("applicant.email").exact()
3976
5056
  ]
5057
+ },
5058
+ {
5059
+ title: {
5060
+ defaultMessage: "Recommender's details",
5061
+ description: "Recommender details search field section title",
5062
+ id: "v2.event.tennis-club-membership.search.recommender"
5063
+ },
5064
+ fields: [field("recommender.name").fuzzy()]
3977
5065
  }
3978
- ]
5066
+ ],
5067
+ declaration: TENNIS_CLUB_DECLARATION_FORM
3979
5068
  });
3980
- var tennisClubMembershipEvent = defineConfig({
3981
- id: "TENNIS_CLUB_MEMBERSHIP",
5069
+
5070
+ // ../commons/src/fixtures/football-club-membership-event.ts
5071
+ var footballClubMembershipEvent = defineConfig({
5072
+ id: "FOOTBALL_CLUB_MEMBERSHIP",
3982
5073
  label: {
3983
- defaultMessage: "Tennis club membership application",
5074
+ defaultMessage: "Football club membership application",
3984
5075
  description: "This is what this event is referred as in the system",
3985
- id: "event.tennis-club-membership.label"
5076
+ id: "event.football-club-membership.label"
3986
5077
  },
3987
5078
  title: {
3988
- defaultMessage: "{applicant.firstname} {applicant.surname}",
5079
+ defaultMessage: "{applicant.name.firstname} {applicant.name.surname}",
3989
5080
  description: "This is the title of the summary",
3990
- id: "v2.event.tennis-club-membership.title"
5081
+ id: "v2.event.football-club-membership.title"
3991
5082
  },
3992
5083
  summary: {
3993
5084
  fields: [
3994
5085
  {
3995
- id: "applicant.firstname",
5086
+ id: "applicant.name.firstname",
3996
5087
  label: {
3997
5088
  defaultMessage: "Applicant's first name",
3998
5089
  description: "This is the label for the field",
3999
- id: "event.tennis-club-membership.summary.field.firstname.label"
5090
+ id: "event.football-club-membership.summary.field.firstname.label"
4000
5091
  },
4001
5092
  value: {
4002
- defaultMessage: "{applicant.firstname}",
5093
+ defaultMessage: "{applicant.name.firstname}",
4003
5094
  description: "This is the value to show in the summary",
4004
- id: "event.tennis-club-membership.summary.field.firstname"
5095
+ id: "event.football-club-membership.summary.field.firstname"
4005
5096
  },
4006
5097
  emptyValueMessage: {
4007
5098
  defaultMessage: "First name is not provided",
4008
5099
  description: "This is the message to show when the field is empty",
4009
- id: "event.tennis-club-membership.summary.field.firstname.empty"
5100
+ id: "event.football-club-membership.summary.field.firstname.empty"
4010
5101
  }
4011
5102
  },
4012
5103
  {
4013
- fieldId: "applicant.surname",
5104
+ fieldId: "applicant.name.surname",
4014
5105
  label: {
4015
5106
  defaultMessage: "Applicant's last name",
4016
5107
  description: "Label for surname",
4017
- id: "v2.event.tennis-club-membership.summary.field.surname.label"
5108
+ id: "v2.event.football-club-membership.summary.field.surname.label"
4018
5109
  }
4019
5110
  },
4020
5111
  {
@@ -4023,12 +5114,21 @@ var tennisClubMembershipEvent = defineConfig({
4023
5114
  ]
4024
5115
  },
4025
5116
  actions: [
5117
+ {
5118
+ type: ActionType.READ,
5119
+ label: {
5120
+ id: "v2.event.football-club-membership.action.read.label",
5121
+ defaultMessage: "Read",
5122
+ description: "Title of the read only page"
5123
+ },
5124
+ review: TENNIS_CLUB_DECLARATION_REVIEW
5125
+ },
4026
5126
  {
4027
5127
  type: ActionType.DECLARE,
4028
5128
  label: {
4029
5129
  defaultMessage: "Send an application",
4030
5130
  description: "This is shown as the action name anywhere the user can trigger the action from",
4031
- id: "event.tennis-club-membership.action.declare.label"
5131
+ id: "event.football-club-membership.action.declare.label"
4032
5132
  },
4033
5133
  review: TENNIS_CLUB_DECLARATION_REVIEW
4034
5134
  },
@@ -4037,7 +5137,7 @@ var tennisClubMembershipEvent = defineConfig({
4037
5137
  label: {
4038
5138
  defaultMessage: "Validate",
4039
5139
  description: "This is shown as the action name anywhere the user can trigger the action from",
4040
- id: "event.tennis-club-membership.action.validate.label"
5140
+ id: "event.football-club-membership.action.validate.label"
4041
5141
  },
4042
5142
  review: TENNIS_CLUB_DECLARATION_REVIEW
4043
5143
  },
@@ -4046,7 +5146,7 @@ var tennisClubMembershipEvent = defineConfig({
4046
5146
  label: {
4047
5147
  defaultMessage: "Register",
4048
5148
  description: "This is shown as the action name anywhere the user can trigger the action from",
4049
- id: "event.tennis-club-membership.action.register.label"
5149
+ id: "event.football-club-membership.action.register.label"
4050
5150
  },
4051
5151
  review: TENNIS_CLUB_DECLARATION_REVIEW
4052
5152
  },
@@ -4055,14 +5155,14 @@ var tennisClubMembershipEvent = defineConfig({
4055
5155
  label: {
4056
5156
  defaultMessage: "Request correction",
4057
5157
  description: "This is shown as the action name anywhere the user can trigger the action from",
4058
- id: "event.tennis-club-membership.action.correction.request.label"
5158
+ id: "event.football-club-membership.action.correction.request.label"
4059
5159
  },
4060
5160
  onboardingForm: [
4061
5161
  {
4062
5162
  id: "correction-requester",
4063
5163
  type: PageTypes.enum.FORM,
4064
5164
  title: {
4065
- id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
5165
+ id: "event.football-club-membership.action.requestCorrection.form.section.corrector",
4066
5166
  defaultMessage: "Correction requester",
4067
5167
  description: "This is the title of the section"
4068
5168
  },
@@ -4126,7 +5226,7 @@ var tennisClubMembershipEvent = defineConfig({
4126
5226
  id: "identity-check",
4127
5227
  type: PageTypes.enum.FORM,
4128
5228
  title: {
4129
- id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
5229
+ id: "event.football-club-membership.action.requestCorrection.form.section.verify",
4130
5230
  defaultMessage: "Verify their identity",
4131
5231
  description: "This is the title of the section"
4132
5232
  },
@@ -4169,7 +5269,7 @@ var tennisClubMembershipEvent = defineConfig({
4169
5269
  id: "correction-request.supporting-documents",
4170
5270
  type: PageTypes.enum.FORM,
4171
5271
  title: {
4172
- id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
5272
+ id: "event.football-club-membership.action.requestCorrection.form.section.verify",
4173
5273
  defaultMessage: "Upload supporting documents",
4174
5274
  description: "This is the title of the section"
4175
5275
  },
@@ -4231,7 +5331,7 @@ var tennisClubMembershipEvent = defineConfig({
4231
5331
  id: "correction-request.additional-details",
4232
5332
  type: PageTypes.enum.FORM,
4233
5333
  title: {
4234
- id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
5334
+ id: "event.football-club-membership.action.requestCorrection.form.section.corrector",
4235
5335
  defaultMessage: "Reason for correction",
4236
5336
  description: "This is the title of the section"
4237
5337
  },
@@ -4254,13 +5354,13 @@ var tennisClubMembershipEvent = defineConfig({
4254
5354
  label: {
4255
5355
  defaultMessage: "Approve correction",
4256
5356
  description: "This is shown as the action name anywhere the user can trigger the action from",
4257
- id: "event.tennis-club-membership.action.correction.approve.label"
5357
+ id: "event.football-club-membership.action.correction.approve.label"
4258
5358
  }
4259
5359
  },
4260
5360
  {
4261
5361
  type: ActionType.PRINT_CERTIFICATE,
4262
5362
  label: {
4263
- id: "v2.event.tennis-club-membership.action.collect-certificate.label",
5363
+ id: "v2.event.football-club-membership.action.collect-certificate.label",
4264
5364
  defaultMessage: "Print certificate",
4265
5365
  description: "This is shown as the action name anywhere the user can trigger the action from"
4266
5366
  },
@@ -4308,7 +5408,7 @@ var tennisClubMembershipEvent = defineConfig({
4308
5408
  {
4309
5409
  type: ActionType.ARCHIVE,
4310
5410
  label: {
4311
- id: "v2.event.tennis-club-membership.action.archive.label",
5411
+ id: "v2.event.football-club-membership.action.archive.label",
4312
5412
  defaultMessage: "Archive",
4313
5413
  description: "This is shown as the action name anywhere the user can trigger the action from"
4314
5414
  }
@@ -4316,7 +5416,7 @@ var tennisClubMembershipEvent = defineConfig({
4316
5416
  {
4317
5417
  type: ActionType.REJECT,
4318
5418
  label: {
4319
- id: "v2.event.tennis-club-membership.action.reject.label",
5419
+ id: "v2.event.football-club-membership.action.reject.label",
4320
5420
  defaultMessage: "Reject",
4321
5421
  description: "This is shown as the action name anywhere the user can trigger the action from"
4322
5422
  }
@@ -4325,43 +5425,347 @@ var tennisClubMembershipEvent = defineConfig({
4325
5425
  advancedSearch: [
4326
5426
  {
4327
5427
  title: {
4328
- defaultMessage: "Tennis club registration search",
4329
- description: "This is what this event is referred as in the system",
4330
- id: "v2.event.tennis-club-membership.search"
5428
+ defaultMessage: "Registration details",
5429
+ description: "The title of Registration details accordion",
5430
+ id: "v2.advancedSearch.form.registrationDetails"
5431
+ },
5432
+ fields: [
5433
+ event("legalStatus.REGISTERED.createdAtLocation").exact(),
5434
+ event("legalStatus.REGISTERED.createdAt").range(),
5435
+ event("status", statusOptions).exact(),
5436
+ event("updatedAt", timePeriodOptions).range()
5437
+ ]
5438
+ },
5439
+ {
5440
+ title: {
5441
+ defaultMessage: "Applicant's details",
5442
+ description: "Applicant details search field section title",
5443
+ id: "v2.event.football-club-membership.search.applicants"
5444
+ },
5445
+ fields: [
5446
+ field("applicant.name").fuzzy(),
5447
+ field("applicant.dob").range(),
5448
+ field("applicant.email").exact()
5449
+ ]
5450
+ },
5451
+ {
5452
+ title: {
5453
+ defaultMessage: "Recommender's details",
5454
+ description: "Recommender details search field section title",
5455
+ id: "v2.event.football-club-membership.search.recommender"
4331
5456
  },
4332
- fields: [field("applicant.dob").exact()]
5457
+ fields: [field("recommender.name").fuzzy()]
4333
5458
  }
4334
5459
  ],
4335
5460
  declaration: TENNIS_CLUB_DECLARATION_FORM
4336
5461
  });
4337
5462
 
5463
+ // ../commons/src/fixtures/library-membership-event.ts
5464
+ var libraryMembershipForm = defineDeclarationForm({
5465
+ label: {
5466
+ id: "v2.event.library-membership.action.declare.form.label",
5467
+ defaultMessage: "Library membership application",
5468
+ description: "This is what this form is referred as in the system"
5469
+ },
5470
+ pages: [
5471
+ {
5472
+ id: "member",
5473
+ title: {
5474
+ id: "v2.event.library-membership.action.declare.form.section.who.title",
5475
+ defaultMessage: "Who is applying for the membership?",
5476
+ description: "This is the title of the section"
5477
+ },
5478
+ fields: [
5479
+ {
5480
+ id: "member.firstname",
5481
+ type: FieldType.TEXT,
5482
+ required: true,
5483
+ conditionals: [],
5484
+ label: {
5485
+ defaultMessage: "Member's first name",
5486
+ description: "This is the label for the field",
5487
+ id: "v2.event.library-membership.action.declare.form.section.who.field.firstname.label"
5488
+ }
5489
+ },
5490
+ {
5491
+ id: "member.surname",
5492
+ type: FieldType.TEXT,
5493
+ required: true,
5494
+ conditionals: [],
5495
+ label: {
5496
+ defaultMessage: "Member's surname",
5497
+ description: "This is the label for the field",
5498
+ id: "v2.event.library-membership.action.declare.form.section.who.field.surname.label"
5499
+ }
5500
+ }
5501
+ ]
5502
+ }
5503
+ ]
5504
+ });
5505
+ var libraryMembershipEvent = defineConfig({
5506
+ id: "library-membership",
5507
+ label: {
5508
+ defaultMessage: "Library membership application",
5509
+ description: "This is what this event is referred as in the system",
5510
+ id: "event.library-membership.label"
5511
+ },
5512
+ title: {
5513
+ defaultMessage: "{member.firstname} {member.surname}",
5514
+ description: "This is the title of the summary",
5515
+ id: "v2.event.library-membership.title"
5516
+ },
5517
+ summary: { fields: [] },
5518
+ actions: [],
5519
+ declaration: libraryMembershipForm
5520
+ });
5521
+
5522
+ // ../commons/src/fixtures/v2-birth-event.ts
5523
+ var child = defineFormPage({
5524
+ id: "child",
5525
+ type: PageTypes.enum.FORM,
5526
+ title: {
5527
+ defaultMessage: "Child's details",
5528
+ description: "Form section title for Child",
5529
+ id: "v2.form.birth.child.title"
5530
+ },
5531
+ fields: [
5532
+ {
5533
+ id: "child.firstNames",
5534
+ type: FieldType.TEXT,
5535
+ required: true,
5536
+ configuration: { maxLength: 32 },
5537
+ hideLabel: true,
5538
+ label: {
5539
+ defaultMessage: "Child's first name",
5540
+ description: "This is the label for the field",
5541
+ id: "v2.event.birth.action.declare.form.section.child.field.name.label"
5542
+ }
5543
+ },
5544
+ {
5545
+ id: "child.familyName",
5546
+ type: FieldType.TEXT,
5547
+ required: true,
5548
+ configuration: { maxLength: 32 },
5549
+ hideLabel: true,
5550
+ label: {
5551
+ defaultMessage: "Child's last name",
5552
+ description: "This is the label for the field",
5553
+ id: "v2.event.birth.action.declare.form.section.child.field.name.label"
5554
+ }
5555
+ },
5556
+ {
5557
+ id: "child.DoB",
5558
+ type: "DATE",
5559
+ required: true,
5560
+ label: {
5561
+ defaultMessage: "Date of birth",
5562
+ description: "This is the label for the field",
5563
+ id: "v2.event.birth.action.declare.form.section.child.field.dob.label"
5564
+ }
5565
+ }
5566
+ ]
5567
+ });
5568
+ var mother = defineFormPage({
5569
+ id: "mother",
5570
+ type: PageTypes.enum.FORM,
5571
+ title: {
5572
+ defaultMessage: "Mother's details",
5573
+ description: "Form section title for mothers details",
5574
+ id: "v2.form.section.mother.title"
5575
+ },
5576
+ fields: [
5577
+ {
5578
+ id: "mother.firstNames",
5579
+ configuration: { maxLength: 32 },
5580
+ type: FieldType.TEXT,
5581
+ required: true,
5582
+ label: {
5583
+ defaultMessage: "First name(s)",
5584
+ description: "This is the label for the field",
5585
+ id: `v2.event.birth.action.declare.form.section.person.field.firstname.label`
5586
+ }
5587
+ },
5588
+ {
5589
+ id: `mother.familyName`,
5590
+ configuration: { maxLength: 32 },
5591
+ type: FieldType.TEXT,
5592
+ required: true,
5593
+ label: {
5594
+ defaultMessage: "Last name",
5595
+ description: "This is the label for the field",
5596
+ id: `v2.event.birth.action.declare.form.section.person.field.surname.label`
5597
+ }
5598
+ },
5599
+ {
5600
+ id: `mother.DoB`,
5601
+ type: "DATE",
5602
+ required: true,
5603
+ label: {
5604
+ defaultMessage: "Date of birth",
5605
+ description: "This is the label for the field",
5606
+ id: `v2.event.birth.action.declare.form.section.person.field.dob.label`
5607
+ }
5608
+ },
5609
+ {
5610
+ id: "mother.identifier",
5611
+ type: FieldType.ID,
5612
+ required: true,
5613
+ label: {
5614
+ defaultMessage: "ID Number",
5615
+ description: "This is the label for the field",
5616
+ id: `v2.event.birth.action.declare.form.section.person.field.nid.label`
5617
+ }
5618
+ }
5619
+ ]
5620
+ });
5621
+ var BIRTH_DECLARATION_FORM = defineDeclarationForm({
5622
+ label: {
5623
+ defaultMessage: "Birth decalration form",
5624
+ id: "v2.event.birth.action.declare.form.label",
5625
+ description: "This is what this form is referred as in the system"
5626
+ },
5627
+ pages: [child, mother]
5628
+ });
5629
+ var v2BirthEvent = defineConfig({
5630
+ id: BIRTH_EVENT,
5631
+ title: {
5632
+ defaultMessage: "{child.name.firstname} {child.name.surname}",
5633
+ description: "This is the title of the summary",
5634
+ id: "v2.event.birth.title"
5635
+ },
5636
+ label: {
5637
+ defaultMessage: "Birth",
5638
+ description: "This is what this event is referred as in the system",
5639
+ id: "v2.event.birth.label"
5640
+ },
5641
+ summary: {
5642
+ fields: []
5643
+ },
5644
+ actions: [],
5645
+ declaration: BIRTH_DECLARATION_FORM
5646
+ });
5647
+
4338
5648
  // ../commons/src/events/test.utils.ts
4339
- function fieldConfigsToActionPayload(fields) {
5649
+ function pickRandom(rng, items) {
5650
+ return items[Math.floor(rng() * items.length)];
5651
+ }
5652
+ function generateRandomName(rng) {
5653
+ const firstnames = [
5654
+ "Danny",
5655
+ "John",
5656
+ "Jane",
5657
+ "Emily",
5658
+ "Michael",
5659
+ "Sarah",
5660
+ "Chris",
5661
+ "Jessica",
5662
+ "Sara",
5663
+ "Sarachella",
5664
+ "Sarandera",
5665
+ "Zara"
5666
+ ];
5667
+ const surnames = [
5668
+ "Doe",
5669
+ "Smith",
5670
+ "Johnson",
5671
+ "Brown",
5672
+ "Williams",
5673
+ "Jones",
5674
+ "Garcia",
5675
+ "Miller",
5676
+ "Saranen",
5677
+ "Sarajanen",
5678
+ "Sarthua",
5679
+ "Tsarakovski",
5680
+ "Salamander",
5681
+ "Zarathustra"
5682
+ ];
5683
+ return {
5684
+ firstname: pickRandom(rng, firstnames),
5685
+ surname: pickRandom(rng, surnames)
5686
+ };
5687
+ }
5688
+ function mapFieldTypeToMockValue(field2, i, rng) {
5689
+ switch (field2.type) {
5690
+ case FieldType.DIVIDER:
5691
+ case FieldType.TEXT:
5692
+ case FieldType.TEXTAREA:
5693
+ case FieldType.BULLET_LIST:
5694
+ case FieldType.PAGE_HEADER:
5695
+ case FieldType.LOCATION:
5696
+ case FieldType.SELECT:
5697
+ case FieldType.COUNTRY:
5698
+ case FieldType.RADIO_GROUP:
5699
+ case FieldType.PARAGRAPH:
5700
+ case FieldType.ADMINISTRATIVE_AREA:
5701
+ case FieldType.FACILITY:
5702
+ case FieldType.PHONE:
5703
+ case FieldType.ID:
5704
+ case FieldType.OFFICE:
5705
+ return `${field2.id}-${field2.type}-${i}`;
5706
+ case FieldType.NAME:
5707
+ return generateRandomName(rng);
5708
+ case FieldType.NUMBER:
5709
+ return 19;
5710
+ case FieldType.EMAIL:
5711
+ return "test@opencrvs.org";
5712
+ case FieldType.ADDRESS:
5713
+ return {
5714
+ country: "FAR",
5715
+ addressType: AddressType.DOMESTIC,
5716
+ province: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
5717
+ district: "5ef450bc-712d-48ad-93f3-8da0fa453baa",
5718
+ urbanOrRural: "URBAN",
5719
+ town: "Example Town",
5720
+ residentialArea: "Example Residential Area",
5721
+ street: "Example Street",
5722
+ number: "55",
5723
+ zipCode: "123456"
5724
+ };
5725
+ case FieldType.DATE:
5726
+ return "2021-01-01";
5727
+ case FieldType.DATE_RANGE:
5728
+ return ["2021-01-01", "2021-01-02"];
5729
+ case FieldType.CHECKBOX:
5730
+ return true;
5731
+ case FieldType.SIGNATURE:
5732
+ case FieldType.FILE:
5733
+ return {
5734
+ filename: "4f095fc4-4312-4de2-aa38-86dcc0f71044.png",
5735
+ originalFilename: "abcd.png",
5736
+ type: "image/png"
5737
+ };
5738
+ case FieldType.FILE_WITH_OPTIONS:
5739
+ case FieldType.DATA:
5740
+ return void 0;
5741
+ }
5742
+ }
5743
+ function fieldConfigsToActionPayload(fields, rng) {
4340
5744
  return fields.reduce(
4341
5745
  (acc, field2, i) => ({
4342
5746
  ...acc,
4343
- [field2.id]: mapFieldTypeToMockValue(field2, i)
5747
+ [field2.id]: mapFieldTypeToMockValue(field2, i, rng)
4344
5748
  }),
4345
5749
  {}
4346
5750
  );
4347
5751
  }
4348
- function generateActionDeclarationInput(configuration, action) {
5752
+ function generateActionDeclarationInput(configuration, action, rng) {
4349
5753
  const parsed = DeclarationUpdateActions.safeParse(action);
4350
5754
  if (parsed.success) {
4351
5755
  const fields = getDeclarationFields(configuration);
4352
5756
  const declarationConfig = getDeclaration(configuration);
4353
- const declaration = fieldConfigsToActionPayload(fields);
5757
+ const declaration = fieldConfigsToActionPayload(fields, rng);
4354
5758
  return omitHiddenPaginatedFields(declarationConfig, declaration);
4355
5759
  }
4356
5760
  console.warn(`${action} is not a declaration action. Setting data as {}.`);
4357
5761
  return {};
4358
5762
  }
4359
- function generateActionAnnotationInput(configuration, action) {
5763
+ function generateActionAnnotationInput(configuration, action, rng) {
4360
5764
  const actionConfig = configuration.actions.find(
4361
5765
  (ac) => ac.type === action
4362
5766
  );
4363
5767
  const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
4364
- const annotation = fieldConfigsToActionPayload(annotationFields);
5768
+ const annotation = fieldConfigsToActionPayload(annotationFields, rng);
4365
5769
  const visibleVerificationPageIds = getVisibleVerificationPageIds(
4366
5770
  findRecordActionPages(configuration, action),
4367
5771
  annotation
@@ -4379,193 +5783,226 @@ function generateActionAnnotationInput(configuration, action) {
4379
5783
  ...visiblePageVerificationMap
4380
5784
  };
4381
5785
  }
4382
- var eventPayloadGenerator = {
4383
- create: (input = {}) => ({
4384
- transactionId: input.transactionId ?? getUUID(),
4385
- type: input.type ?? "TENNIS_CLUB_MEMBERSHIP"
4386
- }),
4387
- patch: (id, input = {}) => ({
4388
- transactionId: input.transactionId ?? getUUID(),
4389
- type: input.type ?? "TENNIS_CLUB_MEMBERSHIP",
4390
- id
4391
- }),
4392
- draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
4393
- {
4394
- id: getUUID(),
4395
- eventId,
4396
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4397
- transactionId: getUUID(),
4398
- action: {
4399
- transactionId: getUUID(),
4400
- type: actionType,
4401
- status: ActionStatus.Accepted,
4402
- declaration: {
4403
- "applicant.firstname": "Max",
4404
- "applicant.surname": "McLaren",
4405
- "applicant.dob": "2020-01-02",
4406
- "recommender.none": true
4407
- },
4408
- annotation: {
4409
- "correction.requester.relationship": "ANOTHER_AGENT",
4410
- "correction.request.reason": "Child's name was incorrect"
4411
- },
4412
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4413
- createdBy: "@todo",
4414
- createdByRole: "@todo",
4415
- createdAtLocation: "@todo"
4416
- }
4417
- },
4418
- input
4419
- ),
4420
- actions: {
4421
- declare: (eventId, input = {}) => ({
4422
- type: ActionType.DECLARE,
4423
- transactionId: input.transactionId ?? getUUID(),
4424
- declaration: input.declaration ?? generateActionDeclarationInput(
4425
- tennisClubMembershipEvent,
4426
- ActionType.DECLARE
4427
- ),
4428
- annotation: input.annotation ?? generateActionAnnotationInput(
4429
- tennisClubMembershipEvent,
4430
- ActionType.DECLARE
4431
- ),
4432
- eventId
4433
- }),
4434
- /**
4435
- * Notify allows sending incomplete data. Think it as 'partial declare' for now.
4436
- */
4437
- notify: (eventId, input = {}) => {
4438
- let declaration = input.declaration;
4439
- if (!declaration) {
4440
- const partialDeclaration = (0, import_lodash2.omitBy)(
4441
- generateActionDeclarationInput(
4442
- tennisClubMembershipEvent,
4443
- ActionType.DECLARE
4444
- ),
4445
- import_lodash2.isString
4446
- );
4447
- declaration = partialDeclaration;
4448
- }
4449
- return {
4450
- type: ActionType.NOTIFY,
4451
- transactionId: input.transactionId ?? getUUID(),
4452
- declaration,
4453
- eventId
4454
- };
4455
- },
4456
- validate: (eventId, input = {}) => ({
4457
- type: ActionType.VALIDATE,
4458
- transactionId: input.transactionId ?? getUUID(),
4459
- declaration: input.declaration ?? generateActionDeclarationInput(
4460
- tennisClubMembershipEvent,
4461
- ActionType.VALIDATE
4462
- ),
4463
- annotation: input.annotation ?? generateActionAnnotationInput(
4464
- tennisClubMembershipEvent,
4465
- ActionType.VALIDATE
4466
- ),
4467
- duplicates: [],
4468
- eventId
4469
- }),
4470
- assign: (eventId, input = {}) => ({
4471
- type: ActionType.ASSIGN,
4472
- transactionId: input.transactionId ?? getUUID(),
4473
- declaration: {},
4474
- assignedTo: input.assignedTo ?? getUUID(),
4475
- eventId
4476
- }),
4477
- unassign: (eventId, input = {}) => ({
4478
- type: ActionType.UNASSIGN,
4479
- transactionId: input.transactionId ?? getUUID(),
4480
- declaration: {},
4481
- assignedTo: null,
4482
- eventId
4483
- }),
4484
- archive: (eventId, input = {}, isDuplicate) => ({
4485
- type: ActionType.ARCHIVE,
4486
- transactionId: input.transactionId ?? getUUID(),
4487
- declaration: {},
4488
- // @TODO: Check whether generator is needed?
4489
- annotation: { isDuplicate: isDuplicate ?? false },
4490
- duplicates: [],
4491
- eventId
4492
- }),
4493
- reject: (eventId, input = {}) => ({
4494
- type: ActionType.REJECT,
4495
- transactionId: input.transactionId ?? getUUID(),
4496
- declaration: {},
4497
- annotation: input.annotation ?? generateActionAnnotationInput(
4498
- tennisClubMembershipEvent,
4499
- ActionType.REJECT
4500
- ),
4501
- duplicates: [],
4502
- eventId
4503
- }),
4504
- register: (eventId, input = {}) => ({
4505
- type: ActionType.REGISTER,
5786
+ function eventPayloadGenerator(rng) {
5787
+ return {
5788
+ create: (input = {}) => ({
4506
5789
  transactionId: input.transactionId ?? getUUID(),
4507
- declaration: input.declaration ?? generateActionDeclarationInput(
4508
- tennisClubMembershipEvent,
4509
- ActionType.REGISTER
4510
- ),
4511
- annotation: input.annotation ?? generateActionAnnotationInput(
4512
- tennisClubMembershipEvent,
4513
- ActionType.REGISTER
4514
- ),
4515
- eventId
5790
+ type: input.type ?? TENNIS_CLUB_MEMBERSHIP
4516
5791
  }),
4517
- printCertificate: (eventId, input = {}) => ({
4518
- type: ActionType.PRINT_CERTIFICATE,
5792
+ patch: (id, input = {}) => ({
4519
5793
  transactionId: input.transactionId ?? getUUID(),
4520
- declaration: {},
4521
- annotation: input.annotation ?? generateActionAnnotationInput(
4522
- tennisClubMembershipEvent,
4523
- ActionType.PRINT_CERTIFICATE
4524
- ),
4525
- eventId
5794
+ type: input.type ?? TENNIS_CLUB_MEMBERSHIP,
5795
+ id
4526
5796
  }),
4527
- correction: {
4528
- request: (eventId, input = {}) => ({
4529
- type: ActionType.REQUEST_CORRECTION,
5797
+ draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
5798
+ {
5799
+ id: getUUID(),
5800
+ eventId,
5801
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
5802
+ transactionId: getUUID(),
5803
+ action: {
5804
+ transactionId: getUUID(),
5805
+ type: actionType,
5806
+ status: ActionStatus.Accepted,
5807
+ declaration: {
5808
+ "applicant.name": {
5809
+ firstname: "Max",
5810
+ surname: "McLaren"
5811
+ },
5812
+ "applicant.dob": "2020-01-02",
5813
+ "recommender.none": true
5814
+ },
5815
+ annotation: {
5816
+ "correction.requester.relationship": "ANOTHER_AGENT",
5817
+ "correction.request.reason": "Child's name was incorrect"
5818
+ },
5819
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
5820
+ createdBy: "@todo",
5821
+ createdByRole: "@todo",
5822
+ createdAtLocation: "@todo"
5823
+ }
5824
+ },
5825
+ input
5826
+ ),
5827
+ actions: {
5828
+ declare: (eventId, input = {}) => ({
5829
+ type: ActionType.DECLARE,
5830
+ transactionId: input.transactionId ?? getUUID(),
5831
+ declaration: input.declaration ?? generateActionDeclarationInput(
5832
+ tennisClubMembershipEvent,
5833
+ ActionType.DECLARE,
5834
+ rng
5835
+ ),
5836
+ annotation: input.annotation ?? generateActionAnnotationInput(
5837
+ tennisClubMembershipEvent,
5838
+ ActionType.DECLARE,
5839
+ rng
5840
+ ),
5841
+ eventId,
5842
+ ...input
5843
+ }),
5844
+ /**
5845
+ * Notify allows sending incomplete data. Think it as 'partial declare' for now.
5846
+ */
5847
+ notify: (eventId, input = {}) => {
5848
+ let declaration = input.declaration;
5849
+ if (!declaration) {
5850
+ const partialDeclaration = (0, import_lodash2.omitBy)(
5851
+ generateActionDeclarationInput(
5852
+ tennisClubMembershipEvent,
5853
+ ActionType.DECLARE,
5854
+ rng
5855
+ ),
5856
+ import_lodash2.isString
5857
+ );
5858
+ declaration = partialDeclaration;
5859
+ }
5860
+ return {
5861
+ type: ActionType.NOTIFY,
5862
+ transactionId: input.transactionId ?? getUUID(),
5863
+ declaration,
5864
+ eventId,
5865
+ keepAssignment: input.keepAssignment
5866
+ };
5867
+ },
5868
+ validate: (eventId, input = {}) => ({
5869
+ type: ActionType.VALIDATE,
4530
5870
  transactionId: input.transactionId ?? getUUID(),
4531
5871
  declaration: input.declaration ?? generateActionDeclarationInput(
4532
5872
  tennisClubMembershipEvent,
4533
- ActionType.REQUEST_CORRECTION
5873
+ ActionType.VALIDATE,
5874
+ rng
4534
5875
  ),
4535
5876
  annotation: input.annotation ?? generateActionAnnotationInput(
4536
5877
  tennisClubMembershipEvent,
4537
- ActionType.REQUEST_CORRECTION
5878
+ ActionType.VALIDATE,
5879
+ rng
4538
5880
  ),
5881
+ duplicates: [],
5882
+ eventId,
5883
+ ...input
5884
+ }),
5885
+ assign: (eventId, input = {}) => ({
5886
+ type: ActionType.ASSIGN,
5887
+ transactionId: input.transactionId ?? getUUID(),
5888
+ declaration: {},
5889
+ assignedTo: input.assignedTo ?? getUUID(),
5890
+ eventId
5891
+ }),
5892
+ unassign: (eventId, input = {}) => ({
5893
+ type: ActionType.UNASSIGN,
5894
+ transactionId: input.transactionId ?? getUUID(),
5895
+ declaration: {},
5896
+ assignedTo: null,
4539
5897
  eventId
4540
5898
  }),
4541
- approve: (eventId, requestId, input = {}) => ({
4542
- type: ActionType.APPROVE_CORRECTION,
5899
+ archive: (eventId, input = {}, isDuplicate) => ({
5900
+ type: ActionType.ARCHIVE,
5901
+ transactionId: input.transactionId ?? getUUID(),
5902
+ declaration: {},
5903
+ // @TODO: Check whether generator is needed?
5904
+ annotation: {},
5905
+ duplicates: [],
5906
+ eventId,
5907
+ reason: {
5908
+ message: `${ActionType.ARCHIVE}`,
5909
+ isDuplicate: isDuplicate ?? false
5910
+ },
5911
+ ...input
5912
+ }),
5913
+ reject: (eventId, input = {}) => ({
5914
+ type: ActionType.REJECT,
4543
5915
  transactionId: input.transactionId ?? getUUID(),
4544
5916
  declaration: {},
4545
5917
  annotation: input.annotation ?? generateActionAnnotationInput(
4546
5918
  tennisClubMembershipEvent,
4547
- ActionType.APPROVE_CORRECTION
5919
+ ActionType.REJECT,
5920
+ rng
5921
+ ),
5922
+ duplicates: [],
5923
+ eventId,
5924
+ reason: { message: `${ActionType.REJECT}` },
5925
+ ...input
5926
+ }),
5927
+ register: (eventId, input = {}) => ({
5928
+ type: ActionType.REGISTER,
5929
+ transactionId: input.transactionId ?? getUUID(),
5930
+ declaration: input.declaration ?? generateActionDeclarationInput(
5931
+ tennisClubMembershipEvent,
5932
+ ActionType.REGISTER,
5933
+ rng
5934
+ ),
5935
+ annotation: input.annotation ?? generateActionAnnotationInput(
5936
+ tennisClubMembershipEvent,
5937
+ ActionType.REGISTER,
5938
+ rng
4548
5939
  ),
4549
5940
  eventId,
4550
- requestId
5941
+ ...input
4551
5942
  }),
4552
- reject: (eventId, requestId, input = {}) => ({
4553
- type: ActionType.REJECT_CORRECTION,
5943
+ printCertificate: (eventId, input = {}) => ({
5944
+ type: ActionType.PRINT_CERTIFICATE,
4554
5945
  transactionId: input.transactionId ?? getUUID(),
4555
5946
  declaration: {},
4556
5947
  annotation: input.annotation ?? generateActionAnnotationInput(
4557
5948
  tennisClubMembershipEvent,
4558
- ActionType.REJECT_CORRECTION
5949
+ ActionType.PRINT_CERTIFICATE,
5950
+ rng
4559
5951
  ),
4560
5952
  eventId,
4561
- requestId
4562
- })
5953
+ ...input
5954
+ }),
5955
+ correction: {
5956
+ request: (eventId, input = {}) => ({
5957
+ type: ActionType.REQUEST_CORRECTION,
5958
+ transactionId: input.transactionId ?? getUUID(),
5959
+ declaration: input.declaration ?? generateActionDeclarationInput(
5960
+ tennisClubMembershipEvent,
5961
+ ActionType.REQUEST_CORRECTION,
5962
+ rng
5963
+ ),
5964
+ annotation: input.annotation ?? generateActionAnnotationInput(
5965
+ tennisClubMembershipEvent,
5966
+ ActionType.REQUEST_CORRECTION,
5967
+ rng
5968
+ ),
5969
+ eventId,
5970
+ keepAssignment: input.keepAssignment
5971
+ }),
5972
+ approve: (eventId, requestId, input = {}) => ({
5973
+ type: ActionType.APPROVE_CORRECTION,
5974
+ transactionId: input.transactionId ?? getUUID(),
5975
+ declaration: {},
5976
+ annotation: input.annotation ?? generateActionAnnotationInput(
5977
+ tennisClubMembershipEvent,
5978
+ ActionType.APPROVE_CORRECTION,
5979
+ rng
5980
+ ),
5981
+ eventId,
5982
+ requestId,
5983
+ keepAssignment: input.keepAssignment
5984
+ }),
5985
+ reject: (eventId, requestId, input = {}) => ({
5986
+ type: ActionType.REJECT_CORRECTION,
5987
+ transactionId: input.transactionId ?? getUUID(),
5988
+ declaration: {},
5989
+ annotation: input.annotation ?? generateActionAnnotationInput(
5990
+ tennisClubMembershipEvent,
5991
+ ActionType.REJECT_CORRECTION,
5992
+ rng
5993
+ ),
5994
+ eventId,
5995
+ requestId,
5996
+ keepAssignment: input.keepAssignment
5997
+ })
5998
+ }
4563
5999
  }
4564
- }
4565
- };
6000
+ };
6001
+ }
4566
6002
  function generateActionDocument({
4567
6003
  configuration,
4568
6004
  action,
6005
+ rng = () => 0.1,
4569
6006
  defaults = {}
4570
6007
  }) {
4571
6008
  const actionBase = {
@@ -4576,7 +6013,7 @@ function generateActionDocument({
4576
6013
  createdByRole: "FIELD_AGENT",
4577
6014
  id: getUUID(),
4578
6015
  createdAtLocation: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
4579
- declaration: generateActionDeclarationInput(configuration, action),
6016
+ declaration: generateActionDeclarationInput(configuration, action, rng),
4580
6017
  annotation: {},
4581
6018
  status: ActionStatus.Accepted,
4582
6019
  transactionId: getUUID(),
@@ -4596,9 +6033,9 @@ function generateActionDocument({
4596
6033
  case ActionType.VALIDATE:
4597
6034
  return { ...actionBase, type: action };
4598
6035
  case ActionType.ARCHIVE:
4599
- return { ...actionBase, type: action };
6036
+ return { ...actionBase, type: action, reason: { message: "Archive" } };
4600
6037
  case ActionType.REJECT:
4601
- return { ...actionBase, type: action };
6038
+ return { ...actionBase, type: action, reason: { message: "Reject" } };
4602
6039
  case ActionType.CREATE:
4603
6040
  return { ...actionBase, type: action };
4604
6041
  case ActionType.NOTIFY:
@@ -4610,7 +6047,11 @@ function generateActionDocument({
4610
6047
  case ActionType.APPROVE_CORRECTION:
4611
6048
  return { ...actionBase, requestId: getUUID(), type: action };
4612
6049
  case ActionType.REJECT_CORRECTION:
4613
- return { ...actionBase, requestId: getUUID(), type: action };
6050
+ return {
6051
+ ...actionBase,
6052
+ requestId: getUUID(),
6053
+ type: action
6054
+ };
4614
6055
  case ActionType.REGISTER:
4615
6056
  return {
4616
6057
  ...actionBase,
@@ -4624,13 +6065,14 @@ function generateActionDocument({
4624
6065
  }
4625
6066
  function generateEventDocument({
4626
6067
  configuration,
4627
- actions
6068
+ actions,
6069
+ rng = () => 0.1
4628
6070
  }) {
4629
6071
  return {
4630
6072
  trackingId: getUUID(),
4631
6073
  type: configuration.id,
4632
6074
  actions: actions.map(
4633
- (action) => generateActionDocument({ configuration, action })
6075
+ (action) => generateActionDocument({ configuration, action, rng })
4634
6076
  ),
4635
6077
  // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
4636
6078
  // @TODO: This should be fixed in the future.
@@ -4638,14 +6080,19 @@ function generateEventDocument({
4638
6080
  id: getUUID(),
4639
6081
  // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
4640
6082
  // @TODO: This should be fixed in the future.
4641
- updatedAt: new Date(Date.now() - 1e3).toISOString(),
4642
- dateOfEvent: configuration.dateOfEvent
6083
+ updatedAt: new Date(Date.now() - 1e3).toISOString()
4643
6084
  };
4644
6085
  }
4645
- function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
6086
+ function generateEventDraftDocument({
6087
+ eventId,
6088
+ actionType,
6089
+ rng = () => 0.1,
6090
+ declaration = {}
6091
+ }) {
4646
6092
  const action = generateActionDocument({
4647
6093
  configuration: tennisClubMembershipEvent,
4648
- action: actionType
6094
+ action: actionType,
6095
+ rng
4649
6096
  });
4650
6097
  return {
4651
6098
  id: getUUID(),
@@ -4661,82 +6108,105 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, de
4661
6108
  eventId
4662
6109
  };
4663
6110
  }
4664
- function getEventStatus() {
4665
- const statuses = [
4666
- EventStatus.CREATED,
4667
- EventStatus.REGISTERED,
4668
- EventStatus.DECLARED
4669
- ];
4670
- const randomIndex = Math.floor(Math.random() * 3);
4671
- return statuses[randomIndex];
6111
+ function getRandomDatetime(rng, start, end) {
6112
+ const range = end.getTime() - start.getTime();
6113
+ const offset = Math.floor(rng() * range);
6114
+ const randomDate = new Date(start.getTime() + offset);
6115
+ return randomDate.toISOString();
4672
6116
  }
4673
- function getTrackingId() {
4674
- const uuid = getUUID().replace(/-/g, "");
4675
- const trackingId = uuid.slice(0, 6).toUpperCase();
4676
- return trackingId;
6117
+ function getRandomDate(rng, start, end) {
6118
+ const datetime = getRandomDatetime(rng, new Date(start), new Date(end));
6119
+ return datetime.split("T")[0];
4677
6120
  }
4678
- function getRandomApplicant() {
4679
- const firstNames = [
4680
- "Danny",
4681
- "John",
4682
- "Jane",
4683
- "Emily",
4684
- "Michael",
4685
- "Sarah",
4686
- "Chris",
4687
- "Jessica"
4688
- ];
4689
- const surnames = [
4690
- "Doe",
4691
- "Smith",
4692
- "Johnson",
4693
- "Brown",
4694
- "Williams",
4695
- "Jones",
4696
- "Garcia",
4697
- "Miller"
4698
- ];
4699
- function getRandomDate(start, end) {
4700
- const randomDate = new Date(
4701
- start.getTime() + Math.random() * (end.getTime() - start.getTime())
4702
- );
4703
- return randomDate.toISOString().split("T")[0];
4704
- }
4705
- const randomFirstName = firstNames[Math.floor(Math.random() * firstNames.length)];
4706
- const randomSurname = surnames[Math.floor(Math.random() * surnames.length)];
4707
- const randomDob = getRandomDate(
4708
- /* @__PURE__ */ new Date("1990-01-01"),
4709
- /* @__PURE__ */ new Date("2010-12-31")
4710
- );
6121
+ function generateRandomApplicant(rng) {
6122
+ const { firstname, surname } = generateRandomName(rng);
6123
+ const randomDob = getRandomDate(rng, "1990-01-01", "2010-12-31");
4711
6124
  return {
4712
6125
  "recommender.none": true,
4713
- "applicant.firstname": randomFirstName,
4714
- "applicant.surname": randomSurname,
6126
+ "applicant.name": {
6127
+ firstname,
6128
+ surname
6129
+ },
4715
6130
  "applicant.dob": randomDob
4716
6131
  };
4717
6132
  }
4718
- var eventQueryDataGenerator = (overrides = {}) => ({
4719
- id: overrides.id ?? getUUID(),
4720
- type: overrides.type ?? "TENNIS_CLUB_MEMBERSHIP",
4721
- status: overrides.status ?? getEventStatus(),
4722
- createdAt: overrides.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
4723
- createdBy: overrides.createdBy ?? getUUID(),
4724
- createdAtLocation: overrides.createdAtLocation ?? getUUID(),
4725
- updatedAtLocation: overrides.updatedAtLocation ?? getUUID(),
4726
- updatedAt: overrides.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
4727
- assignedTo: overrides.assignedTo ?? null,
4728
- updatedBy: overrides.updatedBy ?? getUUID(),
4729
- updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
4730
- flags: [],
4731
- legalStatuses: overrides.legalStatuses ?? {},
4732
- declaration: overrides.declaration ?? getRandomApplicant(),
4733
- trackingId: overrides.trackingId ?? getTrackingId()
4734
- });
6133
+ function createPrng(seed) {
6134
+ const MODULUS = 2 ** 32;
6135
+ const MULTIPLIER = 1664525;
6136
+ const INCREMENT = 1013904223;
6137
+ let state = seed >>> 0;
6138
+ return () => {
6139
+ state = (MULTIPLIER * state + INCREMENT) % MODULUS;
6140
+ return state / MODULUS;
6141
+ };
6142
+ }
6143
+ function generateUuid(rng) {
6144
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
6145
+ const r = Math.floor(rng() * 16);
6146
+ const v = c === "x" ? r : r & 3 | 8;
6147
+ return v.toString(16);
6148
+ });
6149
+ }
6150
+ function generateTrackingId(rng) {
6151
+ const uuid = generateUuid(rng).replace(/-/g, "");
6152
+ const trackingId = uuid.slice(0, 6).toUpperCase();
6153
+ return trackingId;
6154
+ }
6155
+ function generateRandomSignature(rng) {
6156
+ return `/random-bucket/${generateUuid(rng)}.png`;
6157
+ }
6158
+ var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
6159
+ const rng = createPrng(seed);
6160
+ const createdAt = getRandomDatetime(
6161
+ rng,
6162
+ /* @__PURE__ */ new Date("2024-01-01"),
6163
+ /* @__PURE__ */ new Date("2024-12-31")
6164
+ );
6165
+ return {
6166
+ id: overrides.id ?? generateUuid(rng),
6167
+ type: overrides.type ?? TENNIS_CLUB_MEMBERSHIP,
6168
+ status: overrides.status ?? pickRandom(rng, EventStatus.options),
6169
+ createdAt: overrides.createdAt ?? createdAt,
6170
+ createdBy: overrides.createdBy ?? generateUuid(rng),
6171
+ createdAtLocation: overrides.createdAtLocation ?? generateUuid(rng),
6172
+ updatedAtLocation: overrides.updatedAtLocation ?? generateUuid(rng),
6173
+ createdBySignature: overrides.createdBySignature ?? generateRandomSignature(rng),
6174
+ updatedAt: overrides.updatedAt ?? (0, import_addDays.default)(new Date(createdAt), 1).toISOString(),
6175
+ assignedTo: overrides.assignedTo ?? null,
6176
+ updatedBy: overrides.updatedBy ?? generateUuid(rng),
6177
+ updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
6178
+ flags: [],
6179
+ legalStatuses: overrides.legalStatuses ?? {},
6180
+ declaration: overrides.declaration ?? generateRandomApplicant(rng),
6181
+ trackingId: overrides.trackingId ?? generateTrackingId(rng)
6182
+ };
6183
+ };
4735
6184
  var generateTranslationConfig = (message) => ({
4736
6185
  defaultMessage: message,
4737
6186
  description: "Description for ${message}",
4738
6187
  id: message
4739
6188
  });
6189
+ var BearerTokenByUserType = {
6190
+ fieldAgent: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJyZWNvcmQuZGVjbGFyZS1iaXJ0aCIsInJlY29yZC5kZWNsYXJlLWRlYXRoIiwicmVjb3JkLmRlY2xhcmUtbWFycmlhZ2UiLCJyZWNvcmQuZGVjbGFyYXRpb24tc3VibWl0LWluY29tcGxldGUiLCJyZWNvcmQuZGVjbGFyYXRpb24tc3VibWl0LWZvci1yZXZpZXciLCJzZWFyY2guYmlydGgiLCJzZWFyY2guZGVhdGgiLCJzZWFyY2gubWFycmlhZ2UiLCJkZW1vIl0sInVzZXJUeXBlIjoidXNlciIsImlhdCI6MTc0ODUyNjQ4OCwiZXhwIjoxNzQ5MTMxMjg4LCJhdWQiOlsib3BlbmNydnM6YXV0aC11c2VyIiwib3BlbmNydnM6dXNlci1tZ250LXVzZXIiLCJvcGVuY3J2czpoZWFydGgtdXNlciIsIm9wZW5jcnZzOmdhdGV3YXktdXNlciIsIm9wZW5jcnZzOm5vdGlmaWNhdGlvbi11c2VyIiwib3BlbmNydnM6d29ya2Zsb3ctdXNlciIsIm9wZW5jcnZzOnNlYXJjaC11c2VyIiwib3BlbmNydnM6bWV0cmljcy11c2VyIiwib3BlbmNydnM6Y291bnRyeWNvbmZpZy11c2VyIiwib3BlbmNydnM6d2ViaG9va3MtdXNlciIsIm9wZW5jcnZzOmNvbmZpZy11c2VyIiwib3BlbmNydnM6ZG9jdW1lbnRzLXVzZXIiXSwiaXNzIjoib3BlbmNydnM6YXV0aC1zZXJ2aWNlIiwic3ViIjoiNjc3ZmIwODYzMGYzYWJmYTMzMDcyNzBmIn0.qLif2TmTPpqfbSUWR3TSfWf5syyCtRRJV-fDOZBtN9th-gdT0sUPZp5PB_t2QHHCLes7JLDlSA9CGNIbVvRR8a7EedXTAf0T7pwiE96PgljHSKI9jLMCYb_rhqnl8BwfsxAU3qv8EBYM9rDlcabl5iKnAOM-YLMv63CRMQxZOZ0O3Wl1Xil82dp6PqW_Lom5Qd-Esftt9BWXk5gxmqq-YegT8qU9n3hDXEsOvmIyYQvPDwmUOB-xp74CKJk_o3eBuq4TVCMYxY-tS9qkkn2A7Txhh-bzWMVNrQjQ1Yumvs8gi_F-XYTi89QbZVz8PzJ9kT8w3jshYwmAy7be9M-EQg",
6191
+ registrationAgent: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJyZWNvcmQucmVhZCIsInJlY29yZC5kZWNsYXJlLWJpcnRoIiwicmVjb3JkLmRlY2xhcmUtZGVhdGgiLCJyZWNvcmQuZGVjbGFyZS1tYXJyaWFnZSIsInJlY29yZC5kZWNsYXJhdGlvbi1lZGl0IiwicmVjb3JkLmRlY2xhcmF0aW9uLXN1Ym1pdC1mb3ItYXBwcm92YWwiLCJyZWNvcmQuZGVjbGFyYXRpb24tc3VibWl0LWZvci11cGRhdGVzIiwicmVjb3JkLmRlY2xhcmF0aW9uLWFyY2hpdmUiLCJyZWNvcmQuZGVjbGFyYXRpb24tcmVpbnN0YXRlIiwicmVjb3JkLnJlZ2lzdHJhdGlvbi1yZXF1ZXN0LWNvcnJlY3Rpb24iLCJyZWNvcmQuZGVjbGFyYXRpb24tcHJpbnQtc3VwcG9ydGluZy1kb2N1bWVudHMiLCJyZWNvcmQuZXhwb3J0LXJlY29yZHMiLCJyZWNvcmQucmVnaXN0cmF0aW9uLXByaW50Jmlzc3VlLWNlcnRpZmllZC1jb3BpZXMiLCJwZXJmb3JtYW5jZS5yZWFkIiwicGVyZm9ybWFuY2UucmVhZC1kYXNoYm9hcmRzIiwib3JnYW5pc2F0aW9uLnJlYWQtbG9jYXRpb25zOm15LW9mZmljZSIsInNlYXJjaC5iaXJ0aCIsInNlYXJjaC5kZWF0aCIsInNlYXJjaC5tYXJyaWFnZSIsImRlbW8iXSwidXNlclR5cGUiOiJ1c2VyIiwiaWF0IjoxNzQ4NTI2NDY4LCJleHAiOjE3NDkxMzEyNjgsImF1ZCI6WyJvcGVuY3J2czphdXRoLXVzZXIiLCJvcGVuY3J2czp1c2VyLW1nbnQtdXNlciIsIm9wZW5jcnZzOmhlYXJ0aC11c2VyIiwib3BlbmNydnM6Z2F0ZXdheS11c2VyIiwib3BlbmNydnM6bm90aWZpY2F0aW9uLXVzZXIiLCJvcGVuY3J2czp3b3JrZmxvdy11c2VyIiwib3BlbmNydnM6c2VhcmNoLXVzZXIiLCJvcGVuY3J2czptZXRyaWNzLXVzZXIiLCJvcGVuY3J2czpjb3VudHJ5Y29uZmlnLXVzZXIiLCJvcGVuY3J2czp3ZWJob29rcy11c2VyIiwib3BlbmNydnM6Y29uZmlnLXVzZXIiLCJvcGVuY3J2czpkb2N1bWVudHMtdXNlciJdLCJpc3MiOiJvcGVuY3J2czphdXRoLXNlcnZpY2UiLCJzdWIiOiI2NzdmYjA4NjMwZjNhYmZhMzMwNzI3MTgifQ.C0R3cda9tczdJyadyJzk_wjVx79yiQ4r2BZbrF5VMTol97CwqMk1cPKVv5xZR1fHW5nhYl1X_vsmTYx-p9oSmcAYVud-4Z24TrA3oZ214zCB8RW_RmmFzJSczwe-9Son-96JOpRJTz2F-F_SSmblF0cjndJ-iXCAbOn1hmQ1q45NqaV-oFaFWigvAaRoBFcEvGufQxss_NjRmG12ooENSfWQl0tYM9BmTw4JQo2xerwJcgaJTrtDgRagkuiR7zhVNjcoT64AQiSRp5KmWRhbU4ozlJ2tfy1ccD9jJkbQTf1AZT2pl1diusjstJYFuM9QPFPOyCO0umaxYfgSer_Hmg",
6192
+ localRegistrar: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJyZWNvcmQucmVhZCIsInJlY29yZC5kZWNsYXJlLWJpcnRoIiwicmVjb3JkLmRlY2xhcmUtZGVhdGgiLCJyZWNvcmQuZGVjbGFyZS1tYXJyaWFnZSIsInJlY29yZC5kZWNsYXJhdGlvbi1lZGl0IiwicmVjb3JkLmRlY2xhcmF0aW9uLXN1Ym1pdC1mb3ItdXBkYXRlcyIsInJlY29yZC5yZXZpZXctZHVwbGljYXRlcyIsInJlY29yZC5kZWNsYXJhdGlvbi1hcmNoaXZlIiwicmVjb3JkLmRlY2xhcmF0aW9uLXJlaW5zdGF0ZSIsInJlY29yZC5yZWdpc3RlciIsInJlY29yZC5yZWdpc3RyYXRpb24tY29ycmVjdCIsInJlY29yZC5kZWNsYXJhdGlvbi1wcmludC1zdXBwb3J0aW5nLWRvY3VtZW50cyIsInJlY29yZC5leHBvcnQtcmVjb3JkcyIsInJlY29yZC51bmFzc2lnbi1vdGhlcnMiLCJyZWNvcmQucmVnaXN0cmF0aW9uLXByaW50Jmlzc3VlLWNlcnRpZmllZC1jb3BpZXMiLCJyZWNvcmQuY29uZmlybS1yZWdpc3RyYXRpb24iLCJyZWNvcmQucmVqZWN0LXJlZ2lzdHJhdGlvbiIsInBlcmZvcm1hbmNlLnJlYWQiLCJwZXJmb3JtYW5jZS5yZWFkLWRhc2hib2FyZHMiLCJwcm9maWxlLmVsZWN0cm9uaWMtc2lnbmF0dXJlIiwib3JnYW5pc2F0aW9uLnJlYWQtbG9jYXRpb25zOm15LW9mZmljZSIsInNlYXJjaC5iaXJ0aCIsInNlYXJjaC5kZWF0aCIsInNlYXJjaC5tYXJyaWFnZSIsImRlbW8iXSwidXNlclR5cGUiOiJ1c2VyIiwiaWF0IjoxNzQ4NTI2NDIwLCJleHAiOjE3NDkxMzEyMjAsImF1ZCI6WyJvcGVuY3J2czphdXRoLXVzZXIiLCJvcGVuY3J2czp1c2VyLW1nbnQtdXNlciIsIm9wZW5jcnZzOmhlYXJ0aC11c2VyIiwib3BlbmNydnM6Z2F0ZXdheS11c2VyIiwib3BlbmNydnM6bm90aWZpY2F0aW9uLXVzZXIiLCJvcGVuY3J2czp3b3JrZmxvdy11c2VyIiwib3BlbmNydnM6c2VhcmNoLXVzZXIiLCJvcGVuY3J2czptZXRyaWNzLXVzZXIiLCJvcGVuY3J2czpjb3VudHJ5Y29uZmlnLXVzZXIiLCJvcGVuY3J2czp3ZWJob29rcy11c2VyIiwib3BlbmNydnM6Y29uZmlnLXVzZXIiLCJvcGVuY3J2czpkb2N1bWVudHMtdXNlciJdLCJpc3MiOiJvcGVuY3J2czphdXRoLXNlcnZpY2UiLCJzdWIiOiI2NzdmYjA4NjMwZjNhYmZhMzMwNzI3MjEifQ.Exwojy_1lsoPmp-kQ79SMWI0eQy8Qt7yO_ynGvb_oIVdqSwTxFkkNr9x4UxhBA-o0P6LkMZ2ELKOlSzBr3PRJ8IQnfMQ7Db8oG8HAPsY8sKqra_L6ryV088NW2e2LqAjoOX0dXRIqYMolUhF_OOuZpHW5K8nvog5SLlnJ1gKysQ1EuWBg2dcKbjkkB16v-9NGz4XHye3vcoZlalyha5OOujzbPhkmr9UGiksSIXFNbanBhkQdt-EJlLX9SXvQ4ACJWPKFb_f4gv8p84jdLiryzQux46zHPpTicZHzg0nZtoKKIH1AyFtqWfBFm4y8qWC3ht9TAk93NAXTfkS0wzxKA"
6193
+ };
6194
+ var generateWorkqueues = (slug = "all-events") => defineWorkqueues([
6195
+ {
6196
+ slug,
6197
+ name: {
6198
+ id: "workqueues.inProgress.title",
6199
+ defaultMessage: slug.charAt(0).toUpperCase() + slug.slice(1).split("-").join(" "),
6200
+ description: "Title of in progress workqueue"
6201
+ },
6202
+ query: {
6203
+ type: "and",
6204
+ clauses: [{ eventType: tennisClubMembershipEvent.id }]
6205
+ },
6206
+ actions: [],
6207
+ icon: "Draft"
6208
+ }
6209
+ ]);
4740
6210
 
4741
6211
  // ../commons/src/events/TemplateConfig.ts
4742
6212
  function isTemplateVariable(value) {
@@ -4749,7 +6219,9 @@ function isFieldValueWithoutTemplates(value) {
4749
6219
  if (isTemplateVariable(value)) {
4750
6220
  return false;
4751
6221
  }
4752
- if (typeof value === "object" && Object.values(value).some((val) => isTemplateVariable(val))) {
6222
+ if (typeof value === "object" && // @todo remove ts-ignore
6223
+ //@ts-ignore
6224
+ Object.values(value).some((val) => isTemplateVariable(val))) {
4753
6225
  return false;
4754
6226
  }
4755
6227
  return true;
@@ -4774,7 +6246,7 @@ function isFieldConfigDefaultValue(value) {
4774
6246
  var import_lodash3 = require("lodash");
4775
6247
 
4776
6248
  // ../commons/src/scopes.ts
4777
- var import_zod25 = require("zod");
6249
+ var import_zod31 = require("zod");
4778
6250
  var SCOPES = {
4779
6251
  // TODO v1.8 legacy scopes
4780
6252
  NATLSYSADMIN: "natlsysadmin",
@@ -4798,6 +6270,8 @@ var SCOPES = {
4798
6270
  */
4799
6271
  RECORD_DECLARE: "record.declare-birth",
4800
6272
  // declare
6273
+ RECORD_IMPORT: "record.import",
6274
+ // declare
4801
6275
  RECORD_DECLARE_BIRTH: "record.declare-birth",
4802
6276
  RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
4803
6277
  RECORD_DECLARE_DEATH: "record.declare-death",
@@ -4885,107 +6359,119 @@ var SCOPES = {
4885
6359
  // data seeding
4886
6360
  USER_DATA_SEEDING: "user.data-seeding"
4887
6361
  };
4888
- var LiteralScopes = import_zod25.z.union([
4889
- import_zod25.z.literal(SCOPES.NATLSYSADMIN),
4890
- import_zod25.z.literal(SCOPES.BYPASSRATELIMIT),
4891
- import_zod25.z.literal(SCOPES.DECLARE),
4892
- import_zod25.z.literal(SCOPES.REGISTER),
4893
- import_zod25.z.literal(SCOPES.VALIDATE),
4894
- import_zod25.z.literal(SCOPES.DEMO),
4895
- import_zod25.z.literal(SCOPES.CERTIFY),
4896
- import_zod25.z.literal(SCOPES.PERFORMANCE),
4897
- import_zod25.z.literal(SCOPES.SYSADMIN),
4898
- import_zod25.z.literal(SCOPES.TEAMS),
4899
- import_zod25.z.literal(SCOPES.CONFIG),
4900
- import_zod25.z.literal(SCOPES.WEBHOOK),
4901
- import_zod25.z.literal(SCOPES.NATIONALID),
4902
- import_zod25.z.literal(SCOPES.NOTIFICATION_API),
4903
- import_zod25.z.literal(SCOPES.RECORDSEARCH),
4904
- import_zod25.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
4905
- import_zod25.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
4906
- import_zod25.z.literal(SCOPES.RECORD_DECLARE_DEATH),
4907
- import_zod25.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
4908
- import_zod25.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
4909
- import_zod25.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
4910
- import_zod25.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
4911
- import_zod25.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW),
4912
- import_zod25.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS),
4913
- import_zod25.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
4914
- import_zod25.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
4915
- import_zod25.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
4916
- import_zod25.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
4917
- import_zod25.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
4918
- import_zod25.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE),
4919
- import_zod25.z.literal(SCOPES.RECORD_REGISTER),
4920
- import_zod25.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
4921
- import_zod25.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
4922
- import_zod25.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
4923
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
4924
- import_zod25.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
4925
- import_zod25.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
4926
- import_zod25.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
4927
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES),
4928
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
4929
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
4930
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
4931
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
4932
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
4933
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
4934
- import_zod25.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
4935
- import_zod25.z.literal(SCOPES.RECORD_REJECT_REGISTRATION),
4936
- import_zod25.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
4937
- import_zod25.z.literal(SCOPES.SEARCH_BIRTH),
4938
- import_zod25.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
4939
- import_zod25.z.literal(SCOPES.SEARCH_DEATH),
4940
- import_zod25.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
4941
- import_zod25.z.literal(SCOPES.SEARCH_MARRIAGE),
4942
- import_zod25.z.literal(SCOPES.RECORD_READ),
4943
- import_zod25.z.literal(SCOPES.RECORD_READ_AUDIT),
4944
- import_zod25.z.literal(SCOPES.RECORD_READ_COMMENTS),
4945
- import_zod25.z.literal(SCOPES.RECORD_CREATE_COMMENTS),
4946
- import_zod25.z.literal(SCOPES.PROFILE_UPDATE),
4947
- import_zod25.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE),
4948
- import_zod25.z.literal(SCOPES.PERFORMANCE_READ),
4949
- import_zod25.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
4950
- import_zod25.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS),
4951
- import_zod25.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
4952
- import_zod25.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
4953
- import_zod25.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION),
4954
- import_zod25.z.literal(SCOPES.USER_READ),
4955
- import_zod25.z.literal(SCOPES.USER_READ_MY_OFFICE),
4956
- import_zod25.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
4957
- import_zod25.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
4958
- import_zod25.z.literal(SCOPES.USER_CREATE),
4959
- import_zod25.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
4960
- import_zod25.z.literal(SCOPES.USER_UPDATE),
4961
- import_zod25.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION),
4962
- import_zod25.z.literal(SCOPES.CONFIG_UPDATE_ALL),
4963
- import_zod25.z.literal(SCOPES.USER_DATA_SEEDING)
6362
+ var LiteralScopes = import_zod31.z.union([
6363
+ import_zod31.z.literal(SCOPES.NATLSYSADMIN),
6364
+ import_zod31.z.literal(SCOPES.BYPASSRATELIMIT),
6365
+ import_zod31.z.literal(SCOPES.DECLARE),
6366
+ import_zod31.z.literal(SCOPES.REGISTER),
6367
+ import_zod31.z.literal(SCOPES.VALIDATE),
6368
+ import_zod31.z.literal(SCOPES.DEMO),
6369
+ import_zod31.z.literal(SCOPES.CERTIFY),
6370
+ import_zod31.z.literal(SCOPES.PERFORMANCE),
6371
+ import_zod31.z.literal(SCOPES.SYSADMIN),
6372
+ import_zod31.z.literal(SCOPES.TEAMS),
6373
+ import_zod31.z.literal(SCOPES.CONFIG),
6374
+ import_zod31.z.literal(SCOPES.WEBHOOK),
6375
+ import_zod31.z.literal(SCOPES.NATIONALID),
6376
+ import_zod31.z.literal(SCOPES.NOTIFICATION_API),
6377
+ import_zod31.z.literal(SCOPES.RECORDSEARCH),
6378
+ import_zod31.z.literal(SCOPES.RECORD_IMPORT),
6379
+ import_zod31.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
6380
+ import_zod31.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
6381
+ import_zod31.z.literal(SCOPES.RECORD_DECLARE_DEATH),
6382
+ import_zod31.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
6383
+ import_zod31.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
6384
+ import_zod31.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
6385
+ import_zod31.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
6386
+ import_zod31.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW),
6387
+ import_zod31.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS),
6388
+ import_zod31.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
6389
+ import_zod31.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
6390
+ import_zod31.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
6391
+ import_zod31.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
6392
+ import_zod31.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
6393
+ import_zod31.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE),
6394
+ import_zod31.z.literal(SCOPES.RECORD_REGISTER),
6395
+ import_zod31.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
6396
+ import_zod31.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
6397
+ import_zod31.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
6398
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
6399
+ import_zod31.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
6400
+ import_zod31.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
6401
+ import_zod31.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
6402
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES),
6403
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
6404
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
6405
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
6406
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
6407
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
6408
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
6409
+ import_zod31.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
6410
+ import_zod31.z.literal(SCOPES.RECORD_REJECT_REGISTRATION),
6411
+ import_zod31.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
6412
+ import_zod31.z.literal(SCOPES.SEARCH_BIRTH),
6413
+ import_zod31.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
6414
+ import_zod31.z.literal(SCOPES.SEARCH_DEATH),
6415
+ import_zod31.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
6416
+ import_zod31.z.literal(SCOPES.SEARCH_MARRIAGE),
6417
+ import_zod31.z.literal(SCOPES.RECORD_READ),
6418
+ import_zod31.z.literal(SCOPES.RECORD_READ_AUDIT),
6419
+ import_zod31.z.literal(SCOPES.RECORD_READ_COMMENTS),
6420
+ import_zod31.z.literal(SCOPES.RECORD_CREATE_COMMENTS),
6421
+ import_zod31.z.literal(SCOPES.PROFILE_UPDATE),
6422
+ import_zod31.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE),
6423
+ import_zod31.z.literal(SCOPES.PERFORMANCE_READ),
6424
+ import_zod31.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
6425
+ import_zod31.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS),
6426
+ import_zod31.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
6427
+ import_zod31.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
6428
+ import_zod31.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION),
6429
+ import_zod31.z.literal(SCOPES.USER_READ),
6430
+ import_zod31.z.literal(SCOPES.USER_READ_MY_OFFICE),
6431
+ import_zod31.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
6432
+ import_zod31.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
6433
+ import_zod31.z.literal(SCOPES.USER_CREATE),
6434
+ import_zod31.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
6435
+ import_zod31.z.literal(SCOPES.USER_UPDATE),
6436
+ import_zod31.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION),
6437
+ import_zod31.z.literal(SCOPES.CONFIG_UPDATE_ALL),
6438
+ import_zod31.z.literal(SCOPES.USER_DATA_SEEDING)
4964
6439
  ]);
4965
- var rawConfigurableScopeRegex = /^([a-zA-Z]+\.[a-zA-Z]+)\[((?:\w+=\w+(?:\|\w+)*)(:?,\w+=\w+(?:\|\w+)*)*)\]$/;
4966
- var rawConfigurableScope = import_zod25.z.string().regex(rawConfigurableScopeRegex);
4967
- var CreateUserScope = import_zod25.z.object({
4968
- type: import_zod25.z.literal("user.create"),
4969
- options: import_zod25.z.object({
4970
- role: import_zod25.z.array(import_zod25.z.string())
6440
+ var rawConfigurableScopeRegex = /^([a-zA-Z\.]+)\[((?:\w+=[\w.-]+(?:\|[\w.-]+)*)(?:,[\w]+=[\w.-]+(?:\|[\w.-]+)*)*)\]$/;
6441
+ var rawConfigurableScope = import_zod31.z.string().regex(rawConfigurableScopeRegex);
6442
+ var CreateUserScope = import_zod31.z.object({
6443
+ type: import_zod31.z.literal("user.create"),
6444
+ options: import_zod31.z.object({
6445
+ role: import_zod31.z.array(import_zod31.z.string())
4971
6446
  })
4972
6447
  });
4973
- var EditUserScope = import_zod25.z.object({
4974
- type: import_zod25.z.literal("user.edit"),
4975
- options: import_zod25.z.object({
4976
- role: import_zod25.z.array(import_zod25.z.string())
6448
+ var EditUserScope = import_zod31.z.object({
6449
+ type: import_zod31.z.literal("user.edit"),
6450
+ options: import_zod31.z.object({
6451
+ role: import_zod31.z.array(import_zod31.z.string())
4977
6452
  })
4978
6453
  });
4979
- var ConfigurableScopes = import_zod25.z.discriminatedUnion("type", [
6454
+ var WorkqueueScope = import_zod31.z.object({
6455
+ type: import_zod31.z.literal("workqueue"),
6456
+ options: import_zod31.z.object({
6457
+ id: import_zod31.z.array(import_zod31.z.string())
6458
+ })
6459
+ });
6460
+ var NotifyRecordScope = import_zod31.z.object({
6461
+ type: import_zod31.z.literal("record.notify"),
6462
+ options: import_zod31.z.object({
6463
+ event: import_zod31.z.array(import_zod31.z.string())
6464
+ })
6465
+ });
6466
+ var ConfigurableScopes = import_zod31.z.discriminatedUnion("type", [
4980
6467
  CreateUserScope,
4981
- EditUserScope
6468
+ EditUserScope,
6469
+ WorkqueueScope,
6470
+ NotifyRecordScope
4982
6471
  ]);
4983
6472
  var scopes = Object.values(SCOPES);
4984
6473
 
4985
6474
  // ../commons/src/events/scopes.ts
4986
- function hasAnyOfScopes(a, b) {
4987
- return (0, import_lodash3.intersection)(a, b).length > 0;
4988
- }
4989
6475
  var CONFIG_GET_ALLOWED_SCOPES = [
4990
6476
  SCOPES.RECORD_DECLARE,
4991
6477
  SCOPES.RECORD_READ,
@@ -5043,6 +6529,28 @@ var ACTION_ALLOWED_SCOPES = {
5043
6529
  [ActionType.UNASSIGN]: null,
5044
6530
  [ActionType.DETECT_DUPLICATE]: []
5045
6531
  };
6532
+ var ACTION_ALLOWED_CONFIGURABLE_SCOPES = {
6533
+ [ActionType.READ]: [],
6534
+ [ActionType.CREATE]: ["record.notify"],
6535
+ [ActionType.NOTIFY]: ["record.notify"],
6536
+ [ActionType.DECLARE]: [],
6537
+ [ActionType.DELETE]: [],
6538
+ [ActionType.VALIDATE]: [],
6539
+ [ActionType.REGISTER]: [],
6540
+ [ActionType.PRINT_CERTIFICATE]: [],
6541
+ [ActionType.REQUEST_CORRECTION]: [],
6542
+ [ActionType.REJECT_CORRECTION]: [],
6543
+ [ActionType.APPROVE_CORRECTION]: [],
6544
+ [ActionType.MARKED_AS_DUPLICATE]: [],
6545
+ [ActionType.ARCHIVE]: [],
6546
+ [ActionType.REJECT]: [],
6547
+ [ActionType.ASSIGN]: [],
6548
+ [ActionType.UNASSIGN]: [],
6549
+ [ActionType.DETECT_DUPLICATE]: []
6550
+ };
6551
+ function hasAnyOfScopes(a, b) {
6552
+ return (0, import_lodash3.intersection)(a, b).length > 0;
6553
+ }
5046
6554
  function filterUnallowedActions(actions, userScopes) {
5047
6555
  const allowedActions = actions.filter((action) => {
5048
6556
  const requiredScopes = ACTION_ALLOWED_SCOPES[action];
@@ -5052,10 +6560,74 @@ function filterUnallowedActions(actions, userScopes) {
5052
6560
  return hasAnyOfScopes(userScopes, requiredScopes);
5053
6561
  });
5054
6562
  const hasOtherAllowedActions = allowedActions.some(
5055
- (action) => action !== ActionType.READ && action !== ActionType.ASSIGN && action !== ActionType.UNASSIGN
6563
+ (action) => !isMetaAction(action)
5056
6564
  );
5057
6565
  if (hasOtherAllowedActions) {
5058
6566
  return allowedActions;
5059
6567
  }
5060
6568
  return [ActionType.READ];
5061
6569
  }
6570
+
6571
+ // ../commons/src/events/serializers/user/deserializer.ts
6572
+ var import_zod32 = require("zod");
6573
+ var UserWithPrimaryOffice = User.extend({
6574
+ primaryOfficeId: import_zod32.z.string()
6575
+ });
6576
+ function userDeserializer(serializedUserField, user2) {
6577
+ if (typeof serializedUserField === "string") {
6578
+ return serializedUserField;
6579
+ }
6580
+ if (serializedUserField.$userField === "name" || serializedUserField.$userField === "signatureFilename") {
6581
+ throw new Error(
6582
+ `Deserializer for ${serializedUserField.$userField} is not implemented yet`
6583
+ );
6584
+ }
6585
+ return user2[serializedUserField.$userField];
6586
+ }
6587
+ function deserializeQueryExpression(expression, user2) {
6588
+ return {
6589
+ ...expression,
6590
+ assignedTo: expression.assignedTo && {
6591
+ ...expression.assignedTo,
6592
+ term: userDeserializer(expression.assignedTo.term, user2)
6593
+ },
6594
+ createdBy: expression.createdBy && {
6595
+ ...expression.createdBy,
6596
+ term: userDeserializer(expression.createdBy.term, user2)
6597
+ },
6598
+ updatedBy: expression.updatedBy && {
6599
+ ...expression.updatedBy,
6600
+ term: userDeserializer(expression.updatedBy.term, user2)
6601
+ },
6602
+ createdAtLocation: expression.createdAtLocation && (expression.createdAtLocation.type === "within" ? {
6603
+ ...expression.createdAtLocation,
6604
+ location: userDeserializer(
6605
+ expression.createdAtLocation.location,
6606
+ user2
6607
+ )
6608
+ } : {
6609
+ ...expression.createdAtLocation,
6610
+ term: userDeserializer(expression.createdAtLocation.term, user2)
6611
+ }),
6612
+ updatedAtLocation: expression.updatedAtLocation && (expression.updatedAtLocation.type === "within" ? {
6613
+ ...expression.updatedAtLocation,
6614
+ location: userDeserializer(
6615
+ expression.updatedAtLocation.location,
6616
+ user2
6617
+ )
6618
+ } : {
6619
+ ...expression.updatedAtLocation,
6620
+ term: userDeserializer(expression.updatedAtLocation.term, user2)
6621
+ })
6622
+ };
6623
+ }
6624
+ function deserializeQuery(query, user2) {
6625
+ return {
6626
+ ...query,
6627
+ clauses: query.clauses.map(
6628
+ (clause) => deserializeQueryExpression(clause, user2)
6629
+ // SAFETY: This cast should be safe because `query.clauses` has already been validated as non-empty by the Zod schema.
6630
+ // Without the cast, TypeScript cannot infer the tuple type required by the target interface.
6631
+ )
6632
+ };
6633
+ }