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

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