@opencrvs/toolkit 1.8.0-rc.ff73871 → 1.8.0-rc.ffbb9d7

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