@opencrvs/toolkit 1.8.0-rc.fc43738 → 1.8.0-rc.fcf46fc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +1 -1
  2. package/dist/commons/api/router.d.ts +6956 -9633
  3. package/dist/commons/conditionals/conditionals.d.ts +28 -5
  4. package/dist/commons/conditionals/validate-address.test.d.ts +2 -0
  5. package/dist/commons/conditionals/validate.d.ts +46 -22
  6. package/dist/commons/conditionals/validate.test.d.ts +2 -0
  7. package/dist/commons/events/ActionConfig.d.ts +1116 -2067
  8. package/dist/commons/events/ActionDocument.d.ts +10571 -1388
  9. package/dist/commons/events/ActionInput.d.ts +6943 -2170
  10. package/dist/commons/events/ActionType.d.ts +27 -12
  11. package/dist/commons/events/CompositeFieldValue.d.ts +414 -0
  12. package/dist/commons/events/Conditional.d.ts +21 -5
  13. package/dist/commons/events/Draft.d.ts +499 -199
  14. package/dist/commons/events/EventConfig.d.ts +559 -1238
  15. package/dist/commons/events/EventConfigInput.d.ts +6 -3
  16. package/dist/commons/events/EventDocument.d.ts +4635 -1719
  17. package/dist/commons/events/EventIndex.d.ts +9 -6
  18. package/dist/commons/events/EventMetadata.d.ts +6 -3
  19. package/dist/commons/events/FieldConfig.d.ts +529 -74
  20. package/dist/commons/events/FieldType.d.ts +6 -1
  21. package/dist/commons/events/FieldTypeMapping.d.ts +274 -39
  22. package/dist/commons/events/FieldValue.d.ts +136 -65
  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 +38 -0
  26. package/dist/commons/events/defineConfig.d.ts +91 -222
  27. package/dist/commons/events/index.d.ts +4 -1
  28. package/dist/commons/events/test.utils.d.ts +176 -243
  29. package/dist/commons/events/utils.d.ts +196 -70
  30. package/dist/commons/events/utils.test.d.ts +2 -0
  31. package/dist/conditionals/index.js +166 -81
  32. package/dist/events/index.js +1679 -903
  33. package/package.json +1 -1
@@ -30,18 +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,
39
- ActionMetadata: () => ActionMetadata,
41
+ ActionStatus: () => ActionStatus,
40
42
  ActionType: () => ActionType,
43
+ ActionTypes: () => ActionTypes,
44
+ ActionUpdate: () => ActionUpdate,
45
+ AddressFieldUpdateValue: () => AddressFieldUpdateValue,
41
46
  AddressFieldValue: () => AddressFieldValue,
47
+ AddressType: () => AddressType,
48
+ AdministrativeAreas: () => AdministrativeAreas,
42
49
  AdvancedSearchConfig: () => AdvancedSearchConfig,
43
50
  ApproveCorrectionActionInput: () => ApproveCorrectionActionInput,
44
- ArchivedActionInput: () => ArchivedActionInput,
51
+ ArchiveActionInput: () => ArchiveActionInput,
52
+ AssignActionInput: () => AssignActionInput,
53
+ AsyncRejectActionDocument: () => AsyncRejectActionDocument,
45
54
  BaseActionInput: () => BaseActionInput,
46
55
  CertificateConfig: () => CertificateConfig,
47
56
  CertificateTemplateConfig: () => CertificateTemplateConfig,
@@ -49,9 +58,18 @@ __export(events_exports, {
49
58
  Clause: () => Clause,
50
59
  Conditional: () => Conditional,
51
60
  ConditionalType: () => ConditionalType,
61
+ ConfirmableActions: () => ConfirmableActions,
62
+ DataEntry: () => DataEntry,
63
+ DataFieldValue: () => DataFieldValue,
52
64
  DateValue: () => DateValue,
65
+ DeclarationActionConfig: () => DeclarationActionConfig,
66
+ DeclarationActions: () => DeclarationActions,
67
+ DeclarationFormConfig: () => DeclarationFormConfig,
68
+ DeclarationReviewConfig: () => DeclarationReviewConfig,
69
+ DeclarationUpdateActions: () => DeclarationUpdateActions,
53
70
  DeclareActionInput: () => DeclareActionInput,
54
71
  DeduplicationConfig: () => DeduplicationConfig,
72
+ DisplayOnReviewConditional: () => DisplayOnReviewConditional,
55
73
  Draft: () => Draft,
56
74
  DraftInput: () => DraftInput,
57
75
  EmailField: () => EmailField,
@@ -65,39 +83,66 @@ __export(events_exports, {
65
83
  EventSearchIndex: () => EventSearchIndex,
66
84
  EventStatus: () => EventStatus,
67
85
  EventStatuses: () => EventStatuses,
86
+ FieldConditional: () => FieldConditional,
68
87
  FieldConfig: () => FieldConfig,
69
88
  FieldType: () => FieldType,
89
+ FieldUpdateValue: () => FieldUpdateValue,
70
90
  FieldValue: () => FieldValue,
71
91
  FileFieldValue: () => FileFieldValue,
72
92
  FileFieldValueWithOption: () => FileFieldValueWithOption,
73
93
  FileFieldWithOptionValue: () => FileFieldWithOptionValue,
74
94
  FormConfig: () => FormConfig,
75
- FormPage: () => FormPage,
95
+ FormPageConfig: () => FormPageConfig,
96
+ GenericAddressUpdateValue: () => GenericAddressUpdateValue,
97
+ GenericAddressValue: () => GenericAddressValue,
98
+ GeographicalArea: () => GeographicalArea,
99
+ ImageMimeType: () => ImageMimeType,
76
100
  LanguageConfig: () => LanguageConfig,
77
101
  MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
102
+ MimeType: () => MimeType,
78
103
  NotifyActionInput: () => NotifyActionInput,
79
104
  NumberFieldValue: () => NumberFieldValue,
105
+ PageConfig: () => PageConfig,
106
+ PageTypes: () => PageTypes,
80
107
  PrintCertificateActionInput: () => PrintCertificateActionInput,
108
+ ReadActionInput: () => ReadActionInput,
109
+ RegisterAction: () => RegisterAction,
81
110
  RegisterActionInput: () => RegisterActionInput,
82
111
  RejectCorrectionActionInput: () => RejectCorrectionActionInput,
83
112
  RejectDeclarationActionInput: () => RejectDeclarationActionInput,
84
113
  RequestCorrectionActionInput: () => RequestCorrectionActionInput,
85
114
  RequiredTextValue: () => RequiredTextValue,
86
115
  ResolvedUser: () => ResolvedUser,
116
+ RuralAddressUpdateValue: () => RuralAddressUpdateValue,
117
+ RuralAddressValue: () => RuralAddressValue,
87
118
  ShowConditional: () => ShowConditional,
88
119
  SummaryConfig: () => SummaryConfig,
89
120
  TextValue: () => TextValue,
90
121
  TranslationConfig: () => TranslationConfig,
122
+ UnassignActionInput: () => UnassignActionInput,
123
+ UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
124
+ UrbanAddressValue: () => UrbanAddressValue,
91
125
  ValidateActionInput: () => ValidateActionInput,
126
+ VerificationActionConfig: () => VerificationActionConfig,
127
+ VerificationPageConfig: () => VerificationPageConfig,
92
128
  WorkqueueConfig: () => WorkqueueConfig,
93
129
  alwaysTrue: () => alwaysTrue,
94
130
  and: () => and,
131
+ annotationActions: () => annotationActions,
95
132
  applyDraftsToEventIndex: () => applyDraftsToEventIndex,
133
+ compositeFieldTypes: () => compositeFieldTypes,
134
+ createEmptyDraft: () => createEmptyDraft,
96
135
  createValidationSchema: () => createValidationSchema,
136
+ deepDropNulls: () => deepDropNulls,
137
+ deepMerge: () => deepMerge,
138
+ defineActionForm: () => defineActionForm,
97
139
  defineConditional: () => defineConditional,
98
140
  defineConfig: () => defineConfig,
99
- defineForm: () => defineForm,
141
+ defineDeclarationForm: () => defineDeclarationForm,
142
+ defineFormConditional: () => defineFormConditional,
100
143
  defineFormPage: () => defineFormPage,
144
+ definePage: () => definePage,
145
+ errorMessages: () => errorMessages,
101
146
  event: () => event,
102
147
  eventMetadataLabelMap: () => eventMetadataLabelMap,
103
148
  eventPayloadGenerator: () => eventPayloadGenerator,
@@ -105,97 +150,130 @@ __export(events_exports, {
105
150
  eventStatuses: () => eventStatuses,
106
151
  field: () => field,
107
152
  fieldTypes: () => fieldTypes,
108
- findActiveActionFields: () => findActiveActionFields,
109
- findActiveActionForm: () => findActiveActionForm,
110
- findActiveActionFormFields: () => findActiveActionFormFields,
111
- findActiveActionFormPages: () => findActiveActionFormPages,
112
- findInputPageFields: () => findInputPageFields,
113
- findPageFields: () => findPageFields,
114
- generateActionInput: () => generateActionInput,
153
+ findActiveDrafts: () => findActiveDrafts,
154
+ findAllFields: () => findAllFields,
155
+ findLastAssignmentAction: () => findLastAssignmentAction,
156
+ findRecordActionPages: () => findRecordActionPages,
157
+ generateActionAnnotationInput: () => generateActionAnnotationInput,
158
+ generateActionDeclarationInput: () => generateActionDeclarationInput,
159
+ generateActionDocument: () => generateActionDocument,
115
160
  generateEventDocument: () => generateEventDocument,
116
161
  generateEventDraftDocument: () => generateEventDraftDocument,
117
162
  generateTransactionId: () => generateTransactionId,
118
- getActiveActionFields: () => getActiveActionFields,
119
- getAllFields: () => getAllFields,
120
- getAllPages: () => getAllPages,
163
+ generateTranslationConfig: () => generateTranslationConfig,
164
+ getAcceptedActions: () => getAcceptedActions,
165
+ getActionAnnotation: () => getActionAnnotation,
166
+ getActionAnnotationFields: () => getActionAnnotationFields,
167
+ getActionReview: () => getActionReview,
168
+ getActionReviewFields: () => getActionReviewFields,
169
+ getAllAnnotationFields: () => getAllAnnotationFields,
170
+ getAnnotationFromDrafts: () => getAnnotationFromDrafts,
121
171
  getCurrentEventState: () => getCurrentEventState,
122
172
  getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
123
- getEventConfiguration: () => getEventConfiguration,
173
+ getDeclaration: () => getDeclaration,
174
+ getDeclarationFields: () => getDeclarationFields,
175
+ getDeclarationPages: () => getDeclarationPages,
124
176
  getFieldValidationErrors: () => getFieldValidationErrors,
125
- getFormFields: () => getFormFields,
126
- getMetadataForAction: () => getMetadataForAction,
127
177
  isAddressFieldType: () => isAddressFieldType,
128
178
  isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
129
179
  isBulletListFieldType: () => isBulletListFieldType,
130
180
  isCheckboxFieldType: () => isCheckboxFieldType,
131
181
  isCountryFieldType: () => isCountryFieldType,
182
+ isDataFieldType: () => isDataFieldType,
132
183
  isDateFieldType: () => isDateFieldType,
133
184
  isDividerFieldType: () => isDividerFieldType,
134
185
  isEmailFieldType: () => isEmailFieldType,
135
186
  isFacilityFieldType: () => isFacilityFieldType,
187
+ isFieldConfigDefaultValue: () => isFieldConfigDefaultValue,
188
+ isFieldDisplayedOnReview: () => isFieldDisplayedOnReview,
136
189
  isFieldEnabled: () => isFieldEnabled,
190
+ isFieldValue: () => isFieldValue,
191
+ isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
137
192
  isFieldVisible: () => isFieldVisible,
138
193
  isFileFieldType: () => isFileFieldType,
139
194
  isFileFieldWithOptionType: () => isFileFieldWithOptionType,
140
195
  isLocationFieldType: () => isLocationFieldType,
141
196
  isNumberFieldType: () => isNumberFieldType,
142
197
  isOfficeFieldType: () => isOfficeFieldType,
143
- isOptionalUncheckedCheckbox: () => isOptionalUncheckedCheckbox,
144
198
  isPageHeaderFieldType: () => isPageHeaderFieldType,
199
+ isPageVisible: () => isPageVisible,
145
200
  isParagraphFieldType: () => isParagraphFieldType,
146
201
  isRadioGroupFieldType: () => isRadioGroupFieldType,
147
202
  isSelectFieldType: () => isSelectFieldType,
148
203
  isSignatureFieldType: () => isSignatureFieldType,
204
+ isTemplateVariable: () => isTemplateVariable,
149
205
  isTextAreaFieldType: () => isTextAreaFieldType,
150
206
  isTextFieldType: () => isTextFieldType,
151
207
  isUndeclaredDraft: () => isUndeclaredDraft,
208
+ isVerificationPage: () => isVerificationPage,
209
+ isWriteAction: () => isWriteAction,
210
+ mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
152
211
  mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
153
212
  mapFieldTypeToZod: () => mapFieldTypeToZod,
213
+ never: () => never,
154
214
  not: () => not,
215
+ omitHiddenFields: () => omitHiddenFields,
216
+ omitHiddenPaginatedFields: () => omitHiddenPaginatedFields,
155
217
  or: () => or,
156
- resolveLabelsFromKnownFields: () => resolveLabelsFromKnownFields,
157
- stripHiddenFields: () => stripHiddenFields,
158
218
  user: () => user,
159
219
  validate: () => validate,
160
220
  validateFieldInput: () => validateFieldInput,
161
- validateWorkqueueConfig: () => validateWorkqueueConfig
221
+ validateWorkqueueConfig: () => validateWorkqueueConfig,
222
+ writeActions: () => writeActions
162
223
  });
163
224
  module.exports = __toCommonJS(events_exports);
164
225
 
165
226
  // ../commons/src/events/ActionConfig.ts
166
- var import_zod6 = require("zod");
227
+ var import_zod9 = require("zod");
167
228
 
168
229
  // ../commons/src/events/Conditional.ts
169
230
  var import_zod = require("zod");
170
- function Conditional() {
171
- return import_zod.z.custom((val) => typeof val === "object" && val !== null);
172
- }
231
+ var Conditional = import_zod.z.custom(
232
+ (val) => typeof val === "object" && val !== null
233
+ );
173
234
  var ConditionalType = {
174
- /** When 'SHOW' conditional is defined, the action is shown to the user only if the condition is met */
175
235
  SHOW: "SHOW",
176
- /** If 'ENABLE' conditional is defined, the action is enabled only if the condition is met */
177
- ENABLE: "ENABLE"
236
+ ENABLE: "ENABLE",
237
+ DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
178
238
  };
179
239
  var ShowConditional = import_zod.z.object({
180
240
  type: import_zod.z.literal(ConditionalType.SHOW),
181
- conditional: Conditional()
182
- });
241
+ conditional: Conditional
242
+ }).describe(
243
+ "If 'SHOW' conditional is defined, the component is shown to the user only if the condition is met"
244
+ );
183
245
  var EnableConditional = import_zod.z.object({
184
246
  type: import_zod.z.literal(ConditionalType.ENABLE),
185
- conditional: Conditional()
186
- });
247
+ conditional: Conditional
248
+ }).describe(
249
+ "If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
250
+ );
187
251
  var ActionConditional = import_zod.z.discriminatedUnion("type", [
188
252
  // Action can be shown / hidden
189
253
  ShowConditional,
190
254
  // Action can be shown to the user in the list but as disabled
191
255
  EnableConditional
192
256
  ]);
257
+ var DisplayOnReviewConditional = import_zod.z.object({
258
+ type: import_zod.z.literal(ConditionalType.DISPLAY_ON_REVIEW),
259
+ conditional: Conditional
260
+ }).describe(
261
+ "If 'DISPLAY_ON_REVIEW' conditional is defined, the component is shown on the review page only if both the 'DISPLAY_ON_REVIEW' and 'SHOW' conditions are met. This should only be used for fields within declaration forms, as they are the only ones with review pages."
262
+ );
263
+ var FieldConditional = import_zod.z.discriminatedUnion("type", [
264
+ // Field input can be shown / hidden
265
+ ShowConditional,
266
+ // Field input can be shown to the user but as disabled
267
+ EnableConditional,
268
+ // Field output can be shown / hidden on the review page
269
+ DisplayOnReviewConditional
270
+ ]);
193
271
 
194
- // ../commons/src/events/FormConfig.ts
195
- var import_zod5 = require("zod");
272
+ // ../commons/src/events/PageConfig.ts
273
+ var import_zod6 = require("zod");
196
274
 
197
275
  // ../commons/src/events/FieldConfig.ts
198
- var import_zod4 = require("zod");
276
+ var import_zod5 = require("zod");
199
277
 
200
278
  // ../commons/src/events/TranslationConfig.ts
201
279
  var import_zod2 = require("zod");
@@ -232,16 +310,29 @@ var FieldType = {
232
310
  ADMINISTRATIVE_AREA: "ADMINISTRATIVE_AREA",
233
311
  FACILITY: "FACILITY",
234
312
  OFFICE: "OFFICE",
235
- SIGNATURE: "SIGNATURE"
313
+ SIGNATURE: "SIGNATURE",
314
+ DATA: "DATA"
236
315
  };
237
316
  var fieldTypes = Object.values(FieldType);
317
+ var compositeFieldTypes = [
318
+ FieldType.ADDRESS,
319
+ FieldType.FILE_WITH_OPTIONS,
320
+ FieldType.FILE
321
+ ];
238
322
 
239
323
  // ../commons/src/events/FieldValue.ts
324
+ var import_zod4 = require("zod");
325
+
326
+ // ../commons/src/events/CompositeFieldValue.ts
240
327
  var import_zod3 = require("zod");
