@opencrvs/toolkit 1.8.0-rc.ffe8c17 → 1.8.1-rc.a372970

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 (33) hide show
  1. package/README.md +1 -1
  2. package/dist/commons/api/router.d.ts +6644 -9555
  3. package/dist/commons/conditionals/conditionals.d.ts +26 -3
  4. package/dist/commons/conditionals/validate-address.test.d.ts +2 -0
  5. package/dist/commons/conditionals/validate.d.ts +14 -17
  6. package/dist/commons/events/ActionConfig.d.ts +1008 -3209
  7. package/dist/commons/events/ActionDocument.d.ts +9488 -312
  8. package/dist/commons/events/ActionInput.d.ts +5329 -472
  9. package/dist/commons/events/ActionType.d.ts +26 -11
  10. package/dist/commons/events/CompositeFieldValue.d.ts +152 -2
  11. package/dist/commons/events/Conditional.d.ts +21 -5
  12. package/dist/commons/events/Draft.d.ts +351 -48
  13. package/dist/commons/events/EventConfig.d.ts +639 -2862
  14. package/dist/commons/events/EventConfigInput.d.ts +6 -3
  15. package/dist/commons/events/EventDocument.d.ts +3340 -424
  16. package/dist/commons/events/EventIndex.d.ts +6 -3
  17. package/dist/commons/events/EventMetadata.d.ts +3 -0
  18. package/dist/commons/events/FieldConfig.d.ts +383 -104
  19. package/dist/commons/events/FieldTypeMapping.d.ts +104 -207
  20. package/dist/commons/events/FieldValue.d.ts +71 -76
  21. package/dist/commons/events/FormConfig.d.ts +527 -279
  22. package/dist/commons/events/PageConfig.d.ts +335 -0
  23. package/dist/commons/events/TemplateConfig.d.ts +5 -5
  24. package/dist/commons/events/defineConfig.d.ts +40 -417
  25. package/dist/commons/events/index.d.ts +2 -1
  26. package/dist/commons/events/test.utils.d.ts +140 -213
  27. package/dist/commons/events/utils.d.ts +126 -156
  28. package/dist/commons/events/utils.test.d.ts +2 -0
  29. package/dist/conditionals/index.js +166 -81
  30. package/dist/events/index.js +1287 -795
  31. package/dist/scopes/index.d.ts +70 -1
  32. package/dist/scopes/index.js +130 -0
  33. 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,10 +58,18 @@ __export(events_exports, {
51
58
  Clause: () => Clause,
52
59
  Conditional: () => Conditional,
53
60
  ConditionalType: () => ConditionalType,
61
+ ConfirmableActions: () => ConfirmableActions,
62
+ DataEntry: () => DataEntry,
54
63
  DataFieldValue: () => DataFieldValue,
55
64
  DateValue: () => DateValue,
65
+ DeclarationActionConfig: () => DeclarationActionConfig,
66
+ DeclarationActions: () => DeclarationActions,
67
+ DeclarationFormConfig: () => DeclarationFormConfig,
68
+ DeclarationReviewConfig: () => DeclarationReviewConfig,
69
+ DeclarationUpdateActions: () => DeclarationUpdateActions,
56
70
  DeclareActionInput: () => DeclareActionInput,
57
71
  DeduplicationConfig: () => DeduplicationConfig,
72
+ DisplayOnReviewConditional: () => DisplayOnReviewConditional,
58
73
  Draft: () => Draft,
59
74
  DraftInput: () => DraftInput,
60
75
  EmailField: () => EmailField,
@@ -68,6 +83,7 @@ __export(events_exports, {
68
83
  EventSearchIndex: () => EventSearchIndex,
69
84
  EventStatus: () => EventStatus,
70
85
  EventStatuses: () => EventStatuses,
86
+ FieldConditional: () => FieldConditional,
71
87
  FieldConfig: () => FieldConfig,
72
88
  FieldType: () => FieldType,
73
89
  FieldUpdateValue: () => FieldUpdateValue,
@@ -76,15 +92,21 @@ __export(events_exports, {
76
92
  FileFieldValueWithOption: () => FileFieldValueWithOption,
77
93
  FileFieldWithOptionValue: () => FileFieldWithOptionValue,
78
94
  FormConfig: () => FormConfig,
79
- FormPage: () => FormPage,
95
+ FormPageConfig: () => FormPageConfig,
96
+ GenericAddressUpdateValue: () => GenericAddressUpdateValue,
97
+ GenericAddressValue: () => GenericAddressValue,
80
98
  GeographicalArea: () => GeographicalArea,
99
+ ImageMimeType: () => ImageMimeType,
81
100
  LanguageConfig: () => LanguageConfig,
82
101
  MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
102
+ MimeType: () => MimeType,
83
103
  NotifyActionInput: () => NotifyActionInput,
84
104
  NumberFieldValue: () => NumberFieldValue,
85
105
  PageConfig: () => PageConfig,
86
- PageType: () => PageType,
106
+ PageTypes: () => PageTypes,
87
107
  PrintCertificateActionInput: () => PrintCertificateActionInput,
108
+ ReadActionInput: () => ReadActionInput,
109
+ RegisterAction: () => RegisterAction,
88
110
  RegisterActionInput: () => RegisterActionInput,
89
111
  RejectCorrectionActionInput: () => RejectCorrectionActionInput,
90
112
  RejectDeclarationActionInput: () => RejectDeclarationActionInput,
@@ -97,22 +119,28 @@ __export(events_exports, {
97
119
  SummaryConfig: () => SummaryConfig,
98
120
  TextValue: () => TextValue,
99
121
  TranslationConfig: () => TranslationConfig,
122
+ UnassignActionInput: () => UnassignActionInput,
100
123
  UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
101
124
  UrbanAddressValue: () => UrbanAddressValue,
102
125
  ValidateActionInput: () => ValidateActionInput,
103
- VerificationPage: () => VerificationPage,
126
+ VerificationActionConfig: () => VerificationActionConfig,
104
127
  VerificationPageConfig: () => VerificationPageConfig,
105
128
  WorkqueueConfig: () => WorkqueueConfig,
106
129
  alwaysTrue: () => alwaysTrue,
107
130
  and: () => and,
131
+ annotationActions: () => annotationActions,
108
132
  applyDraftsToEventIndex: () => applyDraftsToEventIndex,
109
133
  compositeFieldTypes: () => compositeFieldTypes,
110
134
  createEmptyDraft: () => createEmptyDraft,
111
135
  createValidationSchema: () => createValidationSchema,
112
136
  deepDropNulls: () => deepDropNulls,
137
+ deepMerge: () => deepMerge,
138
+ defineActionForm: () => defineActionForm,
113
139
  defineConditional: () => defineConditional,
114
140
  defineConfig: () => defineConfig,
115
- defineForm: () => defineForm,
141
+ defineDeclarationForm: () => defineDeclarationForm,
142
+ defineFormConditional: () => defineFormConditional,
143
+ defineFormPage: () => defineFormPage,
116
144
  definePage: () => definePage,
117
145
  errorMessages: () => errorMessages,
118
146
  event: () => event,
@@ -122,28 +150,30 @@ __export(events_exports, {
122
150
  eventStatuses: () => eventStatuses,
123
151
  field: () => field,
124
152
  fieldTypes: () => fieldTypes,
125
- findActiveActionFields: () => findActiveActionFields,
126
- findActiveActionForm: () => findActiveActionForm,
127
- findActiveActionFormFields: () => findActiveActionFormFields,
128
- findActiveActionFormPages: () => findActiveActionFormPages,
129
153
  findActiveDrafts: () => findActiveDrafts,
130
- findInputPageFields: () => findInputPageFields,
131
- findPageFields: () => findPageFields,
154
+ findAllFields: () => findAllFields,
155
+ findLastAssignmentAction: () => findLastAssignmentAction,
156
+ findRecordActionPages: () => findRecordActionPages,
157
+ generateActionAnnotationInput: () => generateActionAnnotationInput,
158
+ generateActionDeclarationInput: () => generateActionDeclarationInput,
132
159
  generateActionDocument: () => generateActionDocument,
133
- generateActionInput: () => generateActionInput,
134
160
  generateEventDocument: () => generateEventDocument,
135
161
  generateEventDraftDocument: () => generateEventDraftDocument,
136
162
  generateTransactionId: () => generateTransactionId,
137
- getActiveActionFields: () => getActiveActionFields,
138
- getActiveActionFormPages: () => getActiveActionFormPages,
139
- getAllFields: () => getAllFields,
140
- getAllPages: () => getAllPages,
163
+ generateTranslationConfig: () => generateTranslationConfig,
164
+ getAcceptedActions: () => getAcceptedActions,
165
+ getActionAnnotation: () => getActionAnnotation,
166
+ getActionAnnotationFields: () => getActionAnnotationFields,
167
+ getActionReview: () => getActionReview,
168
+ getActionReviewFields: () => getActionReviewFields,
169
+ getAllAnnotationFields: () => getAllAnnotationFields,
170
+ getAnnotationFromDrafts: () => getAnnotationFromDrafts,
141
171
  getCurrentEventState: () => getCurrentEventState,
142
172
  getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
143
- getEventConfiguration: () => getEventConfiguration,
173
+ getDeclaration: () => getDeclaration,
174
+ getDeclarationFields: () => getDeclarationFields,
175
+ getDeclarationPages: () => getDeclarationPages,
144
176
  getFieldValidationErrors: () => getFieldValidationErrors,
145
- getFormFields: () => getFormFields,
146
- getMetadataForAction: () => getMetadataForAction,
147
177
  isAddressFieldType: () => isAddressFieldType,
148
178
  isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
149
179
  isBulletListFieldType: () => isBulletListFieldType,
@@ -155,6 +185,7 @@ __export(events_exports, {
155
185
  isEmailFieldType: () => isEmailFieldType,
156
186
  isFacilityFieldType: () => isFacilityFieldType,
157
187
  isFieldConfigDefaultValue: () => isFieldConfigDefaultValue,
188
+ isFieldDisplayedOnReview: () => isFieldDisplayedOnReview,
158
189
  isFieldEnabled: () => isFieldEnabled,
159
190
  isFieldValue: () => isFieldValue,
160
191
  isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
@@ -165,6 +196,7 @@ __export(events_exports, {
165
196
  isNumberFieldType: () => isNumberFieldType,
166
197
  isOfficeFieldType: () => isOfficeFieldType,
167
198
  isPageHeaderFieldType: () => isPageHeaderFieldType,
199
+ isPageVisible: () => isPageVisible,
168
200
  isParagraphFieldType: () => isParagraphFieldType,
169
201
  isRadioGroupFieldType: () => isRadioGroupFieldType,
170
202
  isSelectFieldType: () => isSelectFieldType,
@@ -173,50 +205,71 @@ __export(events_exports, {
173
205
  isTextAreaFieldType: () => isTextAreaFieldType,
174
206
  isTextFieldType: () => isTextFieldType,
175
207
  isUndeclaredDraft: () => isUndeclaredDraft,
208
+ isVerificationPage: () => isVerificationPage,
209
+ isWriteAction: () => isWriteAction,
176
210
  mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
177
211
  mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
178
212
  mapFieldTypeToZod: () => mapFieldTypeToZod,
213
+ never: () => never,
179
214
  not: () => not,
215
+ omitHiddenFields: () => omitHiddenFields,
216
+ omitHiddenPaginatedFields: () => omitHiddenPaginatedFields,
180
217
  or: () => or,
181
- resolveLabelsFromKnownFields: () => resolveLabelsFromKnownFields,
182
- stripHiddenFields: () => stripHiddenFields,
183
218
  user: () => user,
184
219
  validate: () => validate,
185
220
  validateFieldInput: () => validateFieldInput,
186
- validateWorkqueueConfig: () => validateWorkqueueConfig
221
+ validateWorkqueueConfig: () => validateWorkqueueConfig,
222
+ writeActions: () => writeActions
187
223
  });
188
224
  module.exports = __toCommonJS(events_exports);
189
225
 
190
226
  // ../commons/src/events/ActionConfig.ts
191
- var import_zod7 = require("zod");
227
+ var import_zod9 = require("zod");
192
228
 
193
229
  // ../commons/src/events/Conditional.ts
194
230
  var import_zod = require("zod");
195
- function Conditional() {
196
- return import_zod.z.custom((val) => typeof val === "object" && val !== null);
197
- }
231
+ var Conditional = import_zod.z.custom(
232
+ (val) => typeof val === "object" && val !== null
233
+ );
198
234
  var ConditionalType = {
199
- /** When 'SHOW' conditional is defined, the action is shown to the user only if the condition is met */
200
235
  SHOW: "SHOW",
201
- /** If 'ENABLE' conditional is defined, the action is enabled only if the condition is met */
202
- ENABLE: "ENABLE"
236
+ ENABLE: "ENABLE",
237
+ DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
203
238
  };
204
239
  var ShowConditional = import_zod.z.object({
205
240
  type: import_zod.z.literal(ConditionalType.SHOW),
206
- conditional: Conditional()
207
- });
241
+ conditional: Conditional
242
+ }).describe(
243
+ "If 'SHOW' conditional is defined, the component is shown to the user only if the condition is met"
244
+ );
208
245
  var EnableConditional = import_zod.z.object({
209
246
  type: import_zod.z.literal(ConditionalType.ENABLE),
210
- conditional: Conditional()
211
- });
247
+ conditional: Conditional
248
+ }).describe(
249
+ "If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
250
+ );
212
251
  var ActionConditional = import_zod.z.discriminatedUnion("type", [
213
252
  // Action can be shown / hidden
214
253
  ShowConditional,
215
254
  // Action can be shown to the user in the list but as disabled
216
255
  EnableConditional
217
256
  ]);
257
+ var DisplayOnReviewConditional = import_zod.z.object({
258
+ type: import_zod.z.literal(ConditionalType.DISPLAY_ON_REVIEW),
259
+ conditional: Conditional
260
+ }).describe(
261
+ "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."
262
+ );
263
+ var FieldConditional = import_zod.z.discriminatedUnion("type", [
264
+ // Field input can be shown / hidden
265
+ ShowConditional,
266
+ // Field input can be shown to the user but as disabled
267
+ EnableConditional,
268
+ // Field output can be shown / hidden on the review page
269
+ DisplayOnReviewConditional
270
+ ]);
218
271
 
219
- // ../commons/src/events/FormConfig.ts
272
+ // ../commons/src/events/PageConfig.ts
220
273
  var import_zod6 = require("zod");
221
274
 
222
275
  // ../commons/src/events/FieldConfig.ts
@@ -276,6 +329,10 @@ var GeographicalArea = {
276
329
  URBAN: "URBAN",
277
330
  RURAL: "RURAL"
278
331
  };
332
+ var AddressType = {
333
+ DOMESTIC: "DOMESTIC",
334
+ INTERNATIONAL: "INTERNATIONAL"
335
+ };
279
336
  var FileFieldValue = import_zod3.z.object({
280
337
  filename: import_zod3.z.string(),
281
338
  originalFilename: import_zod3.z.string(),
@@ -283,6 +340,7 @@ var FileFieldValue = import_zod3.z.object({
283
340
  });
284
341
  var AdminStructure = import_zod3.z.object({
285
342
  country: import_zod3.z.string(),
343
+ addressType: import_zod3.z.literal(AddressType.DOMESTIC),
286
344
  province: import_zod3.z.string(),
287
345
  district: import_zod3.z.string()
288
346
  });
@@ -310,14 +368,33 @@ var RuralAddressUpdateValue = AdminStructure.extend({
310
368
  urbanOrRural: import_zod3.z.literal(GeographicalArea.RURAL),
311
369
  village: import_zod3.z.string().nullish()
312
370
  });
313
- var AddressFieldValue = import_zod3.z.discriminatedUnion("urbanOrRural", [
314
- UrbanAddressValue,
315
- RuralAddressValue
316
- ]);
371
+ var GenericAddressValue = import_zod3.z.object({
372
+ country: import_zod3.z.string(),
373
+ addressType: import_zod3.z.literal(AddressType.INTERNATIONAL),
374
+ state: import_zod3.z.string(),
375
+ district2: import_zod3.z.string(),
376
+ cityOrTown: import_zod3.z.string().optional(),
377
+ addressLine1: import_zod3.z.string().optional(),
378
+ addressLine2: import_zod3.z.string().optional(),
379
+ addressLine3: import_zod3.z.string().optional(),
380
+ postcodeOrZip: import_zod3.z.string().optional()
381
+ });
382
+ var AddressFieldValue = import_zod3.z.discriminatedUnion("urbanOrRural", [UrbanAddressValue, RuralAddressValue]).or(GenericAddressValue);
383
+ var GenericAddressUpdateValue = import_zod3.z.object({
384
+ country: import_zod3.z.string(),
385
+ addressType: import_zod3.z.literal(AddressType.INTERNATIONAL),
386
+ state: import_zod3.z.string(),
387
+ district2: import_zod3.z.string(),
388
+ cityOrTown: import_zod3.z.string().nullish(),
389
+ addressLine1: import_zod3.z.string().nullish(),
390
+ addressLine2: import_zod3.z.string().nullish(),
391
+ addressLine3: import_zod3.z.string().nullish(),
392
+ postcodeOrZip: import_zod3.z.string().nullish()
393
+ });
317
394
  var AddressFieldUpdateValue = import_zod3.z.discriminatedUnion("urbanOrRural", [
318
395
  UrbanAddressUpdateValue,
319
396
  RuralAddressUpdateValue
320
- ]);
397
+ ]).or(GenericAddressUpdateValue);
321
398
  var FileFieldValueWithOption = import_zod3.z.object({
322
399
  filename: import_zod3.z.string(),
323
400
  originalFilename: import_zod3.z.string(),
@@ -333,6 +410,7 @@ var DateValue = import_zod4.z.string().date().describe("Date in the format YYYY-
333
410
  var EmailValue = import_zod4.z.string().email();
334
411
  var CheckboxFieldValue = import_zod4.z.boolean();
335
412
  var NumberFieldValue = import_zod4.z.number();
413
+ var DataFieldValue = import_zod4.z.undefined();
336
414
  var FieldValue = import_zod4.z.union([
337
415
  TextValue,
338
416
  DateValue,
@@ -341,9 +419,10 @@ var FieldValue = import_zod4.z.union([
341
419
  FileFieldValue,
342
420
  FileFieldWithOptionValue,
343
421
  UrbanAddressValue,
344
- RuralAddressValue
422
+ RuralAddressValue,
423
+ DataFieldValue,
424
+ GenericAddressValue
345
425
  ]);
346
- var DataFieldValue = import_zod4.z.record(import_zod4.z.string(), FieldValue);
347
426
  var FieldUpdateValue = import_zod4.z.union([
348
427
  TextValue,
349
428
  DateValue,
@@ -352,7 +431,9 @@ var FieldUpdateValue = import_zod4.z.union([
352
431
  FileFieldValue,
353
432
  FileFieldWithOptionValue,
354
433
  UrbanAddressUpdateValue,
355
- RuralAddressUpdateValue
434
+ RuralAddressUpdateValue,
435
+ DataFieldValue,
436
+ GenericAddressUpdateValue
356
437
  ]);
357
438
 
358
439
  // ../commons/src/events/FieldConfig.ts
@@ -374,14 +455,14 @@ var BaseField = import_zod5.z.object({
374
455
  ]),
375
456
  DependencyExpression
376
457
  ]).optional(),
377
- conditionals: import_zod5.z.array(ActionConditional).default([]).optional(),
458
+ conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
378
459
  required: import_zod5.z.boolean().default(false).optional(),
379
460
  disabled: import_zod5.z.boolean().default(false).optional(),
380
461
  hidden: import_zod5.z.boolean().default(false).optional(),
381
462
  placeholder: TranslationConfig.optional(),
382
463
  validation: import_zod5.z.array(
383
464
  import_zod5.z.object({
384
- validator: Conditional(),
465
+ validator: Conditional,
385
466
  message: TranslationConfig
386
467
  })
387
468
  ).default([]).optional(),
@@ -423,15 +504,25 @@ var TextAreaField = BaseField.extend({
423
504
  postfix: TranslationConfig.optional()
424
505
  }).default({ rows: 4 }).optional()
425
506
  }).describe("Multiline text input");
507
+ var ImageMimeType = import_zod5.z.enum([
508
+ "image/png",
509
+ "image/jpg",
510
+ "image/jpeg",
511
+ "image/svg+xml"
512
+ ]);
513
+ var MimeType = ImageMimeType;
514
+ var DEFAULT_MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;
426
515
  var SignatureField = BaseField.extend({
427
516
  type: import_zod5.z.literal(FieldType.SIGNATURE),
428
517
  signaturePromptLabel: TranslationConfig.describe(
429
518
  "Title of the signature modal"
430
519
  ),
431
520
  configuration: import_zod5.z.object({
432
- maxSizeMb: import_zod5.z.number().optional().describe("Maximum file size in MB"),
433
- allowedFileFormats: import_zod5.z.array(import_zod5.z.string()).optional().describe("List of allowed file formats for the signature")
434
- }).default({}).optional()
521
+ maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
522
+ acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
523
+ }).default({
524
+ maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
525
+ })
435
526
  }).describe("Signature input field");
436
527
  var EmailField = BaseField.extend({
437
528
  type: import_zod5.z.literal(FieldType.EMAIL),
@@ -474,13 +565,17 @@ var PageHeader = BaseField.extend({
474
565
  }).describe("A read-only header component for form pages");
475
566
  var File = BaseField.extend({
476
567
  type: import_zod5.z.literal(FieldType.FILE),
477
- options: import_zod5.z.object({
568
+ configuration: import_zod5.z.object({
569
+ maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
570
+ acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
478
571
  style: import_zod5.z.object({
479
- fullWidth: import_zod5.z.boolean().describe(
572
+ width: import_zod5.z.enum(["full", "auto"]).optional().describe(
480
573
  "Whether the file upload button should take the full width of the container or not"
481
574
  )
482
- })
483
- }).optional()
575
+ }).optional()
576
+ }).default({
577
+ maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
578
+ })
484
579
  }).describe("File upload");
485
580
  var SelectOption = import_zod5.z.object({
486
581
  value: import_zod5.z.string().describe("The value of the option"),
@@ -526,7 +621,7 @@ var AdministrativeAreas = import_zod5.z.enum([
526
621
  ]);
527
622
  var AdministrativeAreaConfiguration = import_zod5.z.object({
528
623
  partOf: import_zod5.z.object({
529
- $data: import_zod5.z.string()
624
+ $declaration: import_zod5.z.string()
530
625
  }).optional().describe("Parent location"),
531
626
  type: AdministrativeAreas
532
627
  }).describe("Administrative area options");
@@ -541,8 +636,14 @@ var Location = BaseField.extend({
541
636
  }).describe("Input field for a location");
542
637
  var FileUploadWithOptions = BaseField.extend({
543
638
  type: import_zod5.z.literal(FieldType.FILE_WITH_OPTIONS),
544
- options: import_zod5.z.array(SelectOption).describe("A list of options")
545
- }).describe("Select input");
639
+ options: import_zod5.z.array(SelectOption).describe("A list of options"),
640
+ configuration: import_zod5.z.object({
641
+ maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
642
+ acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
643
+ }).default({
644
+ maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
645
+ })
646
+ });
546
647
  var Facility = BaseField.extend({
547
648
  type: import_zod5.z.literal(FieldType.FACILITY),
548
649
  defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
@@ -555,12 +656,20 @@ var Address = BaseField.extend({
555
656
  type: import_zod5.z.literal(FieldType.ADDRESS),
556
657
  defaultValue: AddressFieldValue.optional()
557
658
  }).describe("Address input field \u2013 a combination of location and text fields");
558
- var Data = BaseField.extend({
659
+ var DataEntry = import_zod5.z.union([
660
+ import_zod5.z.object({
661
+ label: TranslationConfig,
662
+ value: import_zod5.z.string()
663
+ }),
664
+ import_zod5.z.object({
665
+ fieldId: import_zod5.z.string()
666
+ })
667
+ ]);
668
+ var DataField = BaseField.extend({
559
669
  type: import_zod5.z.literal(FieldType.DATA),
560
670
  configuration: import_zod5.z.object({
561
- title: TranslationConfig.optional(),
562
671
  subtitle: TranslationConfig.optional(),
563
- data: import_zod5.z.array(import_zod5.z.object({ fieldId: import_zod5.z.string() }))
672
+ data: import_zod5.z.array(DataEntry)
564
673
  })
565
674
  }).describe("Data field for displaying read-only data");
566
675
  var FieldConfig = import_zod5.z.discriminatedUnion("type", [
@@ -585,22 +694,24 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
585
694
  SignatureField,
586
695
  EmailField,
587
696
  FileUploadWithOptions,
588
- Data
697
+ DataField
698
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
589
699
  ]);
590
700
 
591
- // ../commons/src/events/FormConfig.ts
592
- var PageType = /* @__PURE__ */ ((PageType2) => {
593
- PageType2["FORM"] = "FORM";
594
- PageType2["VERIFICATION"] = "VERIFICATION";
595
- return PageType2;
596
- })(PageType || {});
597
- var FormPage = import_zod6.z.object({
701
+ // ../commons/src/events/PageConfig.ts
702
+ var PageTypes = import_zod6.z.enum(["FORM", "VERIFICATION"]);
703
+ var PageConfigBase = import_zod6.z.object({
598
704
  id: import_zod6.z.string().describe("Unique identifier for the page"),
599
705
  title: TranslationConfig.describe("Header title of the page"),
600
706
  fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page"),
601
- type: import_zod6.z.literal("FORM" /* FORM */).default("FORM" /* FORM */)
707
+ conditional: Conditional.optional().describe(
708
+ "Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
709
+ )
602
710
  });
603
- var VerificationPageConfig = import_zod6.z.object({
711
+ var FormPageConfig = PageConfigBase.extend({
712
+ type: import_zod6.z.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
713
+ });
714
+ var VerificationActionConfig = import_zod6.z.object({
604
715
  verify: import_zod6.z.object({ label: TranslationConfig }),
605
716
  cancel: import_zod6.z.object({
606
717
  label: TranslationConfig,
@@ -610,135 +721,182 @@ var VerificationPageConfig = import_zod6.z.object({
610
721
  })
611
722
  })
612
723
  }).describe("Actions available on the verification page");
613
- var VerificationPage = FormPage.extend({
614
- type: import_zod6.z.literal("VERIFICATION" /* VERIFICATION */),
615
- actions: VerificationPageConfig
616
- });
617
- var PageConfig = import_zod6.z.preprocess(
618
- (data) => ({
619
- type: data.type ?? "FORM" /* FORM */,
620
- // Default type to "FORM" if not provided
621
- ...data
622
- }),
623
- import_zod6.z.discriminatedUnion("type", [FormPage, VerificationPage])
624
- );
625
- var FormConfig = import_zod6.z.object({
626
- label: TranslationConfig.describe("Human readable description of the form"),
627
- version: import_zod6.z.object({
628
- id: import_zod6.z.string().describe(
629
- "Form version. Semantic versioning recommended. Example: 0.0.1"
630
- ),
631
- label: TranslationConfig.describe(
632
- "Human readable description of the version"
633
- )
634
- }),
635
- active: import_zod6.z.boolean().default(false).describe("Whether the form is active"),
636
- pages: import_zod6.z.array(PageConfig),
637
- review: import_zod6.z.object({
638
- title: TranslationConfig.describe(
639
- "Title of the form to show in review page"
640
- ),
641
- fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the review page for metadata")
642
- })
724
+ var VerificationPageConfig = FormPageConfig.extend({
725
+ type: import_zod6.z.literal(PageTypes.enum.VERIFICATION),
726
+ actions: VerificationActionConfig
643
727
  });
728
+ var PageConfig = import_zod6.z.discriminatedUnion("type", [
729
+ FormPageConfig,
730
+ VerificationPageConfig
731
+ ]);
644
732
 
645
733
  // ../commons/src/events/ActionType.ts
734
+ var import_zod7 = require("zod");
646
735
  var ActionType = {
736
+ // Pre-declaration actions
737
+ DELETE: "DELETE",
647
738
  CREATE: "CREATE",
648
- ASSIGN: "ASSIGN",
649
- UNASSIGN: "UNASSIGN",
650
- REGISTER: "REGISTER",
651
- VALIDATE: "VALIDATE",
652
- REQUEST_CORRECTION: "REQUEST_CORRECTION",
653
- REJECT_CORRECTION: "REJECT_CORRECTION",
654
- APPROVE_CORRECTION: "APPROVE_CORRECTION",
655
- DETECT_DUPLICATE: "DETECT_DUPLICATE",
656
739
  NOTIFY: "NOTIFY",
740
+ // Declaration actions
657
741
  DECLARE: "DECLARE",
658
- DELETE: "DELETE",
659
- PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
660
- CUSTOM: "CUSTOM",
742
+ VALIDATE: "VALIDATE",
743
+ REGISTER: "REGISTER",
744
+ // Declaration system actions. Non-configurable.
745
+ DETECT_DUPLICATE: "DETECT_DUPLICATE",
661
746
  REJECT: "REJECT",
747
+ // REJECT_DECLARATION
662
748
  MARKED_AS_DUPLICATE: "MARKED_AS_DUPLICATE",
663
- ARCHIVE: "ARCHIVE"
749
+ // MARK_AS_DUPLICATE
750
+ ARCHIVE: "ARCHIVE",
751
+ // Record actions
752
+ PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
753
+ REQUEST_CORRECTION: "REQUEST_CORRECTION",
754
+ REJECT_CORRECTION: "REJECT_CORRECTION",
755
+ APPROVE_CORRECTION: "APPROVE_CORRECTION",
756
+ // General actions
757
+ READ: "READ",
758
+ ASSIGN: "ASSIGN",
759
+ UNASSIGN: "UNASSIGN"
664
760
  };
761
+ var ConfirmableActions = [
762
+ ActionType.NOTIFY,
763
+ ActionType.DECLARE,
764
+ ActionType.VALIDATE,
765
+ ActionType.REGISTER,
766
+ ActionType.REJECT,
767
+ ActionType.ARCHIVE,
768
+ ActionType.PRINT_CERTIFICATE
769
+ ];
770
+ var ActionTypes = import_zod7.z.enum([
771
+ "DELETE",
772
+ "CREATE",
773
+ "NOTIFY",
774
+ "DECLARE",
775
+ "VALIDATE",
776
+ "REGISTER",
777
+ "DETECT_DUPLICATE",
778
+ "REJECT",
779
+ "MARKED_AS_DUPLICATE",
780
+ "ARCHIVE",
781
+ "PRINT_CERTIFICATE",
782
+ "REQUEST_CORRECTION",
783
+ "REJECT_CORRECTION",
784
+ "APPROVE_CORRECTION",
785
+ "READ",
786
+ "ASSIGN",
787
+ "UNASSIGN"
788
+ ]);
789
+ var declarationActionValues = [
790
+ ActionTypes.enum.DECLARE,
791
+ ActionTypes.enum.VALIDATE,
792
+ ActionTypes.enum.REGISTER
793
+ ];
794
+ var DeclarationActions = ActionTypes.extract(declarationActionValues);
795
+ var declarationUpdateActionValues = [
796
+ ...declarationActionValues,
797
+ ActionTypes.enum.REQUEST_CORRECTION
798
+ ];
799
+ var DeclarationUpdateActions = ActionTypes.extract(
800
+ declarationUpdateActionValues
801
+ );
802
+ var annotationActions = ActionTypes.exclude(declarationActionValues);
803
+ var writeActions = ActionTypes.exclude([
804
+ ActionType.CREATE,
805
+ ActionType.READ,
806
+ ActionType.ASSIGN,
807
+ ActionType.UNASSIGN
808
+ ]);
809
+
810
+ // ../commons/src/events/FormConfig.ts
811
+ var import_zod8 = require("zod");
812
+ var DeclarationFormConfig = import_zod8.z.object({
813
+ label: TranslationConfig.describe("Human readable description of the form"),
814
+ pages: import_zod8.z.array(FormPageConfig)
815
+ }).describe("Configuration for a declaration form");
816
+ var ActionFormConfig = import_zod8.z.object({
817
+ label: TranslationConfig.describe("Human readable description of the form"),
818
+ pages: import_zod8.z.array(PageConfig)
819
+ });
820
+ var FormConfig = import_zod8.z.union([DeclarationFormConfig, ActionFormConfig]);
665
821
 
666
822
  // ../commons/src/events/ActionConfig.ts
667
- var ActionConditional2 = import_zod7.z.discriminatedUnion("type", [
823
+ var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
668
824
  /** If conditional is defined, the action is shown to the user only if the condition is met */
669
825
  ShowConditional,
670
826
  /** If conditional is defined, the action is enabled only if the condition is met */
671
827
  EnableConditional
672
828
  ]);
673
- var ActionConfigBase = import_zod7.z.object({
829
+ var DeclarationReviewConfig = import_zod9.z.object({
830
+ title: TranslationConfig.describe("Title of the review page"),
831
+ fields: import_zod9.z.array(FieldConfig).describe("Fields to be rendered on the review page for annotations.")
832
+ }).describe("Configuration for **declaration** review page.");
833
+ var ActionConfigBase = import_zod9.z.object({
674
834
  label: TranslationConfig,
675
- conditionals: import_zod7.z.array(ActionConditional2).optional().default([]),
676
- draft: import_zod7.z.boolean().optional(),
677
- forms: import_zod7.z.array(FormConfig)
835
+ conditionals: import_zod9.z.array(ActionConditional2).optional().default([]),
836
+ draft: import_zod9.z.boolean().optional()
678
837
  });
679
838
  var DeclareConfig = ActionConfigBase.merge(
680
- import_zod7.z.object({
681
- type: import_zod7.z.literal(ActionType.DECLARE)
839
+ import_zod9.z.object({
840
+ type: import_zod9.z.literal(ActionType.DECLARE),
841
+ review: DeclarationReviewConfig
682
842
  })
683
843
  );
684
844
  var ValidateConfig = ActionConfigBase.merge(
685
- import_zod7.z.object({
686
- type: import_zod7.z.literal(ActionType.VALIDATE)
845
+ import_zod9.z.object({
846
+ type: import_zod9.z.literal(ActionType.VALIDATE),
847
+ review: DeclarationReviewConfig
848
+ })
849
+ );
850
+ var RegisterConfig = ActionConfigBase.merge(
851
+ import_zod9.z.object({
852
+ type: import_zod9.z.literal(ActionType.REGISTER),
853
+ review: DeclarationReviewConfig
687
854
  })
688
855
  );
689
856
  var RejectDeclarationConfig = ActionConfigBase.merge(
690
- import_zod7.z.object({
691
- type: import_zod7.z.literal(ActionType.REJECT)
857
+ import_zod9.z.object({
858
+ type: import_zod9.z.literal(ActionType.REJECT)
692
859
  })
693
860
  );
694
861
  var MarkedAsDuplicateConfig = ActionConfigBase.merge(
695
- import_zod7.z.object({
696
- type: import_zod7.z.literal(ActionType.MARKED_AS_DUPLICATE)
862
+ import_zod9.z.object({
863
+ type: import_zod9.z.literal(ActionType.MARKED_AS_DUPLICATE)
697
864
  })
698
865
  );
699
866
  var ArchiveConfig = ActionConfigBase.merge(
700
- import_zod7.z.object({
701
- type: import_zod7.z.literal(ActionType.ARCHIVE)
702
- })
703
- );
704
- var RegisterConfig = ActionConfigBase.merge(
705
- import_zod7.z.object({
706
- type: import_zod7.z.literal(ActionType.REGISTER)
867
+ import_zod9.z.object({
868
+ type: import_zod9.z.literal(ActionType.ARCHIVE)
707
869
  })
708
870
  );
709
871
  var DeleteConfig = ActionConfigBase.merge(
710
- import_zod7.z.object({
711
- type: import_zod7.z.literal(ActionType.DELETE)
872
+ import_zod9.z.object({
873
+ type: import_zod9.z.literal(ActionType.DELETE)
712
874
  })
713
875
  );
714
876
  var PrintCertificateActionConfig = ActionConfigBase.merge(
715
- import_zod7.z.object({
716
- type: import_zod7.z.literal(ActionType.PRINT_CERTIFICATE)
877
+ import_zod9.z.object({
878
+ type: import_zod9.z.literal(ActionType.PRINT_CERTIFICATE),
879
+ printForm: ActionFormConfig
717
880
  })
718
881
  );
719
882
  var RequestCorrectionConfig = ActionConfigBase.merge(
720
- import_zod7.z.object({
721
- type: import_zod7.z.literal(ActionType.REQUEST_CORRECTION),
722
- onboardingForm: import_zod7.z.array(PageConfig),
723
- additionalDetailsForm: import_zod7.z.array(PageConfig)
883
+ import_zod9.z.object({
884
+ type: import_zod9.z.literal(ActionType.REQUEST_CORRECTION),
885
+ onboardingForm: import_zod9.z.array(PageConfig),
886
+ additionalDetailsForm: import_zod9.z.array(PageConfig)
724
887
  })
725
888
  );
726
889
  var RejectCorrectionConfig = ActionConfigBase.merge(
727
- import_zod7.z.object({
728
- type: import_zod7.z.literal(ActionType.REJECT_CORRECTION)
890
+ import_zod9.z.object({
891
+ type: import_zod9.z.literal(ActionType.REJECT_CORRECTION)
729
892
  })
730
893
  );
731
894
  var ApproveCorrectionConfig = ActionConfigBase.merge(
732
- import_zod7.z.object({
733
- type: import_zod7.z.literal(ActionType.APPROVE_CORRECTION)
734
- })
735
- );
736
- var CustomConfig = ActionConfigBase.merge(
737
- import_zod7.z.object({
738
- type: import_zod7.z.literal(ActionType.CUSTOM)
895
+ import_zod9.z.object({
896
+ type: import_zod9.z.literal(ActionType.APPROVE_CORRECTION)
739
897
  })
740
898
  );
741
- var ActionConfig = import_zod7.z.discriminatedUnion("type", [
899
+ var ActionConfig = import_zod9.z.discriminatedUnion("type", [
742
900
  DeclareConfig,
743
901
  ValidateConfig,
744
902
  RejectDeclarationConfig,
@@ -749,102 +907,108 @@ var ActionConfig = import_zod7.z.discriminatedUnion("type", [
749
907
  PrintCertificateActionConfig,
750
908
  RequestCorrectionConfig,
751
909
  RejectCorrectionConfig,
752
- ApproveCorrectionConfig,
753
- CustomConfig
910
+ ApproveCorrectionConfig
911
+ ]);
912
+ var DeclarationActionConfig = import_zod9.z.discriminatedUnion("type", [
913
+ DeclareConfig,
914
+ ValidateConfig,
915
+ RegisterConfig
754
916
  ]);
755
917
 
756
918
  // ../commons/src/events/offline/CertificateConfig.ts
757
- var import_zod8 = require("zod");
758
- var FontFamily = import_zod8.z.object({
759
- normal: import_zod8.z.string(),
760
- bold: import_zod8.z.string(),
761
- italics: import_zod8.z.string(),
762
- bolditalics: import_zod8.z.string()
919
+ var import_zod10 = require("zod");
920
+ var FontFamily = import_zod10.z.object({
921
+ normal: import_zod10.z.string(),
922
+ bold: import_zod10.z.string(),
923
+ italics: import_zod10.z.string(),
924
+ bolditalics: import_zod10.z.string()
763
925
  });
764
- var CertificateConfig = import_zod8.z.object({
765
- id: import_zod8.z.string(),
766
- event: import_zod8.z.string(),
926
+ var CertificateConfig = import_zod10.z.object({
927
+ id: import_zod10.z.string(),
928
+ event: import_zod10.z.string(),
767
929
  label: TranslationConfig,
768
- isDefault: import_zod8.z.boolean(),
769
- fee: import_zod8.z.object({
770
- onTime: import_zod8.z.number(),
771
- late: import_zod8.z.number(),
772
- delayed: import_zod8.z.number()
930
+ isDefault: import_zod10.z.boolean(),
931
+ fee: import_zod10.z.object({
932
+ onTime: import_zod10.z.number(),
933
+ late: import_zod10.z.number(),
934
+ delayed: import_zod10.z.number()
773
935
  }),
774
- svgUrl: import_zod8.z.string(),
775
- fonts: import_zod8.z.record(FontFamily).optional()
936
+ svgUrl: import_zod10.z.string(),
937
+ fonts: import_zod10.z.record(FontFamily).optional()
776
938
  });
777
939
  var CertificateTemplateConfig = CertificateConfig.extend({
778
- hash: import_zod8.z.string().optional(),
779
- svg: import_zod8.z.string()
940
+ hash: import_zod10.z.string().optional(),
941
+ svg: import_zod10.z.string()
780
942
  });
781
943
 
782
944
  // ../commons/src/events/offline/LanguageConfig.ts
783
- var import_zod9 = require("zod");
784
- var LanguageConfig = import_zod9.z.object({
785
- lang: import_zod9.z.string(),
945
+ var import_zod11 = require("zod");
946
+ var LanguageConfig = import_zod11.z.object({
947
+ lang: import_zod11.z.string(),
786
948
  /**
787
949
  * client.csv contents
788
950
  */
789
- messages: import_zod9.z.record(import_zod9.z.string())
951
+ messages: import_zod11.z.record(import_zod11.z.string())
790
952
  });
791
953
 
792
954
  // ../commons/src/events/EventConfig.ts
793
- var import_zod18 = require("zod");
955
+ var import_zod20 = require("zod");
794
956
 
795
957
  // ../commons/src/events/DeduplicationConfig.ts
796
- var import_zod10 = require("zod");
797
- var FieldReference = import_zod10.z.string();
798
- var Matcher = import_zod10.z.object({
799
- fieldId: import_zod10.z.string(),
800
- options: import_zod10.z.object({
801
- boost: import_zod10.z.number().optional()
958
+ var import_zod12 = require("zod");
959
+ var FieldReference = import_zod12.z.string();
960
+ var Matcher = import_zod12.z.object({
961
+ fieldId: import_zod12.z.string(),
962
+ options: import_zod12.z.object({
963
+ boost: import_zod12.z.number().optional()
802
964
  }).optional().default({})
803
965
  });
804
966
  var FuzzyMatcher = Matcher.extend({
805
- type: import_zod10.z.literal("fuzzy"),
806
- options: import_zod10.z.object({
967
+ type: import_zod12.z.literal("fuzzy"),
968
+ options: import_zod12.z.object({
807
969
  /**
808
970
  * Names of length 3 or less characters = 0 edits allowed
809
971
  * Names of length 4 - 6 characters = 1 edit allowed
810
972
  * Names of length >7 characters = 2 edits allowed
811
973
  */
812
- fuzziness: import_zod10.z.union([import_zod10.z.string(), import_zod10.z.number()]).optional().default("AUTO:4,7"),
813
- boost: import_zod10.z.number().optional().default(1)
974
+ fuzziness: import_zod12.z.union([import_zod12.z.string(), import_zod12.z.number()]).optional().default("AUTO:4,7"),
975
+ boost: import_zod12.z.number().optional().default(1)
814
976
  }).optional().default({})
815
977
  });
816
978
  var StrictMatcher = Matcher.extend({
817
- type: import_zod10.z.literal("strict"),
818
- options: import_zod10.z.object({
819
- boost: import_zod10.z.number().optional().default(1)
979
+ type: import_zod12.z.literal("strict"),
980
+ options: import_zod12.z.object({
981
+ boost: import_zod12.z.number().optional().default(1)
820
982
  }).optional().default({})
821
983
  });
822
984
  var DateRangeMatcher = Matcher.extend({
823
- type: import_zod10.z.literal("dateRange"),
824
- options: import_zod10.z.object({
825
- days: import_zod10.z.number(),
985
+ type: import_zod12.z.literal("dateRange"),
986
+ options: import_zod12.z.object({
987
+ days: import_zod12.z.number(),
826
988
  origin: FieldReference,
827
- boost: import_zod10.z.number().optional().default(1)
989
+ boost: import_zod12.z.number().optional().default(1)
828
990
  })
829
991
  });
830
992
  var DateDistanceMatcher = Matcher.extend({
831
- type: import_zod10.z.literal("dateDistance"),
832
- options: import_zod10.z.object({
833
- days: import_zod10.z.number(),
993
+ type: import_zod12.z.literal("dateDistance"),
994
+ options: import_zod12.z.object({
995
+ days: import_zod12.z.number(),
834
996
  origin: FieldReference,
835
- boost: import_zod10.z.number().optional().default(1)
997
+ boost: import_zod12.z.number().optional().default(1)
836
998
  })
837
999
  });
838
- var And = import_zod10.z.object({
839
- type: import_zod10.z.literal("and"),
840
- clauses: import_zod10.z.lazy(() => Clause.array())
1000
+ var And = import_zod12.z.object({
1001
+ type: import_zod12.z.literal("and"),
1002
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
1003
+ clauses: import_zod12.z.lazy(() => Clause.array())
841
1004
  });
842
- var Or = import_zod10.z.object({
843
- type: import_zod10.z.literal("or"),
844
- clauses: import_zod10.z.lazy(() => Clause.array())
1005
+ var Or = import_zod12.z.object({
1006
+ type: import_zod12.z.literal("or"),
1007
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
1008
+ clauses: import_zod12.z.lazy(() => Clause.array())
845
1009
  });
846
- var Clause = import_zod10.z.lazy(
847
- () => import_zod10.z.discriminatedUnion("type", [
1010
+ var Clause = import_zod12.z.lazy(
1011
+ () => import_zod12.z.discriminatedUnion("type", [
848
1012
  And,
849
1013
  Or,
850
1014
  FuzzyMatcher,
@@ -853,37 +1017,37 @@ var Clause = import_zod10.z.lazy(
853
1017
  DateDistanceMatcher
854
1018
  ])
855
1019
  );
856
- var DeduplicationConfig = import_zod10.z.object({
857
- id: import_zod10.z.string(),
1020
+ var DeduplicationConfig = import_zod12.z.object({
1021
+ id: import_zod12.z.string(),
858
1022
  label: TranslationConfig,
859
1023
  query: Clause
860
1024
  });
861
1025
 
862
1026
  // ../commons/src/events/SummaryConfig.ts
863
- var import_zod11 = require("zod");
864
- var Field = import_zod11.z.object({
865
- id: import_zod11.z.string().describe("Id of summary field"),
1027
+ var import_zod13 = require("zod");
1028
+ var Field = import_zod13.z.object({
1029
+ id: import_zod13.z.string().describe("Id of summary field"),
866
1030
  value: TranslationConfig.describe(
867
1031
  "Summary field value. Can utilise values defined in configuration and EventMetadata"
868
1032
  ),
869
1033
  label: TranslationConfig,
870
1034
  emptyValueMessage: TranslationConfig.optional()
871
1035
  });
872
- var Title = import_zod11.z.object({
873
- id: import_zod11.z.string(),
1036
+ var Title = import_zod13.z.object({
1037
+ id: import_zod13.z.string(),
874
1038
  label: TranslationConfig.describe("Title content"),
875
1039
  emptyValueMessage: TranslationConfig.optional()
876
1040
  });
877
- var SummaryConfig = import_zod11.z.object({
1041
+ var SummaryConfig = import_zod13.z.object({
878
1042
  title: Title.describe("Title of summary view."),
879
- fields: import_zod11.z.array(Field).describe("Fields rendered in summary view.")
1043
+ fields: import_zod13.z.array(Field).describe("Fields rendered in summary view.")
880
1044
  }).describe("Configuration for summary in event.");
881
1045
 
882
1046
  // ../commons/src/events/WorkqueueConfig.ts
883
- var import_zod13 = require("zod");
1047
+ var import_zod15 = require("zod");
884
1048
 
885
1049
  // ../commons/src/events/EventMetadata.ts
886
- var import_zod12 = require("zod");
1050
+ var import_zod14 = require("zod");
887
1051
  var EventStatus = {
888
1052
  CREATED: "CREATED",
889
1053
  NOTIFIED: "NOTIFIED",
@@ -895,18 +1059,19 @@ var EventStatus = {
895
1059
  ARCHIVED: "ARCHIVED"
896
1060
  };
897
1061
  var eventStatuses = Object.values(EventStatus);
898
- var EventStatuses = import_zod12.z.nativeEnum(EventStatus);
899
- var EventMetadata = import_zod12.z.object({
900
- id: import_zod12.z.string(),
901
- type: import_zod12.z.string(),
1062
+ var EventStatuses = import_zod14.z.nativeEnum(EventStatus);
1063
+ var EventMetadata = import_zod14.z.object({
1064
+ id: import_zod14.z.string(),
1065
+ type: import_zod14.z.string(),
902
1066
  status: EventStatuses,
903
- createdAt: import_zod12.z.string().datetime(),
904
- createdBy: import_zod12.z.string(),
905
- createdAtLocation: import_zod12.z.string(),
906
- modifiedAt: import_zod12.z.string().datetime(),
907
- assignedTo: import_zod12.z.string().nullish(),
908
- updatedBy: import_zod12.z.string(),
909
- trackingId: import_zod12.z.string()
1067
+ createdAt: import_zod14.z.string().datetime(),
1068
+ createdBy: import_zod14.z.string(),
1069
+ createdAtLocation: import_zod14.z.string(),
1070
+ modifiedAt: import_zod14.z.string().datetime(),
1071
+ assignedTo: import_zod14.z.string().nullish(),
1072
+ updatedBy: import_zod14.z.string(),
1073
+ trackingId: import_zod14.z.string(),
1074
+ registrationNumber: import_zod14.z.string().nullish()
910
1075
  });
911
1076
  var eventMetadataLabelMap = {
912
1077
  "event.assignedTo": {
@@ -958,28 +1123,33 @@ var eventMetadataLabelMap = {
958
1123
  id: "event.trackingId.label",
959
1124
  defaultMessage: "Tracking ID",
960
1125
  description: "Tracking ID"
1126
+ },
1127
+ "event.registrationNumber": {
1128
+ id: "event.registrationNumber.label",
1129
+ defaultMessage: "Registration Number",
1130
+ description: "Registration Number"
961
1131
  }
962
1132
  };
963
1133
 
964
1134
  // ../commons/src/events/WorkqueueConfig.ts
965
- var WorkqueueConfig = import_zod13.z.object({
966
- id: import_zod13.z.string().describe("Unique identifier for workqueue."),
967
- filters: import_zod13.z.array(
968
- import_zod13.z.object({
969
- status: import_zod13.z.array(EventStatuses).describe("Defines which statusese are included in the workqueue.")
1135
+ var WorkqueueConfig = import_zod15.z.object({
1136
+ id: import_zod15.z.string().describe("Unique identifier for workqueue."),
1137
+ filters: import_zod15.z.array(
1138
+ import_zod15.z.object({
1139
+ status: import_zod15.z.array(EventStatuses).describe("Defines which statusese are included in the workqueue.")
970
1140
  })
971
1141
  ).describe("Filters to be applied to workqueue.")
972
1142
  }).describe("Configuration for workqueue.");
973
1143
 
974
1144
  // ../commons/src/events/AdvancedSearchConfig.ts
975
- var import_zod14 = require("zod");
976
- var AdvancedSearchConfig = import_zod14.z.object({
1145
+ var import_zod16 = require("zod");
1146
+ var AdvancedSearchConfig = import_zod16.z.object({
977
1147
  title: TranslationConfig.describe("Advanced search tab title"),
978
- fields: import_zod14.z.array(
979
- import_zod14.z.object({
980
- fieldId: import_zod14.z.string(),
981
- config: import_zod14.z.object({
982
- type: import_zod14.z.enum(["FUZZY", "EXACT", "RANGE"]).describe("Determines the type of field")
1148
+ fields: import_zod16.z.array(
1149
+ import_zod16.z.object({
1150
+ fieldId: import_zod16.z.string(),
1151
+ config: import_zod16.z.object({
1152
+ type: import_zod16.z.enum(["FUZZY", "EXACT", "RANGE"]).describe("Determines the type of field")
983
1153
  }).optional().describe("Configuration options for the field")
984
1154
  })
985
1155
  ).optional().default([]).describe("Advanced search fields.")
@@ -989,12 +1159,12 @@ var AdvancedSearchConfig = import_zod14.z.object({
989
1159
  var import_lodash = require("lodash");
990
1160
 
991
1161
  // ../commons/src/workqueues/WorkqueueConfig.ts
992
- var import_zod16 = require("zod");
1162
+ var import_zod18 = require("zod");
993
1163
 
994
1164
  // ../commons/src/workqueues/defaultColumns.ts
995
- var import_zod15 = require("zod");
996
- var WorkQueueColumnConfig = import_zod15.z.object({
997
- id: import_zod15.z.string(),
1165
+ var import_zod17 = require("zod");
1166
+ var WorkQueueColumnConfig = import_zod17.z.object({
1167
+ id: import_zod17.z.string(),
998
1168
  label: TranslationConfig
999
1169
  });
1000
1170
  var defaultColumns = {
@@ -1031,16 +1201,16 @@ var defaultColumns = {
1031
1201
  }
1032
1202
  }
1033
1203
  };
1034
- var DefaultColumnKeys = import_zod15.z.enum(
1204
+ var DefaultColumnKeys = import_zod17.z.enum(
1035
1205
  Object.keys(defaultColumns)
1036
1206
  );
1037
1207
 
1038
1208
  // ../commons/src/workqueues/WorkqueueConfig.ts
1039
- var rootWorkqueueConfig = import_zod16.z.object({
1040
- id: import_zod16.z.string(),
1209
+ var rootWorkqueueConfig = import_zod18.z.object({
1210
+ id: import_zod18.z.string(),
1041
1211
  title: TranslationConfig,
1042
- columns: import_zod16.z.array(WorkQueueColumnConfig),
1043
- defaultColumns: import_zod16.z.array(DefaultColumnKeys)
1212
+ columns: import_zod18.z.array(WorkQueueColumnConfig),
1213
+ defaultColumns: import_zod18.z.array(DefaultColumnKeys)
1044
1214
  });
1045
1215
  var defineWorkqueue = (config) => rootWorkqueueConfig.parse(config);
1046
1216
 
@@ -1120,7 +1290,7 @@ var import_ajv_formats = __toESM(require("ajv-formats"));
1120
1290
  var import_date_fns = require("date-fns");
1121
1291
 
1122
1292
  // ../commons/src/events/FieldTypeMapping.ts
1123
- var import_zod17 = require("zod");
1293
+ var import_zod19 = require("zod");
1124
1294
  function mapFieldTypeToZod(type, required) {
1125
1295
  let schema;
1126
1296
  switch (type) {
@@ -1173,7 +1343,7 @@ function createValidationSchema(config) {
1173
1343
  for (const field2 of config) {
1174
1344
  shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
1175
1345
  }
1176
- return import_zod17.z.object(shape);
1346
+ return import_zod19.z.object(shape);
1177
1347
  }
1178
1348
  function mapFieldTypeToMockValue(field2, i) {
1179
1349
  switch (field2.type) {
@@ -1199,6 +1369,7 @@ function mapFieldTypeToMockValue(field2, i) {
1199
1369
  case FieldType.ADDRESS:
1200
1370
  return {
1201
1371
  country: "FAR",
1372
+ addressType: AddressType.DOMESTIC,
1202
1373
  province: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
1203
1374
  district: "5ef450bc-712d-48ad-93f3-8da0fa453baa",
1204
1375
  urbanOrRural: "URBAN",
@@ -1249,6 +1420,7 @@ function mapFieldTypeToEmptyValue(field2) {
1249
1420
  case FieldType.ADDRESS:
1250
1421
  return {
1251
1422
  country: null,
1423
+ addressType: AddressType.DOMESTIC,
1252
1424
  province: null,
1253
1425
  district: null,
1254
1426
  urbanOrRural: "URBAN",
@@ -1338,7 +1510,8 @@ var isDataFieldType = (field2) => {
1338
1510
 
1339
1511
  // ../commons/src/conditionals/validate.ts
1340
1512
  var ajv = new import_ajv.default({
1341
- $data: true
1513
+ $data: true,
1514
+ allowUnionTypes: true
1342
1515
  });
1343
1516
  (0, import_ajv_formats.default)(ajv);
1344
1517
  function validate(schema, data) {
@@ -1371,6 +1544,9 @@ function isFieldVisible(field2, form) {
1371
1544
  function isFieldEnabled(field2, form) {
1372
1545
  return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
1373
1546
  }
1547
+ function isFieldDisplayedOnReview(field2, form) {
1548
+ return isFieldVisible(field2, form) && isFieldConditionMet(field2, form, ConditionalType.DISPLAY_ON_REVIEW);
1549
+ }
1374
1550
  var errorMessages = {
1375
1551
  hiddenField: {
1376
1552
  id: "v2.error.hidden",
@@ -1398,12 +1574,14 @@ var errorMessages = {
1398
1574
  id: "v2.error.invalid"
1399
1575
  }
1400
1576
  };
1401
- var createIntlError = (message) => ({
1402
- message: {
1403
- message
1404
- }
1405
- });
1406
- var zodToIntlErrorMap = (issue, _ctx) => {
1577
+ function createIntlError(message) {
1578
+ return {
1579
+ message: {
1580
+ message
1581
+ }
1582
+ };
1583
+ }
1584
+ function zodToIntlErrorMap(issue, _ctx) {
1407
1585
  switch (issue.code) {
1408
1586
  case "invalid_string": {
1409
1587
  if (_ctx.data === "") {
@@ -1429,10 +1607,41 @@ var zodToIntlErrorMap = (issue, _ctx) => {
1429
1607
  }
1430
1608
  break;
1431
1609
  }
1610
+ case "invalid_union": {
1611
+ for (const { issues } of issue.unionErrors) {
1612
+ for (const e of issues) {
1613
+ if (zodToIntlErrorMap(e, _ctx).message.message.id !== "v2.error.required") {
1614
+ return createIntlError(errorMessages.invalidInput);
1615
+ }
1616
+ }
1617
+ }
1618
+ return createIntlError(errorMessages.requiredField);
1619
+ }
1432
1620
  }
1433
1621
  return createIntlError(errorMessages.invalidInput);
1434
- };
1435
- function getFieldValidationErrors({
1622
+ }
1623
+ function runCustomFieldValidations({
1624
+ field: field2,
1625
+ conditionalParameters
1626
+ }) {
1627
+ return (field2.validation ?? []).filter((validation) => {
1628
+ return !validate(validation.validator, conditionalParameters);
1629
+ }).map((validation) => ({ message: validation.message }));
1630
+ }
1631
+ function validateFieldInput({
1632
+ field: field2,
1633
+ value
1634
+ }) {
1635
+ const rawError = mapFieldTypeToZod(field2.type, field2.required).safeParse(
1636
+ value,
1637
+ {
1638
+ // @ts-expect-error
1639
+ errorMap: zodToIntlErrorMap
1640
+ }
1641
+ );
1642
+ return rawError.error?.issues.map((issue) => issue.message) ?? [];
1643
+ }
1644
+ function runFieldValidations({
1436
1645
  field: field2,
1437
1646
  values
1438
1647
  }) {
@@ -1440,6 +1649,23 @@ function getFieldValidationErrors({
1440
1649
  $form: values,
1441
1650
  $now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
1442
1651
  };
1652
+ const fieldValidationResult = validateFieldInput({
1653
+ field: field2,
1654
+ value: values[field2.id]
1655
+ });
1656
+ const customValidationResults = runCustomFieldValidations({
1657
+ field: field2,
1658
+ conditionalParameters
1659
+ });
1660
+ return {
1661
+ // Assumes that custom validation errors are based on the field type, and extend the validation.
1662
+ errors: [...fieldValidationResult, ...customValidationResults]
1663
+ };
1664
+ }
1665
+ function getFieldValidationErrors({
1666
+ field: field2,
1667
+ values
1668
+ }) {
1443
1669
  if (!isFieldVisible(field2, values) || !isFieldEnabled(field2, values)) {
1444
1670
  if (values[field2.id]) {
1445
1671
  return {
@@ -1454,41 +1680,21 @@ function getFieldValidationErrors({
1454
1680
  errors: []
1455
1681
  };
1456
1682
  }
1457
- const fieldValidationResult = validateFieldInput({
1683
+ return runFieldValidations({
1458
1684
  field: field2,
1459
- value: values[field2.id]
1460
- });
1461
- const customValidationResults = runCustomFieldValidations({
1462
- field: field2,
1463
- conditionalParameters
1685
+ values
1464
1686
  });
1465
- return {
1466
- // Assumes that custom validation errors are based on the field type, and extend the validation.
1467
- errors: [...fieldValidationResult, ...customValidationResults]
1468
- };
1469
- }
1470
- function runCustomFieldValidations({
1471
- field: field2,
1472
- conditionalParameters
1473
- }) {
1474
- return (field2.validation ?? []).filter((validation) => {
1475
- return !validate(validation.validator, conditionalParameters);
1476
- }).map((validation) => ({ message: validation.message }));
1477
1687
  }
1478
- function validateFieldInput({
1479
- field: field2,
1480
- value
1481
- }) {
1482
- const rawError = mapFieldTypeToZod(field2.type, field2.required).safeParse(
1483
- value,
1484
- {
1485
- // @ts-expect-error
1486
- errorMap: zodToIntlErrorMap
1487
- }
1488
- );
1489
- return rawError.error?.issues.map((issue) => issue.message) ?? [];
1688
+
1689
+ // ../commons/src/uuid.ts
1690
+ var import_uuid = require("uuid");
1691
+ function getUUID() {
1692
+ return (0, import_uuid.v4)();
1490
1693
  }
1491
1694
 
1695
+ // ../commons/src/events/utils.ts
1696
+ var import_date_fns2 = require("date-fns");
1697
+
1492
1698
  // ../commons/src/utils.ts
1493
1699
  function getOrThrow(x, message) {
1494
1700
  if (x === void 0 || x === null) {
@@ -1497,73 +1703,64 @@ function getOrThrow(x, message) {
1497
1703
  return x;
1498
1704
  }
1499
1705
 
1500
- // ../commons/src/uuid.ts
1501
- var import_uuid = require("uuid");
1502
- function getUUID() {
1503
- return (0, import_uuid.v4)();
1504
- }
1505
-
1506
1706
  // ../commons/src/events/utils.ts
1507
- function isMetadataField(field2) {
1508
- return field2 in eventMetadataLabelMap;
1509
- }
1510
- var findInputPageFields = (config) => {
1511
- return (0, import_lodash.flattenDeep)(
1512
- config.actions.map(
1513
- ({ forms }) => forms.map(
1514
- ({ pages }) => pages.map(
1515
- ({ fields }) => fields.map(({ id, label }) => ({ id, label }))
1516
- )
1517
- )
1518
- )
1519
- );
1707
+ function isDeclarationActionConfig(action) {
1708
+ return DeclarationActions.safeParse(action.type).success;
1709
+ }
1710
+ function getDeclarationFields(configuration) {
1711
+ return configuration.declaration.pages.flatMap(({ fields }) => fields);
1712
+ }
1713
+ function getDeclarationPages(configuration) {
1714
+ return configuration.declaration.pages;
1715
+ }
1716
+ function getDeclaration(configuration) {
1717
+ return configuration.declaration;
1718
+ }
1719
+ var getActionAnnotationFields = (actionConfig) => {
1720
+ if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
1721
+ return [
1722
+ ...actionConfig.onboardingForm.flatMap(({ fields }) => fields),
1723
+ ...actionConfig.additionalDetailsForm.flatMap(({ fields }) => fields)
1724
+ ];
1725
+ }
1726
+ if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
1727
+ return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
1728
+ }
1729
+ if (isDeclarationActionConfig(actionConfig)) {
1730
+ return actionConfig.review.fields;
1731
+ }
1732
+ return [];
1520
1733
  };
1521
- var findPageFields = (config) => {
1522
- return (0, import_lodash.flattenDeep)(
1523
- config.actions.map((action) => {
1524
- if (action.type === ActionType.REQUEST_CORRECTION) {
1525
- return [
1526
- ...action.forms.map(({ pages }) => pages.map(({ fields }) => fields)),
1527
- ...action.onboardingForm.flatMap(({ fields }) => fields),
1528
- ...action.additionalDetailsForm.flatMap(({ fields }) => fields)
1529
- ];
1530
- }
1531
- return action.forms.map(({ pages }) => pages.map(({ fields }) => fields));
1532
- })
1533
- );
1734
+ var getAllAnnotationFields = (config) => {
1735
+ return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
1534
1736
  };
1535
- var resolveLabelsFromKnownFields = ({
1536
- pageFields,
1537
- refFields
1538
- }) => {
1539
- return refFields.map((field2) => {
1540
- if (field2.label) {
1541
- return field2;
1542
- }
1543
- if (isMetadataField(field2.id)) {
1544
- return {
1545
- ...field2,
1546
- label: eventMetadataLabelMap[field2.id]
1547
- };
1548
- }
1549
- const pageLabel = pageFields.find((pageField) => pageField.id === field2.id);
1550
- if (!pageLabel) {
1551
- throw new Error(`Referenced field ${field2.id} does not have a label`);
1552
- }
1553
- return {
1554
- ...field2,
1555
- label: pageLabel.label
1556
- };
1557
- });
1558
- };
1559
- function getAllFields(configuration) {
1560
- return configuration.actions.flatMap((action) => action.forms.filter((form) => form.active)).flatMap((form) => [
1561
- ...form.review.fields,
1562
- ...form.pages.flatMap((page) => page.fields)
1737
+ var findAllFields = (config) => {
1738
+ return (0, import_lodash.flattenDeep)([
1739
+ ...getDeclarationFields(config),
1740
+ ...getAllAnnotationFields(config)
1563
1741
  ]);
1742
+ };
1743
+ var findRecordActionPages = (config, actionType) => {
1744
+ const action = config.actions.find((a) => a.type === actionType);
1745
+ if (action?.type === ActionType.REQUEST_CORRECTION) {
1746
+ return [...action.onboardingForm, ...action.additionalDetailsForm];
1747
+ }
1748
+ if (action?.type === ActionType.PRINT_CERTIFICATE) {
1749
+ return action.printForm.pages;
1750
+ }
1751
+ return [];
1752
+ };
1753
+ function getActionReview(configuration, actionType) {
1754
+ const [actionConfig] = configuration.actions.filter(
1755
+ (a) => a.type === actionType
1756
+ );
1757
+ return getOrThrow(
1758
+ actionConfig.review,
1759
+ `No review config found for ${actionType}`
1760
+ );
1564
1761
  }
1565
- function getAllPages(configuration) {
1566
- return configuration.actions.flatMap((action) => action.forms.filter((form) => form.active)).flatMap((form) => form.pages);
1762
+ function getActionReviewFields(configuration, actionType) {
1763
+ return getActionReview(configuration, actionType).fields;
1567
1764
  }
1568
1765
  function validateWorkqueueConfig(workqueueConfigs) {
1569
1766
  workqueueConfigs.map((workqueue) => {
@@ -1577,68 +1774,30 @@ function validateWorkqueueConfig(workqueueConfigs) {
1577
1774
  }
1578
1775
  });
1579
1776
  }
1580
- var findActiveActionForm = (configuration, action) => {
1581
- const actionConfig = configuration.actions.find((a) => a.type === action);
1582
- const form = actionConfig?.forms.find((f) => f.active);
1583
- return form;
1584
- };
1585
- var findActiveActionFormPages = (configuration, action) => {
1586
- return findActiveActionForm(configuration, action)?.pages;
1587
- };
1588
- var getFormFields = (formConfig) => {
1589
- return formConfig.pages.flatMap((p) => p.fields);
1590
- };
1591
- var findActiveActionFormFields = (configuration, action) => {
1592
- const form = findActiveActionForm(configuration, action);
1593
- return form ? getFormFields(form) : void 0;
1594
- };
1595
- var findActiveActionFields = (configuration, action) => {
1596
- const form = findActiveActionForm(configuration, action);
1597
- const reviewFields = form?.review.fields;
1598
- const formFields = form ? getFormFields(form) : void 0;
1599
- const allFields = formFields ? formFields.concat(reviewFields ?? []) : reviewFields;
1600
- return allFields;
1601
- };
1602
- var getActiveActionFormPages = (configuration, action) => {
1603
- return getOrThrow(
1604
- findActiveActionForm(configuration, action)?.pages,
1605
- "Form configuration not found for type: " + configuration.id
1606
- );
1607
- };
1608
- function getActiveActionFields(configuration, action) {
1609
- const fields = findActiveActionFields(configuration, action);
1610
- if (!fields) {
1611
- throw new Error(`No active field config found for action type ${action}`);
1612
- }
1613
- return fields;
1614
- }
1615
- function getEventConfiguration(eventConfigurations, type) {
1616
- const config = eventConfigurations.find((config2) => config2.id === type);
1617
- if (!config) {
1618
- throw new Error(`Event configuration not found for type: ${type}`);
1619
- }
1620
- return config;
1621
- }
1622
- function isOptionalUncheckedCheckbox(field2, form) {
1623
- if (field2.type !== FieldType.CHECKBOX || field2.required) {
1624
- return false;
1777
+ function isPageVisible(page, formValues) {
1778
+ if (!page.conditional) {
1779
+ return true;
1625
1780
  }
1626
- return !form[field2.id];
1781
+ return validate(page.conditional, {
1782
+ $form: formValues,
1783
+ $now: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
1784
+ });
1627
1785
  }
1628
- function stripHiddenFields(fields, data) {
1629
- return (0, import_lodash.omitBy)(data, (_2, fieldId) => {
1786
+ function omitHiddenFields(fields, values) {
1787
+ return (0, import_lodash.omitBy)(values, (_, fieldId) => {
1630
1788
  const field2 = fields.find((f) => f.id === fieldId);
1631
1789
  if (!field2) {
1632
1790
  return true;
1633
1791
  }
1634
- if (isOptionalUncheckedCheckbox(field2, data)) {
1635
- return true;
1636
- }
1637
- return !isFieldVisible(field2, data);
1792
+ return !isFieldVisible(field2, values);
1638
1793
  });
1639
1794
  }
1795
+ function omitHiddenPaginatedFields(formConfig, declaration) {
1796
+ const visiblePagesFormFields = formConfig.pages.filter((p) => isPageVisible(p, declaration)).flatMap((p) => p.fields);
1797
+ return omitHiddenFields(visiblePagesFormFields, declaration);
1798
+ }
1640
1799
  function findActiveDrafts(event2, drafts) {
1641
- const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
1800
+ const actions = event2.actions.slice().filter(({ type }) => type !== ActionType.READ).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
1642
1801
  const lastAction = actions[actions.length - 1];
1643
1802
  return drafts.filter(({ createdAt }) => createdAt >= lastAction.createdAt).filter(({ eventId }) => eventId === event2.id);
1644
1803
  }
@@ -1650,28 +1809,58 @@ function createEmptyDraft(eventId, draftId, actionType) {
1650
1809
  transactionId: getUUID(),
1651
1810
  action: {
1652
1811
  type: actionType,
1653
- data: {},
1654
- metadata: {},
1812
+ declaration: {},
1813
+ annotation: {},
1655
1814
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1656
1815
  createdBy: "@todo",
1657
1816
  createdAtLocation: "@todo"
1658
1817
  }
1659
1818
  };
1660
1819
  }
1820
+ function isVerificationPage(page) {
1821
+ return page.type === PageTypes.enum.VERIFICATION;
1822
+ }
1823
+ function deepMerge(currentDocument, actionDocument) {
1824
+ return (0, import_lodash.mergeWith)(
1825
+ currentDocument,
1826
+ actionDocument,
1827
+ (previousValue, incomingValue) => {
1828
+ if (incomingValue === void 0) {
1829
+ return previousValue;
1830
+ }
1831
+ if ((0, import_lodash.isArray)(incomingValue)) {
1832
+ return incomingValue;
1833
+ }
1834
+ if ((0, import_lodash.isObject)(previousValue) && (0, import_lodash.isObject)(incomingValue)) {
1835
+ return void 0;
1836
+ }
1837
+ return incomingValue;
1838
+ }
1839
+ );
1840
+ }
1841
+ function findLastAssignmentAction(actions) {
1842
+ return actions.filter(
1843
+ ({ type }) => type === ActionType.ASSIGN || type === ActionType.UNASSIGN
1844
+ ).reduce((latestAction, action) => !latestAction || action.createdAt > latestAction.createdAt ? action : latestAction, void 0);
1845
+ }
1846
+ function isWriteAction(actionType) {
1847
+ return writeActions.safeParse(actionType).success;
1848
+ }
1661
1849
 
1662
1850
  // ../commons/src/events/EventConfig.ts
1663
- var EventConfig = import_zod18.z.object({
1664
- id: import_zod18.z.string().describe(
1851
+ var EventConfig = import_zod20.z.object({
1852
+ id: import_zod20.z.string().describe(
1665
1853
  'A machine-readable identifier for the event, e.g. "birth" or "death"'
1666
1854
  ),
1667
1855
  summary: SummaryConfig,
1668
1856
  label: TranslationConfig,
1669
- actions: import_zod18.z.array(ActionConfig),
1670
- workqueues: import_zod18.z.array(WorkqueueConfig),
1671
- deduplication: import_zod18.z.array(DeduplicationConfig).optional().default([]),
1672
- advancedSearch: import_zod18.z.array(AdvancedSearchConfig).optional().default([])
1857
+ actions: import_zod20.z.array(ActionConfig),
1858
+ declaration: DeclarationFormConfig,
1859
+ workqueues: import_zod20.z.array(WorkqueueConfig),
1860
+ deduplication: import_zod20.z.array(DeduplicationConfig).optional().default([]),
1861
+ advancedSearch: import_zod20.z.array(AdvancedSearchConfig).optional().default([])
1673
1862
  }).superRefine((event2, ctx) => {
1674
- const allFields = findPageFields(event2);
1863
+ const allFields = findAllFields(event2);
1675
1864
  const fieldIds = allFields.map((field2) => field2.id);
1676
1865
  const advancedSearchFields = event2.advancedSearch.flatMap(
1677
1866
  (section) => section.fields.flatMap((field2) => field2.fieldId)
@@ -1698,106 +1887,118 @@ var EventConfig = import_zod18.z.object({
1698
1887
  });
1699
1888
 
1700
1889
  // ../commons/src/events/EventConfigInput.ts
1701
- var defineForm = (form) => FormConfig.parse(form);
1702
- var definePage = (formPage) => PageConfig.parse(formPage);
1890
+ var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
1891
+ var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
1892
+ var definePage = (page) => PageConfig.parse(page);
1893
+ var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
1703
1894
 
1704
1895
  // ../commons/src/events/Draft.ts
1705
- var import_zod21 = require("zod");
1896
+ var import_zod23 = require("zod");
1706
1897
 
1707
1898
  // ../commons/src/events/ActionDocument.ts
1708
- var import_zod19 = require("zod");
1709
- var ActionUpdate = import_zod19.z.record(import_zod19.z.string(), FieldUpdateValue);
1710
- var ActionBase = import_zod19.z.object({
1711
- id: import_zod19.z.string(),
1712
- createdAt: import_zod19.z.string().datetime(),
1713
- createdBy: import_zod19.z.string(),
1714
- data: ActionUpdate,
1715
- metadata: ActionUpdate.optional(),
1716
- createdAtLocation: import_zod19.z.string()
1899
+ var import_zod21 = require("zod");
1900
+ var ActionUpdate = import_zod21.z.record(import_zod21.z.string(), FieldUpdateValue);
1901
+ var ActionStatus = {
1902
+ Requested: "Requested",
1903
+ Accepted: "Accepted",
1904
+ Rejected: "Rejected"
1905
+ };
1906
+ var ActionBase = import_zod21.z.object({
1907
+ id: import_zod21.z.string(),
1908
+ createdAt: import_zod21.z.string().datetime(),
1909
+ createdBy: import_zod21.z.string(),
1910
+ declaration: ActionUpdate,
1911
+ annotation: ActionUpdate.optional(),
1912
+ createdAtLocation: import_zod21.z.string(),
1913
+ status: import_zod21.z.enum([
1914
+ ActionStatus.Requested,
1915
+ ActionStatus.Accepted,
1916
+ ActionStatus.Rejected
1917
+ ]),
1918
+ // If the action is an asynchronous confirmation for another action, we will save the original action id here.
1919
+ originalActionId: import_zod21.z.string().optional()
1717
1920
  });
1718
1921
  var AssignedAction = ActionBase.merge(
1719
- import_zod19.z.object({
1720
- type: import_zod19.z.literal(ActionType.ASSIGN),
1721
- assignedTo: import_zod19.z.string()
1922
+ import_zod21.z.object({
1923
+ type: import_zod21.z.literal(ActionType.ASSIGN),
1924
+ assignedTo: import_zod21.z.string()
1722
1925
  })
1723
1926
  );
1724
1927
  var UnassignedAction = ActionBase.merge(
1725
- import_zod19.z.object({
1726
- type: import_zod19.z.literal(ActionType.UNASSIGN)
1928
+ import_zod21.z.object({
1929
+ type: import_zod21.z.literal(ActionType.UNASSIGN),
1930
+ assignedTo: import_zod21.z.literal(null).default(null)
1727
1931
  })
1728
1932
  );
1729
1933
  var RegisterAction = ActionBase.merge(
1730
- import_zod19.z.object({
1731
- type: import_zod19.z.literal(ActionType.REGISTER),
1732
- identifiers: import_zod19.z.object({
1733
- trackingId: import_zod19.z.string(),
1734
- registrationNumber: import_zod19.z.string()
1735
- })
1934
+ import_zod21.z.object({
1935
+ type: import_zod21.z.literal(ActionType.REGISTER),
1936
+ registrationNumber: import_zod21.z.string().optional()
1736
1937
  })
1737
1938
  );
1738
1939
  var DeclareAction = ActionBase.merge(
1739
- import_zod19.z.object({
1740
- type: import_zod19.z.literal(ActionType.DECLARE)
1940
+ import_zod21.z.object({
1941
+ type: import_zod21.z.literal(ActionType.DECLARE)
1741
1942
  })
1742
1943
  );
1743
1944
  var ValidateAction = ActionBase.merge(
1744
- import_zod19.z.object({
1745
- type: import_zod19.z.literal(ActionType.VALIDATE)
1945
+ import_zod21.z.object({
1946
+ type: import_zod21.z.literal(ActionType.VALIDATE)
1746
1947
  })
1747
1948
  );
1748
1949
  var RejectAction = ActionBase.merge(
1749
- import_zod19.z.object({
1750
- type: import_zod19.z.literal(ActionType.REJECT)
1950
+ import_zod21.z.object({
1951
+ type: import_zod21.z.literal(ActionType.REJECT)
1751
1952
  })
1752
1953
  );
1753
1954
  var MarkAsDuplicateAction = ActionBase.merge(
1754
- import_zod19.z.object({
1755
- type: import_zod19.z.literal(ActionType.MARKED_AS_DUPLICATE)
1955
+ import_zod21.z.object({
1956
+ type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE)
1756
1957
  })
1757
1958
  );
1758
1959
  var ArchiveAction = ActionBase.merge(
1759
- import_zod19.z.object({
1760
- type: import_zod19.z.literal(ActionType.ARCHIVE)
1960
+ import_zod21.z.object({
1961
+ type: import_zod21.z.literal(ActionType.ARCHIVE)
1761
1962
  })
1762
1963
  );
1763
1964
  var CreatedAction = ActionBase.merge(
1764
- import_zod19.z.object({
1765
- type: import_zod19.z.literal(ActionType.CREATE)
1965
+ import_zod21.z.object({
1966
+ type: import_zod21.z.literal(ActionType.CREATE)
1766
1967
  })
1767
1968
  );
1768
1969
  var NotifiedAction = ActionBase.merge(
1769
- import_zod19.z.object({
1770
- type: import_zod19.z.literal(ActionType.NOTIFY)
1970
+ import_zod21.z.object({
1971
+ type: import_zod21.z.literal(ActionType.NOTIFY)
1771
1972
  })
1772
1973
  );
1773
1974
  var PrintCertificateAction = ActionBase.merge(
1774
- import_zod19.z.object({
1775
- type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE)
1975
+ import_zod21.z.object({
1976
+ type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE)
1776
1977
  })
1777
1978
  );
1778
1979
  var RequestedCorrectionAction = ActionBase.merge(
1779
- import_zod19.z.object({
1780
- type: import_zod19.z.literal(ActionType.REQUEST_CORRECTION)
1980
+ import_zod21.z.object({
1981
+ type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION)
1781
1982
  })
1782
1983
  );
1783
1984
  var ApprovedCorrectionAction = ActionBase.merge(
1784
- import_zod19.z.object({
1785
- type: import_zod19.z.literal(ActionType.APPROVE_CORRECTION),
1786
- requestId: import_zod19.z.string()
1985
+ import_zod21.z.object({
1986
+ type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION),
1987
+ requestId: import_zod21.z.string()
1787
1988
  })
1788
1989
  );
1789
1990
  var RejectedCorrectionAction = ActionBase.merge(
1790
- import_zod19.z.object({
1791
- type: import_zod19.z.literal(ActionType.REJECT_CORRECTION),
1792
- requestId: import_zod19.z.string()
1991
+ import_zod21.z.object({
1992
+ type: import_zod21.z.literal(ActionType.REJECT_CORRECTION),
1993
+ requestId: import_zod21.z.string()
1793
1994
  })
1794
1995
  );
1795
- var CustomAction = ActionBase.merge(
1796
- import_zod19.z.object({
1797
- type: import_zod19.z.literal(ActionType.CUSTOM)
1996
+ var ReadAction = ActionBase.merge(
1997
+ import_zod21.z.object({
1998
+ type: import_zod21.z.literal(ActionType.READ)
1798
1999
  })
1799
2000
  );
1800
- var ActionDocument = import_zod19.z.discriminatedUnion("type", [
2001
+ var ActionDocument = import_zod21.z.discriminatedUnion("type", [
1801
2002
  CreatedAction,
1802
2003
  ValidateAction,
1803
2004
  RejectAction,
@@ -1812,108 +2013,125 @@ var ActionDocument = import_zod19.z.discriminatedUnion("type", [
1812
2013
  RejectedCorrectionAction,
1813
2014
  UnassignedAction,
1814
2015
  PrintCertificateAction,
1815
- CustomAction
2016
+ ReadAction
1816
2017
  ]);
1817
- var ResolvedUser = import_zod19.z.object({
1818
- id: import_zod19.z.string(),
1819
- role: import_zod19.z.string(),
1820
- name: import_zod19.z.array(
1821
- import_zod19.z.object({
1822
- use: import_zod19.z.string(),
1823
- given: import_zod19.z.array(import_zod19.z.string()),
1824
- family: import_zod19.z.string()
2018
+ var AsyncRejectActionDocument = ActionBase.omit({
2019
+ declaration: true,
2020
+ annotation: true,
2021
+ createdBy: true,
2022
+ createdAtLocation: true
2023
+ }).merge(
2024
+ import_zod21.z.object({
2025
+ type: import_zod21.z.enum(ConfirmableActions),
2026
+ status: import_zod21.z.literal(ActionStatus.Rejected)
2027
+ })
2028
+ );
2029
+ var Action = import_zod21.z.union([ActionDocument, AsyncRejectActionDocument]);
2030
+ var ResolvedUser = import_zod21.z.object({
2031
+ id: import_zod21.z.string(),
2032
+ role: import_zod21.z.string(),
2033
+ name: import_zod21.z.array(
2034
+ import_zod21.z.object({
2035
+ use: import_zod21.z.string(),
2036
+ given: import_zod21.z.array(import_zod21.z.string()),
2037
+ family: import_zod21.z.string()
1825
2038
  })
1826
2039
  )
1827
2040
  });
1828
2041
 
1829
2042
  // ../commons/src/events/ActionInput.ts
1830
- var import_zod20 = require("zod");
1831
- var BaseActionInput = import_zod20.z.object({
1832
- eventId: import_zod20.z.string(),
1833
- transactionId: import_zod20.z.string(),
1834
- data: ActionUpdate,
1835
- metadata: ActionUpdate.optional()
2043
+ var import_zod22 = require("zod");
2044
+ var BaseActionInput = import_zod22.z.object({
2045
+ eventId: import_zod22.z.string(),
2046
+ transactionId: import_zod22.z.string(),
2047
+ declaration: ActionUpdate.default({}),
2048
+ annotation: ActionUpdate.optional(),
2049
+ originalActionId: import_zod22.z.string().optional(),
2050
+ keepAssignment: import_zod22.z.boolean().optional()
1836
2051
  });
1837
2052
  var CreateActionInput = BaseActionInput.merge(
1838
- import_zod20.z.object({
1839
- type: import_zod20.z.literal(ActionType.CREATE).default(ActionType.CREATE),
1840
- createdAtLocation: import_zod20.z.string()
2053
+ import_zod22.z.object({
2054
+ type: import_zod22.z.literal(ActionType.CREATE).default(ActionType.CREATE),
2055
+ createdAtLocation: import_zod22.z.string()
1841
2056
  })
1842
2057
  );
1843
2058
  var RegisterActionInput = BaseActionInput.merge(
1844
- import_zod20.z.object({
1845
- type: import_zod20.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
1846
- identifiers: import_zod20.z.object({
1847
- trackingId: import_zod20.z.string(),
1848
- registrationNumber: import_zod20.z.string()
1849
- })
2059
+ import_zod22.z.object({
2060
+ type: import_zod22.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
2061
+ registrationNumber: import_zod22.z.string().optional()
1850
2062
  })
1851
2063
  );
1852
2064
  var ValidateActionInput = BaseActionInput.merge(
1853
- import_zod20.z.object({
1854
- type: import_zod20.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
1855
- duplicates: import_zod20.z.array(import_zod20.z.string())
2065
+ import_zod22.z.object({
2066
+ type: import_zod22.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
2067
+ duplicates: import_zod22.z.array(import_zod22.z.string())
1856
2068
  })
1857
2069
  );
1858
2070
  var NotifyActionInput = BaseActionInput.merge(
1859
- import_zod20.z.object({
1860
- type: import_zod20.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
2071
+ import_zod22.z.object({
2072
+ type: import_zod22.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
1861
2073
  })
1862
2074
  );
1863
2075
  var DeclareActionInput = BaseActionInput.merge(
1864
- import_zod20.z.object({
1865
- type: import_zod20.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
2076
+ import_zod22.z.object({
2077
+ type: import_zod22.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
1866
2078
  })
1867
2079
  );
1868
2080
  var PrintCertificateActionInput = BaseActionInput.merge(
1869
- import_zod20.z.object({
1870
- type: import_zod20.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
2081
+ import_zod22.z.object({
2082
+ type: import_zod22.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
1871
2083
  })
1872
2084
  );
1873
2085
  var RejectDeclarationActionInput = BaseActionInput.merge(
1874
- import_zod20.z.object({
1875
- type: import_zod20.z.literal(ActionType.REJECT).default(ActionType.REJECT)
2086
+ import_zod22.z.object({
2087
+ type: import_zod22.z.literal(ActionType.REJECT).default(ActionType.REJECT)
1876
2088
  })
1877
2089
  );
1878
2090
  var MarkedAsDuplicateActionInput = BaseActionInput.merge(
1879
- import_zod20.z.object({
1880
- type: import_zod20.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
2091
+ import_zod22.z.object({
2092
+ type: import_zod22.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
1881
2093
  })
1882
2094
  );
1883
2095
  var ArchiveActionInput = BaseActionInput.merge(
1884
- import_zod20.z.object({
1885
- type: import_zod20.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
2096
+ import_zod22.z.object({
2097
+ type: import_zod22.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
1886
2098
  })
1887
2099
  );
1888
2100
  var AssignActionInput = BaseActionInput.merge(
1889
- import_zod20.z.object({
1890
- type: import_zod20.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
1891
- assignedTo: import_zod20.z.string()
2101
+ import_zod22.z.object({
2102
+ type: import_zod22.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
2103
+ assignedTo: import_zod22.z.string()
1892
2104
  })
1893
2105
  );
1894
2106
  var UnassignActionInput = BaseActionInput.merge(
1895
- import_zod20.z.object({
1896
- type: import_zod20.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN)
2107
+ import_zod22.z.object({
2108
+ type: import_zod22.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
2109
+ assignedTo: import_zod22.z.literal(null).default(null)
1897
2110
  })
1898
2111
  );
1899
2112
  var RequestCorrectionActionInput = BaseActionInput.merge(
1900
- import_zod20.z.object({
1901
- type: import_zod20.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
2113
+ import_zod22.z.object({
2114
+ type: import_zod22.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
1902
2115
  })
1903
2116
  );
1904
2117
  var RejectCorrectionActionInput = BaseActionInput.merge(
1905
- import_zod20.z.object({
1906
- requestId: import_zod20.z.string(),
1907
- type: import_zod20.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
2118
+ import_zod22.z.object({
2119
+ requestId: import_zod22.z.string(),
2120
+ type: import_zod22.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
1908
2121
  })
1909
2122
  );
1910
2123
  var ApproveCorrectionActionInput = BaseActionInput.merge(
1911
- import_zod20.z.object({
1912
- requestId: import_zod20.z.string(),
1913
- type: import_zod20.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
2124
+ import_zod22.z.object({
2125
+ requestId: import_zod22.z.string(),
2126
+ type: import_zod22.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
1914
2127
  })
1915
2128
  );
1916
- var ActionInput = import_zod20.z.discriminatedUnion("type", [
2129
+ var ReadActionInput = BaseActionInput.merge(
2130
+ import_zod22.z.object({
2131
+ type: import_zod22.z.literal(ActionType.READ).default(ActionType.READ)
2132
+ })
2133
+ );
2134
+ var ActionInput = import_zod22.z.discriminatedUnion("type", [
1917
2135
  CreateActionInput,
1918
2136
  ValidateActionInput,
1919
2137
  RegisterActionInput,
@@ -1927,56 +2145,62 @@ var ActionInput = import_zod20.z.discriminatedUnion("type", [
1927
2145
  PrintCertificateActionInput,
1928
2146
  RequestCorrectionActionInput,
1929
2147
  RejectCorrectionActionInput,
1930
- ApproveCorrectionActionInput
2148
+ ApproveCorrectionActionInput,
2149
+ ReadActionInput
1931
2150
  ]);
1932
2151
 
1933
2152
  // ../commons/src/events/Draft.ts
1934
- var Draft = import_zod21.z.object({
1935
- id: import_zod21.z.string(),
1936
- eventId: import_zod21.z.string(),
1937
- transactionId: import_zod21.z.string(),
1938
- createdAt: import_zod21.z.string().datetime(),
2153
+ var Draft = import_zod23.z.object({
2154
+ id: import_zod23.z.string(),
2155
+ eventId: import_zod23.z.string(),
2156
+ transactionId: import_zod23.z.string(),
2157
+ createdAt: import_zod23.z.string().datetime(),
1939
2158
  action: ActionBase.extend({
1940
- type: import_zod21.z.enum(Object.values(ActionType))
2159
+ type: ActionTypes
1941
2160
  }).omit({ id: true })
1942
2161
  });
1943
2162
  var DraftInput = BaseActionInput.extend({
1944
- type: import_zod21.z.enum(Object.values(ActionType))
2163
+ type: ActionTypes
1945
2164
  });
1946
2165
 
1947
2166
  // ../commons/src/events/EventInput.ts
1948
- var import_zod22 = require("zod");
1949
- var EventInput = import_zod22.z.object({
1950
- transactionId: import_zod22.z.string(),
1951
- type: import_zod22.z.string()
2167
+ var import_zod24 = require("zod");
2168
+ var EventInput = import_zod24.z.object({
2169
+ transactionId: import_zod24.z.string(),
2170
+ type: import_zod24.z.string()
1952
2171
  });
1953
2172
 
1954
2173
  // ../commons/src/events/EventDocument.ts
1955
- var import_zod23 = require("zod");
1956
- var EventDocument = import_zod23.z.object({
1957
- id: import_zod23.z.string(),
1958
- type: import_zod23.z.string(),
1959
- createdAt: import_zod23.z.string().datetime(),
1960
- updatedAt: import_zod23.z.string().datetime(),
1961
- actions: import_zod23.z.array(ActionDocument),
1962
- trackingId: import_zod23.z.string()
2174
+ var import_zod25 = require("zod");
2175
+ var EventDocument = import_zod25.z.object({
2176
+ id: import_zod25.z.string(),
2177
+ type: import_zod25.z.string(),
2178
+ createdAt: import_zod25.z.string().datetime(),
2179
+ updatedAt: import_zod25.z.string().datetime(),
2180
+ actions: import_zod25.z.array(Action),
2181
+ trackingId: import_zod25.z.string()
1963
2182
  });
1964
2183
 
1965
2184
  // ../commons/src/events/EventIndex.ts
1966
- var import_zod24 = require("zod");
2185
+ var import_zod26 = require("zod");
1967
2186
  var EventIndex = EventMetadata.extend({
1968
- data: import_zod24.z.record(import_zod24.z.string(), import_zod24.z.any())
2187
+ declaration: import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any())
1969
2188
  });
1970
- var EventSearchIndex = import_zod24.z.record(import_zod24.z.string(), import_zod24.z.any()).and(
1971
- import_zod24.z.object({
1972
- type: import_zod24.z.string()
2189
+ var EventSearchIndex = import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any()).and(
2190
+ import_zod26.z.object({
2191
+ type: import_zod26.z.string()
1973
2192
  // Ensures "type" (event-id) exists and is a string
1974
2193
  })
1975
2194
  );
1976
2195
 
1977
2196
  // ../commons/src/events/state/index.ts
1978
- var _ = __toESM(require("lodash"));
1979
2197
  function getStatusFromActions(actions) {
2198
+ const hasRejectedAction = actions.some(
2199
+ (a) => a.status === ActionStatus.Rejected
2200
+ );
2201
+ if (hasRejectedAction) {
2202
+ return EventStatus.REJECTED;
2203
+ }
1980
2204
  return actions.reduce((status, action) => {
1981
2205
  if (action.type === ActionType.CREATE) {
1982
2206
  return EventStatus.CREATED;
@@ -2013,7 +2237,7 @@ function getAssignedUserFromActions(actions) {
2013
2237
  return user2;
2014
2238
  }, null);
2015
2239
  }
2016
- function getData(actions) {
2240
+ function aggregateActionDeclarations(actions) {
2017
2241
  const excludedActions = [
2018
2242
  ActionType.REQUEST_CORRECTION,
2019
2243
  ActionType.PRINT_CERTIFICATE
@@ -2027,47 +2251,35 @@ function getData(actions) {
2027
2251
  if (!requestAction) {
2028
2252
  return status;
2029
2253
  }
2030
- return deepMerge(status, requestAction.data);
2254
+ return deepMerge(status, requestAction.declaration);
2031
2255
  }
2032
- return deepMerge(status, action.data);
2256
+ return deepMerge(status, action.declaration);
2033
2257
  }, {});
2034
2258
  }
2035
2259
  function deepDropNulls(obj) {
2036
- if (!_.isObject(obj)) return obj;
2037
- return Object.entries(obj).reduce((acc, [key, value]) => {
2038
- if (_.isObject(value)) {
2039
- value = deepDropNulls(value);
2040
- }
2041
- if (value !== null) {
2042
- return {
2043
- ...acc,
2044
- [key]: value
2045
- };
2046
- }
2047
- return acc;
2048
- }, {});
2049
- }
2050
- function deepMerge(currentDocument, actionDocument) {
2051
- return _.mergeWith(
2052
- currentDocument,
2053
- actionDocument,
2054
- (previousValue, incomingValue) => {
2055
- if (incomingValue === void 0) {
2056
- return previousValue;
2057
- }
2058
- if (_.isArray(incomingValue)) {
2059
- return incomingValue;
2060
- }
2061
- if (_.isObject(previousValue) && _.isObject(incomingValue)) {
2062
- return void 0;
2260
+ if (Array.isArray(obj)) {
2261
+ return obj.map(deepDropNulls);
2262
+ }
2263
+ if (obj !== null && typeof obj === "object") {
2264
+ return Object.entries(obj).reduce((acc, [key, value]) => {
2265
+ const cleanedValue = deepDropNulls(value);
2266
+ if (cleanedValue !== null) {
2267
+ ;
2268
+ acc[key] = cleanedValue;
2063
2269
  }
2064
- return incomingValue;
2065
- }
2066
- );
2270
+ return acc;
2271
+ }, {});
2272
+ }
2273
+ return obj;
2067
2274
  }
2068
2275
  function isUndeclaredDraft(status) {
2069
2276
  return status === EventStatus.CREATED;
2070
2277
  }
2278
+ function getAcceptedActions(event2) {
2279
+ return event2.actions.filter(
2280
+ (a) => a.status === ActionStatus.Accepted
2281
+ );
2282
+ }
2071
2283
  function getCurrentEventState(event2) {
2072
2284
  const creationAction = event2.actions.find(
2073
2285
  (action) => action.type === ActionType.CREATE
@@ -2075,7 +2287,12 @@ function getCurrentEventState(event2) {
2075
2287
  if (!creationAction) {
2076
2288
  throw new Error(`Event ${event2.id} has no creation action`);
2077
2289
  }
2078
- const latestAction = event2.actions[event2.actions.length - 1];
2290
+ const activeActions = getAcceptedActions(event2);
2291
+ const latestAction = activeActions[activeActions.length - 1];
2292
+ const registrationAction = activeActions.find(
2293
+ (a) => a.type === ActionType.REGISTER && a.status === ActionStatus.Accepted
2294
+ );
2295
+ const registrationNumber = registrationAction?.registrationNumber ?? null;
2079
2296
  return deepDropNulls({
2080
2297
  id: event2.id,
2081
2298
  type: event2.type,
@@ -2084,10 +2301,11 @@ function getCurrentEventState(event2) {
2084
2301
  createdBy: creationAction.createdBy,
2085
2302
  createdAtLocation: creationAction.createdAtLocation,
2086
2303
  modifiedAt: latestAction.createdAt,
2087
- assignedTo: getAssignedUserFromActions(event2.actions),
2304
+ assignedTo: getAssignedUserFromActions(activeActions),
2088
2305
  updatedBy: latestAction.createdBy,
2089
- data: getData(event2.actions),
2090
- trackingId: event2.trackingId
2306
+ declaration: aggregateActionDeclarations(activeActions),
2307
+ trackingId: event2.trackingId,
2308
+ registrationNumber
2091
2309
  });
2092
2310
  }
2093
2311
  function getCurrentEventStateWithDrafts(event2, drafts) {
@@ -2119,38 +2337,44 @@ function applyDraftsToEventIndex(eventIndex, drafts) {
2119
2337
  }
2120
2338
  return {
2121
2339
  ...eventIndex,
2122
- data: {
2123
- ...eventIndex.data,
2124
- ...activeDrafts[activeDrafts.length - 1].data
2340
+ declaration: {
2341
+ ...eventIndex.declaration,
2342
+ ...activeDrafts[activeDrafts.length - 1].declaration
2125
2343
  }
2126
2344
  };
2127
2345
  }
2128
- function getMetadataForAction({
2346
+ function getAnnotationFromDrafts(drafts) {
2347
+ const actions = drafts.map((draft) => draft.action);
2348
+ const annotation = actions.reduce((ann, action) => {
2349
+ return deepMerge(ann, action.annotation ?? {});
2350
+ }, {});
2351
+ return deepDropNulls(annotation);
2352
+ }
2353
+ function getActionAnnotation({
2129
2354
  event: event2,
2130
2355
  actionType,
2131
2356
  drafts
2132
2357
  }) {
2133
- const action = event2.actions.find((action2) => actionType === action2.type);
2358
+ const activeActions = getAcceptedActions(event2);
2359
+ const action = activeActions.find(
2360
+ (activeAction) => actionType === activeAction.type
2361
+ );
2134
2362
  const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
2135
2363
  const sorted = [
2136
2364
  ...action ? [action] : [],
2137
2365
  ...eventDrafts.map((draft) => draft.action)
2138
2366
  ].sort();
2139
- const metadata = sorted.reduce((metadata2, action2) => {
2140
- return deepMerge(metadata2, action2.metadata ?? {});
2367
+ const annotation = sorted.reduce((ann, sortedAction) => {
2368
+ return deepMerge(ann, sortedAction.annotation ?? {});
2141
2369
  }, {});
2142
- return deepDropNulls(metadata);
2370
+ return deepDropNulls(annotation);
2143
2371
  }
2144
2372
 
2145
2373
  // ../commons/src/events/defineConfig.ts
2146
2374
  var defineConfig = (config) => {
2147
2375
  validateWorkqueueConfig(config.workqueues);
2148
2376
  const input = EventConfig.parse(config);
2149
- const pageFields = findInputPageFields(input);
2150
- return EventConfig.parse({
2151
- ...input,
2152
- pageFields
2153
- });
2377
+ return input;
2154
2378
  };
2155
2379
 
2156
2380
  // ../commons/src/events/transactions.ts
@@ -2165,6 +2389,16 @@ var import_lodash2 = require("lodash");
2165
2389
  function defineConditional(schema) {
2166
2390
  return schema;
2167
2391
  }
2392
+ function defineFormConditional(schema) {
2393
+ const schemaWithForm = {
2394
+ type: "object",
2395
+ properties: {
2396
+ $form: schema
2397
+ },
2398
+ required: ["$form"]
2399
+ };
2400
+ return defineConditional(schemaWithForm);
2401
+ }
2168
2402
  function alwaysTrue() {
2169
2403
  return {};
2170
2404
  }
@@ -2189,6 +2423,9 @@ function not(condition) {
2189
2423
  required: []
2190
2424
  });
2191
2425
  }
2426
+ function never() {
2427
+ return not(alwaysTrue());
2428
+ }
2192
2429
  var user = {
2193
2430
  hasScope: (scope) => defineConditional({
2194
2431
  type: "object",
@@ -2236,69 +2473,120 @@ var event = {
2236
2473
  required: ["$event"]
2237
2474
  })
2238
2475
  };
2476
+ function getDateFromNow(days) {
2477
+ return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
2478
+ }
2479
+ function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
2480
+ return {
2481
+ type: "object",
2482
+ properties: {
2483
+ [fieldId]: {
2484
+ type: "string",
2485
+ format: "date",
2486
+ [clause]: { $data: `1/${comparedFieldId}` }
2487
+ },
2488
+ [comparedFieldId]: { type: "string", format: "date" }
2489
+ },
2490
+ required: [fieldId]
2491
+ };
2492
+ }
2493
+ function isFieldReference(value) {
2494
+ return typeof value === "object" && value !== null && "_fieldId" in value;
2495
+ }
2239
2496
  function field(fieldId) {
2240
- const getDateFromNow = (days) => new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
2241
2497
  const getDateRange = (date, clause) => ({
2242
2498
  type: "object",
2243
2499
  properties: {
2244
- $form: {
2245
- type: "object",
2246
- properties: {
2247
- [fieldId]: {
2248
- type: "string",
2249
- format: "date",
2250
- [clause]: date
2251
- }
2252
- },
2253
- required: [fieldId]
2500
+ [fieldId]: {
2501
+ type: "string",
2502
+ format: "date",
2503
+ [clause]: date
2254
2504
  }
2255
2505
  },
2256
- required: ["$form"]
2506
+ required: [fieldId]
2257
2507
  });
2258
2508
  return {
2509
+ /**
2510
+ * @private Internal property used for field reference tracking.
2511
+ */
2512
+ _fieldId: fieldId,
2259
2513
  isAfter: () => ({
2260
2514
  days: (days) => ({
2261
- inPast: () => defineConditional(
2515
+ inPast: () => defineFormConditional(
2262
2516
  getDateRange(getDateFromNow(days), "formatMinimum")
2263
2517
  ),
2264
- inFuture: () => defineConditional(
2518
+ inFuture: () => defineFormConditional(
2265
2519
  getDateRange(getDateFromNow(-days), "formatMinimum")
2266
2520
  )
2267
2521
  }),
2268
- date: (date) => defineConditional(getDateRange(date, "formatMinimum")),
2269
- now: () => defineConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
2522
+ date: (date) => {
2523
+ if (isFieldReference(date)) {
2524
+ const comparedFieldId = date._fieldId;
2525
+ return defineFormConditional(
2526
+ getDateRangeToFieldReference(
2527
+ fieldId,
2528
+ comparedFieldId,
2529
+ "formatMinimum"
2530
+ )
2531
+ );
2532
+ }
2533
+ return defineFormConditional(getDateRange(date, "formatMinimum"));
2534
+ },
2535
+ now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
2270
2536
  }),
2271
2537
  isBefore: () => ({
2272
2538
  days: (days) => ({
2273
- inPast: () => defineConditional(
2539
+ inPast: () => defineFormConditional(
2274
2540
  getDateRange(getDateFromNow(days), "formatMaximum")
2275
2541
  ),
2276
- inFuture: () => defineConditional(
2542
+ inFuture: () => defineFormConditional(
2277
2543
  getDateRange(getDateFromNow(-days), "formatMaximum")
2278
2544
  )
2279
2545
  }),
2280
- date: (date) => defineConditional(getDateRange(date, "formatMaximum")),
2281
- now: () => defineConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
2546
+ date: (date) => {
2547
+ if (isFieldReference(date)) {
2548
+ const comparedFieldId = date._fieldId;
2549
+ return defineFormConditional(
2550
+ getDateRangeToFieldReference(
2551
+ fieldId,
2552
+ comparedFieldId,
2553
+ "formatMaximum"
2554
+ )
2555
+ );
2556
+ }
2557
+ return defineFormConditional(getDateRange(date, "formatMaximum"));
2558
+ },
2559
+ now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
2282
2560
  }),
2283
- isEqualTo: (value) => defineConditional({
2284
- type: "object",
2285
- properties: {
2286
- $form: {
2561
+ isEqualTo: (value) => {
2562
+ if (isFieldReference(value)) {
2563
+ const comparedFieldId = value._fieldId;
2564
+ return defineFormConditional({
2287
2565
  type: "object",
2288
2566
  properties: {
2289
2567
  [fieldId]: {
2290
- oneOf: [
2291
- { type: "string", const: value },
2292
- { type: "boolean", const: value }
2293
- ],
2294
- const: value
2295
- }
2568
+ type: ["string", "boolean"],
2569
+ const: { $data: `1/${comparedFieldId}` }
2570
+ },
2571
+ [comparedFieldId]: { type: ["string", "boolean"] }
2296
2572
  },
2297
- required: [fieldId]
2298
- }
2299
- },
2300
- required: ["$form"]
2301
- }),
2573
+ required: [fieldId, comparedFieldId]
2574
+ });
2575
+ }
2576
+ return defineFormConditional({
2577
+ type: "object",
2578
+ properties: {
2579
+ [fieldId]: {
2580
+ oneOf: [
2581
+ { type: "string", const: value },
2582
+ { type: "boolean", const: value }
2583
+ ],
2584
+ const: value
2585
+ }
2586
+ },
2587
+ required: [fieldId]
2588
+ });
2589
+ },
2302
2590
  /**
2303
2591
  * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
2304
2592
  * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
@@ -2307,91 +2595,102 @@ function field(fieldId) {
2307
2595
  * NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
2308
2596
  *
2309
2597
  */
2310
- isFalsy: () => defineConditional({
2598
+ isFalsy: () => defineFormConditional({
2311
2599
  type: "object",
2312
2600
  properties: {
2313
- $form: {
2314
- type: "object",
2315
- properties: {
2316
- [fieldId]: {
2317
- anyOf: [
2318
- { const: "undefined" },
2319
- { const: false },
2320
- { const: null },
2321
- { const: "" }
2322
- ]
2323
- }
2324
- },
2601
+ [fieldId]: {
2325
2602
  anyOf: [
2326
- {
2327
- required: [fieldId]
2328
- },
2329
- {
2330
- not: {
2331
- required: [fieldId]
2332
- }
2333
- }
2603
+ { const: "undefined" },
2604
+ { const: false },
2605
+ { const: null },
2606
+ { const: "" }
2334
2607
  ]
2335
2608
  }
2336
2609
  },
2337
- required: ["$form"]
2338
- }),
2339
- isUndefined: () => defineConditional({
2340
- type: "object",
2341
- properties: {
2342
- $form: {
2343
- type: "object",
2344
- properties: {
2345
- [fieldId]: {
2346
- type: "string",
2347
- enum: ["undefined"]
2348
- }
2349
- },
2610
+ anyOf: [
2611
+ {
2612
+ required: [fieldId]
2613
+ },
2614
+ {
2350
2615
  not: {
2351
2616
  required: [fieldId]
2352
2617
  }
2353
2618
  }
2619
+ ]
2620
+ }),
2621
+ isUndefined: () => defineFormConditional({
2622
+ type: "object",
2623
+ properties: {
2624
+ [fieldId]: {
2625
+ type: "string",
2626
+ enum: ["undefined"]
2627
+ }
2354
2628
  },
2355
- required: ["$form"]
2629
+ not: {
2630
+ required: [fieldId]
2631
+ }
2356
2632
  }),
2357
- inArray: (values) => defineConditional({
2633
+ inArray: (values) => defineFormConditional({
2358
2634
  type: "object",
2359
2635
  properties: {
2360
- $form: {
2361
- type: "object",
2362
- properties: {
2363
- [fieldId]: {
2364
- type: "string",
2365
- enum: values
2366
- }
2367
- },
2368
- required: [fieldId]
2636
+ [fieldId]: {
2637
+ type: "string",
2638
+ enum: values
2639
+ }
2640
+ },
2641
+ required: [fieldId]
2642
+ }),
2643
+ isValidEnglishName: () => defineFormConditional({
2644
+ type: "object",
2645
+ properties: {
2646
+ [fieldId]: {
2647
+ type: "string",
2648
+ 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'._-]*)*$",
2649
+ description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
2650
+ }
2651
+ },
2652
+ required: [fieldId]
2653
+ }),
2654
+ /**
2655
+ * Checks if the field value matches a given regular expression pattern.
2656
+ * @param pattern - The regular expression pattern to match the field value against.
2657
+ * @returns A JSONSchema conditional that validates the field value against the pattern.
2658
+ */
2659
+ matches: (pattern) => defineFormConditional({
2660
+ type: "object",
2661
+ properties: {
2662
+ [fieldId]: {
2663
+ type: "string",
2664
+ pattern
2665
+ }
2666
+ },
2667
+ required: [fieldId]
2668
+ }),
2669
+ isBetween: (min, max) => defineFormConditional({
2670
+ type: "object",
2671
+ properties: {
2672
+ [fieldId]: {
2673
+ type: "number",
2674
+ minimum: min,
2675
+ maximum: max
2369
2676
  }
2370
2677
  },
2371
- required: ["$form"]
2678
+ required: [fieldId]
2372
2679
  })
2373
2680
  };
2374
2681
  }
2375
2682
 
2376
2683
  // ../commons/src/fixtures/tennis-club-membership-event.ts
2377
- var PRINT_CERTIFICATE_FORM = defineForm({
2684
+ var PRINT_CERTIFICATE_FORM = defineActionForm({
2378
2685
  label: {
2379
2686
  id: "v2.event.tennis-club-membership.action.certificate.form.label",
2380
2687
  defaultMessage: "Tennis club membership certificate collector",
2381
2688
  description: "This is what this form is referred as in the system"
2382
2689
  },
2383
- version: {
2384
- id: "1.0.0",
2385
- label: {
2386
- id: "v2.event.tennis-club-membership.action.certificate.form.version.1",
2387
- defaultMessage: "Version 1",
2388
- description: "This is the first version of the form"
2389
- }
2390
- },
2391
- active: true,
2392
2690
  pages: [
2393
2691
  {
2394
2692
  id: "collector",
2693
+ type: PageTypes.enum.FORM,
2395
2694
  title: {
2396
2695
  id: "v2.event.tennis-club-membership.action.certificate.form.section.who.title",
2397
2696
  defaultMessage: "Print certified copy",
@@ -2406,7 +2705,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2406
2705
  defaultMessage: "Requester",
2407
2706
  description: "This is the label for the field"
2408
2707
  },
2409
- type: "SELECT",
2708
+ type: FieldType.SELECT,
2410
2709
  options: [
2411
2710
  {
2412
2711
  value: "INFORMANT",
@@ -2483,7 +2782,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2483
2782
  defaultMessage: "Select Type of ID",
2484
2783
  description: "This is the label for selecting the type of ID"
2485
2784
  },
2486
- type: "SELECT",
2785
+ type: FieldType.SELECT,
2487
2786
  options: [
2488
2787
  {
2489
2788
  value: "PASSPORT",
@@ -2584,7 +2883,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2584
2883
  defaultMessage: "Passport Details",
2585
2884
  description: "Field for entering Passport details"
2586
2885
  },
2587
- type: "TEXT"
2886
+ type: FieldType.TEXT
2588
2887
  },
2589
2888
  {
2590
2889
  id: "collector.DRIVING_LICENSE.details",
@@ -2635,7 +2934,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2635
2934
  defaultMessage: "Driving License Details",
2636
2935
  description: "Field for entering Driving License details"
2637
2936
  },
2638
- type: "TEXT"
2937
+ type: FieldType.TEXT
2639
2938
  },
2640
2939
  {
2641
2940
  id: "collector.REFUGEE_NUMBER.details",
@@ -2686,7 +2985,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2686
2985
  defaultMessage: "Refugee Number Details",
2687
2986
  description: "Field for entering Refugee Number details"
2688
2987
  },
2689
- type: "TEXT"
2988
+ type: FieldType.TEXT
2690
2989
  },
2691
2990
  {
2692
2991
  id: "collector.ALIEN_NUMBER.details",
@@ -2737,7 +3036,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2737
3036
  defaultMessage: "Alien Number Details",
2738
3037
  description: "Field for entering Alien Number details"
2739
3038
  },
2740
- type: "TEXT"
3039
+ type: FieldType.TEXT
2741
3040
  },
2742
3041
  {
2743
3042
  id: "collector.OTHER.idTypeOther",
@@ -2788,7 +3087,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2788
3087
  defaultMessage: "Other ID Type (if applicable)",
2789
3088
  description: 'Field for entering ID type if "Other" is selected'
2790
3089
  },
2791
- type: "TEXT"
3090
+ type: FieldType.TEXT
2792
3091
  },
2793
3092
  {
2794
3093
  id: "collector.OTHER.firstName",
@@ -2839,7 +3138,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2839
3138
  defaultMessage: "First Name",
2840
3139
  description: "This is the label for the first name field"
2841
3140
  },
2842
- type: "TEXT"
3141
+ type: FieldType.TEXT
2843
3142
  },
2844
3143
  {
2845
3144
  id: "collector.OTHER.lastName",
@@ -2890,7 +3189,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2890
3189
  defaultMessage: "Last Name",
2891
3190
  description: "This is the label for the last name field"
2892
3191
  },
2893
- type: "TEXT"
3192
+ type: FieldType.TEXT
2894
3193
  },
2895
3194
  {
2896
3195
  id: "collector.OTHER.relationshipToMember",
@@ -2941,7 +3240,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2941
3240
  defaultMessage: "Relationship to Member",
2942
3241
  description: "This is the label for the relationship to member field"
2943
3242
  },
2944
- type: "TEXT"
3243
+ type: FieldType.TEXT
2945
3244
  },
2946
3245
  {
2947
3246
  id: "collector.OTHER.signedAffidavit",
@@ -2992,66 +3291,88 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2992
3291
  defaultMessage: "Signed Affidavit (Optional)",
2993
3292
  description: "This is the label for uploading a signed affidavit"
2994
3293
  },
2995
- type: "FILE"
3294
+ type: FieldType.FILE
2996
3295
  }
2997
3296
  ]
2998
- }
2999
- ],
3000
- review: {
3001
- title: {
3002
- id: "v2.event.tennis-club-membership.action.certificate.form.review.title",
3003
- defaultMessage: "Member certificate collector for {firstname} {surname}",
3004
- description: "Title of the form to show in review page"
3005
3297
  },
3006
- fields: []
3007
- }
3008
- });
3009
- var TENNIS_CLUB_FORM = defineForm({
3010
- label: {
3011
- id: "v2.event.tennis-club-membership.action.declare.form.label",
3012
- defaultMessage: "Tennis club membership application",
3013
- description: "This is what this form is referred as in the system"
3014
- },
3015
- active: true,
3016
- version: {
3017
- id: "1.0.0",
3018
- label: {
3019
- id: "v2.event.tennis-club-membership.action.declare.form.version.1",
3020
- defaultMessage: "Version 1",
3021
- description: "This is the first version of the form"
3298
+ {
3299
+ id: "collector.identity.verify",
3300
+ type: PageTypes.enum.VERIFICATION,
3301
+ conditional: field("collector.requesterId").isEqualTo("INFORMANT"),
3302
+ title: {
3303
+ id: "event.tennis-club-membership.action.print.verifyIdentity",
3304
+ defaultMessage: "Verify their identity",
3305
+ description: "This is the title of the section"
3306
+ },
3307
+ fields: [],
3308
+ actions: {
3309
+ verify: {
3310
+ label: {
3311
+ defaultMessage: "Verified",
3312
+ description: "This is the label for the verification button",
3313
+ id: "v2.event.tennis-club-membership.action.certificate.form.verify"
3314
+ }
3315
+ },
3316
+ cancel: {
3317
+ label: {
3318
+ defaultMessage: "Identity does not match",
3319
+ description: "This is the label for the verification cancellation button",
3320
+ id: "v2.event.tennis-club-membership.action.certificate.form.cancel"
3321
+ },
3322
+ confirmation: {
3323
+ title: {
3324
+ defaultMessage: "Print without proof of ID?",
3325
+ description: "This is the title for the verification cancellation modal",
3326
+ id: "v2.event.tennis-club-membership.action.certificate.form.cancel.confirmation.title"
3327
+ },
3328
+ body: {
3329
+ 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",
3330
+ description: "This is the body for the verification cancellation modal",
3331
+ id: "v2.event.tennis-club-membership.action.certificate.form.cancel.confirmation.body"
3332
+ }
3333
+ }
3334
+ }
3335
+ }
3022
3336
  }
3337
+ ]
3338
+ });
3339
+ var TENNIS_CLUB_DECLARATION_REVIEW = {
3340
+ title: {
3341
+ id: "v2.event.tennis-club-membership.action.declare.form.review.title",
3342
+ defaultMessage: "{applicant.firstname, select, __EMPTY__ {Member declaration} other {{applicant.surname, select, __EMPTY__ {Member declaration} other {Member declaration for {applicant.firstname} {applicant.surname}}}}}",
3343
+ description: "Title of the review page"
3023
3344
  },
3024
- review: {
3025
- title: {
3026
- id: "v2.event.tennis-club-membership.action.declare.form.review.title",
3027
- defaultMessage: "{applicant.firstname, select, __EMPTY__ {Member declaration} other {{applicant.surname, select, __EMPTY__ {Member declaration} other {Member declaration for {applicant.firstname} {applicant.surname}}}}}",
3028
- description: "Title of the form to show in review page"
3345
+ fields: [
3346
+ {
3347
+ id: "review.comment",
3348
+ type: FieldType.TEXTAREA,
3349
+ label: {
3350
+ defaultMessage: "Comment",
3351
+ id: "v2.event.birth.action.declare.form.review.comment.label",
3352
+ description: "Label for the comment field in the review section"
3353
+ }
3029
3354
  },
3030
- fields: [
3031
- {
3032
- id: "review.comment",
3033
- type: "TEXTAREA",
3034
- label: {
3035
- defaultMessage: "Comment",
3036
- id: "v2.event.birth.action.declare.form.review.comment.label",
3037
- description: "Label for the comment field in the review section"
3038
- }
3355
+ {
3356
+ type: FieldType.SIGNATURE,
3357
+ id: "review.signature",
3358
+ label: {
3359
+ defaultMessage: "Signature of informant",
3360
+ id: "v2.event.birth.action.declare.form.review.signature.label",
3361
+ description: "Label for the signature field in the review section"
3039
3362
  },
3040
- {
3041
- type: "SIGNATURE",
3042
- id: "review.signature",
3043
- label: {
3044
- defaultMessage: "Signature of informant",
3045
- id: "v2.event.birth.action.declare.form.review.signature.label",
3046
- description: "Label for the signature field in the review section"
3047
- },
3048
- signaturePromptLabel: {
3049
- id: "v2.signature.upload.modal.title",
3050
- defaultMessage: "Draw signature",
3051
- description: "Title for the modal to draw signature"
3052
- }
3363
+ signaturePromptLabel: {
3364
+ id: "v2.signature.upload.modal.title",
3365
+ defaultMessage: "Draw signature",
3366
+ description: "Title for the modal to draw signature"
3053
3367
  }
3054
- ]
3368
+ }
3369
+ ]
3370
+ };
3371
+ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
3372
+ label: {
3373
+ id: "v2.event.tennis-club-membership.action.declare.form.label",
3374
+ defaultMessage: "Tennis club membership application",
3375
+ description: "This is what this form is referred as in the system"
3055
3376
  },
3056
3377
  pages: [
3057
3378
  {
@@ -3064,7 +3385,7 @@ var TENNIS_CLUB_FORM = defineForm({
3064
3385
  fields: [
3065
3386
  {
3066
3387
  id: "applicant.firstname",
3067
- type: "TEXT",
3388
+ type: FieldType.TEXT,
3068
3389
  required: true,
3069
3390
  conditionals: [],
3070
3391
  label: {
@@ -3075,7 +3396,7 @@ var TENNIS_CLUB_FORM = defineForm({
3075
3396
  },
3076
3397
  {
3077
3398
  id: "applicant.surname",
3078
- type: "TEXT",
3399
+ type: FieldType.TEXT,
3079
3400
  required: true,
3080
3401
  conditionals: [],
3081
3402
  label: {
@@ -3097,9 +3418,8 @@ var TENNIS_CLUB_FORM = defineForm({
3097
3418
  },
3098
3419
  {
3099
3420
  id: "applicant.dob",
3100
- type: "DATE",
3421
+ type: FieldType.DATE,
3101
3422
  required: true,
3102
- conditionals: [],
3103
3423
  validation: [
3104
3424
  {
3105
3425
  message: {
@@ -3110,15 +3430,53 @@ var TENNIS_CLUB_FORM = defineForm({
3110
3430
  validator: field("applicant.dob").isBefore().now()
3111
3431
  }
3112
3432
  ],
3433
+ conditionals: [
3434
+ {
3435
+ type: ConditionalType.SHOW,
3436
+ conditional: field("applicant.dobUnknown").isFalsy()
3437
+ }
3438
+ ],
3113
3439
  label: {
3114
3440
  defaultMessage: "Applicant's date of birth",
3115
3441
  description: "This is the label for the field",
3116
3442
  id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dob.label"
3117
3443
  }
3118
3444
  },
3445
+ {
3446
+ id: "applicant.dobUnknown",
3447
+ type: FieldType.CHECKBOX,
3448
+ required: false,
3449
+ label: {
3450
+ defaultMessage: "Exact date of birth unknown",
3451
+ description: "This is the label for the field",
3452
+ id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dobUnknown.label"
3453
+ },
3454
+ conditionals: [
3455
+ {
3456
+ type: ConditionalType.DISPLAY_ON_REVIEW,
3457
+ conditional: never()
3458
+ }
3459
+ ]
3460
+ },
3461
+ {
3462
+ id: "applicant.age",
3463
+ type: FieldType.NUMBER,
3464
+ required: true,
3465
+ label: {
3466
+ defaultMessage: "Age of tennis-member",
3467
+ description: "This is the label for the field",
3468
+ id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.age.label"
3469
+ },
3470
+ conditionals: [
3471
+ {
3472
+ type: ConditionalType.SHOW,
3473
+ conditional: field("applicant.dobUnknown").isEqualTo(true)
3474
+ }
3475
+ ]
3476
+ },
3119
3477
  {
3120
3478
  id: "applicant.image",
3121
- type: "FILE",
3479
+ type: FieldType.FILE,
3122
3480
  required: false,
3123
3481
  label: {
3124
3482
  defaultMessage: "Applicant's profile picture",
@@ -3139,6 +3497,27 @@ var TENNIS_CLUB_FORM = defineForm({
3139
3497
  }
3140
3498
  ]
3141
3499
  },
3500
+ {
3501
+ id: "senior-pass",
3502
+ conditional: field("applicant.dob").isBefore().date("1950-01-01"),
3503
+ title: {
3504
+ id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.title",
3505
+ defaultMessage: "Assign senior pass for applicant",
3506
+ description: "This is the title of the section"
3507
+ },
3508
+ fields: [
3509
+ {
3510
+ id: "senior-pass.id",
3511
+ type: FieldType.TEXT,
3512
+ required: true,
3513
+ label: {
3514
+ defaultMessage: "Senior pass ID",
3515
+ description: "This is the label for the field",
3516
+ id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.field.id.label"
3517
+ }
3518
+ }
3519
+ ]
3520
+ },
3142
3521
  {
3143
3522
  id: "recommender",
3144
3523
  title: {
@@ -3160,7 +3539,7 @@ var TENNIS_CLUB_FORM = defineForm({
3160
3539
  },
3161
3540
  {
3162
3541
  id: "recommender.firstname",
3163
- type: "TEXT",
3542
+ type: FieldType.TEXT,
3164
3543
  required: true,
3165
3544
  conditionals: [
3166
3545
  {
@@ -3176,7 +3555,7 @@ var TENNIS_CLUB_FORM = defineForm({
3176
3555
  },
3177
3556
  {
3178
3557
  id: "recommender.surname",
3179
- type: "TEXT",
3558
+ type: FieldType.TEXT,
3180
3559
  required: true,
3181
3560
  conditionals: [
3182
3561
  {
@@ -3192,7 +3571,7 @@ var TENNIS_CLUB_FORM = defineForm({
3192
3571
  },
3193
3572
  {
3194
3573
  id: "recommender.id",
3195
- type: "TEXT",
3574
+ type: FieldType.TEXT,
3196
3575
  required: true,
3197
3576
  conditionals: [
3198
3577
  {
@@ -3300,7 +3679,7 @@ var tennisClubMembershipEvent = defineConfig({
3300
3679
  description: "This is shown as the action name anywhere the user can trigger the action from",
3301
3680
  id: "event.tennis-club-membership.action.declare.label"
3302
3681
  },
3303
- forms: [TENNIS_CLUB_FORM]
3682
+ review: TENNIS_CLUB_DECLARATION_REVIEW
3304
3683
  },
3305
3684
  {
3306
3685
  type: ActionType.VALIDATE,
@@ -3309,7 +3688,7 @@ var tennisClubMembershipEvent = defineConfig({
3309
3688
  description: "This is shown as the action name anywhere the user can trigger the action from",
3310
3689
  id: "event.tennis-club-membership.action.validate.label"
3311
3690
  },
3312
- forms: [TENNIS_CLUB_FORM]
3691
+ review: TENNIS_CLUB_DECLARATION_REVIEW
3313
3692
  },
3314
3693
  {
3315
3694
  type: ActionType.REGISTER,
@@ -3318,7 +3697,7 @@ var tennisClubMembershipEvent = defineConfig({
3318
3697
  description: "This is shown as the action name anywhere the user can trigger the action from",
3319
3698
  id: "event.tennis-club-membership.action.register.label"
3320
3699
  },
3321
- forms: [TENNIS_CLUB_FORM]
3700
+ review: TENNIS_CLUB_DECLARATION_REVIEW
3322
3701
  },
3323
3702
  {
3324
3703
  type: ActionType.REQUEST_CORRECTION,
@@ -3327,10 +3706,10 @@ var tennisClubMembershipEvent = defineConfig({
3327
3706
  description: "This is shown as the action name anywhere the user can trigger the action from",
3328
3707
  id: "event.tennis-club-membership.action.correction.request.label"
3329
3708
  },
3330
- forms: [TENNIS_CLUB_FORM],
3331
3709
  onboardingForm: [
3332
3710
  {
3333
3711
  id: "correction-requester",
3712
+ type: PageTypes.enum.FORM,
3334
3713
  title: {
3335
3714
  id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
3336
3715
  defaultMessage: "Correction requester",
@@ -3394,6 +3773,7 @@ var tennisClubMembershipEvent = defineConfig({
3394
3773
  },
3395
3774
  {
3396
3775
  id: "identity-check",
3776
+ type: PageTypes.enum.FORM,
3397
3777
  title: {
3398
3778
  id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
3399
3779
  defaultMessage: "Verify their identity",
@@ -3436,6 +3816,7 @@ var tennisClubMembershipEvent = defineConfig({
3436
3816
  additionalDetailsForm: [
3437
3817
  {
3438
3818
  id: "correction-request.supporting-documents",
3819
+ type: PageTypes.enum.FORM,
3439
3820
  title: {
3440
3821
  id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
3441
3822
  defaultMessage: "Upload supporting documents",
@@ -3453,7 +3834,7 @@ var tennisClubMembershipEvent = defineConfig({
3453
3834
  },
3454
3835
  {
3455
3836
  id: "correction.supportingDocs",
3456
- type: "FILE",
3837
+ type: FieldType.FILE,
3457
3838
  label: {
3458
3839
  id: "correction.corrector.title",
3459
3840
  defaultMessage: "Upload supporting documents",
@@ -3497,6 +3878,7 @@ var tennisClubMembershipEvent = defineConfig({
3497
3878
  },
3498
3879
  {
3499
3880
  id: "correction-request.additional-details",
3881
+ type: PageTypes.enum.FORM,
3500
3882
  title: {
3501
3883
  id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
3502
3884
  defaultMessage: "Reason for correction",
@@ -3505,7 +3887,7 @@ var tennisClubMembershipEvent = defineConfig({
3505
3887
  fields: [
3506
3888
  {
3507
3889
  id: "correction.request.reason",
3508
- type: "TEXT",
3890
+ type: FieldType.TEXT,
3509
3891
  label: {
3510
3892
  id: "correction.reason.title",
3511
3893
  defaultMessage: "Reason for correction?",
@@ -3518,7 +3900,6 @@ var tennisClubMembershipEvent = defineConfig({
3518
3900
  },
3519
3901
  {
3520
3902
  type: ActionType.APPROVE_CORRECTION,
3521
- forms: [TENNIS_CLUB_FORM],
3522
3903
  label: {
3523
3904
  defaultMessage: "Approve correction",
3524
3905
  description: "This is shown as the action name anywhere the user can trigger the action from",
@@ -3532,7 +3913,7 @@ var tennisClubMembershipEvent = defineConfig({
3532
3913
  defaultMessage: "Print certificate",
3533
3914
  description: "This is shown as the action name anywhere the user can trigger the action from"
3534
3915
  },
3535
- forms: [PRINT_CERTIFICATE_FORM],
3916
+ printForm: PRINT_CERTIFICATE_FORM,
3536
3917
  conditionals: [
3537
3918
  {
3538
3919
  type: "SHOW",
@@ -3579,8 +3960,7 @@ var tennisClubMembershipEvent = defineConfig({
3579
3960
  id: "v2.event.tennis-club-membership.action.archive.label",
3580
3961
  defaultMessage: "Archive",
3581
3962
  description: "This is shown as the action name anywhere the user can trigger the action from"
3582
- },
3583
- forms: [TENNIS_CLUB_FORM]
3963
+ }
3584
3964
  },
3585
3965
  {
3586
3966
  type: ActionType.REJECT,
@@ -3588,8 +3968,7 @@ var tennisClubMembershipEvent = defineConfig({
3588
3968
  id: "v2.event.tennis-club-membership.action.reject.label",
3589
3969
  defaultMessage: "Reject",
3590
3970
  description: "This is shown as the action name anywhere the user can trigger the action from"
3591
- },
3592
- forms: [TENNIS_CLUB_FORM]
3971
+ }
3593
3972
  }
3594
3973
  ],
3595
3974
  advancedSearch: [
@@ -3605,20 +3984,53 @@ var tennisClubMembershipEvent = defineConfig({
3605
3984
  }
3606
3985
  ]
3607
3986
  }
3608
- ]
3987
+ ],
3988
+ declaration: TENNIS_CLUB_DECLARATION_FORM
3609
3989
  });
3610
3990
 
3611
3991
  // ../commons/src/events/test.utils.ts
3612
- function generateActionInput(configuration, action) {
3613
- const fields = findActiveActionFormFields(configuration, action) ?? [];
3614
- const data = fields.reduce(
3992
+ function fieldConfigsToActionPayload(fields) {
3993
+ return fields.reduce(
3615
3994
  (acc, field2, i) => ({
3616
3995
  ...acc,
3617
3996
  [field2.id]: mapFieldTypeToMockValue(field2, i)
3618
3997
  }),
3619
3998
  {}
3620
3999
  );
3621
- return stripHiddenFields(fields, data);
4000
+ }
4001
+ function generateActionDeclarationInput(configuration, action) {
4002
+ const parsed = DeclarationUpdateActions.safeParse(action);
4003
+ if (parsed.success) {
4004
+ const fields = getDeclarationFields(configuration);
4005
+ const declarationConfig = getDeclaration(configuration);
4006
+ const declaration = fieldConfigsToActionPayload(fields);
4007
+ return omitHiddenPaginatedFields(declarationConfig, declaration);
4008
+ }
4009
+ console.warn(`${action} is not a declaration action. Setting data as {}.`);
4010
+ return {};
4011
+ }
4012
+ function generateActionAnnotationInput(configuration, action) {
4013
+ const actionConfig = configuration.actions.find(
4014
+ (ac) => ac.type === action
4015
+ );
4016
+ const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
4017
+ const annotation = fieldConfigsToActionPayload(annotationFields);
4018
+ const visibleVerificationPageIds = findRecordActionPages(
4019
+ configuration,
4020
+ action
4021
+ ).filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page, annotation)).map((page) => page.id);
4022
+ const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
4023
+ (acc, pageId) => ({
4024
+ ...acc,
4025
+ [pageId]: true
4026
+ }),
4027
+ {}
4028
+ );
4029
+ const fieldBasedPayload = omitHiddenFields(annotationFields, annotation);
4030
+ return {
4031
+ ...fieldBasedPayload,
4032
+ ...visiblePageVerificationMap
4033
+ };
3622
4034
  }
3623
4035
  var eventPayloadGenerator = {
3624
4036
  create: (input = {}) => ({
@@ -3630,21 +4042,22 @@ var eventPayloadGenerator = {
3630
4042
  type: input.type ?? "TENNIS_CLUB_MEMBERSHIP",
3631
4043
  id
3632
4044
  }),
3633
- draft: (eventId, input = {}) => (0, import_lodash2.merge)(
4045
+ draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
3634
4046
  {
3635
4047
  id: getUUID(),
3636
4048
  eventId,
3637
4049
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
3638
4050
  transactionId: getUUID(),
3639
4051
  action: {
3640
- type: ActionType.REQUEST_CORRECTION,
3641
- data: {
4052
+ type: actionType,
4053
+ status: ActionStatus.Accepted,
4054
+ declaration: {
3642
4055
  "applicant.firstname": "Max",
3643
4056
  "applicant.surname": "McLaren",
3644
4057
  "applicant.dob": "2020-01-02",
3645
4058
  "recommender.none": true
3646
4059
  },
3647
- metadata: {
4060
+ annotation: {
3648
4061
  "correction.requester.relationship": "ANOTHER_AGENT",
3649
4062
  "correction.request.reason": "Child's name was incorrect"
3650
4063
  },
@@ -3659,41 +4072,104 @@ var eventPayloadGenerator = {
3659
4072
  declare: (eventId, input = {}) => ({
3660
4073
  type: ActionType.DECLARE,
3661
4074
  transactionId: input.transactionId ?? getUUID(),
3662
- data: input.data ?? generateActionInput(tennisClubMembershipEvent, ActionType.DECLARE),
4075
+ declaration: input.declaration ?? generateActionDeclarationInput(
4076
+ tennisClubMembershipEvent,
4077
+ ActionType.DECLARE
4078
+ ),
4079
+ annotation: input.annotation ?? generateActionAnnotationInput(
4080
+ tennisClubMembershipEvent,
4081
+ ActionType.DECLARE
4082
+ ),
3663
4083
  eventId
3664
4084
  }),
4085
+ /**
4086
+ * Notify allows sending incomplete data. Think it as 'partial declare' for now.
4087
+ */
4088
+ notify: (eventId, input = {}) => {
4089
+ let declaration = input.declaration;
4090
+ if (!declaration) {
4091
+ const partialDeclaration = (0, import_lodash2.omitBy)(
4092
+ generateActionDeclarationInput(
4093
+ tennisClubMembershipEvent,
4094
+ ActionType.DECLARE
4095
+ ),
4096
+ import_lodash2.isString
4097
+ );
4098
+ declaration = partialDeclaration;
4099
+ }
4100
+ return {
4101
+ type: ActionType.NOTIFY,
4102
+ transactionId: input.transactionId ?? getUUID(),
4103
+ declaration,
4104
+ eventId
4105
+ };
4106
+ },
3665
4107
  validate: (eventId, input = {}) => ({
3666
4108
  type: ActionType.VALIDATE,
3667
4109
  transactionId: input.transactionId ?? getUUID(),
3668
- data: input.data ?? generateActionInput(tennisClubMembershipEvent, ActionType.VALIDATE),
4110
+ declaration: input.declaration ?? generateActionDeclarationInput(
4111
+ tennisClubMembershipEvent,
4112
+ ActionType.VALIDATE
4113
+ ),
4114
+ annotation: input.annotation ?? generateActionAnnotationInput(
4115
+ tennisClubMembershipEvent,
4116
+ ActionType.VALIDATE
4117
+ ),
3669
4118
  duplicates: [],
3670
4119
  eventId
3671
4120
  }),
4121
+ assign: (eventId, input = {}) => ({
4122
+ type: ActionType.ASSIGN,
4123
+ transactionId: input.transactionId ?? getUUID(),
4124
+ declaration: {},
4125
+ assignedTo: input.assignedTo ?? getUUID(),
4126
+ eventId
4127
+ }),
4128
+ unassign: (eventId, input = {}) => ({
4129
+ type: ActionType.UNASSIGN,
4130
+ transactionId: input.transactionId ?? getUUID(),
4131
+ declaration: {},
4132
+ assignedTo: null,
4133
+ eventId
4134
+ }),
3672
4135
  archive: (eventId, input = {}, isDuplicate) => ({
3673
4136
  type: ActionType.ARCHIVE,
3674
4137
  transactionId: input.transactionId ?? getUUID(),
3675
- data: input.data ?? generateActionInput(tennisClubMembershipEvent, ActionType.ARCHIVE),
3676
- metadata: { isDuplicate: isDuplicate ?? false },
4138
+ declaration: {},
4139
+ // @TODO: Check whether generator is needed?
4140
+ annotation: { isDuplicate: isDuplicate ?? false },
3677
4141
  duplicates: [],
3678
4142
  eventId
3679
4143
  }),
3680
4144
  reject: (eventId, input = {}) => ({
3681
4145
  type: ActionType.REJECT,
3682
4146
  transactionId: input.transactionId ?? getUUID(),
3683
- data: input.data ?? generateActionInput(tennisClubMembershipEvent, ActionType.REJECT),
4147
+ declaration: {},
4148
+ annotation: input.annotation ?? generateActionAnnotationInput(
4149
+ tennisClubMembershipEvent,
4150
+ ActionType.REJECT
4151
+ ),
3684
4152
  duplicates: [],
3685
4153
  eventId
3686
4154
  }),
3687
4155
  register: (eventId, input = {}) => ({
3688
4156
  type: ActionType.REGISTER,
3689
4157
  transactionId: input.transactionId ?? getUUID(),
3690
- data: input.data ?? generateActionInput(tennisClubMembershipEvent, ActionType.REGISTER),
4158
+ declaration: input.declaration ?? generateActionDeclarationInput(
4159
+ tennisClubMembershipEvent,
4160
+ ActionType.REGISTER
4161
+ ),
4162
+ annotation: input.annotation ?? generateActionAnnotationInput(
4163
+ tennisClubMembershipEvent,
4164
+ ActionType.REGISTER
4165
+ ),
3691
4166
  eventId
3692
4167
  }),
3693
4168
  printCertificate: (eventId, input = {}) => ({
3694
4169
  type: ActionType.PRINT_CERTIFICATE,
3695
4170
  transactionId: input.transactionId ?? getUUID(),
3696
- data: input.data ?? generateActionInput(
4171
+ declaration: {},
4172
+ annotation: input.annotation ?? generateActionAnnotationInput(
3697
4173
  tennisClubMembershipEvent,
3698
4174
  ActionType.PRINT_CERTIFICATE
3699
4175
  ),
@@ -3703,17 +4179,21 @@ var eventPayloadGenerator = {
3703
4179
  request: (eventId, input = {}) => ({
3704
4180
  type: ActionType.REQUEST_CORRECTION,
3705
4181
  transactionId: input.transactionId ?? getUUID(),
3706
- data: input.data ?? generateActionInput(
4182
+ declaration: input.declaration ?? generateActionDeclarationInput(
4183
+ tennisClubMembershipEvent,
4184
+ ActionType.REQUEST_CORRECTION
4185
+ ),
4186
+ annotation: input.annotation ?? generateActionAnnotationInput(
3707
4187
  tennisClubMembershipEvent,
3708
4188
  ActionType.REQUEST_CORRECTION
3709
4189
  ),
3710
- metadata: {},
3711
4190
  eventId
3712
4191
  }),
3713
4192
  approve: (eventId, requestId, input = {}) => ({
3714
4193
  type: ActionType.APPROVE_CORRECTION,
3715
4194
  transactionId: input.transactionId ?? getUUID(),
3716
- data: input.data ?? generateActionInput(
4195
+ declaration: {},
4196
+ annotation: input.annotation ?? generateActionAnnotationInput(
3717
4197
  tennisClubMembershipEvent,
3718
4198
  ActionType.APPROVE_CORRECTION
3719
4199
  ),
@@ -3723,7 +4203,8 @@ var eventPayloadGenerator = {
3723
4203
  reject: (eventId, requestId, input = {}) => ({
3724
4204
  type: ActionType.REJECT_CORRECTION,
3725
4205
  transactionId: input.transactionId ?? getUUID(),
3726
- data: input.data ?? generateActionInput(
4206
+ declaration: {},
4207
+ annotation: input.annotation ?? generateActionAnnotationInput(
3727
4208
  tennisClubMembershipEvent,
3728
4209
  ActionType.REJECT_CORRECTION
3729
4210
  ),
@@ -3745,15 +4226,20 @@ function generateActionDocument({
3745
4226
  createdBy: getUUID(),
3746
4227
  id: getUUID(),
3747
4228
  createdAtLocation: "TODO",
3748
- data: generateActionInput(configuration, action),
3749
- metadata: {},
3750
- ...defaults
4229
+ declaration: generateActionDeclarationInput(configuration, action),
4230
+ annotation: {},
4231
+ ...defaults,
4232
+ status: ActionStatus.Accepted
3751
4233
  };
3752
4234
  switch (action) {
4235
+ case ActionType.READ:
4236
+ return { ...actionBase, type: action };
4237
+ case ActionType.MARKED_AS_DUPLICATE:
4238
+ return { ...actionBase, type: action };
3753
4239
  case ActionType.DECLARE:
3754
4240
  return { ...actionBase, type: action };
3755
4241
  case ActionType.UNASSIGN:
3756
- return { ...actionBase, type: action };
4242
+ return { ...actionBase, type: action, assignedTo: null };
3757
4243
  case ActionType.ASSIGN:
3758
4244
  return { ...actionBase, assignedTo: getUUID(), type: action };
3759
4245
  case ActionType.VALIDATE:
@@ -3774,14 +4260,13 @@ function generateActionDocument({
3774
4260
  return { ...actionBase, requestId: getUUID(), type: action };
3775
4261
  case ActionType.REJECT_CORRECTION:
3776
4262
  return { ...actionBase, requestId: getUUID(), type: action };
3777
- case ActionType.CUSTOM:
3778
- return { ...actionBase, type: action };
3779
4263
  case ActionType.REGISTER:
3780
4264
  return {
3781
4265
  ...actionBase,
3782
- type: action,
3783
- identifiers: { trackingId: getUUID(), registrationNumber: getUUID() }
4266
+ type: action
3784
4267
  };
4268
+ case ActionType.DELETE:
4269
+ case ActionType.DETECT_DUPLICATE:
3785
4270
  default:
3786
4271
  throw new Error(`Unsupported action type: ${action}`);
3787
4272
  }
@@ -3805,7 +4290,7 @@ function generateEventDocument({
3805
4290
  updatedAt: new Date(Date.now() - 1e3).toISOString()
3806
4291
  };
3807
4292
  }
3808
- function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, data = {}) {
4293
+ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
3809
4294
  const action = generateActionDocument({
3810
4295
  configuration: tennisClubMembershipEvent,
3811
4296
  action: actionType
@@ -3815,9 +4300,9 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, da
3815
4300
  transactionId: getUUID(),
3816
4301
  action: {
3817
4302
  ...action,
3818
- data: {
3819
- ...action.data,
3820
- ...data
4303
+ declaration: {
4304
+ ...action.declaration,
4305
+ ...declaration
3821
4306
  }
3822
4307
  },
3823
4308
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -3834,7 +4319,7 @@ var eventQueryDataGenerator = (overrides = {}) => ({
3834
4319
  modifiedAt: overrides.modifiedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
3835
4320
  assignedTo: overrides.assignedTo ?? null,
3836
4321
  updatedBy: overrides.updatedBy ?? getUUID(),
3837
- data: overrides.data ?? {
4322
+ declaration: overrides.declaration ?? {
3838
4323
  "recommender.none": true,
3839
4324
  "applicant.firstname": "Danny",
3840
4325
  "applicant.surname": "Doe",
@@ -3842,6 +4327,11 @@ var eventQueryDataGenerator = (overrides = {}) => ({
3842
4327
  },
3843
4328
  trackingId: overrides.trackingId ?? "M3F8YQ"
3844
4329
  });
4330
+ var generateTranslationConfig = (message) => ({
4331
+ defaultMessage: message,
4332
+ description: "Description for ${message}",
4333
+ id: message
4334
+ });
3845
4335
 
3846
4336
  // ../commons/src/events/TemplateConfig.ts
3847
4337
  function isTemplateVariable(value) {
@@ -3860,7 +4350,9 @@ function isFieldValueWithoutTemplates(value) {
3860
4350
  return true;
3861
4351
  }
3862
4352
  function isFieldConfigDefaultValue(value) {
3863
- if (!value) return false;
4353
+ if (!value) {
4354
+ return false;
4355
+ }
3864
4356
  if (isFieldValue(value)) {
3865
4357
  return true;
3866
4358
  }