@opencrvs/toolkit 1.8.0-rc.fd16d13 → 1.8.0-rc.fd31705

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +1 -1
  2. package/dist/commons/api/router.d.ts +6304 -12729
  3. package/dist/commons/conditionals/conditionals.d.ts +26 -3
  4. package/dist/commons/conditionals/validate.d.ts +12 -11
  5. package/dist/commons/events/ActionConfig.d.ts +1123 -2056
  6. package/dist/commons/events/ActionDocument.d.ts +8065 -452
  7. package/dist/commons/events/ActionInput.d.ts +3021 -594
  8. package/dist/commons/events/ActionType.d.ts +24 -11
  9. package/dist/commons/events/CompositeFieldValue.d.ts +52 -12
  10. package/dist/commons/events/Conditional.d.ts +21 -5
  11. package/dist/commons/events/Draft.d.ts +145 -61
  12. package/dist/commons/events/EventConfig.d.ts +551 -1206
  13. package/dist/commons/events/EventConfigInput.d.ts +6 -3
  14. package/dist/commons/events/EventDocument.d.ts +1565 -544
  15. package/dist/commons/events/EventIndex.d.ts +6 -3
  16. package/dist/commons/events/EventMetadata.d.ts +3 -0
  17. package/dist/commons/events/FieldConfig.d.ts +483 -76
  18. package/dist/commons/events/FieldType.d.ts +2 -1
  19. package/dist/commons/events/FieldTypeMapping.d.ts +57 -8
  20. package/dist/commons/events/FieldValue.d.ts +30 -10
  21. package/dist/commons/events/FormConfig.d.ts +633 -48
  22. package/dist/commons/events/PageConfig.d.ts +335 -0
  23. package/dist/commons/events/TemplateConfig.d.ts +2 -2
  24. package/dist/commons/events/defineConfig.d.ts +91 -216
  25. package/dist/commons/events/index.d.ts +2 -1
  26. package/dist/commons/events/test.utils.d.ts +87 -268
  27. package/dist/commons/events/utils.d.ts +90 -83
  28. package/dist/conditionals/index.js +166 -81
  29. package/dist/events/index.js +1188 -743
  30. package/package.json +1 -1
@@ -30,20 +30,27 @@ 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: () => Action,
33
34
  ActionBase: () => ActionBase,
34
35
  ActionConditional: () => ActionConditional,
35
36
  ActionConfig: () => ActionConfig,
36
37
  ActionConfigBase: () => ActionConfigBase,
37
38
  ActionDocument: () => ActionDocument,
39
+ ActionFormConfig: () => ActionFormConfig,
38
40
  ActionInput: () => ActionInput,
41
+ ActionStatus: () => ActionStatus,
39
42
  ActionType: () => ActionType,
43
+ ActionTypes: () => ActionTypes,
40
44
  ActionUpdate: () => ActionUpdate,
41
45
  AddressFieldUpdateValue: () => AddressFieldUpdateValue,
42
46
  AddressFieldValue: () => AddressFieldValue,
47
+ AddressType: () => AddressType,
43
48
  AdministrativeAreas: () => AdministrativeAreas,
44
49
  AdvancedSearchConfig: () => AdvancedSearchConfig,
45
50
  ApproveCorrectionActionInput: () => ApproveCorrectionActionInput,
46
51
  ArchiveActionInput: () => ArchiveActionInput,
52
+ AssignActionInput: () => AssignActionInput,
53
+ AsyncRejectActionDocument: () => AsyncRejectActionDocument,
47
54
  BaseActionInput: () => BaseActionInput,
48
55
  CertificateConfig: () => CertificateConfig,
49
56
  CertificateTemplateConfig: () => CertificateTemplateConfig,