241
- var TextValue = import_zod3.z.string();
242
- var RequiredTextValue = TextValue.min(1);
243
- var DateValue = import_zod3.z.string().date().describe("Date in the format YYYY-MM-DD");
244
- var EmailValue = import_zod3.z.string().email();
328
+ var GeographicalArea = {
329
+ URBAN: "URBAN",
330
+ RURAL: "RURAL"
331
+ };
332
+ var AddressType = {
333
+ DOMESTIC: "DOMESTIC",
334
+ INTERNATIONAL: "INTERNATIONAL"
335
+ };
245
336
  var FileFieldValue = import_zod3.z.object({
246
337
  filename: import_zod3.z.string(),
247
338
  originalFilename: import_zod3.z.string(),
@@ -249,25 +340,61 @@ var FileFieldValue = import_zod3.z.object({
249
340
  });
250
341
  var AdminStructure = import_zod3.z.object({
251
342
  country: import_zod3.z.string(),
343
+ addressType: import_zod3.z.literal(AddressType.DOMESTIC),
252
344
  province: import_zod3.z.string(),
253
345
  district: import_zod3.z.string()
254
346
  });
255
- var UrbanAddress = AdminStructure.extend({
256
- urbanOrRural: import_zod3.z.literal("URBAN"),
347
+ var UrbanAddressValue = AdminStructure.extend({
348
+ urbanOrRural: import_zod3.z.literal(GeographicalArea.URBAN),
257
349
  town: import_zod3.z.string().optional(),
258
350
  residentialArea: import_zod3.z.string().optional(),
259
351
  street: import_zod3.z.string().optional(),
260
352
  number: import_zod3.z.string().optional(),
261
353
  zipCode: import_zod3.z.string().optional()
262
354
  });
263
- var RuralAddress = AdminStructure.extend({
264
- urbanOrRural: import_zod3.z.literal("RURAL"),
355
+ var RuralAddressValue = AdminStructure.extend({
356
+ urbanOrRural: import_zod3.z.literal(GeographicalArea.RURAL),
265
357
  village: import_zod3.z.string().optional()
266
358
  });
267
- var AddressFieldValue = import_zod3.z.discriminatedUnion("urbanOrRural", [
268
- UrbanAddress,
269
- RuralAddress
270
- ]);
359
+ var UrbanAddressUpdateValue = AdminStructure.extend({
360
+ urbanOrRural: import_zod3.z.literal(GeographicalArea.URBAN),
361
+ town: import_zod3.z.string().nullish(),
362
+ residentialArea: import_zod3.z.string().nullish(),
363
+ street: import_zod3.z.string().nullish(),
364
+ number: import_zod3.z.string().nullish(),
365
+ zipCode: import_zod3.z.string().nullish()
366
+ });
367
+ var RuralAddressUpdateValue = AdminStructure.extend({
368
+ urbanOrRural: import_zod3.z.literal(GeographicalArea.RURAL),
369
+ village: import_zod3.z.string().nullish()
370
+ });
371
+ var GenericAddressValue = import_zod3.z.object({
372
+ country: import_zod3.z.string(),
373
+ addressType: import_zod3.z.literal(AddressType.INTERNATIONAL),
374
+ state: import_zod3.z.string(),
375
+ district2: import_zod3.z.string(),
376
+ cityOrTown: import_zod3.z.string().optional(),
377
+ addressLine1: import_zod3.z.string().optional(),
378
+ addressLine2: import_zod3.z.string().optional(),
379
+ addressLine3: import_zod3.z.string().optional(),
380
+ postcodeOrZip: import_zod3.z.string().optional()
381
+ });
382
+ var AddressFieldValue = import_zod3.z.discriminatedUnion("urbanOrRural", [UrbanAddressValue, RuralAddressValue]).or(GenericAddressValue);
383
+ var GenericAddressUpdateValue = import_zod3.z.object({
384
+ country: import_zod3.z.string(),
385
+ addressType: import_zod3.z.literal(AddressType.INTERNATIONAL),
386
+ state: import_zod3.z.string(),
387
+ district2: import_zod3.z.string(),
388
+ cityOrTown: import_zod3.z.string().nullish(),
389
+ addressLine1: import_zod3.z.string().nullish(),
390
+ addressLine2: import_zod3.z.string().nullish(),
391
+ addressLine3: import_zod3.z.string().nullish(),
392
+ postcodeOrZip: import_zod3.z.string().nullish()
393
+ });
394
+ var AddressFieldUpdateValue = import_zod3.z.discriminatedUnion("urbanOrRural", [
395
+ UrbanAddressUpdateValue,
396
+ RuralAddressUpdateValue
397
+ ]).or(GenericAddressUpdateValue);
271
398
  var FileFieldValueWithOption = import_zod3.z.object({
272
399
  filename: import_zod3.z.string(),
273
400
  originalFilename: import_zod3.z.string(),
@@ -275,30 +402,51 @@ var FileFieldValueWithOption = import_zod3.z.object({
275
402
  option: import_zod3.z.string()
276
403
  });
277
404
  var FileFieldWithOptionValue = import_zod3.z.array(FileFieldValueWithOption);
278
- var CheckboxFieldValue = import_zod3.z.boolean();
279
- var NumberFieldValue = import_zod3.z.number();
280
- var FieldValue = import_zod3.z.union([
405
+
406
+ // ../commons/src/events/FieldValue.ts
407
+ var TextValue = import_zod4.z.string();
408
+ var RequiredTextValue = TextValue.min(1);
409
+ var DateValue = import_zod4.z.string().date().describe("Date in the format YYYY-MM-DD");
410
+ var EmailValue = import_zod4.z.string().email();
411
+ var CheckboxFieldValue = import_zod4.z.boolean();
412
+ var NumberFieldValue = import_zod4.z.number();
413
+ var DataFieldValue = import_zod4.z.undefined();
414
+ var FieldValue = import_zod4.z.union([
281
415
  TextValue,
282
416
  DateValue,
417
+ CheckboxFieldValue,
418
+ NumberFieldValue,
283
419
  FileFieldValue,
284
420
  FileFieldWithOptionValue,
421
+ UrbanAddressValue,
422
+ RuralAddressValue,
423
+ DataFieldValue,
424
+ GenericAddressValue
425
+ ]);
426
+ var FieldUpdateValue = import_zod4.z.union([
427
+ TextValue,
428
+ DateValue,
285
429
  CheckboxFieldValue,
286
430
  NumberFieldValue,
287
- UrbanAddress,
288
- RuralAddress
431
+ FileFieldValue,
432
+ FileFieldWithOptionValue,
433
+ UrbanAddressUpdateValue,
434
+ RuralAddressUpdateValue,
435
+ DataFieldValue,
436
+ GenericAddressUpdateValue
289
437
  ]);
290
438
 
291
439
  // ../commons/src/events/FieldConfig.ts
292
- var FieldId = import_zod4.z.string();
293
- var DependencyExpression = import_zod4.z.object({
294
- dependsOn: import_zod4.z.array(FieldId).default([]),
295
- expression: import_zod4.z.string()
440
+ var FieldId = import_zod5.z.string();
441
+ var DependencyExpression = import_zod5.z.object({
442
+ dependsOn: import_zod5.z.array(FieldId).default([]),
443
+ expression: import_zod5.z.string()
296
444
  });
297
- var BaseField = import_zod4.z.object({
445
+ var BaseField = import_zod5.z.object({
298
446
  id: FieldId,
299
- defaultValue: import_zod4.z.union([
447
+ defaultValue: import_zod5.z.union([
300
448
  // These are the currently supported default values types
301
- import_zod4.z.union([
449
+ import_zod5.z.union([
302
450
  TextValue,
303
451
  RequiredTextValue,
304
452
  DateValue,
@@ -307,82 +455,92 @@ var BaseField = import_zod4.z.object({
307
455
  ]),
308
456
  DependencyExpression
309
457
  ]).optional(),
310
- conditionals: import_zod4.z.array(ActionConditional).default([]).optional(),
311
- required: import_zod4.z.boolean().default(false).optional(),
312
- disabled: import_zod4.z.boolean().default(false).optional(),
313
- hidden: import_zod4.z.boolean().default(false).optional(),
458
+ conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
459
+ required: import_zod5.z.boolean().default(false).optional(),
460
+ disabled: import_zod5.z.boolean().default(false).optional(),
461
+ hidden: import_zod5.z.boolean().default(false).optional(),
314
462
  placeholder: TranslationConfig.optional(),
315
- validation: import_zod4.z.array(
316
- import_zod4.z.object({
317
- validator: Conditional(),
463
+ validation: import_zod5.z.array(
464
+ import_zod5.z.object({
465
+ validator: Conditional,
318
466
  message: TranslationConfig
319
467
  })
320
468
  ).default([]).optional(),
321
- dependsOn: import_zod4.z.array(FieldId).default([]).optional(),
469
+ dependsOn: import_zod5.z.array(FieldId).default([]).optional(),
322
470
  label: TranslationConfig,
323
- hideLabel: import_zod4.z.boolean().default(false).optional()
471
+ hideLabel: import_zod5.z.boolean().default(false).optional()
324
472
  });
325
473
  var Divider = BaseField.extend({
326
- type: import_zod4.z.literal(FieldType.DIVIDER)
474
+ type: import_zod5.z.literal(FieldType.DIVIDER)
327
475
  });
328
476
  var TextField = BaseField.extend({
329
- type: import_zod4.z.literal(FieldType.TEXT),
330
- defaultValue: import_zod4.z.union([RequiredTextValue, DependencyExpression]).optional(),
331
- configuration: import_zod4.z.object({
332
- maxLength: import_zod4.z.number().optional().describe("Maximum length of the text"),
333
- type: import_zod4.z.enum(["text", "password"]).optional(),
477
+ type: import_zod5.z.literal(FieldType.TEXT),
478
+ defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional(),
479
+ configuration: import_zod5.z.object({
480
+ maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
481
+ type: import_zod5.z.enum(["text", "password"]).optional(),
334
482
  prefix: TranslationConfig.optional(),
335
483
  postfix: TranslationConfig.optional()
336
484
  }).default({ type: "text" }).optional()
337
485
  }).describe("Text input");
338
486
  var NumberField = BaseField.extend({
339
- type: import_zod4.z.literal(FieldType.NUMBER),
340
- defaultValue: import_zod4.z.union([NumberFieldValue, DependencyExpression]).optional(),
341
- configuration: import_zod4.z.object({
342
- min: import_zod4.z.number().optional().describe("Minimum value"),
343
- max: import_zod4.z.number().optional().describe("Maximum value"),
487
+ type: import_zod5.z.literal(FieldType.NUMBER),
488
+ defaultValue: import_zod5.z.union([NumberFieldValue, DependencyExpression]).optional(),
489
+ configuration: import_zod5.z.object({
490
+ min: import_zod5.z.number().optional().describe("Minimum value"),
491
+ max: import_zod5.z.number().optional().describe("Maximum value"),
344
492
  prefix: TranslationConfig.optional(),
345
493
  postfix: TranslationConfig.optional()
346
494
  }).optional()
347
495
  }).describe("Number input");
348
496
  var TextAreaField = BaseField.extend({
349
- type: import_zod4.z.literal(FieldType.TEXTAREA),
350
- defaultValue: import_zod4.z.union([RequiredTextValue, DependencyExpression]).optional(),
351
- configuration: import_zod4.z.object({
352
- maxLength: import_zod4.z.number().optional().describe("Maximum length of the text"),
353
- rows: import_zod4.z.number().optional().describe("Number of visible text lines"),
354
- cols: import_zod4.z.number().optional().describe("Number of visible columns"),
497
+ type: import_zod5.z.literal(FieldType.TEXTAREA),
498
+ defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional(),
499
+ configuration: import_zod5.z.object({
500
+ maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
501
+ rows: import_zod5.z.number().optional().describe("Number of visible text lines"),
502
+ cols: import_zod5.z.number().optional().describe("Number of visible columns"),
355
503
  prefix: TranslationConfig.optional(),
356
504
  postfix: TranslationConfig.optional()
357
505
  }).default({ rows: 4 }).optional()
358
506
  }).describe("Multiline text input");
507
+ var ImageMimeType = import_zod5.z.enum([
508
+ "image/png",
509
+ "image/jpg",
510
+ "image/jpeg",
511
+ "image/svg+xml"
512
+ ]);
513
+ var MimeType = ImageMimeType;
514
+ var DEFAULT_MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;
359
515
  var SignatureField = BaseField.extend({
360
- type: import_zod4.z.literal(FieldType.SIGNATURE),
516
+ type: import_zod5.z.literal(FieldType.SIGNATURE),
361
517
  signaturePromptLabel: TranslationConfig.describe(
362
518
  "Title of the signature modal"
363
519
  ),
364
- configuration: import_zod4.z.object({
365
- maxSizeMb: import_zod4.z.number().optional().describe("Maximum file size in MB"),
366
- allowedFileFormats: import_zod4.z.array(import_zod4.z.string()).optional().describe("List of allowed file formats for the signature")
367
- }).default({}).optional()
520
+ configuration: import_zod5.z.object({
521
+ maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
522
+ acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
523
+ }).default({
524
+ maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
525
+ })
368
526
  }).describe("Signature input field");
369
527
  var EmailField = BaseField.extend({
370
- type: import_zod4.z.literal(FieldType.EMAIL),
371
- configuration: import_zod4.z.object({
372
- maxLength: import_zod4.z.number().optional().describe("Maximum length of the text")
528
+ type: import_zod5.z.literal(FieldType.EMAIL),
529
+ configuration: import_zod5.z.object({
530
+ maxLength: import_zod5.z.number().optional().describe("Maximum length of the text")
373
531
  }).default({ maxLength: 10 }).optional(),
374
- defaultValue: import_zod4.z.union([RequiredTextValue, DependencyExpression]).optional()
532
+ defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
375
533
  });
376
534
  var DateField = BaseField.extend({
377
- type: import_zod4.z.literal(FieldType.DATE),
378
- defaultValue: import_zod4.z.union([DateValue, DependencyExpression]).optional(),
379
- configuration: import_zod4.z.object({
535
+ type: import_zod5.z.literal(FieldType.DATE),
536
+ defaultValue: import_zod5.z.union([DateValue, DependencyExpression]).optional(),
537
+ configuration: import_zod5.z.object({
380
538
  notice: TranslationConfig.describe(
381
539
  "Text to display above the date input"
382
540
  ).optional()
383
541
  }).optional()
384
542
  }).describe("A single date input (dd-mm-YYYY)");
385
- var HtmlFontVariant = import_zod4.z.enum([
543
+ var HtmlFontVariant = import_zod5.z.enum([
386
544
  "reg12",
387
545
  "reg14",
388
546
  "reg16",
@@ -393,97 +551,128 @@ var HtmlFontVariant = import_zod4.z.enum([
393
551
  "h1"
394
552
  ]);
395
553
  var Paragraph = BaseField.extend({
396
- type: import_zod4.z.literal(FieldType.PARAGRAPH),
397
- defaultValue: import_zod4.z.union([RequiredTextValue, DependencyExpression]).optional(),
398
- configuration: import_zod4.z.object({
399
- styles: import_zod4.z.object({
554
+ type: import_zod5.z.literal(FieldType.PARAGRAPH),
555
+ defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional(),
556
+ configuration: import_zod5.z.object({
557
+ styles: import_zod5.z.object({
400
558
  fontVariant: HtmlFontVariant.optional()
401
559
  }).optional()
402
560
  }).default({})
403
561
  }).describe("A read-only HTML <p> paragraph");
404
562
  var PageHeader = BaseField.extend({
405
- type: import_zod4.z.literal(FieldType.PAGE_HEADER),
406
- defaultValue: import_zod4.z.union([RequiredTextValue, DependencyExpression]).optional()
563
+ type: import_zod5.z.literal(FieldType.PAGE_HEADER),
564
+ defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
407
565
  }).describe("A read-only header component for form pages");
408
566
  var File = BaseField.extend({
409
- type: import_zod4.z.literal(FieldType.FILE),
410
- options: import_zod4.z.object({
411
- style: import_zod4.z.object({
412
- fullWidth: import_zod4.z.boolean().describe(
567
+ type: import_zod5.z.literal(FieldType.FILE),
568
+ configuration: import_zod5.z.object({
569
+ maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
570
+ acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
571
+ style: import_zod5.z.object({
572
+ width: import_zod5.z.enum(["full", "auto"]).optional().describe(
413
573
  "Whether the file upload button should take the full width of the container or not"
414
574
  )
415
- })
416
- }).optional()
575
+ }).optional()
576
+ }).default({
577
+ maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
578
+ })
417
579
  }).describe("File upload");
418
- var SelectOption = import_zod4.z.object({
419
- value: import_zod4.z.string().describe("The value of the option"),
580
+ var SelectOption = import_zod5.z.object({
581
+ value: import_zod5.z.string().describe("The value of the option"),
420
582
  label: TranslationConfig.describe("The label of the option")
421
583
  });
422
584
  var RadioGroup = BaseField.extend({
423
- type: import_zod4.z.literal(FieldType.RADIO_GROUP),
424
- defaultValue: import_zod4.z.union([TextValue, DependencyExpression]).optional(),
425
- options: import_zod4.z.array(SelectOption).describe("A list of options"),
426
- configuration: import_zod4.z.object({
427
- styles: import_zod4.z.object({
428
- size: import_zod4.z.enum(["NORMAL", "LARGE"]).optional()
585
+ type: import_zod5.z.literal(FieldType.RADIO_GROUP),
586
+ defaultValue: import_zod5.z.union([TextValue, DependencyExpression]).optional(),
587
+ options: import_zod5.z.array(SelectOption).describe("A list of options"),
588
+ configuration: import_zod5.z.object({
589
+ styles: import_zod5.z.object({
590
+ size: import_zod5.z.enum(["NORMAL", "LARGE"]).optional()
429
591
  }).optional()
430
592
  }).optional()
431
593
  }).describe("Grouped radio options");
432
594
  var BulletList = BaseField.extend({
433
- type: import_zod4.z.literal(FieldType.BULLET_LIST),
434
- defaultValue: import_zod4.z.string().optional(),
435
- items: import_zod4.z.array(TranslationConfig).describe("A list of items"),
436
- configuration: import_zod4.z.object({
437
- styles: import_zod4.z.object({
595
+ type: import_zod5.z.literal(FieldType.BULLET_LIST),
596
+ defaultValue: import_zod5.z.string().optional(),
597
+ items: import_zod5.z.array(TranslationConfig).describe("A list of items"),
598
+ configuration: import_zod5.z.object({
599
+ styles: import_zod5.z.object({
438
600
  fontVariant: HtmlFontVariant.optional()
439
601
  }).optional()
440
602
  }).default({})
441
603
  }).describe("A list of bullet points");
442
604
  var Select = BaseField.extend({
443
- type: import_zod4.z.literal(FieldType.SELECT),
444
- defaultValue: import_zod4.z.union([TextValue, DependencyExpression]).optional(),
445
- options: import_zod4.z.array(SelectOption).describe("A list of options")
605
+ type: import_zod5.z.literal(FieldType.SELECT),
606
+ defaultValue: import_zod5.z.union([TextValue, DependencyExpression]).optional(),
607
+ options: import_zod5.z.array(SelectOption).describe("A list of options")
446
608
  }).describe("Select input");
447
609
  var Checkbox = BaseField.extend({
448
- type: import_zod4.z.literal(FieldType.CHECKBOX),
449
- defaultValue: import_zod4.z.union([CheckboxFieldValue, DependencyExpression]).optional()
610
+ type: import_zod5.z.literal(FieldType.CHECKBOX),
611
+ defaultValue: import_zod5.z.union([CheckboxFieldValue, DependencyExpression]).optional()
450
612
  }).describe("Boolean checkbox field");
451
613
  var Country = BaseField.extend({
452
- type: import_zod4.z.literal(FieldType.COUNTRY),
453
- defaultValue: import_zod4.z.union([RequiredTextValue, DependencyExpression]).optional()
614
+ type: import_zod5.z.literal(FieldType.COUNTRY),
615
+ defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
454
616
  }).describe("Country select field");
455
- var AdministrativeAreaConfiguration = import_zod4.z.object({
456
- partOf: import_zod4.z.object({
457
- $data: import_zod4.z.string()
617
+ var AdministrativeAreas = import_zod5.z.enum([
618
+ "ADMIN_STRUCTURE",
619
+ "HEALTH_FACILITY",
620
+ "CRVS_OFFICE"
621
+ ]);
622
+ var AdministrativeAreaConfiguration = import_zod5.z.object({
623
+ partOf: import_zod5.z.object({
624
+ $declaration: import_zod5.z.string()
458
625
  }).optional().describe("Parent location"),
459
- type: import_zod4.z.enum(["ADMIN_STRUCTURE", "HEALTH_FACILITY", "CRVS_OFFICE"])
626
+ type: AdministrativeAreas
460
627
  }).describe("Administrative area options");
461
628
  var AdministrativeArea = BaseField.extend({
462
- type: import_zod4.z.literal(FieldType.ADMINISTRATIVE_AREA),
463
- defaultValue: import_zod4.z.union([RequiredTextValue, DependencyExpression]).optional(),
629
+ type: import_zod5.z.literal(FieldType.ADMINISTRATIVE_AREA),
630
+ defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional(),
464
631
  configuration: AdministrativeAreaConfiguration
465
632
  }).describe("Administrative area input field e.g. facility, office");
466
633
  var Location = BaseField.extend({
467
- type: import_zod4.z.literal(FieldType.LOCATION),
468
- defaultValue: import_zod4.z.union([RequiredTextValue, DependencyExpression]).optional()
634
+ type: import_zod5.z.literal(FieldType.LOCATION),
635
+ defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
469
636
  }).describe("Input field for a location");
470
637
  var FileUploadWithOptions = BaseField.extend({
471
- type: import_zod4.z.literal(FieldType.FILE_WITH_OPTIONS),
472
- options: import_zod4.z.array(SelectOption).describe("A list of options")
473
- }).describe("Select input");
638
+ type: import_zod5.z.literal(FieldType.FILE_WITH_OPTIONS),
639
+ options: import_zod5.z.array(SelectOption).describe("A list of options"),
640
+ configuration: import_zod5.z.object({
641
+ maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
642
+ acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
643
+ }).default({
644
+ maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
645
+ })
646
+ });
474
647
  var Facility = BaseField.extend({
475
- type: import_zod4.z.literal(FieldType.FACILITY),
476
- defaultValue: import_zod4.z.union([RequiredTextValue, DependencyExpression]).optional()
648
+ type: import_zod5.z.literal(FieldType.FACILITY),
649
+ defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
477
650
  }).describe("Input field for a facility");
478
651
  var Office = BaseField.extend({
479
- type: import_zod4.z.literal(FieldType.OFFICE),
480
- defaultValue: import_zod4.z.union([RequiredTextValue, DependencyExpression]).optional()
652
+ type: import_zod5.z.literal(FieldType.OFFICE),
653
+ defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
481
654
  }).describe("Input field for an office");
482
655
  var Address = BaseField.extend({
483
- type: import_zod4.z.literal(FieldType.ADDRESS),
656
+ type: import_zod5.z.literal(FieldType.ADDRESS),
484
657
  defaultValue: AddressFieldValue.optional()
485
658
  }).describe("Address input field \u2013 a combination of location and text fields");
486
- var FieldConfig = import_zod4.z.discriminatedUnion("type", [
659
+ var DataEntry = import_zod5.z.union([
660
+ import_zod5.z.object({
661
+ label: TranslationConfig,
662
+ value: import_zod5.z.string()
663
+ }),
664
+ import_zod5.z.object({
665
+ fieldId: import_zod5.z.string()
666
+ })
667
+ ]);
668
+ var DataField = BaseField.extend({
669
+ type: import_zod5.z.literal(FieldType.DATA),
670
+ configuration: import_zod5.z.object({
671
+ subtitle: TranslationConfig.optional(),
672
+ data: import_zod5.z.array(DataEntry)
673
+ })
674
+ }).describe("Data field for displaying read-only data");
675
+ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
487
676
  Address,
488
677
  TextField,
489
678
  NumberField,
@@ -504,244 +693,322 @@ var FieldConfig = import_zod4.z.discriminatedUnion("type", [
504
693
  Office,
505
694
  SignatureField,
506
695
  EmailField,
507
- FileUploadWithOptions
696
+ FileUploadWithOptions,
697
+ DataField
698
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
508
699
  ]);
509
700
 
510
- // ../commons/src/events/FormConfig.ts
511
- var FormPage = import_zod5.z.object({
512
- id: import_zod5.z.string().describe("Unique identifier for the page"),
701
+ // ../commons/src/events/PageConfig.ts
702
+ var PageTypes = import_zod6.z.enum(["FORM", "VERIFICATION"]);
703
+ var PageConfigBase = import_zod6.z.object({
704
+ id: import_zod6.z.string().describe("Unique identifier for the page"),
513
705
  title: TranslationConfig.describe("Header title of the page"),
514
- fields: import_zod5.z.array(FieldConfig).describe("Fields to be rendered on the page")
706
+ fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page"),
707
+ conditional: Conditional.optional().describe(
708
+ "Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
709
+ )
515
710
  });
516
- var FormConfig = import_zod5.z.object({
517
- label: TranslationConfig.describe("Human readable description of the form"),
518
- version: import_zod5.z.object({
519
- id: import_zod5.z.string().describe(
520
- "Form version. Semantic versioning recommended. Example: 0.0.1"
521
- ),
522
- label: TranslationConfig.describe(
523
- "Human readable description of the version"
524
- )
525
- }),
526
- active: import_zod5.z.boolean().default(false).describe("Whether the form is active"),
527
- pages: import_zod5.z.array(FormPage),
528
- review: import_zod5.z.object({
529
- title: TranslationConfig.describe(
530
- "Title of the form to show in review page"
531
- ),
532
- fields: import_zod5.z.array(FieldConfig).describe("Fields to be rendered on the review page for metadata")
711
+ var FormPageConfig = PageConfigBase.extend({
712
+ type: import_zod6.z.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
713
+ });
714
+ var VerificationActionConfig = import_zod6.z.object({
715
+ verify: import_zod6.z.object({ label: TranslationConfig }),
716
+ cancel: import_zod6.z.object({
717
+ label: TranslationConfig,
718
+ confirmation: import_zod6.z.object({
719
+ title: TranslationConfig,
720
+ body: TranslationConfig
721
+ })
533
722
  })
723
+ }).describe("Actions available on the verification page");
724
+ var VerificationPageConfig = FormPageConfig.extend({
725
+ type: import_zod6.z.literal(PageTypes.enum.VERIFICATION),
726
+ actions: VerificationActionConfig
534
727
  });
728
+ var PageConfig = import_zod6.z.discriminatedUnion("type", [
729
+ FormPageConfig,
730
+ VerificationPageConfig
731
+ ]);
535
732
 
536
733
  // ../commons/src/events/ActionType.ts
734
+ var import_zod7 = require("zod");
537
735
  var ActionType = {
736
+ // Pre-declaration actions
737
+ DELETE: "DELETE",
538
738
  CREATE: "CREATE",
539
- ASSIGN: "ASSIGN",
540
- UNASSIGN: "UNASSIGN",
541
- REGISTER: "REGISTER",
542
- VALIDATE: "VALIDATE",
543
- REQUEST_CORRECTION: "REQUEST_CORRECTION",
544
- REJECT_CORRECTION: "REJECT_CORRECTION",
545
- APPROVE_CORRECTION: "APPROVE_CORRECTION",
546
- DETECT_DUPLICATE: "DETECT_DUPLICATE",
547
739
  NOTIFY: "NOTIFY",
740
+ // Declaration actions
548
741
  DECLARE: "DECLARE",
549
- DELETE: "DELETE",
550
- PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
551
- CUSTOM: "CUSTOM",
742
+ VALIDATE: "VALIDATE",
743
+ REGISTER: "REGISTER",
744
+ // Declaration system actions. Non-configurable.
745
+ DETECT_DUPLICATE: "DETECT_DUPLICATE",
552
746
  REJECT: "REJECT",
747
+ // REJECT_DECLARATION
553
748
  MARKED_AS_DUPLICATE: "MARKED_AS_DUPLICATE",
554
- ARCHIVED: "ARCHIVED"
749
+ // MARK_AS_DUPLICATE
750
+ ARCHIVE: "ARCHIVE",
751
+ // Record actions
752
+ PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
753
+ REQUEST_CORRECTION: "REQUEST_CORRECTION",
754
+ REJECT_CORRECTION: "REJECT_CORRECTION",
755
+ APPROVE_CORRECTION: "APPROVE_CORRECTION",
756
+ // General actions
757
+ READ: "READ",
758
+ ASSIGN: "ASSIGN",
759
+ UNASSIGN: "UNASSIGN"
555
760
  };
761
+ var ConfirmableActions = [
762
+ ActionType.NOTIFY,
763
+ ActionType.DECLARE,
764
+ ActionType.VALIDATE,
765
+ ActionType.REGISTER,
766
+ ActionType.REJECT,
767
+ ActionType.ARCHIVE,
768
+ ActionType.PRINT_CERTIFICATE
769
+ ];
770
+ var ActionTypes = import_zod7.z.enum([
771
+ "DELETE",
772
+ "CREATE",
773
+ "NOTIFY",
774
+ "DECLARE",
775
+ "VALIDATE",
776
+ "REGISTER",
777
+ "DETECT_DUPLICATE",
778
+ "REJECT",
779
+ "MARKED_AS_DUPLICATE",
780
+ "ARCHIVE",
781
+ "PRINT_CERTIFICATE",
782
+ "REQUEST_CORRECTION",
783
+ "REJECT_CORRECTION",
784
+ "APPROVE_CORRECTION",
785
+ "READ",
786
+ "ASSIGN",
787
+ "UNASSIGN"
788
+ ]);
789
+ var declarationActionValues = [
790
+ ActionTypes.enum.DECLARE,
791
+ ActionTypes.enum.VALIDATE,
792
+ ActionTypes.enum.REGISTER
793
+ ];
794
+ var DeclarationActions = ActionTypes.extract(declarationActionValues);
795
+ var declarationUpdateActionValues = [
796
+ ...declarationActionValues,
797
+ ActionTypes.enum.REQUEST_CORRECTION
798
+ ];
799
+ var DeclarationUpdateActions = ActionTypes.extract(
800
+ declarationUpdateActionValues
801
+ );
802
+ var annotationActions = ActionTypes.exclude(declarationActionValues);
803
+ var writeActions = ActionTypes.exclude([
804
+ ActionType.CREATE,
805
+ ActionType.READ,
806
+ ActionType.ASSIGN,
807
+ ActionType.UNASSIGN
808
+ ]);
809
+
810
+ // ../commons/src/events/FormConfig.ts
811
+ var import_zod8 = require("zod");
812
+ var DeclarationFormConfig = import_zod8.z.object({
813
+ label: TranslationConfig.describe("Human readable description of the form"),
814
+ pages: import_zod8.z.array(FormPageConfig)
815
+ }).describe("Configuration for a declaration form");
816
+ var ActionFormConfig = import_zod8.z.object({
817
+ label: TranslationConfig.describe("Human readable description of the form"),
818
+ pages: import_zod8.z.array(PageConfig)
819
+ });
820
+ var FormConfig = import_zod8.z.union([DeclarationFormConfig, ActionFormConfig]);
556
821
 
557
822
  // ../commons/src/events/ActionConfig.ts
558
- var ActionConditional2 = import_zod6.z.discriminatedUnion("type", [
823
+ var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
559
824
  /** If conditional is defined, the action is shown to the user only if the condition is met */
560
825
  ShowConditional,
561
826
  /** If conditional is defined, the action is enabled only if the condition is met */
562
827
  EnableConditional
563
828
  ]);
564
- var ActionConfigBase = import_zod6.z.object({
829
+ var DeclarationReviewConfig = import_zod9.z.object({
830
+ title: TranslationConfig.describe("Title of the review page"),
831
+ fields: import_zod9.z.array(FieldConfig).describe("Fields to be rendered on the review page for annotations.")
832
+ }).describe("Configuration for **declaration** review page.");
833
+ var ActionConfigBase = import_zod9.z.object({
565
834
  label: TranslationConfig,
566
- conditionals: import_zod6.z.array(ActionConditional2).optional().default([]),
567
- draft: import_zod6.z.boolean().optional(),
568
- forms: import_zod6.z.array(FormConfig)
835
+ conditionals: import_zod9.z.array(ActionConditional2).optional().default([]),
836
+ draft: import_zod9.z.boolean().optional()
569
837
  });
570
838
  var DeclareConfig = ActionConfigBase.merge(
571
- import_zod6.z.object({
572
- type: import_zod6.z.literal(ActionType.DECLARE)
839
+ import_zod9.z.object({
840
+ type: import_zod9.z.literal(ActionType.DECLARE),
841
+ review: DeclarationReviewConfig
573
842
  })
574
843
  );
575
844
  var ValidateConfig = ActionConfigBase.merge(
576
- import_zod6.z.object({
577
- type: import_zod6.z.literal(ActionType.VALIDATE)
845
+ import_zod9.z.object({
846
+ type: import_zod9.z.literal(ActionType.VALIDATE),
847
+ review: DeclarationReviewConfig
578
848
  })
579
849
  );
580
- var RejectDeclarationConfig = ActionConfigBase.merge(
581
- import_zod6.z.object({
582
- type: import_zod6.z.literal(ActionType.REJECT),
583
- comment: import_zod6.z.string(),
584
- isDuplicate: import_zod6.z.boolean()
850
+ var RegisterConfig = ActionConfigBase.merge(
851
+ import_zod9.z.object({
852
+ type: import_zod9.z.literal(ActionType.REGISTER),
853
+ review: DeclarationReviewConfig
585
854
  })
586
855
  );
587
- var MarkedAsDuplicateConfig = ActionConfigBase.merge(
588
- import_zod6.z.object({
589
- type: import_zod6.z.literal(ActionType.MARKED_AS_DUPLICATE),
590
- comment: import_zod6.z.string(),
591
- duplicates: import_zod6.z.array(import_zod6.z.string()).describe("UUIDs of duplicate records")
856
+ var RejectDeclarationConfig = ActionConfigBase.merge(
857
+ import_zod9.z.object({
858
+ type: import_zod9.z.literal(ActionType.REJECT)
592
859
  })
593
860
  );
594
- var ArchivedConfig = ActionConfigBase.merge(
595
- import_zod6.z.object({
596
- type: import_zod6.z.literal(ActionType.ARCHIVED),
597
- comment: import_zod6.z.string(),
598
- isDuplicate: import_zod6.z.boolean()
861
+ var MarkedAsDuplicateConfig = ActionConfigBase.merge(
862
+ import_zod9.z.object({
863
+ type: import_zod9.z.literal(ActionType.MARKED_AS_DUPLICATE)
599
864
  })
600
865
  );
601
- var RegisterConfig = ActionConfigBase.merge(
602
- import_zod6.z.object({
603
- type: import_zod6.z.literal(ActionType.REGISTER)
866
+ var ArchiveConfig = ActionConfigBase.merge(
867
+ import_zod9.z.object({
868
+ type: import_zod9.z.literal(ActionType.ARCHIVE)
604
869
  })
605
870
  );
606
871
  var DeleteConfig = ActionConfigBase.merge(
607
- import_zod6.z.object({
608
- type: import_zod6.z.literal(ActionType.DELETE)
872
+ import_zod9.z.object({
873
+ type: import_zod9.z.literal(ActionType.DELETE)
609
874
  })
610
875
  );
611
876
  var PrintCertificateActionConfig = ActionConfigBase.merge(
612
- import_zod6.z.object({
613
- type: import_zod6.z.literal(ActionType.PRINT_CERTIFICATE)
877
+ import_zod9.z.object({
878
+ type: import_zod9.z.literal(ActionType.PRINT_CERTIFICATE),
879
+ printForm: ActionFormConfig
614
880
  })
615
881
  );
616
882
  var RequestCorrectionConfig = ActionConfigBase.merge(
617
- import_zod6.z.object({
618
- type: import_zod6.z.literal(ActionType.REQUEST_CORRECTION),
619
- onboardingForm: import_zod6.z.array(FormPage),
620
- additionalDetailsForm: import_zod6.z.array(FormPage)
883
+ import_zod9.z.object({
884
+ type: import_zod9.z.literal(ActionType.REQUEST_CORRECTION),
885
+ onboardingForm: import_zod9.z.array(PageConfig),
886
+ additionalDetailsForm: import_zod9.z.array(PageConfig)
621
887
  })
622
888
  );
623
889
  var RejectCorrectionConfig = ActionConfigBase.merge(
624
- import_zod6.z.object({
625
- type: import_zod6.z.literal(ActionType.REJECT_CORRECTION)
890
+ import_zod9.z.object({
891
+ type: import_zod9.z.literal(ActionType.REJECT_CORRECTION)
626
892
  })
627
893
  );
628
894
  var ApproveCorrectionConfig = ActionConfigBase.merge(
629
- import_zod6.z.object({
630
- type: import_zod6.z.literal(ActionType.APPROVE_CORRECTION)
631
- })
632
- );
633
- var CustomConfig = ActionConfigBase.merge(
634
- import_zod6.z.object({
635
- type: import_zod6.z.literal(ActionType.CUSTOM)
895
+ import_zod9.z.object({
896
+ type: import_zod9.z.literal(ActionType.APPROVE_CORRECTION)
636
897
  })
637
898
  );
638
- var ActionConfig = import_zod6.z.discriminatedUnion("type", [
899
+ var ActionConfig = import_zod9.z.discriminatedUnion("type", [
639
900
  DeclareConfig,
640
901
  ValidateConfig,
641
902
  RejectDeclarationConfig,
642
903
  MarkedAsDuplicateConfig,
643
- ArchivedConfig,
904
+ ArchiveConfig,
644
905
  RegisterConfig,
645
906
  DeleteConfig,
646
907
  PrintCertificateActionConfig,
647
908
  RequestCorrectionConfig,
648
909
  RejectCorrectionConfig,
649
- ApproveCorrectionConfig,
650
- CustomConfig
910
+ ApproveCorrectionConfig
911
+ ]);
912
+ var DeclarationActionConfig = import_zod9.z.discriminatedUnion("type", [
913
+ DeclareConfig,
914
+ ValidateConfig,
915
+ RegisterConfig
651
916
  ]);
652
917
 
653
918
  // ../commons/src/events/offline/CertificateConfig.ts
654
- var import_zod7 = require("zod");
655
- var FontFamily = import_zod7.z.object({
656
- normal: import_zod7.z.string(),
657
- bold: import_zod7.z.string(),
658
- italics: import_zod7.z.string(),
659
- bolditalics: import_zod7.z.string()
919
+ var import_zod10 = require("zod");
920
+ var FontFamily = import_zod10.z.object({
921
+ normal: import_zod10.z.string(),
922
+ bold: import_zod10.z.string(),
923
+ italics: import_zod10.z.string(),
924
+ bolditalics: import_zod10.z.string()
660
925
  });
661
- var CertificateConfig = import_zod7.z.object({
662
- id: import_zod7.z.string(),
663
- event: import_zod7.z.string(),
926
+ var CertificateConfig = import_zod10.z.object({
927
+ id: import_zod10.z.string(),
928
+ event: import_zod10.z.string(),
664
929
  label: TranslationConfig,
665
- isDefault: import_zod7.z.boolean(),
666
- fee: import_zod7.z.object({
667
- onTime: import_zod7.z.number(),
668
- late: import_zod7.z.number(),
669
- delayed: import_zod7.z.number()
930
+ isDefault: import_zod10.z.boolean(),
931
+ fee: import_zod10.z.object({
932
+ onTime: import_zod10.z.number(),
933
+ late: import_zod10.z.number(),
934
+ delayed: import_zod10.z.number()
670
935
  }),
671
- svgUrl: import_zod7.z.string(),
672
- fonts: import_zod7.z.record(FontFamily).optional()
936
+ svgUrl: import_zod10.z.string(),
937
+ fonts: import_zod10.z.record(FontFamily).optional()
673
938
  });
674
939
  var CertificateTemplateConfig = CertificateConfig.extend({
675
- hash: import_zod7.z.string().optional(),
676
- svg: import_zod7.z.string()
940
+ hash: import_zod10.z.string().optional(),
941
+ svg: import_zod10.z.string()
677
942
  });
678
943
 
679
944
  // ../commons/src/events/offline/LanguageConfig.ts
680
- var import_zod8 = require("zod");
681
- var LanguageConfig = import_zod8.z.object({
682
- lang: import_zod8.z.string(),
945
+ var import_zod11 = require("zod");
946
+ var LanguageConfig = import_zod11.z.object({
947
+ lang: import_zod11.z.string(),
683
948
  /**
684
949
  * client.csv contents
685
950
  */
686
- messages: import_zod8.z.record(import_zod8.z.string())
951
+ messages: import_zod11.z.record(import_zod11.z.string())
687
952
  });
688
953
 
689
954
  // ../commons/src/events/EventConfig.ts
690
- var import_zod17 = require("zod");
955
+ var import_zod20 = require("zod");
691
956
 
692
957
  // ../commons/src/events/DeduplicationConfig.ts
693
- var import_zod9 = require("zod");
694
- var FieldReference = import_zod9.z.string();
695
- var Matcher = import_zod9.z.object({
696
- fieldId: import_zod9.z.string(),
697
- options: import_zod9.z.object({
698
- boost: import_zod9.z.number().optional()
958
+ var import_zod12 = require("zod");
959
+ var FieldReference = import_zod12.z.string();
960
+ var Matcher = import_zod12.z.object({
961
+ fieldId: import_zod12.z.string(),
962
+ options: import_zod12.z.object({
963
+ boost: import_zod12.z.number().optional()
699
964
  }).optional().default({})
700
965
  });
701
966
  var FuzzyMatcher = Matcher.extend({
702
- type: import_zod9.z.literal("fuzzy"),
703
- options: import_zod9.z.object({
967
+ type: import_zod12.z.literal("fuzzy"),
968
+ options: import_zod12.z.object({
704
969
  /**
705
970
  * Names of length 3 or less characters = 0 edits allowed
706
971
  * Names of length 4 - 6 characters = 1 edit allowed
707
972
  * Names of length >7 characters = 2 edits allowed
708
973
  */
709
- fuzziness: import_zod9.z.union([import_zod9.z.string(), import_zod9.z.number()]).optional().default("AUTO:4,7"),
710
- boost: import_zod9.z.number().optional().default(1)
974
+ fuzziness: import_zod12.z.union([import_zod12.z.string(), import_zod12.z.number()]).optional().default("AUTO:4,7"),
975
+ boost: import_zod12.z.number().optional().default(1)
711
976
  }).optional().default({})
712
977
  });
713
978
  var StrictMatcher = Matcher.extend({
714
- type: import_zod9.z.literal("strict"),
715
- options: import_zod9.z.object({
716
- boost: import_zod9.z.number().optional().default(1)
979
+ type: import_zod12.z.literal("strict"),
980
+ options: import_zod12.z.object({
981
+ boost: import_zod12.z.number().optional().default(1)
717
982
  }).optional().default({})
718
983
  });
719
984
  var DateRangeMatcher = Matcher.extend({
720
- type: import_zod9.z.literal("dateRange"),
721
- options: import_zod9.z.object({
722
- days: import_zod9.z.number(),
985
+ type: import_zod12.z.literal("dateRange"),
986
+ options: import_zod12.z.object({
987
+ days: import_zod12.z.number(),
723
988
  origin: FieldReference,
724
- boost: import_zod9.z.number().optional().default(1)
989
+ boost: import_zod12.z.number().optional().default(1)
725
990
  })
726
991
  });
727
992
  var DateDistanceMatcher = Matcher.extend({
728
- type: import_zod9.z.literal("dateDistance"),
729
- options: import_zod9.z.object({
730
- days: import_zod9.z.number(),
993
+ type: import_zod12.z.literal("dateDistance"),
994
+ options: import_zod12.z.object({
995
+ days: import_zod12.z.number(),
731
996
  origin: FieldReference,
732
- boost: import_zod9.z.number().optional().default(1)
997
+ boost: import_zod12.z.number().optional().default(1)
733
998
  })
734
999
  });
735
- var And = import_zod9.z.object({
736
- type: import_zod9.z.literal("and"),
737
- clauses: import_zod9.z.lazy(() => Clause.array())
1000
+ var And = import_zod12.z.object({
1001
+ type: import_zod12.z.literal("and"),
1002
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
1003
+ clauses: import_zod12.z.lazy(() => Clause.array())
738
1004
  });
739
- var Or = import_zod9.z.object({
740
- type: import_zod9.z.literal("or"),
741
- clauses: import_zod9.z.lazy(() => Clause.array())
1005
+ var Or = import_zod12.z.object({
1006
+ type: import_zod12.z.literal("or"),
1007
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
1008
+ clauses: import_zod12.z.lazy(() => Clause.array())
742
1009
  });
743
- var Clause = import_zod9.z.lazy(
744
- () => import_zod9.z.discriminatedUnion("type", [
1010
+ var Clause = import_zod12.z.lazy(
1011
+ () => import_zod12.z.discriminatedUnion("type", [
745
1012
  And,
746
1013
  Or,
747
1014
  FuzzyMatcher,
@@ -750,37 +1017,37 @@ var Clause = import_zod9.z.lazy(
750
1017
  DateDistanceMatcher
751
1018
  ])
752
1019
  );
753
- var DeduplicationConfig = import_zod9.z.object({
754
- id: import_zod9.z.string(),
1020
+ var DeduplicationConfig = import_zod12.z.object({
1021
+ id: import_zod12.z.string(),
755
1022
  label: TranslationConfig,
756
1023
  query: Clause
757
1024
  });
758
1025
 
759
1026
  // ../commons/src/events/SummaryConfig.ts
760
- var import_zod10 = require("zod");
761
- var Field = import_zod10.z.object({
762
- id: import_zod10.z.string().describe("Id of summary field"),
1027
+ var import_zod13 = require("zod");
1028
+ var Field = import_zod13.z.object({
1029
+ id: import_zod13.z.string().describe("Id of summary field"),
763
1030
  value: TranslationConfig.describe(
764
1031
  "Summary field value. Can utilise values defined in configuration and EventMetadata"
765
1032
  ),
766
1033
  label: TranslationConfig,
767
1034
  emptyValueMessage: TranslationConfig.optional()
768
1035
  });
769
- var Title = import_zod10.z.object({
770
- id: import_zod10.z.string(),
1036
+ var Title = import_zod13.z.object({
1037
+ id: import_zod13.z.string(),
771
1038
  label: TranslationConfig.describe("Title content"),
772
1039
  emptyValueMessage: TranslationConfig.optional()
773
1040
  });
774
- var SummaryConfig = import_zod10.z.object({
1041
+ var SummaryConfig = import_zod13.z.object({
775
1042
  title: Title.describe("Title of summary view."),
776
- fields: import_zod10.z.array(Field).describe("Fields rendered in summary view.")
1043
+ fields: import_zod13.z.array(Field).describe("Fields rendered in summary view.")
777
1044
  }).describe("Configuration for summary in event.");
778
1045
 
779
1046
  // ../commons/src/events/WorkqueueConfig.ts
780
- var import_zod12 = require("zod");
1047
+ var import_zod15 = require("zod");
781
1048
 
782
1049
  // ../commons/src/events/EventMetadata.ts
783
- var import_zod11 = require("zod");
1050
+ var import_zod14 = require("zod");
784
1051
  var EventStatus = {
785
1052
  CREATED: "CREATED",
786
1053
  NOTIFIED: "NOTIFIED",
@@ -792,18 +1059,19 @@ var EventStatus = {
792
1059
  ARCHIVED: "ARCHIVED"
793
1060
  };
794
1061
  var eventStatuses = Object.values(EventStatus);
795
- var EventStatuses = import_zod11.z.nativeEnum(EventStatus);
796
- var EventMetadata = import_zod11.z.object({
797
- id: import_zod11.z.string(),
798
- type: import_zod11.z.string(),
1062
+ var EventStatuses = import_zod14.z.nativeEnum(EventStatus);
1063
+ var EventMetadata = import_zod14.z.object({
1064
+ id: import_zod14.z.string(),
1065
+ type: import_zod14.z.string(),
799
1066
  status: EventStatuses,
800
- createdAt: import_zod11.z.string().datetime(),
801
- createdBy: import_zod11.z.string(),
802
- createdAtLocation: import_zod11.z.string(),
803
- modifiedAt: import_zod11.z.string().datetime(),
804
- assignedTo: import_zod11.z.string().nullable(),
805
- updatedBy: import_zod11.z.string(),
806
- trackingId: import_zod11.z.string()
1067
+ createdAt: import_zod14.z.string().datetime(),
1068
+ createdBy: import_zod14.z.string(),
1069
+ createdAtLocation: import_zod14.z.string(),
1070
+ modifiedAt: import_zod14.z.string().datetime(),
1071
+ assignedTo: import_zod14.z.string().nullish(),
1072
+ updatedBy: import_zod14.z.string(),
1073
+ trackingId: import_zod14.z.string(),
1074
+ registrationNumber: import_zod14.z.string().nullish()
807
1075
  });
808
1076
  var eventMetadataLabelMap = {
809
1077
  "event.assignedTo": {
@@ -855,28 +1123,33 @@ var eventMetadataLabelMap = {
855
1123
  id: "event.trackingId.label",
856
1124
  defaultMessage: "Tracking ID",
857
1125
  description: "Tracking ID"
1126
+ },
1127
+ "event.registrationNumber": {
1128
+ id: "event.registrationNumber.label",
1129
+ defaultMessage: "Registration Number",
1130
+ description: "Registration Number"
858
1131
  }
859
1132
  };
860
1133
 
861
1134
  // ../commons/src/events/WorkqueueConfig.ts
862
- var WorkqueueConfig = import_zod12.z.object({
863
- id: import_zod12.z.string().describe("Unique identifier for workqueue."),
864
- filters: import_zod12.z.array(
865
- import_zod12.z.object({
866
- status: import_zod12.z.array(EventStatuses).describe("Defines which statusese are included in the workqueue.")
1135
+ var WorkqueueConfig = import_zod15.z.object({
1136
+ id: import_zod15.z.string().describe("Unique identifier for workqueue."),
1137
+ filters: import_zod15.z.array(
1138
+ import_zod15.z.object({
1139
+ status: import_zod15.z.array(EventStatuses).describe("Defines which statusese are included in the workqueue.")
867
1140
  })
868
1141
  ).describe("Filters to be applied to workqueue.")
869
1142
  }).describe("Configuration for workqueue.");
870
1143
 
871
1144
  // ../commons/src/events/AdvancedSearchConfig.ts
872
- var import_zod13 = require("zod");
873
- var AdvancedSearchConfig = import_zod13.z.object({
1145
+ var import_zod16 = require("zod");
1146
+ var AdvancedSearchConfig = import_zod16.z.object({
874
1147
  title: TranslationConfig.describe("Advanced search tab title"),
875
- fields: import_zod13.z.array(
876
- import_zod13.z.object({
877
- fieldId: import_zod13.z.string(),
878
- config: import_zod13.z.object({
879
- type: import_zod13.z.enum(["FUZZY", "EXACT", "RANGE"]).describe("Determines the type of field")
1148
+ fields: import_zod16.z.array(
1149
+ import_zod16.z.object({
1150
+ fieldId: import_zod16.z.string(),
1151
+ config: import_zod16.z.object({
1152
+ type: import_zod16.z.enum(["FUZZY", "EXACT", "RANGE"]).describe("Determines the type of field")
880
1153
  }).optional().describe("Configuration options for the field")
881
1154
  })
882
1155
  ).optional().default([]).describe("Advanced search fields.")
@@ -886,12 +1159,12 @@ var AdvancedSearchConfig = import_zod13.z.object({
886
1159
  var import_lodash = require("lodash");
887
1160
 
888
1161
  // ../commons/src/workqueues/WorkqueueConfig.ts
889
- var import_zod15 = require("zod");
1162
+ var import_zod18 = require("zod");
890
1163
 
891
1164
  // ../commons/src/workqueues/defaultColumns.ts
892
- var import_zod14 = require("zod");
893
- var WorkQueueColumnConfig = import_zod14.z.object({
894
- id: import_zod14.z.string(),
1165
+ var import_zod17 = require("zod");
1166
+ var WorkQueueColumnConfig = import_zod17.z.object({
1167
+ id: import_zod17.z.string(),
895
1168
  label: TranslationConfig
896
1169
  });
897
1170
  var defaultColumns = {
@@ -928,16 +1201,16 @@ var defaultColumns = {
928
1201
  }
929
1202
  }
930
1203
  };
931
- var DefaultColumnKeys = import_zod14.z.enum(
1204
+ var DefaultColumnKeys = import_zod17.z.enum(
932
1205
  Object.keys(defaultColumns)
933
1206
  );
934
1207
 
935
1208
  // ../commons/src/workqueues/WorkqueueConfig.ts
936
- var rootWorkqueueConfig = import_zod15.z.object({
937
- id: import_zod15.z.string(),
1209
+ var rootWorkqueueConfig = import_zod18.z.object({
1210
+ id: import_zod18.z.string(),
938
1211
  title: TranslationConfig,
939
- columns: import_zod15.z.array(WorkQueueColumnConfig),
940
- defaultColumns: import_zod15.z.array(DefaultColumnKeys)
1212
+ columns: import_zod18.z.array(WorkQueueColumnConfig),
1213
+ defaultColumns: import_zod18.z.array(DefaultColumnKeys)
941
1214
  });
942
1215
  var defineWorkqueue = (config) => rootWorkqueueConfig.parse(config);
943
1216
 
@@ -1017,7 +1290,7 @@ var import_ajv_formats = __toESM(require("ajv-formats"));
1017
1290
  var import_date_fns = require("date-fns");
1018
1291
 
1019
1292
  // ../commons/src/events/FieldTypeMapping.ts
1020
- var import_zod16 = require("zod");
1293
+ var import_zod19 = require("zod");
1021
1294
  function mapFieldTypeToZod(type, required) {
1022
1295
  let schema;
1023
1296
  switch (type) {
@@ -1057,17 +1330,20 @@ function mapFieldTypeToZod(type, required) {
1057
1330
  schema = FileFieldWithOptionValue;
1058
1331
  break;
1059
1332
  case FieldType.ADDRESS:
1060
- schema = AddressFieldValue;
1333
+ schema = AddressFieldUpdateValue;
1334
+ break;
1335
+ case FieldType.DATA:
1336
+ schema = DataFieldValue;
1061
1337
  break;
1062
1338
  }
1063
- return required ? schema : schema.optional();
1339
+ return required ? schema : schema.nullish();
1064
1340
  }
1065
1341
  function createValidationSchema(config) {
1066
1342
  const shape = {};
1067
1343
  for (const field2 of config) {
1068
1344
  shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
1069
1345
  }
1070
- return import_zod16.z.object(shape);
1346
+ return import_zod19.z.object(shape);
1071
1347
  }
1072
1348
  function mapFieldTypeToMockValue(field2, i) {
1073
1349
  switch (field2.type) {
@@ -1093,6 +1369,7 @@ function mapFieldTypeToMockValue(field2, i) {
1093
1369
  case FieldType.ADDRESS:
1094
1370
  return {
1095
1371
  country: "FAR",
1372
+ addressType: AddressType.DOMESTIC,
1096
1373
  province: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
1097
1374
  district: "5ef450bc-712d-48ad-93f3-8da0fa453baa",
1098
1375
  urbanOrRural: "URBAN",
@@ -1114,6 +1391,54 @@ function mapFieldTypeToMockValue(field2, i) {
1114
1391
  };
1115
1392
  case FieldType.FILE_WITH_OPTIONS:
1116
1393
  return null;
1394
+ case FieldType.DATA:
1395
+ return {};
1396
+ }
1397
+ }
1398
+ function mapFieldTypeToEmptyValue(field2) {
1399
+ switch (field2.type) {
1400
+ case FieldType.DIVIDER:
1401
+ case FieldType.TEXT:
1402
+ case FieldType.TEXTAREA:
1403
+ case FieldType.BULLET_LIST:
1404
+ case FieldType.PAGE_HEADER:
1405
+ case FieldType.LOCATION:
1406
+ case FieldType.SELECT:
1407
+ case FieldType.COUNTRY:
1408
+ case FieldType.RADIO_GROUP:
1409
+ case FieldType.SIGNATURE:
1410
+ case FieldType.PARAGRAPH:
1411
+ case FieldType.ADMINISTRATIVE_AREA:
1412
+ case FieldType.FACILITY:
1413
+ case FieldType.OFFICE:
1414
+ case FieldType.NUMBER:
1415
+ case FieldType.EMAIL:
1416
+ case FieldType.DATE:
1417
+ case FieldType.CHECKBOX:
1418
+ case FieldType.DATA:
1419
+ return null;
1420
+ case FieldType.ADDRESS:
1421
+ return {
1422
+ country: null,
1423
+ addressType: AddressType.DOMESTIC,
1424
+ province: null,
1425
+ district: null,
1426
+ urbanOrRural: "URBAN",
1427
+ // Default to urban needed for validation
1428
+ town: null,
1429
+ residentialArea: null,
1430
+ street: null,
1431
+ number: null,
1432
+ zipCode: null
1433
+ };
1434
+ case FieldType.FILE:
1435
+ return {
1436
+ filename: "",
1437
+ originalFilename: "",
1438
+ type: ""
1439
+ };
1440
+ case FieldType.FILE_WITH_OPTIONS:
1441
+ return [];
1117
1442
  }
1118
1443
  }
1119
1444
  var isParagraphFieldType = (field2) => {
@@ -1179,10 +1504,14 @@ var isFacilityFieldType = (field2) => {
1179
1504
  var isOfficeFieldType = (field2) => {
1180
1505
  return field2.config.type === FieldType.OFFICE;
1181
1506
  };
1507
+ var isDataFieldType = (field2) => {
1508
+ return field2.config.type === FieldType.DATA;
1509
+ };
1182
1510
 
1183
1511
  // ../commons/src/conditionals/validate.ts
1184
1512
  var ajv = new import_ajv.default({
1185
- $data: true
1513
+ $data: true,
1514
+ allowUnionTypes: true
1186
1515
  });
1187
1516
  (0, import_ajv_formats.default)(ajv);
1188
1517
  function validate(schema, data) {
@@ -1215,88 +1544,81 @@ function isFieldVisible(field2, form) {
1215
1544
  function isFieldEnabled(field2, form) {
1216
1545
  return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
1217
1546
  }
1218
- var zodToIntlErrorMap = (issue, _ctx) => {
1219
- if (issue.code === "invalid_string" && issue.validation === "date") {
1220
- return {
1221
- message: {
1222
- message: {
1223
- defaultMessage: "Invalid date. Please use the format YYYY-MM-DD",
1224
- description: "This is the error message for invalid date fields",
1225
- id: "v2.error.invalidDate"
1226
- }
1227
- }
1228
- };
1229
- }
1230
- if (issue.code === "invalid_string" && issue.validation === "email") {
1231
- return {
1232
- message: {
1233
- message: {
1234
- defaultMessage: "Invalid email address",
1235
- description: "This is the error message for invalid email fields",
1236
- id: "v2.error.invalidEmail"
1237
- }
1238
- }
1239
- };
1240
- }
1241
- if (issue.code === "invalid_type" && issue.expected !== issue.received && issue.received === "undefined" || issue.code === "too_small" && issue.message === void 0) {
1242
- return {
1243
- message: {
1244
- message: {
1245
- defaultMessage: "Required for registration",
1246
- description: "This is the error message for required fields",
1247
- id: "v2.error.required"
1248
- }
1249
- }
1250
- };
1547
+ function isFieldDisplayedOnReview(field2, form) {
1548
+ return isFieldVisible(field2, form) && isFieldConditionMet(field2, form, ConditionalType.DISPLAY_ON_REVIEW);
1549
+ }
1550
+ var errorMessages = {
1551
+ hiddenField: {
1552
+ id: "v2.error.hidden",
1553
+ defaultMessage: "Hidden or disabled field should not receive a value",
1554
+ description: "Error message when field is hidden or disabled, but a value was received"
1555
+ },
1556
+ invalidDate: {
1557
+ defaultMessage: "Invalid date field",
1558
+ description: "Error message when date field is invalid",
1559
+ id: "v2.error.invalidDate"
1560
+ },
1561
+ invalidEmail: {
1562
+ defaultMessage: "Invalid email address",
1563
+ description: "Error message when email address is invalid",
1564
+ id: "v2.error.invalidEmail"
1565
+ },
1566
+ requiredField: {
1567
+ defaultMessage: "Required for registration",
1568
+ description: "Error message when required field is missing",
1569
+ id: "v2.error.required"
1570
+ },
1571
+ invalidInput: {
1572
+ defaultMessage: "Invalid input",
1573
+ description: "Error message when generic field is invalid",
1574
+ id: "v2.error.invalid"
1251
1575
  }
1576
+ };
1577
+ function createIntlError(message) {
1252
1578
  return {
1253
1579
  message: {
1254
- message: {
1255
- defaultMessage: "Invalid input",
1256
- description: "This is the error message for invalid field value",
1257
- id: "v2.error.invalid"
1258
- }
1580
+ message
1259
1581
  }
1260
1582
  };
1261
- };
1262
- function getFieldValidationErrors({
1263
- field: field2,
1264
- values
1265
- }) {
1266
- const conditionalParameters = {
1267
- $form: values,
1268
- $now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
1269
- };
1270
- if (!isFieldVisible(field2, values) || !isFieldEnabled(field2, values)) {
1271
- if (values[field2.id]) {
1272
- return {
1273
- errors: [
1274
- {
1275
- message: {
1276
- id: "v2.error.hidden",
1277
- defaultMessage: "Hidden or disabled field should not receive a value",
1278
- description: "Error message when field is hidden or disabled, but a value was received"
1279
- }
1583
+ }
1584
+ function zodToIntlErrorMap(issue, _ctx) {
1585
+ switch (issue.code) {
1586
+ case "invalid_string": {
1587
+ if (_ctx.data === "") {
1588
+ return createIntlError(errorMessages.requiredField);
1589
+ }
1590
+ if (issue.validation === "date") {
1591
+ return createIntlError(errorMessages.invalidDate);
1592
+ }
1593
+ if (issue.validation === "email") {
1594
+ return createIntlError(errorMessages.invalidEmail);
1595
+ }
1596
+ break;
1597
+ }
1598
+ case "invalid_type": {
1599
+ if (issue.expected !== issue.received && issue.received === "undefined") {
1600
+ return createIntlError(errorMessages.requiredField);
1601
+ }
1602
+ break;
1603
+ }
1604
+ case "too_small": {
1605
+ if (issue.message === void 0) {
1606
+ return createIntlError(errorMessages.requiredField);
1607
+ }
1608
+ break;
1609
+ }
1610
+ case "invalid_union": {
1611
+ for (const { issues } of issue.unionErrors) {
1612
+ for (const e of issues) {
1613
+ if (zodToIntlErrorMap(e, _ctx).message.message.id !== "v2.error.required") {
1614
+ return createIntlError(errorMessages.invalidInput);
1280
1615
  }
1281
- ]
1282
- };
1616
+ }
1617
+ }
1618
+ return createIntlError(errorMessages.requiredField);
1283
1619
  }
1284
- return {
1285
- errors: []
1286
- };
1287
1620
  }
1288
- const fieldValidationResult = validateFieldInput({
1289
- field: field2,
1290
- value: values[field2.id]
1291
- });
1292
- const customValidationResults = runCustomFieldValidations({
1293
- field: field2,
1294
- conditionalParameters
1295
- });
1296
- return {
1297
- // Assumes that custom validation errors are more important than field validation errors
1298
- errors: [...customValidationResults, ...fieldValidationResult]
1299
- };
1621
+ return createIntlError(errorMessages.invalidInput);
1300
1622
  }
1301
1623
  function runCustomFieldValidations({
1302
1624
  field: field2,
@@ -1319,68 +1641,126 @@ function validateFieldInput({
1319
1641
  );
1320
1642
  return rawError.error?.issues.map((issue) => issue.message) ?? [];
1321
1643
  }
1322
-
1323
- // ../commons/src/events/utils.ts
1324
- function isMetadataField(field2) {
1325
- return field2 in eventMetadataLabelMap;
1326
- }
1327
- var findInputPageFields = (config) => {
1328
- return (0, import_lodash.flattenDeep)(
1329
- config.actions.map(
1330
- ({ forms }) => forms.map(
1331
- ({ pages }) => pages.map(
1332
- ({ fields }) => fields.map(({ id, label }) => ({ id, label }))
1333
- )
1334
- )
1335
- )
1336
- );
1337
- };
1338
- var findPageFields = (config) => {
1339
- return (0, import_lodash.flattenDeep)(
1340
- config.actions.map((action) => {
1341
- if (action.type === ActionType.REQUEST_CORRECTION) {
1342
- return [
1343
- ...action.forms.map(({ pages }) => pages.map(({ fields }) => fields)),
1344
- ...action.onboardingForm.flatMap(({ fields }) => fields),
1345
- ...action.additionalDetailsForm.flatMap(({ fields }) => fields)
1346
- ];
1347
- }
1348
- return action.forms.map(({ pages }) => pages.map(({ fields }) => fields));
1349
- })
1350
- );
1351
- };
1352
- var resolveLabelsFromKnownFields = ({
1353
- pageFields,
1354
- refFields
1355
- }) => {
1356
- return refFields.map((field2) => {
1357
- if (field2.label) {
1358
- return field2;
1359
- }
1360
- if (isMetadataField(field2.id)) {
1644
+ function runFieldValidations({
1645
+ field: field2,
1646
+ values
1647
+ }) {
1648
+ const conditionalParameters = {
1649
+ $form: values,
1650
+ $now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
1651
+ };
1652
+ const fieldValidationResult = validateFieldInput({
1653
+ field: field2,
1654
+ value: values[field2.id]
1655
+ });
1656
+ const customValidationResults = runCustomFieldValidations({
1657
+ field: field2,
1658
+ conditionalParameters
1659
+ });
1660
+ return {
1661
+ // Assumes that custom validation errors are based on the field type, and extend the validation.
1662
+ errors: [...fieldValidationResult, ...customValidationResults]
1663
+ };
1664
+ }
1665
+ function getFieldValidationErrors({
1666
+ field: field2,
1667
+ values
1668
+ }) {
1669
+ if (!isFieldVisible(field2, values) || !isFieldEnabled(field2, values)) {
1670
+ if (values[field2.id]) {
1361
1671
  return {
1362
- ...field2,
1363
- label: eventMetadataLabelMap[field2.id]
1672
+ errors: [
1673
+ {
1674
+ message: errorMessages.hiddenField
1675
+ }
1676
+ ]
1364
1677
  };
1365
1678
  }
1366
- const pageLabel = pageFields.find((pageField) => pageField.id === field2.id);
1367
- if (!pageLabel) {
1368
- throw new Error(`Referenced field ${field2.id} does not have a label`);
1369
- }
1370
1679
  return {
1371
- ...field2,
1372
- label: pageLabel.label
1680
+ errors: []
1373
1681
  };
1682
+ }
1683
+ return runFieldValidations({
1684
+ field: field2,
1685
+ values
1374
1686
  });
1687
+ }
1688
+
1689
+ // ../commons/src/uuid.ts
1690
+ var import_uuid = require("uuid");
1691
+ function getUUID() {
1692
+ return (0, import_uuid.v4)();
1693
+ }
1694
+
1695
+ // ../commons/src/events/utils.ts
1696
+ var import_date_fns2 = require("date-fns");
1697
+
1698
+ // ../commons/src/utils.ts
1699
+ function getOrThrow(x, message) {
1700
+ if (x === void 0 || x === null) {
1701
+ throw new Error(message);
1702
+ }
1703
+ return x;
1704
+ }
1705
+
1706
+ // ../commons/src/events/utils.ts
1707
+ function isDeclarationActionConfig(action) {
1708
+ return DeclarationActions.safeParse(action.type).success;
1709
+ }
1710
+ function getDeclarationFields(configuration) {
1711
+ return configuration.declaration.pages.flatMap(({ fields }) => fields);
1712
+ }
1713
+ function getDeclarationPages(configuration) {
1714
+ return configuration.declaration.pages;
1715
+ }
1716
+ function getDeclaration(configuration) {
1717
+ return configuration.declaration;
1718
+ }
1719
+ var getActionAnnotationFields = (actionConfig) => {
1720
+ if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
1721
+ return [
1722
+ ...actionConfig.onboardingForm.flatMap(({ fields }) => fields),
1723
+ ...actionConfig.additionalDetailsForm.flatMap(({ fields }) => fields)
1724
+ ];
1725
+ }
1726
+ if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
1727
+ return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
1728
+ }
1729
+ if (isDeclarationActionConfig(actionConfig)) {
1730
+ return actionConfig.review.fields;
1731
+ }
1732
+ return [];
1375
1733
  };
1376
- function getAllFields(configuration) {
1377
- return configuration.actions.flatMap((action) => action.forms.filter((form) => form.active)).flatMap((form) => [
1378
- ...form.review.fields,
1379
- ...form.pages.flatMap((page) => page.fields)
1734
+ var getAllAnnotationFields = (config) => {
1735
+ return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
1736
+ };
1737
+ var findAllFields = (config) => {
1738
+ return (0, import_lodash.flattenDeep)([
1739
+ ...getDeclarationFields(config),
1740
+ ...getAllAnnotationFields(config)
1380
1741
  ]);
1742
+ };
1743
+ var findRecordActionPages = (config, actionType) => {
1744
+ const action = config.actions.find((a) => a.type === actionType);
1745
+ if (action?.type === ActionType.REQUEST_CORRECTION) {
1746
+ return [...action.onboardingForm, ...action.additionalDetailsForm];
1747
+ }
1748
+ if (action?.type === ActionType.PRINT_CERTIFICATE) {
1749
+ return action.printForm.pages;
1750
+ }
1751
+ return [];
1752
+ };
1753
+ function getActionReview(configuration, actionType) {
1754
+ const [actionConfig] = configuration.actions.filter(
1755
+ (a) => a.type === actionType
1756
+ );
1757
+ return getOrThrow(
1758
+ actionConfig.review,
1759
+ `No review config found for ${actionType}`
1760
+ );
1381
1761
  }
1382
- function getAllPages(configuration) {
1383
- return configuration.actions.flatMap((action) => action.forms.filter((form) => form.active)).flatMap((form) => form.pages);
1762
+ function getActionReviewFields(configuration, actionType) {
1763
+ return getActionReview(configuration, actionType).fields;
1384
1764
  }
1385
1765
  function validateWorkqueueConfig(workqueueConfigs) {
1386
1766
  workqueueConfigs.map((workqueue) => {
@@ -1389,82 +1769,98 @@ function validateWorkqueueConfig(workqueueConfigs) {
1389
1769
  );
1390
1770
  if (!rootWorkqueue) {
1391
1771
  throw new Error(
1392
- `Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
1772
+ `Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
1393
1773
  );
1394
1774
  }
1395
1775
  });
1396
1776
  }
1397
- var findActiveActionForm = (configuration, action) => {
1398
- const actionConfig = configuration.actions.find((a) => a.type === action);
1399
- const form = actionConfig?.forms.find((f) => f.active);
1400
- return form;
1401
- };
1402
- var findActiveActionFormPages = (configuration, action) => {
1403
- return findActiveActionForm(configuration, action)?.pages;
1404
- };
1405
- var getFormFields = (formConfig) => {
1406
- return formConfig.pages.flatMap((p) => p.fields);
1407
- };
1408
- var findActiveActionFormFields = (configuration, action) => {
1409
- const form = findActiveActionForm(configuration, action);
1410
- return form ? getFormFields(form) : void 0;
1411
- };
1412
- var findActiveActionFields = (configuration, action) => {
1413
- const form = findActiveActionForm(configuration, action);
1414
- const reviewFields = form?.review.fields;
1415
- const formFields = form ? getFormFields(form) : void 0;
1416
- const allFields = formFields ? formFields.concat(reviewFields ?? []) : reviewFields;
1417
- return allFields;
1418
- };
1419
- function getActiveActionFields(configuration, action) {
1420
- const fields = findActiveActionFields(configuration, action);
1421
- if (!fields) {
1422
- throw new Error(`No active field config found for action type ${action}`);
1423
- }
1424
- return fields;
1425
- }
1426
- function getEventConfiguration(eventConfigurations, type) {
1427
- const config = eventConfigurations.find((config2) => config2.id === type);
1428
- if (!config) {
1429
- throw new Error(`Event configuration not found for type: ${type}`);
1430
- }
1431
- return config;
1432
- }
1433
- function isOptionalUncheckedCheckbox(field2, form) {
1434
- if (field2.type !== FieldType.CHECKBOX) {
1435
- return false;
1436
- }
1437
- if (field2.required) {
1438
- return false;
1777
+ function isPageVisible(page, formValues) {
1778
+ if (!page.conditional) {
1779
+ return true;
1439
1780
  }
1440
- return !form[field2.id];
1781
+ return validate(page.conditional, {
1782
+ $form: formValues,
1783
+ $now: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
1784
+ });
1441
1785
  }
1442
- function stripHiddenFields(fields, data) {
1443
- return (0, import_lodash.omitBy)(data, (_, fieldId) => {
1786
+ function omitHiddenFields(fields, values) {
1787
+ return (0, import_lodash.omitBy)(values, (_, fieldId) => {
1444
1788
  const field2 = fields.find((f) => f.id === fieldId);
1445
1789
  if (!field2) {
1446
1790
  return true;
1447
1791
  }
1448
- if (isOptionalUncheckedCheckbox(field2, data)) {
1449
- return true;
1450
- }
1451
- return !isFieldVisible(field2, data);
1792
+ return !isFieldVisible(field2, values);
1452
1793
  });
1453
1794
  }
1795
+ function omitHiddenPaginatedFields(formConfig, declaration) {
1796
+ const visiblePagesFormFields = formConfig.pages.filter((p) => isPageVisible(p, declaration)).flatMap((p) => p.fields);
1797
+ return omitHiddenFields(visiblePagesFormFields, declaration);
1798
+ }
1799
+ function findActiveDrafts(event2, drafts) {
1800
+ const actions = event2.actions.slice().filter(({ type }) => type !== ActionType.READ).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
1801
+ const lastAction = actions[actions.length - 1];
1802
+ return drafts.filter(({ createdAt }) => createdAt >= lastAction.createdAt).filter(({ eventId }) => eventId === event2.id);
1803
+ }
1804
+ function createEmptyDraft(eventId, draftId, actionType) {
1805
+ return {
1806
+ id: draftId,
1807
+ eventId,
1808
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1809
+ transactionId: getUUID(),
1810
+ action: {
1811
+ type: actionType,
1812
+ declaration: {},
1813
+ annotation: {},
1814
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1815
+ createdBy: "@todo",
1816
+ createdAtLocation: "@todo"
1817
+ }
1818
+ };
1819
+ }
1820
+ function isVerificationPage(page) {
1821
+ return page.type === PageTypes.enum.VERIFICATION;
1822
+ }
1823
+ function deepMerge(currentDocument, actionDocument) {
1824
+ return (0, import_lodash.mergeWith)(
1825
+ currentDocument,
1826
+ actionDocument,
1827
+ (previousValue, incomingValue) => {
1828
+ if (incomingValue === void 0) {
1829
+ return previousValue;
1830
+ }
1831
+ if ((0, import_lodash.isArray)(incomingValue)) {
1832
+ return incomingValue;
1833
+ }
1834
+ if ((0, import_lodash.isObject)(previousValue) && (0, import_lodash.isObject)(incomingValue)) {
1835
+ return void 0;
1836
+ }
1837
+ return incomingValue;
1838
+ }
1839
+ );
1840
+ }
1841
+ function findLastAssignmentAction(actions) {
1842
+ return actions.filter(
1843
+ ({ type }) => type === ActionType.ASSIGN || type === ActionType.UNASSIGN
1844
+ ).reduce((latestAction, action) => !latestAction || action.createdAt > latestAction.createdAt ? action : latestAction, void 0);
1845
+ }
1846
+ function isWriteAction(actionType) {
1847
+ return writeActions.safeParse(actionType).success;
1848
+ }
1454
1849
 
1455
1850
  // ../commons/src/events/EventConfig.ts
1456
- var EventConfig = import_zod17.z.object({
1457
- id: import_zod17.z.string().describe(
1851
+ var EventConfig = import_zod20.z.object({
1852
+ id: import_zod20.z.string().describe(
1458
1853
  'A machine-readable identifier for the event, e.g. "birth" or "death"'
1459
1854
  ),
1460
1855
  summary: SummaryConfig,
1461
1856
  label: TranslationConfig,
1462
- actions: import_zod17.z.array(ActionConfig),
1463
- workqueues: import_zod17.z.array(WorkqueueConfig),
1464
- deduplication: import_zod17.z.array(DeduplicationConfig).optional().default([]),
1465
- advancedSearch: import_zod17.z.array(AdvancedSearchConfig).optional().default([])
1857
+ actions: import_zod20.z.array(ActionConfig),
1858
+ declaration: DeclarationFormConfig,
1859
+ workqueues: import_zod20.z.array(WorkqueueConfig),
1860
+ deduplication: import_zod20.z.array(DeduplicationConfig).optional().default([]),
1861
+ advancedSearch: import_zod20.z.array(AdvancedSearchConfig).optional().default([])
1466
1862
  }).superRefine((event2, ctx) => {
1467
- const allFields = findPageFields(event2);
1863
+ const allFields = findAllFields(event2);
1468
1864
  const fieldIds = allFields.map((field2) => field2.id);
1469
1865
  const advancedSearchFields = event2.advancedSearch.flatMap(
1470
1866
  (section) => section.fields.flatMap((field2) => field2.fieldId)
@@ -1491,111 +1887,123 @@ var EventConfig = import_zod17.z.object({
1491
1887
  });
1492
1888
 
1493
1889
  // ../commons/src/events/EventConfigInput.ts
1494
- var defineForm = (form) => FormConfig.parse(form);
1495
- var defineFormPage = (formPage) => FormPage.parse(formPage);
1890
+ var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
1891
+ var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
1892
+ var definePage = (page) => PageConfig.parse(page);
1893
+ var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
1496
1894
 
1497
1895
  // ../commons/src/events/Draft.ts
1498
- var import_zod20 = require("zod");
1896
+ var import_zod23 = require("zod");
1499
1897
 
1500
1898
  // ../commons/src/events/ActionDocument.ts
1501
- var import_zod18 = require("zod");
1502
- var ActionMetadata = import_zod18.z.record(import_zod18.z.string(), FieldValue);
1503
- var ActionBase = import_zod18.z.object({
1504
- id: import_zod18.z.string(),
1505
- createdAt: import_zod18.z.string().datetime(),
1506
- createdBy: import_zod18.z.string(),
1507
- data: import_zod18.z.record(import_zod18.z.string(), FieldValue),
1508
- metadata: ActionMetadata.optional(),
1509
- createdAtLocation: import_zod18.z.string()
1899
+ var import_zod21 = require("zod");
1900
+ var ActionUpdate = import_zod21.z.record(import_zod21.z.string(), FieldUpdateValue);
1901
+ var ActionStatus = {
1902
+ Requested: "Requested",
1903
+ Accepted: "Accepted",
1904
+ Rejected: "Rejected"
1905
+ };
1906
+ var ActionBase = import_zod21.z.object({
1907
+ id: import_zod21.z.string(),
1908
+ createdAt: import_zod21.z.string().datetime(),
1909
+ createdBy: import_zod21.z.string(),
1910
+ declaration: ActionUpdate,
1911
+ annotation: ActionUpdate.optional(),
1912
+ createdAtLocation: import_zod21.z.string(),
1913
+ status: import_zod21.z.enum([
1914
+ ActionStatus.Requested,
1915
+ ActionStatus.Accepted,
1916
+ ActionStatus.Rejected
1917
+ ]),
1918
+ // If the action is an asynchronous confirmation for another action, we will save the original action id here.
1919
+ originalActionId: import_zod21.z.string().optional()
1510
1920
  });
1511
1921
  var AssignedAction = ActionBase.merge(
1512
- import_zod18.z.object({
1513
- type: import_zod18.z.literal(ActionType.ASSIGN),
1514
- assignedTo: import_zod18.z.string()
1922
+ import_zod21.z.object({
1923
+ type: import_zod21.z.literal(ActionType.ASSIGN),
1924
+ assignedTo: import_zod21.z.string()
1515
1925
  })
1516
1926
  );
1517
1927
  var UnassignedAction = ActionBase.merge(
1518
- import_zod18.z.object({
1519
- type: import_zod18.z.literal(ActionType.UNASSIGN)
1928
+ import_zod21.z.object({
1929
+ type: import_zod21.z.literal(ActionType.UNASSIGN),
1930
+ assignedTo: import_zod21.z.literal(null).default(null)
1520
1931
  })
1521
1932
  );
1522
1933
  var RegisterAction = ActionBase.merge(
1523
- import_zod18.z.object({
1524
- type: import_zod18.z.literal(ActionType.REGISTER),
1525
- identifiers: import_zod18.z.object({
1526
- trackingId: import_zod18.z.string(),
1527
- registrationNumber: import_zod18.z.string()
1528
- })
1934
+ import_zod21.z.object({
1935
+ type: import_zod21.z.literal(ActionType.REGISTER),
1936
+ registrationNumber: import_zod21.z.string().optional()
1529
1937
  })
1530
1938
  );
1531
1939
  var DeclareAction = ActionBase.merge(
1532
- import_zod18.z.object({
1533
- type: import_zod18.z.literal(ActionType.DECLARE)
1940
+ import_zod21.z.object({
1941
+ type: import_zod21.z.literal(ActionType.DECLARE)
1534
1942
  })
1535
1943
  );
1536
1944
  var ValidateAction = ActionBase.merge(
1537
- import_zod18.z.object({
1538
- type: import_zod18.z.literal(ActionType.VALIDATE)
1945
+ import_zod21.z.object({
1946
+ type: import_zod21.z.literal(ActionType.VALIDATE)
1539
1947
  })
1540
1948
  );
1541
1949
  var RejectAction = ActionBase.merge(
1542
- import_zod18.z.object({
1543
- type: import_zod18.z.literal(ActionType.REJECT)
1950
+ import_zod21.z.object({
1951
+ type: import_zod21.z.literal(ActionType.REJECT)
1544
1952
  })
1545
1953
  );
1546
1954
  var MarkAsDuplicateAction = ActionBase.merge(
1547
- import_zod18.z.object({
1548
- type: import_zod18.z.literal(ActionType.MARKED_AS_DUPLICATE)
1955
+ import_zod21.z.object({
1956
+ type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE)
1549
1957
  })
1550
1958
  );
1551
- var ArchivedAction = ActionBase.merge(
1552
- import_zod18.z.object({
1553
- type: import_zod18.z.literal(ActionType.ARCHIVED)
1959
+ var ArchiveAction = ActionBase.merge(
1960
+ import_zod21.z.object({
1961
+ type: import_zod21.z.literal(ActionType.ARCHIVE)
1554
1962
  })
1555
1963
  );
1556
1964
  var CreatedAction = ActionBase.merge(
1557
- import_zod18.z.object({
1558
- type: import_zod18.z.literal(ActionType.CREATE)
1965
+ import_zod21.z.object({
1966
+ type: import_zod21.z.literal(ActionType.CREATE)
1559
1967
  })
1560
1968
  );
1561
1969
  var NotifiedAction = ActionBase.merge(
1562
- import_zod18.z.object({
1563
- type: import_zod18.z.literal(ActionType.NOTIFY)
1970
+ import_zod21.z.object({
1971
+ type: import_zod21.z.literal(ActionType.NOTIFY)
1564
1972
  })
1565
1973
  );
1566
1974
  var PrintCertificateAction = ActionBase.merge(
1567
- import_zod18.z.object({
1568
- type: import_zod18.z.literal(ActionType.PRINT_CERTIFICATE)
1975
+ import_zod21.z.object({
1976
+ type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE)
1569
1977
  })
1570
1978
  );
1571
1979
  var RequestedCorrectionAction = ActionBase.merge(
1572
- import_zod18.z.object({
1573
- type: import_zod18.z.literal(ActionType.REQUEST_CORRECTION)
1980
+ import_zod21.z.object({
1981
+ type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION)
1574
1982
  })
1575
1983
  );
1576
1984
  var ApprovedCorrectionAction = ActionBase.merge(
1577
- import_zod18.z.object({
1578
- type: import_zod18.z.literal(ActionType.APPROVE_CORRECTION),
1579
- requestId: import_zod18.z.string()
1985
+ import_zod21.z.object({
1986
+ type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION),
1987
+ requestId: import_zod21.z.string()
1580
1988
  })
1581
1989
  );
1582
1990
  var RejectedCorrectionAction = ActionBase.merge(
1583
- import_zod18.z.object({
1584
- type: import_zod18.z.literal(ActionType.REJECT_CORRECTION),
1585
- requestId: import_zod18.z.string()
1991
+ import_zod21.z.object({
1992
+ type: import_zod21.z.literal(ActionType.REJECT_CORRECTION),
1993
+ requestId: import_zod21.z.string()
1586
1994
  })
1587
1995
  );
1588
- var CustomAction = ActionBase.merge(
1589
- import_zod18.z.object({
1590
- type: import_zod18.z.literal(ActionType.CUSTOM)
1996
+ var ReadAction = ActionBase.merge(
1997
+ import_zod21.z.object({
1998
+ type: import_zod21.z.literal(ActionType.READ)
1591
1999
  })
1592
2000
  );
1593
- var ActionDocument = import_zod18.z.discriminatedUnion("type", [
2001
+ var ActionDocument = import_zod21.z.discriminatedUnion("type", [
1594
2002
  CreatedAction,
1595
2003
  ValidateAction,
1596
2004
  RejectAction,
1597
2005
  MarkAsDuplicateAction,
1598
- ArchivedAction,
2006
+ ArchiveAction,
1599
2007
  NotifiedAction,
1600
2008
  RegisterAction,
1601
2009
  DeclareAction,
@@ -1605,110 +2013,125 @@ var ActionDocument = import_zod18.z.discriminatedUnion("type", [
1605
2013
  RejectedCorrectionAction,
1606
2014
  UnassignedAction,
1607
2015
  PrintCertificateAction,
1608
- CustomAction
2016
+ ReadAction
1609
2017
  ]);
1610
- var ResolvedUser = import_zod18.z.object({
1611
- id: import_zod18.z.string(),
1612
- role: import_zod18.z.string(),
1613
- name: import_zod18.z.array(
1614
- import_zod18.z.object({
1615
- use: import_zod18.z.string(),
1616
- given: import_zod18.z.array(import_zod18.z.string()),
1617
- family: import_zod18.z.string()
2018
+ var AsyncRejectActionDocument = ActionBase.omit({
2019
+ declaration: true,
2020
+ annotation: true,
2021
+ createdBy: true,
2022
+ createdAtLocation: true
2023
+ }).merge(
2024
+ import_zod21.z.object({
2025
+ type: import_zod21.z.enum(ConfirmableActions),
2026
+ status: import_zod21.z.literal(ActionStatus.Rejected)
2027
+ })
2028
+ );
2029
+ var Action = import_zod21.z.union([ActionDocument, AsyncRejectActionDocument]);
2030
+ var ResolvedUser = import_zod21.z.object({
2031
+ id: import_zod21.z.string(),
2032
+ role: import_zod21.z.string(),
2033
+ name: import_zod21.z.array(
2034
+ import_zod21.z.object({
2035
+ use: import_zod21.z.string(),
2036
+ given: import_zod21.z.array(import_zod21.z.string()),
2037
+ family: import_zod21.z.string()
1618
2038
  })
1619
2039
  )
1620
2040
  });
1621
2041
 
1622
2042
  // ../commons/src/events/ActionInput.ts
1623
- var import_zod19 = require("zod");
1624
- var BaseActionInput = import_zod19.z.object({
1625
- eventId: import_zod19.z.string(),
1626
- transactionId: import_zod19.z.string(),
1627
- incomplete: import_zod19.z.boolean().optional().default(false).describe("Allows action with partial data to be saved"),
1628
- data: import_zod19.z.record(import_zod19.z.string(), FieldValue),
1629
- metadata: import_zod19.z.record(import_zod19.z.string(), FieldValue).optional()
2043
+ var import_zod22 = require("zod");
2044
+ var BaseActionInput = import_zod22.z.object({
2045
+ eventId: import_zod22.z.string(),
2046
+ transactionId: import_zod22.z.string(),
2047
+ declaration: ActionUpdate.default({}),
2048
+ annotation: ActionUpdate.optional(),
2049
+ originalActionId: import_zod22.z.string().optional(),
2050
+ keepAssignment: import_zod22.z.boolean().optional()
1630
2051
  });
1631
2052
  var CreateActionInput = BaseActionInput.merge(
1632
- import_zod19.z.object({
1633
- type: import_zod19.z.literal(ActionType.CREATE).default(ActionType.CREATE),
1634
- createdAtLocation: import_zod19.z.string()
2053
+ import_zod22.z.object({
2054
+ type: import_zod22.z.literal(ActionType.CREATE).default(ActionType.CREATE),
2055
+ createdAtLocation: import_zod22.z.string()
1635
2056
  })
1636
2057
  );
1637
2058
  var RegisterActionInput = BaseActionInput.merge(
1638
- import_zod19.z.object({
1639
- type: import_zod19.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
1640
- identifiers: import_zod19.z.object({
1641
- trackingId: import_zod19.z.string(),
1642
- registrationNumber: import_zod19.z.string()
1643
- })
2059
+ import_zod22.z.object({
2060
+ type: import_zod22.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
2061
+ registrationNumber: import_zod22.z.string().optional()
1644
2062
  })
1645
2063
  );
1646
2064
  var ValidateActionInput = BaseActionInput.merge(
1647
- import_zod19.z.object({
1648
- type: import_zod19.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
1649
- duplicates: import_zod19.z.array(import_zod19.z.string())
2065
+ import_zod22.z.object({
2066
+ type: import_zod22.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
2067
+ duplicates: import_zod22.z.array(import_zod22.z.string())
1650
2068
  })
1651
2069
  );
1652
2070
  var NotifyActionInput = BaseActionInput.merge(
1653
- import_zod19.z.object({
1654
- type: import_zod19.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
1655
- createdAtLocation: import_zod19.z.string()
2071
+ import_zod22.z.object({
2072
+ type: import_zod22.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
1656
2073
  })
1657
2074
  );
1658
2075
  var DeclareActionInput = BaseActionInput.merge(
1659
- import_zod19.z.object({
1660
- type: import_zod19.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
2076
+ import_zod22.z.object({
2077
+ type: import_zod22.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
1661
2078
  })
1662
2079
  );
1663
2080
  var PrintCertificateActionInput = BaseActionInput.merge(
1664
- import_zod19.z.object({
1665
- type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
2081
+ import_zod22.z.object({
2082
+ type: import_zod22.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
1666
2083
  })
1667
2084
  );
1668
2085
  var RejectDeclarationActionInput = BaseActionInput.merge(
1669
- import_zod19.z.object({
1670
- type: import_zod19.z.literal(ActionType.REJECT).default(ActionType.REJECT)
2086
+ import_zod22.z.object({
2087
+ type: import_zod22.z.literal(ActionType.REJECT).default(ActionType.REJECT)
1671
2088
  })
1672
2089
  );
1673
2090
  var MarkedAsDuplicateActionInput = BaseActionInput.merge(
1674
- import_zod19.z.object({
1675
- type: import_zod19.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
2091
+ import_zod22.z.object({
2092
+ type: import_zod22.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
1676
2093
  })
1677
2094
  );
1678
- var ArchivedActionInput = BaseActionInput.merge(
1679
- import_zod19.z.object({
1680
- type: import_zod19.z.literal(ActionType.ARCHIVED).default(ActionType.ARCHIVED)
2095
+ var ArchiveActionInput = BaseActionInput.merge(
2096
+ import_zod22.z.object({
2097
+ type: import_zod22.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
1681
2098
  })
1682
2099
  );
1683
2100
  var AssignActionInput = BaseActionInput.merge(
1684
- import_zod19.z.object({
1685
- type: import_zod19.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
1686
- assignedTo: import_zod19.z.string()
2101
+ import_zod22.z.object({
2102
+ type: import_zod22.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
2103
+ assignedTo: import_zod22.z.string()
1687
2104
  })
1688
2105
  );
1689
2106
  var UnassignActionInput = BaseActionInput.merge(
1690
- import_zod19.z.object({
1691
- type: import_zod19.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN)
2107
+ import_zod22.z.object({
2108
+ type: import_zod22.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
2109
+ assignedTo: import_zod22.z.literal(null).default(null)
1692
2110
  })
1693
2111
  );
1694
2112
  var RequestCorrectionActionInput = BaseActionInput.merge(
1695
- import_zod19.z.object({
1696
- type: import_zod19.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
2113
+ import_zod22.z.object({
2114
+ type: import_zod22.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
1697
2115
  })
1698
2116
  );
1699
2117
  var RejectCorrectionActionInput = BaseActionInput.merge(
1700
- import_zod19.z.object({
1701
- requestId: import_zod19.z.string(),
1702
- type: import_zod19.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
2118
+ import_zod22.z.object({
2119
+ requestId: import_zod22.z.string(),
2120
+ type: import_zod22.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
1703
2121
  })
1704
2122
  );
1705
2123
  var ApproveCorrectionActionInput = BaseActionInput.merge(
1706
- import_zod19.z.object({
1707
- requestId: import_zod19.z.string(),
1708
- type: import_zod19.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
2124
+ import_zod22.z.object({
2125
+ requestId: import_zod22.z.string(),
2126
+ type: import_zod22.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
1709
2127
  })
1710
2128
  );
1711
- var ActionInput = import_zod19.z.discriminatedUnion("type", [
2129
+ var ReadActionInput = BaseActionInput.merge(
2130
+ import_zod22.z.object({
2131
+ type: import_zod22.z.literal(ActionType.READ).default(ActionType.READ)
2132
+ })
2133
+ );
2134
+ var ActionInput = import_zod22.z.discriminatedUnion("type", [
1712
2135
  CreateActionInput,
1713
2136
  ValidateActionInput,
1714
2137
  RegisterActionInput,
@@ -1716,61 +2139,68 @@ var ActionInput = import_zod19.z.discriminatedUnion("type", [
1716
2139
  DeclareActionInput,
1717
2140
  RejectDeclarationActionInput,
1718
2141
  MarkedAsDuplicateActionInput,
1719
- ArchivedActionInput,
2142
+ ArchiveActionInput,
1720
2143
  AssignActionInput,
1721
2144
  UnassignActionInput,
1722
2145
  PrintCertificateActionInput,
1723
2146
  RequestCorrectionActionInput,
1724
2147
  RejectCorrectionActionInput,
1725
- ApproveCorrectionActionInput
2148
+ ApproveCorrectionActionInput,
2149
+ ReadActionInput
1726
2150
  ]);
1727
2151
 
1728
2152
  // ../commons/src/events/Draft.ts
1729
- var Draft = import_zod20.z.object({
1730
- id: import_zod20.z.string(),
1731
- eventId: import_zod20.z.string(),
1732
- transactionId: import_zod20.z.string(),
1733
- createdAt: import_zod20.z.string().datetime(),
2153
+ var Draft = import_zod23.z.object({
2154
+ id: import_zod23.z.string(),
2155
+ eventId: import_zod23.z.string(),
2156
+ transactionId: import_zod23.z.string(),
2157
+ createdAt: import_zod23.z.string().datetime(),
1734
2158
  action: ActionBase.extend({
1735
- type: import_zod20.z.enum(Object.values(ActionType))
2159
+ type: ActionTypes
1736
2160
  }).omit({ id: true })
1737
2161
  });
1738
2162
  var DraftInput = BaseActionInput.extend({
1739
- type: import_zod20.z.enum(Object.values(ActionType))
2163
+ type: ActionTypes
1740
2164
  });
1741
2165
 
1742
2166
  // ../commons/src/events/EventInput.ts
1743
- var import_zod21 = require("zod");
1744
- var EventInput = import_zod21.z.object({
1745
- transactionId: import_zod21.z.string(),
1746
- type: import_zod21.z.string()
2167
+ var import_zod24 = require("zod");
2168
+ var EventInput = import_zod24.z.object({
2169
+ transactionId: import_zod24.z.string(),
2170
+ type: import_zod24.z.string()
1747
2171
  });
1748
2172
 
1749
2173
  // ../commons/src/events/EventDocument.ts
1750
- var import_zod22 = require("zod");
1751
- var EventDocument = import_zod22.z.object({
1752
- id: import_zod22.z.string(),
1753
- type: import_zod22.z.string(),
1754
- createdAt: import_zod22.z.string().datetime(),
1755
- updatedAt: import_zod22.z.string().datetime(),
1756
- actions: import_zod22.z.array(ActionDocument),
1757
- trackingId: import_zod22.z.string()
2174
+ var import_zod25 = require("zod");
2175
+ var EventDocument = import_zod25.z.object({
2176
+ id: import_zod25.z.string(),
2177
+ type: import_zod25.z.string(),
2178
+ createdAt: import_zod25.z.string().datetime(),
2179
+ updatedAt: import_zod25.z.string().datetime(),
2180
+ actions: import_zod25.z.array(Action),
2181
+ trackingId: import_zod25.z.string()
1758
2182
  });
1759
2183
 
1760
2184
  // ../commons/src/events/EventIndex.ts
1761
- var import_zod23 = require("zod");
2185
+ var import_zod26 = require("zod");
1762
2186
  var EventIndex = EventMetadata.extend({
1763
- data: import_zod23.z.record(import_zod23.z.string(), import_zod23.z.any())
2187
+ declaration: import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any())
1764
2188
  });
1765
- var EventSearchIndex = import_zod23.z.record(import_zod23.z.string(), import_zod23.z.any()).and(
1766
- import_zod23.z.object({
1767
- type: import_zod23.z.string()
2189
+ var EventSearchIndex = import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any()).and(
2190
+ import_zod26.z.object({
2191
+ type: import_zod26.z.string()
1768
2192
  // Ensures "type" (event-id) exists and is a string
1769
2193
  })
1770
2194
  );
1771
2195
 
1772
2196
  // ../commons/src/events/state/index.ts
1773
2197
  function getStatusFromActions(actions) {
2198
+ const hasRejectedAction = actions.some(
2199
+ (a) => a.status === ActionStatus.Rejected
2200
+ );
2201
+ if (hasRejectedAction) {
2202
+ return EventStatus.REJECTED;
2203
+ }
1774
2204
  return actions.reduce((status, action) => {
1775
2205
  if (action.type === ActionType.CREATE) {
1776
2206
  return EventStatus.CREATED;
@@ -1787,9 +2217,12 @@ function getStatusFromActions(actions) {
1787
2217
  if (action.type === ActionType.REJECT) {
1788
2218
  return EventStatus.REJECTED;
1789
2219
  }
1790
- if (action.type === ActionType.ARCHIVED) {
2220
+ if (action.type === ActionType.ARCHIVE) {
1791
2221
  return EventStatus.ARCHIVED;
1792
2222
  }
2223
+ if (action.type === ActionType.NOTIFY) {
2224
+ return EventStatus.NOTIFIED;
2225
+ }
1793
2226
  return status;
1794
2227
  }, EventStatus.CREATED);
1795
2228
  }
@@ -1804,7 +2237,7 @@ function getAssignedUserFromActions(actions) {
1804
2237
  return user2;
1805
2238
  }, null);
1806
2239
  }
1807
- function getData(actions) {
2240
+ function aggregateActionDeclarations(actions) {
1808
2241
  const excludedActions = [
1809
2242
  ActionType.REQUEST_CORRECTION,
1810
2243
  ActionType.PRINT_CERTIFICATE
@@ -1818,19 +2251,34 @@ function getData(actions) {
1818
2251
  if (!requestAction) {
1819
2252
  return status;
1820
2253
  }
1821
- return {
1822
- ...status,
1823
- ...requestAction.data
1824
- };
2254
+ return deepMerge(status, requestAction.declaration);
1825
2255
  }
1826
- return {
1827
- ...status,
1828
- ...action.data
1829
- };
2256
+ return deepMerge(status, action.declaration);
1830
2257
  }, {});
1831
2258
  }
1832
- function isUndeclaredDraft(event2) {
1833
- return event2.actions.every(({ type }) => type === ActionType.CREATE);
2259
+ function deepDropNulls(obj) {
2260
+ if (Array.isArray(obj)) {
2261
+ return obj.map(deepDropNulls);
2262
+ }
2263
+ if (obj !== null && typeof obj === "object") {
2264
+ return Object.entries(obj).reduce((acc, [key, value]) => {
2265
+ const cleanedValue = deepDropNulls(value);
2266
+ if (cleanedValue !== null) {
2267
+ ;
2268
+ acc[key] = cleanedValue;
2269
+ }
2270
+ return acc;
2271
+ }, {});
2272
+ }
2273
+ return obj;
2274
+ }
2275
+ function isUndeclaredDraft(status) {
2276
+ return status === EventStatus.CREATED;
2277
+ }
2278
+ function getAcceptedActions(event2) {
2279
+ return event2.actions.filter(
2280
+ (a) => a.status === ActionStatus.Accepted
2281
+ );
1834
2282
  }
1835
2283
  function getCurrentEventState(event2) {
1836
2284
  const creationAction = event2.actions.find(
@@ -1839,8 +2287,13 @@ function getCurrentEventState(event2) {
1839
2287
  if (!creationAction) {
1840
2288
  throw new Error(`Event ${event2.id} has no creation action`);
1841
2289
  }
1842
- const latestAction = event2.actions[event2.actions.length - 1];
1843
- return {
2290
+ const activeActions = getAcceptedActions(event2);
2291
+ const latestAction = activeActions[activeActions.length - 1];
2292
+ const registrationAction = activeActions.find(
2293
+ (a) => a.type === ActionType.REGISTER && a.status === ActionStatus.Accepted
2294
+ );
2295
+ const registrationNumber = registrationAction?.registrationNumber ?? null;
2296
+ return deepDropNulls({
1844
2297
  id: event2.id,
1845
2298
  type: event2.type,
1846
2299
  status: getStatusFromActions(event2.actions),
@@ -1848,18 +2301,16 @@ function getCurrentEventState(event2) {
1848
2301
  createdBy: creationAction.createdBy,
1849
2302
  createdAtLocation: creationAction.createdAtLocation,
1850
2303
  modifiedAt: latestAction.createdAt,
1851
- assignedTo: getAssignedUserFromActions(event2.actions),
2304
+ assignedTo: getAssignedUserFromActions(activeActions),
1852
2305
  updatedBy: latestAction.createdBy,
1853
- data: getData(event2.actions),
1854
- trackingId: event2.trackingId
1855
- };
2306
+ declaration: aggregateActionDeclarations(activeActions),
2307
+ trackingId: event2.trackingId,
2308
+ registrationNumber
2309
+ });
1856
2310
  }
1857
2311
  function getCurrentEventStateWithDrafts(event2, drafts) {
1858
- const actions = event2.actions.slice().sort();
1859
- const lastAction = actions[actions.length - 1];
1860
- const activeDrafts = drafts.filter(({ eventId }) => eventId === event2.id).filter(
1861
- ({ createdAt }) => new Date(createdAt) > new Date(lastAction.createdAt)
1862
- ).map((draft) => draft.action).flatMap((action) => {
2312
+ const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
2313
+ const activeDrafts = findActiveDrafts(event2, drafts).map((draft) => draft.action).flatMap((action) => {
1863
2314
  if (action.type === ActionType.REQUEST_CORRECTION) {
1864
2315
  return [
1865
2316
  action,
@@ -1886,45 +2337,46 @@ function applyDraftsToEventIndex(eventIndex, drafts) {
1886
2337
  }
1887
2338
  return {
1888
2339
  ...eventIndex,
1889
- data: {
1890
- ...eventIndex.data,
1891
- ...activeDrafts[activeDrafts.length - 1].data
2340
+ declaration: {
2341
+ ...eventIndex.declaration,
2342
+ ...activeDrafts[activeDrafts.length - 1].declaration
1892
2343
  }
1893
2344
  };
1894
2345
  }
1895
- function getMetadataForAction(event2, actionType, draftsForEvent) {
1896
- const action = event2.actions.find((action2) => actionType === action2.type);
1897
- const drafts = draftsForEvent.filter((draft) => draft.eventId === event2.id);
2346
+ function getAnnotationFromDrafts(drafts) {
2347
+ const actions = drafts.map((draft) => draft.action);
2348
+ const annotation = actions.reduce((ann, action) => {
2349
+ return deepMerge(ann, action.annotation ?? {});
2350
+ }, {});
2351
+ return deepDropNulls(annotation);
2352
+ }
2353
+ function getActionAnnotation({
2354
+ event: event2,
2355
+ actionType,
2356
+ drafts
2357
+ }) {
2358
+ const activeActions = getAcceptedActions(event2);
2359
+ const action = activeActions.find(
2360
+ (activeAction) => actionType === activeAction.type
2361
+ );
2362
+ const eventDrafts = drafts.filter((draft) => draft.eventId === event2.id);
1898
2363
  const sorted = [
1899
2364
  ...action ? [action] : [],
1900
- ...drafts.map((draft) => draft.action)
2365
+ ...eventDrafts.map((draft) => draft.action)
1901
2366
  ].sort();
1902
- const metadata = sorted.reduce((metadata2, action2) => {
1903
- return {
1904
- ...metadata2,
1905
- ...action2.metadata
1906
- };
2367
+ const annotation = sorted.reduce((ann, sortedAction) => {
2368
+ return deepMerge(ann, sortedAction.annotation ?? {});
1907
2369
  }, {});
1908
- return metadata;
2370
+ return deepDropNulls(annotation);
1909
2371
  }
1910
2372
 
1911
2373
  // ../commons/src/events/defineConfig.ts
1912
2374
  var defineConfig = (config) => {
1913
2375
  validateWorkqueueConfig(config.workqueues);
1914
2376
  const input = EventConfig.parse(config);
1915
- const pageFields = findInputPageFields(input);
1916
- return EventConfig.parse({
1917
- ...input,
1918
- pageFields
1919
- });
2377
+ return input;
1920
2378
  };
1921
2379
 
1922
- // ../commons/src/uuid.ts
1923
- var import_uuid = require("uuid");
1924
- function getUUID() {
1925
- return (0, import_uuid.v4)();
1926
- }
1927
-
1928
2380
  // ../commons/src/events/transactions.ts
1929
2381
  function generateTransactionId() {
1930
2382
  return getUUID();
@@ -1937,6 +2389,16 @@ var import_lodash2 = require("lodash");
1937
2389
  function defineConditional(schema) {
1938
2390
  return schema;
1939
2391
  }
2392
+ function defineFormConditional(schema) {
2393
+ const schemaWithForm = {
2394
+ type: "object",
2395
+ properties: {
2396
+ $form: schema
2397
+ },
2398
+ required: ["$form"]
2399
+ };
2400
+ return defineConditional(schemaWithForm);
2401
+ }
1940
2402
  function alwaysTrue() {
1941
2403
  return {};
1942
2404
  }
@@ -1961,6 +2423,9 @@ function not(condition) {
1961
2423
  required: []
1962
2424
  });
1963
2425
  }
2426
+ function never() {
2427
+ return not(alwaysTrue());
2428
+ }
1964
2429
  var user = {
1965
2430
  hasScope: (scope) => defineConditional({
1966
2431
  type: "object",
@@ -2008,69 +2473,120 @@ var event = {
2008
2473
  required: ["$event"]
2009
2474
  })
2010
2475
  };
2476
+ function getDateFromNow(days) {
2477
+ return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
2478
+ }
2479
+ function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
2480
+ return {
2481
+ type: "object",
2482
+ properties: {
2483
+ [fieldId]: {
2484
+ type: "string",
2485
+ format: "date",
2486
+ [clause]: { $data: `1/${comparedFieldId}` }
2487
+ },
2488
+ [comparedFieldId]: { type: "string", format: "date" }
2489
+ },
2490
+ required: [fieldId]
2491
+ };
2492
+ }
2493
+ function isFieldReference(value) {
2494
+ return typeof value === "object" && value !== null && "_fieldId" in value;
2495
+ }
2011
2496
  function field(fieldId) {
2012
- const getDateFromNow = (days) => new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
2013
2497
  const getDateRange = (date, clause) => ({
2014
2498
  type: "object",
2015
2499
  properties: {
2016
- $form: {
2017
- type: "object",
2018
- properties: {
2019
- [fieldId]: {
2020
- type: "string",
2021
- format: "date",
2022
- [clause]: date
2023
- }
2024
- },
2025
- required: [fieldId]
2500
+ [fieldId]: {
2501
+ type: "string",
2502
+ format: "date",
2503
+ [clause]: date
2026
2504
  }
2027
2505
  },
2028
- required: ["$form"]
2506
+ required: [fieldId]
2029
2507
  });
2030
2508
  return {
2509
+ /**
2510
+ * @private Internal property used for field reference tracking.
2511
+ */
2512
+ _fieldId: fieldId,
2031
2513
  isAfter: () => ({
2032
2514
  days: (days) => ({
2033
- inPast: () => defineConditional(
2515
+ inPast: () => defineFormConditional(
2034
2516
  getDateRange(getDateFromNow(days), "formatMinimum")
2035
2517
  ),
2036
- inFuture: () => defineConditional(
2518
+ inFuture: () => defineFormConditional(
2037
2519
  getDateRange(getDateFromNow(-days), "formatMinimum")
2038
2520
  )
2039
2521
  }),
2040
- date: (date) => defineConditional(getDateRange(date, "formatMinimum")),
2041
- now: () => defineConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
2522
+ date: (date) => {
2523
+ if (isFieldReference(date)) {
2524
+ const comparedFieldId = date._fieldId;
2525
+ return defineFormConditional(
2526
+ getDateRangeToFieldReference(
2527
+ fieldId,
2528
+ comparedFieldId,
2529
+ "formatMinimum"
2530
+ )
2531
+ );
2532
+ }
2533
+ return defineFormConditional(getDateRange(date, "formatMinimum"));
2534
+ },
2535
+ now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
2042
2536
  }),
2043
2537
  isBefore: () => ({
2044
2538
  days: (days) => ({
2045
- inPast: () => defineConditional(
2539
+ inPast: () => defineFormConditional(
2046
2540
  getDateRange(getDateFromNow(days), "formatMaximum")
2047
2541
  ),
2048
- inFuture: () => defineConditional(
2542
+ inFuture: () => defineFormConditional(
2049
2543
  getDateRange(getDateFromNow(-days), "formatMaximum")
2050
2544
  )
2051
2545
  }),
2052
- date: (date) => defineConditional(getDateRange(date, "formatMaximum")),
2053
- now: () => defineConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
2546
+ date: (date) => {
2547
+ if (isFieldReference(date)) {
2548
+ const comparedFieldId = date._fieldId;
2549
+ return defineFormConditional(
2550
+ getDateRangeToFieldReference(
2551
+ fieldId,
2552
+ comparedFieldId,
2553
+ "formatMaximum"
2554
+ )
2555
+ );
2556
+ }
2557
+ return defineFormConditional(getDateRange(date, "formatMaximum"));
2558
+ },
2559
+ now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
2054
2560
  }),
2055
- isEqualTo: (value) => defineConditional({
2056
- type: "object",
2057
- properties: {
2058
- $form: {
2561
+ isEqualTo: (value) => {
2562
+ if (isFieldReference(value)) {
2563
+ const comparedFieldId = value._fieldId;
2564
+ return defineFormConditional({
2059
2565
  type: "object",
2060
2566
  properties: {
2061
2567
  [fieldId]: {
2062
- oneOf: [
2063
- { type: "string", const: value },
2064
- { type: "boolean", const: value }
2065
- ],
2066
- const: value
2067
- }
2568
+ type: ["string", "boolean"],
2569
+ const: { $data: `1/${comparedFieldId}` }
2570
+ },
2571
+ [comparedFieldId]: { type: ["string", "boolean"] }
2068
2572
  },
2069
- required: [fieldId]
2070
- }
2071
- },
2072
- required: ["$form"]
2073
- }),
2573
+ required: [fieldId, comparedFieldId]
2574
+ });
2575
+ }
2576
+ return defineFormConditional({
2577
+ type: "object",
2578
+ properties: {
2579
+ [fieldId]: {
2580
+ oneOf: [
2581
+ { type: "string", const: value },
2582
+ { type: "boolean", const: value }
2583
+ ],
2584
+ const: value
2585
+ }
2586
+ },
2587
+ required: [fieldId]
2588
+ });
2589
+ },
2074
2590
  /**
2075
2591
  * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
2076
2592
  * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
@@ -2079,91 +2595,102 @@ function field(fieldId) {
2079
2595
  * NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
2080
2596
  *
2081
2597
  */
2082
- isFalsy: () => defineConditional({
2598
+ isFalsy: () => defineFormConditional({
2083
2599
  type: "object",
2084
2600
  properties: {
2085
- $form: {
2086
- type: "object",
2087
- properties: {
2088
- [fieldId]: {
2089
- anyOf: [
2090
- { const: "undefined" },
2091
- { const: false },
2092
- { const: null },
2093
- { const: "" }
2094
- ]
2095
- }
2096
- },
2601
+ [fieldId]: {
2097
2602
  anyOf: [
2098
- {
2099
- required: [fieldId]
2100
- },
2101
- {
2102
- not: {
2103
- required: [fieldId]
2104
- }
2105
- }
2603
+ { const: "undefined" },
2604
+ { const: false },
2605
+ { const: null },
2606
+ { const: "" }
2106
2607
  ]
2107
2608
  }
2108
2609
  },
2109
- required: ["$form"]
2110
- }),
2111
- isUndefined: () => defineConditional({
2112
- type: "object",
2113
- properties: {
2114
- $form: {
2115
- type: "object",
2116
- properties: {
2117
- [fieldId]: {
2118
- type: "string",
2119
- enum: ["undefined"]
2120
- }
2121
- },
2610
+ anyOf: [
2611
+ {
2612
+ required: [fieldId]
2613
+ },
2614
+ {
2122
2615
  not: {
2123
2616
  required: [fieldId]
2124
2617
  }
2125
2618
  }
2619
+ ]
2620
+ }),
2621
+ isUndefined: () => defineFormConditional({
2622
+ type: "object",
2623
+ properties: {
2624
+ [fieldId]: {
2625
+ type: "string",
2626
+ enum: ["undefined"]
2627
+ }
2126
2628
  },
2127
- required: ["$form"]
2629
+ not: {
2630
+ required: [fieldId]
2631
+ }
2128
2632
  }),
2129
- inArray: (values) => defineConditional({
2633
+ inArray: (values) => defineFormConditional({
2130
2634
  type: "object",
2131
2635
  properties: {
2132
- $form: {
2133
- type: "object",
2134
- properties: {
2135
- [fieldId]: {
2136
- type: "string",
2137
- enum: values
2138
- }
2139
- },
2140
- required: [fieldId]
2636
+ [fieldId]: {
2637
+ type: "string",
2638
+ enum: values
2639
+ }
2640
+ },
2641
+ required: [fieldId]
2642
+ }),
2643
+ isValidEnglishName: () => defineFormConditional({
2644
+ type: "object",
2645
+ properties: {
2646
+ [fieldId]: {
2647
+ type: "string",
2648
+ pattern: "^[\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*( [\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*)*$",
2649
+ description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
2650
+ }
2651
+ },
2652
+ required: [fieldId]
2653
+ }),
2654
+ /**
2655
+ * Checks if the field value matches a given regular expression pattern.
2656
+ * @param pattern - The regular expression pattern to match the field value against.
2657
+ * @returns A JSONSchema conditional that validates the field value against the pattern.
2658
+ */
2659
+ matches: (pattern) => defineFormConditional({
2660
+ type: "object",
2661
+ properties: {
2662
+ [fieldId]: {
2663
+ type: "string",
2664
+ pattern
2665
+ }
2666
+ },
2667
+ required: [fieldId]
2668
+ }),
2669
+ isBetween: (min, max) => defineFormConditional({
2670
+ type: "object",
2671
+ properties: {
2672
+ [fieldId]: {
2673
+ type: "number",
2674
+ minimum: min,
2675
+ maximum: max
2141
2676
  }
2142
2677
  },
2143
- required: ["$form"]
2678
+ required: [fieldId]
2144
2679
  })
2145
2680
  };
2146
2681
  }
2147
2682
 
2148
2683
  // ../commons/src/fixtures/tennis-club-membership-event.ts
2149
- var PRINT_CERTIFICATE_FORM = defineForm({
2684
+ var PRINT_CERTIFICATE_FORM = defineActionForm({
2150
2685
  label: {
2151
2686
  id: "v2.event.tennis-club-membership.action.certificate.form.label",
2152
2687
  defaultMessage: "Tennis club membership certificate collector",
2153
2688
  description: "This is what this form is referred as in the system"
2154
2689
  },
2155
- version: {
2156
- id: "1.0.0",
2157
- label: {
2158
- id: "v2.event.tennis-club-membership.action.certificate.form.version.1",
2159
- defaultMessage: "Version 1",
2160
- description: "This is the first version of the form"
2161
- }
2162
- },
2163
- active: true,
2164
2690
  pages: [
2165
2691
  {
2166
2692
  id: "collector",
2693
+ type: PageTypes.enum.FORM,
2167
2694
  title: {
2168
2695
  id: "v2.event.tennis-club-membership.action.certificate.form.section.who.title",
2169
2696
  defaultMessage: "Print certified copy",
@@ -2178,7 +2705,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2178
2705
  defaultMessage: "Requester",
2179
2706
  description: "This is the label for the field"
2180
2707
  },
2181
- type: "SELECT",
2708
+ type: FieldType.SELECT,
2182
2709
  options: [
2183
2710
  {
2184
2711
  value: "INFORMANT",
@@ -2255,7 +2782,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2255
2782
  defaultMessage: "Select Type of ID",
2256
2783
  description: "This is the label for selecting the type of ID"
2257
2784
  },
2258
- type: "SELECT",
2785
+ type: FieldType.SELECT,
2259
2786
  options: [
2260
2787
  {
2261
2788
  value: "PASSPORT",
@@ -2356,7 +2883,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2356
2883
  defaultMessage: "Passport Details",
2357
2884
  description: "Field for entering Passport details"
2358
2885
  },
2359
- type: "TEXT"
2886
+ type: FieldType.TEXT
2360
2887
  },
2361
2888
  {
2362
2889
  id: "collector.DRIVING_LICENSE.details",
@@ -2407,7 +2934,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2407
2934
  defaultMessage: "Driving License Details",
2408
2935
  description: "Field for entering Driving License details"
2409
2936
  },
2410
- type: "TEXT"
2937
+ type: FieldType.TEXT
2411
2938
  },
2412
2939
  {
2413
2940
  id: "collector.REFUGEE_NUMBER.details",
@@ -2458,7 +2985,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2458
2985
  defaultMessage: "Refugee Number Details",
2459
2986
  description: "Field for entering Refugee Number details"
2460
2987
  },
2461
- type: "TEXT"
2988
+ type: FieldType.TEXT
2462
2989
  },
2463
2990
  {
2464
2991
  id: "collector.ALIEN_NUMBER.details",
@@ -2509,7 +3036,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2509
3036
  defaultMessage: "Alien Number Details",
2510
3037
  description: "Field for entering Alien Number details"
2511
3038
  },
2512
- type: "TEXT"
3039
+ type: FieldType.TEXT
2513
3040
  },
2514
3041
  {
2515
3042
  id: "collector.OTHER.idTypeOther",
@@ -2560,7 +3087,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2560
3087
  defaultMessage: "Other ID Type (if applicable)",
2561
3088
  description: 'Field for entering ID type if "Other" is selected'
2562
3089
  },
2563
- type: "TEXT"
3090
+ type: FieldType.TEXT
2564
3091
  },
2565
3092
  {
2566
3093
  id: "collector.OTHER.firstName",
@@ -2611,7 +3138,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2611
3138
  defaultMessage: "First Name",
2612
3139
  description: "This is the label for the first name field"
2613
3140
  },
2614
- type: "TEXT"
3141
+ type: FieldType.TEXT
2615
3142
  },
2616
3143
  {
2617
3144
  id: "collector.OTHER.lastName",
@@ -2662,7 +3189,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2662
3189
  defaultMessage: "Last Name",
2663
3190
  description: "This is the label for the last name field"
2664
3191
  },
2665
- type: "TEXT"
3192
+ type: FieldType.TEXT
2666
3193
  },
2667
3194
  {
2668
3195
  id: "collector.OTHER.relationshipToMember",
@@ -2713,7 +3240,7 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2713
3240
  defaultMessage: "Relationship to Member",
2714
3241
  description: "This is the label for the relationship to member field"
2715
3242
  },
2716
- type: "TEXT"
3243
+ type: FieldType.TEXT
2717
3244
  },
2718
3245
  {
2719
3246
  id: "collector.OTHER.signedAffidavit",
@@ -2764,66 +3291,88 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2764
3291
  defaultMessage: "Signed Affidavit (Optional)",
2765
3292
  description: "This is the label for uploading a signed affidavit"
2766
3293
  },
2767
- type: "FILE"
3294
+ type: FieldType.FILE
2768
3295
  }
2769
3296
  ]
2770
- }
2771
- ],
2772
- review: {
2773
- title: {
2774
- id: "v2.event.tennis-club-membership.action.certificate.form.review.title",
2775
- defaultMessage: "Member certificate collector for {firstname} {surname}",
2776
- description: "Title of the form to show in review page"
2777
3297
  },
2778
- fields: []
2779
- }
2780
- });
2781
- var TENNIS_CLUB_FORM = defineForm({
2782
- label: {
2783
- id: "v2.event.tennis-club-membership.action.declare.form.label",
2784
- defaultMessage: "Tennis club membership application",
2785
- description: "This is what this form is referred as in the system"
2786
- },
2787
- active: true,
2788
- version: {
2789
- id: "1.0.0",
2790
- label: {
2791
- id: "v2.event.tennis-club-membership.action.declare.form.version.1",
2792
- defaultMessage: "Version 1",
2793
- description: "This is the first version of the form"
3298
+ {
3299
+ id: "collector.identity.verify",
3300
+ type: PageTypes.enum.VERIFICATION,
3301
+ conditional: field("collector.requesterId").isEqualTo("INFORMANT"),
3302
+ title: {
3303
+ id: "event.tennis-club-membership.action.print.verifyIdentity",
3304
+ defaultMessage: "Verify their identity",
3305
+ description: "This is the title of the section"
3306
+ },
3307
+ fields: [],
3308
+ actions: {
3309
+ verify: {
3310
+ label: {
3311
+ defaultMessage: "Verified",
3312
+ description: "This is the label for the verification button",
3313
+ id: "v2.event.tennis-club-membership.action.certificate.form.verify"
3314
+ }
3315
+ },
3316
+ cancel: {
3317
+ label: {
3318
+ defaultMessage: "Identity does not match",
3319
+ description: "This is the label for the verification cancellation button",
3320
+ id: "v2.event.tennis-club-membership.action.certificate.form.cancel"
3321
+ },
3322
+ confirmation: {
3323
+ title: {
3324
+ defaultMessage: "Print without proof of ID?",
3325
+ description: "This is the title for the verification cancellation modal",
3326
+ id: "v2.event.tennis-club-membership.action.certificate.form.cancel.confirmation.title"
3327
+ },
3328
+ body: {
3329
+ defaultMessage: "Please be aware that if you proceed, you will be responsible for issuing a certificate without the necessary proof of ID from the collector",
3330
+ description: "This is the body for the verification cancellation modal",
3331
+ id: "v2.event.tennis-club-membership.action.certificate.form.cancel.confirmation.body"
3332
+ }
3333
+ }
3334
+ }
3335
+ }
2794
3336
  }
3337
+ ]
3338
+ });
3339
+ var TENNIS_CLUB_DECLARATION_REVIEW = {
3340
+ title: {
3341
+ id: "v2.event.tennis-club-membership.action.declare.form.review.title",
3342
+ defaultMessage: "{applicant.firstname, select, __EMPTY__ {Member declaration} other {{applicant.surname, select, __EMPTY__ {Member declaration} other {Member declaration for {applicant.firstname} {applicant.surname}}}}}",
3343
+ description: "Title of the review page"
2795
3344
  },
2796
- review: {
2797
- title: {
2798
- id: "v2.event.tennis-club-membership.action.declare.form.review.title",
2799
- defaultMessage: "Member declaration{hasAnyKey, select, true { for {applicant.firstname} {applicant.surname}} other {}}",
2800
- description: "Title of the form to show in review page"
3345
+ fields: [
3346
+ {
3347
+ id: "review.comment",
3348
+ type: FieldType.TEXTAREA,
3349
+ label: {
3350
+ defaultMessage: "Comment",
3351
+ id: "v2.event.birth.action.declare.form.review.comment.label",
3352
+ description: "Label for the comment field in the review section"
3353
+ }
2801
3354
  },
2802
- fields: [
2803
- {
2804
- id: "review.comment",
2805
- type: "TEXTAREA",
2806
- label: {
2807
- defaultMessage: "Comment",
2808
- id: "v2.event.birth.action.declare.form.review.comment.label",
2809
- description: "Label for the comment field in the review section"
2810
- }
3355
+ {
3356
+ type: FieldType.SIGNATURE,
3357
+ id: "review.signature",
3358
+ label: {
3359
+ defaultMessage: "Signature of informant",
3360
+ id: "v2.event.birth.action.declare.form.review.signature.label",
3361
+ description: "Label for the signature field in the review section"
2811
3362
  },
2812
- {
2813
- type: "SIGNATURE",
2814
- id: "review.signature",
2815
- label: {
2816
- defaultMessage: "Signature of informant",
2817
- id: "v2.event.birth.action.declare.form.review.signature.label",
2818
- description: "Label for the signature field in the review section"
2819
- },
2820
- signaturePromptLabel: {
2821
- id: "v2.signature.upload.modal.title",
2822
- defaultMessage: "Draw signature",
2823
- description: "Title for the modal to draw signature"
2824
- }
3363
+ signaturePromptLabel: {
3364
+ id: "v2.signature.upload.modal.title",
3365
+ defaultMessage: "Draw signature",
3366
+ description: "Title for the modal to draw signature"
2825
3367
  }
2826
- ]
3368
+ }
3369
+ ]
3370
+ };
3371
+ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
3372
+ label: {
3373
+ id: "v2.event.tennis-club-membership.action.declare.form.label",
3374
+ defaultMessage: "Tennis club membership application",
3375
+ description: "This is what this form is referred as in the system"
2827
3376
  },
2828
3377
  pages: [
2829
3378
  {
@@ -2836,7 +3385,7 @@ var TENNIS_CLUB_FORM = defineForm({
2836
3385
  fields: [
2837
3386
  {
2838
3387
  id: "applicant.firstname",
2839
- type: "TEXT",
3388
+ type: FieldType.TEXT,
2840
3389
  required: true,
2841
3390
  conditionals: [],
2842
3391
  label: {
@@ -2847,7 +3396,7 @@ var TENNIS_CLUB_FORM = defineForm({
2847
3396
  },
2848
3397
  {
2849
3398
  id: "applicant.surname",
2850
- type: "TEXT",
3399
+ type: FieldType.TEXT,
2851
3400
  required: true,
2852
3401
  conditionals: [],
2853
3402
  label: {
@@ -2869,9 +3418,8 @@ var TENNIS_CLUB_FORM = defineForm({
2869
3418
  },
2870
3419
  {
2871
3420
  id: "applicant.dob",
2872
- type: "DATE",
3421
+ type: FieldType.DATE,
2873
3422
  required: true,
2874
- conditionals: [],
2875
3423
  validation: [
2876
3424
  {
2877
3425
  message: {
@@ -2882,15 +3430,53 @@ var TENNIS_CLUB_FORM = defineForm({
2882
3430
  validator: field("applicant.dob").isBefore().now()
2883
3431
  }
2884
3432
  ],
3433
+ conditionals: [
3434
+ {
3435
+ type: ConditionalType.SHOW,
3436
+ conditional: field("applicant.dobUnknown").isFalsy()
3437
+ }
3438
+ ],
2885
3439
  label: {
2886
3440
  defaultMessage: "Applicant's date of birth",
2887
3441
  description: "This is the label for the field",
2888
3442
  id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dob.label"
2889
3443
  }
2890
3444
  },
3445
+ {
3446
+ id: "applicant.dobUnknown",
3447
+ type: FieldType.CHECKBOX,
3448
+ required: false,
3449
+ label: {
3450
+ defaultMessage: "Exact date of birth unknown",
3451
+ description: "This is the label for the field",
3452
+ id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dobUnknown.label"
3453
+ },
3454
+ conditionals: [
3455
+ {
3456
+ type: ConditionalType.DISPLAY_ON_REVIEW,
3457
+ conditional: never()
3458
+ }
3459
+ ]
3460
+ },
3461
+ {
3462
+ id: "applicant.age",
3463
+ type: FieldType.NUMBER,
3464
+ required: true,
3465
+ label: {
3466
+ defaultMessage: "Age of tennis-member",
3467
+ description: "This is the label for the field",
3468
+ id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.age.label"
3469
+ },
3470
+ conditionals: [
3471
+ {
3472
+ type: ConditionalType.SHOW,
3473
+ conditional: field("applicant.dobUnknown").isEqualTo(true)
3474
+ }
3475
+ ]
3476
+ },
2891
3477
  {
2892
3478
  id: "applicant.image",
2893
- type: "FILE",
3479
+ type: FieldType.FILE,
2894
3480
  required: false,
2895
3481
  label: {
2896
3482
  defaultMessage: "Applicant's profile picture",
@@ -2911,6 +3497,27 @@ var TENNIS_CLUB_FORM = defineForm({
2911
3497
  }
2912
3498
  ]
2913
3499
  },
3500
+ {
3501
+ id: "senior-pass",
3502
+ conditional: field("applicant.dob").isBefore().date("1950-01-01"),
3503
+ title: {
3504
+ id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.title",
3505
+ defaultMessage: "Assign senior pass for applicant",
3506
+ description: "This is the title of the section"
3507
+ },
3508
+ fields: [
3509
+ {
3510
+ id: "senior-pass.id",
3511
+ type: FieldType.TEXT,
3512
+ required: true,
3513
+ label: {
3514
+ defaultMessage: "Senior pass ID",
3515
+ description: "This is the label for the field",
3516
+ id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.field.id.label"
3517
+ }
3518
+ }
3519
+ ]
3520
+ },
2914
3521
  {
2915
3522
  id: "recommender",
2916
3523
  title: {
@@ -2932,7 +3539,7 @@ var TENNIS_CLUB_FORM = defineForm({
2932
3539
  },
2933
3540
  {
2934
3541
  id: "recommender.firstname",
2935
- type: "TEXT",
3542
+ type: FieldType.TEXT,
2936
3543
  required: true,
2937
3544
  conditionals: [
2938
3545
  {
@@ -2948,7 +3555,7 @@ var TENNIS_CLUB_FORM = defineForm({
2948
3555
  },
2949
3556
  {
2950
3557
  id: "recommender.surname",
2951
- type: "TEXT",
3558
+ type: FieldType.TEXT,
2952
3559
  required: true,
2953
3560
  conditionals: [
2954
3561
  {
@@ -2964,7 +3571,7 @@ var TENNIS_CLUB_FORM = defineForm({
2964
3571
  },
2965
3572
  {
2966
3573
  id: "recommender.id",
2967
- type: "TEXT",
3574
+ type: FieldType.TEXT,
2968
3575
  required: true,
2969
3576
  conditionals: [
2970
3577
  {
@@ -3072,7 +3679,7 @@ var tennisClubMembershipEvent = defineConfig({
3072
3679
  description: "This is shown as the action name anywhere the user can trigger the action from",
3073
3680
  id: "event.tennis-club-membership.action.declare.label"
3074
3681
  },
3075
- forms: [TENNIS_CLUB_FORM]
3682
+ review: TENNIS_CLUB_DECLARATION_REVIEW
3076
3683
  },
3077
3684
  {
3078
3685
  type: ActionType.VALIDATE,
@@ -3081,7 +3688,7 @@ var tennisClubMembershipEvent = defineConfig({
3081
3688
  description: "This is shown as the action name anywhere the user can trigger the action from",
3082
3689
  id: "event.tennis-club-membership.action.validate.label"
3083
3690
  },
3084
- forms: [TENNIS_CLUB_FORM]
3691
+ review: TENNIS_CLUB_DECLARATION_REVIEW
3085
3692
  },
3086
3693
  {
3087
3694
  type: ActionType.REGISTER,
@@ -3090,7 +3697,7 @@ var tennisClubMembershipEvent = defineConfig({
3090
3697
  description: "This is shown as the action name anywhere the user can trigger the action from",
3091
3698
  id: "event.tennis-club-membership.action.register.label"
3092
3699
  },
3093
- forms: [TENNIS_CLUB_FORM]
3700
+ review: TENNIS_CLUB_DECLARATION_REVIEW
3094
3701
  },
3095
3702
  {
3096
3703
  type: ActionType.REQUEST_CORRECTION,
@@ -3099,10 +3706,10 @@ var tennisClubMembershipEvent = defineConfig({
3099
3706
  description: "This is shown as the action name anywhere the user can trigger the action from",
3100
3707
  id: "event.tennis-club-membership.action.correction.request.label"
3101
3708
  },
3102
- forms: [TENNIS_CLUB_FORM],
3103
3709
  onboardingForm: [
3104
3710
  {
3105
3711
  id: "correction-requester",
3712
+ type: PageTypes.enum.FORM,
3106
3713
  title: {
3107
3714
  id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
3108
3715
  defaultMessage: "Correction requester",
@@ -3166,6 +3773,7 @@ var tennisClubMembershipEvent = defineConfig({
3166
3773
  },
3167
3774
  {
3168
3775
  id: "identity-check",
3776
+ type: PageTypes.enum.FORM,
3169
3777
  title: {
3170
3778
  id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
3171
3779
  defaultMessage: "Verify their identity",
@@ -3208,6 +3816,7 @@ var tennisClubMembershipEvent = defineConfig({
3208
3816
  additionalDetailsForm: [
3209
3817
  {
3210
3818
  id: "correction-request.supporting-documents",
3819
+ type: PageTypes.enum.FORM,
3211
3820
  title: {
3212
3821
  id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
3213
3822
  defaultMessage: "Upload supporting documents",
@@ -3225,7 +3834,7 @@ var tennisClubMembershipEvent = defineConfig({
3225
3834
  },
3226
3835
  {
3227
3836
  id: "correction.supportingDocs",
3228
- type: "FILE",
3837
+ type: FieldType.FILE,
3229
3838
  label: {
3230
3839
  id: "correction.corrector.title",
3231
3840
  defaultMessage: "Upload supporting documents",
@@ -3269,6 +3878,7 @@ var tennisClubMembershipEvent = defineConfig({
3269
3878
  },
3270
3879
  {
3271
3880
  id: "correction-request.additional-details",
3881
+ type: PageTypes.enum.FORM,
3272
3882
  title: {
3273
3883
  id: "event.tennis-club-membership.action.requestCorrection.form.section.corrector",
3274
3884
  defaultMessage: "Reason for correction",
@@ -3277,7 +3887,7 @@ var tennisClubMembershipEvent = defineConfig({
3277
3887
  fields: [
3278
3888
  {
3279
3889
  id: "correction.request.reason",
3280
- type: "TEXT",
3890
+ type: FieldType.TEXT,
3281
3891
  label: {
3282
3892
  id: "correction.reason.title",
3283
3893
  defaultMessage: "Reason for correction?",
@@ -3290,7 +3900,6 @@ var tennisClubMembershipEvent = defineConfig({
3290
3900
  },
3291
3901
  {
3292
3902
  type: ActionType.APPROVE_CORRECTION,
3293
- forms: [TENNIS_CLUB_FORM],
3294
3903
  label: {
3295
3904
  defaultMessage: "Approve correction",
3296
3905
  description: "This is shown as the action name anywhere the user can trigger the action from",
@@ -3304,7 +3913,7 @@ var tennisClubMembershipEvent = defineConfig({
3304
3913
  defaultMessage: "Print certificate",
3305
3914
  description: "This is shown as the action name anywhere the user can trigger the action from"
3306
3915
  },
3307
- forms: [PRINT_CERTIFICATE_FORM],
3916
+ printForm: PRINT_CERTIFICATE_FORM,
3308
3917
  conditionals: [
3309
3918
  {
3310
3919
  type: "SHOW",
@@ -3344,6 +3953,22 @@ var tennisClubMembershipEvent = defineConfig({
3344
3953
  })
3345
3954
  }
3346
3955
  ]
3956
+ },
3957
+ {
3958
+ type: ActionType.ARCHIVE,
3959
+ label: {
3960
+ id: "v2.event.tennis-club-membership.action.archive.label",
3961
+ defaultMessage: "Archive",
3962
+ description: "This is shown as the action name anywhere the user can trigger the action from"
3963
+ }
3964
+ },
3965
+ {
3966
+ type: ActionType.REJECT,
3967
+ label: {
3968
+ id: "v2.event.tennis-club-membership.action.reject.label",
3969
+ defaultMessage: "Reject",
3970
+ description: "This is shown as the action name anywhere the user can trigger the action from"
3971
+ }
3347
3972
  }
3348
3973
  ],
3349
3974
  advancedSearch: [
@@ -3359,20 +3984,53 @@ var tennisClubMembershipEvent = defineConfig({
3359
3984
  }
3360
3985
  ]
3361
3986
  }
3362
- ]
3987
+ ],
3988
+ declaration: TENNIS_CLUB_DECLARATION_FORM
3363
3989
  });
3364
3990
 
3365
3991
  // ../commons/src/events/test.utils.ts
3366
- function generateActionInput(configuration, action) {
3367
- const fields = findActiveActionFormFields(configuration, action) ?? [];
3368
- const data = fields.reduce(
3992
+ function fieldConfigsToActionPayload(fields) {
3993
+ return fields.reduce(
3369
3994
  (acc, field2, i) => ({
3370
3995
  ...acc,
3371
3996
  [field2.id]: mapFieldTypeToMockValue(field2, i)
3372
3997
  }),
3373
3998
  {}
3374
3999
  );
3375
- return stripHiddenFields(fields, data);
4000
+ }
4001
+ function generateActionDeclarationInput(configuration, action) {
4002
+ const parsed = DeclarationUpdateActions.safeParse(action);
4003
+ if (parsed.success) {
4004
+ const fields = getDeclarationFields(configuration);
4005
+ const declarationConfig = getDeclaration(configuration);
4006
+ const declaration = fieldConfigsToActionPayload(fields);
4007
+ return omitHiddenPaginatedFields(declarationConfig, declaration);
4008
+ }
4009
+ console.warn(`${action} is not a declaration action. Setting data as {}.`);
4010
+ return {};
4011
+ }
4012
+ function generateActionAnnotationInput(configuration, action) {
4013
+ const actionConfig = configuration.actions.find(
4014
+ (ac) => ac.type === action
4015
+ );
4016
+ const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
4017
+ const annotation = fieldConfigsToActionPayload(annotationFields);
4018
+ const visibleVerificationPageIds = findRecordActionPages(
4019
+ configuration,
4020
+ action
4021
+ ).filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page, annotation)).map((page) => page.id);
4022
+ const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
4023
+ (acc, pageId) => ({
4024
+ ...acc,
4025
+ [pageId]: true
4026
+ }),
4027
+ {}
4028
+ );
4029
+ const fieldBasedPayload = omitHiddenFields(annotationFields, annotation);
4030
+ return {
4031
+ ...fieldBasedPayload,
4032
+ ...visiblePageVerificationMap
4033
+ };
3376
4034
  }
3377
4035
  var eventPayloadGenerator = {
3378
4036
  create: (input = {}) => ({
@@ -3384,21 +4042,22 @@ var eventPayloadGenerator = {
3384
4042
  type: input.type ?? "TENNIS_CLUB_MEMBERSHIP",
3385
4043
  id
3386
4044
  }),
3387
- draft: (eventId, input = {}) => (0, import_lodash2.merge)(
4045
+ draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
3388
4046
  {
3389
4047
  id: getUUID(),
3390
4048
  eventId,
3391
4049
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
3392
4050
  transactionId: getUUID(),
3393
4051
  action: {
3394
- type: ActionType.REQUEST_CORRECTION,
3395
- data: {
4052
+ type: actionType,
4053
+ status: ActionStatus.Accepted,
4054
+ declaration: {
3396
4055
  "applicant.firstname": "Max",
3397
4056
  "applicant.surname": "McLaren",
3398
4057
  "applicant.dob": "2020-01-02",
3399
4058
  "recommender.none": true
3400
4059
  },
3401
- metadata: {
4060
+ annotation: {
3402
4061
  "correction.requester.relationship": "ANOTHER_AGENT",
3403
4062
  "correction.request.reason": "Child's name was incorrect"
3404
4063
  },
@@ -3413,41 +4072,104 @@ var eventPayloadGenerator = {
3413
4072
  declare: (eventId, input = {}) => ({
3414
4073
  type: ActionType.DECLARE,
3415
4074
  transactionId: input.transactionId ?? getUUID(),
3416
- data: input.data ?? generateActionInput(tennisClubMembershipEvent, ActionType.DECLARE),
4075
+ declaration: input.declaration ?? generateActionDeclarationInput(
4076
+ tennisClubMembershipEvent,
4077
+ ActionType.DECLARE
4078
+ ),
4079
+ annotation: input.annotation ?? generateActionAnnotationInput(
4080
+ tennisClubMembershipEvent,
4081
+ ActionType.DECLARE
4082
+ ),
3417
4083
  eventId
3418
4084
  }),
4085
+ /**
4086
+ * Notify allows sending incomplete data. Think it as 'partial declare' for now.
4087
+ */
4088
+ notify: (eventId, input = {}) => {
4089
+ let declaration = input.declaration;
4090
+ if (!declaration) {
4091
+ const partialDeclaration = (0, import_lodash2.omitBy)(
4092
+ generateActionDeclarationInput(
4093
+ tennisClubMembershipEvent,
4094
+ ActionType.DECLARE
4095
+ ),
4096
+ import_lodash2.isString
4097
+ );
4098
+ declaration = partialDeclaration;
4099
+ }
4100
+ return {
4101
+ type: ActionType.NOTIFY,
4102
+ transactionId: input.transactionId ?? getUUID(),
4103
+ declaration,
4104
+ eventId
4105
+ };
4106
+ },
3419
4107
  validate: (eventId, input = {}) => ({
3420
4108
  type: ActionType.VALIDATE,
3421
4109
  transactionId: input.transactionId ?? getUUID(),
3422
- data: input.data ?? generateActionInput(tennisClubMembershipEvent, ActionType.VALIDATE),
4110
+ declaration: input.declaration ?? generateActionDeclarationInput(
4111
+ tennisClubMembershipEvent,
4112
+ ActionType.VALIDATE
4113
+ ),
4114
+ annotation: input.annotation ?? generateActionAnnotationInput(
4115
+ tennisClubMembershipEvent,
4116
+ ActionType.VALIDATE
4117
+ ),
3423
4118
  duplicates: [],
3424
4119
  eventId
3425
4120
  }),
4121
+ assign: (eventId, input = {}) => ({
4122
+ type: ActionType.ASSIGN,
4123
+ transactionId: input.transactionId ?? getUUID(),
4124
+ declaration: {},
4125
+ assignedTo: input.assignedTo ?? getUUID(),
4126
+ eventId
4127
+ }),
4128
+ unassign: (eventId, input = {}) => ({
4129
+ type: ActionType.UNASSIGN,
4130
+ transactionId: input.transactionId ?? getUUID(),
4131
+ declaration: {},
4132
+ assignedTo: null,
4133
+ eventId
4134
+ }),
3426
4135
  archive: (eventId, input = {}, isDuplicate) => ({
3427
- type: ActionType.ARCHIVED,
4136
+ type: ActionType.ARCHIVE,
3428
4137
  transactionId: input.transactionId ?? getUUID(),
3429
- data: input.data ?? {},
3430
- metadata: { isDuplicate: isDuplicate ?? false },
4138
+ declaration: {},
4139
+ // @TODO: Check whether generator is needed?
4140
+ annotation: { isDuplicate: isDuplicate ?? false },
3431
4141
  duplicates: [],
3432
4142
  eventId
3433
4143
  }),
3434
4144
  reject: (eventId, input = {}) => ({
3435
4145
  type: ActionType.REJECT,
3436
4146
  transactionId: input.transactionId ?? getUUID(),
3437
- data: input.data ?? {},
4147
+ declaration: {},
4148
+ annotation: input.annotation ?? generateActionAnnotationInput(
4149
+ tennisClubMembershipEvent,
4150
+ ActionType.REJECT
4151
+ ),
3438
4152
  duplicates: [],
3439
4153
  eventId
3440
4154
  }),
3441
4155
  register: (eventId, input = {}) => ({
3442
4156
  type: ActionType.REGISTER,
3443
4157
  transactionId: input.transactionId ?? getUUID(),
3444
- data: input.data ?? generateActionInput(tennisClubMembershipEvent, ActionType.REGISTER),
4158
+ declaration: input.declaration ?? generateActionDeclarationInput(
4159
+ tennisClubMembershipEvent,
4160
+ ActionType.REGISTER
4161
+ ),
4162
+ annotation: input.annotation ?? generateActionAnnotationInput(
4163
+ tennisClubMembershipEvent,
4164
+ ActionType.REGISTER
4165
+ ),
3445
4166
  eventId
3446
4167
  }),
3447
4168
  printCertificate: (eventId, input = {}) => ({
3448
4169
  type: ActionType.PRINT_CERTIFICATE,
3449
4170
  transactionId: input.transactionId ?? getUUID(),
3450
- data: input.data ?? generateActionInput(
4171
+ declaration: {},
4172
+ annotation: input.annotation ?? generateActionAnnotationInput(
3451
4173
  tennisClubMembershipEvent,
3452
4174
  ActionType.PRINT_CERTIFICATE
3453
4175
  ),
@@ -3457,17 +4179,21 @@ var eventPayloadGenerator = {
3457
4179
  request: (eventId, input = {}) => ({
3458
4180
  type: ActionType.REQUEST_CORRECTION,
3459
4181
  transactionId: input.transactionId ?? getUUID(),
3460
- data: input.data ?? generateActionInput(
4182
+ declaration: input.declaration ?? generateActionDeclarationInput(
4183
+ tennisClubMembershipEvent,
4184
+ ActionType.REQUEST_CORRECTION
4185
+ ),
4186
+ annotation: input.annotation ?? generateActionAnnotationInput(
3461
4187
  tennisClubMembershipEvent,
3462
4188
  ActionType.REQUEST_CORRECTION
3463
4189
  ),
3464
- metadata: {},
3465
4190
  eventId
3466
4191
  }),
3467
4192
  approve: (eventId, requestId, input = {}) => ({
3468
4193
  type: ActionType.APPROVE_CORRECTION,
3469
4194
  transactionId: input.transactionId ?? getUUID(),
3470
- data: input.data ?? generateActionInput(
4195
+ declaration: {},
4196
+ annotation: input.annotation ?? generateActionAnnotationInput(
3471
4197
  tennisClubMembershipEvent,
3472
4198
  ActionType.APPROVE_CORRECTION
3473
4199
  ),
@@ -3477,7 +4203,8 @@ var eventPayloadGenerator = {
3477
4203
  reject: (eventId, requestId, input = {}) => ({
3478
4204
  type: ActionType.REJECT_CORRECTION,
3479
4205
  transactionId: input.transactionId ?? getUUID(),
3480
- data: input.data ?? generateActionInput(
4206
+ declaration: {},
4207
+ annotation: input.annotation ?? generateActionAnnotationInput(
3481
4208
  tennisClubMembershipEvent,
3482
4209
  ActionType.REJECT_CORRECTION
3483
4210
  ),
@@ -3489,26 +4216,35 @@ var eventPayloadGenerator = {
3489
4216
  };
3490
4217
  function generateActionDocument({
3491
4218
  configuration,
3492
- action
4219
+ action,
4220
+ defaults = {}
3493
4221
  }) {
3494
4222
  const actionBase = {
3495
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4223
+ // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
4224
+ // @TODO: This should be fixed in the future.
4225
+ createdAt: new Date(Date.now() - 500).toISOString(),
3496
4226
  createdBy: getUUID(),
3497
4227
  id: getUUID(),
3498
4228
  createdAtLocation: "TODO",
3499
- data: generateActionInput(configuration, action),
3500
- metadata: {}
4229
+ declaration: generateActionDeclarationInput(configuration, action),
4230
+ annotation: {},
4231
+ ...defaults,
4232
+ status: ActionStatus.Accepted
3501
4233
  };
3502
4234
  switch (action) {
4235
+ case ActionType.READ:
4236
+ return { ...actionBase, type: action };
4237
+ case ActionType.MARKED_AS_DUPLICATE:
4238
+ return { ...actionBase, type: action };
3503
4239
  case ActionType.DECLARE:
3504
4240
  return { ...actionBase, type: action };
3505
4241
  case ActionType.UNASSIGN:
3506
- return { ...actionBase, type: action };
4242
+ return { ...actionBase, type: action, assignedTo: null };
3507
4243
  case ActionType.ASSIGN:
3508
4244
  return { ...actionBase, assignedTo: getUUID(), type: action };
3509
4245
  case ActionType.VALIDATE:
3510
4246
  return { ...actionBase, type: action };
3511
- case ActionType.ARCHIVED:
4247
+ case ActionType.ARCHIVE:
3512
4248
  return { ...actionBase, type: action };
3513
4249
  case ActionType.REJECT:
3514
4250
  return { ...actionBase, type: action };
@@ -3524,14 +4260,13 @@ function generateActionDocument({
3524
4260
  return { ...actionBase, requestId: getUUID(), type: action };
3525
4261
  case ActionType.REJECT_CORRECTION:
3526
4262
  return { ...actionBase, requestId: getUUID(), type: action };
3527
- case ActionType.CUSTOM:
3528
- return { ...actionBase, type: action };
3529
4263
  case ActionType.REGISTER:
3530
4264
  return {
3531
4265
  ...actionBase,
3532
- type: action,
3533
- identifiers: { trackingId: getUUID(), registrationNumber: getUUID() }
4266
+ type: action
3534
4267
  };
4268
+ case ActionType.DELETE:
4269
+ case ActionType.DETECT_DUPLICATE:
3535
4270
  default:
3536
4271
  throw new Error(`Unsupported action type: ${action}`);
3537
4272
  }
@@ -3546,12 +4281,16 @@ function generateEventDocument({
3546
4281
  actions: actions.map(
3547
4282
  (action) => generateActionDocument({ configuration, action })
3548
4283
  ),
3549
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4284
+ // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
4285
+ // @TODO: This should be fixed in the future.
4286
+ createdAt: new Date(Date.now() - 1e3).toISOString(),
3550
4287
  id: getUUID(),
3551
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
4288
+ // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
4289
+ // @TODO: This should be fixed in the future.
4290
+ updatedAt: new Date(Date.now() - 1e3).toISOString()
3552
4291
  };
3553
4292
  }
3554
- function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, data = {}) {
4293
+ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
3555
4294
  const action = generateActionDocument({
3556
4295
  configuration: tennisClubMembershipEvent,
3557
4296
  action: actionType
@@ -3561,9 +4300,9 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, da
3561
4300
  transactionId: getUUID(),
3562
4301
  action: {
3563
4302
  ...action,
3564
- data: {
3565
- ...action.data,
3566
- ...data
4303
+ declaration: {
4304
+ ...action.declaration,
4305
+ ...declaration
3567
4306
  }
3568
4307
  },
3569
4308
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -3580,7 +4319,7 @@ var eventQueryDataGenerator = (overrides = {}) => ({
3580
4319
  modifiedAt: overrides.modifiedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
3581
4320
  assignedTo: overrides.assignedTo ?? null,
3582
4321
  updatedBy: overrides.updatedBy ?? getUUID(),
3583
- data: overrides.data ?? {
4322
+ declaration: overrides.declaration ?? {
3584
4323
  "recommender.none": true,
3585
4324
  "applicant.firstname": "Danny",
3586
4325
  "applicant.surname": "Doe",
@@ -3588,3 +4327,40 @@ var eventQueryDataGenerator = (overrides = {}) => ({
3588
4327
  },
3589
4328
  trackingId: overrides.trackingId ?? "M3F8YQ"
3590
4329
  });
4330
+ var generateTranslationConfig = (message) => ({
4331
+ defaultMessage: message,
4332
+ description: "Description for ${message}",
4333
+ id: message
4334
+ });
4335
+
4336
+ // ../commons/src/events/TemplateConfig.ts
4337
+ function isTemplateVariable(value) {
4338
+ return typeof value === "string" && value.startsWith("$");
4339
+ }
4340
+ function isFieldValue(value) {
4341
+ return FieldValue.safeParse(value).success;
4342
+ }
4343
+ function isFieldValueWithoutTemplates(value) {
4344
+ if (isTemplateVariable(value)) {
4345
+ return false;
4346
+ }
4347
+ if (typeof value === "object" && Object.values(value).some((val) => isTemplateVariable(val))) {
4348
+ return false;
4349
+ }
4350
+ return true;
4351
+ }
4352
+ function isFieldConfigDefaultValue(value) {
4353
+ if (!value) {
4354
+ return false;
4355
+ }
4356
+ if (isFieldValue(value)) {
4357
+ return true;
4358
+ }
4359
+ if (isTemplateVariable(value)) {
4360
+ return true;
4361
+ }
4362
+ if (typeof value === "object" && Object.values(value).every((v) => typeof v === "object" && v !== null)) {
4363
+ return Object.values(value).every((v) => isFieldConfigDefaultValue(v));
4364
+ }
4365
+ return false;
4366
+ }