@opencrvs/toolkit 1.8.0-rc.fef85f2 → 1.8.0-rc.ff0a1b5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/commons/api/router.d.ts +7684 -4215
  2. package/dist/commons/conditionals/conditionals.d.ts +9 -6
  3. package/dist/commons/events/ActionConfig.d.ts +90025 -1680
  4. package/dist/commons/events/ActionDocument.d.ts +542 -211
  5. package/dist/commons/events/ActionInput.d.ts +248 -240
  6. package/dist/commons/events/AdvancedSearchConfig.d.ts +369 -25
  7. package/dist/commons/events/Draft.d.ts +33 -20
  8. package/dist/commons/events/EventConfig.d.ts +42730 -1400
  9. package/dist/commons/events/EventDocument.d.ts +337 -159
  10. package/dist/commons/events/EventIndex.d.ts +1462 -16
  11. package/dist/commons/events/EventInput.d.ts +13 -0
  12. package/dist/commons/events/EventMetadata.d.ts +273 -14
  13. package/dist/commons/events/FieldConfig.d.ts +3682 -714
  14. package/dist/commons/events/FieldType.d.ts +3 -3
  15. package/dist/commons/events/FieldTypeMapping.d.ts +11 -4
  16. package/dist/commons/events/FieldValue.d.ts +7 -4
  17. package/dist/commons/events/FormConfig.d.ts +40417 -439
  18. package/dist/commons/events/PageConfig.d.ts +10077 -203
  19. package/dist/commons/events/SummaryConfig.d.ts +17 -47
  20. package/dist/commons/events/WorkqueueConfig.d.ts +1257 -19
  21. package/dist/commons/events/defineConfig.d.ts +6952 -32
  22. package/dist/commons/events/event.d.ts +27 -0
  23. package/dist/commons/events/field.d.ts +68 -0
  24. package/dist/commons/events/index.d.ts +2 -0
  25. package/dist/commons/events/scopes.d.ts +1 -0
  26. package/dist/commons/events/test.utils.d.ts +7 -44
  27. package/dist/commons/events/utils.d.ts +3550 -67
  28. package/dist/conditionals/index.js +36 -33
  29. package/dist/events/index.js +1446 -949
  30. package/dist/scopes/index.d.ts +70 -1
  31. package/dist/scopes/index.js +130 -0
  32. package/package.json +3 -2