@@ -51,9 +58,18 @@ __export(events_exports, {
51
58
  Clause: () => Clause,
52
59
  Conditional: () => Conditional,
53
60
  ConditionalType: () => ConditionalType,
61
+ ConfirmableActions: () => ConfirmableActions,
62
+ DataEntry: () => DataEntry,
63
+ DataFieldValue: () => DataFieldValue,
54
64
  DateValue: () => DateValue,
65
+ DeclarationActionConfig: () => DeclarationActionConfig,
66
+ DeclarationActions: () => DeclarationActions,
67
+ DeclarationFormConfig: () => DeclarationFormConfig,
68
+ DeclarationReviewConfig: () => DeclarationReviewConfig,
69
+ DeclarationUpdateActions: () => DeclarationUpdateActions,
55
70
  DeclareActionInput: () => DeclareActionInput,
56
71
  DeduplicationConfig: () => DeduplicationConfig,
72
+ DisplayOnReviewConditional: () => DisplayOnReviewConditional,
57
73
  Draft: () => Draft,
58
74
  DraftInput: () => DraftInput,
59
75
  EmailField: () => EmailField,
@@ -67,6 +83,7 @@ __export(events_exports, {
67
83
  EventSearchIndex: () => EventSearchIndex,
68
84
  EventStatus: () => EventStatus,
69
85
  EventStatuses: () => EventStatuses,
86
+ FieldConditional: () => FieldConditional,
70
87
  FieldConfig: () => FieldConfig,
71
88
  FieldType: () => FieldType,
72
89
  FieldUpdateValue: () => FieldUpdateValue,
@@ -75,15 +92,21 @@ __export(events_exports, {
75
92
  FileFieldValueWithOption: () => FileFieldValueWithOption,
76
93
  FileFieldWithOptionValue: () => FileFieldWithOptionValue,
77
94
  FormConfig: () => FormConfig,
78
- FormPage: () => FormPage,
95
+ FormPageConfig: () => FormPageConfig,
79
96
  GenericAddressUpdateValue: () => GenericAddressUpdateValue,
80
97
  GenericAddressValue: () => GenericAddressValue,
81
98
  GeographicalArea: () => GeographicalArea,
99
+ ImageMimeType: () => ImageMimeType,
82
100
  LanguageConfig: () => LanguageConfig,
83
101
  MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
102
+ MimeType: () => MimeType,
84
103
  NotifyActionInput: () => NotifyActionInput,
85
104
  NumberFieldValue: () => NumberFieldValue,
105
+ PageConfig: () => PageConfig,
106
+ PageTypes: () => PageTypes,
86
107
  PrintCertificateActionInput: () => PrintCertificateActionInput,
108
+ ReadActionInput: () => ReadActionInput,
109
+ RegisterAction: () => RegisterAction,
87
110
  RegisterActionInput: () => RegisterActionInput,
88
111
  RejectCorrectionActionInput: () => RejectCorrectionActionInput,
89
112
  RejectDeclarationActionInput: () => RejectDeclarationActionInput,
@@ -96,21 +119,29 @@ __export(events_exports, {
96
119
  SummaryConfig: () => SummaryConfig,
97
120
  TextValue: () => TextValue,
98
121
  TranslationConfig: () => TranslationConfig,
122
+ UnassignActionInput: () => UnassignActionInput,
99
123
  UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
100
124
  UrbanAddressValue: () => UrbanAddressValue,
101
125
  ValidateActionInput: () => ValidateActionInput,
126
+ VerificationActionConfig: () => VerificationActionConfig,
127
+ VerificationPageConfig: () => VerificationPageConfig,
102
128
  WorkqueueConfig: () => WorkqueueConfig,
103
129
  alwaysTrue: () => alwaysTrue,
104
130
  and: () => and,
131
+ annotationActions: () => annotationActions,
105
132
  applyDraftsToEventIndex: () => applyDraftsToEventIndex,
106
133
  compositeFieldTypes: () => compositeFieldTypes,
107
134
  createEmptyDraft: () => createEmptyDraft,
108
135
  createValidationSchema: () => createValidationSchema,
109
136
  deepDropNulls: () => deepDropNulls,
137
+ deepMerge: () => deepMerge,
138
+ defineActionForm: () => defineActionForm,
110
139
  defineConditional: () => defineConditional,
111
140
  defineConfig: () => defineConfig,
112
- defineForm: () => defineForm,
141
+ defineDeclarationForm: () => defineDeclarationForm,
142
+ defineFormConditional: () => defineFormConditional,
113
143
  defineFormPage: () => defineFormPage,
144
+ definePage: () => definePage,
114
145
  errorMessages: () => errorMessages,
115
146
  event: () => event,
116
147
  eventMetadataLabelMap: () => eventMetadataLabelMap,
@@ -119,38 +150,42 @@ __export(events_exports, {
119
150
  eventStatuses: () => eventStatuses,
120
151
  field: () => field,
121
152
  fieldTypes: () => fieldTypes,
122
- findActiveActionFields: () => findActiveActionFields,
123
- findActiveActionForm: () => findActiveActionForm,
124
- findActiveActionFormFields: () => findActiveActionFormFields,
125
- findActiveActionFormPages: () => findActiveActionFormPages,
126
153
  findActiveDrafts: () => findActiveDrafts,
127
- findInputPageFields: () => findInputPageFields,
128
- findPageFields: () => findPageFields,
154
+ findAllFields: () => findAllFields,
155
+ findRecordActionPages: () => findRecordActionPages,
129
156
  generateActionDocument: () => generateActionDocument,
130
157
  generateActionInput: () => generateActionInput,
158
+ generateActionMetadataInput: () => generateActionMetadataInput,
131
159
  generateEventDocument: () => generateEventDocument,
132
160
  generateEventDraftDocument: () => generateEventDraftDocument,
133
161
  generateTransactionId: () => generateTransactionId,
134
- getActiveActionFields: () => getActiveActionFields,
135
- getActiveActionFormPages: () => getActiveActionFormPages,
136
- getAllFields: () => getAllFields,
137
- getAllPages: () => getAllPages,
162
+ generateTranslationConfig: () => generateTranslationConfig,
163
+ getAcceptedActions: () => getAcceptedActions,
164
+ getActionAnnotation: () => getActionAnnotation,
165
+ getActionAnnotationFields: () => getActionAnnotationFields,
166
+ getActionReview: () => getActionReview,
167
+ getActionReviewFields: () => getActionReviewFields,
168
+ getAllAnnotationFields: () => getAllAnnotationFields,
169
+ getAnnotationFromDrafts: () => getAnnotationFromDrafts,
138
170
  getCurrentEventState: () => getCurrentEventState,
139
171
  getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
140
- getEventConfiguration: () => getEventConfiguration,
172
+ getDeclaration: () => getDeclaration,
173
+ getDeclarationFields: () => getDeclarationFields,
174
+ getDeclarationPages: () => getDeclarationPages,
141
175
  getFieldValidationErrors: () => getFieldValidationErrors,
142
- getFormFields: () => getFormFields,
143
- getMetadataForAction: () => getMetadataForAction,
176
+ getVisiblePagesFormFields: () => getVisiblePagesFormFields,
144
177
  isAddressFieldType: () => isAddressFieldType,
145
178
  isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
146
179
  isBulletListFieldType: () => isBulletListFieldType,
147
180
  isCheckboxFieldType: () => isCheckboxFieldType,
148
181
  isCountryFieldType: () => isCountryFieldType,
182
+ isDataFieldType: () => isDataFieldType,
149
183
  isDateFieldType: () => isDateFieldType,
150
184
  isDividerFieldType: () => isDividerFieldType,
151
185
  isEmailFieldType: () => isEmailFieldType,
152
186
  isFacilityFieldType: () => isFacilityFieldType,
153
187
  isFieldConfigDefaultValue: () => isFieldConfigDefaultValue,
188
+ isFieldDisplayedOnReview: () => isFieldDisplayedOnReview,
154
189
  isFieldEnabled: () => isFieldEnabled,
155
190
  isFieldValue: () => isFieldValue,
156
191
  isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
@@ -161,6 +196,7 @@ __export(events_exports, {
161
196
  isNumberFieldType: () => isNumberFieldType,
162
197
  isOfficeFieldType: () => isOfficeFieldType,
163
198
  isPageHeaderFieldType: () => isPageHeaderFieldType,
199
+ isPageVisible: () => isPageVisible,
164
200
  isParagraphFieldType: () => isParagraphFieldType,
165
201
  isRadioGroupFieldType: () => isRadioGroupFieldType,
166
202
  isSelectFieldType: () => isSelectFieldType,
@@ -169,12 +205,13 @@ __export(events_exports, {
169
205
  isTextAreaFieldType: () => isTextAreaFieldType,
170
206
  isTextFieldType: () => isTextFieldType,
171
207
  isUndeclaredDraft: () => isUndeclaredDraft,
208
+ isVerificationPage: () => isVerificationPage,
172
209
  mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
173
210
  mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
174
211
  mapFieldTypeToZod: () => mapFieldTypeToZod,
212
+ never: () => never,
175
213
  not: () => not,
176
214
  or: () => or,
177
- resolveLabelsFromKnownFields: () => resolveLabelsFromKnownFields,
178
215
  stripHiddenFields: () => stripHiddenFields,
179
216
  user: () => user,
180
217
  validate: () => validate,
@@ -184,35 +221,52 @@ __export(events_exports, {
184
221
  module.exports = __toCommonJS(events_exports);
185
222
 
186
223
  // ../commons/src/events/ActionConfig.ts
187
- var import_zod7 = require("zod");
224
+ var import_zod9 = require("zod");
188
225
 
189
226
  // ../commons/src/events/Conditional.ts
190
227
  var import_zod = require("zod");
191
- function Conditional() {
192
- return import_zod.z.custom((val) => typeof val === "object" && val !== null);
193
- }
228
+ var Conditional = import_zod.z.custom(
229
+ (val) => typeof val === "object" && val !== null
230
+ );
194
231
  var ConditionalType = {
195
- /** When 'SHOW' conditional is defined, the action is shown to the user only if the condition is met */
196
232
  SHOW: "SHOW",
197
- /** If 'ENABLE' conditional is defined, the action is enabled only if the condition is met */
198
- ENABLE: "ENABLE"
233
+ ENABLE: "ENABLE",
234
+ DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
199
235
  };
200
236
  var ShowConditional = import_zod.z.object({
201
237
  type: import_zod.z.literal(ConditionalType.SHOW),
202
- conditional: Conditional()
203
- });
238
+ conditional: Conditional
239
+ }).describe(
240
+ "If 'SHOW' conditional is defined, the component is shown to the user only if the condition is met"
241
+ );
204
242
  var EnableConditional = import_zod.z.object({
205
243
  type: import_zod.z.literal(ConditionalType.ENABLE),
206
- conditional: Conditional()
207
- });
244
+ conditional: Conditional
245
+ }).describe(
246
+ "If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
247
+ );
208
248
  var ActionConditional = import_zod.z.discriminatedUnion("type", [
209
249
  // Action can be shown / hidden
210
250
  ShowConditional,
211
251
  // Action can be shown to the user in the list but as disabled
212
252
  EnableConditional
213
253
  ]);
254
+ var DisplayOnReviewConditional = import_zod.z.object({
255
+ type: import_zod.z.literal(ConditionalType.DISPLAY_ON_REVIEW),
256
+ conditional: Conditional
257
+ }).describe(
258
+ "If 'DISPLAY_ON_REVIEW' conditional is defined, the component is shown on the review page only if both the 'DISPLAY_ON_REVIEW' and 'SHOW' conditions are met. This should only be used for fields within declaration forms, as they are the only ones with review pages."
259
+ );
260
+ var FieldConditional = import_zod.z.discriminatedUnion("type", [
261
+ // Field input can be shown / hidden
262
+ ShowConditional,
263
+ // Field input can be shown to the user but as disabled
264
+ EnableConditional,
265
+ // Field output can be shown / hidden on the review page
266
+ DisplayOnReviewConditional
267
+ ]);
214
268
 
215
- // ../commons/src/events/FormConfig.ts
269
+ // ../commons/src/events/PageConfig.ts
216
270
  var import_zod6 = require("zod");
217
271
 
218
272
  // ../commons/src/events/FieldConfig.ts
@@ -253,7 +307,8 @@ var FieldType = {
253
307
  ADMINISTRATIVE_AREA: "ADMINISTRATIVE_AREA",
254
308
  FACILITY: "FACILITY",
255
309
  OFFICE: "OFFICE",
256
- SIGNATURE: "SIGNATURE"
310
+ SIGNATURE: "SIGNATURE",
311
+ DATA: "DATA"
257
312
  };
258
313
  var fieldTypes = Object.values(FieldType);
259
314
  var compositeFieldTypes = [
@@ -271,13 +326,18 @@ var GeographicalArea = {
271
326
  URBAN: "URBAN",
272
327
  RURAL: "RURAL"
273
328
  };
329
+ var AddressType = {
330
+ DOMESTIC: "DOMESTIC",
331
+ INTERNATIONAL: "INTERNATIONAL"
332
+ };
274
333
  var FileFieldValue = import_zod3.z.object({
275
334
  filename: import_zod3.z.string(),
276
335
  originalFilename: import_zod3.z.string(),
277
336
  type: import_zod3.z.string()
278
337
  });
279
338
  var AdminStructure = import_zod3.z.object({
280
- country: import_zod3.z.literal(process.env.country || "FAR"),
339
+ country: import_zod3.z.string(),
340
+ addressType: import_zod3.z.literal(AddressType.DOMESTIC),
281
341
  province: import_zod3.z.string(),
282
342
  district: import_zod3.z.string()
283
343
  });
@@ -306,7 +366,8 @@ var RuralAddressUpdateValue = AdminStructure.extend({
306
366
  village: import_zod3.z.string().nullish()
307
367
  });
308
368
  var GenericAddressValue = import_zod3.z.object({
309
- country: import_zod3.z.string().refine((value) => value !== process.env.country || "FAR"),
369
+ country: import_zod3.z.string(),
370
+ addressType: import_zod3.z.literal(AddressType.INTERNATIONAL),
310
371
  state: import_zod3.z.string(),
311
372
  district2: import_zod3.z.string(),
312
373
  cityOrTown: import_zod3.z.string().optional(),
@@ -317,7 +378,8 @@ var GenericAddressValue = import_zod3.z.object({
317
378
  });
318
379
  var AddressFieldValue = import_zod3.z.discriminatedUnion("urbanOrRural", [UrbanAddressValue, RuralAddressValue]).or(GenericAddressValue);
319
380
  var GenericAddressUpdateValue = import_zod3.z.object({
320
- country: import_zod3.z.string().refine((value) => value !== process.env.country || "FAR"),
381
+ country: import_zod3.z.string(),
382
+ addressType: import_zod3.z.literal(AddressType.INTERNATIONAL),
321
383
  state: import_zod3.z.string(),
322
384
  district2: import_zod3.z.string(),
323
385
  cityOrTown: import_zod3.z.string().nullish(),
@@ -345,6 +407,7 @@ var DateValue = import_zod4.z.string().date().describe("Date in the format YYYY-
345
407
  var EmailValue = import_zod4.z.string().email();
346
408
  var CheckboxFieldValue = import_zod4.z.boolean();
347
409
  var NumberFieldValue = import_zod4.z.number();
410
+ var DataFieldValue = import_zod4.z.undefined();
348
411
  var FieldValue = import_zod4.z.union([
349
412
  TextValue,
350
413
  DateValue,
@@ -354,6 +417,7 @@ var FieldValue = import_zod4.z.union([
354
417
  FileFieldWithOptionValue,
355
418
  UrbanAddressValue,
356
419
  RuralAddressValue,
420
+ DataFieldValue,
357
421
  GenericAddressValue
358
422
  ]);
359
423
  var FieldUpdateValue = import_zod4.z.union([
@@ -365,6 +429,7 @@ var FieldUpdateValue = import_zod4.z.union([
365
429
  FileFieldWithOptionValue,
366
430
  UrbanAddressUpdateValue,
367
431
  RuralAddressUpdateValue,
432
+ DataFieldValue,
368
433
  GenericAddressUpdateValue
369
434
  ]);
370
435
 
@@ -387,14 +452,14 @@ var BaseField = import_zod5.z.object({
387
452
  ]),
388
453
  DependencyExpression
389
454
  ]).optional(),
390
- conditionals: import_zod5.z.array(ActionConditional).default([]).optional(),
455
+ conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
391
456
  required: import_zod5.z.boolean().default(false).optional(),
392
457
  disabled: import_zod5.z.boolean().default(false).optional(),
393
458
  hidden: import_zod5.z.boolean().default(false).optional(),
394
459
  placeholder: TranslationConfig.optional(),
395
460
  validation: import_zod5.z.array(
396
461
  import_zod5.z.object({
397
- validator: Conditional(),
462
+ validator: Conditional,
398
463
  message: TranslationConfig
399
464
  })
400
465
  ).default([]).optional(),
@@ -436,15 +501,25 @@ var TextAreaField = BaseField.extend({
436
501
  postfix: TranslationConfig.optional()
437
502
  }).default({ rows: 4 }).optional()
438
503
  }).describe("Multiline text input");
504
+ var ImageMimeType = import_zod5.z.enum([
505
+ "image/png",
506
+ "image/jpg",
507
+ "image/jpeg",
508
+ "image/svg+xml"
509
+ ]);
510
+ var MimeType = ImageMimeType;
511
+ var DEFAULT_MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;
439
512
  var SignatureField = BaseField.extend({
440
513
  type: import_zod5.z.literal(FieldType.SIGNATURE),
441
514
  signaturePromptLabel: TranslationConfig.describe(
442
515
  "Title of the signature modal"
443
516
  ),
444
517
  configuration: import_zod5.z.object({
445
- maxSizeMb: import_zod5.z.number().optional().describe("Maximum file size in MB"),
446
- allowedFileFormats: import_zod5.z.array(import_zod5.z.string()).optional().describe("List of allowed file formats for the signature")
447
- }).default({}).optional()
518
+ maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
519
+ acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
520
+ }).default({
521
+ maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
522
+ })
448
523
  }).describe("Signature input field");
449
524
  var EmailField = BaseField.extend({
450
525
  type: import_zod5.z.literal(FieldType.EMAIL),
@@ -487,13 +562,17 @@ var PageHeader = BaseField.extend({
487
562
  }).describe("A read-only header component for form pages");
488
563
  var File = BaseField.extend({
489
564
  type: import_zod5.z.literal(FieldType.FILE),
490
- options: import_zod5.z.object({
565
+ configuration: import_zod5.z.object({
566
+ maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
567
+ acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
491
568
  style: import_zod5.z.object({
492
- fullWidth: import_zod5.z.boolean().describe(
569
+ width: import_zod5.z.enum(["full", "auto"]).optional().describe(
493
570
  "Whether the file upload button should take the full width of the container or not"
494
571
  )
495
- })
496
- }).optional()
572
+ }).optional()
573
+ }).default({
574
+ maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
575
+ })
497
576
  }).describe("File upload");
498
577
  var SelectOption = import_zod5.z.object({
499
578
  value: import_zod5.z.string().describe("The value of the option"),
@@ -539,7 +618,7 @@ var AdministrativeAreas = import_zod5.z.enum([
539
618
  ]);
540
619
  var AdministrativeAreaConfiguration = import_zod5.z.object({
541
620
  partOf: import_zod5.z.object({
542
- $data: import_zod5.z.string()
621
+ $declaration: import_zod5.z.string()
543
622
  }).optional().describe("Parent location"),
544
623
  type: AdministrativeAreas
545
624
  }).describe("Administrative area options");
@@ -554,8 +633,14 @@ var Location = BaseField.extend({
554
633
  }).describe("Input field for a location");
555
634
  var FileUploadWithOptions = BaseField.extend({
556
635
  type: import_zod5.z.literal(FieldType.FILE_WITH_OPTIONS),
557
- options: import_zod5.z.array(SelectOption).describe("A list of options")
558
- }).describe("Select input");
636
+ options: import_zod5.z.array(SelectOption).describe("A list of options"),
637
+ configuration: import_zod5.z.object({
638
+ maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
639
+ acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
640
+ }).default({
641
+ maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
642
+ })
643
+ });
559
644
  var Facility = BaseField.extend({
560
645
  type: import_zod5.z.literal(FieldType.FACILITY),
561
646
  defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
@@ -568,6 +653,22 @@ var Address = BaseField.extend({
568
653
  type: import_zod5.z.literal(FieldType.ADDRESS),
569
654
  defaultValue: AddressFieldValue.optional()
570
655
  }).describe("Address input field \u2013 a combination of location and text fields");
656
+ var DataEntry = import_zod5.z.union([
657
+ import_zod5.z.object({
658
+ label: TranslationConfig,
659
+ value: import_zod5.z.string()
660
+ }),
661
+ import_zod5.z.object({
662
+ fieldId: import_zod5.z.string()
663
+ })
664
+ ]);
665
+ var DataField = BaseField.extend({
666
+ type: import_zod5.z.literal(FieldType.DATA),
667
+ configuration: import_zod5.z.object({
668
+ subtitle: TranslationConfig.optional(),
669
+ data: import_zod5.z.array(DataEntry)
670
+ })
671
+ }).describe("Data field for displaying read-only data");
571
672
  var FieldConfig = import_zod5.z.discriminatedUnion("type", [
572
673
  Address,
573
674
  TextField,
@@ -589,132 +690,204 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
589
690
  Office,
590
691
  SignatureField,
591
692
  EmailField,
592
- FileUploadWithOptions
693
+ FileUploadWithOptions,
694
+ DataField
695
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
593
696
  ]);
594
697
 
595
- // ../commons/src/events/FormConfig.ts
596
- var FormPage = import_zod6.z.object({
698
+ // ../commons/src/events/PageConfig.ts
699
+ var PageTypes = import_zod6.z.enum(["FORM", "VERIFICATION"]);
700
+ var PageConfigBase = import_zod6.z.object({
597
701
  id: import_zod6.z.string().describe("Unique identifier for the page"),
598
702
  title: TranslationConfig.describe("Header title of the page"),
599
- fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page")
703
+ fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page"),
704
+ conditional: Conditional.optional().describe(
705
+ "Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
706
+ )
600
707
  });
601
- var FormConfig = import_zod6.z.object({
602
- label: TranslationConfig.describe("Human readable description of the form"),
603
- version: import_zod6.z.object({
604
- id: import_zod6.z.string().describe(
605
- "Form version. Semantic versioning recommended. Example: 0.0.1"
606
- ),
607
- label: TranslationConfig.describe(
608
- "Human readable description of the version"
609
- )
610
- }),
611
- active: import_zod6.z.boolean().default(false).describe("Whether the form is active"),
612
- pages: import_zod6.z.array(FormPage),
613
- review: import_zod6.z.object({
614
- title: TranslationConfig.describe(
615
- "Title of the form to show in review page"
616
- ),
617
- fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the review page for metadata")
708
+ var FormPageConfig = PageConfigBase.extend({
709
+ type: import_zod6.z.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
710
+ });
711
+ var VerificationActionConfig = import_zod6.z.object({
712
+ verify: import_zod6.z.object({ label: TranslationConfig }),
713
+ cancel: import_zod6.z.object({
714
+ label: TranslationConfig,
715
+ confirmation: import_zod6.z.object({
716
+ title: TranslationConfig,
717
+ body: TranslationConfig
718
+ })
618
719
  })
720
+ }).describe("Actions available on the verification page");
721
+ var VerificationPageConfig = FormPageConfig.extend({
722
+ type: import_zod6.z.literal(PageTypes.enum.VERIFICATION),
723
+ actions: VerificationActionConfig
619
724
  });
725
+ var PageConfig = import_zod6.z.discriminatedUnion("type", [
726
+ FormPageConfig,
727
+ VerificationPageConfig
728
+ ]);
620
729
 
621
730
  // ../commons/src/events/ActionType.ts
731
+ var import_zod7 = require("zod");
622
732
  var ActionType = {
733
+ // Pre-declaration actions
734
+ DELETE: "DELETE",
623
735
  CREATE: "CREATE",
624
- ASSIGN: "ASSIGN",
625
- UNASSIGN: "UNASSIGN",
626
- REGISTER: "REGISTER",
627
- VALIDATE: "VALIDATE",
628
- REQUEST_CORRECTION: "REQUEST_CORRECTION",
629
- REJECT_CORRECTION: "REJECT_CORRECTION",
630
- APPROVE_CORRECTION: "APPROVE_CORRECTION",
631
- DETECT_DUPLICATE: "DETECT_DUPLICATE",
632
736
  NOTIFY: "NOTIFY",
737
+ // Declaration actions
633
738
  DECLARE: "DECLARE",
634
- DELETE: "DELETE",
635
- PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
636
- CUSTOM: "CUSTOM",
739
+ VALIDATE: "VALIDATE",
740
+ REGISTER: "REGISTER",
741
+ // Declaration system actions. Non-configurable.
742
+ DETECT_DUPLICATE: "DETECT_DUPLICATE",
637
743
  REJECT: "REJECT",
744
+ // REJECT_DECLARATION
638
745
  MARKED_AS_DUPLICATE: "MARKED_AS_DUPLICATE",
639
- ARCHIVE: "ARCHIVE"
746
+ // MARK_AS_DUPLICATE
747
+ ARCHIVE: "ARCHIVE",
748
+ // Record actions
749
+ PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
750
+ REQUEST_CORRECTION: "REQUEST_CORRECTION",
751
+ REJECT_CORRECTION: "REJECT_CORRECTION",
752
+ APPROVE_CORRECTION: "APPROVE_CORRECTION",
753
+ // General actions
754
+ READ: "READ",
755
+ ASSIGN: "ASSIGN",
756
+ UNASSIGN: "UNASSIGN"
640
757
  };
758
+ var ConfirmableActions = [
759
+ ActionType.NOTIFY,
760
+ ActionType.DECLARE,
761
+ ActionType.VALIDATE,
762
+ ActionType.REGISTER,
763
+ ActionType.REJECT,
764
+ ActionType.ARCHIVE,
765
+ ActionType.PRINT_CERTIFICATE
766
+ ];
767
+ var ActionTypes = import_zod7.z.enum([
768
+ "DELETE",
769
+ "CREATE",
770
+ "NOTIFY",
771
+ "DECLARE",
772
+ "VALIDATE",
773
+ "REGISTER",
774
+ "DETECT_DUPLICATE",
775
+ "REJECT",
776
+ "MARKED_AS_DUPLICATE",
777
+ "ARCHIVE",
778
+ "PRINT_CERTIFICATE",
779
+ "REQUEST_CORRECTION",
780
+ "REJECT_CORRECTION",
781
+ "APPROVE_CORRECTION",
782
+ "READ",
783
+ "ASSIGN",
784
+ "UNASSIGN"
785
+ ]);
786
+ var declarationActionValues = [
787
+ ActionTypes.enum.DECLARE,
788
+ ActionTypes.enum.VALIDATE,
789
+ ActionTypes.enum.REGISTER
790
+ ];
791
+ var DeclarationActions = ActionTypes.extract(declarationActionValues);
792
+ var declarationUpdateActionValues = [
793
+ ...declarationActionValues,
794
+ ActionTypes.enum.REQUEST_CORRECTION
795
+ ];
796
+ var DeclarationUpdateActions = ActionTypes.extract(
797
+ declarationUpdateActionValues
798
+ );
799
+ var annotationActions = ActionTypes.exclude(declarationActionValues);
800
+
801
+ // ../commons/src/events/FormConfig.ts
802
+ var import_zod8 = require("zod");
803
+ var DeclarationFormConfig = import_zod8.z.object({
804
+ label: TranslationConfig.describe("Human readable description of the form"),
805
+ pages: import_zod8.z.array(FormPageConfig)
806
+ }).describe("Configuration for a declaration form");
807
+ var ActionFormConfig = import_zod8.z.object({
808
+ label: TranslationConfig.describe("Human readable description of the form"),
809
+ pages: import_zod8.z.array(PageConfig)
810
+ });
811
+ var FormConfig = import_zod8.z.union([DeclarationFormConfig, ActionFormConfig]);
641
812
 
642
813
  // ../commons/src/events/ActionConfig.ts
643
- var ActionConditional2 = import_zod7.z.discriminatedUnion("type", [
814
+ var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
644
815
  /** If conditional is defined, the action is shown to the user only if the condition is met */
645
816
  ShowConditional,
646
817
  /** If conditional is defined, the action is enabled only if the condition is met */
647
818
  EnableConditional
648
819
  ]);
649
- var ActionConfigBase = import_zod7.z.object({
820
+ var DeclarationReviewConfig = import_zod9.z.object({
821
+ title: TranslationConfig.describe("Title of the review page"),
822
+ fields: import_zod9.z.array(FieldConfig).describe("Fields to be rendered on the review page for annotations.")
823
+ }).describe("Configuration for **declaration** review page.");
824
+ var ActionConfigBase = import_zod9.z.object({
650
825
  label: TranslationConfig,
651
- conditionals: import_zod7.z.array(ActionConditional2).optional().default([]),
652
- draft: import_zod7.z.boolean().optional(),
653
- forms: import_zod7.z.array(FormConfig)
826
+ conditionals: import_zod9.z.array(ActionConditional2).optional().default([]),
827
+ draft: import_zod9.z.boolean().optional()
654
828
  });
655
829
  var DeclareConfig = ActionConfigBase.merge(
656
- import_zod7.z.object({
657
- type: import_zod7.z.literal(ActionType.DECLARE)
830
+ import_zod9.z.object({
831
+ type: import_zod9.z.literal(ActionType.DECLARE),
832
+ review: DeclarationReviewConfig
658
833
  })
659
834
  );
660
835
  var ValidateConfig = ActionConfigBase.merge(
661
- import_zod7.z.object({
662
- type: import_zod7.z.literal(ActionType.VALIDATE)
836
+ import_zod9.z.object({
837
+ type: import_zod9.z.literal(ActionType.VALIDATE),
838
+ review: DeclarationReviewConfig
839
+ })
840
+ );
841
+ var RegisterConfig = ActionConfigBase.merge(
842
+ import_zod9.z.object({
843
+ type: import_zod9.z.literal(ActionType.REGISTER),
844
+ review: DeclarationReviewConfig
663
845
  })
664
846
  );
665
847
  var RejectDeclarationConfig = ActionConfigBase.merge(
666
- import_zod7.z.object({
667
- type: import_zod7.z.literal(ActionType.REJECT)
848
+ import_zod9.z.object({
849
+ type: import_zod9.z.literal(ActionType.REJECT)
668
850
  })
669
851
  );
670
852
  var MarkedAsDuplicateConfig = ActionConfigBase.merge(
671
- import_zod7.z.object({
672
- type: import_zod7.z.literal(ActionType.MARKED_AS_DUPLICATE)
853
+ import_zod9.z.object({
854
+ type: import_zod9.z.literal(ActionType.MARKED_AS_DUPLICATE)
673
855
  })
674
856
  );
675
857
  var ArchiveConfig = ActionConfigBase.merge(
676
- import_zod7.z.object({
677
- type: import_zod7.z.literal(ActionType.ARCHIVE)
678
- })
679
- );
680
- var RegisterConfig = ActionConfigBase.merge(
681
- import_zod7.z.object({
682
- type: import_zod7.z.literal(ActionType.REGISTER)
858
+ import_zod9.z.object({
859
+ type: import_zod9.z.literal(ActionType.ARCHIVE)
683
860
  })
684
861
  );
685
862
  var DeleteConfig = ActionConfigBase.merge(
686
- import_zod7.z.object({
687
- type: import_zod7.z.literal(ActionType.DELETE)
863
+ import_zod9.z.object({
864
+ type: import_zod9.z.literal(ActionType.DELETE)
688
865
  })
689
866
  );
690
867
  var PrintCertificateActionConfig = ActionConfigBase.merge(
691
- import_zod7.z.object({
692
- type: import_zod7.z.literal(ActionType.PRINT_CERTIFICATE)
868
+ import_zod9.z.object({
869
+ type: import_zod9.z.literal(ActionType.PRINT_CERTIFICATE),
870
+ printForm: ActionFormConfig
693
871
  })
694
872
  );
695
873
  var RequestCorrectionConfig = ActionConfigBase.merge(
696
- import_zod7.z.object({
697
- type: import_zod7.z.literal(ActionType.REQUEST_CORRECTION),
698
- onboardingForm: import_zod7.z.array(FormPage),
699
- additionalDetailsForm: import_zod7.z.array(FormPage)
874
+ import_zod9.z.object({
875
+ type: import_zod9.z.literal(ActionType.REQUEST_CORRECTION),
876
+ onboardingForm: import_zod9.z.array(PageConfig),
877
+ additionalDetailsForm: import_zod9.z.array(PageConfig)
700
878
  })
701
879
  );
702
880
  var RejectCorrectionConfig = ActionConfigBase.merge(
703
- import_zod7.z.object({
704
- type: import_zod7.z.literal(ActionType.REJECT_CORRECTION)
881
+ import_zod9.z.object({
882
+ type: import_zod9.z.literal(ActionType.REJECT_CORRECTION)
705
883
  })
706
884
  );
707
885
  var ApproveCorrectionConfig = ActionConfigBase.merge(
708
- import_zod7.z.object({
709
- type: import_zod7.z.literal(ActionType.APPROVE_CORRECTION)
886
+ import_zod9.z.object({
887
+ type: import_zod9.z.literal(ActionType.APPROVE_CORRECTION)
710
888
  })
711
889
  );
712
- var CustomConfig = ActionConfigBase.merge(
713
- import_zod7.z.object({
714
- type: import_zod7.z.literal(ActionType.CUSTOM)
715
- })
716
- );
717
- var ActionConfig = import_zod7.z.discriminatedUnion("type", [
890
+ var ActionConfig = import_zod9.z.discriminatedUnion("type", [
718
891
  DeclareConfig,
719
892
  ValidateConfig,
720
893
  RejectDeclarationConfig,
@@ -725,102 +898,108 @@ var ActionConfig = import_zod7.z.discriminatedUnion("type", [
725
898
  PrintCertificateActionConfig,
726
899
  RequestCorrectionConfig,
727
900
  RejectCorrectionConfig,
728
- ApproveCorrectionConfig,
729
- CustomConfig
901
+ ApproveCorrectionConfig
902
+ ]);
903
+ var DeclarationActionConfig = import_zod9.z.discriminatedUnion("type", [
904
+ DeclareConfig,
905
+ ValidateConfig,
906
+ RegisterConfig
730
907
  ]);
731
908
 
732
909
  // ../commons/src/events/offline/CertificateConfig.ts
733
- var import_zod8 = require("zod");
734
- var FontFamily = import_zod8.z.object({
735
- normal: import_zod8.z.string(),
736
- bold: import_zod8.z.string(),
737
- italics: import_zod8.z.string(),
738
- bolditalics: import_zod8.z.string()
910
+ var import_zod10 = require("zod");
911
+ var FontFamily = import_zod10.z.object({
912
+ normal: import_zod10.z.string(),
913
+ bold: import_zod10.z.string(),
914
+ italics: import_zod10.z.string(),
915
+ bolditalics: import_zod10.z.string()
739
916
  });
740
- var CertificateConfig = import_zod8.z.object({
741
- id: import_zod8.z.string(),
742
- event: import_zod8.z.string(),
917
+ var CertificateConfig = import_zod10.z.object({
918
+ id: import_zod10.z.string(),
919
+ event: import_zod10.z.string(),
743
920
  label: TranslationConfig,
744
- isDefault: import_zod8.z.boolean(),
745
- fee: import_zod8.z.object({
746
- onTime: import_zod8.z.number(),
747
- late: import_zod8.z.number(),
748
- delayed: import_zod8.z.number()
921
+ isDefault: import_zod10.z.boolean(),
922
+ fee: import_zod10.z.object({
923
+ onTime: import_zod10.z.number(),
924
+ late: import_zod10.z.number(),
925
+ delayed: import_zod10.z.number()
749
926
  }),
750
- svgUrl: import_zod8.z.string(),
751
- fonts: import_zod8.z.record(FontFamily).optional()
927
+ svgUrl: import_zod10.z.string(),
928
+ fonts: import_zod10.z.record(FontFamily).optional()
752
929
  });
753
930
  var CertificateTemplateConfig = CertificateConfig.extend({
754
- hash: import_zod8.z.string().optional(),
755
- svg: import_zod8.z.string()
931
+ hash: import_zod10.z.string().optional(),
932
+ svg: import_zod10.z.string()
756
933
  });
757
934
 
758
935
  // ../commons/src/events/offline/LanguageConfig.ts
759
- var import_zod9 = require("zod");
760
- var LanguageConfig = import_zod9.z.object({
761
- lang: import_zod9.z.string(),
936
+ var import_zod11 = require("zod");
937
+ var LanguageConfig = import_zod11.z.object({
938
+ lang: import_zod11.z.string(),
762
939
  /**
763
940
  * client.csv contents
764
941
  */
765
- messages: import_zod9.z.record(import_zod9.z.string())
942
+ messages: import_zod11.z.record(import_zod11.z.string())
766
943
  });
767
944
 
768
945
  // ../commons/src/events/EventConfig.ts
769
- var import_zod18 = require("zod");
946
+ var import_zod20 = require("zod");
770
947
 
771
948
  // ../commons/src/events/DeduplicationConfig.ts
772
- var import_zod10 = require("zod");
773
- var FieldReference = import_zod10.z.string();
774
- var Matcher = import_zod10.z.object({
775
- fieldId: import_zod10.z.string(),
776
- options: import_zod10.z.object({
777
- boost: import_zod10.z.number().optional()
949
+ var import_zod12 = require("zod");
950
+ var FieldReference = import_zod12.z.string();
951
+ var Matcher = import_zod12.z.object({
952
+ fieldId: import_zod12.z.string(),
953
+ options: import_zod12.z.object({
954
+ boost: import_zod12.z.number().optional()
778
955
  }).optional().default({})
779
956
  });
780
957
  var FuzzyMatcher = Matcher.extend({
781
- type: import_zod10.z.literal("fuzzy"),
782
- options: import_zod10.z.object({
958
+ type: import_zod12.z.literal("fuzzy"),
959
+ options: import_zod12.z.object({
783
960
  /**
784
961
  * Names of length 3 or less characters = 0 edits allowed
785
962
  * Names of length 4 - 6 characters = 1 edit allowed
786
963
  * Names of length >7 characters = 2 edits allowed
787
964
  */
788
- fuzziness: import_zod10.z.union([import_zod10.z.string(), import_zod10.z.number()]).optional().default("AUTO:4,7"),
789
- boost: import_zod10.z.number().optional().default(1)
965
+ fuzziness: import_zod12.z.union([import_zod12.z.string(), import_zod12.z.number()]).optional().default("AUTO:4,7"),
966
+ boost: import_zod12.z.number().optional().default(1)
790
967
  }).optional().default({})
791
968
  });
792
969
  var StrictMatcher = Matcher.extend({
793
- type: import_zod10.z.literal("strict"),
794
- options: import_zod10.z.object({
795
- boost: import_zod10.z.number().optional().default(1)
970
+ type: import_zod12.z.literal("strict"),
971
+ options: import_zod12.z.object({
972
+ boost: import_zod12.z.number().optional().default(1)
796
973
  }).optional().default({})
797
974
  });
798
975
  var DateRangeMatcher = Matcher.extend({
799
- type: import_zod10.z.literal("dateRange"),
800
- options: import_zod10.z.object({
801
- days: import_zod10.z.number(),
976
+ type: import_zod12.z.literal("dateRange"),
977
+ options: import_zod12.z.object({
978
+ days: import_zod12.z.number(),
802
979
  origin: FieldReference,
803
- boost: import_zod10.z.number().optional().default(1)
980
+ boost: import_zod12.z.number().optional().default(1)
804
981
  })
805
982
  });
806
983
  var DateDistanceMatcher = Matcher.extend({
807
- type: import_zod10.z.literal("dateDistance"),
808
- options: import_zod10.z.object({
809
- days: import_zod10.z.number(),
984
+ type: import_zod12.z.literal("dateDistance"),
985
+ options: import_zod12.z.object({
986
+ days: import_zod12.z.number(),
810
987
  origin: FieldReference,
811
- boost: import_zod10.z.number().optional().default(1)
988
+ boost: import_zod12.z.number().optional().default(1)
812
989
  })
813
990
  });
814
- var And = import_zod10.z.object({
815
- type: import_zod10.z.literal("and"),
816
- clauses: import_zod10.z.lazy(() => Clause.array())
991
+ var And = import_zod12.z.object({
992
+ type: import_zod12.z.literal("and"),
993
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
994
+ clauses: import_zod12.z.lazy(() => Clause.array())
817
995
  });
818
- var Or = import_zod10.z.object({
819
- type: import_zod10.z.literal("or"),
820
- clauses: import_zod10.z.lazy(() => Clause.array())
996
+ var Or = import_zod12.z.object({
997
+ type: import_zod12.z.literal("or"),
998
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
999
+ clauses: import_zod12.z.lazy(() => Clause.array())
821
1000
  });
822
- var Clause = import_zod10.z.lazy(
823
- () => import_zod10.z.discriminatedUnion("type", [
1001
+ var Clause = import_zod12.z.lazy(
1002
+ () => import_zod12.z.discriminatedUnion("type", [
824
1003
  And,
825
1004
  Or,
826
1005
  FuzzyMatcher,
@@ -829,37 +1008,37 @@ var Clause = import_zod10.z.lazy(
829
1008
  DateDistanceMatcher
830
1009
  ])
831
1010
  );
832
- var DeduplicationConfig = import_zod10.z.object({
833
- id: import_zod10.z.string(),
1011
+ var DeduplicationConfig = import_zod12.z.object({
1012
+ id: import_zod12.z.string(),
834
1013
  label: TranslationConfig,
835
1014
  query: Clause
836
1015
  });
837
1016
 
838
1017
  // ../commons/src/events/SummaryConfig.ts
839
- var import_zod11 = require("zod");
840
- var Field = import_zod11.z.object({
841
- id: import_zod11.z.string().describe("Id of summary field"),
1018
+ var import_zod13 = require("zod");
1019
+ var Field = import_zod13.z.object({
1020
+ id: import_zod13.z.string().describe("Id of summary field"),
842
1021
  value: TranslationConfig.describe(
843
1022
  "Summary field value. Can utilise values defined in configuration and EventMetadata"
844
1023
  ),
845
1024
  label: TranslationConfig,
846
1025
  emptyValueMessage: TranslationConfig.optional()
847
1026
  });
848
- var Title = import_zod11.z.object({
849
- id: import_zod11.z.string(),
1027
+ var Title = import_zod13.z.object({
1028
+ id: import_zod13.z.string(),
850
1029
  label: TranslationConfig.describe("Title content"),
851
1030
  emptyValueMessage: TranslationConfig.optional()
852
1031
  });
853
- var SummaryConfig = import_zod11.z.object({
1032
+ var SummaryConfig = import_zod13.z.object({
854
1033
  title: Title.describe("Title of summary view."),
855
- fields: import_zod11.z.array(Field).describe("Fields rendered in summary view.")
1034
+ fields: import_zod13.z.array(Field).describe("Fields rendered in summary view.")
856
1035
  }).describe("Configuration for summary in event.");
857
1036
 
858
1037
  // ../commons/src/events/WorkqueueConfig.ts
859
- var import_zod13 = require("zod");
1038
+ var import_zod15 = require("zod");
860
1039
 
861
1040
  // ../commons/src/events/EventMetadata.ts
862
- var import_zod12 = require("zod");
1041
+ var import_zod14 = require("zod");
863
1042
  var EventStatus = {
864
1043
  CREATED: "CREATED",
865
1044
  NOTIFIED: "NOTIFIED",
@@ -871,18 +1050,19 @@ var EventStatus = {
871
1050
  ARCHIVED: "ARCHIVED"
872
1051
  };
873
1052
  var eventStatuses = Object.values(EventStatus);
874
- var EventStatuses = import_zod12.z.nativeEnum(EventStatus);
875
- var EventMetadata = import_zod12.z.object({
876
- id: import_zod12.z.string(),
877
- type: import_zod12.z.string(),
1053
+ var EventStatuses = import_zod14.z.nativeEnum(EventStatus);
1054
+ var EventMetadata = import_zod14.z.object({
1055
+ id: import_zod14.z.string(),
1056
+ type: import_zod14.z.string(),
878
1057
  status: EventStatuses,
879
- createdAt: import_zod12.z.string().datetime(),
880
- createdBy: import_zod12.z.string(),
881
- createdAtLocation: import_zod12.z.string(),
882
- modifiedAt: import_zod12.z.string().datetime(),
883
- assignedTo: import_zod12.z.string().nullish(),
884
- updatedBy: import_zod12.z.string(),
885
- trackingId: import_zod12.z.string()
1058
+ createdAt: import_zod14.z.string().datetime(),
1059
+ createdBy: import_zod14.z.string(),
1060
+ createdAtLocation: import_zod14.z.string(),
1061
+ modifiedAt: import_zod14.z.string().datetime(),
1062
+ assignedTo: import_zod14.z.string().nullish(),
1063
+ updatedBy: import_zod14.z.string(),
1064
+ trackingId: import_zod14.z.string(),
1065
+ registrationNumber: import_zod14.z.string().nullish()
886
1066
  });
887
1067
  var eventMetadataLabelMap = {
888
1068
  "event.assignedTo": {
@@ -934,28 +1114,33 @@ var eventMetadataLabelMap = {
934
1114
  id: "event.trackingId.label",
935
1115
  defaultMessage: "Tracking ID",
936
1116
  description: "Tracking ID"
1117
+ },
1118
+ "event.registrationNumber": {
1119
+ id: "event.registrationNumber.label",
1120
+ defaultMessage: "Registration Number",
1121
+ description: "Registration Number"
937
1122
  }
938
1123
  };
939
1124
 
940
1125
  // ../commons/src/events/WorkqueueConfig.ts
941
- var WorkqueueConfig = import_zod13.z.object({
942
- id: import_zod13.z.string().describe("Unique identifier for workqueue."),
943
- filters: import_zod13.z.array(
944
- import_zod13.z.object({
945
- status: import_zod13.z.array(EventStatuses).describe("Defines which statusese are included in the workqueue.")
1126
+ var WorkqueueConfig = import_zod15.z.object({
1127
+ id: import_zod15.z.string().describe("Unique identifier for workqueue."),
1128
+ filters: import_zod15.z.array(
1129
+ import_zod15.z.object({
1130
+ status: import_zod15.z.array(EventStatuses).describe("Defines which statusese are included in the workqueue.")
946
1131
  })
947
1132
  ).describe("Filters to be applied to workqueue.")
948
1133
  }).describe("Configuration for workqueue.");
949
1134
 
950
1135
  // ../commons/src/events/AdvancedSearchConfig.ts
951
- var import_zod14 = require("zod");
952
- var AdvancedSearchConfig = import_zod14.z.object({
1136
+ var import_zod16 = require("zod");
1137
+ var AdvancedSearchConfig = import_zod16.z.object({
953
1138
  title: TranslationConfig.describe("Advanced search tab title"),
954
- fields: import_zod14.z.array(
955
- import_zod14.z.object({
956
- fieldId: import_zod14.z.string(),
957
- config: import_zod14.z.object({
958
- type: import_zod14.z.enum(["FUZZY", "EXACT", "RANGE"]).describe("Determines the type of field")
1139
+ fields: import_zod16.z.array(
1140
+ import_zod16.z.object({
1141
+ fieldId: import_zod16.z.string(),
1142
+ config: import_zod16.z.object({
1143
+ type: import_zod16.z.enum(["FUZZY", "EXACT", "RANGE"]).describe("Determines the type of field")
959
1144
  }).optional().describe("Configuration options for the field")
960
1145
  })
961
1146
  ).optional().default([]).describe("Advanced search fields.")
@@ -965,12 +1150,12 @@ var AdvancedSearchConfig = import_zod14.z.object({
965
1150
  var import_lodash = require("lodash");
966
1151
 
967
1152
  // ../commons/src/workqueues/WorkqueueConfig.ts
968
- var import_zod16 = require("zod");
1153
+ var import_zod18 = require("zod");
969
1154
 
970
1155
  // ../commons/src/workqueues/defaultColumns.ts
971
- var import_zod15 = require("zod");
972
- var WorkQueueColumnConfig = import_zod15.z.object({
973
- id: import_zod15.z.string(),
1156
+ var import_zod17 = require("zod");
1157
+ var WorkQueueColumnConfig = import_zod17.z.object({
1158
+ id: import_zod17.z.string(),
974
1159
  label: TranslationConfig
975
1160
  });
976
1161
  var defaultColumns = {
@@ -1007,16 +1192,16 @@ var defaultColumns = {
1007
1192
  }
1008
1193
  }
1009
1194
  };
1010
- var DefaultColumnKeys = import_zod15.z.enum(
1195
+ var DefaultColumnKeys = import_zod17.z.enum(
1011
1196
  Object.keys(defaultColumns)
1012
1197
  );
1013
1198
 
1014
1199
  // ../commons/src/workqueues/WorkqueueConfig.ts
1015
- var rootWorkqueueConfig = import_zod16.z.object({
1016
- id: import_zod16.z.string(),
1200
+ var rootWorkqueueConfig = import_zod18.z.object({
1201
+ id: import_zod18.z.string(),
1017
1202
  title: TranslationConfig,
1018
- columns: import_zod16.z.array(WorkQueueColumnConfig),
1019
- defaultColumns: import_zod16.z.array(DefaultColumnKeys)
1203
+ columns: import_zod18.z.array(WorkQueueColumnConfig),
1204
+ defaultColumns: import_zod18.z.array(DefaultColumnKeys)
1020
1205
  });
1021
1206
  var defineWorkqueue = (config) => rootWorkqueueConfig.parse(config);
1022
1207
 
@@ -1096,7 +1281,7 @@ var import_ajv_formats = __toESM(require("ajv-formats"));
1096
1281
  var import_date_fns = require("date-fns");
1097
1282
 
1098
1283
  // ../commons/src/events/FieldTypeMapping.ts
1099
- var import_zod17 = require("zod");
1284
+ var import_zod19 = require("zod");
1100
1285
  function mapFieldTypeToZod(type, required) {
1101
1286
  let schema;
1102
1287
  switch (type) {
@@ -1138,6 +1323,9 @@ function mapFieldTypeToZod(type, required) {
1138
1323
  case FieldType.ADDRESS:
1139
1324
  schema = AddressFieldUpdateValue;
1140
1325
  break;
1326
+ case FieldType.DATA:
1327
+ schema = DataFieldValue;
1328
+ break;
1141
1329
  }
1142
1330
  return required ? schema : schema.nullish();
1143
1331
  }
@@ -1146,7 +1334,7 @@ function createValidationSchema(config) {
1146
1334
  for (const field2 of config) {
1147
1335
  shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
1148
1336
  }
1149
- return import_zod17.z.object(shape);
1337
+ return import_zod19.z.object(shape);
1150
1338
  }
1151
1339
  function mapFieldTypeToMockValue(field2, i) {
1152
1340
  switch (field2.type) {
@@ -1171,7 +1359,8 @@ function mapFieldTypeToMockValue(field2, i) {
1171
1359
  return "test@opencrvs.org";
1172
1360
  case FieldType.ADDRESS:
1173
1361
  return {
1174
- country: process.env.COUNTRY || "FAR",
1362
+ country: "FAR",
1363
+ addressType: AddressType.DOMESTIC,
1175
1364
  province: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
1176
1365
  district: "5ef450bc-712d-48ad-93f3-8da0fa453baa",
1177
1366
  urbanOrRural: "URBAN",
@@ -1193,6 +1382,8 @@ function mapFieldTypeToMockValue(field2, i) {
1193
1382
  };
1194
1383
  case FieldType.FILE_WITH_OPTIONS:
1195
1384
  return null;
1385
+ case FieldType.DATA:
1386
+ return {};
1196
1387
  }
1197
1388
  }
1198
1389
  function mapFieldTypeToEmptyValue(field2) {
@@ -1215,10 +1406,12 @@ function mapFieldTypeToEmptyValue(field2) {
1215
1406
  case FieldType.EMAIL:
1216
1407
  case FieldType.DATE:
1217
1408
  case FieldType.CHECKBOX:
1409
+ case FieldType.DATA:
1218
1410
  return null;
1219
1411
  case FieldType.ADDRESS:
1220
1412
  return {
1221
1413
  country: null,
1414
+ addressType: AddressType.DOMESTIC,
1222
1415
  province: null,
1223
1416
  district: null,
1224
1417
  urbanOrRural: "URBAN",
@@ -1302,10 +1495,14 @@ var isFacilityFieldType = (field2) => {
1302
1495
  var isOfficeFieldType = (field2) => {
1303
1496
  return field2.config.type === FieldType.OFFICE;
1304
1497
  };
1498
+ var isDataFieldType = (field2) => {
1499
+ return field2.config.type === FieldType.DATA;
1500
+ };
1305
1501
 
1306
1502
  // ../commons/src/conditionals/validate.ts
1307
1503
  var ajv = new import_ajv.default({
1308
- $data: true
1504
+ $data: true,
1505
+ allowUnionTypes: true
1309
1506
  });
1310
1507
  (0, import_ajv_formats.default)(ajv);
1311
1508
  function validate(schema, data) {
@@ -1338,6 +1535,9 @@ function isFieldVisible(field2, form) {
1338
1535
  function isFieldEnabled(field2, form) {
1339
1536
  return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
1340
1537
  }
1538
+ function isFieldDisplayedOnReview(field2, form) {
1539
+ return isFieldVisible(field2, form) && isFieldConditionMet(field2, form, ConditionalType.DISPLAY_ON_REVIEW);
1540
+ }
1341
1541
  var errorMessages = {
1342
1542
  hiddenField: {
1343
1543
  id: "v2.error.hidden",
@@ -1365,12 +1565,14 @@ var errorMessages = {
1365
1565
  id: "v2.error.invalid"
1366
1566
  }
1367
1567
  };
1368
- var createIntlError = (message) => ({
1369
- message: {
1370
- message
1371
- }
1372
- });
1373
- var zodToIntlErrorMap = (issue, _ctx) => {
1568
+ function createIntlError(message) {
1569
+ return {
1570
+ message: {
1571
+ message
1572
+ }
1573
+ };
1574
+ }
1575
+ function zodToIntlErrorMap(issue, _ctx) {
1374
1576
  switch (issue.code) {
1375
1577
  case "invalid_string": {
1376
1578
  if (_ctx.data === "") {
@@ -1408,7 +1610,28 @@ var zodToIntlErrorMap = (issue, _ctx) => {
1408
1610
  }
1409
1611
  }
1410
1612
  return createIntlError(errorMessages.invalidInput);
1411
- };
1613
+ }
1614
+ function runCustomFieldValidations({
1615
+ field: field2,
1616
+ conditionalParameters
1617
+ }) {
1618
+ return (field2.validation ?? []).filter((validation) => {
1619
+ return !validate(validation.validator, conditionalParameters);
1620
+ }).map((validation) => ({ message: validation.message }));
1621
+ }
1622
+ function validateFieldInput({
1623
+ field: field2,
1624
+ value
1625
+ }) {
1626
+ const rawError = mapFieldTypeToZod(field2.type, field2.required).safeParse(
1627
+ value,
1628
+ {
1629
+ // @ts-expect-error
1630
+ errorMap: zodToIntlErrorMap
1631
+ }
1632
+ );
1633
+ return rawError.error?.issues.map((issue) => issue.message) ?? [];
1634
+ }
1412
1635
  function getFieldValidationErrors({
1413
1636
  field: field2,
1414
1637
  values
@@ -1444,28 +1667,16 @@ function getFieldValidationErrors({
1444
1667
  errors: [...fieldValidationResult, ...customValidationResults]
1445
1668
  };
1446
1669
  }
1447
- function runCustomFieldValidations({
1448
- field: field2,
1449
- conditionalParameters
1450
- }) {
1451
- return (field2.validation ?? []).filter((validation) => {
1452
- return !validate(validation.validator, conditionalParameters);
1453
- }).map((validation) => ({ message: validation.message }));
1454
- }
1455
- function validateFieldInput({
1456
- field: field2,
1457
- value
1458
- }) {
1459
- const rawError = mapFieldTypeToZod(field2.type, field2.required).safeParse(
1460
- value,
1461
- {
1462
- // @ts-expect-error
1463
- errorMap: zodToIntlErrorMap
1464
- }
1465
- );
1466
- return rawError.error?.issues.map((issue) => issue.message) ?? [];
1670
+
1671
+ // ../commons/src/uuid.ts
1672
+ var import_uuid = require("uuid");
1673
+ function getUUID() {
1674
+ return (0, import_uuid.v4)();
1467
1675
  }
1468
1676
 
1677
+ // ../commons/src/events/utils.ts
1678
+ var import_date_fns2 = require("date-fns");
1679
+
1469
1680
  // ../commons/src/utils.ts
1470
1681
  function getOrThrow(x, message) {
1471
1682
  if (x === void 0 || x === null) {
@@ -1474,73 +1685,64 @@ function getOrThrow(x, message) {
1474
1685
  return x;
1475
1686
  }
1476
1687
 
1477
- // ../commons/src/uuid.ts
1478
- var import_uuid = require("uuid");
1479
- function getUUID() {
1480
- return (0, import_uuid.v4)();
1481
- }
1482
-
1483
1688
  // ../commons/src/events/utils.ts
1484
- function isMetadataField(field2) {
1485
- return field2 in eventMetadataLabelMap;
1486
- }
1487
- var findInputPageFields = (config) => {
1488
- return (0, import_lodash.flattenDeep)(
1489
- config.actions.map(
1490
- ({ forms }) => forms.map(
1491
- ({ pages }) => pages.map(
1492
- ({ fields }) => fields.map(({ id, label }) => ({ id, label }))
1493
- )
1494
- )
1495
- )
1496
- );
1689
+ function isDeclarationActionConfig(action) {
1690
+ return DeclarationActions.safeParse(action.type).success;
1691
+ }
1692
+ function getDeclarationFields(configuration) {
1693
+ return configuration.declaration.pages.flatMap(({ fields }) => fields);
1694
+ }
1695
+ function getDeclarationPages(configuration) {
1696
+ return configuration.declaration.pages;
1697
+ }
1698
+ function getDeclaration(configuration) {
1699
+ return configuration.declaration;
1700
+ }
1701
+ var getActionAnnotationFields = (actionConfig) => {
1702
+ if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
1703
+ return [
1704
+ ...actionConfig.onboardingForm.flatMap(({ fields }) => fields),
1705
+ ...actionConfig.additionalDetailsForm.flatMap(({ fields }) => fields)
1706
+ ];
1707
+ }
1708
+ if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
1709
+ return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
1710
+ }
1711
+ if (isDeclarationActionConfig(actionConfig)) {
1712
+ return actionConfig.review.fields;
1713
+ }
1714
+ return [];
1497
1715
  };
1498
- var findPageFields = (config) => {
1499
- return (0, import_lodash.flattenDeep)(
1500
- config.actions.map((action) => {
1501
- if (action.type === ActionType.REQUEST_CORRECTION) {
1502
- return [
1503
- ...action.forms.map(({ pages }) => pages.map(({ fields }) => fields)),
1504
- ...action.onboardingForm.flatMap(({ fields }) => fields),
1505
- ...action.additionalDetailsForm.flatMap(({ fields }) => fields)
1506
- ];
1507
- }
1508
- return action.forms.map(({ pages }) => pages.map(({ fields }) => fields));
1509
- })
1510
- );
1716
+ var getAllAnnotationFields = (config) => {
1717
+ return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
1511
1718
  };
1512
- var resolveLabelsFromKnownFields = ({
1513
- pageFields,
1514
- refFields
1515
- }) => {
1516
- return refFields.map((field2) => {
1517
- if (field2.label) {
1518
- return field2;
1519
- }
1520
- if (isMetadataField(field2.id)) {
1521
- return {
1522
- ...field2,
1523
- label: eventMetadataLabelMap[field2.id]
1524
- };
1525
- }
1526
- const pageLabel = pageFields.find((pageField) => pageField.id === field2.id);
1527
- if (!pageLabel) {
1528
- throw new Error(`Referenced field ${field2.id} does not have a label`);
1529
- }
1530
- return {
1531
- ...field2,
1532
- label: pageLabel.label
1533
- };
1534
- });
1535
- };
1536
- function getAllFields(configuration) {
1537
- return configuration.actions.flatMap((action) => action.forms.filter((form) => form.active)).flatMap((form) => [
1538
- ...form.review.fields,
1539
- ...form.pages.flatMap((page) => page.fields)
1719
+ var findAllFields = (config) => {
1720
+ return (0, import_lodash.flattenDeep)([
1721
+ ...getDeclarationFields(config),
1722
+ ...getAllAnnotationFields(config)
1540
1723
  ]);
1724
+ };
1725
+ var findRecordActionPages = (config, actionType) => {
1726
+ const action = config.actions.find((a) => a.type === actionType);
1727
+ if (action?.type === ActionType.REQUEST_CORRECTION) {
1728
+ return [...action.onboardingForm, ...action.additionalDetailsForm];
1729
+ }
1730
+ if (action?.type === ActionType.PRINT_CERTIFICATE) {
1731
+ return action.printForm.pages;
1732
+ }
1733
+ return [];
1734
+ };
1735
+ function getActionReview(configuration, actionType) {
1736
+ const [actionConfig] = configuration.actions.filter(
1737
+ (a) => a.type === actionType
1738
+ );
1739
+ return getOrThrow(
1740
+ actionConfig.review,
1741
+ `No review config found for ${actionType}`
1742
+ );
1541
1743
  }
1542
- function getAllPages(configuration) {
1543
- return configuration.actions.flatMap((action) => action.forms.filter((form) => form.active)).flatMap((form) => form.pages);
1744
+ function getActionReviewFields(configuration, actionType) {
1745
+ return getActionReview(configuration, actionType).fields;
1544
1746
  }
1545
1747
  function validateWorkqueueConfig(workqueueConfigs) {
1546
1748
  workqueueConfigs.map((workqueue) => {
@@ -1554,68 +1756,38 @@ function validateWorkqueueConfig(workqueueConfigs) {
1554
1756
  }
1555
1757
  });
1556
1758
  }
1557
- var findActiveActionForm = (configuration, action) => {
1558
- const actionConfig = configuration.actions.find((a) => a.type === action);
1559
- const form = actionConfig?.forms.find((f) => f.active);
1560
- return form;
1561
- };
1562
- var findActiveActionFormPages = (configuration, action) => {
1563
- return findActiveActionForm(configuration, action)?.pages;
1564
- };
1565
- var getFormFields = (formConfig) => {
1566
- return formConfig.pages.flatMap((p) => p.fields);
1567
- };
1568
- var findActiveActionFormFields = (configuration, action) => {
1569
- const form = findActiveActionForm(configuration, action);
1570
- return form ? getFormFields(form) : void 0;
1571
- };
1572
- var findActiveActionFields = (configuration, action) => {
1573
- const form = findActiveActionForm(configuration, action);
1574
- const reviewFields = form?.review.fields;
1575
- const formFields = form ? getFormFields(form) : void 0;
1576
- const allFields = formFields ? formFields.concat(reviewFields ?? []) : reviewFields;
1577
- return allFields;
1578
- };
1579
- var getActiveActionFormPages = (configuration, action) => {
1580
- return getOrThrow(
1581
- findActiveActionForm(configuration, action)?.pages,
1582
- "Form configuration not found for type: " + configuration.id
1583
- );
1584
- };
1585
- function getActiveActionFields(configuration, action) {
1586
- const fields = findActiveActionFields(configuration, action);
1587
- if (!fields) {
1588
- throw new Error(`No active field config found for action type ${action}`);
1589
- }
1590
- return fields;
1591
- }
1592
- function getEventConfiguration(eventConfigurations, type) {
1593
- const config = eventConfigurations.find((config2) => config2.id === type);
1594
- if (!config) {
1595
- throw new Error(`Event configuration not found for type: ${type}`);
1759
+ function isPageVisible(page, formValues) {
1760
+ if (!page.conditional) {
1761
+ return true;
1596
1762
  }
1597
- return config;
1763
+ return validate(page.conditional, {
1764
+ $form: formValues,
1765
+ $now: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
1766
+ });
1598
1767
  }
1768
+ var getVisiblePagesFormFields = (formConfig, formData) => {
1769
+ return formConfig.pages.filter((p) => isPageVisible(p, formData)).flatMap((p) => p.fields);
1770
+ };
1599
1771
  function isOptionalUncheckedCheckbox(field2, form) {
1600
1772
  if (field2.type !== FieldType.CHECKBOX || field2.required) {
1601
1773
  return false;
1602
1774
  }
1603
1775
  return !form[field2.id];
1604
1776
  }
1605
- function stripHiddenFields(fields, data) {
1606
- return (0, import_lodash.omitBy)(data, (_2, fieldId) => {
1777
+ function stripHiddenFields(fields, declaration) {
1778
+ return (0, import_lodash.omitBy)(declaration, (_, fieldId) => {
1607
1779
  const field2 = fields.find((f) => f.id === fieldId);
1608
1780
  if (!field2) {
1609
1781
  return true;
1610
1782
  }
1611
- if (isOptionalUncheckedCheckbox(field2, data)) {
1783
+ if (isOptionalUncheckedCheckbox(field2, declaration)) {
1612
1784
  return true;
1613
1785
  }
1614
- return !isFieldVisible(field2, data);
1786
+ return !isFieldVisible(field2, declaration);
1615
1787
  });
1616
1788
  }
1617
1789
  function findActiveDrafts(event2, drafts) {
1618
- const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
1790
+ const actions = event2.actions.slice().filter(({ type }) => type !== ActionType.READ).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
1619
1791
  const lastAction = actions[actions.length - 1];
1620
1792
  return drafts.filter(({ createdAt }) => createdAt >= lastAction.createdAt).filter(({ eventId }) => eventId === event2.id);
1621
1793
  }
@@ -1627,28 +1799,50 @@ function createEmptyDraft(eventId, draftId, actionType) {
1627
1799
  transactionId: getUUID(),
1628
1800
  action: {
1629
1801
  type: actionType,
1630
- data: {},
1631
- metadata: {},
1802
+ declaration: {},
1803
+ annotation: {},
1632
1804
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1633
1805
  createdBy: "@todo",
1634
1806
  createdAtLocation: "@todo"
1635
1807
  }
1636
1808
  };
1637
1809
  }
1810
+ function isVerificationPage(page) {
1811
+ return page.type === PageTypes.enum.VERIFICATION;
1812
+ }
1813
+ function deepMerge(currentDocument, actionDocument) {
1814
+ return (0, import_lodash.mergeWith)(
1815
+ currentDocument,
1816
+ actionDocument,
1817
+ (previousValue, incomingValue) => {
1818
+ if (incomingValue === void 0) {
1819
+ return previousValue;
1820
+ }
1821
+ if ((0, import_lodash.isArray)(incomingValue)) {
1822
+ return incomingValue;
1823
+ }
1824
+ if ((0, import_lodash.isObject)(previousValue) && (0, import_lodash.isObject)(incomingValue)) {
1825
+ return void 0;
1826
+ }
1827
+ return incomingValue;
1828
+ }
1829
+ );
1830
+ }
1638
1831
 
1639
1832
  // ../commons/src/events/EventConfig.ts
1640
- var EventConfig = import_zod18.z.object({
1641
- id: import_zod18.z.string().describe(
1833
+ var EventConfig = import_zod20.z.object({
1834
+ id: import_zod20.z.string().describe(
1642
1835
  'A machine-readable identifier for the event, e.g. "birth" or "death"'
1643
1836
  ),
1644
1837
  summary: SummaryConfig,
1645
1838
  label: TranslationConfig,
1646
- actions: import_zod18.z.array(ActionConfig),
1647
- workqueues: import_zod18.z.array(WorkqueueConfig),
1648
- deduplication: import_zod18.z.array(DeduplicationConfig).optional().default([]),
1649
- advancedSearch: import_zod18.z.array(AdvancedSearchConfig).optional().default([])
1839
+ actions: import_zod20.z.array(ActionConfig),
1840
+ declaration: DeclarationFormConfig,
1841
+ workqueues: import_zod20.z.array(WorkqueueConfig),
1842
+ deduplication: import_zod20.z.array(DeduplicationConfig).optional().default([]),
1843
+ advancedSearch: import_zod20.z.array(AdvancedSearchConfig).optional().default([])
1650
1844
  }).superRefine((event2, ctx) => {
1651
- const allFields = findPageFields(event2);
1845
+ const allFields = findAllFields(event2);
1652
1846
  const fieldIds = allFields.map((field2) => field2.id);
1653
1847
  const advancedSearchFields = event2.advancedSearch.flatMap(
1654
1848
  (section) => section.fields.flatMap((field2) => field2.fieldId)
@@ -1675,106 +1869,117 @@ var EventConfig = import_zod18.z.object({
1675
1869
  });
1676
1870
 
1677
1871
  // ../commons/src/events/EventConfigInput.ts
1678
- var defineForm = (form) => FormConfig.parse(form);
1679
- var defineFormPage = (formPage) => FormPage.parse(formPage);
1872
+ var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
1873
+ var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
1874
+ var definePage = (page) => PageConfig.parse(page);
1875
+ var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
1680
1876
 
1681
1877
  // ../commons/src/events/Draft.ts
1682
- var import_zod21 = require("zod");
1878
+ var import_zod23 = require("zod");
1683
1879
 
1684
1880
  // ../commons/src/events/ActionDocument.ts
1685
- var import_zod19 = require("zod");
1686
- var ActionUpdate = import_zod19.z.record(import_zod19.z.string(), FieldUpdateValue);
1687
- var ActionBase = import_zod19.z.object({
1688
- id: import_zod19.z.string(),
1689
- createdAt: import_zod19.z.string().datetime(),
1690
- createdBy: import_zod19.z.string(),
1691
- data: ActionUpdate,
1692
- metadata: ActionUpdate.optional(),
1693
- createdAtLocation: import_zod19.z.string()
1881
+ var import_zod21 = require("zod");
1882
+ var ActionUpdate = import_zod21.z.record(import_zod21.z.string(), FieldUpdateValue);
1883
+ var ActionStatus = {
1884
+ Requested: "Requested",
1885
+ Accepted: "Accepted",
1886
+ Rejected: "Rejected"
1887
+ };
1888
+ var ActionBase = import_zod21.z.object({
1889
+ id: import_zod21.z.string(),
1890
+ createdAt: import_zod21.z.string().datetime(),
1891
+ createdBy: import_zod21.z.string(),
1892
+ declaration: ActionUpdate,
1893
+ annotation: ActionUpdate.optional(),
1894
+ createdAtLocation: import_zod21.z.string(),
1895
+ status: import_zod21.z.enum([
1896
+ ActionStatus.Requested,
1897
+ ActionStatus.Accepted,
1898
+ ActionStatus.Rejected
1899
+ ]),
1900
+ // If the action is an asynchronous confirmation for another action, we will save the original action id here.
1901
+ originalActionId: import_zod21.z.string().optional()
1694
1902
  });
1695
1903
  var AssignedAction = ActionBase.merge(
1696
- import_zod19.z.object({
1697
- type: import_zod19.z.literal(ActionType.ASSIGN),
1698
- assignedTo: import_zod19.z.string()
1904
+ import_zod21.z.object({
1905
+ type: import_zod21.z.literal(ActionType.ASSIGN),
1906
+ assignedTo: import_zod21.z.string()
1699
1907
  })
1700
1908
  );
1701
1909
  var UnassignedAction = ActionBase.merge(
1702
- import_zod19.z.object({
1703
- type: import_zod19.z.literal(ActionType.UNASSIGN)
1910
+ import_zod21.z.object({
1911
+ type: import_zod21.z.literal(ActionType.UNASSIGN)
1704
1912
  })
1705
1913
  );
1706
1914
  var RegisterAction = ActionBase.merge(
1707
- import_zod19.z.object({
1708
- type: import_zod19.z.literal(ActionType.REGISTER),
1709
- identifiers: import_zod19.z.object({
1710
- trackingId: import_zod19.z.string(),
1711
- registrationNumber: import_zod19.z.string()
1712
- })
1915
+ import_zod21.z.object({
1916
+ type: import_zod21.z.literal(ActionType.REGISTER),
1917
+ registrationNumber: import_zod21.z.string().optional()
1713
1918
  })
1714
1919
  );
1715
1920
  var DeclareAction = ActionBase.merge(
1716
- import_zod19.z.object({
1717
- type: import_zod19.z.literal(ActionType.DECLARE)
1921
+ import_zod21.z.object({
1922
+ type: import_zod21.z.literal(ActionType.DECLARE)
1718
1923
  })
1719
1924
  );
1720
1925
  var ValidateAction = ActionBase.merge(
1721
- import_zod19.z.object({
1722
- type: import_zod19.z.literal(ActionType.VALIDATE)
1926
+ import_zod21.z.object({
1927
+ type: import_zod21.z.literal(ActionType.VALIDATE)
1723
1928
  })
1724
1929
  );
1725
1930
  var RejectAction = ActionBase.merge(
1726
- import_zod19.z.object({
1727
- type: import_zod19.z.literal(ActionType.REJECT)
1931
+ import_zod21.z.object({
1932
+ type: import_zod21.z.literal(ActionType.REJECT)
1728
1933
  })
1729
1934
  );
1730
1935
  var MarkAsDuplicateAction = ActionBase.merge(
1731
- import_zod19.z.object({
1732
- type: import_zod19.z.literal(ActionType.MARKED_AS_DUPLICATE)
1936
+ import_zod21.z.object({
1937
+ type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE)
1733
1938
  })
1734
1939
  );
1735
1940
  var ArchiveAction = ActionBase.merge(
1736
- import_zod19.z.object({
1737
- type: import_zod19.z.literal(ActionType.ARCHIVE)
1941
+ import_zod21.z.object({
1942
+ type: import_zod21.z.literal(ActionType.ARCHIVE)
1738
1943
  })
1739
1944
  );
1740
1945
  var CreatedAction = ActionBase.merge(
1741
- import_zod19.z.object({
1742
- type: import_zod19.z.literal(ActionType.CREATE)
1946
+ import_zod21.z.object({
1947
+ type: import_zod21.z.literal(ActionType.CREATE)
1743
1948
  })
1744
1949
  );
1745
1950
  var NotifiedAction = ActionBase.merge(
1746
- import_zod19.z.object({
1747
- type: import_zod19.z.literal(ActionType.NOTIFY)
1951
+ import_zod21.z.object({
1952
+ type: import_zod21.z.literal(ActionType.NOTIFY)
1748
1953
  })
1749
1954
  );
1750
1955
  var PrintCertificateAction = ActionBase.merge(
1751
- import_zod19.z.object({
1752
- type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE)
1956
+ import_zod21.z.object({
1957
+ type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE)
1753
1958
  })
1754
1959
  );
1755
1960
  var RequestedCorrectionAction = ActionBase.merge(
1756
- import_zod19.z.object({
1757
- type: import_zod19.z.literal(ActionType.REQUEST_CORRECTION)
1961
+ import_zod21.z.object({
1962
+ type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION)
1758
1963
  })
1759
1964
  );
1760
1965
  var ApprovedCorrectionAction = ActionBase.merge(
1761
- import_zod19.z.object({
1762
- type: import_zod19.z.literal(ActionType.APPROVE_CORRECTION),
1763
- requestId: import_zod19.z.string()
1966
+ import_zod21.z.object({
1967
+ type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION),
1968
+ requestId: import_zod21.z.string()
1764
1969
  })
1765
1970
  );
1766
1971
  var RejectedCorrectionAction = ActionBase.merge(
1767
- import_zod19.z.object({
1768
- type: import_zod19.z.literal(ActionType.REJECT_CORRECTION),
1769
- requestId: import_zod19.z.string()
1972
+ import_zod21.z.object({
1973
+ type: import_zod21.z.literal(ActionType.REJECT_CORRECTION),
1974
+ requestId: import_zod21.z.string()
1770
1975
  })
1771
1976
  );
1772
- var CustomAction = ActionBase.merge(
1773
- import_zod19.z.object({
1774
- type: import_zod19.z.literal(ActionType.CUSTOM)
1977
+ var ReadAction = ActionBase.merge(
1978
+ import_zod21.z.object({
1979
+ type: import_zod21.z.literal(ActionType.READ)
1775
1980
  })
1776
1981
  );
1777
- var ActionDocument = import_zod19.z.discriminatedUnion("type", [
1982
+ var ActionDocument = import_zod21.z.discriminatedUnion("type", [
1778
1983
  CreatedAction,
1779
1984
  ValidateAction,
1780
1985
  RejectAction,
@@ -1789,108 +1994,124 @@ var ActionDocument = import_zod19.z.discriminatedUnion("type", [
1789
1994
  RejectedCorrectionAction,
1790
1995
  UnassignedAction,
1791
1996
  PrintCertificateAction,
1792
- CustomAction
1997
+ ReadAction
1793
1998
  ]);
1794
- var ResolvedUser = import_zod19.z.object({
1795
- id: import_zod19.z.string(),
1796
- role: import_zod19.z.string(),
1797
- name: import_zod19.z.array(
1798
- import_zod19.z.object({
1799
- use: import_zod19.z.string(),
1800
- given: import_zod19.z.array(import_zod19.z.string()),
1801
- family: import_zod19.z.string()
1999
+ var AsyncRejectActionDocument = ActionBase.omit({
2000
+ declaration: true,
2001
+ annotation: true,
2002
+ createdBy: true,
2003
+ createdAtLocation: true
2004
+ }).merge(
2005
+ import_zod21.z.object({
2006
+ type: import_zod21.z.enum(ConfirmableActions),
2007
+ status: import_zod21.z.literal(ActionStatus.Rejected)
2008
+ })
2009
+ );
2010
+ var Action = import_zod21.z.union([ActionDocument, AsyncRejectActionDocument]);
2011
+ var ResolvedUser = import_zod21.z.object({
2012
+ id: import_zod21.z.string(),
2013
+ role: import_zod21.z.string(),
2014
+ name: import_zod21.z.array(
2015
+ import_zod21.z.object({
2016
+ use: import_zod21.z.string(),
2017
+ given: import_zod21.z.array(import_zod21.z.string()),
2018
+ family: import_zod21.z.string()
1802
2019
  })
1803
2020
  )
1804
2021
  });
1805
2022
 
1806
2023
  // ../commons/src/events/ActionInput.ts
1807
- var import_zod20 = require("zod");
1808
- var BaseActionInput = import_zod20.z.object({
1809
- eventId: import_zod20.z.string(),
1810
- transactionId: import_zod20.z.string(),
1811
- data: ActionUpdate,
1812
- metadata: ActionUpdate.optional()
2024
+ var import_zod22 = require("zod");
2025
+ var BaseActionInput = import_zod22.z.object({
2026
+ eventId: import_zod22.z.string(),
2027
+ transactionId: import_zod22.z.string(),
2028
+ declaration: ActionUpdate,
2029
+ annotation: ActionUpdate.optional(),
2030
+ originalActionId: import_zod22.z.string().optional()
1813
2031
  });
1814
2032
  var CreateActionInput = BaseActionInput.merge(
1815
- import_zod20.z.object({
1816
- type: import_zod20.z.literal(ActionType.CREATE).default(ActionType.CREATE),
1817
- createdAtLocation: import_zod20.z.string()
2033
+ import_zod22.z.object({
2034
+ type: import_zod22.z.literal(ActionType.CREATE).default(ActionType.CREATE),
2035
+ createdAtLocation: import_zod22.z.string()
1818
2036
  })
1819
2037
  );
1820
2038
  var RegisterActionInput = BaseActionInput.merge(
1821
- import_zod20.z.object({
1822
- type: import_zod20.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
1823
- identifiers: import_zod20.z.object({
1824
- trackingId: import_zod20.z.string(),
1825
- registrationNumber: import_zod20.z.string()
1826
- })
2039
+ import_zod22.z.object({
2040
+ type: import_zod22.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
2041
+ registrationNumber: import_zod22.z.string().optional()
1827
2042
  })
1828
2043
  );
1829
2044
  var ValidateActionInput = BaseActionInput.merge(
1830
- import_zod20.z.object({
1831
- type: import_zod20.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
1832
- duplicates: import_zod20.z.array(import_zod20.z.string())
2045
+ import_zod22.z.object({
2046
+ type: import_zod22.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
2047
+ duplicates: import_zod22.z.array(import_zod22.z.string())
1833
2048
  })
1834
2049
  );
1835
2050
  var NotifyActionInput = BaseActionInput.merge(
1836
- import_zod20.z.object({
1837
- type: import_zod20.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
2051
+ import_zod22.z.object({
2052
+ type: import_zod22.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
1838
2053
  })
1839
2054
  );
1840
2055
  var DeclareActionInput = BaseActionInput.merge(
1841
- import_zod20.z.object({
1842
- type: import_zod20.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
2056
+ import_zod22.z.object({
2057
+ type: import_zod22.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
1843
2058
  })
1844
2059
  );
1845
2060
  var PrintCertificateActionInput = BaseActionInput.merge(
1846
- import_zod20.z.object({
1847
- type: import_zod20.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
2061
+ import_zod22.z.object({
2062
+ type: import_zod22.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
1848
2063
  })
1849
2064
  );
1850
2065
  var RejectDeclarationActionInput = BaseActionInput.merge(
1851
- import_zod20.z.object({
1852
- type: import_zod20.z.literal(ActionType.REJECT).default(ActionType.REJECT)
2066
+ import_zod22.z.object({
2067
+ type: import_zod22.z.literal(ActionType.REJECT).default(ActionType.REJECT)
1853
2068
  })
1854
2069
  );
1855
2070
  var MarkedAsDuplicateActionInput = BaseActionInput.merge(
1856
- import_zod20.z.object({
1857
- type: import_zod20.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
2071
+ import_zod22.z.object({
2072
+ type: import_zod22.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
1858
2073
  })
1859
2074
  );
1860
2075
  var ArchiveActionInput = BaseActionInput.merge(
1861
- import_zod20.z.object({
1862
- type: import_zod20.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
2076
+ import_zod22.z.object({
2077
+ type: import_zod22.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
1863
2078
  })
1864
2079
  );
1865
2080
  var AssignActionInput = BaseActionInput.merge(
1866
- import_zod20.z.object({
1867
- type: import_zod20.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
1868
- assignedTo: import_zod20.z.string()
2081
+ import_zod22.z.object({
2082
+ type: import_zod22.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
2083
+ assignedTo: import_zod22.z.string()
1869
2084
  })
1870
2085
  );
1871
2086
  var UnassignActionInput = BaseActionInput.merge(
1872
- import_zod20.z.object({
1873
- type: import_zod20.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN)
2087
+ import_zod22.z.object({
2088
+ type: import_zod22.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
2089
+ assignedTo: import_zod22.z.literal(null).default(null)
1874
2090
  })
1875
2091
  );
1876
2092
  var RequestCorrectionActionInput = BaseActionInput.merge(
1877
- import_zod20.z.object({
1878
- type: import_zod20.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
2093
+ import_zod22.z.object({
2094
+ type: import_zod22.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
1879
2095
  })
1880
2096
  );
1881
2097
  var RejectCorrectionActionInput = BaseActionInput.merge(
1882
- import_zod20.z.object({
1883
- requestId: import_zod20.z.string(),
1884
- type: import_zod20.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
2098
+ import_zod22.z.object({
2099
+ requestId: import_zod22.z.string(),
2100
+ type: import_zod22.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
1885
2101
  })
1886
2102
  );
1887
2103
  var ApproveCorrectionActionInput = BaseActionInput.merge(
1888
- import_zod20.z.object({
1889
- requestId: import_zod20.z.string(),
1890
- type: import_zod20.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
2104
+ import_zod22.z.object({
2105
+ requestId: import_zod22.z.string(),
2106
+ type: import_zod22.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
1891
2107
  })
1892
2108
  );
1893
- var ActionInput = import_zod20.z.discriminatedUnion("type", [
2109
+ var ReadActionInput = BaseActionInput.merge(
2110
+ import_zod22.z.object({
2111
+ type: import_zod22.z.literal(ActionType.READ).default(ActionType.READ)
2112
+ })
2113
+ );
2114
+ var ActionInput = import_zod22.z.discriminatedUnion("type", [
1894
2115
  CreateActionInput,
1895
2116
  ValidateActionInput,
1896
2117
  RegisterActionInput,
@@ -1904,56 +2125,62 @@ var ActionInput = import_zod20.z.discriminatedUnion("type", [
1904
2125
  PrintCertificateActionInput,
1905
2126
  RequestCorrectionActionInput,
1906
2127
  RejectCorrectionActionInput,
1907
- ApproveCorrectionActionInput
2128
+ ApproveCorrectionActionInput,
2129
+ ReadActionInput
1908
2130
  ]);
1909
2131
 
1910
2132
  // ../commons/src/events/Draft.ts
1911
- var Draft = import_zod21.z.object({
1912
- id: import_zod21.z.string(),
1913
- eventId: import_zod21.z.string(),
1914
- transactionId: import_zod21.z.string(),
1915
- createdAt: import_zod21.z.string().datetime(),
2133
+ var Draft = import_zod23.z.object({
2134
+ id: import_zod23.z.string(),
2135
+ eventId: import_zod23.z.string(),
2136
+ transactionId: import_zod23.z.string(),
2137
+ createdAt: import_zod23.z.string().datetime(),
1916
2138
  action: ActionBase.extend({
1917
- type: import_zod21.z.enum(Object.values(ActionType))
2139
+ type: ActionTypes
1918
2140
  }).omit({ id: true })
1919
2141
  });
1920
2142
  var DraftInput = BaseActionInput.extend({
1921
- type: import_zod21.z.enum(Object.values(ActionType))
2143
+ type: ActionTypes
1922
2144
  });
1923
2145
 
1924
2146
  // ../commons/src/events/EventInput.ts
1925
- var import_zod22 = require("zod");
1926
- var EventInput = import_zod22.z.object({
1927
- transactionId: import_zod22.z.string(),
1928
- type: import_zod22.z.string()
2147
+ var import_zod24 = require("zod");
2148
+ var EventInput = import_zod24.z.object({
2149
+ transactionId: import_zod24.z.string(),
2150
+ type: import_zod24.z.string()
1929
2151
  });
1930
2152
 
1931
2153
  // ../commons/src/events/EventDocument.ts
1932
- var import_zod23 = require("zod");
1933
- var EventDocument = import_zod23.z.object({
1934
- id: import_zod23.z.string(),
1935
- type: import_zod23.z.string(),
1936
- createdAt: import_zod23.z.string().datetime(),
1937
- updatedAt: import_zod23.z.string().datetime(),
1938
- actions: import_zod23.z.array(ActionDocument),
1939
- trackingId: import_zod23.z.string()
2154
+ var import_zod25 = require("zod");
2155
+ var EventDocument = import_zod25.z.object({
2156
+ id: import_zod25.z.string(),
2157
+ type: import_zod25.z.string(),
2158
+ createdAt: import_zod25.z.string().datetime(),
2159
+ updatedAt: import_zod25.z.string().datetime(),
2160
+ actions: import_zod25.z.array(Action),
2161
+ trackingId: import_zod25.z.string()
1940
2162
  });
1941
2163
 
1942
2164
  // ../commons/src/events/EventIndex.ts
1943
- var import_zod24 = require("zod");
2165
+ var import_zod26 = require("zod");
1944
2166
  var EventIndex = EventMetadata.extend({
1945
- data: import_zod24.z.record(import_zod24.z.string(), import_zod24.z.any())
2167
+ declaration: import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any())
1946
2168
  });
1947
- var EventSearchIndex = import_zod24.z.record(import_zod24.z.string(), import_zod24.z.any()).and(
1948
- import_zod24.z.object({
1949
- type: import_zod24.z.string()
2169
+ var EventSearchIndex = import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any()).and(
2170
+ import_zod26.z.object({
2171
+ type: import_zod26.z.string()
1950
2172
  // Ensures "type" (event-id) exists and is a string
1951
2173
  })
1952
2174
  );
1953
2175
 
1954
2176
  // ../commons/src/events/state/index.ts
1955
- var _ = __toESM(require("lodash"));
1956
2177
  function getStatusFromActions(actions) {
2178
+ const hasRejectedAction = actions.some(
2179
+ (a) => a.status === ActionStatus.Rejected
2180
+ );
2181
+ if (hasRejectedAction) {
2182
+ return EventStatus.REJECTED;
2183
+ }
1957
2184
  return actions.reduce((status, action) => {
1958
2185
  if (action.type === ActionType.CREATE) {
1959
2186
  return EventStatus.CREATED;
@@ -1990,7 +2217,7 @@ function getAssignedUserFromActions(actions) {
1990
2217
  return user2;
1991
2218
  }, null);
1992
2219
  }
1993
- function getData(actions) {
2220
+ function aggregateActionDeclarations(actions) {
1994
2221
  const excludedActions = [
1995
2222
  ActionType.REQUEST_CORRECTION,
1996
2223
  ActionType.PRINT_CERTIFICATE
@@ -2004,47 +2231,35 @@ function getData(actions) {
2004
2231
  if (!requestAction) {
2005
2232
  return status;
2006
2233
  }
2007
- return deepMerge(status, requestAction.data);
2234
+ return deepMerge(status, requestAction.declaration);
2008
2235
  }
2009
- return deepMerge(status, action.data);
2236
+ return deepMerge(status, action.declaration);
2010
2237
  }, {});
2011
2238
  }
2012
2239
  function deepDropNulls(obj) {
2013
- if (!_.isObject(obj)) return obj;
2014
- return Object.entries(obj).reduce((acc, [key, value]) => {
2015
- if (_.isObject(value)) {
2016
- value = deepDropNulls(value);
2017
- }
2018
- if (value !== null) {
2019
- return {
2020
- ...acc,
2021
- [key]: value
2022
- };
2023
- }
2024
- return acc;
2025
- }, {});
2026
- }
2027
- function deepMerge(currentDocument, actionDocument) {
2028
- return _.mergeWith(
2029
- currentDocument,
2030
- actionDocument,
2031
- (previousValue, incomingValue) => {
2032
- if (incomingValue === void 0) {
2033
- return previousValue;
2034
- }
2035
- if (_.isArray(incomingValue)) {
2036
- return incomingValue;
2037
- }
2038
- if (_.isObject(previousValue) && _.isObject(incomingValue)) {
2039
- return void 0;
2240
+ if (Array.isArray(obj)) {
2241
+ return obj;
2242
+ }
2243
+ if (obj !== null && typeof obj === "object") {
2244
+ return Object.entries(obj).reduce((acc, [key, value]) => {
2245
+ const cleanedValue = deepDropNulls(value);
2246
+ if (cleanedValue !== null) {
2247
+ ;
2248
+ acc[key] = cleanedValue;
2040
2249
  }
2041
- return incomingValue;
2042
- }
2043
- );
2250
+ return acc;
2251
+ }, {});
2252
+ }
2253
+ return obj;
2044
2254
  }
2045
2255
  function isUndeclaredDraft(status) {
2046
2256
  return status === EventStatus.CREATED;
2047
2257
  }
2258
+ function getAcceptedActions(event2) {
2259
+ return event2.actions.filter(
2260
+ (a) => a.status === ActionStatus.Accepted
2261
+ );
2262
+ }
2048
2263
  function getCurrentEventState(event2) {
2049
2264
  const creationAction = event2.actions.find(
2050
2265
  (action) => action.type === ActionType.CREATE
@@ -2052,7 +2267,12 @@ function getCurrentEventState(event2) {
2052
2267
  if (!creationAction) {
2053
2268
  throw new Error(`Event ${event2.id} has no creation action`);
2054
2269
  }
2055
- const latestAction = event2.actions[event2.actions.length - 1];
2270
+ const activeActions = getAcceptedActions(event2);
2271
+ const latestAction = activeActions[activeActions.length - 1];
2272
+ const registrationAction = activeActions.find(
2273
+ (a) => a.type === ActionType.REGISTER && a.status === ActionStatus.Accepted
2274
+ );
2275
+ const registrationNumber = registrationAction?.registrationNumber ?? null;
2056
2276
  return deepDropNulls({
2057
2277
  id: event2.id,
2058
2278
  type: event2.type,
@@ -2061,10 +2281,11 @@ function getCurrentEventState(event2) {
2061
2281
  createdBy: creationAction.createdBy,
2062
2282
  createdAtLocation: creationAction.createdAtLocation,
2063
2283
  modifiedAt: latestAction.createdAt,
2064
- assignedTo: getAssignedUserFromActions(event2.actions),
2284
+ assignedTo: getAssignedUserFromActions(activeActions),
2065
2285
  updatedBy: latestAction.createdBy,
2066
- data: getData(event2.actions),
2067
- trackingId: event2.trackingId
2286
+ declaration: aggregateActionDeclarations(activeActions),
2287
+ trackingId: event2.trackingId,
2288
+ registrationNumber
2068
2289
  });
2069
2290
  }
2070
2291
  function getCurrentEventStateWithDrafts(event2, drafts) {
@@ -2096,38 +2317,44 @@ function applyDraftsToEventIndex(eventIndex, drafts) {
2096
2317
  }
2097
2318
  return {
2098
2319
  ...eventIndex,
2099
- data: {
2100
- ...eventIndex.data,
2101
- ...activeDrafts[activeDrafts.length - 1].data
2320
+ declaration: {
2321
+ ...eventIndex.declaration,
2322
+ ...activeDrafts[activeDrafts.length - 1].declaration
2102
2323
  }
2103
2324
  };
2104
2325
  }
2105
- function getMetadataForAction({
2326
+ function getAnnotationFromDrafts(drafts) {
2327
+ const actions = drafts.map((draft) => draft.action);
2328
+ const annotation = actions.reduce((ann, action) => {
2329
+ return deepMerge(ann, action.annotation ?? {});
2330
+ }, {});
2331
+ return deepDropNulls(annotation);
2332
+ }
2333
+ function getActionAnnotation({
2106
2334
  event: event2,
2107
2335
  actionType,
2108
2336
  drafts
2109
2337
  }) {
2110
- const action = event2.actions.find((action2) => actionType === action2.type);
2338
+ const activeActions = getAcceptedActions(event2);
2339
+ const action = activeActions.find(
2340
+ (activeAction) => actionType === activeAction.type
2341
+ );
2111
2342
  const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
2112
2343
  const sorted = [
2113
2344
  ...action ? [action] : [],
2114
2345
  ...eventDrafts.map((draft) => draft.action)
2115
2346
  ].sort();
2116
- const metadata = sorted.reduce((metadata2, action2) => {
2117
- return deepMerge(metadata2, action2.metadata ?? {});
2347
+ const annotation = sorted.reduce((ann, sortedAction) => {
2348
+ return deepMerge(ann, sortedAction.annotation ?? {});
2118
2349
  }, {});
2119
- return deepDropNulls(metadata);
2350
+ return deepDropNulls(annotation);
2120
2351
  }
2121
2352
 
2122
2353
  // ../commons/src/events/defineConfig.ts
2123
2354
  var defineConfig = (config) => {
2124
2355
  validateWorkqueueConfig(config.workqueues);
2125
2356
  const input = EventConfig.parse(config);
2126
- const pageFields = findInputPageFields(input);
2127
- return EventConfig.parse({
2128
- ...input,
2129
- pageFields
2130
- });
2357
+ return input;
2131
2358
  };
2132
2359
 
2133
2360
  // ../commons/src/events/transactions.ts
@@ -2142,6 +2369,16 @@ var import_lodash2 = require("lodash");
2142
2369
  function defineConditional(schema) {
2143
2370
  return schema;
2144
2371
  }
2372
+ function defineFormConditional(schema) {
2373
+ const schemaWithForm = {
2374
+ type: "object",
2375
+ properties: {
2376
+ $form: schema
2377
+ },
2378
+ required: ["$form"]
2379
+ };
2380
+ return defineConditional(schemaWithForm);
2381
+ }
2145
2382
  function alwaysTrue() {
2146
2383
  return {};
2147
2384
  }
@@ -2166,6 +2403,9 @@ function not(condition) {
2166
2403
  required: []
2167
2404
  });
2168
2405
  }
2406
+ function never() {
2407
+ return not(alwaysTrue());
2408
+ }
2169
2409
  var user = {
2170
2410
  hasScope: (scope) => defineConditional({
2171
2411
  type: "object",
@@ -2213,69 +2453,120 @@ var event = {
2213
2453
  required: ["$event"]
2214
2454
  })
2215
2455
  };
2456
+ function getDateFromNow(days) {
2457
+ return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
2458
+ }
2459
+ function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
2460
+ return {
2461
+ type: "object",
2462
+ properties: {
2463
+ [fieldId]: {
2464
+ type: "string",
2465
+ format: "date",
2466
+ [clause]: { $data: `1/${comparedFieldId}` }
2467
+ },
2468
+ [comparedFieldId]: { type: "string", format: "date" }
2469
+ },
2470
+ required: [fieldId]
2471
+ };
2472
+ }
2473
+ function isFieldReference(value) {
2474
+ return typeof value === "object" && value !== null && "_fieldId" in value;
2475
+ }
2216
2476
  function field(fieldId) {
2217
- const getDateFromNow = (days) => new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
2218
2477
  const getDateRange = (date, clause) => ({
2219
2478
  type: "object",
2220
2479
  properties: {
2221
- $form: {
2222
- type: "object",
2223
- properties: {
2224
- [fieldId]: {
2225
- type: "string",
2226
- format: "date",
2227
- [clause]: date
2228
- }
2229
- },
2230
- required: [fieldId]
2480
+ [fieldId]: {
2481
+ type: "string",
2482
+ format: "date",
2483
+ [clause]: date
2231
2484
  }
2232
2485
  },
2233
- required: ["$form"]
2486
+ required: [fieldId]
2234
2487
  });
2235
2488
  return {
2489
+ /**
2490
+ * @private Internal property used for field reference tracking.
2491
+ */
2492
+ _fieldId: fieldId,
2236
2493
  isAfter: () => ({
2237
2494
  days: (days) => ({
2238
- inPast: () => defineConditional(
2495
+ inPast: () => defineFormConditional(
2239
2496
  getDateRange(getDateFromNow(days), "formatMinimum")
2240
2497
  ),
2241
- inFuture: () => defineConditional(
2498
+ inFuture: () => defineFormConditional(
2242
2499
  getDateRange(getDateFromNow(-days), "formatMinimum")
2243
2500
  )
2244
2501
  }),
2245
- date: (date) => defineConditional(getDateRange(date, "formatMinimum")),
2246
- now: () => defineConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
2502
+ date: (date) => {
2503
+ if (isFieldReference(date)) {
2504
+ const comparedFieldId = date._fieldId;
2505
+ return defineFormConditional(
2506
+ getDateRangeToFieldReference(
2507
+ fieldId,
2508
+ comparedFieldId,
2509
+ "formatMinimum"
2510
+ )
2511
+ );
2512
+ }
2513
+ return defineFormConditional(getDateRange(date, "formatMinimum"));
2514
+ },
2515
+ now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
2247
2516
  }),
2248
2517
  isBefore: () => ({
2249
2518
  days: (days) => ({
2250
- inPast: () => defineConditional(
2519
+ inPast: () => defineFormConditional(
2251
2520
  getDateRange(getDateFromNow(days), "formatMaximum")
2252
2521
  ),
2253
- inFuture: () => defineConditional(
2522
+ inFuture: () => defineFormConditional(
2254
2523
  getDateRange(getDateFromNow(-days), "formatMaximum")
2255
2524
  )
2256
2525
  }),
2257
- date: (date) => defineConditional(getDateRange(date, "formatMaximum")),
2258
- now: () => defineConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
2526
+ date: (date) => {
2527
+ if (isFieldReference(date)) {
2528
+ const comparedFieldId = date._fieldId;
2529
+ return defineFormConditional(
2530
+ getDateRangeToFieldReference(
2531
+ fieldId,
2532
+ comparedFieldId,
2533
+ "formatMaximum"
2534
+ )
2535
+ );
2536
+ }
2537
+ return defineFormConditional(getDateRange(date, "formatMaximum"));
2538
+ },
2539
+ now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
2259
2540
  }),
2260
- isEqualTo: (value) => defineConditional({
2261
- type: "object",
2262
- properties: {
2263
- $form: {
2541
+ isEqualTo: (value) => {
2542
+ if (isFieldReference(value)) {
2543
+ const comparedFieldId = value._fieldId;
2544
+ return defineFormConditional({
2264
2545
  type: "object",
2265
2546
  properties: {
2266
2547
  [fieldId]: {
2267
- oneOf: [
2268
- { type: "string", const: value },
2269
- { type: "boolean", const: value }
2270
- ],
2271
- const: value
2272
- }
2548
+ type: ["string", "boolean"],
2549
+ const: { $data: `1/${comparedFieldId}` }
2550
+ },
2551
+ [comparedFieldId]: { type: ["string", "boolean"] }
2273
2552
  },
2274
- required: [fieldId]
2275
- }
2276
- },
2277
- required: ["$form"]
2278
- }),
2553
+ required: [fieldId, comparedFieldId]
2554
+ });
2555
+ }
2556
+ return defineFormConditional({
2557
+ type: "object",
2558
+ properties: {
2559
+ [fieldId]: {
2560
+ oneOf: [
2561
+ { type: "string", const: value },
2562
+ { type: "boolean", const: value }
2563
+ ],
2564
+ const: value
2565
+ }
2566
+ },
2567
+ required: [fieldId]
2568
+ });
2569
+ },
2279
2570
  /**
2280
2571
  * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
2281
2572
  * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
@@ -2284,91 +2575,102 @@ function field(fieldId) {
2284
2575
  * NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
2285
2576
  *
2286
2577
  */
2287
- isFalsy: () => defineConditional({
2578
+ isFalsy: () => defineFormConditional({
2288
2579
  type: "object",
2289
2580
  properties: {
2290
- $form: {
2291
- type: "object",
2292
- properties: {
2293
- [fieldId]: {
2294
- anyOf: [
2295
- { const: "undefined" },
2296
- { const: false },
2297
- { const: null },
2298
- { const: "" }
2299
- ]
2300
- }
2301
- },
2581
+ [fieldId]: {
2302
2582
  anyOf: [
2303
- {
2304
- required: [fieldId]
2305
- },
2306
- {
2307
- not: {
2308
- required: [fieldId]
2309
- }
2310
- }
2583
+ { const: "undefined" },
2584
+ { const: false },
2585
+ { const: null },
2586
+ { const: "" }
2311
2587
  ]
2312
2588
  }
2313
2589
  },
2314
- required: ["$form"]
2315
- }),
2316
- isUndefined: () => defineConditional({
2317
- type: "object",
2318
- properties: {
2319
- $form: {
2320
- type: "object",
2321
- properties: {
2322
- [fieldId]: {
2323
- type: "string",
2324
- enum: ["undefined"]
2325
- }
2326
- },
2590
+ anyOf: [
2591
+ {
2592
+ required: [fieldId]
2593
+ },
2594
+ {
2327
2595
  not: {
2328
2596
  required: [fieldId]
2329
2597
  }
2330
2598
  }
2599
+ ]
2600
+ }),
2601
+ isUndefined: () => defineFormConditional({
2602
+ type: "object",
2603
+ properties: {
2604
+ [fieldId]: {
2605
+ type: "string",
2606
+ enum: ["undefined"]
2607
+ }
2331
2608
  },
2332
- required: ["$form"]
2609
+ not: {
2610
+ required: [fieldId]
2611
+ }
2333
2612
  }),
2334
- inArray: (values) => defineConditional({
2613
+ inArray: (values) => defineFormConditional({
2335
2614
  type: "object",
2336
2615
  properties: {
2337
- $form: {
2338
- type: "object",
2339
- properties: {
2340
- [fieldId]: {
2341
- type: "string",
2342
- enum: values
2343
- }
2344
- },
2345
- required: [fieldId]
2616
+ [fieldId]: {
2617
+ type: "string",
2618
+ enum: values
2346
2619
  }
2347
2620
  },
2348
- required: ["$form"]
2621
+ required: [fieldId]
2622
+ }),
2623
+ isValidEnglishName: () => defineFormConditional({
2624
+ type: "object",
2625
+ properties: {
2626
+ [fieldId]: {
2627
+ type: "string",
2628
+ pattern: "^[\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*( [\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*)*$",
2629
+ description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
2630
+ }
2631
+ },
2632
+ required: [fieldId]
2633
+ }),
2634
+ /**
2635
+ * Checks if the field value matches a given regular expression pattern.
2636
+ * @param pattern - The regular expression pattern to match the field value against.
2637
+ * @returns A JSONSchema conditional that validates the field value against the pattern.
2638
+ */
2639
+ matches: (pattern) => defineFormConditional({
2640
+ type: "object",
2641
+ properties: {
2642
+ [fieldId]: {
2643
+ type: "string",
2644
+ pattern
2645
+ }
2646
+ },
2647
+ required: [fieldId]
2648
+ }),
2649
+ isBetween: (min, max) => defineFormConditional({
2650
+ type: "object",
2651
+ properties: {
2652
+ [fieldId]: {
2653
+ type: "number",
2654
+ minimum: min,
2655
+ maximum: max
2656
+ }
2657
+ },
2658
+ required: [fieldId]
2349
2659
  })
2350
2660
  };
2351
2661
  }
2352
2662
 
2353
2663
  // ../commons/src/fixtures/tennis-club-membership-event.ts
2354
- var PRINT_CERTIFICATE_FORM = defineForm({
2664
+ var PRINT_CERTIFICATE_FORM = defineActionForm({
2355
2665
  label: {
2356
2666
  id: "v2.event.tennis-club-membership.action.certificate.form.label",
2357
2667
  defaultMessage: "Tennis club membership certificate collector",
2358
2668
  description: "This is what this form is referred as in the system"
2359
2669
  },
2360
- version: {
2361
- id: "1.0.0",
2362
- label: {
2363
- id: "v2.event.tennis-club-membership.action.certificate.form.version.1",
2364
- defaultMessage: "Version 1",
2365
- description: "This is the first version of the form"
2366
- }
2367
- },
2368
- active: true,
2369
2670
  pages: [
2370
2671
  {
2371
2672
  id: "collector",
2673
+ type: PageTypes.enum.FORM,
2372
2674
  title: {
2373
2675
  id: "v2.event.tennis-club-membership.action.certificate.form.section.who.title",
2374
2676
  defaultMessage: "Print certified copy",
@@ -2383,7 +2685,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2383
2685
  defaultMessage: "Requester",
2384
2686
  description: "This is the label for the field"
2385
2687
  },
2386
- type: "SELECT",
2688
+ type: FieldType.SELECT,
2387
2689
  options: [
2388
2690
  {
2389
2691
  value: "INFORMANT",
@@ -2460,7 +2762,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2460
2762
  defaultMessage: "Select Type of ID",
2461
2763
  description: "This is the label for selecting the type of ID"
2462
2764
  },
2463
- type: "SELECT",
2765
+ type: FieldType.SELECT,
2464
2766
  options: [
2465
2767
  {
2466
2768
  value: "PASSPORT",
@@ -2561,7 +2863,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2561
2863
  defaultMessage: "Passport Details",
2562
2864
  description: "Field for entering Passport details"
2563
2865
  },
2564
- type: "TEXT"
2866
+ type: FieldType.TEXT
2565
2867
  },
2566
2868
  {
2567
2869
  id: "collector.DRIVING_LICENSE.details",
@@ -2612,7 +2914,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2612
2914
  defaultMessage: "Driving License Details",
2613
2915
  description: "Field for entering Driving License details"
2614
2916
  },
2615
- type: "TEXT"
2917
+ type: FieldType.TEXT
2616
2918
  },
2617
2919
  {
2618
2920
  id: "collector.REFUGEE_NUMBER.details",
@@ -2663,7 +2965,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2663
2965
  defaultMessage: "Refugee Number Details",
2664
2966
  description: "Field for entering Refugee Number details"
2665
2967
  },
2666
- type: "TEXT"
2968
+ type: FieldType.TEXT
2667
2969
  },
2668
2970
  {
2669
2971
  id: "collector.ALIEN_NUMBER.details",
@@ -2714,7 +3016,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2714
3016
  defaultMessage: "Alien Number Details",
2715
3017
  description: "Field for entering Alien Number details"
2716
3018
  },
2717
- type: "TEXT"
3019
+ type: FieldType.TEXT
2718
3020
  },
2719
3021
  {
2720
3022
  id: "collector.OTHER.idTypeOther",
@@ -2765,7 +3067,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2765
3067
  defaultMessage: "Other ID Type (if applicable)",
2766
3068
  description: 'Field for entering ID type if "Other" is selected'
2767
3069
  },
2768
- type: "TEXT"
3070
+ type: FieldType.TEXT
2769
3071
  },
2770
3072
  {
2771
3073
  id: "collector.OTHER.firstName",
@@ -2816,7 +3118,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2816
3118
  defaultMessage: "First Name",
2817
3119
  description: "This is the label for the first name field"
2818
3120
  },
2819
- type: "TEXT"
3121
+ type: FieldType.TEXT
2820
3122
  },
2821
3123
  {
2822
3124
  id: "collector.OTHER.lastName",
@@ -2867,7 +3169,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2867
3169
  defaultMessage: "Last Name",
2868
3170
  description: "This is the label for the last name field"
2869
3171
  },
2870
- type: "TEXT"
3172
+ type: FieldType.TEXT
2871
3173
  },
2872
3174
  {
2873
3175
  id: "collector.OTHER.relationshipToMember",
@@ -2918,7 +3220,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2918
3220
  defaultMessage: "Relationship to Member",
2919
3221
  description: "This is the label for the relationship to member field"
2920
3222
  },
2921
- type: "TEXT"
3223
+ type: FieldType.TEXT
2922
3224
  },
2923
3225
  {
2924
3226
  id: "collector.OTHER.signedAffidavit",
@@ -2969,66 +3271,88 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2969
3271
  defaultMessage: "Signed Affidavit (Optional)",
2970
3272
  description: "This is the label for uploading a signed affidavit"
2971
3273
  },
2972
- type: "FILE"
3274
+ type: FieldType.FILE
2973
3275
  }
2974
3276
  ]
2975
- }
2976
- ],
2977
- review: {
2978
- title: {
2979
- id: "v2.event.tennis-club-membership.action.certificate.form.review.title",
2980
- defaultMessage: "Member certificate collector for {firstname} {surname}",
2981
- description: "Title of the form to show in review page"
2982
3277
  },
2983
- fields: []
2984
- }
2985
- });
2986
- var TENNIS_CLUB_FORM = defineForm({
2987
- label: {
2988
- id: "v2.event.tennis-club-membership.action.declare.form.label",
2989
- defaultMessage: "Tennis club membership application",
2990
- description: "This is what this form is referred as in the system"
2991
- },
2992
- active: true,
2993
- version: {
2994
- id: "1.0.0",
2995
- label: {
2996
- id: "v2.event.tennis-club-membership.action.declare.form.version.1",
2997
- defaultMessage: "Version 1",
2998
- description: "This is the first version of the form"
3278
+ {
3279
+ id: "collector.identity.verify",
3280
+ type: PageTypes.enum.VERIFICATION,
3281
+ conditional: field("collector.requesterId").isEqualTo("INFORMANT"),
3282
+ title: {
3283
+ id: "event.tennis-club-membership.action.print.verifyIdentity",
3284
+ defaultMessage: "Verify their identity",
3285
+ description: "This is the title of the section"
3286
+ },
3287
+ fields: [],
3288
+ actions: {
3289
+ verify: {
3290
+ label: {
3291
+ defaultMessage: "Verified",
3292
+ description: "This is the label for the verification button",
3293
+ id: "v2.event.tennis-club-membership.action.certificate.form.verify"
3294
+ }
3295
+ },
3296
+ cancel: {
3297
+ label: {
3298
+ defaultMessage: "Identity does not match",
3299
+ description: "This is the label for the verification cancellation button",
3300
+ id: "v2.event.tennis-club-membership.action.certificate.form.cancel"
3301
+ },
3302
+ confirmation: {
3303
+ title: {
3304
+ defaultMessage: "Print without proof of ID?",
3305
+ description: "This is the title for the verification cancellation modal",
3306
+ id: "v2.event.tennis-club-membership.action.certificate.form.cancel.confirmation.title"
3307
+ },
3308
+ body: {
3309
+ defaultMessage: "Please be aware that if you proceed, you will be responsible for issuing a certificate without the necessary proof of ID from the collector",
3310
+ description: "This is the body for the verification cancellation modal",
3311
+ id: "v2.event.tennis-club-membership.action.certificate.form.cancel.confirmation.body"
3312
+ }
3313
+ }
3314
+ }
3315
+ }
2999
3316
  }
3317
+ ]
3318
+ });
3319
+ var TENNIS_CLUB_DECLARATION_REVIEW = {
3320
+ title: {
3321
+ id: "v2.event.tennis-club-membership.action.declare.form.review.title",
3322
+ defaultMessage: "{applicant.firstname, select, __EMPTY__ {Member declaration} other {{applicant.surname, select, __EMPTY__ {Member declaration} other {Member declaration for {applicant.firstname} {applicant.surname}}}}}",
3323
+ description: "Title of the review page"
3000
3324
  },
3001
- review: {
3002
- title: {
3003
- id: "v2.event.tennis-club-membership.action.declare.form.review.title",
3004
- defaultMessage: "{applicant.firstname, select, __EMPTY__ {Member declaration} other {{applicant.surname, select, __EMPTY__ {Member declaration} other {Member declaration for {applicant.firstname} {applicant.surname}}}}}",
3005
- description: "Title of the form to show in review page"
3325
+ fields: [
3326
+ {
3327
+ id: "review.comment",
3328
+ type: FieldType.TEXTAREA,
3329
+ label: {
3330
+ defaultMessage: "Comment",
3331
+ id: "v2.event.birth.action.declare.form.review.comment.label",
3332
+ description: "Label for the comment field in the review section"
3333
+ }
3006
3334
  },
3007
- fields: [
3008
- {
3009
- id: "review.comment",
3010
- type: "TEXTAREA",
3011
- label: {
3012
- defaultMessage: "Comment",
3013
- id: "v2.event.birth.action.declare.form.review.comment.label",
3014
- description: "Label for the comment field in the review section"
3015
- }
3335
+ {
3336
+ type: FieldType.SIGNATURE,
3337
+ id: "review.signature",
3338
+ label: {
3339
+ defaultMessage: "Signature of informant",
3340
+ id: "v2.event.birth.action.declare.form.review.signature.label",
3341
+ description: "Label for the signature field in the review section"
3016
3342
  },
3017
- {
3018
- type: "SIGNATURE",
3019
- id: "review.signature",
3020
- label: {
3021
- defaultMessage: "Signature of informant",
3022
- id: "v2.event.birth.action.declare.form.review.signature.label",
3023
- description: "Label for the signature field in the review section"
3024
- },
3025
- signaturePromptLabel: {
3026
- id: "v2.signature.upload.modal.title",
3027
- defaultMessage: "Draw signature",
3028
- description: "Title for the modal to draw signature"
3029
- }
3343
+ signaturePromptLabel: {
3344
+ id: "v2.signature.upload.modal.title",
3345
+ defaultMessage: "Draw signature",
3346
+ description: "Title for the modal to draw signature"
3030
3347
  }
3031
- ]
3348
+ }
3349
+ ]
3350
+ };
3351
+ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
3352
+ label: {
3353
+ id: "v2.event.tennis-club-membership.action.declare.form.label",
3354
+ defaultMessage: "Tennis club membership application",
3355
+ description: "This is what this form is referred as in the system"
3032
3356
  },
3033
3357
  pages: [
3034
3358
  {
@@ -3041,7 +3365,7 @@ var TENNIS_CLUB_FORM = defineForm({
3041
3365
  fields: [
3042
3366
  {
3043
3367
  id: "applicant.firstname",
3044
- type: "TEXT",
3368
+ type: FieldType.TEXT,
3045
3369
  required: true,
3046
3370
  conditionals: [],
3047
3371
  label: {
@@ -3052,7 +3376,7 @@ var TENNIS_CLUB_FORM = defineForm({
3052
3376
  },
3053
3377
  {
3054
3378
  id: "applicant.surname",
3055
- type: "TEXT",
3379
+ type: FieldType.TEXT,
3056
3380
  required: true,
3057
3381
  conditionals: [],
3058
3382
  label: {
@@ -3095,7 +3419,7 @@ var TENNIS_CLUB_FORM = defineForm({
3095
3419
  },
3096
3420
  {
3097
3421
  id: "applicant.image",
3098
- type: "FILE",
3422
+ type: FieldType.FILE,
3099
3423
  required: false,
3100
3424
  label: {
3101
3425
  defaultMessage: "Applicant's profile picture",
@@ -3116,6 +3440,27 @@ var TENNIS_CLUB_FORM = defineForm({
3116
3440
  }
3117
3441
  ]
3118
3442
  },
3443
+ {
3444
+ id: "senior-pass",
3445
+ conditional: field("applicant.dob").isBefore().date("1950-01-01"),
3446
+ title: {
3447
+ id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.title",
3448
+ defaultMessage: "Assign senior pass for applicant",
3449
+ description: "This is the title of the section"
3450
+ },
3451
+ fields: [
3452
+ {
3453
+ id: "senior-pass.id",
3454
+ type: FieldType.TEXT,
3455
+ required: true,
3456
+ label: {
3457
+ defaultMessage: "Senior pass ID",
3458
+ description: "This is the label for the field",
3459
+ id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.field.id.label"
3460
+ }
3461
+ }
3462
+ ]
3463
+ },
3119
3464
  {
3120
3465
  id: "recommender",
3121
3466
  title: {
@@ -3137,7 +3482,7 @@ var TENNIS_CLUB_FORM = defineForm({
3137
3482
  },
3138
3483
  {
3139
3484
  id: "recommender.firstname",
3140
- type: "TEXT",
3485
+ type: FieldType.TEXT,
3141
3486
  required: true,
3142
3487
  conditionals: [
3143
3488
  {
@@ -3153,7 +3498,7 @@ var TENNIS_CLUB_FORM = defineForm({
3153
3498
  },
3154
3499
  {
3155
3500
  id: "recommender.surname",
3156
- type: "TEXT",
3501
+ type: FieldType.TEXT,
3157
3502
  required: true,
3158
3503
  conditionals: [
3159
3504
  {
@@ -3169,7 +3514,7 @@ var TENNIS_CLUB_FORM = defineForm({
3169
3514
  },
3170
3515
  {
3171
3516
  id: "recommender.id",
3172
- type: "TEXT",
3517
+ type: FieldType.TEXT,
3173
3518
  required: true,
3174
3519
  conditionals: [
3175
3520
  {
@@ -3277,7 +3622,7 @@ var tennisClubMembershipEvent = defineConfig({
3277
3622
  description: "This is shown as the action name anywhere the user can trigger the action from",
3278
3623
  id: "event.tennis-club-membership.action.declare.label"
3279
3624
  },
3280
- forms: [TENNIS_CLUB_FORM]
3625
+ review: TENNIS_CLUB_DECLARATION_REVIEW
3281
3626
  },
3282
3627
  {
3283
3628
  type: ActionType.VALIDATE,
@@ -3286,7 +3631,7 @@ var tennisClubMembershipEvent = defineConfig({
3286
3631
  description: "This is shown as the action name anywhere the user can trigger the action from",
3287
3632
  id: "event.tennis-club-membership.action.validate.label"
3288
3633
  },
3289
- forms: [TENNIS_CLUB_FORM]
3634
+ review: TENNIS_CLUB_DECLARATION_REVIEW
3290
3635
  },
3291
3636
  {
3292
3637
  type: ActionType.REGISTER,
@@ -3295,7 +3640,7 @@ var tennisClubMembershipEvent = defineConfig({
3295
3640
  description: "This is shown as the action name anywhere the user can trigger the action from",
3296
3641
  id: "event.tennis-club-membership.action.register.label"
3297
3642
  },
3298
- forms: [TENNIS_CLUB_FORM]
3643
+ review: TENNIS_CLUB_DECLARATION_REVIEW
3299
3644
  },
3300
3645
  {
3301
3646
  type: ActionType.REQUEST_CORRECTION,
@@ -3304,10 +3649,10 @@ var tennisClubMembershipEvent = defineConfig({
3304
3649
  description: "This is shown as the action name anywhere the user can trigger the action from",
3305
3650
  id: "event.tennis-club-membership.action.correction.request.label"
3306
3651
  },
3307
- forms: [TENNIS_CLUB_FORM],
3308
3652
  onboardingForm: [
3309
3653
  {
3310
3654
  id: "correction-requester",
3655
+ type: PageTypes.enum.FORM,
3311
3656
  title: {
3312
3657
  id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
3313
3658
  defaultMessage: "Correction requester",
@@ -3371,6 +3716,7 @@ var tennisClubMembershipEvent = defineConfig({
3371
3716
  },
3372
3717
  {
3373
3718
  id: "identity-check",
3719
+ type: PageTypes.enum.FORM,
3374
3720
  title: {
3375
3721
  id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
3376
3722
  defaultMessage: "Verify their identity",
@@ -3413,6 +3759,7 @@ var tennisClubMembershipEvent = defineConfig({
3413
3759
  additionalDetailsForm: [
3414
3760
  {
3415
3761
  id: "correction-request.supporting-documents",
3762
+ type: PageTypes.enum.FORM,
3416
3763
  title: {
3417
3764
  id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
3418
3765
  defaultMessage: "Upload supporting documents",
@@ -3430,7 +3777,7 @@ var tennisClubMembershipEvent = defineConfig({
3430
3777
  },
3431
3778
  {
3432
3779
  id: "correction.supportingDocs",
3433
- type: "FILE",
3780
+ type: FieldType.FILE,
3434
3781
  label: {
3435
3782
  id: "correction.corrector.title",
3436
3783
  defaultMessage: "Upload supporting documents",
@@ -3474,6 +3821,7 @@ var tennisClubMembershipEvent = defineConfig({
3474
3821
  },
3475
3822
  {
3476
3823
  id: "correction-request.additional-details",
3824
+ type: PageTypes.enum.FORM,
3477
3825
  title: {
3478
3826
  id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
3479
3827
  defaultMessage: "Reason for correction",
@@ -3482,7 +3830,7 @@ var tennisClubMembershipEvent = defineConfig({
3482
3830
  fields: [
3483
3831
  {
3484
3832
  id: "correction.request.reason",
3485
- type: "TEXT",
3833
+ type: FieldType.TEXT,
3486
3834
  label: {
3487
3835
  id: "correction.reason.title",
3488
3836
  defaultMessage: "Reason for correction?",
@@ -3495,7 +3843,6 @@ var tennisClubMembershipEvent = defineConfig({
3495
3843
  },
3496
3844
  {
3497
3845
  type: ActionType.APPROVE_CORRECTION,
3498
- forms: [TENNIS_CLUB_FORM],
3499
3846
  label: {
3500
3847
  defaultMessage: "Approve correction",
3501
3848
  description: "This is shown as the action name anywhere the user can trigger the action from",
@@ -3509,7 +3856,7 @@ var tennisClubMembershipEvent = defineConfig({
3509
3856
  defaultMessage: "Print certificate",
3510
3857
  description: "This is shown as the action name anywhere the user can trigger the action from"
3511
3858
  },
3512
- forms: [PRINT_CERTIFICATE_FORM],
3859
+ printForm: PRINT_CERTIFICATE_FORM,
3513
3860
  conditionals: [
3514
3861
  {
3515
3862
  type: "SHOW",
@@ -3556,8 +3903,7 @@ var tennisClubMembershipEvent = defineConfig({
3556
3903
  id: "v2.event.tennis-club-membership.action.archive.label",
3557
3904
  defaultMessage: "Archive",
3558
3905
  description: "This is shown as the action name anywhere the user can trigger the action from"
3559
- },
3560
- forms: [TENNIS_CLUB_FORM]
3906
+ }
3561
3907
  },
3562
3908
  {
3563
3909
  type: ActionType.REJECT,
@@ -3565,8 +3911,7 @@ var tennisClubMembershipEvent = defineConfig({
3565
3911
  id: "v2.event.tennis-club-membership.action.reject.label",
3566
3912
  defaultMessage: "Reject",
3567
3913
  description: "This is shown as the action name anywhere the user can trigger the action from"
3568
- },
3569
- forms: [TENNIS_CLUB_FORM]
3914
+ }
3570
3915
  }
3571
3916
  ],
3572
3917
  advancedSearch: [
@@ -3582,20 +3927,52 @@ var tennisClubMembershipEvent = defineConfig({
3582
3927
  }
3583
3928
  ]
3584
3929
  }
3585
- ]
3930
+ ],
3931
+ declaration: TENNIS_CLUB_DECLARATION_FORM
3586
3932
  });
3587
3933
 
3588
3934
  // ../commons/src/events/test.utils.ts
3589
- function generateActionInput(configuration, action) {
3590
- const fields = findActiveActionFormFields(configuration, action) ?? [];
3591
- const data = fields.reduce(
3935
+ function fieldConfigsToActionAnnotation(fields) {
3936
+ return fields.reduce(
3592
3937
  (acc, field2, i) => ({
3593
3938
  ...acc,
3594
3939
  [field2.id]: mapFieldTypeToMockValue(field2, i)
3595
3940
  }),
3596
3941
  {}
3597
3942
  );
3598
- return stripHiddenFields(fields, data);
3943
+ }
3944
+ function generateActionInput(configuration, action) {
3945
+ const parsed = DeclarationUpdateActions.safeParse(action);
3946
+ if (parsed.success) {
3947
+ const fields = getDeclarationFields(configuration);
3948
+ const annotation = fieldConfigsToActionAnnotation(fields);
3949
+ return stripHiddenFields(fields, annotation);
3950
+ }
3951
+ console.warn(`${action} is not a declaration action. Setting data as {}.`);
3952
+ return {};
3953
+ }
3954
+ function generateActionMetadataInput(configuration, action) {
3955
+ const actionConfig = configuration.actions.find(
3956
+ (ac) => ac.type === action
3957
+ );
3958
+ const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
3959
+ const annotation = fieldConfigsToActionAnnotation(annotationFields);
3960
+ const visibleVerificationPageIds = findRecordActionPages(
3961
+ configuration,
3962
+ action
3963
+ ).filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page, annotation)).map((page) => page.id);
3964
+ const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
3965
+ (acc, pageId) => ({
3966
+ ...acc,
3967
+ [pageId]: true
3968
+ }),
3969
+ {}
3970
+ );
3971
+ const fieldBasedPayload = stripHiddenFields(annotationFields, annotation);
3972
+ return {
3973
+ ...fieldBasedPayload,
3974
+ ...visiblePageVerificationMap
3975
+ };
3599
3976
  }
3600
3977
  var eventPayloadGenerator = {
3601
3978
  create: (input = {}) => ({
@@ -3607,21 +3984,22 @@ var eventPayloadGenerator = {
3607
3984
  type: input.type ?? "TENNIS_CLUB_MEMBERSHIP",
3608
3985
  id
3609
3986
  }),
3610
- draft: (eventId, input = {}) => (0, import_lodash2.merge)(
3987
+ draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
3611
3988
  {
3612
3989
  id: getUUID(),
3613
3990
  eventId,
3614
3991
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
3615
3992
  transactionId: getUUID(),
3616
3993
  action: {
3617
- type: ActionType.REQUEST_CORRECTION,
3618
- data: {
3994
+ type: actionType,
3995
+ status: ActionStatus.Accepted,
3996
+ declaration: {
3619
3997
  "applicant.firstname": "Max",
3620
3998
  "applicant.surname": "McLaren",
3621
3999
  "applicant.dob": "2020-01-02",
3622
4000
  "recommender.none": true
3623
4001
  },
3624
- metadata: {
4002
+ annotation: {
3625
4003
  "correction.requester.relationship": "ANOTHER_AGENT",
3626
4004
  "correction.request.reason": "Child's name was incorrect"
3627
4005
  },
@@ -3636,41 +4014,92 @@ var eventPayloadGenerator = {
3636
4014
  declare: (eventId, input = {}) => ({
3637
4015
  type: ActionType.DECLARE,
3638
4016
  transactionId: input.transactionId ?? getUUID(),
3639
- data: input.data ?? generateActionInput(tennisClubMembershipEvent, ActionType.DECLARE),
4017
+ declaration: input.declaration ?? generateActionInput(tennisClubMembershipEvent, ActionType.DECLARE),
4018
+ annotation: input.annotation ?? generateActionMetadataInput(
4019
+ tennisClubMembershipEvent,
4020
+ ActionType.DECLARE
4021
+ ),
3640
4022
  eventId
3641
4023
  }),
4024
+ /**
4025
+ * Notify allows sending incomplete data. Think it as 'partial declare' for now.
4026
+ */
4027
+ notify: (eventId, input = {}) => {
4028
+ let declaration = input.declaration;
4029
+ if (!declaration) {
4030
+ const partialDeclaration = (0, import_lodash2.omitBy)(
4031
+ generateActionInput(tennisClubMembershipEvent, ActionType.DECLARE),
4032
+ import_lodash2.isString
4033
+ );
4034
+ declaration = partialDeclaration;
4035
+ }
4036
+ return {
4037
+ type: ActionType.NOTIFY,
4038
+ transactionId: input.transactionId ?? getUUID(),
4039
+ declaration,
4040
+ eventId
4041
+ };
4042
+ },
3642
4043
  validate: (eventId, input = {}) => ({
3643
4044
  type: ActionType.VALIDATE,
3644
4045
  transactionId: input.transactionId ?? getUUID(),
3645
- data: input.data ?? generateActionInput(tennisClubMembershipEvent, ActionType.VALIDATE),
4046
+ declaration: input.declaration ?? generateActionInput(tennisClubMembershipEvent, ActionType.VALIDATE),
4047
+ annotation: input.annotation ?? generateActionMetadataInput(
4048
+ tennisClubMembershipEvent,
4049
+ ActionType.VALIDATE
4050
+ ),
3646
4051
  duplicates: [],
3647
4052
  eventId
3648
4053
  }),
4054
+ assign: (eventId, input = {}) => ({
4055
+ type: ActionType.ASSIGN,
4056
+ transactionId: input.transactionId ?? getUUID(),
4057
+ declaration: {},
4058
+ assignedTo: input.assignedTo ?? getUUID(),
4059
+ eventId
4060
+ }),
4061
+ unassign: (eventId, input = {}) => ({
4062
+ type: ActionType.UNASSIGN,
4063
+ transactionId: input.transactionId ?? getUUID(),
4064
+ declaration: {},
4065
+ assignedTo: null,
4066
+ eventId
4067
+ }),
3649
4068
  archive: (eventId, input = {}, isDuplicate) => ({
3650
4069
  type: ActionType.ARCHIVE,
3651
4070
  transactionId: input.transactionId ?? getUUID(),
3652
- data: input.data ?? generateActionInput(tennisClubMembershipEvent, ActionType.ARCHIVE),
3653
- metadata: { isDuplicate: isDuplicate ?? false },
4071
+ declaration: {},
4072
+ // @TODO: Check whether generator is needed?
4073
+ annotation: { isDuplicate: isDuplicate ?? false },
3654
4074
  duplicates: [],
3655
4075
  eventId
3656
4076
  }),
3657
4077
  reject: (eventId, input = {}) => ({
3658
4078
  type: ActionType.REJECT,
3659
4079
  transactionId: input.transactionId ?? getUUID(),
3660
- data: input.data ?? generateActionInput(tennisClubMembershipEvent, ActionType.REJECT),
4080
+ declaration: {},
4081
+ annotation: input.annotation ?? generateActionMetadataInput(
4082
+ tennisClubMembershipEvent,
4083
+ ActionType.REJECT
4084
+ ),
3661
4085
  duplicates: [],
3662
4086
  eventId
3663
4087
  }),
3664
4088
  register: (eventId, input = {}) => ({
3665
4089
  type: ActionType.REGISTER,
3666
4090
  transactionId: input.transactionId ?? getUUID(),
3667
- data: input.data ?? generateActionInput(tennisClubMembershipEvent, ActionType.REGISTER),
4091
+ declaration: input.declaration ?? generateActionInput(tennisClubMembershipEvent, ActionType.REGISTER),
4092
+ annotation: input.annotation ?? generateActionMetadataInput(
4093
+ tennisClubMembershipEvent,
4094
+ ActionType.REGISTER
4095
+ ),
3668
4096
  eventId
3669
4097
  }),
3670
4098
  printCertificate: (eventId, input = {}) => ({
3671
4099
  type: ActionType.PRINT_CERTIFICATE,
3672
4100
  transactionId: input.transactionId ?? getUUID(),
3673
- data: input.data ?? generateActionInput(
4101
+ declaration: {},
4102
+ annotation: input.annotation ?? generateActionMetadataInput(
3674
4103
  tennisClubMembershipEvent,
3675
4104
  ActionType.PRINT_CERTIFICATE
3676
4105
  ),
@@ -3680,17 +4109,21 @@ var eventPayloadGenerator = {
3680
4109
  request: (eventId, input = {}) => ({
3681
4110
  type: ActionType.REQUEST_CORRECTION,
3682
4111
  transactionId: input.transactionId ?? getUUID(),
3683
- data: input.data ?? generateActionInput(
4112
+ declaration: input.declaration ?? generateActionInput(
4113
+ tennisClubMembershipEvent,
4114
+ ActionType.REQUEST_CORRECTION
4115
+ ),
4116
+ annotation: input.annotation ?? generateActionMetadataInput(
3684
4117
  tennisClubMembershipEvent,
3685
4118
  ActionType.REQUEST_CORRECTION
3686
4119
  ),
3687
- metadata: {},
3688
4120
  eventId
3689
4121
  }),
3690
4122
  approve: (eventId, requestId, input = {}) => ({
3691
4123
  type: ActionType.APPROVE_CORRECTION,
3692
4124
  transactionId: input.transactionId ?? getUUID(),
3693
- data: input.data ?? generateActionInput(
4125
+ declaration: {},
4126
+ annotation: input.annotation ?? generateActionMetadataInput(
3694
4127
  tennisClubMembershipEvent,
3695
4128
  ActionType.APPROVE_CORRECTION
3696
4129
  ),
@@ -3700,7 +4133,8 @@ var eventPayloadGenerator = {
3700
4133
  reject: (eventId, requestId, input = {}) => ({
3701
4134
  type: ActionType.REJECT_CORRECTION,
3702
4135
  transactionId: input.transactionId ?? getUUID(),
3703
- data: input.data ?? generateActionInput(
4136
+ declaration: {},
4137
+ annotation: input.annotation ?? generateActionMetadataInput(
3704
4138
  tennisClubMembershipEvent,
3705
4139
  ActionType.REJECT_CORRECTION
3706
4140
  ),
@@ -3722,11 +4156,16 @@ function generateActionDocument({
3722
4156
  createdBy: getUUID(),
3723
4157
  id: getUUID(),
3724
4158
  createdAtLocation: "TODO",
3725
- data: generateActionInput(configuration, action),
3726
- metadata: {},
3727
- ...defaults
4159
+ declaration: generateActionInput(configuration, action),
4160
+ annotation: {},
4161
+ ...defaults,
4162
+ status: ActionStatus.Accepted
3728
4163
  };
3729
4164
  switch (action) {
4165
+ case ActionType.READ:
4166
+ return { ...actionBase, type: action };
4167
+ case ActionType.MARKED_AS_DUPLICATE:
4168
+ return { ...actionBase, type: action };
3730
4169
  case ActionType.DECLARE:
3731
4170
  return { ...actionBase, type: action };
3732
4171
  case ActionType.UNASSIGN:
@@ -3751,14 +4190,13 @@ function generateActionDocument({
3751
4190
  return { ...actionBase, requestId: getUUID(), type: action };
3752
4191
  case ActionType.REJECT_CORRECTION:
3753
4192
  return { ...actionBase, requestId: getUUID(), type: action };
3754
- case ActionType.CUSTOM:
3755
- return { ...actionBase, type: action };
3756
4193
  case ActionType.REGISTER:
3757
4194
  return {
3758
4195
  ...actionBase,
3759
- type: action,
3760
- identifiers: { trackingId: getUUID(), registrationNumber: getUUID() }
4196
+ type: action
3761
4197
  };
4198
+ case ActionType.DELETE:
4199
+ case ActionType.DETECT_DUPLICATE:
3762
4200
  default:
3763
4201
  throw new Error(`Unsupported action type: ${action}`);
3764
4202
  }
@@ -3782,7 +4220,7 @@ function generateEventDocument({
3782
4220
  updatedAt: new Date(Date.now() - 1e3).toISOString()
3783
4221
  };
3784
4222
  }
3785
- function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, data = {}) {
4223
+ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
3786
4224
  const action = generateActionDocument({
3787
4225
  configuration: tennisClubMembershipEvent,
3788
4226
  action: actionType
@@ -3792,9 +4230,9 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, da
3792
4230
  transactionId: getUUID(),
3793
4231
  action: {
3794
4232
  ...action,
3795
- data: {
3796
- ...action.data,
3797
- ...data
4233
+ declaration: {
4234
+ ...action.declaration,
4235
+ ...declaration
3798
4236
  }
3799
4237
  },
3800
4238
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -3811,7 +4249,7 @@ var eventQueryDataGenerator = (overrides = {}) => ({
3811
4249
  modifiedAt: overrides.modifiedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
3812
4250
  assignedTo: overrides.assignedTo ?? null,
3813
4251
  updatedBy: overrides.updatedBy ?? getUUID(),
3814
- data: overrides.data ?? {
4252
+ declaration: overrides.declaration ?? {
3815
4253
  "recommender.none": true,
3816
4254
  "applicant.firstname": "Danny",
3817
4255
  "applicant.surname": "Doe",
@@ -3819,6 +4257,11 @@ var eventQueryDataGenerator = (overrides = {}) => ({
3819
4257
  },
3820
4258
  trackingId: overrides.trackingId ?? "M3F8YQ"
3821
4259
  });
4260
+ var generateTranslationConfig = (message) => ({
4261
+ defaultMessage: message,
4262
+ description: "Description for ${message}",
4263
+ id: message
4264
+ });
3822
4265
 
3823
4266
  // ../commons/src/events/TemplateConfig.ts
3824
4267
  function isTemplateVariable(value) {
@@ -3837,7 +4280,9 @@ function isFieldValueWithoutTemplates(value) {
3837
4280
  return true;
3838
4281
  }
3839
4282
  function isFieldConfigDefaultValue(value) {
3840
- if (!value) return false;
4283
+ if (!value) {
4284
+ return false;
4285
+ }
3841
4286
  if (isFieldValue(value)) {
3842
4287
  return true;
3843
4288
  }