@opencrvs/toolkit 1.8.0-rc.feaeeb7 → 1.8.0-rc.ff62f9e

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.
@@ -40,9 +40,11 @@ __export(events_exports, {
40
40
  ActionUpdate: () => ActionUpdate,
41
41
  AddressFieldUpdateValue: () => AddressFieldUpdateValue,
42
42
  AddressFieldValue: () => AddressFieldValue,
43
+ AddressType: () => AddressType,
44
+ AdministrativeAreas: () => AdministrativeAreas,
43
45
  AdvancedSearchConfig: () => AdvancedSearchConfig,
44
46
  ApproveCorrectionActionInput: () => ApproveCorrectionActionInput,
45
- ArchivedActionInput: () => ArchivedActionInput,
47
+ ArchiveActionInput: () => ArchiveActionInput,
46
48
  BaseActionInput: () => BaseActionInput,
47
49
  CertificateConfig: () => CertificateConfig,
48
50
  CertificateTemplateConfig: () => CertificateTemplateConfig,
@@ -50,6 +52,7 @@ __export(events_exports, {
50
52
  Clause: () => Clause,
51
53
  Conditional: () => Conditional,
52
54
  ConditionalType: () => ConditionalType,
55
+ DataFieldValue: () => DataFieldValue,
53
56
  DateValue: () => DateValue,
54
57
  DeclareActionInput: () => DeclareActionInput,
55
58
  DeduplicationConfig: () => DeduplicationConfig,
@@ -75,12 +78,20 @@ __export(events_exports, {
75
78
  FileFieldWithOptionValue: () => FileFieldWithOptionValue,
76
79
  FormConfig: () => FormConfig,
77
80
  FormPage: () => FormPage,
81
+ FormPageConfig: () => FormPageConfig,
82
+ FormPageType: () => FormPageType,
83
+ GenericAddressUpdateValue: () => GenericAddressUpdateValue,
84
+ GenericAddressValue: () => GenericAddressValue,
78
85
  GeographicalArea: () => GeographicalArea,
86
+ ImageMimeType: () => ImageMimeType,
79
87
  LanguageConfig: () => LanguageConfig,
88
+ LatentActions: () => LatentActions,
80
89
  MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
90
+ MimeType: () => MimeType,
81
91
  NotifyActionInput: () => NotifyActionInput,
82
92
  NumberFieldValue: () => NumberFieldValue,
83
93
  PrintCertificateActionInput: () => PrintCertificateActionInput,
94
+ ReadActionInput: () => ReadActionInput,
84
95
  RegisterActionInput: () => RegisterActionInput,
85
96
  RejectCorrectionActionInput: () => RejectCorrectionActionInput,
86
97
  RejectDeclarationActionInput: () => RejectDeclarationActionInput,
@@ -96,16 +107,21 @@ __export(events_exports, {
96
107
  UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
97
108
  UrbanAddressValue: () => UrbanAddressValue,
98
109
  ValidateActionInput: () => ValidateActionInput,
110
+ VerificationPage: () => VerificationPage,
111
+ VerificationPageConfig: () => VerificationPageConfig,
99
112
  WorkqueueConfig: () => WorkqueueConfig,
100
113
  alwaysTrue: () => alwaysTrue,
101
114
  and: () => and,
102
115
  applyDraftsToEventIndex: () => applyDraftsToEventIndex,
116
+ compositeFieldTypes: () => compositeFieldTypes,
117
+ createEmptyDraft: () => createEmptyDraft,
103
118
  createValidationSchema: () => createValidationSchema,
104
119
  deepDropNulls: () => deepDropNulls,
105
120
  defineConditional: () => defineConditional,
106
121
  defineConfig: () => defineConfig,
107
122
  defineForm: () => defineForm,
108
123
  defineFormPage: () => defineFormPage,
124
+ errorMessages: () => errorMessages,
109
125
  event: () => event,
110
126
  eventMetadataLabelMap: () => eventMetadataLabelMap,
111
127
  eventPayloadGenerator: () => eventPayloadGenerator,
@@ -117,14 +133,18 @@ __export(events_exports, {
117
133
  findActiveActionForm: () => findActiveActionForm,
118
134
  findActiveActionFormFields: () => findActiveActionFormFields,
119
135
  findActiveActionFormPages: () => findActiveActionFormPages,
136
+ findActiveDrafts: () => findActiveDrafts,
120
137
  findInputPageFields: () => findInputPageFields,
121
138
  findPageFields: () => findPageFields,
122
139
  generateActionDocument: () => generateActionDocument,
123
140
  generateActionInput: () => generateActionInput,
141
+ generateActionMetadataInput: () => generateActionMetadataInput,
124
142
  generateEventDocument: () => generateEventDocument,
125
143
  generateEventDraftDocument: () => generateEventDraftDocument,
126
144
  generateTransactionId: () => generateTransactionId,
145
+ generateTranslationConfig: () => generateTranslationConfig,
127
146
  getActiveActionFields: () => getActiveActionFields,
147
+ getActiveActionFormPages: () => getActiveActionFormPages,
128
148
  getAllFields: () => getAllFields,
129
149
  getAllPages: () => getAllPages,
130
150
  getCurrentEventState: () => getCurrentEventState,
@@ -133,16 +153,18 @@ __export(events_exports, {
133
153
  getFieldValidationErrors: () => getFieldValidationErrors,
134
154
  getFormFields: () => getFormFields,
135
155
  getMetadataForAction: () => getMetadataForAction,
156
+ getVisiblePagesFormFields: () => getVisiblePagesFormFields,
136
157
  isAddressFieldType: () => isAddressFieldType,
137
158
  isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
138
159
  isBulletListFieldType: () => isBulletListFieldType,
139
160
  isCheckboxFieldType: () => isCheckboxFieldType,
140
161
  isCountryFieldType: () => isCountryFieldType,
162
+ isDataFieldType: () => isDataFieldType,
141
163
  isDateFieldType: () => isDateFieldType,
142
- isDefaultValue: () => isDefaultValue,
143
164
  isDividerFieldType: () => isDividerFieldType,
144
165
  isEmailFieldType: () => isEmailFieldType,
145
166
  isFacilityFieldType: () => isFacilityFieldType,
167
+ isFieldConfigDefaultValue: () => isFieldConfigDefaultValue,
146
168
  isFieldEnabled: () => isFieldEnabled,
147
169
  isFieldValue: () => isFieldValue,
148
170
  isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
@@ -153,6 +175,7 @@ __export(events_exports, {
153
175
  isNumberFieldType: () => isNumberFieldType,
154
176
  isOfficeFieldType: () => isOfficeFieldType,
155
177
  isPageHeaderFieldType: () => isPageHeaderFieldType,
178
+ isPageVisible: () => isPageVisible,
156
179
  isParagraphFieldType: () => isParagraphFieldType,
157
180
  isRadioGroupFieldType: () => isRadioGroupFieldType,
158
181
  isSelectFieldType: () => isSelectFieldType,
@@ -161,6 +184,8 @@ __export(events_exports, {
161
184
  isTextAreaFieldType: () => isTextAreaFieldType,
162
185
  isTextFieldType: () => isTextFieldType,
163
186
  isUndeclaredDraft: () => isUndeclaredDraft,
187
+ isVerificationPage: () => isVerificationPage,
188
+ mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
164
189
  mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
165
190
  mapFieldTypeToZod: () => mapFieldTypeToZod,
166
191
  not: () => not,
@@ -244,9 +269,15 @@ var FieldType = {
244
269
  ADMINISTRATIVE_AREA: "ADMINISTRATIVE_AREA",
245
270
  FACILITY: "FACILITY",
246
271
  OFFICE: "OFFICE",
247
- SIGNATURE: "SIGNATURE"
272
+ SIGNATURE: "SIGNATURE",
273
+ DATA: "DATA"
248
274
  };
249
275
  var fieldTypes = Object.values(FieldType);
276
+ var compositeFieldTypes = [
277
+ FieldType.ADDRESS,
278
+ FieldType.FILE_WITH_OPTIONS,
279
+ FieldType.FILE
280
+ ];
250
281
 
251
282
  // ../commons/src/events/FieldValue.ts
252
283
  var import_zod4 = require("zod");
@@ -257,6 +288,10 @@ var GeographicalArea = {
257
288
  URBAN: "URBAN",
258
289
  RURAL: "RURAL"
259
290
  };
291
+ var AddressType = {
292
+ DOMESTIC: "DOMESTIC",
293
+ INTERNATIONAL: "INTERNATIONAL"
294
+ };
260
295
  var FileFieldValue = import_zod3.z.object({
261
296
  filename: import_zod3.z.string(),
262
297
  originalFilename: import_zod3.z.string(),
@@ -264,6 +299,7 @@ var FileFieldValue = import_zod3.z.object({
264
299
  });
265
300
  var AdminStructure = import_zod3.z.object({
266
301
  country: import_zod3.z.string(),
302
+ addressType: import_zod3.z.literal(AddressType.DOMESTIC),
267
303
  province: import_zod3.z.string(),
268
304
  district: import_zod3.z.string()
269
305
  });
@@ -291,14 +327,33 @@ var RuralAddressUpdateValue = AdminStructure.extend({
291
327
  urbanOrRural: import_zod3.z.literal(GeographicalArea.RURAL),
292
328
  village: import_zod3.z.string().nullish()
293
329
  });
294
- var AddressFieldValue = import_zod3.z.discriminatedUnion("urbanOrRural", [
295
- UrbanAddressValue,
296
- RuralAddressValue
297
- ]);
330
+ var GenericAddressValue = import_zod3.z.object({
331
+ country: import_zod3.z.string(),
332
+ addressType: import_zod3.z.literal(AddressType.INTERNATIONAL),
333
+ state: import_zod3.z.string(),
334
+ district2: import_zod3.z.string(),
335
+ cityOrTown: import_zod3.z.string().optional(),
336
+ addressLine1: import_zod3.z.string().optional(),
337
+ addressLine2: import_zod3.z.string().optional(),
338
+ addressLine3: import_zod3.z.string().optional(),
339
+ postcodeOrZip: import_zod3.z.string().optional()
340
+ });
341
+ var AddressFieldValue = import_zod3.z.discriminatedUnion("urbanOrRural", [UrbanAddressValue, RuralAddressValue]).or(GenericAddressValue);
342
+ var GenericAddressUpdateValue = import_zod3.z.object({
343
+ country: import_zod3.z.string(),
344
+ addressType: import_zod3.z.literal(AddressType.INTERNATIONAL),
345
+ state: import_zod3.z.string(),
346
+ district2: import_zod3.z.string(),
347
+ cityOrTown: import_zod3.z.string().nullish(),
348
+ addressLine1: import_zod3.z.string().nullish(),
349
+ addressLine2: import_zod3.z.string().nullish(),
350
+ addressLine3: import_zod3.z.string().nullish(),
351
+ postcodeOrZip: import_zod3.z.string().nullish()
352
+ });
298
353
  var AddressFieldUpdateValue = import_zod3.z.discriminatedUnion("urbanOrRural", [
299
354
  UrbanAddressUpdateValue,
300
355
  RuralAddressUpdateValue
301
- ]);
356
+ ]).or(GenericAddressUpdateValue);
302
357
  var FileFieldValueWithOption = import_zod3.z.object({
303
358
  filename: import_zod3.z.string(),
304
359
  originalFilename: import_zod3.z.string(),
@@ -314,6 +369,7 @@ var DateValue = import_zod4.z.string().date().describe("Date in the format YYYY-
314
369
  var EmailValue = import_zod4.z.string().email();
315
370
  var CheckboxFieldValue = import_zod4.z.boolean();
316
371
  var NumberFieldValue = import_zod4.z.number();
372
+ var DataFieldValue = import_zod4.z.undefined();
317
373
  var FieldValue = import_zod4.z.union([
318
374
  TextValue,
319
375
  DateValue,
@@ -322,7 +378,9 @@ var FieldValue = import_zod4.z.union([
322
378
  FileFieldValue,
323
379
  FileFieldWithOptionValue,
324
380
  UrbanAddressValue,
325
- RuralAddressValue
381
+ RuralAddressValue,
382
+ DataFieldValue,
383
+ GenericAddressValue
326
384
  ]);
327
385
  var FieldUpdateValue = import_zod4.z.union([
328
386
  TextValue,
@@ -332,7 +390,9 @@ var FieldUpdateValue = import_zod4.z.union([
332
390
  FileFieldValue,
333
391
  FileFieldWithOptionValue,
334
392
  UrbanAddressUpdateValue,
335
- RuralAddressUpdateValue
393
+ RuralAddressUpdateValue,
394
+ DataFieldValue,
395
+ GenericAddressUpdateValue
336
396
  ]);
337
397
 
338
398
  // ../commons/src/events/FieldConfig.ts
@@ -403,15 +463,25 @@ var TextAreaField = BaseField.extend({
403
463
  postfix: TranslationConfig.optional()
404
464
  }).default({ rows: 4 }).optional()
405
465
  }).describe("Multiline text input");
466
+ var ImageMimeType = import_zod5.z.enum([
467
+ "image/png",
468
+ "image/jpg",
469
+ "image/jpeg",
470
+ "image/svg+xml"
471
+ ]);
472
+ var MimeType = ImageMimeType;
473
+ var DEFAULT_MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;
406
474
  var SignatureField = BaseField.extend({
407
475
  type: import_zod5.z.literal(FieldType.SIGNATURE),
408
476
  signaturePromptLabel: TranslationConfig.describe(
409
477
  "Title of the signature modal"
410
478
  ),
411
479
  configuration: import_zod5.z.object({
412
- maxSizeMb: import_zod5.z.number().optional().describe("Maximum file size in MB"),
413
- allowedFileFormats: import_zod5.z.array(import_zod5.z.string()).optional().describe("List of allowed file formats for the signature")
414
- }).default({}).optional()
480
+ maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
481
+ acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
482
+ }).default({
483
+ maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
484
+ })
415
485
  }).describe("Signature input field");
416
486
  var EmailField = BaseField.extend({
417
487
  type: import_zod5.z.literal(FieldType.EMAIL),
@@ -454,13 +524,17 @@ var PageHeader = BaseField.extend({
454
524
  }).describe("A read-only header component for form pages");
455
525
  var File = BaseField.extend({
456
526
  type: import_zod5.z.literal(FieldType.FILE),
457
- options: import_zod5.z.object({
527
+ configuration: import_zod5.z.object({
528
+ maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
529
+ acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
458
530
  style: import_zod5.z.object({
459
- fullWidth: import_zod5.z.boolean().describe(
531
+ width: import_zod5.z.enum(["full", "auto"]).optional().describe(
460
532
  "Whether the file upload button should take the full width of the container or not"
461
533
  )
462
- })
463
- }).optional()
534
+ }).optional()
535
+ }).default({
536
+ maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
537
+ })
464
538
  }).describe("File upload");
465
539
  var SelectOption = import_zod5.z.object({
466
540
  value: import_zod5.z.string().describe("The value of the option"),
@@ -499,11 +573,16 @@ var Country = BaseField.extend({
499
573
  type: import_zod5.z.literal(FieldType.COUNTRY),
500
574
  defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
501
575
  }).describe("Country select field");
576
+ var AdministrativeAreas = import_zod5.z.enum([
577
+ "ADMIN_STRUCTURE",
578
+ "HEALTH_FACILITY",
579
+ "CRVS_OFFICE"
580
+ ]);
502
581
  var AdministrativeAreaConfiguration = import_zod5.z.object({
503
582
  partOf: import_zod5.z.object({
504
583
  $data: import_zod5.z.string()
505
584
  }).optional().describe("Parent location"),
506
- type: import_zod5.z.enum(["ADMIN_STRUCTURE", "HEALTH_FACILITY", "CRVS_OFFICE"])
585
+ type: AdministrativeAreas
507
586
  }).describe("Administrative area options");
508
587
  var AdministrativeArea = BaseField.extend({
509
588
  type: import_zod5.z.literal(FieldType.ADMINISTRATIVE_AREA),
@@ -516,8 +595,14 @@ var Location = BaseField.extend({
516
595
  }).describe("Input field for a location");
517
596
  var FileUploadWithOptions = BaseField.extend({
518
597
  type: import_zod5.z.literal(FieldType.FILE_WITH_OPTIONS),
519
- options: import_zod5.z.array(SelectOption).describe("A list of options")
520
- }).describe("Select input");
598
+ options: import_zod5.z.array(SelectOption).describe("A list of options"),
599
+ configuration: import_zod5.z.object({
600
+ maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
601
+ acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
602
+ }).default({
603
+ maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
604
+ })
605
+ });
521
606
  var Facility = BaseField.extend({
522
607
  type: import_zod5.z.literal(FieldType.FACILITY),
523
608
  defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
@@ -530,6 +615,13 @@ var Address = BaseField.extend({
530
615
  type: import_zod5.z.literal(FieldType.ADDRESS),
531
616
  defaultValue: AddressFieldValue.optional()
532
617
  }).describe("Address input field \u2013 a combination of location and text fields");
618
+ var DataField = BaseField.extend({
619
+ type: import_zod5.z.literal(FieldType.DATA),
620
+ configuration: import_zod5.z.object({
621
+ subtitle: TranslationConfig.optional(),
622
+ data: import_zod5.z.array(import_zod5.z.object({ fieldId: import_zod5.z.string() }))
623
+ })
624
+ }).describe("Data field for displaying read-only data");
533
625
  var FieldConfig = import_zod5.z.discriminatedUnion("type", [
534
626
  Address,
535
627
  TextField,
@@ -551,15 +643,46 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
551
643
  Office,
552
644
  SignatureField,
553
645
  EmailField,
554
- FileUploadWithOptions
646
+ FileUploadWithOptions,
647
+ DataField
555
648
  ]);
556
649
 
557
650
  // ../commons/src/events/FormConfig.ts
651
+ var FormPageType = {
652
+ FORM: "FORM",
653
+ VERIFICATION: "VERIFICATION"
654
+ };
558
655
  var FormPage = import_zod6.z.object({
559
656
  id: import_zod6.z.string().describe("Unique identifier for the page"),
657
+ type: import_zod6.z.literal(FormPageType.FORM).default(FormPageType.FORM),
560
658
  title: TranslationConfig.describe("Header title of the page"),
561
- fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page")
659
+ fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page"),
660
+ conditional: Conditional().optional().describe(
661
+ "Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
662
+ )
562
663
  });
664
+ var VerificationPageConfig = import_zod6.z.object({
665
+ verify: import_zod6.z.object({ label: TranslationConfig }),
666
+ cancel: import_zod6.z.object({
667
+ label: TranslationConfig,
668
+ confirmation: import_zod6.z.object({
669
+ title: TranslationConfig,
670
+ body: TranslationConfig
671
+ })
672
+ })
673
+ }).describe("Actions available on the verification page");
674
+ var VerificationPage = FormPage.extend({
675
+ type: import_zod6.z.literal(FormPageType.VERIFICATION),
676
+ actions: VerificationPageConfig
677
+ });
678
+ var FormPageConfig = import_zod6.z.preprocess(
679
+ (pageConfig) => ({
680
+ ...pageConfig,
681
+ type: pageConfig.type ?? FormPageType.FORM
682
+ // Default type to "FORM" if not provided
683
+ }),
684
+ import_zod6.z.discriminatedUnion("type", [FormPage, VerificationPage])
685
+ );
563
686
  var FormConfig = import_zod6.z.object({
564
687
  label: TranslationConfig.describe("Human readable description of the form"),
565
688
  version: import_zod6.z.object({
@@ -571,7 +694,7 @@ var FormConfig = import_zod6.z.object({
571
694
  )
572
695
  }),
573
696
  active: import_zod6.z.boolean().default(false).describe("Whether the form is active"),
574
- pages: import_zod6.z.array(FormPage),
697
+ pages: import_zod6.z.array(FormPageConfig),
575
698
  review: import_zod6.z.object({
576
699
  title: TranslationConfig.describe(
577
700
  "Title of the form to show in review page"
@@ -598,8 +721,10 @@ var ActionType = {
598
721
  CUSTOM: "CUSTOM",
599
722
  REJECT: "REJECT",
600
723
  MARKED_AS_DUPLICATE: "MARKED_AS_DUPLICATE",
601
- ARCHIVED: "ARCHIVED"
724
+ ARCHIVE: "ARCHIVE",
725
+ READ: "READ"
602
726
  };
727
+ var LatentActions = [ActionType.ARCHIVE, ActionType.REJECT];
603
728
 
604
729
  // ../commons/src/events/ActionConfig.ts
605
730
  var ActionConditional2 = import_zod7.z.discriminatedUnion("type", [
@@ -626,23 +751,17 @@ var ValidateConfig = ActionConfigBase.merge(
626
751
  );
627
752
  var RejectDeclarationConfig = ActionConfigBase.merge(
628
753
  import_zod7.z.object({
629
- type: import_zod7.z.literal(ActionType.REJECT),
630
- comment: import_zod7.z.string(),
631
- isDuplicate: import_zod7.z.boolean()
754
+ type: import_zod7.z.literal(ActionType.REJECT)
632
755
  })
633
756
  );
634
757
  var MarkedAsDuplicateConfig = ActionConfigBase.merge(
635
758
  import_zod7.z.object({
636
- type: import_zod7.z.literal(ActionType.MARKED_AS_DUPLICATE),
637
- comment: import_zod7.z.string(),
638
- duplicates: import_zod7.z.array(import_zod7.z.string()).describe("UUIDs of duplicate records")
759
+ type: import_zod7.z.literal(ActionType.MARKED_AS_DUPLICATE)
639
760
  })
640
761
  );
641
- var ArchivedConfig = ActionConfigBase.merge(
762
+ var ArchiveConfig = ActionConfigBase.merge(
642
763
  import_zod7.z.object({
643
- type: import_zod7.z.literal(ActionType.ARCHIVED),
644
- comment: import_zod7.z.string(),
645
- isDuplicate: import_zod7.z.boolean()
764
+ type: import_zod7.z.literal(ActionType.ARCHIVE)
646
765
  })
647
766
  );
648
767
  var RegisterConfig = ActionConfigBase.merge(
@@ -663,8 +782,8 @@ var PrintCertificateActionConfig = ActionConfigBase.merge(
663
782
  var RequestCorrectionConfig = ActionConfigBase.merge(
664
783
  import_zod7.z.object({
665
784
  type: import_zod7.z.literal(ActionType.REQUEST_CORRECTION),
666
- onboardingForm: import_zod7.z.array(FormPage),
667
- additionalDetailsForm: import_zod7.z.array(FormPage)
785
+ onboardingForm: import_zod7.z.array(FormPageConfig),
786
+ additionalDetailsForm: import_zod7.z.array(FormPageConfig)
668
787
  })
669
788
  );
670
789
  var RejectCorrectionConfig = ActionConfigBase.merge(
@@ -687,7 +806,7 @@ var ActionConfig = import_zod7.z.discriminatedUnion("type", [
687
806
  ValidateConfig,
688
807
  RejectDeclarationConfig,
689
808
  MarkedAsDuplicateConfig,
690
- ArchivedConfig,
809
+ ArchiveConfig,
691
810
  RegisterConfig,
692
811
  DeleteConfig,
693
812
  PrintCertificateActionConfig,
@@ -1106,6 +1225,9 @@ function mapFieldTypeToZod(type, required) {
1106
1225
  case FieldType.ADDRESS:
1107
1226
  schema = AddressFieldUpdateValue;
1108
1227
  break;
1228
+ case FieldType.DATA:
1229
+ schema = DataFieldValue;
1230
+ break;
1109
1231
  }
1110
1232
  return required ? schema : schema.nullish();
1111
1233
  }
@@ -1140,6 +1262,7 @@ function mapFieldTypeToMockValue(field2, i) {
1140
1262
  case FieldType.ADDRESS:
1141
1263
  return {
1142
1264
  country: "FAR",
1265
+ addressType: AddressType.DOMESTIC,
1143
1266
  province: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
1144
1267
  district: "5ef450bc-712d-48ad-93f3-8da0fa453baa",
1145
1268
  urbanOrRural: "URBAN",
@@ -1161,6 +1284,54 @@ function mapFieldTypeToMockValue(field2, i) {
1161
1284
  };
1162
1285
  case FieldType.FILE_WITH_OPTIONS:
1163
1286
  return null;
1287
+ case FieldType.DATA:
1288
+ return {};
1289
+ }
1290
+ }
1291
+ function mapFieldTypeToEmptyValue(field2) {
1292
+ switch (field2.type) {
1293
+ case FieldType.DIVIDER:
1294
+ case FieldType.TEXT:
1295
+ case FieldType.TEXTAREA:
1296
+ case FieldType.BULLET_LIST:
1297
+ case FieldType.PAGE_HEADER:
1298
+ case FieldType.LOCATION:
1299
+ case FieldType.SELECT:
1300
+ case FieldType.COUNTRY:
1301
+ case FieldType.RADIO_GROUP:
1302
+ case FieldType.SIGNATURE:
1303
+ case FieldType.PARAGRAPH:
1304
+ case FieldType.ADMINISTRATIVE_AREA:
1305
+ case FieldType.FACILITY:
1306
+ case FieldType.OFFICE:
1307
+ case FieldType.NUMBER:
1308
+ case FieldType.EMAIL:
1309
+ case FieldType.DATE:
1310
+ case FieldType.CHECKBOX:
1311
+ case FieldType.DATA:
1312
+ return null;
1313
+ case FieldType.ADDRESS:
1314
+ return {
1315
+ country: null,
1316
+ addressType: AddressType.DOMESTIC,
1317
+ province: null,
1318
+ district: null,
1319
+ urbanOrRural: "URBAN",
1320
+ // Default to urban needed for validation
1321
+ town: null,
1322
+ residentialArea: null,
1323
+ street: null,
1324
+ number: null,
1325
+ zipCode: null
1326
+ };
1327
+ case FieldType.FILE:
1328
+ return {
1329
+ filename: "",
1330
+ originalFilename: "",
1331
+ type: ""
1332
+ };
1333
+ case FieldType.FILE_WITH_OPTIONS:
1334
+ return [];
1164
1335
  }
1165
1336
  }
1166
1337
  var isParagraphFieldType = (field2) => {
@@ -1226,6 +1397,9 @@ var isFacilityFieldType = (field2) => {
1226
1397
  var isOfficeFieldType = (field2) => {
1227
1398
  return field2.config.type === FieldType.OFFICE;
1228
1399
  };
1400
+ var isDataFieldType = (field2) => {
1401
+ return field2.config.type === FieldType.DATA;
1402
+ };
1229
1403
 
1230
1404
  // ../commons/src/conditionals/validate.ts
1231
1405
  var ajv = new import_ajv.default({
@@ -1262,49 +1436,76 @@ function isFieldVisible(field2, form) {
1262
1436
  function isFieldEnabled(field2, form) {
1263
1437
  return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
1264
1438
  }
1439
+ var errorMessages = {
1440
+ hiddenField: {
1441
+ id: "v2.error.hidden",
1442
+ defaultMessage: "Hidden or disabled field should not receive a value",
1443
+ description: "Error message when field is hidden or disabled, but a value was received"
1444
+ },
1445
+ invalidDate: {
1446
+ defaultMessage: "Invalid date field",
1447
+ description: "Error message when date field is invalid",
1448
+ id: "v2.error.invalidDate"
1449
+ },
1450
+ invalidEmail: {
1451
+ defaultMessage: "Invalid email address",
1452
+ description: "Error message when email address is invalid",
1453
+ id: "v2.error.invalidEmail"
1454
+ },
1455
+ requiredField: {
1456
+ defaultMessage: "Required for registration",
1457
+ description: "Error message when required field is missing",
1458
+ id: "v2.error.required"
1459
+ },
1460
+ invalidInput: {
1461
+ defaultMessage: "Invalid input",
1462
+ description: "Error message when generic field is invalid",
1463
+ id: "v2.error.invalid"
1464
+ }
1465
+ };
1466
+ var createIntlError = (message) => ({
1467
+ message: {
1468
+ message
1469
+ }
1470
+ });
1265
1471
  var zodToIntlErrorMap = (issue, _ctx) => {
1266
- if (issue.code === "invalid_string" && issue.validation === "date") {
1267
- return {
1268
- message: {
1269
- message: {
1270
- defaultMessage: "Invalid date. Please use the format YYYY-MM-DD",
1271
- description: "This is the error message for invalid date fields",
1272
- id: "v2.error.invalidDate"
1273
- }
1472
+ switch (issue.code) {
1473
+ case "invalid_string": {
1474
+ if (_ctx.data === "") {
1475
+ return createIntlError(errorMessages.requiredField);
1274
1476
  }
1275
- };
1276
- }
1277
- if (issue.code === "invalid_string" && issue.validation === "email") {
1278
- return {
1279
- message: {
1280
- message: {
1281
- defaultMessage: "Invalid email address",
1282
- description: "This is the error message for invalid email fields",
1283
- id: "v2.error.invalidEmail"
1284
- }
1477
+ if (issue.validation === "date") {
1478
+ return createIntlError(errorMessages.invalidDate);
1285
1479
  }
1286
- };
1287
- }
1288
- if (issue.code === "invalid_type" && issue.expected !== issue.received && issue.received === "undefined" || issue.code === "too_small" && issue.message === void 0) {
1289
- return {
1290
- message: {
1291
- message: {
1292
- defaultMessage: "Required for registration",
1293
- description: "This is the error message for required fields",
1294
- id: "v2.error.required"
1295
- }
1480
+ if (issue.validation === "email") {
1481
+ return createIntlError(errorMessages.invalidEmail);
1296
1482
  }
1297
- };
1298
- }
1299
- return {
1300
- message: {
1301
- message: {
1302
- defaultMessage: "Invalid input",
1303
- description: "This is the error message for invalid field value",
1304
- id: "v2.error.invalid"
1483
+ break;
1484
+ }
1485
+ case "invalid_type": {
1486
+ if (issue.expected !== issue.received && issue.received === "undefined") {
1487
+ return createIntlError(errorMessages.requiredField);
1305
1488
  }
1489
+ break;
1306
1490
  }
1307
- };
1491
+ case "too_small": {
1492
+ if (issue.message === void 0) {
1493
+ return createIntlError(errorMessages.requiredField);
1494
+ }
1495
+ break;
1496
+ }
1497
+ case "invalid_union": {
1498
+ for (const { issues } of issue.unionErrors) {
1499
+ for (const e of issues) {
1500
+ if (zodToIntlErrorMap(e, _ctx).message.message.id !== "v2.error.required") {
1501
+ return createIntlError(errorMessages.invalidInput);
1502
+ }
1503
+ }
1504
+ }
1505
+ return createIntlError(errorMessages.requiredField);
1506
+ }
1507
+ }
1508
+ return createIntlError(errorMessages.invalidInput);
1308
1509
  };
1309
1510
  function getFieldValidationErrors({
1310
1511
  field: field2,
@@ -1319,11 +1520,7 @@ function getFieldValidationErrors({
1319
1520
  return {
1320
1521
  errors: [
1321
1522
  {
1322
- message: {
1323
- id: "v2.error.hidden",
1324
- defaultMessage: "Hidden or disabled field should not receive a value",
1325
- description: "Error message when field is hidden or disabled, but a value was received"
1326
- }
1523
+ message: errorMessages.hiddenField
1327
1524
  }
1328
1525
  ]
1329
1526
  };
@@ -1341,8 +1538,8 @@ function getFieldValidationErrors({
1341
1538
  conditionalParameters
1342
1539
  });
1343
1540
  return {
1344
- // Assumes that custom validation errors are more important than field validation errors
1345
- errors: [...customValidationResults, ...fieldValidationResult]
1541
+ // Assumes that custom validation errors are based on the field type, and extend the validation.
1542
+ errors: [...fieldValidationResult, ...customValidationResults]
1346
1543
  };
1347
1544
  }
1348
1545
  function runCustomFieldValidations({
@@ -1367,7 +1564,22 @@ function validateFieldInput({
1367
1564
  return rawError.error?.issues.map((issue) => issue.message) ?? [];
1368
1565
  }
1369
1566
 
1567
+ // ../commons/src/utils.ts
1568
+ function getOrThrow(x, message) {
1569
+ if (x === void 0 || x === null) {
1570
+ throw new Error(message);
1571
+ }
1572
+ return x;
1573
+ }
1574
+
1575
+ // ../commons/src/uuid.ts
1576
+ var import_uuid = require("uuid");
1577
+ function getUUID() {
1578
+ return (0, import_uuid.v4)();
1579
+ }
1580
+
1370
1581
  // ../commons/src/events/utils.ts
1582
+ var import_date_fns2 = require("date-fns");
1371
1583
  function isMetadataField(field2) {
1372
1584
  return field2 in eventMetadataLabelMap;
1373
1585
  }
@@ -1436,7 +1648,7 @@ function validateWorkqueueConfig(workqueueConfigs) {
1436
1648
  );
1437
1649
  if (!rootWorkqueue) {
1438
1650
  throw new Error(
1439
- `Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
1651
+ `Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
1440
1652
  );
1441
1653
  }
1442
1654
  });
@@ -1452,18 +1664,42 @@ var findActiveActionFormPages = (configuration, action) => {
1452
1664
  var getFormFields = (formConfig) => {
1453
1665
  return formConfig.pages.flatMap((p) => p.fields);
1454
1666
  };
1667
+ function isPageVisible(page, formValues) {
1668
+ if (!page.conditional) {
1669
+ return true;
1670
+ }
1671
+ return validate(page.conditional, {
1672
+ $form: formValues,
1673
+ $now: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
1674
+ });
1675
+ }
1676
+ var getVisiblePagesFormFields = (formConfig, formData) => {
1677
+ return formConfig.pages.filter((p) => isPageVisible(p, formData)).flatMap((p) => p.fields);
1678
+ };
1455
1679
  var findActiveActionFormFields = (configuration, action) => {
1456
1680
  const form = findActiveActionForm(configuration, action);
1457
1681
  return form ? getFormFields(form) : void 0;
1458
1682
  };
1459
- var findActiveActionFields = (configuration, action) => {
1683
+ var findActiveActionFields = (configuration, action, formData) => {
1460
1684
  const form = findActiveActionForm(configuration, action);
1461
1685
  const reviewFields = form?.review.fields;
1462
- const formFields = form ? getFormFields(form) : void 0;
1686
+ let formFields = void 0;
1687
+ if (form) {
1688
+ formFields = formData ? getVisiblePagesFormFields(form, formData) : getFormFields(form);
1689
+ }
1463
1690
  const allFields = formFields ? formFields.concat(reviewFields ?? []) : reviewFields;
1464
1691
  return allFields;
1465
1692
  };
1693
+ var getActiveActionFormPages = (configuration, action) => {
1694
+ return getOrThrow(
1695
+ findActiveActionForm(configuration, action)?.pages,
1696
+ "Form configuration not found for type: " + configuration.id
1697
+ );
1698
+ };
1466
1699
  function getActiveActionFields(configuration, action) {
1700
+ if (LatentActions.some((latentAction) => latentAction === action)) {
1701
+ return getActiveActionFields(configuration, ActionType.DECLARE);
1702
+ }
1467
1703
  const fields = findActiveActionFields(configuration, action);
1468
1704
  if (!fields) {
1469
1705
  throw new Error(`No active field config found for action type ${action}`);
@@ -1495,6 +1731,30 @@ function stripHiddenFields(fields, data) {
1495
1731
  return !isFieldVisible(field2, data);
1496
1732
  });
1497
1733
  }
1734
+ function findActiveDrafts(event2, drafts) {
1735
+ const actions = event2.actions.slice().filter(({ type }) => type !== ActionType.READ).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
1736
+ const lastAction = actions[actions.length - 1];
1737
+ return drafts.filter(({ createdAt }) => createdAt >= lastAction.createdAt).filter(({ eventId }) => eventId === event2.id);
1738
+ }
1739
+ function createEmptyDraft(eventId, draftId, actionType) {
1740
+ return {
1741
+ id: draftId,
1742
+ eventId,
1743
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1744
+ transactionId: getUUID(),
1745
+ action: {
1746
+ type: actionType,
1747
+ data: {},
1748
+ metadata: {},
1749
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1750
+ createdBy: "@todo",
1751
+ createdAtLocation: "@todo"
1752
+ }
1753
+ };
1754
+ }
1755
+ function isVerificationPage(page) {
1756
+ return page.type === FormPageType.VERIFICATION;
1757
+ }
1498
1758
 
1499
1759
  // ../commons/src/events/EventConfig.ts
1500
1760
  var EventConfig = import_zod18.z.object({
@@ -1536,7 +1796,7 @@ var EventConfig = import_zod18.z.object({
1536
1796
 
1537
1797
  // ../commons/src/events/EventConfigInput.ts
1538
1798
  var defineForm = (form) => FormConfig.parse(form);
1539
- var defineFormPage = (formPage) => FormPage.parse(formPage);
1799
+ var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
1540
1800
 
1541
1801
  // ../commons/src/events/Draft.ts
1542
1802
  var import_zod21 = require("zod");
@@ -1592,9 +1852,9 @@ var MarkAsDuplicateAction = ActionBase.merge(
1592
1852
  type: import_zod19.z.literal(ActionType.MARKED_AS_DUPLICATE)
1593
1853
  })
1594
1854
  );
1595
- var ArchivedAction = ActionBase.merge(
1855
+ var ArchiveAction = ActionBase.merge(
1596
1856
  import_zod19.z.object({
1597
- type: import_zod19.z.literal(ActionType.ARCHIVED)
1857
+ type: import_zod19.z.literal(ActionType.ARCHIVE)
1598
1858
  })
1599
1859
  );
1600
1860
  var CreatedAction = ActionBase.merge(
@@ -1629,6 +1889,11 @@ var RejectedCorrectionAction = ActionBase.merge(
1629
1889
  requestId: import_zod19.z.string()
1630
1890
  })
1631
1891
  );
1892
+ var ReadAction = ActionBase.merge(
1893
+ import_zod19.z.object({
1894
+ type: import_zod19.z.literal(ActionType.READ)
1895
+ })
1896
+ );
1632
1897
  var CustomAction = ActionBase.merge(
1633
1898
  import_zod19.z.object({
1634
1899
  type: import_zod19.z.literal(ActionType.CUSTOM)
@@ -1639,7 +1904,7 @@ var ActionDocument = import_zod19.z.discriminatedUnion("type", [
1639
1904
  ValidateAction,
1640
1905
  RejectAction,
1641
1906
  MarkAsDuplicateAction,
1642
- ArchivedAction,
1907
+ ArchiveAction,
1643
1908
  NotifiedAction,
1644
1909
  RegisterAction,
1645
1910
  DeclareAction,
@@ -1649,6 +1914,7 @@ var ActionDocument = import_zod19.z.discriminatedUnion("type", [
1649
1914
  RejectedCorrectionAction,
1650
1915
  UnassignedAction,
1651
1916
  PrintCertificateAction,
1917
+ ReadAction,
1652
1918
  CustomAction
1653
1919
  ]);
1654
1920
  var ResolvedUser = import_zod19.z.object({
@@ -1668,7 +1934,6 @@ var import_zod20 = require("zod");
1668
1934
  var BaseActionInput = import_zod20.z.object({
1669
1935
  eventId: import_zod20.z.string(),
1670
1936
  transactionId: import_zod20.z.string(),
1671
- incomplete: import_zod20.z.boolean().optional().default(false).describe("Allows action with partial data to be saved"),
1672
1937
  data: ActionUpdate,
1673
1938
  metadata: ActionUpdate.optional()
1674
1939
  });
@@ -1695,8 +1960,7 @@ var ValidateActionInput = BaseActionInput.merge(
1695
1960
  );
1696
1961
  var NotifyActionInput = BaseActionInput.merge(
1697
1962
  import_zod20.z.object({
1698
- type: import_zod20.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
1699
- createdAtLocation: import_zod20.z.string()
1963
+ type: import_zod20.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
1700
1964
  })
1701
1965
  );
1702
1966
  var DeclareActionInput = BaseActionInput.merge(
@@ -1719,9 +1983,9 @@ var MarkedAsDuplicateActionInput = BaseActionInput.merge(
1719
1983
  type: import_zod20.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
1720
1984
  })
1721
1985
  );
1722
- var ArchivedActionInput = BaseActionInput.merge(
1986
+ var ArchiveActionInput = BaseActionInput.merge(
1723
1987
  import_zod20.z.object({
1724
- type: import_zod20.z.literal(ActionType.ARCHIVED).default(ActionType.ARCHIVED)
1988
+ type: import_zod20.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
1725
1989
  })
1726
1990
  );
1727
1991
  var AssignActionInput = BaseActionInput.merge(
@@ -1752,6 +2016,11 @@ var ApproveCorrectionActionInput = BaseActionInput.merge(
1752
2016
  type: import_zod20.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
1753
2017
  })
1754
2018
  );
2019
+ var ReadActionInput = BaseActionInput.merge(
2020
+ import_zod20.z.object({
2021
+ type: import_zod20.z.literal(ActionType.READ).default(ActionType.READ)
2022
+ })
2023
+ );
1755
2024
  var ActionInput = import_zod20.z.discriminatedUnion("type", [
1756
2025
  CreateActionInput,
1757
2026
  ValidateActionInput,
@@ -1760,13 +2029,14 @@ var ActionInput = import_zod20.z.discriminatedUnion("type", [
1760
2029
  DeclareActionInput,
1761
2030
  RejectDeclarationActionInput,
1762
2031
  MarkedAsDuplicateActionInput,
1763
- ArchivedActionInput,
2032
+ ArchiveActionInput,
1764
2033
  AssignActionInput,
1765
2034
  UnassignActionInput,
1766
2035
  PrintCertificateActionInput,
1767
2036
  RequestCorrectionActionInput,
1768
2037
  RejectCorrectionActionInput,
1769
- ApproveCorrectionActionInput
2038
+ ApproveCorrectionActionInput,
2039
+ ReadActionInput
1770
2040
  ]);
1771
2041
 
1772
2042
  // ../commons/src/events/Draft.ts
@@ -1832,9 +2102,12 @@ function getStatusFromActions(actions) {
1832
2102
  if (action.type === ActionType.REJECT) {
1833
2103
  return EventStatus.REJECTED;
1834
2104
  }
1835
- if (action.type === ActionType.ARCHIVED) {
2105
+ if (action.type === ActionType.ARCHIVE) {
1836
2106
  return EventStatus.ARCHIVED;
1837
2107
  }
2108
+ if (action.type === ActionType.NOTIFY) {
2109
+ return EventStatus.NOTIFIED;
2110
+ }
1838
2111
  return status;
1839
2112
  }, EventStatus.CREATED);
1840
2113
  }
@@ -1901,8 +2174,8 @@ function deepMerge(currentDocument, actionDocument) {
1901
2174
  }
1902
2175
  );
1903
2176
  }
1904
- function isUndeclaredDraft(event2) {
1905
- return event2.actions.every(({ type }) => type === ActionType.CREATE);
2177
+ function isUndeclaredDraft(status) {
2178
+ return status === EventStatus.CREATED;
1906
2179
  }
1907
2180
  function getCurrentEventState(event2) {
1908
2181
  const creationAction = event2.actions.find(
@@ -1927,9 +2200,8 @@ function getCurrentEventState(event2) {
1927
2200
  });
1928
2201
  }
1929
2202
  function getCurrentEventStateWithDrafts(event2, drafts) {
1930
- const actions = event2.actions.slice().sort();
1931
- const lastAction = actions[actions.length - 1];
1932
- const activeDrafts = drafts.filter(({ eventId }) => eventId === event2.id).filter(({ createdAt }) => createdAt > lastAction.createdAt).map((draft) => draft.action).flatMap((action) => {
2203
+ const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
2204
+ const activeDrafts = findActiveDrafts(event2, drafts).map((draft) => draft.action).flatMap((action) => {
1933
2205
  if (action.type === ActionType.REQUEST_CORRECTION) {
1934
2206
  return [
1935
2207
  action,
@@ -1990,12 +2262,6 @@ var defineConfig = (config) => {
1990
2262
  });
1991
2263
  };
1992
2264
 
1993
- // ../commons/src/uuid.ts
1994
- var import_uuid = require("uuid");
1995
- function getUUID() {
1996
- return (0, import_uuid.v4)();
1997
- }
1998
-
1999
2265
  // ../commons/src/events/transactions.ts
2000
2266
  function generateTransactionId() {
2001
2267
  return getUUID();
@@ -2212,6 +2478,23 @@ function field(fieldId) {
2212
2478
  }
2213
2479
  },
2214
2480
  required: ["$form"]
2481
+ }),
2482
+ isValidEnglishName: () => defineConditional({
2483
+ type: "object",
2484
+ properties: {
2485
+ $form: {
2486
+ type: "object",
2487
+ properties: {
2488
+ [fieldId]: {
2489
+ type: "string",
2490
+ 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'._-]*)*$",
2491
+ description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
2492
+ }
2493
+ },
2494
+ required: [fieldId]
2495
+ }
2496
+ },
2497
+ required: ["$form"]
2215
2498
  })
2216
2499
  };
2217
2500
  }
@@ -2838,6 +3121,45 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2838
3121
  type: "FILE"
2839
3122
  }
2840
3123
  ]
3124
+ },
3125
+ {
3126
+ id: "collector.identity.verify",
3127
+ type: FormPageType.VERIFICATION,
3128
+ conditional: field("collector.requesterId").isEqualTo("INFORMANT"),
3129
+ title: {
3130
+ id: "event.tennis-club-membership.action.print.verifyIdentity",
3131
+ defaultMessage: "Verify their identity",
3132
+ description: "This is the title of the section"
3133
+ },
3134
+ fields: [],
3135
+ actions: {
3136
+ verify: {
3137
+ label: {
3138
+ defaultMessage: "Verified",
3139
+ description: "This is the label for the verification button",
3140
+ id: "v2.event.tennis-club-membership.action.certificate.form.verify"
3141
+ }
3142
+ },
3143
+ cancel: {
3144
+ label: {
3145
+ defaultMessage: "Identity does not match",
3146
+ description: "This is the label for the verification cancellation button",
3147
+ id: "v2.event.tennis-club-membership.action.certificate.form.cancel"
3148
+ },
3149
+ confirmation: {
3150
+ title: {
3151
+ defaultMessage: "Print without proof of ID?",
3152
+ description: "This is the title for the verification cancellation modal",
3153
+ id: "v2.event.tennis-club-membership.action.certificate.form.cancel.confirmation.title"
3154
+ },
3155
+ body: {
3156
+ 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",
3157
+ description: "This is the body for the verification cancellation modal",
3158
+ id: "v2.event.tennis-club-membership.action.certificate.form.cancel.confirmation.body"
3159
+ }
3160
+ }
3161
+ }
3162
+ }
2841
3163
  }
2842
3164
  ],
2843
3165
  review: {
@@ -2982,6 +3304,27 @@ var TENNIS_CLUB_FORM = defineForm({
2982
3304
  }
2983
3305
  ]
2984
3306
  },
3307
+ {
3308
+ id: "senior-pass",
3309
+ conditional: field("applicant.dob").isBefore().date("1950-01-01"),
3310
+ title: {
3311
+ id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.title",
3312
+ defaultMessage: "Assign senior pass for applicant",
3313
+ description: "This is the title of the section"
3314
+ },
3315
+ fields: [
3316
+ {
3317
+ id: "senior-pass.id",
3318
+ type: "TEXT",
3319
+ required: true,
3320
+ label: {
3321
+ defaultMessage: "Senior pass ID",
3322
+ description: "This is the label for the field",
3323
+ id: "v2.event.tennis-club-membership.action.declare.form.section.senior-pass.field.id.label"
3324
+ }
3325
+ }
3326
+ ]
3327
+ },
2985
3328
  {
2986
3329
  id: "recommender",
2987
3330
  title: {
@@ -3415,6 +3758,24 @@ var tennisClubMembershipEvent = defineConfig({
3415
3758
  })
3416
3759
  }
3417
3760
  ]
3761
+ },
3762
+ {
3763
+ type: ActionType.ARCHIVE,
3764
+ label: {
3765
+ id: "v2.event.tennis-club-membership.action.archive.label",
3766
+ defaultMessage: "Archive",
3767
+ description: "This is shown as the action name anywhere the user can trigger the action from"
3768
+ },
3769
+ forms: [TENNIS_CLUB_FORM]
3770
+ },
3771
+ {
3772
+ type: ActionType.REJECT,
3773
+ label: {
3774
+ id: "v2.event.tennis-club-membership.action.reject.label",
3775
+ defaultMessage: "Reject",
3776
+ description: "This is shown as the action name anywhere the user can trigger the action from"
3777
+ },
3778
+ forms: [TENNIS_CLUB_FORM]
3418
3779
  }
3419
3780
  ],
3420
3781
  advancedSearch: [
@@ -3445,6 +3806,19 @@ function generateActionInput(configuration, action) {
3445
3806
  );
3446
3807
  return stripHiddenFields(fields, data);
3447
3808
  }
3809
+ function generateActionMetadataInput(configuration, action) {
3810
+ const visibleVerificationPageIds = getActiveActionFormPages(
3811
+ configuration,
3812
+ action
3813
+ ).filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page, {})).map((page) => page.id);
3814
+ return visibleVerificationPageIds.reduce(
3815
+ (acc, pageId) => ({
3816
+ ...acc,
3817
+ [pageId]: true
3818
+ }),
3819
+ {}
3820
+ );
3821
+ }
3448
3822
  var eventPayloadGenerator = {
3449
3823
  create: (input = {}) => ({
3450
3824
  transactionId: input.transactionId ?? getUUID(),
@@ -3495,9 +3869,9 @@ var eventPayloadGenerator = {
3495
3869
  eventId
3496
3870
  }),
3497
3871
  archive: (eventId, input = {}, isDuplicate) => ({
3498
- type: ActionType.ARCHIVED,
3872
+ type: ActionType.ARCHIVE,
3499
3873
  transactionId: input.transactionId ?? getUUID(),
3500
- data: input.data ?? {},
3874
+ data: input.data ?? generateActionInput(tennisClubMembershipEvent, ActionType.ARCHIVE),
3501
3875
  metadata: { isDuplicate: isDuplicate ?? false },
3502
3876
  duplicates: [],
3503
3877
  eventId
@@ -3505,7 +3879,7 @@ var eventPayloadGenerator = {
3505
3879
  reject: (eventId, input = {}) => ({
3506
3880
  type: ActionType.REJECT,
3507
3881
  transactionId: input.transactionId ?? getUUID(),
3508
- data: input.data ?? {},
3882
+ data: input.data ?? generateActionInput(tennisClubMembershipEvent, ActionType.REJECT),
3509
3883
  duplicates: [],
3510
3884
  eventId
3511
3885
  }),
@@ -3522,6 +3896,10 @@ var eventPayloadGenerator = {
3522
3896
  tennisClubMembershipEvent,
3523
3897
  ActionType.PRINT_CERTIFICATE
3524
3898
  ),
3899
+ metadata: input.metadata ?? generateActionMetadataInput(
3900
+ tennisClubMembershipEvent,
3901
+ ActionType.PRINT_CERTIFICATE
3902
+ ),
3525
3903
  eventId
3526
3904
  }),
3527
3905
  correction: {
@@ -3564,7 +3942,9 @@ function generateActionDocument({
3564
3942
  defaults = {}
3565
3943
  }) {
3566
3944
  const actionBase = {
3567
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
3945
+ // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
3946
+ // @TODO: This should be fixed in the future.
3947
+ createdAt: new Date(Date.now() - 500).toISOString(),
3568
3948
  createdBy: getUUID(),
3569
3949
  id: getUUID(),
3570
3950
  createdAtLocation: "TODO",
@@ -3581,7 +3961,7 @@ function generateActionDocument({
3581
3961
  return { ...actionBase, assignedTo: getUUID(), type: action };
3582
3962
  case ActionType.VALIDATE:
3583
3963
  return { ...actionBase, type: action };
3584
- case ActionType.ARCHIVED:
3964
+ case ActionType.ARCHIVE:
3585
3965
  return { ...actionBase, type: action };
3586
3966
  case ActionType.REJECT:
3587
3967
  return { ...actionBase, type: action };
@@ -3619,9 +3999,13 @@ function generateEventDocument({
3619
3999
  actions: actions.map(
3620
4000
  (action) => generateActionDocument({ configuration, action })
3621
4001
  ),
3622
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4002
+ // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
4003
+ // @TODO: This should be fixed in the future.
4004
+ createdAt: new Date(Date.now() - 1e3).toISOString(),
3623
4005
  id: getUUID(),
3624
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
4006
+ // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
4007
+ // @TODO: This should be fixed in the future.
4008
+ updatedAt: new Date(Date.now() - 1e3).toISOString()
3625
4009
  };
3626
4010
  }
3627
4011
  function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, data = {}) {
@@ -3661,6 +4045,11 @@ var eventQueryDataGenerator = (overrides = {}) => ({
3661
4045
  },
3662
4046
  trackingId: overrides.trackingId ?? "M3F8YQ"
3663
4047
  });
4048
+ var generateTranslationConfig = (message) => ({
4049
+ defaultMessage: message,
4050
+ description: "Description for ${message}",
4051
+ id: message
4052
+ });
3664
4053
 
3665
4054
  // ../commons/src/events/TemplateConfig.ts
3666
4055
  function isTemplateVariable(value) {
@@ -3678,7 +4067,7 @@ function isFieldValueWithoutTemplates(value) {
3678
4067
  }
3679
4068
  return true;
3680
4069
  }
3681
- function isDefaultValue(value) {
4070
+ function isFieldConfigDefaultValue(value) {
3682
4071
  if (!value) return false;
3683
4072
  if (isFieldValue(value)) {
3684
4073
  return true;
@@ -3687,7 +4076,7 @@ function isDefaultValue(value) {
3687
4076
  return true;
3688
4077
  }
3689
4078
  if (typeof value === "object" && Object.values(value).every((v) => typeof v === "object" && v !== null)) {
3690
- return Object.values(value).every((v) => isDefaultValue(v));
4079
+ return Object.values(value).every((v) => isFieldConfigDefaultValue(v));
3691
4080
  }
3692
4081
  return false;
3693
4082
  }