@opencrvs/toolkit 1.8.0-rc.f8f3eb3 → 1.8.0-rc.f9911ed

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,9 +78,16 @@ __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,
@@ -96,16 +106,21 @@ __export(events_exports, {
96
106
  UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
97
107
  UrbanAddressValue: () => UrbanAddressValue,
98
108
  ValidateActionInput: () => ValidateActionInput,
109
+ VerificationPage: () => VerificationPage,
110
+ VerificationPageConfig: () => VerificationPageConfig,
99
111
  WorkqueueConfig: () => WorkqueueConfig,
100
112
  alwaysTrue: () => alwaysTrue,
101
113
  and: () => and,
102
114
  applyDraftsToEventIndex: () => applyDraftsToEventIndex,
115
+ compositeFieldTypes: () => compositeFieldTypes,
116
+ createEmptyDraft: () => createEmptyDraft,
103
117
  createValidationSchema: () => createValidationSchema,
104
118
  deepDropNulls: () => deepDropNulls,
105
119
  defineConditional: () => defineConditional,
106
120
  defineConfig: () => defineConfig,
107
121
  defineForm: () => defineForm,
108
122
  defineFormPage: () => defineFormPage,
123
+ errorMessages: () => errorMessages,
109
124
  event: () => event,
110
125
  eventMetadataLabelMap: () => eventMetadataLabelMap,
111
126
  eventPayloadGenerator: () => eventPayloadGenerator,
@@ -117,14 +132,19 @@ __export(events_exports, {
117
132
  findActiveActionForm: () => findActiveActionForm,
118
133
  findActiveActionFormFields: () => findActiveActionFormFields,
119
134
  findActiveActionFormPages: () => findActiveActionFormPages,
135
+ findActiveActionVerificationPageIds: () => findActiveActionVerificationPageIds,
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,
@@ -138,11 +158,15 @@ __export(events_exports, {
138
158
  isBulletListFieldType: () => isBulletListFieldType,
139
159
  isCheckboxFieldType: () => isCheckboxFieldType,
140
160
  isCountryFieldType: () => isCountryFieldType,
161
+ isDataFieldType: () => isDataFieldType,
141
162
  isDateFieldType: () => isDateFieldType,
142
163
  isDividerFieldType: () => isDividerFieldType,
143
164
  isEmailFieldType: () => isEmailFieldType,
144
165
  isFacilityFieldType: () => isFacilityFieldType,
166
+ isFieldConfigDefaultValue: () => isFieldConfigDefaultValue,
145
167
  isFieldEnabled: () => isFieldEnabled,
168
+ isFieldValue: () => isFieldValue,
169
+ isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
146
170
  isFieldVisible: () => isFieldVisible,
147
171
  isFileFieldType: () => isFileFieldType,
148
172
  isFileFieldWithOptionType: () => isFileFieldWithOptionType,
@@ -154,9 +178,11 @@ __export(events_exports, {
154
178
  isRadioGroupFieldType: () => isRadioGroupFieldType,
155
179
  isSelectFieldType: () => isSelectFieldType,
156
180
  isSignatureFieldType: () => isSignatureFieldType,
181
+ isTemplateVariable: () => isTemplateVariable,
157
182
  isTextAreaFieldType: () => isTextAreaFieldType,
158
183
  isTextFieldType: () => isTextFieldType,
159
184
  isUndeclaredDraft: () => isUndeclaredDraft,
185
+ mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
160
186
  mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
161
187
  mapFieldTypeToZod: () => mapFieldTypeToZod,
162
188
  not: () => not,
@@ -240,9 +266,15 @@ var FieldType = {
240
266
  ADMINISTRATIVE_AREA: "ADMINISTRATIVE_AREA",
241
267
  FACILITY: "FACILITY",
242
268
  OFFICE: "OFFICE",
243
- SIGNATURE: "SIGNATURE"
269
+ SIGNATURE: "SIGNATURE",
270
+ DATA: "DATA"
244
271
  };
245
272
  var fieldTypes = Object.values(FieldType);
273
+ var compositeFieldTypes = [
274
+ FieldType.ADDRESS,
275
+ FieldType.FILE_WITH_OPTIONS,
276
+ FieldType.FILE
277
+ ];
246
278
 
247
279
  // ../commons/src/events/FieldValue.ts
248
280
  var import_zod4 = require("zod");
@@ -253,6 +285,10 @@ var GeographicalArea = {
253
285
  URBAN: "URBAN",
254
286
  RURAL: "RURAL"
255
287
  };
288
+ var AddressType = {
289
+ DOMESTIC: "DOMESTIC",
290
+ INTERNATIONAL: "INTERNATIONAL"
291
+ };
256
292
  var FileFieldValue = import_zod3.z.object({
257
293
  filename: import_zod3.z.string(),
258
294
  originalFilename: import_zod3.z.string(),
@@ -260,6 +296,7 @@ var FileFieldValue = import_zod3.z.object({
260
296
  });
261
297
  var AdminStructure = import_zod3.z.object({
262
298
  country: import_zod3.z.string(),
299
+ addressType: import_zod3.z.literal(AddressType.DOMESTIC),
263
300
  province: import_zod3.z.string(),
264
301
  district: import_zod3.z.string()
265
302
  });
@@ -287,14 +324,33 @@ var RuralAddressUpdateValue = AdminStructure.extend({
287
324
  urbanOrRural: import_zod3.z.literal(GeographicalArea.RURAL),
288
325
  village: import_zod3.z.string().nullish()
289
326
  });
290
- var AddressFieldValue = import_zod3.z.discriminatedUnion("urbanOrRural", [
291
- UrbanAddressValue,
292
- RuralAddressValue
293
- ]);
327
+ var GenericAddressValue = import_zod3.z.object({
328
+ country: import_zod3.z.string(),
329
+ addressType: import_zod3.z.literal(AddressType.INTERNATIONAL),
330
+ state: import_zod3.z.string(),
331
+ district2: import_zod3.z.string(),
332
+ cityOrTown: import_zod3.z.string().optional(),
333
+ addressLine1: import_zod3.z.string().optional(),
334
+ addressLine2: import_zod3.z.string().optional(),
335
+ addressLine3: import_zod3.z.string().optional(),
336
+ postcodeOrZip: import_zod3.z.string().optional()
337
+ });
338
+ var AddressFieldValue = import_zod3.z.discriminatedUnion("urbanOrRural", [UrbanAddressValue, RuralAddressValue]).or(GenericAddressValue);
339
+ var GenericAddressUpdateValue = import_zod3.z.object({
340
+ country: import_zod3.z.string(),
341
+ addressType: import_zod3.z.literal(AddressType.INTERNATIONAL),
342
+ state: import_zod3.z.string(),
343
+ district2: import_zod3.z.string(),
344
+ cityOrTown: import_zod3.z.string().nullish(),
345
+ addressLine1: import_zod3.z.string().nullish(),
346
+ addressLine2: import_zod3.z.string().nullish(),
347
+ addressLine3: import_zod3.z.string().nullish(),
348
+ postcodeOrZip: import_zod3.z.string().nullish()
349
+ });
294
350
  var AddressFieldUpdateValue = import_zod3.z.discriminatedUnion("urbanOrRural", [
295
351
  UrbanAddressUpdateValue,
296
352
  RuralAddressUpdateValue
297
- ]);
353
+ ]).or(GenericAddressUpdateValue);
298
354
  var FileFieldValueWithOption = import_zod3.z.object({
299
355
  filename: import_zod3.z.string(),
300
356
  originalFilename: import_zod3.z.string(),
@@ -310,6 +366,7 @@ var DateValue = import_zod4.z.string().date().describe("Date in the format YYYY-
310
366
  var EmailValue = import_zod4.z.string().email();
311
367
  var CheckboxFieldValue = import_zod4.z.boolean();
312
368
  var NumberFieldValue = import_zod4.z.number();
369
+ var DataFieldValue = import_zod4.z.undefined();
313
370
  var FieldValue = import_zod4.z.union([
314
371
  TextValue,
315
372
  DateValue,
@@ -318,7 +375,9 @@ var FieldValue = import_zod4.z.union([
318
375
  FileFieldValue,
319
376
  FileFieldWithOptionValue,
320
377
  UrbanAddressValue,
321
- RuralAddressValue
378
+ RuralAddressValue,
379
+ DataFieldValue,
380
+ GenericAddressValue
322
381
  ]);
323
382
  var FieldUpdateValue = import_zod4.z.union([
324
383
  TextValue,
@@ -328,7 +387,9 @@ var FieldUpdateValue = import_zod4.z.union([
328
387
  FileFieldValue,
329
388
  FileFieldWithOptionValue,
330
389
  UrbanAddressUpdateValue,
331
- RuralAddressUpdateValue
390
+ RuralAddressUpdateValue,
391
+ DataFieldValue,
392
+ GenericAddressUpdateValue
332
393
  ]);
333
394
 
334
395
  // ../commons/src/events/FieldConfig.ts
@@ -399,15 +460,25 @@ var TextAreaField = BaseField.extend({
399
460
  postfix: TranslationConfig.optional()
400
461
  }).default({ rows: 4 }).optional()
401
462
  }).describe("Multiline text input");
463
+ var ImageMimeType = import_zod5.z.enum([
464
+ "image/png",
465
+ "image/jpg",
466
+ "image/jpeg",
467
+ "image/svg+xml"
468
+ ]);
469
+ var MimeType = ImageMimeType;
470
+ var DEFAULT_MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;
402
471
  var SignatureField = BaseField.extend({
403
472
  type: import_zod5.z.literal(FieldType.SIGNATURE),
404
473
  signaturePromptLabel: TranslationConfig.describe(
405
474
  "Title of the signature modal"
406
475
  ),
407
476
  configuration: import_zod5.z.object({
408
- maxSizeMb: import_zod5.z.number().optional().describe("Maximum file size in MB"),
409
- allowedFileFormats: import_zod5.z.array(import_zod5.z.string()).optional().describe("List of allowed file formats for the signature")
410
- }).default({}).optional()
477
+ maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
478
+ acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
479
+ }).default({
480
+ maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
481
+ })
411
482
  }).describe("Signature input field");
412
483
  var EmailField = BaseField.extend({
413
484
  type: import_zod5.z.literal(FieldType.EMAIL),
@@ -450,13 +521,17 @@ var PageHeader = BaseField.extend({
450
521
  }).describe("A read-only header component for form pages");
451
522
  var File = BaseField.extend({
452
523
  type: import_zod5.z.literal(FieldType.FILE),
453
- options: import_zod5.z.object({
524
+ configuration: import_zod5.z.object({
525
+ maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
526
+ acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
454
527
  style: import_zod5.z.object({
455
- fullWidth: import_zod5.z.boolean().describe(
528
+ width: import_zod5.z.enum(["full", "auto"]).optional().describe(
456
529
  "Whether the file upload button should take the full width of the container or not"
457
530
  )
458
- })
459
- }).optional()
531
+ }).optional()
532
+ }).default({
533
+ maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
534
+ })
460
535
  }).describe("File upload");
461
536
  var SelectOption = import_zod5.z.object({
462
537
  value: import_zod5.z.string().describe("The value of the option"),
@@ -495,11 +570,16 @@ var Country = BaseField.extend({
495
570
  type: import_zod5.z.literal(FieldType.COUNTRY),
496
571
  defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
497
572
  }).describe("Country select field");
573
+ var AdministrativeAreas = import_zod5.z.enum([
574
+ "ADMIN_STRUCTURE",
575
+ "HEALTH_FACILITY",
576
+ "CRVS_OFFICE"
577
+ ]);
498
578
  var AdministrativeAreaConfiguration = import_zod5.z.object({
499
579
  partOf: import_zod5.z.object({
500
580
  $data: import_zod5.z.string()
501
581
  }).optional().describe("Parent location"),
502
- type: import_zod5.z.enum(["ADMIN_STRUCTURE", "HEALTH_FACILITY", "CRVS_OFFICE"])
582
+ type: AdministrativeAreas
503
583
  }).describe("Administrative area options");
504
584
  var AdministrativeArea = BaseField.extend({
505
585
  type: import_zod5.z.literal(FieldType.ADMINISTRATIVE_AREA),
@@ -512,8 +592,14 @@ var Location = BaseField.extend({
512
592
  }).describe("Input field for a location");
513
593
  var FileUploadWithOptions = BaseField.extend({
514
594
  type: import_zod5.z.literal(FieldType.FILE_WITH_OPTIONS),
515
- options: import_zod5.z.array(SelectOption).describe("A list of options")
516
- }).describe("Select input");
595
+ options: import_zod5.z.array(SelectOption).describe("A list of options"),
596
+ configuration: import_zod5.z.object({
597
+ maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
598
+ acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
599
+ }).default({
600
+ maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
601
+ })
602
+ });
517
603
  var Facility = BaseField.extend({
518
604
  type: import_zod5.z.literal(FieldType.FACILITY),
519
605
  defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
@@ -526,6 +612,13 @@ var Address = BaseField.extend({
526
612
  type: import_zod5.z.literal(FieldType.ADDRESS),
527
613
  defaultValue: AddressFieldValue.optional()
528
614
  }).describe("Address input field \u2013 a combination of location and text fields");
615
+ var DataField = BaseField.extend({
616
+ type: import_zod5.z.literal(FieldType.DATA),
617
+ configuration: import_zod5.z.object({
618
+ subtitle: TranslationConfig.optional(),
619
+ data: import_zod5.z.array(import_zod5.z.object({ fieldId: import_zod5.z.string() }))
620
+ })
621
+ }).describe("Data field for displaying read-only data");
529
622
  var FieldConfig = import_zod5.z.discriminatedUnion("type", [
530
623
  Address,
531
624
  TextField,
@@ -547,15 +640,43 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
547
640
  Office,
548
641
  SignatureField,
549
642
  EmailField,
550
- FileUploadWithOptions
643
+ FileUploadWithOptions,
644
+ DataField
551
645
  ]);
552
646
 
553
647
  // ../commons/src/events/FormConfig.ts
648
+ var FormPageType = {
649
+ FORM: "FORM",
650
+ VERIFICATION: "VERIFICATION"
651
+ };
554
652
  var FormPage = import_zod6.z.object({
555
653
  id: import_zod6.z.string().describe("Unique identifier for the page"),
556
654
  title: TranslationConfig.describe("Header title of the page"),
557
- fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page")
655
+ fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page"),
656
+ type: import_zod6.z.literal(FormPageType.FORM).default(FormPageType.FORM)
657
+ });
658
+ var VerificationPageConfig = import_zod6.z.object({
659
+ verify: import_zod6.z.object({ label: TranslationConfig }),
660
+ cancel: import_zod6.z.object({
661
+ label: TranslationConfig,
662
+ confirmation: import_zod6.z.object({
663
+ title: TranslationConfig,
664
+ body: TranslationConfig
665
+ })
666
+ })
667
+ }).describe("Actions available on the verification page");
668
+ var VerificationPage = FormPage.extend({
669
+ type: import_zod6.z.literal(FormPageType.VERIFICATION),
670
+ actions: VerificationPageConfig
558
671
  });
672
+ var FormPageConfig = import_zod6.z.preprocess(
673
+ (pageConfig) => ({
674
+ ...pageConfig,
675
+ type: pageConfig.type ?? FormPageType.FORM
676
+ // Default type to "FORM" if not provided
677
+ }),
678
+ import_zod6.z.discriminatedUnion("type", [FormPage, VerificationPage])
679
+ );
559
680
  var FormConfig = import_zod6.z.object({
560
681
  label: TranslationConfig.describe("Human readable description of the form"),
561
682
  version: import_zod6.z.object({
@@ -567,7 +688,7 @@ var FormConfig = import_zod6.z.object({
567
688
  )
568
689
  }),
569
690
  active: import_zod6.z.boolean().default(false).describe("Whether the form is active"),
570
- pages: import_zod6.z.array(FormPage),
691
+ pages: import_zod6.z.array(FormPageConfig),
571
692
  review: import_zod6.z.object({
572
693
  title: TranslationConfig.describe(
573
694
  "Title of the form to show in review page"
@@ -594,8 +715,9 @@ var ActionType = {
594
715
  CUSTOM: "CUSTOM",
595
716
  REJECT: "REJECT",
596
717
  MARKED_AS_DUPLICATE: "MARKED_AS_DUPLICATE",
597
- ARCHIVED: "ARCHIVED"
718
+ ARCHIVE: "ARCHIVE"
598
719
  };
720
+ var LatentActions = [ActionType.ARCHIVE, ActionType.REJECT];
599
721
 
600
722
  // ../commons/src/events/ActionConfig.ts
601
723
  var ActionConditional2 = import_zod7.z.discriminatedUnion("type", [
@@ -622,23 +744,17 @@ var ValidateConfig = ActionConfigBase.merge(
622
744
  );
623
745
  var RejectDeclarationConfig = ActionConfigBase.merge(
624
746
  import_zod7.z.object({
625
- type: import_zod7.z.literal(ActionType.REJECT),
626
- comment: import_zod7.z.string(),
627
- isDuplicate: import_zod7.z.boolean()
747
+ type: import_zod7.z.literal(ActionType.REJECT)
628
748
  })
629
749
  );
630
750
  var MarkedAsDuplicateConfig = ActionConfigBase.merge(
631
751
  import_zod7.z.object({
632
- type: import_zod7.z.literal(ActionType.MARKED_AS_DUPLICATE),
633
- comment: import_zod7.z.string(),
634
- duplicates: import_zod7.z.array(import_zod7.z.string()).describe("UUIDs of duplicate records")
752
+ type: import_zod7.z.literal(ActionType.MARKED_AS_DUPLICATE)
635
753
  })
636
754
  );
637
- var ArchivedConfig = ActionConfigBase.merge(
755
+ var ArchiveConfig = ActionConfigBase.merge(
638
756
  import_zod7.z.object({
639
- type: import_zod7.z.literal(ActionType.ARCHIVED),
640
- comment: import_zod7.z.string(),
641
- isDuplicate: import_zod7.z.boolean()
757
+ type: import_zod7.z.literal(ActionType.ARCHIVE)
642
758
  })
643
759
  );
644
760
  var RegisterConfig = ActionConfigBase.merge(
@@ -659,8 +775,8 @@ var PrintCertificateActionConfig = ActionConfigBase.merge(
659
775
  var RequestCorrectionConfig = ActionConfigBase.merge(
660
776
  import_zod7.z.object({
661
777
  type: import_zod7.z.literal(ActionType.REQUEST_CORRECTION),
662
- onboardingForm: import_zod7.z.array(FormPage),
663
- additionalDetailsForm: import_zod7.z.array(FormPage)
778
+ onboardingForm: import_zod7.z.array(FormPageConfig),
779
+ additionalDetailsForm: import_zod7.z.array(FormPageConfig)
664
780
  })
665
781
  );
666
782
  var RejectCorrectionConfig = ActionConfigBase.merge(
@@ -683,7 +799,7 @@ var ActionConfig = import_zod7.z.discriminatedUnion("type", [
683
799
  ValidateConfig,
684
800
  RejectDeclarationConfig,
685
801
  MarkedAsDuplicateConfig,
686
- ArchivedConfig,
802
+ ArchiveConfig,
687
803
  RegisterConfig,
688
804
  DeleteConfig,
689
805
  PrintCertificateActionConfig,
@@ -1102,6 +1218,9 @@ function mapFieldTypeToZod(type, required) {
1102
1218
  case FieldType.ADDRESS:
1103
1219
  schema = AddressFieldUpdateValue;
1104
1220
  break;
1221
+ case FieldType.DATA:
1222
+ schema = DataFieldValue;
1223
+ break;
1105
1224
  }
1106
1225
  return required ? schema : schema.nullish();
1107
1226
  }
@@ -1136,6 +1255,7 @@ function mapFieldTypeToMockValue(field2, i) {
1136
1255
  case FieldType.ADDRESS:
1137
1256
  return {
1138
1257
  country: "FAR",
1258
+ addressType: AddressType.DOMESTIC,
1139
1259
  province: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
1140
1260
  district: "5ef450bc-712d-48ad-93f3-8da0fa453baa",
1141
1261
  urbanOrRural: "URBAN",
@@ -1157,6 +1277,54 @@ function mapFieldTypeToMockValue(field2, i) {
1157
1277
  };
1158
1278
  case FieldType.FILE_WITH_OPTIONS:
1159
1279
  return null;
1280
+ case FieldType.DATA:
1281
+ return {};
1282
+ }
1283
+ }
1284
+ function mapFieldTypeToEmptyValue(field2) {
1285
+ switch (field2.type) {
1286
+ case FieldType.DIVIDER:
1287
+ case FieldType.TEXT:
1288
+ case FieldType.TEXTAREA:
1289
+ case FieldType.BULLET_LIST:
1290
+ case FieldType.PAGE_HEADER:
1291
+ case FieldType.LOCATION:
1292
+ case FieldType.SELECT:
1293
+ case FieldType.COUNTRY:
1294
+ case FieldType.RADIO_GROUP:
1295
+ case FieldType.SIGNATURE:
1296
+ case FieldType.PARAGRAPH:
1297
+ case FieldType.ADMINISTRATIVE_AREA:
1298
+ case FieldType.FACILITY:
1299
+ case FieldType.OFFICE:
1300
+ case FieldType.NUMBER:
1301
+ case FieldType.EMAIL:
1302
+ case FieldType.DATE:
1303
+ case FieldType.CHECKBOX:
1304
+ case FieldType.DATA:
1305
+ return null;
1306
+ case FieldType.ADDRESS:
1307
+ return {
1308
+ country: null,
1309
+ addressType: AddressType.DOMESTIC,
1310
+ province: null,
1311
+ district: null,
1312
+ urbanOrRural: "URBAN",
1313
+ // Default to urban needed for validation
1314
+ town: null,
1315
+ residentialArea: null,
1316
+ street: null,
1317
+ number: null,
1318
+ zipCode: null
1319
+ };
1320
+ case FieldType.FILE:
1321
+ return {
1322
+ filename: "",
1323
+ originalFilename: "",
1324
+ type: ""
1325
+ };
1326
+ case FieldType.FILE_WITH_OPTIONS:
1327
+ return [];
1160
1328
  }
1161
1329
  }
1162
1330
  var isParagraphFieldType = (field2) => {
@@ -1222,6 +1390,9 @@ var isFacilityFieldType = (field2) => {
1222
1390
  var isOfficeFieldType = (field2) => {
1223
1391
  return field2.config.type === FieldType.OFFICE;
1224
1392
  };
1393
+ var isDataFieldType = (field2) => {
1394
+ return field2.config.type === FieldType.DATA;
1395
+ };
1225
1396
 
1226
1397
  // ../commons/src/conditionals/validate.ts
1227
1398
  var ajv = new import_ajv.default({
@@ -1258,49 +1429,76 @@ function isFieldVisible(field2, form) {
1258
1429
  function isFieldEnabled(field2, form) {
1259
1430
  return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
1260
1431
  }
1432
+ var errorMessages = {
1433
+ hiddenField: {
1434
+ id: "v2.error.hidden",
1435
+ defaultMessage: "Hidden or disabled field should not receive a value",
1436
+ description: "Error message when field is hidden or disabled, but a value was received"
1437
+ },
1438
+ invalidDate: {
1439
+ defaultMessage: "Invalid date field",
1440
+ description: "Error message when date field is invalid",
1441
+ id: "v2.error.invalidDate"
1442
+ },
1443
+ invalidEmail: {
1444
+ defaultMessage: "Invalid email address",
1445
+ description: "Error message when email address is invalid",
1446
+ id: "v2.error.invalidEmail"
1447
+ },
1448
+ requiredField: {
1449
+ defaultMessage: "Required for registration",
1450
+ description: "Error message when required field is missing",
1451
+ id: "v2.error.required"
1452
+ },
1453
+ invalidInput: {
1454
+ defaultMessage: "Invalid input",
1455
+ description: "Error message when generic field is invalid",
1456
+ id: "v2.error.invalid"
1457
+ }
1458
+ };
1459
+ var createIntlError = (message) => ({
1460
+ message: {
1461
+ message
1462
+ }
1463
+ });
1261
1464
  var zodToIntlErrorMap = (issue, _ctx) => {
1262
- if (issue.code === "invalid_string" && issue.validation === "date") {
1263
- return {
1264
- message: {
1265
- message: {
1266
- defaultMessage: "Invalid date. Please use the format YYYY-MM-DD",
1267
- description: "This is the error message for invalid date fields",
1268
- id: "v2.error.invalidDate"
1269
- }
1465
+ switch (issue.code) {
1466
+ case "invalid_string": {
1467
+ if (_ctx.data === "") {
1468
+ return createIntlError(errorMessages.requiredField);
1270
1469
  }
1271
- };
1272
- }
1273
- if (issue.code === "invalid_string" && issue.validation === "email") {
1274
- return {
1275
- message: {
1276
- message: {
1277
- defaultMessage: "Invalid email address",
1278
- description: "This is the error message for invalid email fields",
1279
- id: "v2.error.invalidEmail"
1280
- }
1470
+ if (issue.validation === "date") {
1471
+ return createIntlError(errorMessages.invalidDate);
1281
1472
  }
1282
- };
1283
- }
1284
- if (issue.code === "invalid_type" && issue.expected !== issue.received && issue.received === "undefined" || issue.code === "too_small" && issue.message === void 0) {
1285
- return {
1286
- message: {
1287
- message: {
1288
- defaultMessage: "Required for registration",
1289
- description: "This is the error message for required fields",
1290
- id: "v2.error.required"
1291
- }
1473
+ if (issue.validation === "email") {
1474
+ return createIntlError(errorMessages.invalidEmail);
1292
1475
  }
1293
- };
1294
- }
1295
- return {
1296
- message: {
1297
- message: {
1298
- defaultMessage: "Invalid input",
1299
- description: "This is the error message for invalid field value",
1300
- id: "v2.error.invalid"
1476
+ break;
1477
+ }
1478
+ case "invalid_type": {
1479
+ if (issue.expected !== issue.received && issue.received === "undefined") {
1480
+ return createIntlError(errorMessages.requiredField);
1301
1481
  }
1482
+ break;
1302
1483
  }
1303
- };
1484
+ case "too_small": {
1485
+ if (issue.message === void 0) {
1486
+ return createIntlError(errorMessages.requiredField);
1487
+ }
1488
+ break;
1489
+ }
1490
+ case "invalid_union": {
1491
+ for (const { issues } of issue.unionErrors) {
1492
+ for (const e of issues) {
1493
+ if (zodToIntlErrorMap(e, _ctx).message.message.id !== "v2.error.required") {
1494
+ return createIntlError(errorMessages.invalidInput);
1495
+ }
1496
+ }
1497
+ }
1498
+ return createIntlError(errorMessages.requiredField);
1499
+ }
1500
+ }
1501
+ return createIntlError(errorMessages.invalidInput);
1304
1502
  };
1305
1503
  function getFieldValidationErrors({
1306
1504
  field: field2,
@@ -1315,11 +1513,7 @@ function getFieldValidationErrors({
1315
1513
  return {
1316
1514
  errors: [
1317
1515
  {
1318
- message: {
1319
- id: "v2.error.hidden",
1320
- defaultMessage: "Hidden or disabled field should not receive a value",
1321
- description: "Error message when field is hidden or disabled, but a value was received"
1322
- }
1516
+ message: errorMessages.hiddenField
1323
1517
  }
1324
1518
  ]
1325
1519
  };
@@ -1337,8 +1531,8 @@ function getFieldValidationErrors({
1337
1531
  conditionalParameters
1338
1532
  });
1339
1533
  return {
1340
- // Assumes that custom validation errors are more important than field validation errors
1341
- errors: [...customValidationResults, ...fieldValidationResult]
1534
+ // Assumes that custom validation errors are based on the field type, and extend the validation.
1535
+ errors: [...fieldValidationResult, ...customValidationResults]
1342
1536
  };
1343
1537
  }
1344
1538
  function runCustomFieldValidations({
@@ -1363,6 +1557,20 @@ function validateFieldInput({
1363
1557
  return rawError.error?.issues.map((issue) => issue.message) ?? [];
1364
1558
  }
1365
1559
 
1560
+ // ../commons/src/utils.ts
1561
+ function getOrThrow(x, message) {
1562
+ if (x === void 0 || x === null) {
1563
+ throw new Error(message);
1564
+ }
1565
+ return x;
1566
+ }
1567
+
1568
+ // ../commons/src/uuid.ts
1569
+ var import_uuid = require("uuid");
1570
+ function getUUID() {
1571
+ return (0, import_uuid.v4)();
1572
+ }
1573
+
1366
1574
  // ../commons/src/events/utils.ts
1367
1575
  function isMetadataField(field2) {
1368
1576
  return field2 in eventMetadataLabelMap;
@@ -1432,7 +1640,7 @@ function validateWorkqueueConfig(workqueueConfigs) {
1432
1640
  );
1433
1641
  if (!rootWorkqueue) {
1434
1642
  throw new Error(
1435
- `Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
1643
+ `Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
1436
1644
  );
1437
1645
  }
1438
1646
  });
@@ -1459,7 +1667,16 @@ var findActiveActionFields = (configuration, action) => {
1459
1667
  const allFields = formFields ? formFields.concat(reviewFields ?? []) : reviewFields;
1460
1668
  return allFields;
1461
1669
  };
1670
+ var getActiveActionFormPages = (configuration, action) => {
1671
+ return getOrThrow(
1672
+ findActiveActionForm(configuration, action)?.pages,
1673
+ "Form configuration not found for type: " + configuration.id
1674
+ );
1675
+ };
1462
1676
  function getActiveActionFields(configuration, action) {
1677
+ if (LatentActions.some((latentAction) => latentAction === action)) {
1678
+ return getActiveActionFields(configuration, ActionType.DECLARE);
1679
+ }
1463
1680
  const fields = findActiveActionFields(configuration, action);
1464
1681
  if (!fields) {
1465
1682
  throw new Error(`No active field config found for action type ${action}`);
@@ -1491,6 +1708,34 @@ function stripHiddenFields(fields, data) {
1491
1708
  return !isFieldVisible(field2, data);
1492
1709
  });
1493
1710
  }
1711
+ function findActiveDrafts(event2, drafts) {
1712
+ const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
1713
+ const lastAction = actions[actions.length - 1];
1714
+ return drafts.filter(({ createdAt }) => createdAt >= lastAction.createdAt).filter(({ eventId }) => eventId === event2.id);
1715
+ }
1716
+ function createEmptyDraft(eventId, draftId, actionType) {
1717
+ return {
1718
+ id: draftId,
1719
+ eventId,
1720
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1721
+ transactionId: getUUID(),
1722
+ action: {
1723
+ type: actionType,
1724
+ data: {},
1725
+ metadata: {},
1726
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1727
+ createdBy: "@todo",
1728
+ createdAtLocation: "@todo"
1729
+ }
1730
+ };
1731
+ }
1732
+ function findActiveActionVerificationPageIds(configuration, action) {
1733
+ const pages = findActiveActionFormPages(configuration, action);
1734
+ if (!pages) {
1735
+ return [];
1736
+ }
1737
+ return pages.filter((page) => page.type === FormPageType.VERIFICATION).map((page) => page.id);
1738
+ }
1494
1739
 
1495
1740
  // ../commons/src/events/EventConfig.ts
1496
1741
  var EventConfig = import_zod18.z.object({
@@ -1532,7 +1777,7 @@ var EventConfig = import_zod18.z.object({
1532
1777
 
1533
1778
  // ../commons/src/events/EventConfigInput.ts
1534
1779
  var defineForm = (form) => FormConfig.parse(form);
1535
- var defineFormPage = (formPage) => FormPage.parse(formPage);
1780
+ var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
1536
1781
 
1537
1782
  // ../commons/src/events/Draft.ts
1538
1783
  var import_zod21 = require("zod");
@@ -1588,9 +1833,9 @@ var MarkAsDuplicateAction = ActionBase.merge(
1588
1833
  type: import_zod19.z.literal(ActionType.MARKED_AS_DUPLICATE)
1589
1834
  })
1590
1835
  );
1591
- var ArchivedAction = ActionBase.merge(
1836
+ var ArchiveAction = ActionBase.merge(
1592
1837
  import_zod19.z.object({
1593
- type: import_zod19.z.literal(ActionType.ARCHIVED)
1838
+ type: import_zod19.z.literal(ActionType.ARCHIVE)
1594
1839
  })
1595
1840
  );
1596
1841
  var CreatedAction = ActionBase.merge(
@@ -1635,7 +1880,7 @@ var ActionDocument = import_zod19.z.discriminatedUnion("type", [
1635
1880
  ValidateAction,
1636
1881
  RejectAction,
1637
1882
  MarkAsDuplicateAction,
1638
- ArchivedAction,
1883
+ ArchiveAction,
1639
1884
  NotifiedAction,
1640
1885
  RegisterAction,
1641
1886
  DeclareAction,
@@ -1664,7 +1909,6 @@ var import_zod20 = require("zod");
1664
1909
  var BaseActionInput = import_zod20.z.object({
1665
1910
  eventId: import_zod20.z.string(),
1666
1911
  transactionId: import_zod20.z.string(),
1667
- incomplete: import_zod20.z.boolean().optional().default(false).describe("Allows action with partial data to be saved"),
1668
1912
  data: ActionUpdate,
1669
1913
  metadata: ActionUpdate.optional()
1670
1914
  });
@@ -1691,8 +1935,7 @@ var ValidateActionInput = BaseActionInput.merge(
1691
1935
  );
1692
1936
  var NotifyActionInput = BaseActionInput.merge(
1693
1937
  import_zod20.z.object({
1694
- type: import_zod20.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
1695
- createdAtLocation: import_zod20.z.string()
1938
+ type: import_zod20.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
1696
1939
  })
1697
1940
  );
1698
1941
  var DeclareActionInput = BaseActionInput.merge(
@@ -1715,9 +1958,9 @@ var MarkedAsDuplicateActionInput = BaseActionInput.merge(
1715
1958
  type: import_zod20.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
1716
1959
  })
1717
1960
  );
1718
- var ArchivedActionInput = BaseActionInput.merge(
1961
+ var ArchiveActionInput = BaseActionInput.merge(
1719
1962
  import_zod20.z.object({
1720
- type: import_zod20.z.literal(ActionType.ARCHIVED).default(ActionType.ARCHIVED)
1963
+ type: import_zod20.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
1721
1964
  })
1722
1965
  );
1723
1966
  var AssignActionInput = BaseActionInput.merge(
@@ -1756,7 +1999,7 @@ var ActionInput = import_zod20.z.discriminatedUnion("type", [
1756
1999
  DeclareActionInput,
1757
2000
  RejectDeclarationActionInput,
1758
2001
  MarkedAsDuplicateActionInput,
1759
- ArchivedActionInput,
2002
+ ArchiveActionInput,
1760
2003
  AssignActionInput,
1761
2004
  UnassignActionInput,
1762
2005
  PrintCertificateActionInput,
@@ -1828,9 +2071,12 @@ function getStatusFromActions(actions) {
1828
2071
  if (action.type === ActionType.REJECT) {
1829
2072
  return EventStatus.REJECTED;
1830
2073
  }
1831
- if (action.type === ActionType.ARCHIVED) {
2074
+ if (action.type === ActionType.ARCHIVE) {
1832
2075
  return EventStatus.ARCHIVED;
1833
2076
  }
2077
+ if (action.type === ActionType.NOTIFY) {
2078
+ return EventStatus.NOTIFIED;
2079
+ }
1834
2080
  return status;
1835
2081
  }, EventStatus.CREATED);
1836
2082
  }
@@ -1897,8 +2143,8 @@ function deepMerge(currentDocument, actionDocument) {
1897
2143
  }
1898
2144
  );
1899
2145
  }
1900
- function isUndeclaredDraft(event2) {
1901
- return event2.actions.every(({ type }) => type === ActionType.CREATE);
2146
+ function isUndeclaredDraft(status) {
2147
+ return status === EventStatus.CREATED;
1902
2148
  }
1903
2149
  function getCurrentEventState(event2) {
1904
2150
  const creationAction = event2.actions.find(
@@ -1923,9 +2169,8 @@ function getCurrentEventState(event2) {
1923
2169
  });
1924
2170
  }
1925
2171
  function getCurrentEventStateWithDrafts(event2, drafts) {
1926
- const actions = event2.actions.slice().sort();
1927
- const lastAction = actions[actions.length - 1];
1928
- const activeDrafts = drafts.filter(({ eventId }) => eventId === event2.id).filter(({ createdAt }) => createdAt > lastAction.createdAt).map((draft) => draft.action).flatMap((action) => {
2172
+ const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
2173
+ const activeDrafts = findActiveDrafts(event2, drafts).map((draft) => draft.action).flatMap((action) => {
1929
2174
  if (action.type === ActionType.REQUEST_CORRECTION) {
1930
2175
  return [
1931
2176
  action,
@@ -1986,12 +2231,6 @@ var defineConfig = (config) => {
1986
2231
  });
1987
2232
  };
1988
2233
 
1989
- // ../commons/src/uuid.ts
1990
- var import_uuid = require("uuid");
1991
- function getUUID() {
1992
- return (0, import_uuid.v4)();
1993
- }
1994
-
1995
2234
  // ../commons/src/events/transactions.ts
1996
2235
  function generateTransactionId() {
1997
2236
  return getUUID();
@@ -2208,6 +2447,23 @@ function field(fieldId) {
2208
2447
  }
2209
2448
  },
2210
2449
  required: ["$form"]
2450
+ }),
2451
+ isValidEnglishName: () => defineConditional({
2452
+ type: "object",
2453
+ properties: {
2454
+ $form: {
2455
+ type: "object",
2456
+ properties: {
2457
+ [fieldId]: {
2458
+ type: "string",
2459
+ 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'._-]*)*$",
2460
+ description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
2461
+ }
2462
+ },
2463
+ required: [fieldId]
2464
+ }
2465
+ },
2466
+ required: ["$form"]
2211
2467
  })
2212
2468
  };
2213
2469
  }
@@ -2834,6 +3090,44 @@ var PRINT_CERTIFICATE_FORM = defineForm({
2834
3090
  type: "FILE"
2835
3091
  }
2836
3092
  ]
3093
+ },
3094
+ {
3095
+ id: "collector.identity.verify",
3096
+ type: FormPageType.VERIFICATION,
3097
+ title: {
3098
+ id: "event.tennis-club-membership.action.print.verifyIdentity",
3099
+ defaultMessage: "Verify their identity",
3100
+ description: "This is the title of the section"
3101
+ },
3102
+ fields: [],
3103
+ actions: {
3104
+ verify: {
3105
+ label: {
3106
+ defaultMessage: "Verified",
3107
+ description: "This is the label for the verification button",
3108
+ id: "v2.event.tennis-club-membership.action.certificate.form.verify"
3109
+ }
3110
+ },
3111
+ cancel: {
3112
+ label: {
3113
+ defaultMessage: "Identity does not match",
3114
+ description: "This is the label for the verification cancellation button",
3115
+ id: "v2.event.tennis-club-membership.action.certificate.form.cancel"
3116
+ },
3117
+ confirmation: {
3118
+ title: {
3119
+ defaultMessage: "Print without proof of ID?",
3120
+ description: "This is the title for the verification cancellation modal",
3121
+ id: "v2.event.tennis-club-membership.action.certificate.form.cancel.confirmation.title"
3122
+ },
3123
+ body: {
3124
+ 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",
3125
+ description: "This is the body for the verification cancellation modal",
3126
+ id: "v2.event.tennis-club-membership.action.certificate.form.cancel.confirmation.body"
3127
+ }
3128
+ }
3129
+ }
3130
+ }
2837
3131
  }
2838
3132
  ],
2839
3133
  review: {
@@ -3411,6 +3705,24 @@ var tennisClubMembershipEvent = defineConfig({
3411
3705
  })
3412
3706
  }
3413
3707
  ]
3708
+ },
3709
+ {
3710
+ type: ActionType.ARCHIVE,
3711
+ label: {
3712
+ id: "v2.event.tennis-club-membership.action.archive.label",
3713
+ defaultMessage: "Archive",
3714
+ description: "This is shown as the action name anywhere the user can trigger the action from"
3715
+ },
3716
+ forms: [TENNIS_CLUB_FORM]
3717
+ },
3718
+ {
3719
+ type: ActionType.REJECT,
3720
+ label: {
3721
+ id: "v2.event.tennis-club-membership.action.reject.label",
3722
+ defaultMessage: "Reject",
3723
+ description: "This is shown as the action name anywhere the user can trigger the action from"
3724
+ },
3725
+ forms: [TENNIS_CLUB_FORM]
3414
3726
  }
3415
3727
  ],
3416
3728
  advancedSearch: [
@@ -3441,6 +3753,19 @@ function generateActionInput(configuration, action) {
3441
3753
  );
3442
3754
  return stripHiddenFields(fields, data);
3443
3755
  }
3756
+ function generateActionMetadataInput(configuration, action) {
3757
+ const verificationPageIds = findActiveActionVerificationPageIds(
3758
+ configuration,
3759
+ action
3760
+ );
3761
+ return verificationPageIds.reduce(
3762
+ (acc, pageId) => ({
3763
+ ...acc,
3764
+ [pageId]: true
3765
+ }),
3766
+ {}
3767
+ );
3768
+ }
3444
3769
  var eventPayloadGenerator = {
3445
3770
  create: (input = {}) => ({
3446
3771
  transactionId: input.transactionId ?? getUUID(),
@@ -3491,9 +3816,9 @@ var eventPayloadGenerator = {
3491
3816
  eventId
3492
3817
  }),
3493
3818
  archive: (eventId, input = {}, isDuplicate) => ({
3494
- type: ActionType.ARCHIVED,
3819
+ type: ActionType.ARCHIVE,
3495
3820
  transactionId: input.transactionId ?? getUUID(),
3496
- data: input.data ?? {},
3821
+ data: input.data ?? generateActionInput(tennisClubMembershipEvent, ActionType.ARCHIVE),
3497
3822
  metadata: { isDuplicate: isDuplicate ?? false },
3498
3823
  duplicates: [],
3499
3824
  eventId
@@ -3501,7 +3826,7 @@ var eventPayloadGenerator = {
3501
3826
  reject: (eventId, input = {}) => ({
3502
3827
  type: ActionType.REJECT,
3503
3828
  transactionId: input.transactionId ?? getUUID(),
3504
- data: input.data ?? {},
3829
+ data: input.data ?? generateActionInput(tennisClubMembershipEvent, ActionType.REJECT),
3505
3830
  duplicates: [],
3506
3831
  eventId
3507
3832
  }),
@@ -3518,6 +3843,10 @@ var eventPayloadGenerator = {
3518
3843
  tennisClubMembershipEvent,
3519
3844
  ActionType.PRINT_CERTIFICATE
3520
3845
  ),
3846
+ metadata: input.metadata ?? generateActionMetadataInput(
3847
+ tennisClubMembershipEvent,
3848
+ ActionType.PRINT_CERTIFICATE
3849
+ ),
3521
3850
  eventId
3522
3851
  }),
3523
3852
  correction: {
@@ -3560,7 +3889,9 @@ function generateActionDocument({
3560
3889
  defaults = {}
3561
3890
  }) {
3562
3891
  const actionBase = {
3563
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
3892
+ // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
3893
+ // @TODO: This should be fixed in the future.
3894
+ createdAt: new Date(Date.now() - 500).toISOString(),
3564
3895
  createdBy: getUUID(),
3565
3896
  id: getUUID(),
3566
3897
  createdAtLocation: "TODO",
@@ -3577,7 +3908,7 @@ function generateActionDocument({
3577
3908
  return { ...actionBase, assignedTo: getUUID(), type: action };
3578
3909
  case ActionType.VALIDATE:
3579
3910
  return { ...actionBase, type: action };
3580
- case ActionType.ARCHIVED:
3911
+ case ActionType.ARCHIVE:
3581
3912
  return { ...actionBase, type: action };
3582
3913
  case ActionType.REJECT:
3583
3914
  return { ...actionBase, type: action };
@@ -3615,9 +3946,13 @@ function generateEventDocument({
3615
3946
  actions: actions.map(
3616
3947
  (action) => generateActionDocument({ configuration, action })
3617
3948
  ),
3618
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
3949
+ // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
3950
+ // @TODO: This should be fixed in the future.
3951
+ createdAt: new Date(Date.now() - 1e3).toISOString(),
3619
3952
  id: getUUID(),
3620
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
3953
+ // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
3954
+ // @TODO: This should be fixed in the future.
3955
+ updatedAt: new Date(Date.now() - 1e3).toISOString()
3621
3956
  };
3622
3957
  }
3623
3958
  function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, data = {}) {
@@ -3657,3 +3992,38 @@ var eventQueryDataGenerator = (overrides = {}) => ({
3657
3992
  },
3658
3993
  trackingId: overrides.trackingId ?? "M3F8YQ"
3659
3994
  });
3995
+ var generateTranslationConfig = (message) => ({
3996
+ defaultMessage: message,
3997
+ description: "Description for ${message}",
3998
+ id: message
3999
+ });
4000
+
4001
+ // ../commons/src/events/TemplateConfig.ts
4002
+ function isTemplateVariable(value) {
4003
+ return typeof value === "string" && value.startsWith("$");
4004
+ }
4005
+ function isFieldValue(value) {
4006
+ return FieldValue.safeParse(value).success;
4007
+ }
4008
+ function isFieldValueWithoutTemplates(value) {
4009
+ if (isTemplateVariable(value)) {
4010
+ return false;
4011
+ }
4012
+ if (typeof value === "object" && Object.values(value).some((val) => isTemplateVariable(val))) {
4013
+ return false;
4014
+ }
4015
+ return true;
4016
+ }
4017
+ function isFieldConfigDefaultValue(value) {
4018
+ if (!value) return false;
4019
+ if (isFieldValue(value)) {
4020
+ return true;
4021
+ }
4022
+ if (isTemplateVariable(value)) {
4023
+ return true;
4024
+ }
4025
+ if (typeof value === "object" && Object.values(value).every((v) => typeof v === "object" && v !== null)) {
4026
+ return Object.values(value).every((v) => isFieldConfigDefaultValue(v));
4027
+ }
4028
+ return false;
4029
+ }