@@ -36,6 +36,7 @@ __export(events_exports, {
36
36
  ActionConditional: () => ActionConditional,
37
37
  ActionConfig: () => ActionConfig,
38
38
  ActionConfigBase: () => ActionConfigBase,
39
+ ActionCreationMetadata: () => ActionCreationMetadata,
39
40
  ActionDocument: () => ActionDocument,
40
41
  ActionFormConfig: () => ActionFormConfig,
41
42
  ActionInput: () => ActionInput,
@@ -54,6 +55,7 @@ __export(events_exports, {
54
55
  AsyncRejectActionDocument: () => AsyncRejectActionDocument,
55
56
  BaseActionInput: () => BaseActionInput,
56
57
  CONFIG_GET_ALLOWED_SCOPES: () => CONFIG_GET_ALLOWED_SCOPES,
58
+ CONFIG_SEARCH_ALLOWED_SCOPES: () => CONFIG_SEARCH_ALLOWED_SCOPES,
57
59
  CertificateConfig: () => CertificateConfig,
58
60
  CertificateTemplateConfig: () => CertificateTemplateConfig,
59
61
  CheckboxFieldValue: () => CheckboxFieldValue,
@@ -61,9 +63,13 @@ __export(events_exports, {
61
63
  Conditional: () => Conditional,
62
64
  ConditionalType: () => ConditionalType,
63
65
  ConfirmableActions: () => ConfirmableActions,
66
+ CustomFlags: () => CustomFlags,
67
+ DEFAULT_DATE_OF_EVENT_PROPERTY: () => DEFAULT_DATE_OF_EVENT_PROPERTY,
64
68
  DataEntry: () => DataEntry,
65
69
  DataFieldValue: () => DataFieldValue,
70
+ DateRangeFieldValue: () => DateRangeFieldValue,
66
71
  DateValue: () => DateValue,
72
+ DatetimeValue: () => DatetimeValue,
67
73
  DeclarationActionConfig: () => DeclarationActionConfig,
68
74
  DeclarationActions: () => DeclarationActions,
69
75
  DeclarationFormConfig: () => DeclarationFormConfig,
@@ -71,6 +77,7 @@ __export(events_exports, {
71
77
  DeclarationUpdateActions: () => DeclarationUpdateActions,
72
78
  DeclareActionInput: () => DeclareActionInput,
73
79
  DeduplicationConfig: () => DeduplicationConfig,
80
+ DeleteActionInput: () => DeleteActionInput,
74
81
  DisplayOnReviewConditional: () => DisplayOnReviewConditional,
75
82
  Draft: () => Draft,
76
83
  DraftInput: () => DraftInput,
@@ -79,20 +86,27 @@ __export(events_exports, {
79
86
  EnableConditional: () => EnableConditional,
80
87
  EventConfig: () => EventConfig,
81
88
  EventDocument: () => EventDocument,
89
+ EventFieldConfigSchema: () => EventFieldConfigSchema,
90
+ EventFieldId: () => EventFieldId,
82
91
  EventIndex: () => EventIndex,
83
92
  EventInput: () => EventInput,
84
93
  EventMetadata: () => EventMetadata,
94
+ EventMetadataKeys: () => EventMetadataKeys,
95
+ EventMetadataParameter: () => EventMetadataParameter,
85
96
  EventSearchIndex: () => EventSearchIndex,
97
+ EventState: () => EventState,
86
98
  EventStatus: () => EventStatus,
87
99
  EventStatuses: () => EventStatuses,
88
100
  FieldConditional: () => FieldConditional,
89
101
  FieldConfig: () => FieldConfig,
102
+ FieldConfigSchema: () => FieldConfigSchema,
90
103
  FieldType: () => FieldType,
91
104
  FieldUpdateValue: () => FieldUpdateValue,
92
105
  FieldValue: () => FieldValue,
93
106
  FileFieldValue: () => FileFieldValue,
94
107
  FileFieldValueWithOption: () => FileFieldValueWithOption,
95
108
  FileFieldWithOptionValue: () => FileFieldWithOptionValue,
109
+ Flag: () => Flag,
96
110
  FormConfig: () => FormConfig,
97
111
  FormPageConfig: () => FormPageConfig,
98
112
  GenericAddressUpdateValue: () => GenericAddressUpdateValue,
@@ -100,23 +114,29 @@ __export(events_exports, {
100
114
  GeographicalArea: () => GeographicalArea,
101
115
  ImageMimeType: () => ImageMimeType,
102
116
  LanguageConfig: () => LanguageConfig,
117
+ LegalStatuses: () => LegalStatuses,
103
118
  MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
104
119
  MimeType: () => MimeType,
120
+ NonEmptyTextValue: () => NonEmptyTextValue,
105
121
  NotifyActionInput: () => NotifyActionInput,
106
122
  NumberFieldValue: () => NumberFieldValue,
107
123
  PageConfig: () => PageConfig,
108
124
  PageTypes: () => PageTypes,
109
125
  PrintCertificateActionInput: () => PrintCertificateActionInput,
126
+ QueryInput: () => QueryInput,
127
+ QueryType: () => QueryType,
110
128
  ReadActionInput: () => ReadActionInput,
111
129
  RegisterAction: () => RegisterAction,
112
130
  RegisterActionInput: () => RegisterActionInput,
131
+ RegistrationCreationMetadata: () => RegistrationCreationMetadata,
113
132
  RejectCorrectionActionInput: () => RejectCorrectionActionInput,
114
133
  RejectDeclarationActionInput: () => RejectDeclarationActionInput,
115
134
  RequestCorrectionActionInput: () => RequestCorrectionActionInput,
116
- RequiredTextValue: () => RequiredTextValue,
117
135
  ResolvedUser: () => ResolvedUser,
118
136
  RuralAddressUpdateValue: () => RuralAddressUpdateValue,
119
137
  RuralAddressValue: () => RuralAddressValue,
138
+ SearchField: () => SearchField,
139
+ SelectOption: () => SelectOption,
120
140
  ShowConditional: () => ShowConditional,
121
141
  SummaryConfig: () => SummaryConfig,
122
142
  TextValue: () => TextValue,
@@ -128,6 +148,7 @@ __export(events_exports, {
128
148
  VerificationActionConfig: () => VerificationActionConfig,
129
149
  VerificationPageConfig: () => VerificationPageConfig,
130
150
  WorkqueueConfig: () => WorkqueueConfig,
151
+ ZodDate: () => ZodDate,
131
152
  alwaysTrue: () => alwaysTrue,
132
153
  and: () => and,
133
154
  annotationActions: () => annotationActions,
@@ -135,6 +156,8 @@ __export(events_exports, {
135
156
  areConditionsMet: () => areConditionsMet,
136
157
  compositeFieldTypes: () => compositeFieldTypes,
137
158
  createEmptyDraft: () => createEmptyDraft,
159
+ createEventConditionals: () => createEventConditionals,
160
+ createFieldConditionals: () => createFieldConditionals,
138
161
  createValidationSchema: () => createValidationSchema,
139
162
  deepDropNulls: () => deepDropNulls,
140
163
  deepMerge: () => deepMerge,
@@ -145,6 +168,7 @@ __export(events_exports, {
145
168
  defineFormConditional: () => defineFormConditional,
146
169
  defineFormPage: () => defineFormPage,
147
170
  definePage: () => definePage,
171
+ defineWorkqueue: () => defineWorkqueue,
148
172
  errorMessages: () => errorMessages,
149
173
  event: () => event,
150
174
  eventMetadataLabelMap: () => eventMetadataLabelMap,
@@ -170,13 +194,16 @@ __export(events_exports, {
170
194
  getActionAnnotationFields: () => getActionAnnotationFields,
171
195
  getActionReview: () => getActionReview,
172
196
  getActionReviewFields: () => getActionReviewFields,
173
- getAllAnnotationFields: () => getAllAnnotationFields,
197
+ getActionVerificationPageIds: () => getActionVerificationPageIds,
174
198
  getAnnotationFromDrafts: () => getAnnotationFromDrafts,
199
+ getAssignedUserFromActions: () => getAssignedUserFromActions,
175
200
  getCurrentEventState: () => getCurrentEventState,
176
201
  getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
177
202
  getDeclaration: () => getDeclaration,
178
203
  getDeclarationFields: () => getDeclarationFields,
179
204
  getDeclarationPages: () => getDeclarationPages,
205
+ getMixedPath: () => getMixedPath,
206
+ getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
180
207
  hasAnyOfScopes: () => hasAnyOfScopes,
181
208
  isAddressFieldType: () => isAddressFieldType,
182
209
  isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
@@ -186,6 +213,7 @@ __export(events_exports, {
186
213
  isCountryFieldType: () => isCountryFieldType,
187
214
  isDataFieldType: () => isDataFieldType,
188
215
  isDateFieldType: () => isDateFieldType,
216
+ isDateRangeFieldType: () => isDateRangeFieldType,
189
217
  isDividerFieldType: () => isDividerFieldType,
190
218
  isEmailFieldType: () => isEmailFieldType,
191
219
  isFacilityFieldType: () => isFacilityFieldType,
@@ -217,6 +245,7 @@ __export(events_exports, {
217
245
  mapFieldTypeToZod: () => mapFieldTypeToZod,
218
246
  never: () => never,
219
247
  not: () => not,
248
+ omitHiddenAnnotationFields: () => omitHiddenAnnotationFields,
220
249
  omitHiddenFields: () => omitHiddenFields,
221
250
  omitHiddenPaginatedFields: () => omitHiddenPaginatedFields,
222
251
  or: () => or,
@@ -224,7 +253,6 @@ __export(events_exports, {
224
253
  user: () => user,
225
254
  validate: () => validate,
226
255
  validateFieldInput: () => validateFieldInput,
227
- validateWorkqueueConfig: () => validateWorkqueueConfig,
228
256
  writeActions: () => writeActions
229
257
  });
230
258
  module.exports = __toCommonJS(events_exports);
@@ -301,12 +329,12 @@ var FieldType = {
301
329
  TEXTAREA: "TEXTAREA",
302
330
  EMAIL: "EMAIL",
303
331
  DATE: "DATE",
332
+ DATE_RANGE: "DATE_RANGE",
304
333
  PARAGRAPH: "PARAGRAPH",
305
334
  PAGE_HEADER: "PAGE_HEADER",
306
335
  RADIO_GROUP: "RADIO_GROUP",
307
336
  FILE: "FILE",
308
337
  FILE_WITH_OPTIONS: "FILE_WITH_OPTIONS",
309
- HIDDEN: "HIDDEN",
310
338
  BULLET_LIST: "BULLET_LIST",
311
339
  CHECKBOX: "CHECKBOX",
312
340
  SELECT: "SELECT",
@@ -321,6 +349,7 @@ var FieldType = {
321
349
  };
322
350
  var fieldTypes = Object.values(FieldType);
323
351
  var compositeFieldTypes = [
352
+ FieldType.DATE_RANGE,
324
353
  FieldType.ADDRESS,
325
354
  FieldType.FILE_WITH_OPTIONS,
326
355
  FieldType.FILE
@@ -411,8 +440,10 @@ var FileFieldWithOptionValue = import_zod3.z.array(FileFieldValueWithOption);
411
440
 
412
441
  // ../commons/src/events/FieldValue.ts
413
442
  var TextValue = import_zod4.z.string();
414
- var RequiredTextValue = TextValue.min(1);
443
+ var NonEmptyTextValue = TextValue.min(1);
415
444
  var DateValue = import_zod4.z.string().date().describe("Date in the format YYYY-MM-DD");
445
+ var DatetimeValue = import_zod4.z.string().datetime();
446
+ var DateRangeFieldValue = DateValue.or(import_zod4.z.tuple([DateValue, DateValue]));
416
447
  var EmailValue = import_zod4.z.string().email();
417
448
  var CheckboxFieldValue = import_zod4.z.boolean();
418
449
  var NumberFieldValue = import_zod4.z.number();
@@ -420,6 +451,7 @@ var DataFieldValue = import_zod4.z.undefined();
420
451
  var FieldValue = import_zod4.z.union([
421
452
  TextValue,
422
453
  DateValue,
454
+ DateRangeFieldValue,
423
455
  CheckboxFieldValue,
424
456
  NumberFieldValue,
425
457
  FileFieldValue,
@@ -432,6 +464,7 @@ var FieldValue = import_zod4.z.union([
432
464
  var FieldUpdateValue = import_zod4.z.union([
433
465
  TextValue,
434
466
  DateValue,
467
+ DateRangeFieldValue,
435
468
  CheckboxFieldValue,
436
469
  NumberFieldValue,
437
470
  FileFieldValue,
@@ -444,27 +477,21 @@ var FieldUpdateValue = import_zod4.z.union([
444
477
 
445
478
  // ../commons/src/events/FieldConfig.ts
446
479
  var FieldId = import_zod5.z.string();
447
- var DependencyExpression = import_zod5.z.object({
448
- dependsOn: import_zod5.z.array(FieldId).default([]),
449
- expression: import_zod5.z.string()
450
- });
480
+ var ParentReference = import_zod5.z.object({
481
+ _fieldId: FieldId.optional()
482
+ }).optional();
451
483
  var BaseField = import_zod5.z.object({
452
484
  id: FieldId,
453
485
  defaultValue: import_zod5.z.union([
454
- // These are the currently supported default values types
455
- import_zod5.z.union([
456
- TextValue,
457
- RequiredTextValue,
458
- DateValue,
459
- NumberFieldValue,
460
- CheckboxFieldValue
461
- ]),
462
- DependencyExpression
486
+ TextValue,
487
+ NonEmptyTextValue,
488
+ DateValue,
489
+ NumberFieldValue,
490
+ CheckboxFieldValue
463
491
  ]).optional(),
492
+ parent: ParentReference,
464
493
  conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
465
494
  required: import_zod5.z.boolean().default(false).optional(),
466
- disabled: import_zod5.z.boolean().default(false).optional(),
467
- hidden: import_zod5.z.boolean().default(false).optional(),
468
495
  placeholder: TranslationConfig.optional(),
469
496
  validation: import_zod5.z.array(
470
497
  import_zod5.z.object({
@@ -472,7 +499,6 @@ var BaseField = import_zod5.z.object({
472
499
  message: TranslationConfig
473
500
  })
474
501
  ).default([]).optional(),
475
- dependsOn: import_zod5.z.array(FieldId).default([]).optional(),
476
502
  label: TranslationConfig,
477
503
  hideLabel: import_zod5.z.boolean().default(false).optional()
478
504
  });
@@ -481,7 +507,7 @@ var Divider = BaseField.extend({
481
507
  });
482
508
  var TextField = BaseField.extend({
483
509
  type: import_zod5.z.literal(FieldType.TEXT),
484
- defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional(),
510
+ defaultValue: NonEmptyTextValue.optional(),
485
511
  configuration: import_zod5.z.object({
486
512
  maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
487
513
  type: import_zod5.z.enum(["text", "password"]).optional(),
@@ -491,7 +517,7 @@ var TextField = BaseField.extend({
491
517
  }).describe("Text input");
492
518
  var NumberField = BaseField.extend({
493
519
  type: import_zod5.z.literal(FieldType.NUMBER),
494
- defaultValue: import_zod5.z.union([NumberFieldValue, DependencyExpression]).optional(),
520
+ defaultValue: NumberFieldValue.optional(),
495
521
  configuration: import_zod5.z.object({
496
522
  min: import_zod5.z.number().optional().describe("Minimum value"),
497
523
  max: import_zod5.z.number().optional().describe("Maximum value"),
@@ -501,7 +527,7 @@ var NumberField = BaseField.extend({
501
527
  }).describe("Number input");
502
528
  var TextAreaField = BaseField.extend({
503
529
  type: import_zod5.z.literal(FieldType.TEXTAREA),
504
- defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional(),
530
+ defaultValue: NonEmptyTextValue.optional(),
505
531
  configuration: import_zod5.z.object({
506
532
  maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
507
533
  rows: import_zod5.z.number().optional().describe("Number of visible text lines"),
@@ -535,17 +561,28 @@ var EmailField = BaseField.extend({
535
561
  configuration: import_zod5.z.object({
536
562
  maxLength: import_zod5.z.number().optional().describe("Maximum length of the text")
537
563
  }).default({ maxLength: 10 }).optional(),
538
- defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
564
+ defaultValue: NonEmptyTextValue.optional()
539
565
  });
540
566
  var DateField = BaseField.extend({
541
567
  type: import_zod5.z.literal(FieldType.DATE),
542
- defaultValue: import_zod5.z.union([DateValue, DependencyExpression]).optional(),
568
+ defaultValue: DateValue.optional(),
543
569
  configuration: import_zod5.z.object({
544
570
  notice: TranslationConfig.describe(
545
571
  "Text to display above the date input"
546
572
  ).optional()
547
573
  }).optional()
548
574
  }).describe("A single date input (dd-mm-YYYY)");
575
+ var DateRangeField = BaseField.extend({
576
+ type: import_zod5.z.literal(FieldType.DATE_RANGE),
577
+ defaultValue: DateRangeFieldValue.optional(),
578
+ configuration: import_zod5.z.object({
579
+ notice: TranslationConfig.describe(
580
+ "Text to display above the date input"
581
+ ).optional()
582
+ }).optional()
583
+ }).describe(
584
+ "A date range input ({ rangeStart: dd-mm-YYYY, rangeEnd: dd-mm-YYYY })"
585
+ );
549
586
  var HtmlFontVariant = import_zod5.z.enum([
550
587
  "reg12",
551
588
  "reg14",
@@ -558,7 +595,7 @@ var HtmlFontVariant = import_zod5.z.enum([
558
595
  ]);
559
596
  var Paragraph = BaseField.extend({
560
597
  type: import_zod5.z.literal(FieldType.PARAGRAPH),
561
- defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional(),
598
+ defaultValue: NonEmptyTextValue.optional(),
562
599
  configuration: import_zod5.z.object({
563
600
  styles: import_zod5.z.object({
564
601
  fontVariant: HtmlFontVariant.optional()
@@ -567,7 +604,7 @@ var Paragraph = BaseField.extend({
567
604
  }).describe("A read-only HTML <p> paragraph");
568
605
  var PageHeader = BaseField.extend({
569
606
  type: import_zod5.z.literal(FieldType.PAGE_HEADER),
570
- defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
607
+ defaultValue: NonEmptyTextValue.optional()
571
608
  }).describe("A read-only header component for form pages");
572
609
  var File = BaseField.extend({
573
610
  type: import_zod5.z.literal(FieldType.FILE),
@@ -590,7 +627,7 @@ var SelectOption = import_zod5.z.object({
590
627
  });
591
628
  var RadioGroup = BaseField.extend({
592
629
  type: import_zod5.z.literal(FieldType.RADIO_GROUP),
593
- defaultValue: import_zod5.z.union([TextValue, DependencyExpression]).optional(),
630
+ defaultValue: TextValue.optional(),
594
631
  options: import_zod5.z.array(SelectOption).describe("A list of options"),
595
632
  configuration: import_zod5.z.object({
596
633
  styles: import_zod5.z.object({
@@ -600,7 +637,7 @@ var RadioGroup = BaseField.extend({
600
637
  }).describe("Grouped radio options");
601
638
  var BulletList = BaseField.extend({
602
639
  type: import_zod5.z.literal(FieldType.BULLET_LIST),
603
- defaultValue: import_zod5.z.string().optional(),
640
+ defaultValue: TextValue.optional(),
604
641
  items: import_zod5.z.array(TranslationConfig).describe("A list of items"),
605
642
  configuration: import_zod5.z.object({
606
643
  styles: import_zod5.z.object({
@@ -610,16 +647,16 @@ var BulletList = BaseField.extend({
610
647
  }).describe("A list of bullet points");
611
648
  var Select = BaseField.extend({
612
649
  type: import_zod5.z.literal(FieldType.SELECT),
613
- defaultValue: import_zod5.z.union([TextValue, DependencyExpression]).optional(),
650
+ defaultValue: TextValue.optional(),
614
651
  options: import_zod5.z.array(SelectOption).describe("A list of options")
615
652
  }).describe("Select input");
616
653
  var Checkbox = BaseField.extend({
617
654
  type: import_zod5.z.literal(FieldType.CHECKBOX),
618
- defaultValue: import_zod5.z.union([CheckboxFieldValue, DependencyExpression]).optional()
655
+ defaultValue: CheckboxFieldValue.optional()
619
656
  }).describe("Boolean checkbox field");
620
657
  var Country = BaseField.extend({
621
658
  type: import_zod5.z.literal(FieldType.COUNTRY),
622
- defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
659
+ defaultValue: NonEmptyTextValue.optional()
623
660
  }).describe("Country select field");
624
661
  var AdministrativeAreas = import_zod5.z.enum([
625
662
  "ADMIN_STRUCTURE",
@@ -634,12 +671,12 @@ var AdministrativeAreaConfiguration = import_zod5.z.object({
634
671
  }).describe("Administrative area options");
635
672
  var AdministrativeArea = BaseField.extend({
636
673
  type: import_zod5.z.literal(FieldType.ADMINISTRATIVE_AREA),
637
- defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional(),
674
+ defaultValue: NonEmptyTextValue.optional(),
638
675
  configuration: AdministrativeAreaConfiguration
639
676
  }).describe("Administrative area input field e.g. facility, office");
640
677
  var Location = BaseField.extend({
641
678
  type: import_zod5.z.literal(FieldType.LOCATION),
642
- defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
679
+ defaultValue: NonEmptyTextValue.optional()
643
680
  }).describe("Input field for a location");
644
681
  var FileUploadWithOptions = BaseField.extend({
645
682
  type: import_zod5.z.literal(FieldType.FILE_WITH_OPTIONS),
@@ -653,11 +690,11 @@ var FileUploadWithOptions = BaseField.extend({
653
690
  });
654
691
  var Facility = BaseField.extend({
655
692
  type: import_zod5.z.literal(FieldType.FACILITY),
656
- defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
693
+ defaultValue: NonEmptyTextValue.optional()
657
694
  }).describe("Input field for a facility");
658
695
  var Office = BaseField.extend({
659
696
  type: import_zod5.z.literal(FieldType.OFFICE),
660
- defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
697
+ defaultValue: NonEmptyTextValue.optional()
661
698
  }).describe("Input field for an office");
662
699
  var Address = BaseField.extend({
663
700
  type: import_zod5.z.literal(FieldType.ADDRESS),
@@ -685,6 +722,7 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
685
722
  NumberField,
686
723
  TextAreaField,
687
724
  DateField,
725
+ DateRangeField,
688
726
  Paragraph,
689
727
  RadioGroup,
690
728
  BulletList,
@@ -702,7 +740,6 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
702
740
  EmailField,
703
741
  FileUploadWithOptions,
704
742
  DataField
705
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
706
743
  ]);
707
744
 
708
745
  // ../commons/src/events/PageConfig.ts
@@ -827,6 +864,8 @@ var ActionFormConfig = import_zod8.z.object({
827
864
  var FormConfig = import_zod8.z.union([DeclarationFormConfig, ActionFormConfig]);
828
865
 
829
866
  // ../commons/src/events/ActionConfig.ts
867
+ var import_zod_openapi = require("zod-openapi");
868
+ (0, import_zod_openapi.extendZodWithOpenApi)(import_zod9.z);
830
869
  var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
831
870
  /** If conditional is defined, the action is shown to the user only if the condition is met */
832
871
  ShowConditional,
@@ -904,18 +943,24 @@ var ApproveCorrectionConfig = ActionConfigBase.merge(
904
943
  })
905
944
  );
906
945
  var ActionConfig = import_zod9.z.discriminatedUnion("type", [
907
- DeclareConfig,
908
- ValidateConfig,
909
- RejectDeclarationConfig,
910
- MarkedAsDuplicateConfig,
911
- ArchiveConfig,
912
- RegisterConfig,
913
- DeleteConfig,
914
- PrintCertificateActionConfig,
915
- RequestCorrectionConfig,
916
- RejectCorrectionConfig,
917
- ApproveCorrectionConfig
918
- ]);
946
+ /*
947
+ * OpenAPI references are defined here so our generated OpenAPI spec knows to reuse the models
948
+ * and treat them as "models" instead of duplicating the data structure in each endpoint.
949
+ */
950
+ DeclareConfig.openapi({ ref: "DeclareActionConfig" }),
951
+ ValidateConfig.openapi({ ref: "ValidateActionConfig" }),
952
+ RejectDeclarationConfig.openapi({ ref: "RejectDeclarationActionConfig" }),
953
+ MarkedAsDuplicateConfig.openapi({ ref: "MarkedAsDuplicateActionConfig" }),
954
+ ArchiveConfig.openapi({ ref: "ArchiveActionConfig" }),
955
+ RegisterConfig.openapi({ ref: "RegisterActionConfig" }),
956
+ DeleteConfig.openapi({ ref: "DeleteActionConfig" }),
957
+ PrintCertificateActionConfig.openapi({
958
+ ref: "PrintCertificateActionConfig"
959
+ }),
960
+ RequestCorrectionConfig.openapi({ ref: "RequestCorrectionActionConfig" }),
961
+ RejectCorrectionConfig.openapi({ ref: "RejectCorrectionActionConfig" }),
962
+ ApproveCorrectionConfig.openapi({ ref: "ApproveCorrectionActionConfig" })
963
+ ]).openapi({ ref: "ActionConfig" });
919
964
  var DeclarationActionConfig = import_zod9.z.discriminatedUnion("type", [
920
965
  DeclareConfig,
921
966
  ValidateConfig,
@@ -959,10 +1004,12 @@ var LanguageConfig = import_zod11.z.object({
959
1004
  });
960
1005
 
961
1006
  // ../commons/src/events/EventConfig.ts
962
- var import_zod20 = require("zod");
1007
+ var import_zod17 = require("zod");
963
1008
 
964
1009
  // ../commons/src/events/DeduplicationConfig.ts
965
1010
  var import_zod12 = require("zod");
1011
+ var import_zod_openapi2 = require("zod-openapi");
1012
+ (0, import_zod_openapi2.extendZodWithOpenApi)(import_zod12.z);
966
1013
  var FieldReference = import_zod12.z.string();
967
1014
  var Matcher = import_zod12.z.object({
968
1015
  fieldId: import_zod12.z.string(),
@@ -1023,7 +1070,9 @@ var Clause = import_zod12.z.lazy(
1023
1070
  DateRangeMatcher,
1024
1071
  DateDistanceMatcher
1025
1072
  ])
1026
- );
1073
+ ).openapi({
1074
+ ref: "Clause"
1075
+ });
1027
1076
  var DeduplicationConfig = import_zod12.z.object({
1028
1077
  id: import_zod12.z.string(),
1029
1078
  label: TranslationConfig,
@@ -1037,7 +1086,10 @@ var BaseField2 = import_zod13.z.object({
1037
1086
  conditionals: import_zod13.z.array(ShowConditional).default([]).optional()
1038
1087
  });
1039
1088
  var ReferenceField = BaseField2.extend({
1040
- fieldId: import_zod13.z.string()
1089
+ fieldId: import_zod13.z.string(),
1090
+ label: TranslationConfig.optional().describe(
1091
+ "By default, the configured field's label is used. This can be overridden by providing a custom label."
1092
+ )
1041
1093
  }).describe("Field directly referencing event data with field id");
1042
1094
  var Field = BaseField2.extend({
1043
1095
  id: import_zod13.z.string().describe("Id of summary field"),
@@ -1047,270 +1099,196 @@ var Field = BaseField2.extend({
1047
1099
  label: TranslationConfig,
1048
1100
  emptyValueMessage: TranslationConfig.optional()
1049
1101
  }).describe("Custom configured field");
1050
- var Title = import_zod13.z.object({
1051
- id: import_zod13.z.string(),
1052
- label: TranslationConfig.describe("Title content"),
1053
- emptyValueMessage: TranslationConfig.optional()
1054
- });
1055
1102
  var SummaryConfig = import_zod13.z.object({
1056
- title: Title.describe("Title of summary view."),
1057
1103
  fields: import_zod13.z.array(import_zod13.z.union([Field, ReferenceField])).describe("Fields rendered in summary view.")
1058
1104
  }).describe("Configuration for summary in event.");
1059
1105
 
1060
- // ../commons/src/events/WorkqueueConfig.ts
1061
- var import_zod15 = require("zod");
1062
-
1063
- // ../commons/src/events/EventMetadata.ts
1106
+ // ../commons/src/events/AdvancedSearchConfig.ts
1064
1107
  var import_zod14 = require("zod");
1065
- var EventStatus = {
1066
- CREATED: "CREATED",
1067
- NOTIFIED: "NOTIFIED",
1068
- DECLARED: "DECLARED",
1069
- VALIDATED: "VALIDATED",
1070
- REGISTERED: "REGISTERED",
1071
- CERTIFIED: "CERTIFIED",
1072
- REJECTED: "REJECTED",
1073
- ARCHIVED: "ARCHIVED"
1074
- };
1075
- var eventStatuses = Object.values(EventStatus);
1076
- var EventStatuses = import_zod14.z.nativeEnum(EventStatus);
1077
- var EventMetadata = import_zod14.z.object({
1078
- id: import_zod14.z.string(),
1079
- type: import_zod14.z.string(),
1080
- status: EventStatuses,
1081
- createdAt: import_zod14.z.string().datetime(),
1082
- createdBy: import_zod14.z.string(),
1083
- createdAtLocation: import_zod14.z.string(),
1084
- updatedAtLocation: import_zod14.z.string(),
1085
- modifiedAt: import_zod14.z.string().datetime(),
1086
- assignedTo: import_zod14.z.string().nullish(),
1087
- updatedBy: import_zod14.z.string(),
1088
- trackingId: import_zod14.z.string(),
1089
- registrationNumber: import_zod14.z.string().nullish()
1108
+ var MatchType = import_zod14.z.enum(["fuzzy", "exact", "range"]);
1109
+ var BaseField3 = import_zod14.z.object({
1110
+ config: import_zod14.z.object({
1111
+ type: MatchType.describe("Determines the type of field")
1112
+ }),
1113
+ options: import_zod14.z.array(SelectOption).optional()
1090
1114
  });
1091
- var eventMetadataLabelMap = {
1092
- "event.assignedTo": {
1093
- id: "event.assignedTo.label",
1094
- defaultMessage: "Assigned To",
1095
- description: "Assigned To"
1096
- },
1097
- "event.createdAt": {
1098
- id: "event.createdAt.label",
1099
- defaultMessage: "Created",
1100
- description: "Created At"
1101
- },
1102
- "event.createdAtLocation": {
1103
- id: "event.createdAtLocation.label",
1104
- defaultMessage: "Location",
1105
- description: "Created At Location"
1106
- },
1107
- "event.updatedAtLocation": {
1108
- id: "event.updatedAtLocation.label",
1109
- defaultMessage: "Location",
1110
- description: "Updated At Location"
1111
- },
1112
- "event.createdBy": {
1113
- id: "event.createdBy.label",
1114
- defaultMessage: "Created By",
1115
- description: "Created By"
1116
- },
1117
- "event.id": {
1118
- id: "event.id.label",
1119
- defaultMessage: "ID",
1120
- description: "ID"
1121
- },
1122
- "event.modifiedAt": {
1123
- id: "event.modifiedAt.label",
1124
- defaultMessage: "Updated",
1125
- description: "Modified At"
1126
- },
1127
- "event.status": {
1128
- id: "event.status.label",
1129
- defaultMessage: "Status",
1130
- description: "Status"
1131
- },
1132
- "event.type": {
1133
- id: "event.type.label",
1134
- defaultMessage: "Type",
1135
- description: "Type"
1136
- },
1137
- "event.updatedBy": {
1138
- id: "event.updatedBy.label",
1139
- defaultMessage: "Updated By",
1140
- description: "Updated By"
1141
- },
1142
- "event.trackingId": {
1143
- id: "event.trackingId.label",
1144
- defaultMessage: "Tracking ID",
1145
- description: "Tracking ID"
1146
- },
1147
- "event.registrationNumber": {
1148
- id: "event.registrationNumber.label",
1149
- defaultMessage: "Registration Number",
1150
- description: "Registration Number"
1151
- }
1152
- };
1153
-
1154
- // ../commons/src/events/WorkqueueConfig.ts
1155
- var WorkqueueConfig = import_zod15.z.object({
1156
- id: import_zod15.z.string().describe("Unique identifier for workqueue."),
1157
- filters: import_zod15.z.array(
1158
- import_zod15.z.object({
1159
- status: import_zod15.z.array(EventStatuses).describe("Defines which statusese are included in the workqueue.")
1160
- })
1161
- ).describe("Filters to be applied to workqueue.")
1162
- }).describe("Configuration for workqueue.");
1163
-
1164
- // ../commons/src/events/AdvancedSearchConfig.ts
1165
- var import_zod16 = require("zod");
1166
- var AdvancedSearchConfig = import_zod16.z.object({
1115
+ var FieldConfigSchema = BaseField3.extend({
1116
+ fieldId: import_zod14.z.string(),
1117
+ fieldType: import_zod14.z.literal("field")
1118
+ });
1119
+ var EventFieldId = import_zod14.z.enum(["trackingId", "status"]);
1120
+ var EventFieldConfigSchema = BaseField3.extend({
1121
+ fieldId: EventFieldId,
1122
+ fieldType: import_zod14.z.literal("event")
1123
+ });
1124
+ var SearchField = import_zod14.z.discriminatedUnion("fieldType", [
1125
+ FieldConfigSchema,
1126
+ EventFieldConfigSchema
1127
+ ]);
1128
+ var AdvancedSearchConfig = import_zod14.z.object({
1167
1129
  title: TranslationConfig.describe("Advanced search tab title"),
1168
- fields: import_zod16.z.array(
1169
- import_zod16.z.object({
1170
- fieldId: import_zod16.z.string(),
1171
- config: import_zod16.z.object({
1172
- type: import_zod16.z.enum(["FUZZY", "EXACT", "RANGE"]).describe("Determines the type of field")
1173
- }).optional().describe("Configuration options for the field")
1174
- })
1175
- ).optional().default([]).describe("Advanced search fields.")
1130
+ fields: import_zod14.z.array(SearchField).describe("Advanced search fields.")
1176
1131
  });
1177
1132
 
1178
1133
  // ../commons/src/events/utils.ts
1179
1134
  var import_lodash = require("lodash");
1180
1135
 
1181
- // ../commons/src/workqueues/WorkqueueConfig.ts
1182
- var import_zod18 = require("zod");
1183
-
1184
- // ../commons/src/workqueues/defaultColumns.ts
1185
- var import_zod17 = require("zod");
1186
- var WorkQueueColumnConfig = import_zod17.z.object({
1187
- id: import_zod17.z.string(),
1188
- label: TranslationConfig
1189
- });
1190
- var defaultColumns = {
1191
- event: {
1192
- id: "event",
1193
- label: {
1194
- defaultMessage: "Event",
1195
- description: "This is the label for the workqueue column",
1196
- id: "workqueue.default.column.event"
1197
- }
1198
- },
1199
- status: {
1200
- id: "status",
1201
- label: {
1202
- defaultMessage: "Status",
1203
- description: "This is the label for the workqueue column",
1204
- id: "workqueue.default.column.status"
1205
- }
1206
- },
1207
- createdAt: {
1208
- id: "createdAt",
1209
- label: {
1210
- defaultMessage: "Created",
1211
- description: "This is the label for the workqueue column",
1212
- id: "workqueue.default.column.createdAt"
1213
- }
1214
- },
1215
- modifiedAt: {
1216
- id: "modifiedAt",
1217
- label: {
1218
- defaultMessage: "Modified",
1219
- description: "This is the label for the workqueue column",
1220
- id: "workqueue.default.column.modifiedAt"
1221
- }
1222
- }
1136
+ // ../commons/src/events/ActionDocument.ts
1137
+ var import_zod15 = require("zod");
1138
+ var import_zod_openapi3 = require("zod-openapi");
1139
+ (0, import_zod_openapi3.extendZodWithOpenApi)(import_zod15.z);
1140
+ var ActionUpdate = import_zod15.z.record(import_zod15.z.string(), FieldUpdateValue);
1141
+ var EventState = import_zod15.z.record(import_zod15.z.string(), FieldValue);
1142
+ var ActionStatus = {
1143
+ Requested: "Requested",
1144
+ Accepted: "Accepted",
1145
+ Rejected: "Rejected"
1223
1146
  };
1224
- var DefaultColumnKeys = import_zod17.z.enum(
1225
- Object.keys(defaultColumns)
1226
- );
1227
-
1228
- // ../commons/src/workqueues/WorkqueueConfig.ts
1229
- var rootWorkqueueConfig = import_zod18.z.object({
1230
- id: import_zod18.z.string(),
1231
- title: TranslationConfig,
1232
- columns: import_zod18.z.array(WorkQueueColumnConfig),
1233
- defaultColumns: import_zod18.z.array(DefaultColumnKeys)
1234
- });
1235
- var defineWorkqueue = (config) => rootWorkqueueConfig.parse(config);
1236
-
1237
- // ../commons/src/workqueues/all.ts
1238
- var allWorkqueue = defineWorkqueue({
1239
- id: "all",
1240
- title: {
1241
- defaultMessage: "All events",
1242
- description: "This is the label for the workqueue",
1243
- id: "workqueue.all.label"
1244
- },
1245
- columns: [
1246
- {
1247
- id: "title",
1248
- label: {
1249
- defaultMessage: "Title",
1250
- description: "This is the label for the workqueue column",
1251
- id: "workqueue.all.column.title"
1252
- }
1253
- }
1254
- ],
1255
- defaultColumns: ["event", "status", "createdAt", "modifiedAt"]
1147
+ var ActionBase = import_zod15.z.object({
1148
+ id: import_zod15.z.string(),
1149
+ transactionId: import_zod15.z.string(),
1150
+ createdAt: import_zod15.z.string().datetime(),
1151
+ createdBy: import_zod15.z.string(),
1152
+ createdByRole: import_zod15.z.string(),
1153
+ declaration: ActionUpdate,
1154
+ annotation: ActionUpdate.optional(),
1155
+ createdAtLocation: import_zod15.z.string(),
1156
+ status: import_zod15.z.enum([
1157
+ ActionStatus.Requested,
1158
+ ActionStatus.Accepted,
1159
+ ActionStatus.Rejected
1160
+ ]),
1161
+ // If the action is an asynchronous confirmation for another action, we will save the original action id here.
1162
+ originalActionId: import_zod15.z.string().optional()
1256
1163
  });
1257
-
1258
- // ../commons/src/workqueues/readyForReview.ts
1259
- var inReviewWorkqueue = defineWorkqueue({
1260
- id: "ready-for-review",
1261
- title: {
1262
- defaultMessage: "Ready for review",
1263
- description: "Label for in review workqueue",
1264
- id: "event.workqueue.in-review.label"
1265
- },
1266
- columns: [
1267
- {
1268
- id: "title",
1269
- label: {
1270
- defaultMessage: "Title",
1271
- description: "This is the label for the workqueue column",
1272
- id: "workqueue.in-reveiw.column.title"
1273
- }
1274
- }
1275
- ],
1276
- defaultColumns: ["event", "createdAt", "modifiedAt"]
1164
+ var AssignedAction = ActionBase.merge(
1165
+ import_zod15.z.object({
1166
+ type: import_zod15.z.literal(ActionType.ASSIGN),
1167
+ assignedTo: import_zod15.z.string()
1168
+ })
1169
+ );
1170
+ var UnassignedAction = ActionBase.merge(
1171
+ import_zod15.z.object({
1172
+ type: import_zod15.z.literal(ActionType.UNASSIGN),
1173
+ assignedTo: import_zod15.z.literal(null)
1174
+ })
1175
+ );
1176
+ var RegisterAction = ActionBase.merge(
1177
+ import_zod15.z.object({
1178
+ type: import_zod15.z.literal(ActionType.REGISTER),
1179
+ registrationNumber: import_zod15.z.string().optional()
1180
+ })
1181
+ );
1182
+ var DeclareAction = ActionBase.merge(
1183
+ import_zod15.z.object({
1184
+ type: import_zod15.z.literal(ActionType.DECLARE)
1185
+ })
1186
+ );
1187
+ var ValidateAction = ActionBase.merge(
1188
+ import_zod15.z.object({
1189
+ type: import_zod15.z.literal(ActionType.VALIDATE)
1190
+ })
1191
+ );
1192
+ var RejectAction = ActionBase.merge(
1193
+ import_zod15.z.object({
1194
+ type: import_zod15.z.literal(ActionType.REJECT)
1195
+ })
1196
+ );
1197
+ var MarkAsDuplicateAction = ActionBase.merge(
1198
+ import_zod15.z.object({
1199
+ type: import_zod15.z.literal(ActionType.MARKED_AS_DUPLICATE)
1200
+ })
1201
+ );
1202
+ var ArchiveAction = ActionBase.merge(
1203
+ import_zod15.z.object({
1204
+ type: import_zod15.z.literal(ActionType.ARCHIVE)
1205
+ })
1206
+ );
1207
+ var CreatedAction = ActionBase.merge(
1208
+ import_zod15.z.object({
1209
+ type: import_zod15.z.literal(ActionType.CREATE)
1210
+ })
1211
+ );
1212
+ var NotifiedAction = ActionBase.merge(
1213
+ import_zod15.z.object({
1214
+ type: import_zod15.z.literal(ActionType.NOTIFY)
1215
+ })
1216
+ );
1217
+ var PrintCertificateAction = ActionBase.merge(
1218
+ import_zod15.z.object({
1219
+ type: import_zod15.z.literal(ActionType.PRINT_CERTIFICATE)
1220
+ })
1221
+ );
1222
+ var RequestedCorrectionAction = ActionBase.merge(
1223
+ import_zod15.z.object({
1224
+ type: import_zod15.z.literal(ActionType.REQUEST_CORRECTION)
1225
+ })
1226
+ );
1227
+ var ApprovedCorrectionAction = ActionBase.merge(
1228
+ import_zod15.z.object({
1229
+ type: import_zod15.z.literal(ActionType.APPROVE_CORRECTION),
1230
+ requestId: import_zod15.z.string()
1231
+ })
1232
+ );
1233
+ var RejectedCorrectionAction = ActionBase.merge(
1234
+ import_zod15.z.object({
1235
+ type: import_zod15.z.literal(ActionType.REJECT_CORRECTION),
1236
+ requestId: import_zod15.z.string()
1237
+ })
1238
+ );
1239
+ var ReadAction = ActionBase.merge(
1240
+ import_zod15.z.object({
1241
+ type: import_zod15.z.literal(ActionType.READ)
1242
+ })
1243
+ );
1244
+ var ActionDocument = import_zod15.z.discriminatedUnion("type", [
1245
+ CreatedAction.openapi({ ref: "CreatedAction" }),
1246
+ ValidateAction.openapi({ ref: "ValidateAction" }),
1247
+ RejectAction.openapi({ ref: "RejectAction" }),
1248
+ MarkAsDuplicateAction.openapi({ ref: "MarkAsDuplicateAction" }),
1249
+ ArchiveAction.openapi({ ref: "ArchiveAction" }),
1250
+ NotifiedAction.openapi({ ref: "NotifiedAction" }),
1251
+ RegisterAction.openapi({ ref: "RegisterAction" }),
1252
+ DeclareAction.openapi({ ref: "DeclareAction" }),
1253
+ AssignedAction.openapi({ ref: "AssignedAction" }),
1254
+ RequestedCorrectionAction.openapi({ ref: "RequestedCorrectionAction" }),
1255
+ ApprovedCorrectionAction.openapi({ ref: "ApprovedCorrectionAction" }),
1256
+ RejectedCorrectionAction.openapi({ ref: "RejectedCorrectionAction" }),
1257
+ UnassignedAction.openapi({ ref: "UnassignedAction" }),
1258
+ PrintCertificateAction.openapi({ ref: "PrintCertificateAction" }),
1259
+ ReadAction.openapi({ ref: "ReadAction" })
1260
+ ]).openapi({
1261
+ ref: "ActionDocument"
1277
1262
  });
1278
-
1279
- // ../commons/src/workqueues/readyToPrint.ts
1280
- var registeredWorkqueue = defineWorkqueue({
1281
- id: "registered",
1282
- title: {
1283
- defaultMessage: "Ready to print",
1284
- description: "Label for registered workqueue",
1285
- id: "event.workqueue.registered.label"
1286
- },
1287
- columns: [
1288
- {
1289
- id: "title",
1290
- label: {
1291
- defaultMessage: "Title",
1292
- description: "This is the label for the workqueue column",
1293
- id: "workqueue.registered.column.title"
1294
- }
1295
- }
1296
- ],
1297
- defaultColumns: ["event", "createdAt", "modifiedAt"]
1263
+ var AsyncRejectActionDocument = ActionBase.omit({
1264
+ declaration: true,
1265
+ annotation: true
1266
+ }).merge(
1267
+ import_zod15.z.object({
1268
+ type: import_zod15.z.enum(ConfirmableActions),
1269
+ status: import_zod15.z.literal(ActionStatus.Rejected)
1270
+ })
1271
+ );
1272
+ var Action = import_zod15.z.union([ActionDocument, AsyncRejectActionDocument]);
1273
+ var ResolvedUser = import_zod15.z.object({
1274
+ id: import_zod15.z.string(),
1275
+ role: import_zod15.z.string(),
1276
+ name: import_zod15.z.array(
1277
+ import_zod15.z.object({
1278
+ use: import_zod15.z.string(),
1279
+ given: import_zod15.z.array(import_zod15.z.string()),
1280
+ family: import_zod15.z.string()
1281
+ })
1282
+ )
1298
1283
  });
1299
1284
 
1300
- // ../commons/src/workqueues/index.ts
1301
- var workqueues = {
1302
- all: allWorkqueue,
1303
- registered: registeredWorkqueue,
1304
- inReview: inReviewWorkqueue
1305
- };
1306
-
1307
1285
  // ../commons/src/conditionals/validate.ts
1308
1286
  var import_ajv = __toESM(require("ajv"));
1309
1287
  var import_ajv_formats = __toESM(require("ajv-formats"));
1310
1288
  var import_date_fns = require("date-fns");
1311
1289
 
1312
1290
  // ../commons/src/events/FieldTypeMapping.ts
1313
- var import_zod19 = require("zod");
1291
+ var import_zod16 = require("zod");
1314
1292
  function mapFieldTypeToZod(type, required) {
1315
1293
  let schema;
1316
1294
  switch (type) {
@@ -1320,6 +1298,9 @@ function mapFieldTypeToZod(type, required) {
1320
1298
  case FieldType.EMAIL:
1321
1299
  schema = EmailValue;
1322
1300
  break;
1301
+ case FieldType.DATE_RANGE:
1302
+ schema = DateRangeFieldValue;
1303
+ break;
1323
1304
  case FieldType.TEXT:
1324
1305
  case FieldType.TEXTAREA:
1325
1306
  case FieldType.DIVIDER:
@@ -1334,8 +1315,7 @@ function mapFieldTypeToZod(type, required) {
1334
1315
  case FieldType.FACILITY:
1335
1316
  case FieldType.OFFICE:
1336
1317
  case FieldType.SIGNATURE:
1337
- case FieldType.HIDDEN:
1338
- schema = required ? RequiredTextValue : TextValue;
1318
+ schema = required ? NonEmptyTextValue : TextValue;
1339
1319
  break;
1340
1320
  case FieldType.NUMBER:
1341
1321
  schema = NumberFieldValue;
@@ -1363,7 +1343,7 @@ function createValidationSchema(config) {
1363
1343
  for (const field2 of config) {
1364
1344
  shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
1365
1345
  }
1366
- return import_zod19.z.object(shape);
1346
+ return import_zod16.z.object(shape);
1367
1347
  }
1368
1348
  function mapFieldTypeToMockValue(field2, i) {
1369
1349
  switch (field2.type) {
@@ -1401,6 +1381,8 @@ function mapFieldTypeToMockValue(field2, i) {
1401
1381
  };
1402
1382
  case FieldType.DATE:
1403
1383
  return "2021-01-01";
1384
+ case FieldType.DATE_RANGE:
1385
+ return ["2021-01-01", "2021-01-02"];
1404
1386
  case FieldType.CHECKBOX:
1405
1387
  return true;
1406
1388
  case FieldType.FILE:
@@ -1435,6 +1417,7 @@ function mapFieldTypeToEmptyValue(field2) {
1435
1417
  case FieldType.EMAIL:
1436
1418
  case FieldType.DATE:
1437
1419
  case FieldType.CHECKBOX:
1420
+ case FieldType.DATE_RANGE:
1438
1421
  case FieldType.DATA:
1439
1422
  return null;
1440
1423
  case FieldType.ADDRESS:
@@ -1467,6 +1450,9 @@ var isParagraphFieldType = (field2) => {
1467
1450
  var isDateFieldType = (field2) => {
1468
1451
  return field2.config.type === FieldType.DATE;
1469
1452
  };
1453
+ var isDateRangeFieldType = (field2) => {
1454
+ return field2.config.type === FieldType.DATE_RANGE;
1455
+ };
1470
1456
  var isPageHeaderFieldType = (field2) => {
1471
1457
  return field2.config.type === FieldType.PAGE_HEADER;
1472
1458
  };
@@ -1572,6 +1558,10 @@ function isFieldConditionMet(field2, form, conditionalType) {
1572
1558
  function isFieldVisible(field2, form) {
1573
1559
  return isFieldConditionMet(field2, form, ConditionalType.SHOW);
1574
1560
  }
1561
+ function isFieldEmptyAndNotRequired(field2, form) {
1562
+ const fieldValue = form[field2.id];
1563
+ return !field2.required && (fieldValue === void 0 || fieldValue === "");
1564
+ }
1575
1565
  function isFieldEnabled(field2, form) {
1576
1566
  return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
1577
1567
  }
@@ -1676,7 +1666,7 @@ function runFieldValidations({
1676
1666
  field: field2,
1677
1667
  values
1678
1668
  }) {
1679
- if (!isFieldVisible(field2, values)) {
1669
+ if (!isFieldVisible(field2, values) || isFieldEmptyAndNotRequired(field2, values)) {
1680
1670
  return {
1681
1671
  errors: []
1682
1672
  };
@@ -1741,15 +1731,9 @@ var getActionAnnotationFields = (actionConfig) => {
1741
1731
  }
1742
1732
  return [];
1743
1733
  };
1744
- var getAllAnnotationFields = (config) => {
1734
+ function getAllAnnotationFields(config) {
1745
1735
  return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
1746
- };
1747
- var findAllFields = (config) => {
1748
- return (0, import_lodash.flattenDeep)([
1749
- ...getDeclarationFields(config),
1750
- ...getAllAnnotationFields(config)
1751
- ]);
1752
- };
1736
+ }
1753
1737
  var findRecordActionPages = (config, actionType) => {
1754
1738
  const action = config.actions.find((a) => a.type === actionType);
1755
1739
  if (action?.type === ActionType.REQUEST_CORRECTION) {
@@ -1772,31 +1756,22 @@ function getActionReview(configuration, actionType) {
1772
1756
  function getActionReviewFields(configuration, actionType) {
1773
1757
  return getActionReview(configuration, actionType).fields;
1774
1758
  }
1775
- function validateWorkqueueConfig(workqueueConfigs) {
1776
- workqueueConfigs.map((workqueue) => {
1777
- const rootWorkqueue = Object.values(workqueues).find(
1778
- (wq) => wq.id === workqueue.id
1779
- );
1780
- if (!rootWorkqueue) {
1781
- throw new Error(
1782
- `Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
1783
- );
1784
- }
1785
- });
1786
- }
1787
1759
  function isPageVisible(page, formValues) {
1788
1760
  if (!page.conditional) {
1789
1761
  return true;
1790
1762
  }
1791
1763
  return isConditionMet(page.conditional, formValues);
1792
1764
  }
1793
- function omitHiddenFields(fields, values) {
1765
+ function omitHiddenFields(fields, values, visibleVerificationPageIds = []) {
1794
1766
  return (0, import_lodash.omitBy)(values, (_, fieldId) => {
1795
- const field2 = fields.find((f) => f.id === fieldId);
1796
- if (!field2) {
1767
+ if (visibleVerificationPageIds.includes(fieldId)) {
1768
+ return false;
1769
+ }
1770
+ const fieldConfigs = fields.filter((f) => f.id === fieldId);
1771
+ if (!fieldConfigs.length) {
1797
1772
  return true;
1798
1773
  }
1799
- return !isFieldVisible(field2, values);
1774
+ return fieldConfigs.every((f) => !isFieldVisible(f, values));
1800
1775
  });
1801
1776
  }
1802
1777
  function omitHiddenPaginatedFields(formConfig, declaration) {
@@ -1820,13 +1795,49 @@ function createEmptyDraft(eventId, draftId, actionType) {
1820
1795
  annotation: {},
1821
1796
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1822
1797
  createdBy: "@todo",
1823
- createdAtLocation: "@todo"
1798
+ createdAtLocation: "@todo",
1799
+ status: ActionStatus.Accepted,
1800
+ transactionId: "@todo",
1801
+ createdByRole: "@todo"
1824
1802
  }
1825
1803
  };
1826
1804
  }
1827
1805
  function isVerificationPage(page) {
1828
1806
  return page.type === PageTypes.enum.VERIFICATION;
1829
1807
  }
1808
+ function getVisibleVerificationPageIds(pages, annotation) {
1809
+ return pages.filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page, annotation)).map((page) => page.id);
1810
+ }
1811
+ function getActionVerificationPageIds(actionConfig, annotation) {
1812
+ if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
1813
+ return [
1814
+ ...getVisibleVerificationPageIds(actionConfig.onboardingForm, annotation),
1815
+ ...getVisibleVerificationPageIds(
1816
+ actionConfig.additionalDetailsForm,
1817
+ annotation
1818
+ )
1819
+ ];
1820
+ }
1821
+ if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
1822
+ return getVisibleVerificationPageIds(
1823
+ actionConfig.printForm.pages,
1824
+ annotation
1825
+ );
1826
+ }
1827
+ return [];
1828
+ }
1829
+ function omitHiddenAnnotationFields(actionConfig, declaration, annotation) {
1830
+ const annotationFields = getActionAnnotationFields(actionConfig);
1831
+ const visibleVerificationPageIds = getActionVerificationPageIds(
1832
+ actionConfig,
1833
+ annotation
1834
+ );
1835
+ return omitHiddenFields(
1836
+ annotationFields,
1837
+ { ...declaration, ...annotation },
1838
+ visibleVerificationPageIds
1839
+ );
1840
+ }
1830
1841
  function deepMerge(currentDocument, actionDocument) {
1831
1842
  return (0, import_lodash.mergeWith)(
1832
1843
  currentDocument,
@@ -1853,20 +1864,50 @@ function findLastAssignmentAction(actions) {
1853
1864
  function isWriteAction(actionType) {
1854
1865
  return writeActions.safeParse(actionType).success;
1855
1866
  }
1856
-
1857
- // ../commons/src/events/EventConfig.ts
1858
- var EventConfig = import_zod20.z.object({
1859
- id: import_zod20.z.string().describe(
1860
- 'A machine-readable identifier for the event, e.g. "birth" or "death"'
1861
- ),
1862
- summary: SummaryConfig,
1863
- label: TranslationConfig,
1864
- actions: import_zod20.z.array(ActionConfig),
1865
- declaration: DeclarationFormConfig,
1866
- workqueues: import_zod20.z.array(WorkqueueConfig),
1867
- deduplication: import_zod20.z.array(DeduplicationConfig).optional().default([]),
1868
- advancedSearch: import_zod20.z.array(AdvancedSearchConfig).optional().default([])
1869
- }).superRefine((event2, ctx) => {
1867
+ var findAllFields = (config) => {
1868
+ return (0, import_lodash.flattenDeep)([
1869
+ ...getDeclarationFields(config),
1870
+ ...getAllAnnotationFields(config)
1871
+ ]);
1872
+ };
1873
+ function getMixedPath(obj, path, defaultValue) {
1874
+ const parts = path.split(".");
1875
+ const resolve = (current, segments) => {
1876
+ if (current == null || segments.length === 0) {
1877
+ return current;
1878
+ }
1879
+ for (let i = segments.length; i > 0; i--) {
1880
+ const compoundKey = segments.slice(0, i).join(".");
1881
+ if ((0, import_lodash.has)(current, compoundKey)) {
1882
+ const next = (0, import_lodash.get)(current, compoundKey);
1883
+ return resolve(next, segments.slice(i));
1884
+ }
1885
+ }
1886
+ return void 0;
1887
+ };
1888
+ const result = resolve(obj, parts);
1889
+ return (0, import_lodash.isNil)(result) ? defaultValue : result;
1890
+ }
1891
+
1892
+ // ../commons/src/events/EventConfig.ts
1893
+ var import_zod_openapi4 = require("zod-openapi");
1894
+ (0, import_zod_openapi4.extendZodWithOpenApi)(import_zod17.z);
1895
+ var EventConfig = import_zod17.z.object({
1896
+ id: import_zod17.z.string().describe(
1897
+ 'A machine-readable identifier for the event, e.g. "birth" or "death"'
1898
+ ),
1899
+ dateOfEvent: import_zod17.z.object({ fieldId: import_zod17.z.string() }).optional(),
1900
+ title: TranslationConfig,
1901
+ fallbackTitle: TranslationConfig.optional().describe(
1902
+ "This is a fallback title if actual title resolves to empty string"
1903
+ ),
1904
+ summary: SummaryConfig,
1905
+ label: TranslationConfig,
1906
+ actions: import_zod17.z.array(ActionConfig),
1907
+ declaration: DeclarationFormConfig,
1908
+ deduplication: import_zod17.z.array(DeduplicationConfig).optional().default([]),
1909
+ advancedSearch: import_zod17.z.array(AdvancedSearchConfig).optional().default([])
1910
+ }).superRefine((event2, ctx) => {
1870
1911
  const allFields = findAllFields(event2);
1871
1912
  const fieldIds = allFields.map((field2) => field2.id);
1872
1913
  const advancedSearchFields = event2.advancedSearch.flatMap(
@@ -1881,16 +1922,43 @@ var EventConfig = import_zod20.z.object({
1881
1922
  });
1882
1923
  }
1883
1924
  const invalidFields = event2.advancedSearch.flatMap(
1884
- (section) => section.fields.filter((field2) => !fieldIds.includes(field2.fieldId))
1925
+ (section) => (
1926
+ // Check if the fieldId is not in the fieldIds array
1927
+ // and also not in the metadataFields array
1928
+ section.fields.filter(
1929
+ (field2) => !(fieldIds.includes(field2.fieldId) || EventFieldId.options.includes(field2.fieldId))
1930
+ )
1931
+ )
1885
1932
  );
1886
1933
  if (invalidFields.length > 0) {
1887
1934
  ctx.addIssue({
1888
1935
  code: "custom",
1889
- message: `Advanced search id must match a field id in fields array.
1936
+ message: `Advanced search id must match a field id of form fields or pre-defined metadata fields.
1890
1937
  Invalid AdvancedSearch field IDs for event ${event2.id}: ${invalidFields.map((f) => f.fieldId).join(", ")}`,
1891
1938
  path: ["advancedSearch"]
1892
1939
  });
1893
1940
  }
1941
+ if (event2.dateOfEvent) {
1942
+ const eventDateFieldId = getDeclarationFields(event2).find(
1943
+ ({ id }) => id === event2.dateOfEvent?.fieldId
1944
+ );
1945
+ if (!eventDateFieldId) {
1946
+ ctx.addIssue({
1947
+ code: "custom",
1948
+ message: `Date of event field id must match a field id in fields array.
1949
+ Invalid date of event field ID for event ${event2.id}: ${event2.dateOfEvent.fieldId}`,
1950
+ path: ["dateOfEvent"]
1951
+ });
1952
+ } else if (eventDateFieldId.type !== FieldType.DATE) {
1953
+ ctx.addIssue({
1954
+ code: "custom",
1955
+ message: `Field specified for date of event is of type: ${eventDateFieldId.type}, but it needs to be of type: ${FieldType.DATE}`,
1956
+ path: ["dateOfEvent.fieldType"]
1957
+ });
1958
+ }
1959
+ }
1960
+ }).openapi({
1961
+ ref: "EventConfig"
1894
1962
  });
1895
1963
 
1896
1964
  // ../commons/src/events/EventConfigInput.ts
@@ -1899,307 +1967,810 @@ var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
1899
1967
  var definePage = (page) => PageConfig.parse(page);
1900
1968
  var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
1901
1969
 
1902
- // ../commons/src/events/Draft.ts
1903
- var import_zod23 = require("zod");
1970
+ // ../commons/src/events/WorkqueueConfig.ts
1971
+ var import_zod20 = require("zod");
1904
1972
 
1905
- // ../commons/src/events/ActionDocument.ts
1906
- var import_zod21 = require("zod");
1907
- var ActionUpdate = import_zod21.z.record(import_zod21.z.string(), FieldUpdateValue);
1908
- var ActionStatus = {
1909
- Requested: "Requested",
1910
- Accepted: "Accepted",
1911
- Rejected: "Rejected"
1973
+ // ../commons/src/events/EventIndex.ts
1974
+ var import_zod19 = require("zod");
1975
+
1976
+ // ../commons/src/events/EventMetadata.ts
1977
+ var import_zod18 = require("zod");
1978
+ var EventStatus = {
1979
+ CREATED: "CREATED",
1980
+ NOTIFIED: "NOTIFIED",
1981
+ DECLARED: "DECLARED",
1982
+ VALIDATED: "VALIDATED",
1983
+ REGISTERED: "REGISTERED",
1984
+ CERTIFIED: "CERTIFIED",
1985
+ REJECTED: "REJECTED",
1986
+ ARCHIVED: "ARCHIVED"
1912
1987
  };
1913
- var ActionBase = import_zod21.z.object({
1914
- id: import_zod21.z.string(),
1915
- createdAt: import_zod21.z.string().datetime(),
1916
- createdBy: import_zod21.z.string(),
1917
- declaration: ActionUpdate,
1918
- annotation: ActionUpdate.optional(),
1919
- createdAtLocation: import_zod21.z.string(),
1920
- status: import_zod21.z.enum([
1921
- ActionStatus.Requested,
1922
- ActionStatus.Accepted,
1923
- ActionStatus.Rejected
1924
- ]),
1925
- // If the action is an asynchronous confirmation for another action, we will save the original action id here.
1926
- originalActionId: import_zod21.z.string().optional()
1988
+ var CustomFlags = {
1989
+ CERTIFICATE_PRINTED: "certificate-printed"
1990
+ };
1991
+ var Flag = import_zod18.z.string().regex(
1992
+ new RegExp(
1993
+ `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(ActionStatus).join("|").toLowerCase()})$`
1994
+ ),
1995
+ "Flag must be in the format ActionType:ActionStatus (lowerCase)"
1996
+ ).or(import_zod18.z.nativeEnum(CustomFlags));
1997
+ var eventStatuses = Object.values(EventStatus);
1998
+ var EventStatuses = import_zod18.z.nativeEnum(EventStatus);
1999
+ var ZodDate = import_zod18.z.string().date();
2000
+ var ActionCreationMetadata = import_zod18.z.object({
2001
+ createdAt: import_zod18.z.string().datetime().describe("The timestamp when the action request was created."),
2002
+ createdBy: import_zod18.z.string().describe("ID of the user who created the action request."),
2003
+ createdAtLocation: import_zod18.z.string().describe("Location of the user who created the action request."),
2004
+ acceptedAt: import_zod18.z.string().datetime().describe("Timestamp when the action request was accepted."),
2005
+ createdByRole: import_zod18.z.string().describe("Role of the user at the time of action request creation.")
1927
2006
  });
1928
- var AssignedAction = ActionBase.merge(
1929
- import_zod21.z.object({
1930
- type: import_zod21.z.literal(ActionType.ASSIGN),
1931
- assignedTo: import_zod21.z.string()
1932
- })
1933
- );
1934
- var UnassignedAction = ActionBase.merge(
1935
- import_zod21.z.object({
1936
- type: import_zod21.z.literal(ActionType.UNASSIGN),
1937
- assignedTo: import_zod21.z.literal(null).default(null)
1938
- })
1939
- );
1940
- var RegisterAction = ActionBase.merge(
1941
- import_zod21.z.object({
1942
- type: import_zod21.z.literal(ActionType.REGISTER),
1943
- registrationNumber: import_zod21.z.string().optional()
1944
- })
1945
- );
1946
- var DeclareAction = ActionBase.merge(
1947
- import_zod21.z.object({
1948
- type: import_zod21.z.literal(ActionType.DECLARE)
1949
- })
1950
- );
1951
- var ValidateAction = ActionBase.merge(
1952
- import_zod21.z.object({
1953
- type: import_zod21.z.literal(ActionType.VALIDATE)
1954
- })
1955
- );
1956
- var RejectAction = ActionBase.merge(
1957
- import_zod21.z.object({
1958
- type: import_zod21.z.literal(ActionType.REJECT)
1959
- })
1960
- );
1961
- var MarkAsDuplicateAction = ActionBase.merge(
1962
- import_zod21.z.object({
1963
- type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE)
1964
- })
1965
- );
1966
- var ArchiveAction = ActionBase.merge(
1967
- import_zod21.z.object({
1968
- type: import_zod21.z.literal(ActionType.ARCHIVE)
1969
- })
1970
- );
1971
- var CreatedAction = ActionBase.merge(
1972
- import_zod21.z.object({
1973
- type: import_zod21.z.literal(ActionType.CREATE)
1974
- })
1975
- );
1976
- var NotifiedAction = ActionBase.merge(
1977
- import_zod21.z.object({
1978
- type: import_zod21.z.literal(ActionType.NOTIFY)
1979
- })
1980
- );
1981
- var PrintCertificateAction = ActionBase.merge(
1982
- import_zod21.z.object({
1983
- type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE)
1984
- })
1985
- );
1986
- var RequestedCorrectionAction = ActionBase.merge(
1987
- import_zod21.z.object({
1988
- type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION)
1989
- })
1990
- );
1991
- var ApprovedCorrectionAction = ActionBase.merge(
1992
- import_zod21.z.object({
1993
- type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION),
1994
- requestId: import_zod21.z.string()
1995
- })
1996
- );
1997
- var RejectedCorrectionAction = ActionBase.merge(
1998
- import_zod21.z.object({
1999
- type: import_zod21.z.literal(ActionType.REJECT_CORRECTION),
2000
- requestId: import_zod21.z.string()
2007
+ var RegistrationCreationMetadata = ActionCreationMetadata.extend({
2008
+ registrationNumber: import_zod18.z.string().describe(
2009
+ "Registration number of the event. Always present for accepted registrations."
2010
+ )
2011
+ });
2012
+ var LegalStatuses = import_zod18.z.object({
2013
+ [EventStatus.DECLARED]: ActionCreationMetadata.nullish(),
2014
+ [EventStatus.REGISTERED]: RegistrationCreationMetadata.nullish()
2015
+ });
2016
+ var EventMetadata = import_zod18.z.object({
2017
+ id: import_zod18.z.string(),
2018
+ type: import_zod18.z.string().describe("The type of event, such as birth, death, or marriage."),
2019
+ status: EventStatuses,
2020
+ legalStatuses: LegalStatuses.describe(
2021
+ "Metadata related to the legal registration of the event, such as who registered it and when."
2022
+ ),
2023
+ createdAt: import_zod18.z.string().datetime().describe("The timestamp when the event was first created and saved."),
2024
+ dateOfEvent: ZodDate.nullish(),
2025
+ createdBy: import_zod18.z.string().describe("ID of the user who created the event."),
2026
+ updatedByUserRole: import_zod18.z.string().describe("Role of the user who last updated the declaration."),
2027
+ createdAtLocation: import_zod18.z.string().describe("Location of the user who created the event."),
2028
+ updatedAtLocation: import_zod18.z.string().nullish().describe("Location of the user who last updated the declaration."),
2029
+ updatedAt: import_zod18.z.string().datetime().describe("Timestamp of the most recent declaration update."),
2030
+ assignedTo: import_zod18.z.string().nullish().describe("ID of the user currently assigned to the event."),
2031
+ updatedBy: import_zod18.z.string().nullish().describe("ID of the user who last updated the declaration."),
2032
+ trackingId: import_zod18.z.string().describe(
2033
+ "System-generated tracking ID used by informants or registrars to look up the event."
2034
+ ),
2035
+ flags: import_zod18.z.array(Flag)
2036
+ });
2037
+ var EventMetadataKeys = import_zod18.z.enum([
2038
+ "id",
2039
+ "type",
2040
+ "status",
2041
+ "createdAt",
2042
+ "dateOfEvent",
2043
+ "createdBy",
2044
+ "updatedByUserRole",
2045
+ "createdAtLocation",
2046
+ "updatedAtLocation",
2047
+ "updatedAt",
2048
+ "assignedTo",
2049
+ "updatedBy",
2050
+ "trackingId",
2051
+ "legalStatuses",
2052
+ "flags"
2053
+ ]);
2054
+ var EventMetadataParameter = import_zod18.z.object({
2055
+ // @TODO: Reconcile with the event metadata definition. How could we derive one from the other?
2056
+ $event: EventMetadataKeys
2057
+ });
2058
+ var eventMetadataLabelMap = {
2059
+ "event.assignedTo": {
2060
+ id: "event.assignedTo.label",
2061
+ defaultMessage: "Assigned To",
2062
+ description: "Assigned To"
2063
+ },
2064
+ "event.createdAt": {
2065
+ id: "event.createdAt.label",
2066
+ defaultMessage: "Created",
2067
+ description: "Created At"
2068
+ },
2069
+ "event.dateOfEvent": {
2070
+ id: "event.dateOfEvent.label",
2071
+ defaultMessage: "Date of Event",
2072
+ description: "Date of Event"
2073
+ },
2074
+ "event.createdAtLocation": {
2075
+ id: "event.createdAtLocation.label",
2076
+ defaultMessage: "Location",
2077
+ description: "Created At Location"
2078
+ },
2079
+ "event.updatedAtLocation": {
2080
+ id: "event.updatedAtLocation.label",
2081
+ defaultMessage: "Location",
2082
+ description: "Updated At Location"
2083
+ },
2084
+ "event.createdBy": {
2085
+ id: "event.createdBy.label",
2086
+ defaultMessage: "Created By",
2087
+ description: "Created By"
2088
+ },
2089
+ "event.updatedByUserRole": {
2090
+ id: "event.updatedByUserRole.label",
2091
+ defaultMessage: "Updated By Role",
2092
+ description: "Updated By Role"
2093
+ },
2094
+ "event.id": {
2095
+ id: "event.id.label",
2096
+ defaultMessage: "ID",
2097
+ description: "ID"
2098
+ },
2099
+ "event.updatedAt": {
2100
+ id: "event.modifiedAt.label",
2101
+ defaultMessage: "Updated",
2102
+ description: "Modified At"
2103
+ },
2104
+ "event.status": {
2105
+ id: "event.status.label",
2106
+ defaultMessage: "Status",
2107
+ description: "Status"
2108
+ },
2109
+ "event.type": {
2110
+ id: "event.type.label",
2111
+ defaultMessage: "Type",
2112
+ description: "Type"
2113
+ },
2114
+ "event.updatedBy": {
2115
+ id: "event.updatedBy.label",
2116
+ defaultMessage: "Updated By",
2117
+ description: "Updated By"
2118
+ },
2119
+ "event.trackingId": {
2120
+ id: "event.trackingId.label",
2121
+ defaultMessage: "Tracking ID",
2122
+ description: "Tracking ID"
2123
+ },
2124
+ "event.flags": {
2125
+ id: "event.flags.label",
2126
+ defaultMessage: "Flags",
2127
+ description: "Flags"
2128
+ }
2129
+ };
2130
+
2131
+ // ../commons/src/events/EventIndex.ts
2132
+ var EventIndex = EventMetadata.extend({
2133
+ declaration: EventState
2134
+ });
2135
+ var EventSearchIndex = import_zod19.z.record(import_zod19.z.string(), import_zod19.z.any()).and(
2136
+ import_zod19.z.object({
2137
+ type: import_zod19.z.string()
2138
+ // Ensures "type" (event-id) exists and is a string
2001
2139
  })
2002
2140
  );
2003
- var ReadAction = ActionBase.merge(
2004
- import_zod21.z.object({
2005
- type: import_zod21.z.literal(ActionType.READ)
2006
- })
2141
+ var Fuzzy = import_zod19.z.object({ type: import_zod19.z.literal("fuzzy"), term: import_zod19.z.string() });
2142
+ var Exact = import_zod19.z.object({ type: import_zod19.z.literal("exact"), term: import_zod19.z.string() });
2143
+ var AnyOf = import_zod19.z.object({
2144
+ type: import_zod19.z.literal("anyOf"),
2145
+ terms: import_zod19.z.array(import_zod19.z.string())
2146
+ });
2147
+ var Range = import_zod19.z.object({
2148
+ type: import_zod19.z.literal("range"),
2149
+ gte: import_zod19.z.string(),
2150
+ lte: import_zod19.z.string()
2151
+ });
2152
+ var Not = import_zod19.z.object({ type: import_zod19.z.literal("not"), term: import_zod19.z.string() });
2153
+ var Within = import_zod19.z.object({ type: import_zod19.z.literal("within"), location: import_zod19.z.string() });
2154
+ var DateCondition = import_zod19.z.union([Exact, Range]);
2155
+ var QueryInput = import_zod19.z.lazy(
2156
+ () => import_zod19.z.union([
2157
+ import_zod19.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf, Not]),
2158
+ import_zod19.z.record(import_zod19.z.string(), QueryInput)
2159
+ ])
2007
2160
  );
2008
- var ActionDocument = import_zod21.z.discriminatedUnion("type", [
2009
- CreatedAction,
2010
- ValidateAction,
2011
- RejectAction,
2012
- MarkAsDuplicateAction,
2013
- ArchiveAction,
2014
- NotifiedAction,
2015
- RegisterAction,
2016
- DeclareAction,
2017
- AssignedAction,
2018
- RequestedCorrectionAction,
2019
- ApprovedCorrectionAction,
2020
- RejectedCorrectionAction,
2021
- UnassignedAction,
2022
- PrintCertificateAction,
2023
- ReadAction
2024
- ]);
2025
- var AsyncRejectActionDocument = ActionBase.omit({
2026
- declaration: true,
2027
- annotation: true,
2028
- createdBy: true,
2029
- createdAtLocation: true
2030
- }).merge(
2031
- import_zod21.z.object({
2032
- type: import_zod21.z.enum(ConfirmableActions),
2033
- status: import_zod21.z.literal(ActionStatus.Rejected)
2161
+ var QueryExpression = import_zod19.z.object({
2162
+ eventType: import_zod19.z.string(),
2163
+ status: import_zod19.z.optional(import_zod19.z.union([AnyOf, Exact])),
2164
+ createdAt: import_zod19.z.optional(DateCondition),
2165
+ updatedAt: import_zod19.z.optional(DateCondition),
2166
+ createAtLocation: import_zod19.z.optional(import_zod19.z.union([Within, Exact])),
2167
+ updatedAtLocation: import_zod19.z.optional(import_zod19.z.union([Within, Exact])),
2168
+ createdBy: import_zod19.z.optional(Exact),
2169
+ updatedBy: import_zod19.z.optional(Exact),
2170
+ trackingId: import_zod19.z.optional(Exact),
2171
+ flags: import_zod19.z.optional(import_zod19.z.array(import_zod19.z.union([AnyOf, Not]))),
2172
+ data: QueryInput
2173
+ }).partial();
2174
+ var Or2 = import_zod19.z.object({
2175
+ type: import_zod19.z.literal("or"),
2176
+ clauses: import_zod19.z.array(QueryExpression)
2177
+ });
2178
+ var And2 = import_zod19.z.object({
2179
+ type: import_zod19.z.literal("and"),
2180
+ clauses: import_zod19.z.array(QueryExpression)
2181
+ });
2182
+ var QueryType = import_zod19.z.discriminatedUnion("type", [Or2, And2]);
2183
+
2184
+ // ../commons/src/conditionals/conditionals.ts
2185
+ function defineConditional(schema) {
2186
+ return schema;
2187
+ }
2188
+ function defineFormConditional(schema) {
2189
+ const schemaWithForm = {
2190
+ type: "object",
2191
+ properties: {
2192
+ $form: schema
2193
+ },
2194
+ required: ["$form"]
2195
+ };
2196
+ return defineConditional(schemaWithForm);
2197
+ }
2198
+ function alwaysTrue() {
2199
+ return {};
2200
+ }
2201
+ function and(...conditions) {
2202
+ return defineConditional({
2203
+ type: "object",
2204
+ allOf: conditions,
2205
+ required: []
2206
+ });
2207
+ }
2208
+ function or(...conditions) {
2209
+ return defineConditional({
2210
+ type: "object",
2211
+ anyOf: conditions,
2212
+ required: []
2213
+ });
2214
+ }
2215
+ function not(condition) {
2216
+ return defineConditional({
2217
+ type: "object",
2218
+ not: condition,
2219
+ required: []
2220
+ });
2221
+ }
2222
+ function never() {
2223
+ return not(alwaysTrue());
2224
+ }
2225
+ var user = {
2226
+ hasScope: (scope) => defineConditional({
2227
+ type: "object",
2228
+ properties: {
2229
+ $user: {
2230
+ type: "object",
2231
+ required: ["scope"],
2232
+ properties: {
2233
+ scope: {
2234
+ type: "array",
2235
+ contains: {
2236
+ type: "string",
2237
+ const: scope
2238
+ }
2239
+ }
2240
+ }
2241
+ }
2242
+ },
2243
+ required: ["$user"]
2034
2244
  })
2035
- );
2036
- var Action = import_zod21.z.union([ActionDocument, AsyncRejectActionDocument]);
2037
- var ResolvedUser = import_zod21.z.object({
2038
- id: import_zod21.z.string(),
2039
- role: import_zod21.z.string(),
2040
- name: import_zod21.z.array(
2041
- import_zod21.z.object({
2042
- use: import_zod21.z.string(),
2043
- given: import_zod21.z.array(import_zod21.z.string()),
2044
- family: import_zod21.z.string()
2245
+ };
2246
+ function createEventConditionals() {
2247
+ return {
2248
+ /**
2249
+ * Checks if the event contains a specific action type.
2250
+ * @param action - The action type to check for.
2251
+ */
2252
+ hasAction: (action) => defineConditional({
2253
+ type: "object",
2254
+ properties: {
2255
+ $event: {
2256
+ type: "object",
2257
+ properties: {
2258
+ actions: {
2259
+ type: "array",
2260
+ contains: {
2261
+ type: "object",
2262
+ properties: {
2263
+ type: {
2264
+ const: action
2265
+ }
2266
+ },
2267
+ required: ["type"]
2268
+ }
2269
+ }
2270
+ },
2271
+ required: ["actions"]
2272
+ }
2273
+ },
2274
+ required: ["$event"]
2045
2275
  })
2046
- )
2276
+ };
2277
+ }
2278
+ function getDateFromNow(days) {
2279
+ return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
2280
+ }
2281
+ function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
2282
+ return {
2283
+ type: "object",
2284
+ properties: {
2285
+ [fieldId]: {
2286
+ type: "string",
2287
+ format: "date",
2288
+ [clause]: { $data: `1/${comparedFieldId}` }
2289
+ },
2290
+ [comparedFieldId]: { type: "string", format: "date" }
2291
+ },
2292
+ required: [fieldId]
2293
+ };
2294
+ }
2295
+ function isFieldReference(value) {
2296
+ return typeof value === "object" && value !== null && "_fieldId" in value;
2297
+ }
2298
+ function createFieldConditionals(fieldId) {
2299
+ const getDateRange = (date, clause) => ({
2300
+ type: "object",
2301
+ properties: {
2302
+ [fieldId]: {
2303
+ type: "string",
2304
+ format: "date",
2305
+ [clause]: date
2306
+ }
2307
+ },
2308
+ required: [fieldId]
2309
+ });
2310
+ return {
2311
+ isAfter: () => ({
2312
+ days: (days) => ({
2313
+ inPast: () => defineFormConditional(
2314
+ getDateRange(getDateFromNow(days), "formatMinimum")
2315
+ ),
2316
+ inFuture: () => defineFormConditional(
2317
+ getDateRange(getDateFromNow(-days), "formatMinimum")
2318
+ )
2319
+ }),
2320
+ date: (date) => {
2321
+ if (isFieldReference(date)) {
2322
+ const comparedFieldId = date._fieldId;
2323
+ return defineFormConditional(
2324
+ getDateRangeToFieldReference(
2325
+ fieldId,
2326
+ comparedFieldId,
2327
+ "formatMinimum"
2328
+ )
2329
+ );
2330
+ }
2331
+ return defineFormConditional(getDateRange(date, "formatMinimum"));
2332
+ },
2333
+ now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
2334
+ }),
2335
+ isBefore: () => ({
2336
+ days: (days) => ({
2337
+ inPast: () => defineFormConditional(
2338
+ getDateRange(getDateFromNow(days), "formatMaximum")
2339
+ ),
2340
+ inFuture: () => defineFormConditional(
2341
+ getDateRange(getDateFromNow(-days), "formatMaximum")
2342
+ )
2343
+ }),
2344
+ date: (date) => {
2345
+ if (isFieldReference(date)) {
2346
+ const comparedFieldId = date._fieldId;
2347
+ return defineFormConditional(
2348
+ getDateRangeToFieldReference(
2349
+ fieldId,
2350
+ comparedFieldId,
2351
+ "formatMaximum"
2352
+ )
2353
+ );
2354
+ }
2355
+ return defineFormConditional(getDateRange(date, "formatMaximum"));
2356
+ },
2357
+ now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
2358
+ }),
2359
+ isEqualTo: (value) => {
2360
+ if (isFieldReference(value)) {
2361
+ const comparedFieldId = value._fieldId;
2362
+ return defineFormConditional({
2363
+ type: "object",
2364
+ properties: {
2365
+ [fieldId]: {
2366
+ type: ["string", "boolean"],
2367
+ const: { $data: `1/${comparedFieldId}` }
2368
+ },
2369
+ [comparedFieldId]: { type: ["string", "boolean"] }
2370
+ },
2371
+ required: [fieldId, comparedFieldId]
2372
+ });
2373
+ }
2374
+ return defineFormConditional({
2375
+ type: "object",
2376
+ properties: {
2377
+ [fieldId]: {
2378
+ oneOf: [
2379
+ { type: "string", const: value },
2380
+ { type: "boolean", const: value }
2381
+ ],
2382
+ const: value
2383
+ }
2384
+ },
2385
+ required: [fieldId]
2386
+ });
2387
+ },
2388
+ /**
2389
+ * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
2390
+ * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
2391
+ * @returns whether the field is falsy (undefined, false, null, empty string)
2392
+ *
2393
+ * NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
2394
+ *
2395
+ */
2396
+ isFalsy: () => defineFormConditional({
2397
+ type: "object",
2398
+ properties: {
2399
+ [fieldId]: {
2400
+ anyOf: [
2401
+ { const: "undefined" },
2402
+ { const: false },
2403
+ { const: null },
2404
+ { const: "" }
2405
+ ]
2406
+ }
2407
+ },
2408
+ anyOf: [
2409
+ {
2410
+ required: [fieldId]
2411
+ },
2412
+ {
2413
+ not: {
2414
+ required: [fieldId]
2415
+ }
2416
+ }
2417
+ ]
2418
+ }),
2419
+ isUndefined: () => defineFormConditional({
2420
+ type: "object",
2421
+ properties: {
2422
+ [fieldId]: {
2423
+ type: "string",
2424
+ enum: ["undefined"]
2425
+ }
2426
+ },
2427
+ not: {
2428
+ required: [fieldId]
2429
+ }
2430
+ }),
2431
+ inArray: (values) => defineFormConditional({
2432
+ type: "object",
2433
+ properties: {
2434
+ [fieldId]: {
2435
+ type: "string",
2436
+ enum: values
2437
+ }
2438
+ },
2439
+ required: [fieldId]
2440
+ }),
2441
+ isValidEnglishName: () => defineFormConditional({
2442
+ type: "object",
2443
+ properties: {
2444
+ [fieldId]: {
2445
+ type: "string",
2446
+ 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'._-]*)*$",
2447
+ description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
2448
+ }
2449
+ },
2450
+ required: [fieldId]
2451
+ }),
2452
+ /**
2453
+ * Checks if the field value matches a given regular expression pattern.
2454
+ * @param pattern - The regular expression pattern to match the field value against.
2455
+ * @returns A JSONSchema conditional that validates the field value against the pattern.
2456
+ */
2457
+ matches: (pattern) => defineFormConditional({
2458
+ type: "object",
2459
+ properties: {
2460
+ [fieldId]: {
2461
+ type: "string",
2462
+ pattern
2463
+ }
2464
+ },
2465
+ required: [fieldId]
2466
+ }),
2467
+ isBetween: (min, max) => defineFormConditional({
2468
+ type: "object",
2469
+ properties: {
2470
+ [fieldId]: {
2471
+ type: "number",
2472
+ minimum: min,
2473
+ maximum: max
2474
+ }
2475
+ },
2476
+ required: [fieldId]
2477
+ }),
2478
+ getId: () => ({ fieldId })
2479
+ };
2480
+ }
2481
+
2482
+ // ../commons/src/event-config/event-configuration.ts
2483
+ function createEventFieldConfig(fieldId, options) {
2484
+ return {
2485
+ fieldId,
2486
+ options,
2487
+ config: { type: "exact" },
2488
+ fieldType: "event"
2489
+ };
2490
+ }
2491
+
2492
+ // ../commons/src/events/event.ts
2493
+ function eventFn(fieldId, options) {
2494
+ return createEventFieldConfig(fieldId, options);
2495
+ }
2496
+ var event = Object.assign(eventFn, {
2497
+ ...createEventConditionals(),
2498
+ field(field2) {
2499
+ return {
2500
+ $event: field2
2501
+ };
2502
+ }
2047
2503
  });
2048
2504
 
2049
- // ../commons/src/events/ActionInput.ts
2505
+ // ../commons/src/events/WorkqueueConfig.ts
2506
+ var WorkqueueConfig = import_zod20.z.object({
2507
+ slug: import_zod20.z.string().describe("Determines the url of the workqueue."),
2508
+ name: TranslationConfig.describe(
2509
+ "Title of the workflow (both in navigation and on the page)"
2510
+ ),
2511
+ query: QueryType,
2512
+ actions: import_zod20.z.array(
2513
+ import_zod20.z.object({
2514
+ type: import_zod20.z.string(),
2515
+ conditionals: import_zod20.z.array(Conditional).optional()
2516
+ })
2517
+ ),
2518
+ columns: import_zod20.z.array(
2519
+ import_zod20.z.object({ label: TranslationConfig, value: EventMetadataParameter })
2520
+ ).default([
2521
+ {
2522
+ label: {
2523
+ id: "workqueues.dateOfEvent",
2524
+ defaultMessage: "Date of Event",
2525
+ description: "Label for workqueue column: dateOfEvent"
2526
+ },
2527
+ value: event.field("dateOfEvent")
2528
+ }
2529
+ ])
2530
+ }).describe("Configuration for workqueue.");
2531
+ function defineWorkqueue(workqueues) {
2532
+ return workqueues.map((workqueue) => WorkqueueConfig.parse(workqueue));
2533
+ }
2534
+
2535
+ // ../commons/src/events/Draft.ts
2050
2536
  var import_zod22 = require("zod");
2051
- var BaseActionInput = import_zod22.z.object({
2052
- eventId: import_zod22.z.string(),
2053
- transactionId: import_zod22.z.string(),
2537
+
2538
+ // ../commons/src/events/ActionInput.ts
2539
+ var import_zod21 = require("zod");
2540
+ var import_zod_openapi5 = require("zod-openapi");
2541
+ (0, import_zod_openapi5.extendZodWithOpenApi)(import_zod21.z);
2542
+ var BaseActionInput = import_zod21.z.object({
2543
+ eventId: import_zod21.z.string(),
2544
+ transactionId: import_zod21.z.string(),
2054
2545
  declaration: ActionUpdate.default({}),
2055
2546
  annotation: ActionUpdate.optional(),
2056
- originalActionId: import_zod22.z.string().optional(),
2057
- keepAssignment: import_zod22.z.boolean().optional()
2547
+ originalActionId: import_zod21.z.string().optional(),
2548
+ keepAssignment: import_zod21.z.boolean().optional()
2058
2549
  });
2059
2550
  var CreateActionInput = BaseActionInput.merge(
2060
- import_zod22.z.object({
2061
- type: import_zod22.z.literal(ActionType.CREATE).default(ActionType.CREATE),
2062
- createdAtLocation: import_zod22.z.string()
2551
+ import_zod21.z.object({
2552
+ type: import_zod21.z.literal(ActionType.CREATE).default(ActionType.CREATE),
2553
+ createdAtLocation: import_zod21.z.string()
2063
2554
  })
2064
2555
  );
2065
2556
  var RegisterActionInput = BaseActionInput.merge(
2066
- import_zod22.z.object({
2067
- type: import_zod22.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
2068
- registrationNumber: import_zod22.z.string().optional()
2557
+ import_zod21.z.object({
2558
+ type: import_zod21.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
2559
+ registrationNumber: import_zod21.z.string().optional()
2069
2560
  })
2070
2561
  );
2071
2562
  var ValidateActionInput = BaseActionInput.merge(
2072
- import_zod22.z.object({
2073
- type: import_zod22.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
2074
- duplicates: import_zod22.z.array(import_zod22.z.string())
2563
+ import_zod21.z.object({
2564
+ type: import_zod21.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
2565
+ duplicates: import_zod21.z.array(import_zod21.z.string())
2075
2566
  })
2076
2567
  );
2077
2568
  var NotifyActionInput = BaseActionInput.merge(
2078
- import_zod22.z.object({
2079
- type: import_zod22.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
2569
+ import_zod21.z.object({
2570
+ type: import_zod21.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
2080
2571
  })
2081
2572
  );
2082
2573
  var DeclareActionInput = BaseActionInput.merge(
2083
- import_zod22.z.object({
2084
- type: import_zod22.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
2574
+ import_zod21.z.object({
2575
+ type: import_zod21.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
2085
2576
  })
2086
2577
  );
2087
2578
  var PrintCertificateActionInput = BaseActionInput.merge(
2088
- import_zod22.z.object({
2089
- type: import_zod22.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
2579
+ import_zod21.z.object({
2580
+ type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
2090
2581
  })
2091
2582
  );
2092
2583
  var RejectDeclarationActionInput = BaseActionInput.merge(
2093
- import_zod22.z.object({
2094
- type: import_zod22.z.literal(ActionType.REJECT).default(ActionType.REJECT)
2584
+ import_zod21.z.object({
2585
+ type: import_zod21.z.literal(ActionType.REJECT).default(ActionType.REJECT)
2095
2586
  })
2096
2587
  );
2097
2588
  var MarkedAsDuplicateActionInput = BaseActionInput.merge(
2098
- import_zod22.z.object({
2099
- type: import_zod22.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
2589
+ import_zod21.z.object({
2590
+ type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
2100
2591
  })
2101
2592
  );
2102
2593
  var ArchiveActionInput = BaseActionInput.merge(
2103
- import_zod22.z.object({
2104
- type: import_zod22.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
2594
+ import_zod21.z.object({
2595
+ type: import_zod21.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
2105
2596
  })
2106
2597
  );
2107
2598
  var AssignActionInput = BaseActionInput.merge(
2108
- import_zod22.z.object({
2109
- type: import_zod22.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
2110
- assignedTo: import_zod22.z.string()
2599
+ import_zod21.z.object({
2600
+ type: import_zod21.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
2601
+ assignedTo: import_zod21.z.string()
2111
2602
  })
2112
2603
  );
2113
2604
  var UnassignActionInput = BaseActionInput.merge(
2114
- import_zod22.z.object({
2115
- type: import_zod22.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
2116
- assignedTo: import_zod22.z.literal(null).default(null)
2605
+ import_zod21.z.object({
2606
+ type: import_zod21.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
2607
+ assignedTo: import_zod21.z.literal(null).default(null)
2117
2608
  })
2118
2609
  );
2119
2610
  var RequestCorrectionActionInput = BaseActionInput.merge(
2120
- import_zod22.z.object({
2121
- type: import_zod22.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
2611
+ import_zod21.z.object({
2612
+ type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
2122
2613
  })
2123
2614
  );
2124
2615
  var RejectCorrectionActionInput = BaseActionInput.merge(
2125
- import_zod22.z.object({
2126
- requestId: import_zod22.z.string(),
2127
- type: import_zod22.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
2616
+ import_zod21.z.object({
2617
+ requestId: import_zod21.z.string(),
2618
+ type: import_zod21.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
2128
2619
  })
2129
2620
  );
2130
2621
  var ApproveCorrectionActionInput = BaseActionInput.merge(
2131
- import_zod22.z.object({
2132
- requestId: import_zod22.z.string(),
2133
- type: import_zod22.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
2622
+ import_zod21.z.object({
2623
+ requestId: import_zod21.z.string(),
2624
+ type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
2134
2625
  })
2135
2626
  );
2136
2627
  var ReadActionInput = BaseActionInput.merge(
2137
- import_zod22.z.object({
2138
- type: import_zod22.z.literal(ActionType.READ).default(ActionType.READ)
2628
+ import_zod21.z.object({
2629
+ type: import_zod21.z.literal(ActionType.READ).default(ActionType.READ)
2139
2630
  })
2140
2631
  );
2141
- var ActionInput = import_zod22.z.discriminatedUnion("type", [
2142
- CreateActionInput,
2143
- ValidateActionInput,
2144
- RegisterActionInput,
2145
- NotifyActionInput,
2146
- DeclareActionInput,
2147
- RejectDeclarationActionInput,
2148
- MarkedAsDuplicateActionInput,
2149
- ArchiveActionInput,
2150
- AssignActionInput,
2151
- UnassignActionInput,
2152
- PrintCertificateActionInput,
2153
- RequestCorrectionActionInput,
2154
- RejectCorrectionActionInput,
2155
- ApproveCorrectionActionInput,
2156
- ReadActionInput
2157
- ]);
2632
+ var DeleteActionInput = import_zod21.z.object({ eventId: import_zod21.z.string() });
2633
+ var ActionInput = import_zod21.z.discriminatedUnion("type", [
2634
+ CreateActionInput.openapi({ ref: "CreateActionInput" }),
2635
+ ValidateActionInput.openapi({ ref: "ValidateActionInput" }),
2636
+ RegisterActionInput.openapi({ ref: "RegisterActionInput" }),
2637
+ NotifyActionInput.openapi({ ref: "NotifyActionInput" }),
2638
+ DeclareActionInput.openapi({ ref: "DeclareActionInput" }),
2639
+ RejectDeclarationActionInput.openapi({
2640
+ ref: "RejectDeclarationActionInput"
2641
+ }),
2642
+ MarkedAsDuplicateActionInput.openapi({
2643
+ ref: "MarkedAsDuplicateActionInput"
2644
+ }),
2645
+ ArchiveActionInput.openapi({ ref: "ArchiveActionInput" }),
2646
+ AssignActionInput.openapi({ ref: "AssignActionInput" }),
2647
+ UnassignActionInput.openapi({ ref: "UnassignActionInput" }),
2648
+ PrintCertificateActionInput.openapi({ ref: "PrintCertificateActionInput" }),
2649
+ RequestCorrectionActionInput.openapi({
2650
+ ref: "RequestCorrectionActionInput"
2651
+ }),
2652
+ RejectCorrectionActionInput.openapi({ ref: "RejectCorrectionActionInput" }),
2653
+ ApproveCorrectionActionInput.openapi({
2654
+ ref: "ApproveCorrectionActionInput"
2655
+ }),
2656
+ ReadActionInput.openapi({ ref: "ReadActionInput" })
2657
+ ]).openapi({
2658
+ ref: "ActionInput"
2659
+ });
2158
2660
 
2159
2661
  // ../commons/src/events/Draft.ts
2160
- var Draft = import_zod23.z.object({
2161
- id: import_zod23.z.string(),
2162
- eventId: import_zod23.z.string(),
2163
- transactionId: import_zod23.z.string(),
2164
- createdAt: import_zod23.z.string().datetime(),
2662
+ var Draft = import_zod22.z.object({
2663
+ id: import_zod22.z.string(),
2664
+ eventId: import_zod22.z.string(),
2665
+ transactionId: import_zod22.z.string(),
2666
+ createdAt: import_zod22.z.string().datetime(),
2165
2667
  action: ActionBase.extend({
2166
2668
  type: ActionTypes
2167
2669
  }).omit({ id: true })
2168
2670
  });
2169
2671
  var DraftInput = BaseActionInput.extend({
2170
- type: ActionTypes
2672
+ type: ActionTypes,
2673
+ status: import_zod22.z.enum([
2674
+ ActionStatus.Requested,
2675
+ ActionStatus.Accepted,
2676
+ ActionStatus.Rejected
2677
+ ])
2171
2678
  });
2172
2679
 
2173
2680
  // ../commons/src/events/EventInput.ts
2174
- var import_zod24 = require("zod");
2175
- var EventInput = import_zod24.z.object({
2176
- transactionId: import_zod24.z.string(),
2177
- type: import_zod24.z.string()
2681
+ var import_zod23 = require("zod");
2682
+ var EventInput = import_zod23.z.object({
2683
+ transactionId: import_zod23.z.string(),
2684
+ type: import_zod23.z.string(),
2685
+ dateOfEvent: import_zod23.z.object({ fieldId: import_zod23.z.string() }).optional()
2178
2686
  });
2179
2687
 
2180
2688
  // ../commons/src/events/EventDocument.ts
2181
- var import_zod25 = require("zod");
2182
- var EventDocument = import_zod25.z.object({
2183
- id: import_zod25.z.string(),
2184
- type: import_zod25.z.string(),
2185
- createdAt: import_zod25.z.string().datetime(),
2186
- updatedAt: import_zod25.z.string().datetime(),
2187
- updatedAtLocation: import_zod25.z.string(),
2188
- actions: import_zod25.z.array(Action),
2189
- trackingId: import_zod25.z.string()
2190
- });
2689
+ var import_zod24 = require("zod");
2690
+ var import_zod_openapi6 = require("zod-openapi");
2691
+ (0, import_zod_openapi6.extendZodWithOpenApi)(import_zod24.z);
2692
+ var EventDocument = import_zod24.z.object({
2693
+ id: import_zod24.z.string(),
2694
+ type: import_zod24.z.string(),
2695
+ dateOfEvent: import_zod24.z.object({ fieldId: import_zod24.z.string() }).optional(),
2696
+ createdAt: import_zod24.z.string().datetime(),
2697
+ updatedAt: import_zod24.z.string().datetime(),
2698
+ actions: import_zod24.z.array(Action),
2699
+ trackingId: import_zod24.z.string()
2700
+ }).openapi({ ref: "EventDocument" });
2191
2701
 
2192
- // ../commons/src/events/EventIndex.ts
2193
- var import_zod26 = require("zod");
2194
- var EventIndex = EventMetadata.extend({
2195
- declaration: import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any())
2196
- });
2197
- var EventSearchIndex = import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any()).and(
2198
- import_zod26.z.object({
2199
- type: import_zod26.z.string()
2200
- // Ensures "type" (event-id) exists and is a string
2201
- })
2202
- );
2702
+ // ../commons/src/events/state/utils.ts
2703
+ function getActionRequests(actionType, actions) {
2704
+ const filtered = actions.filter((action) => action.type === actionType);
2705
+ const accept = filtered.find(
2706
+ (action) => action.status === ActionStatus.Accepted
2707
+ );
2708
+ const request = filtered.find(
2709
+ (action) => action.status === ActionStatus.Requested
2710
+ );
2711
+ const reject = filtered.find(
2712
+ (action) => action.status === ActionStatus.Rejected
2713
+ );
2714
+ return {
2715
+ reject,
2716
+ accept,
2717
+ request
2718
+ };
2719
+ }
2720
+ function getDeclarationActionCreationMetadata(actionType, actions) {
2721
+ const { accept: acceptAction, request: requestAction } = getActionRequests(
2722
+ actionType,
2723
+ actions
2724
+ );
2725
+ if (!acceptAction) {
2726
+ return null;
2727
+ }
2728
+ const registrationNumber = acceptAction.type === ActionType.REGISTER ? acceptAction.registrationNumber : null;
2729
+ return {
2730
+ // When 3rd party API returns 200 OK, we assume that the request was accepted, and persist single 'accepted' action.
2731
+ createdAt: requestAction?.createdAt ?? acceptAction.createdAt,
2732
+ createdBy: requestAction?.createdBy ?? acceptAction.createdBy,
2733
+ createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
2734
+ acceptedAt: acceptAction.createdAt,
2735
+ createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
2736
+ registrationNumber
2737
+ };
2738
+ }
2739
+ function getDeclarationActionUpdateMetadata(actions) {
2740
+ const createAction = getOrThrow(
2741
+ actions.find((action) => action.type === ActionType.CREATE),
2742
+ `Event has no ${ActionType.CREATE} action`
2743
+ );
2744
+ return [ActionType.DECLARE, ActionType.VALIDATE, ActionType.REGISTER].reduce(
2745
+ (metadata, actionType) => {
2746
+ const { accept, request } = getActionRequests(actionType, actions);
2747
+ return {
2748
+ createdAt: request?.createdAt ?? accept?.createdAt ?? metadata.createdAt,
2749
+ createdBy: request?.createdBy ?? accept?.createdBy ?? metadata.createdBy,
2750
+ createdAtLocation: request?.createdAtLocation ?? accept?.createdAtLocation ?? metadata.createdAtLocation,
2751
+ createdByRole: request?.createdByRole ?? accept?.createdByRole ?? metadata.createdByRole
2752
+ };
2753
+ },
2754
+ {
2755
+ createdAt: createAction.createdAt,
2756
+ createdBy: createAction.createdBy,
2757
+ createdAtLocation: createAction.createdAtLocation,
2758
+ createdByRole: createAction.createdByRole
2759
+ }
2760
+ );
2761
+ }
2762
+ function getLegalStatuses(actions) {
2763
+ return {
2764
+ [EventStatus.DECLARED]: getDeclarationActionCreationMetadata(
2765
+ ActionType.DECLARE,
2766
+ actions
2767
+ ),
2768
+ [EventStatus.REGISTERED]: getDeclarationActionCreationMetadata(
2769
+ ActionType.REGISTER,
2770
+ actions
2771
+ )
2772
+ };
2773
+ }
2203
2774
 
2204
2775
  // ../commons/src/events/state/index.ts
2205
2776
  function getStatusFromActions(actions) {
@@ -2226,6 +2797,7 @@ function getStatusFromActions(actions) {
2226
2797
  case ActionType.NOTIFY:
2227
2798
  return EventStatus.NOTIFIED;
2228
2799
  case ActionType.PRINT_CERTIFICATE:
2800
+ return EventStatus.CERTIFIED;
2229
2801
  case ActionType.ASSIGN:
2230
2802
  case ActionType.UNASSIGN:
2231
2803
  case ActionType.REQUEST_CORRECTION:
@@ -2238,6 +2810,38 @@ function getStatusFromActions(actions) {
2238
2810
  }
2239
2811
  }, EventStatus.CREATED);
2240
2812
  }
2813
+ function getFlagsFromActions(actions) {
2814
+ const sortedactions = actions.sort(
2815
+ (a, b) => a.createdAt.localeCompare(b.createdAt)
2816
+ );
2817
+ const actionStatus = sortedactions.reduce(
2818
+ (actionStatuses, { type, status }) => ({
2819
+ ...actionStatuses,
2820
+ [type]: status
2821
+ }),
2822
+ {}
2823
+ );
2824
+ const flags = Object.entries(actionStatus).filter(([, status]) => status !== ActionStatus.Accepted).map(([type, status]) => {
2825
+ const flag = `${type.toLowerCase()}:${status.toLowerCase()}`;
2826
+ return flag;
2827
+ });
2828
+ const isCertificatePrinted = sortedactions.reduce(
2829
+ (prev, { type }) => {
2830
+ if (type === ActionType.PRINT_CERTIFICATE) {
2831
+ return true;
2832
+ }
2833
+ if (type === ActionType.APPROVE_CORRECTION) {
2834
+ return false;
2835
+ }
2836
+ return prev;
2837
+ },
2838
+ false
2839
+ );
2840
+ if (isCertificatePrinted) {
2841
+ flags.push(CustomFlags.CERTIFICATE_PRINTED);
2842
+ }
2843
+ return flags;
2844
+ }
2241
2845
  function getAssignedUserFromActions(actions) {
2242
2846
  return actions.reduce((user2, action) => {
2243
2847
  if (action.type === ActionType.ASSIGN) {
@@ -2292,6 +2896,7 @@ function getAcceptedActions(event2) {
2292
2896
  (a) => a.status === ActionStatus.Accepted
2293
2897
  );
2294
2898
  }
2899
+ var DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
2295
2900
  function getCurrentEventState(event2) {
2296
2901
  const creationAction = event2.actions.find(
2297
2902
  (action) => action.type === ActionType.CREATE
@@ -2299,26 +2904,32 @@ function getCurrentEventState(event2) {
2299
2904
  if (!creationAction) {
2300
2905
  throw new Error(`Event ${event2.id} has no creation action`);
2301
2906
  }
2302
- const activeActions = getAcceptedActions(event2);
2303
- const latestAction = activeActions[activeActions.length - 1];
2304
- const registrationAction = activeActions.find(
2305
- (a) => a.type === ActionType.REGISTER && a.status === ActionStatus.Accepted
2907
+ const acceptedActions = getAcceptedActions(event2);
2908
+ const declarationUpdateMetadata = getDeclarationActionUpdateMetadata(
2909
+ event2.actions
2306
2910
  );
2307
- const registrationNumber = registrationAction?.registrationNumber ?? null;
2911
+ const declaration = aggregateActionDeclarations(acceptedActions);
2912
+ const dateOfEvent = ZodDate.safeParse(
2913
+ event2.dateOfEvent?.fieldId ? declaration[event2.dateOfEvent.fieldId] : event2[DEFAULT_DATE_OF_EVENT_PROPERTY]
2914
+ ).data ?? null;
2308
2915
  return deepDropNulls({
2309
2916
  id: event2.id,
2310
2917
  type: event2.type,
2311
2918
  status: getStatusFromActions(event2.actions),
2312
- createdAt: event2.createdAt,
2919
+ legalStatuses: getLegalStatuses(event2.actions),
2920
+ createdAt: creationAction.createdAt,
2313
2921
  createdBy: creationAction.createdBy,
2314
2922
  createdAtLocation: creationAction.createdAtLocation,
2315
- modifiedAt: latestAction.createdAt,
2316
- assignedTo: getAssignedUserFromActions(activeActions),
2317
- updatedBy: latestAction.createdBy,
2318
- updatedAtLocation: event2.updatedAtLocation,
2319
- declaration: aggregateActionDeclarations(activeActions),
2923
+ updatedAt: declarationUpdateMetadata.createdAt,
2924
+ assignedTo: getAssignedUserFromActions(acceptedActions),
2925
+ updatedBy: declarationUpdateMetadata.createdBy,
2926
+ updatedAtLocation: declarationUpdateMetadata.createdAtLocation,
2927
+ declaration,
2320
2928
  trackingId: event2.trackingId,
2321
- registrationNumber
2929
+ // @TODO: unify this with rest of the code. It will trip us if updatedBy has different rules than updatedByUserRole
2930
+ updatedByUserRole: declarationUpdateMetadata.createdByRole,
2931
+ dateOfEvent,
2932
+ flags: getFlagsFromActions(event2.actions)
2322
2933
  });
2323
2934
  }
2324
2935
  function getCurrentEventStateWithDrafts(event2, drafts) {
@@ -2343,7 +2954,7 @@ function getCurrentEventStateWithDrafts(event2, drafts) {
2343
2954
  return getCurrentEventState(withDrafts);
2344
2955
  }
2345
2956
  function applyDraftsToEventIndex(eventIndex, drafts) {
2346
- const indexedAt = eventIndex.modifiedAt;
2957
+ const indexedAt = eventIndex.updatedAt;
2347
2958
  const activeDrafts = drafts.filter(({ createdAt }) => new Date(createdAt) > new Date(indexedAt)).map((draft) => draft.action).sort();
2348
2959
  if (activeDrafts.length === 0) {
2349
2960
  return eventIndex;
@@ -2366,7 +2977,7 @@ function getAnnotationFromDrafts(drafts) {
2366
2977
  function getActionAnnotation({
2367
2978
  event: event2,
2368
2979
  actionType,
2369
- drafts
2980
+ drafts = []
2370
2981
  }) {
2371
2982
  const activeActions = getAcceptedActions(event2);
2372
2983
  const action = activeActions.find(
@@ -2382,317 +2993,84 @@ function getActionAnnotation({
2382
2993
  }, {});
2383
2994
  return deepDropNulls(annotation);
2384
2995
  }
2385
-
2386
- // ../commons/src/events/defineConfig.ts
2387
- var defineConfig = (config) => {
2388
- validateWorkqueueConfig(config.workqueues);
2389
- const input = EventConfig.parse(config);
2390
- return input;
2391
- };
2392
-
2393
- // ../commons/src/events/transactions.ts
2394
- function generateTransactionId() {
2395
- return getUUID();
2396
- }
2397
-
2398
- // ../commons/src/events/test.utils.ts
2399
- var import_lodash2 = require("lodash");
2400
-
2401
- // ../commons/src/conditionals/conditionals.ts
2402
- function defineConditional(schema) {
2403
- return schema;
2404
- }
2405
- function defineFormConditional(schema) {
2406
- const schemaWithForm = {
2407
- type: "object",
2408
- properties: {
2409
- $form: schema
2410
- },
2411
- required: ["$form"]
2412
- };
2413
- return defineConditional(schemaWithForm);
2414
- }
2415
- function alwaysTrue() {
2416
- return {};
2417
- }
2418
- function and(...conditions) {
2419
- return defineConditional({
2420
- type: "object",
2421
- allOf: conditions,
2422
- required: []
2423
- });
2424
- }
2425
- function or(...conditions) {
2426
- return defineConditional({
2427
- type: "object",
2428
- anyOf: conditions,
2429
- required: []
2430
- });
2431
- }
2432
- function not(condition) {
2433
- return defineConditional({
2434
- type: "object",
2435
- not: condition,
2436
- required: []
2437
- });
2438
- }
2439
- function never() {
2440
- return not(alwaysTrue());
2441
- }
2442
- var user = {
2443
- hasScope: (scope) => defineConditional({
2444
- type: "object",
2445
- properties: {
2446
- $user: {
2447
- type: "object",
2448
- required: ["scope"],
2449
- properties: {
2450
- scope: {
2451
- type: "array",
2452
- contains: {
2453
- type: "string",
2454
- const: scope
2455
- }
2456
- }
2457
- }
2458
- }
2459
- },
2460
- required: ["$user"]
2461
- })
2462
- };
2463
- var event = {
2464
- hasAction: (action) => defineConditional({
2465
- type: "object",
2466
- properties: {
2467
- $event: {
2468
- type: "object",
2469
- properties: {
2470
- actions: {
2471
- type: "array",
2472
- contains: {
2473
- type: "object",
2474
- properties: {
2475
- type: {
2476
- const: action
2477
- }
2478
- },
2479
- required: ["type"]
2480
- }
2481
- }
2482
- },
2483
- required: ["actions"]
2484
- }
2485
- },
2486
- required: ["$event"]
2487
- })
2488
- };
2489
- function getDateFromNow(days) {
2490
- return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
2491
- }
2492
- function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
2493
- return {
2494
- type: "object",
2495
- properties: {
2496
- [fieldId]: {
2497
- type: "string",
2498
- format: "date",
2499
- [clause]: { $data: `1/${comparedFieldId}` }
2500
- },
2501
- [comparedFieldId]: { type: "string", format: "date" }
2502
- },
2503
- required: [fieldId]
2504
- };
2505
- }
2506
- function isFieldReference(value) {
2507
- return typeof value === "object" && value !== null && "_fieldId" in value;
2996
+
2997
+ // ../commons/src/events/defineConfig.ts
2998
+ var defineConfig = (config) => {
2999
+ const input = EventConfig.parse(config);
3000
+ return input;
3001
+ };
3002
+
3003
+ // ../commons/src/events/transactions.ts
3004
+ function generateTransactionId() {
3005
+ return getUUID();
2508
3006
  }
2509
- function field(fieldId) {
2510
- const getDateRange = (date, clause) => ({
2511
- type: "object",
2512
- properties: {
2513
- [fieldId]: {
2514
- type: "string",
2515
- format: "date",
2516
- [clause]: date
2517
- }
2518
- },
2519
- required: [fieldId]
2520
- });
3007
+
3008
+ // ../commons/src/events/test.utils.ts
3009
+ var import_lodash2 = require("lodash");
3010
+
3011
+ // ../commons/src/field-config/field-configuration.ts
3012
+ function createFieldConfigs(fieldId) {
3013
+ const baseField = {
3014
+ fieldId,
3015
+ fieldType: "field"
3016
+ };
2521
3017
  return {
2522
3018
  /**
2523
- * @private Internal property used for field reference tracking.
2524
- */
2525
- _fieldId: fieldId,
2526
- isAfter: () => ({
2527
- days: (days) => ({
2528
- inPast: () => defineFormConditional(
2529
- getDateRange(getDateFromNow(days), "formatMinimum")
2530
- ),
2531
- inFuture: () => defineFormConditional(
2532
- getDateRange(getDateFromNow(-days), "formatMinimum")
2533
- )
2534
- }),
2535
- date: (date) => {
2536
- if (isFieldReference(date)) {
2537
- const comparedFieldId = date._fieldId;
2538
- return defineFormConditional(
2539
- getDateRangeToFieldReference(
2540
- fieldId,
2541
- comparedFieldId,
2542
- "formatMinimum"
2543
- )
2544
- );
2545
- }
2546
- return defineFormConditional(getDateRange(date, "formatMinimum"));
2547
- },
2548
- now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
2549
- }),
2550
- isBefore: () => ({
2551
- days: (days) => ({
2552
- inPast: () => defineFormConditional(
2553
- getDateRange(getDateFromNow(days), "formatMaximum")
2554
- ),
2555
- inFuture: () => defineFormConditional(
2556
- getDateRange(getDateFromNow(-days), "formatMaximum")
2557
- )
2558
- }),
2559
- date: (date) => {
2560
- if (isFieldReference(date)) {
2561
- const comparedFieldId = date._fieldId;
2562
- return defineFormConditional(
2563
- getDateRangeToFieldReference(
2564
- fieldId,
2565
- comparedFieldId,
2566
- "formatMaximum"
2567
- )
2568
- );
2569
- }
2570
- return defineFormConditional(getDateRange(date, "formatMaximum"));
2571
- },
2572
- now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
2573
- }),
2574
- isEqualTo: (value) => {
2575
- if (isFieldReference(value)) {
2576
- const comparedFieldId = value._fieldId;
2577
- return defineFormConditional({
2578
- type: "object",
2579
- properties: {
2580
- [fieldId]: {
2581
- type: ["string", "boolean"],
2582
- const: { $data: `1/${comparedFieldId}` }
2583
- },
2584
- [comparedFieldId]: { type: ["string", "boolean"] }
2585
- },
2586
- required: [fieldId, comparedFieldId]
2587
- });
2588
- }
2589
- return defineFormConditional({
2590
- type: "object",
2591
- properties: {
2592
- [fieldId]: {
2593
- oneOf: [
2594
- { type: "string", const: value },
2595
- { type: "boolean", const: value }
2596
- ],
2597
- const: value
2598
- }
2599
- },
2600
- required: [fieldId]
2601
- });
2602
- },
2603
- /**
2604
- * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
2605
- * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
2606
- * @returns whether the field is falsy (undefined, false, null, empty string)
3019
+ * Creates a range configuration for the specified field.
2607
3020
  *
2608
- * NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
3021
+ * @returns An object containing the field ID and a configuration object with a type of 'range'.
2609
3022
  *
3023
+ * @example field('age').range()
3024
+ * // {
3025
+ * // fieldId: 'age',
3026
+ * // config: { type: 'range' }
3027
+ * // }
2610
3028
  */
2611
- isFalsy: () => defineFormConditional({
2612
- type: "object",
2613
- properties: {
2614
- [fieldId]: {
2615
- anyOf: [
2616
- { const: "undefined" },
2617
- { const: false },
2618
- { const: null },
2619
- { const: "" }
2620
- ]
2621
- }
2622
- },
2623
- anyOf: [
2624
- {
2625
- required: [fieldId]
2626
- },
2627
- {
2628
- not: {
2629
- required: [fieldId]
2630
- }
2631
- }
2632
- ]
2633
- }),
2634
- isUndefined: () => defineFormConditional({
2635
- type: "object",
2636
- properties: {
2637
- [fieldId]: {
2638
- type: "string",
2639
- enum: ["undefined"]
2640
- }
2641
- },
2642
- not: {
2643
- required: [fieldId]
2644
- }
2645
- }),
2646
- inArray: (values) => defineFormConditional({
2647
- type: "object",
2648
- properties: {
2649
- [fieldId]: {
2650
- type: "string",
2651
- enum: values
2652
- }
2653
- },
2654
- required: [fieldId]
2655
- }),
2656
- isValidEnglishName: () => defineFormConditional({
2657
- type: "object",
2658
- properties: {
2659
- [fieldId]: {
2660
- type: "string",
2661
- 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'._-]*)*$",
2662
- description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
2663
- }
2664
- },
2665
- required: [fieldId]
3029
+ range: () => ({
3030
+ ...baseField,
3031
+ config: { type: "range" }
2666
3032
  }),
2667
3033
  /**
2668
- * Checks if the field value matches a given regular expression pattern.
2669
- * @param pattern - The regular expression pattern to match the field value against.
2670
- * @returns A JSONSchema conditional that validates the field value against the pattern.
3034
+ * Creates a configuration for exact matching of the specified field.
3035
+ * @returns An object containing the field ID and a configuration object with a type of 'exact'.
3036
+ * @example field('dob').exact()
3037
+ * // {
3038
+ * // fieldId: 'dob',
3039
+ * // config: { type: 'exact' }
3040
+ * // }
2671
3041
  */
2672
- matches: (pattern) => defineFormConditional({
2673
- type: "object",
2674
- properties: {
2675
- [fieldId]: {
2676
- type: "string",
2677
- pattern
2678
- }
2679
- },
2680
- required: [fieldId]
3042
+ exact: () => ({
3043
+ ...baseField,
3044
+ config: { type: "exact" }
2681
3045
  }),
2682
- isBetween: (min, max) => defineFormConditional({
2683
- type: "object",
2684
- properties: {
2685
- [fieldId]: {
2686
- type: "number",
2687
- minimum: min,
2688
- maximum: max
2689
- }
2690
- },
2691
- required: [fieldId]
3046
+ /**
3047
+ * Creates a configuration for fuzzy matching of the specified field.
3048
+ * @returns An object containing the field ID and a configuration object with a type of 'exact'.
3049
+ * @example field('name').fuzzy()
3050
+ * // {
3051
+ * // fieldId: 'name',
3052
+ * // config: { type: 'fuzzy' }
3053
+ * // }
3054
+ */
3055
+ fuzzy: () => ({
3056
+ ...baseField,
3057
+ config: { type: "fuzzy" }
2692
3058
  })
2693
3059
  };
2694
3060
  }
2695
3061
 
3062
+ // ../commons/src/events/field.ts
3063
+ function field(fieldId) {
3064
+ return {
3065
+ /**
3066
+ * @private Internal property used for field reference tracking.
3067
+ */
3068
+ _fieldId: fieldId,
3069
+ ...createFieldConditionals(fieldId),
3070
+ ...createFieldConfigs(fieldId)
3071
+ };
3072
+ }
3073
+
2696
3074
  // ../commons/src/fixtures/tennis-club-membership-event.ts
2697
3075
  var PRINT_CERTIFICATE_FORM = defineActionForm({
2698
3076
  label: {
@@ -3609,20 +3987,12 @@ var tennisClubMembershipEvent = defineConfig({
3609
3987
  description: "This is what this event is referred as in the system",
3610
3988
  id: "event.tennis-club-membership.label"
3611
3989
  },
3990
+ title: {
3991
+ defaultMessage: "{applicant.firstname} {applicant.surname}",
3992
+ description: "This is the title of the summary",
3993
+ id: "v2.event.tennis-club-membership.title"
3994
+ },
3612
3995
  summary: {
3613
- title: {
3614
- id: "event.tennis-club-membership.summary.title",
3615
- label: {
3616
- defaultMessage: "{applicant.firstname} {applicant.surname}",
3617
- description: "This is the title of the summary",
3618
- id: "v2.event.tennis-club-membership.summary.title"
3619
- },
3620
- emptyValueMessage: {
3621
- defaultMessage: "Membership application",
3622
- description: "This is the message shown when the applicant name is missing",
3623
- id: "event.tennis-club-membership.summary.title.empty"
3624
- }
3625
- },
3626
3996
  fields: [
3627
3997
  {
3628
3998
  id: "applicant.firstname",
@@ -3643,47 +4013,18 @@ var tennisClubMembershipEvent = defineConfig({
3643
4013
  }
3644
4014
  },
3645
4015
  {
3646
- id: "applicant.surname",
4016
+ fieldId: "applicant.surname",
3647
4017
  label: {
3648
4018
  defaultMessage: "Applicant's last name",
3649
- description: "This is the label for the field",
3650
- id: "event.tennis-club-membership.summary.field.surname.label"
3651
- },
3652
- value: {
3653
- defaultMessage: "{applicant.surname}",
3654
- description: "This is the value to show in the summary",
3655
- id: "event.tennis-club-membership.summary.field.surname"
3656
- },
3657
- emptyValueMessage: {
3658
- defaultMessage: "Last name is not provided",
3659
- description: "This is the message to show when the field is empty",
3660
- id: "event.tennis-club-membership.summary.field.surname.empty"
4019
+ description: "Label for surname",
4020
+ id: "v2.event.tennis-club-membership.summary.field.surname.label"
3661
4021
  }
4022
+ },
4023
+ {
4024
+ fieldId: "applicant.email"
3662
4025
  }
3663
4026
  ]
3664
4027
  },
3665
- workqueues: [
3666
- {
3667
- id: "all",
3668
- filters: []
3669
- },
3670
- {
3671
- id: "ready-for-review",
3672
- filters: [
3673
- {
3674
- status: ["DECLARED"]
3675
- }
3676
- ]
3677
- },
3678
- {
3679
- id: "registered",
3680
- filters: [
3681
- {
3682
- status: ["REGISTERED"]
3683
- }
3684
- ]
3685
- }
3686
- ],
3687
4028
  actions: [
3688
4029
  {
3689
4030
  type: ActionType.DECLARE,
@@ -3991,11 +4332,7 @@ var tennisClubMembershipEvent = defineConfig({
3991
4332
  description: "This is what this event is referred as in the system",
3992
4333
  id: "v2.event.tennis-club-membership.search"
3993
4334
  },
3994
- fields: [
3995
- {
3996
- fieldId: "applicant.dob"
3997
- }
3998
- ]
4335
+ fields: [field("applicant.dob").exact()]
3999
4336
  }
4000
4337
  ],
4001
4338
  declaration: TENNIS_CLUB_DECLARATION_FORM
@@ -4028,10 +4365,10 @@ function generateActionAnnotationInput(configuration, action) {
4028
4365
  );
4029
4366
  const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
4030
4367
  const annotation = fieldConfigsToActionPayload(annotationFields);
4031
- const visibleVerificationPageIds = findRecordActionPages(
4032
- configuration,
4033
- action
4034
- ).filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page, annotation)).map((page) => page.id);
4368
+ const visibleVerificationPageIds = getVisibleVerificationPageIds(
4369
+ findRecordActionPages(configuration, action),
4370
+ annotation
4371
+ );
4035
4372
  const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
4036
4373
  (acc, pageId) => ({
4037
4374
  ...acc,
@@ -4062,6 +4399,7 @@ var eventPayloadGenerator = {
4062
4399
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4063
4400
  transactionId: getUUID(),
4064
4401
  action: {
4402
+ transactionId: getUUID(),
4065
4403
  type: actionType,
4066
4404
  status: ActionStatus.Accepted,
4067
4405
  declaration: {
@@ -4076,6 +4414,7 @@ var eventPayloadGenerator = {
4076
4414
  },
4077
4415
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4078
4416
  createdBy: "@todo",
4417
+ createdByRole: "@todo",
4079
4418
  createdAtLocation: "@todo"
4080
4419
  }
4081
4420
  },
@@ -4237,12 +4576,14 @@ function generateActionDocument({
4237
4576
  // @TODO: This should be fixed in the future.
4238
4577
  createdAt: new Date(Date.now() - 500).toISOString(),
4239
4578
  createdBy: getUUID(),
4579
+ createdByRole: "FIELD_AGENT",
4240
4580
  id: getUUID(),
4241
- createdAtLocation: "TODO",
4581
+ createdAtLocation: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
4242
4582
  declaration: generateActionDeclarationInput(configuration, action),
4243
4583
  annotation: {},
4244
- ...defaults,
4245
- status: ActionStatus.Accepted
4584
+ status: ActionStatus.Accepted,
4585
+ transactionId: getUUID(),
4586
+ ...defaults
4246
4587
  };
4247
4588
  switch (action) {
4248
4589
  case ActionType.READ:
@@ -4301,7 +4642,7 @@ function generateEventDocument({
4301
4642
  // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
4302
4643
  // @TODO: This should be fixed in the future.
4303
4644
  updatedAt: new Date(Date.now() - 1e3).toISOString(),
4304
- updatedAtLocation: "TODO"
4645
+ dateOfEvent: configuration.dateOfEvent
4305
4646
  };
4306
4647
  }
4307
4648
  function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
@@ -4323,24 +4664,76 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, de
4323
4664
  eventId
4324
4665
  };
4325
4666
  }
4667
+ function getEventStatus() {
4668
+ const statuses = [
4669
+ EventStatus.CREATED,
4670
+ EventStatus.REGISTERED,
4671
+ EventStatus.DECLARED
4672
+ ];
4673
+ const randomIndex = Math.floor(Math.random() * 3);
4674
+ return statuses[randomIndex];
4675
+ }
4676
+ function getTrackingId() {
4677
+ const uuid = getUUID().replace(/-/g, "");
4678
+ const trackingId = uuid.slice(0, 6).toUpperCase();
4679
+ return trackingId;
4680
+ }
4681
+ function getRandomApplicant() {
4682
+ const firstNames = [
4683
+ "Danny",
4684
+ "John",
4685
+ "Jane",
4686
+ "Emily",
4687
+ "Michael",
4688
+ "Sarah",
4689
+ "Chris",
4690
+ "Jessica"
4691
+ ];
4692
+ const surnames = [
4693
+ "Doe",
4694
+ "Smith",
4695
+ "Johnson",
4696
+ "Brown",
4697
+ "Williams",
4698
+ "Jones",
4699
+ "Garcia",
4700
+ "Miller"
4701
+ ];
4702
+ function getRandomDate(start, end) {
4703
+ const randomDate = new Date(
4704
+ start.getTime() + Math.random() * (end.getTime() - start.getTime())
4705
+ );
4706
+ return randomDate.toISOString().split("T")[0];
4707
+ }
4708
+ const randomFirstName = firstNames[Math.floor(Math.random() * firstNames.length)];
4709
+ const randomSurname = surnames[Math.floor(Math.random() * surnames.length)];
4710
+ const randomDob = getRandomDate(
4711
+ /* @__PURE__ */ new Date("1990-01-01"),
4712
+ /* @__PURE__ */ new Date("2010-12-31")
4713
+ );
4714
+ return {
4715
+ "recommender.none": true,
4716
+ "applicant.firstname": randomFirstName,
4717
+ "applicant.surname": randomSurname,
4718
+ "applicant.dob": randomDob
4719
+ };
4720
+ }
4326
4721
  var eventQueryDataGenerator = (overrides = {}) => ({
4327
4722
  id: overrides.id ?? getUUID(),
4328
- type: overrides.type ?? "tennis-club-membership",
4329
- status: overrides.status ?? "REGISTERED",
4723
+ type: overrides.type ?? "TENNIS_CLUB_MEMBERSHIP",
4724
+ status: overrides.status ?? getEventStatus(),
4330
4725
  createdAt: overrides.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
4331
4726
  createdBy: overrides.createdBy ?? getUUID(),
4332
4727
  createdAtLocation: overrides.createdAtLocation ?? getUUID(),
4333
4728
  updatedAtLocation: overrides.updatedAtLocation ?? getUUID(),
4334
- modifiedAt: overrides.modifiedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
4729
+ updatedAt: overrides.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
4335
4730
  assignedTo: overrides.assignedTo ?? null,
4336
4731
  updatedBy: overrides.updatedBy ?? getUUID(),
4337
- declaration: overrides.declaration ?? {
4338
- "recommender.none": true,
4339
- "applicant.firstname": "Danny",
4340
- "applicant.surname": "Doe",
4341
- "applicant.dob": "1999-11-11"
4342
- },
4343
- trackingId: overrides.trackingId ?? "M3F8YQ"
4732
+ updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
4733
+ flags: [],
4734
+ legalStatuses: overrides.legalStatuses ?? {},
4735
+ declaration: overrides.declaration ?? getRandomApplicant(),
4736
+ trackingId: overrides.trackingId ?? getTrackingId()
4344
4737
  });
4345
4738
  var generateTranslationConfig = (message) => ({
4346
4739
  defaultMessage: message,
@@ -4384,6 +4777,7 @@ function isFieldConfigDefaultValue(value) {
4384
4777
  var import_lodash3 = require("lodash");
4385
4778
 
4386
4779
  // ../commons/src/scopes.ts
4780
+ var import_zod25 = require("zod");
4387
4781
  var SCOPES = {
4388
4782
  // TODO v1.8 legacy scopes
4389
4783
  NATLSYSADMIN: "natlsysadmin",
@@ -4494,6 +4888,101 @@ var SCOPES = {
4494
4888
  // data seeding
4495
4889
  USER_DATA_SEEDING: "user.data-seeding"
4496
4890
  };
4891
+ var LiteralScopes = import_zod25.z.union([
4892
+ import_zod25.z.literal(SCOPES.NATLSYSADMIN),
4893
+ import_zod25.z.literal(SCOPES.BYPASSRATELIMIT),
4894
+ import_zod25.z.literal(SCOPES.DECLARE),
4895
+ import_zod25.z.literal(SCOPES.REGISTER),
4896
+ import_zod25.z.literal(SCOPES.VALIDATE),
4897
+ import_zod25.z.literal(SCOPES.DEMO),
4898
+ import_zod25.z.literal(SCOPES.CERTIFY),
4899
+ import_zod25.z.literal(SCOPES.PERFORMANCE),
4900
+ import_zod25.z.literal(SCOPES.SYSADMIN),
4901
+ import_zod25.z.literal(SCOPES.TEAMS),
4902
+ import_zod25.z.literal(SCOPES.CONFIG),
4903
+ import_zod25.z.literal(SCOPES.WEBHOOK),
4904
+ import_zod25.z.literal(SCOPES.NATIONALID),
4905
+ import_zod25.z.literal(SCOPES.NOTIFICATION_API),
4906
+ import_zod25.z.literal(SCOPES.RECORDSEARCH),
4907
+ import_zod25.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
4908
+ import_zod25.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
4909
+ import_zod25.z.literal(SCOPES.RECORD_DECLARE_DEATH),
4910
+ import_zod25.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
4911
+ import_zod25.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
4912
+ import_zod25.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
4913
+ import_zod25.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
4914
+ import_zod25.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW),
4915
+ import_zod25.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS),
4916
+ import_zod25.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
4917
+ import_zod25.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
4918
+ import_zod25.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
4919
+ import_zod25.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
4920
+ import_zod25.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
4921
+ import_zod25.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE),
4922
+ import_zod25.z.literal(SCOPES.RECORD_REGISTER),
4923
+ import_zod25.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
4924
+ import_zod25.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
4925
+ import_zod25.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
4926
+ import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
4927
+ import_zod25.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
4928
+ import_zod25.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
4929
+ import_zod25.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
4930
+ import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES),
4931
+ import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
4932
+ import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
4933
+ import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
4934
+ import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
4935
+ import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
4936
+ import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
4937
+ import_zod25.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
4938
+ import_zod25.z.literal(SCOPES.RECORD_REJECT_REGISTRATION),
4939
+ import_zod25.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
4940
+ import_zod25.z.literal(SCOPES.SEARCH_BIRTH),
4941
+ import_zod25.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
4942
+ import_zod25.z.literal(SCOPES.SEARCH_DEATH),
4943
+ import_zod25.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
4944
+ import_zod25.z.literal(SCOPES.SEARCH_MARRIAGE),
4945
+ import_zod25.z.literal(SCOPES.RECORD_READ),
4946
+ import_zod25.z.literal(SCOPES.RECORD_READ_AUDIT),
4947
+ import_zod25.z.literal(SCOPES.RECORD_READ_COMMENTS),
4948
+ import_zod25.z.literal(SCOPES.RECORD_CREATE_COMMENTS),
4949
+ import_zod25.z.literal(SCOPES.PROFILE_UPDATE),
4950
+ import_zod25.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE),
4951
+ import_zod25.z.literal(SCOPES.PERFORMANCE_READ),
4952
+ import_zod25.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
4953
+ import_zod25.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS),
4954
+ import_zod25.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
4955
+ import_zod25.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
4956
+ import_zod25.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION),
4957
+ import_zod25.z.literal(SCOPES.USER_READ),
4958
+ import_zod25.z.literal(SCOPES.USER_READ_MY_OFFICE),
4959
+ import_zod25.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
4960
+ import_zod25.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
4961
+ import_zod25.z.literal(SCOPES.USER_CREATE),
4962
+ import_zod25.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
4963
+ import_zod25.z.literal(SCOPES.USER_UPDATE),
4964
+ import_zod25.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION),
4965
+ import_zod25.z.literal(SCOPES.CONFIG_UPDATE_ALL),
4966
+ import_zod25.z.literal(SCOPES.USER_DATA_SEEDING)
4967
+ ]);
4968
+ var rawConfigurableScopeRegex = /^([a-zA-Z]+\.[a-zA-Z]+)\[((?:\w+=\w+(?:\|\w+)*)(:?,\w+=\w+(?:\|\w+)*)*)\]$/;
4969
+ var rawConfigurableScope = import_zod25.z.string().regex(rawConfigurableScopeRegex);
4970
+ var CreateUserScope = import_zod25.z.object({
4971
+ type: import_zod25.z.literal("user.create"),
4972
+ options: import_zod25.z.object({
4973
+ role: import_zod25.z.array(import_zod25.z.string())
4974
+ })
4975
+ });
4976
+ var EditUserScope = import_zod25.z.object({
4977
+ type: import_zod25.z.literal("user.edit"),
4978
+ options: import_zod25.z.object({
4979
+ role: import_zod25.z.array(import_zod25.z.string())
4980
+ })
4981
+ });
4982
+ var ConfigurableScopes = import_zod25.z.discriminatedUnion("type", [
4983
+ CreateUserScope,
4984
+ EditUserScope
4985
+ ]);
4497
4986
  var scopes = Object.values(SCOPES);
4498
4987
 
4499
4988
  // ../commons/src/events/scopes.ts
@@ -4510,6 +4999,14 @@ var CONFIG_GET_ALLOWED_SCOPES = [
4510
4999
  SCOPES.CONFIG,
4511
5000
  SCOPES.CONFIG_UPDATE_ALL
4512
5001
  ];
5002
+ var CONFIG_SEARCH_ALLOWED_SCOPES = [
5003
+ SCOPES.SEARCH_BIRTH,
5004
+ SCOPES.SEARCH_DEATH,
5005
+ SCOPES.SEARCH_MARRIAGE,
5006
+ SCOPES.SEARCH_BIRTH_MY_JURISDICTION,
5007
+ SCOPES.SEARCH_DEATH_MY_JURISDICTION,
5008
+ SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION
5009
+ ];
4513
5010
  var ACTION_ALLOWED_SCOPES = {
4514
5011
  [ActionType.READ]: [
4515
5012
  SCOPES.RECORD_DECLARE,