@opencrvs/toolkit 1.8.0-rc.fd754eb → 1.8.0-rc.fd936ab

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/commons/api/router.d.ts +4205 -7695
  2. package/dist/commons/conditionals/conditionals.d.ts +6 -9
  3. package/dist/commons/conditionals/validate.d.ts +6 -4
  4. package/dist/commons/events/ActionConfig.d.ts +1680 -90025
  5. package/dist/commons/events/ActionDocument.d.ts +211 -542
  6. package/dist/commons/events/ActionInput.d.ts +240 -248
  7. package/dist/commons/events/AdvancedSearchConfig.d.ts +25 -369
  8. package/dist/commons/events/CompositeFieldValue.d.ts +0 -3
  9. package/dist/commons/events/Draft.d.ts +20 -33
  10. package/dist/commons/events/EventConfig.d.ts +1344 -42812
  11. package/dist/commons/events/EventDocument.d.ts +156 -337
  12. package/dist/commons/events/EventIndex.d.ts +13 -1346
  13. package/dist/commons/events/EventInput.d.ts +0 -13
  14. package/dist/commons/events/EventMetadata.d.ts +11 -273
  15. package/dist/commons/events/FieldConfig.d.ts +724 -3733
  16. package/dist/commons/events/FieldType.d.ts +3 -3
  17. package/dist/commons/events/FieldTypeMapping.d.ts +4 -11
  18. package/dist/commons/events/FieldValue.d.ts +4 -7
  19. package/dist/commons/events/FormConfig.d.ts +441 -40419
  20. package/dist/commons/events/PageConfig.d.ts +194 -10068
  21. package/dist/commons/events/SummaryConfig.d.ts +39 -95
  22. package/dist/commons/events/User.d.ts +0 -5
  23. package/dist/commons/events/WorkqueueConfig.d.ts +19 -1135
  24. package/dist/commons/events/defineConfig.d.ts +35 -6966
  25. package/dist/commons/events/index.d.ts +0 -3
  26. package/dist/commons/events/test.utils.d.ts +44 -7
  27. package/dist/commons/events/utils.d.ts +67 -3550
  28. package/dist/conditionals/index.js +33 -36
  29. package/dist/events/index.js +977 -1672
  30. package/package.json +2 -3
  31. package/dist/commons/events/event.d.ts +0 -27
  32. package/dist/commons/events/field.d.ts +0 -68
  33. package/dist/commons/events/scopes.d.ts +0 -26
@@ -30,13 +30,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/events/index.ts
31
31
  var events_exports = {};
32
32
  __export(events_exports, {
33
- ACTION_ALLOWED_SCOPES: () => ACTION_ALLOWED_SCOPES,
34
33
  Action: () => Action,
35
34
  ActionBase: () => ActionBase,
36
35
  ActionConditional: () => ActionConditional,
37
36
  ActionConfig: () => ActionConfig,
38
37
  ActionConfigBase: () => ActionConfigBase,
39
- ActionCreationMetadata: () => ActionCreationMetadata,
40
38
  ActionDocument: () => ActionDocument,
41
39
  ActionFormConfig: () => ActionFormConfig,
42
40
  ActionInput: () => ActionInput,
@@ -54,8 +52,6 @@ __export(events_exports, {
54
52
  AssignActionInput: () => AssignActionInput,
55
53
  AsyncRejectActionDocument: () => AsyncRejectActionDocument,
56
54
  BaseActionInput: () => BaseActionInput,
57
- CONFIG_GET_ALLOWED_SCOPES: () => CONFIG_GET_ALLOWED_SCOPES,
58
- CONFIG_SEARCH_ALLOWED_SCOPES: () => CONFIG_SEARCH_ALLOWED_SCOPES,
59
55
  CertificateConfig: () => CertificateConfig,
60
56
  CertificateTemplateConfig: () => CertificateTemplateConfig,
61
57
  CheckboxFieldValue: () => CheckboxFieldValue,
@@ -63,13 +59,9 @@ __export(events_exports, {
63
59
  Conditional: () => Conditional,
64
60
  ConditionalType: () => ConditionalType,
65
61
  ConfirmableActions: () => ConfirmableActions,
66
- CustomFlags: () => CustomFlags,
67
- DEFAULT_DATE_OF_EVENT_PROPERTY: () => DEFAULT_DATE_OF_EVENT_PROPERTY,
68
62
  DataEntry: () => DataEntry,
69
63
  DataFieldValue: () => DataFieldValue,
70
- DateRangeFieldValue: () => DateRangeFieldValue,
71
64
  DateValue: () => DateValue,
72
- DatetimeValue: () => DatetimeValue,
73
65
  DeclarationActionConfig: () => DeclarationActionConfig,
74
66
  DeclarationActions: () => DeclarationActions,
75
67
  DeclarationFormConfig: () => DeclarationFormConfig,
@@ -77,7 +69,6 @@ __export(events_exports, {
77
69
  DeclarationUpdateActions: () => DeclarationUpdateActions,
78
70
  DeclareActionInput: () => DeclareActionInput,
79
71
  DeduplicationConfig: () => DeduplicationConfig,
80
- DeleteActionInput: () => DeleteActionInput,
81
72
  DisplayOnReviewConditional: () => DisplayOnReviewConditional,
82
73
  Draft: () => Draft,
83
74
  DraftInput: () => DraftInput,
@@ -86,27 +77,20 @@ __export(events_exports, {
86
77
  EnableConditional: () => EnableConditional,
87
78
  EventConfig: () => EventConfig,
88
79
  EventDocument: () => EventDocument,
89
- EventFieldConfigSchema: () => EventFieldConfigSchema,
90
- EventFieldId: () => EventFieldId,
91
80
  EventIndex: () => EventIndex,
92
81
  EventInput: () => EventInput,
93
82
  EventMetadata: () => EventMetadata,
94
- EventMetadataKeys: () => EventMetadataKeys,
95
- EventMetadataParameter: () => EventMetadataParameter,
96
83
  EventSearchIndex: () => EventSearchIndex,
97
- EventState: () => EventState,
98
84
  EventStatus: () => EventStatus,
99
85
  EventStatuses: () => EventStatuses,
100
86
  FieldConditional: () => FieldConditional,
101
87
  FieldConfig: () => FieldConfig,
102
- FieldConfigSchema: () => FieldConfigSchema,
103
88
  FieldType: () => FieldType,
104
89
  FieldUpdateValue: () => FieldUpdateValue,
105
90
  FieldValue: () => FieldValue,
106
91
  FileFieldValue: () => FileFieldValue,
107
92
  FileFieldValueWithOption: () => FileFieldValueWithOption,
108
93
  FileFieldWithOptionValue: () => FileFieldWithOptionValue,
109
- Flag: () => Flag,
110
94
  FormConfig: () => FormConfig,
111
95
  FormPageConfig: () => FormPageConfig,
112
96
  GenericAddressUpdateValue: () => GenericAddressUpdateValue,
@@ -114,29 +98,23 @@ __export(events_exports, {
114
98
  GeographicalArea: () => GeographicalArea,
115
99
  ImageMimeType: () => ImageMimeType,
116
100
  LanguageConfig: () => LanguageConfig,
117
- LegalStatuses: () => LegalStatuses,
118
101
  MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
119
102
  MimeType: () => MimeType,
120
- NonEmptyTextValue: () => NonEmptyTextValue,
121
103
  NotifyActionInput: () => NotifyActionInput,
122
104
  NumberFieldValue: () => NumberFieldValue,
123
105
  PageConfig: () => PageConfig,
124
106
  PageTypes: () => PageTypes,
125
107
  PrintCertificateActionInput: () => PrintCertificateActionInput,
126
- QueryInput: () => QueryInput,
127
- QueryType: () => QueryType,
128
108
  ReadActionInput: () => ReadActionInput,
129
109
  RegisterAction: () => RegisterAction,
130
110
  RegisterActionInput: () => RegisterActionInput,
131
- RegistrationCreationMetadata: () => RegistrationCreationMetadata,
132
111
  RejectCorrectionActionInput: () => RejectCorrectionActionInput,
133
112
  RejectDeclarationActionInput: () => RejectDeclarationActionInput,
134
113
  RequestCorrectionActionInput: () => RequestCorrectionActionInput,
114
+ RequiredTextValue: () => RequiredTextValue,
135
115
  ResolvedUser: () => ResolvedUser,
136
116
  RuralAddressUpdateValue: () => RuralAddressUpdateValue,
137
117
  RuralAddressValue: () => RuralAddressValue,
138
- SearchField: () => SearchField,
139
- SelectOption: () => SelectOption,
140
118
  ShowConditional: () => ShowConditional,
141
119
  SummaryConfig: () => SummaryConfig,
142
120
  TextValue: () => TextValue,
@@ -148,16 +126,12 @@ __export(events_exports, {
148
126
  VerificationActionConfig: () => VerificationActionConfig,
149
127
  VerificationPageConfig: () => VerificationPageConfig,
150
128
  WorkqueueConfig: () => WorkqueueConfig,
151
- ZodDate: () => ZodDate,
152
129
  alwaysTrue: () => alwaysTrue,
153
130
  and: () => and,
154
131
  annotationActions: () => annotationActions,
155
132
  applyDraftsToEventIndex: () => applyDraftsToEventIndex,
156
- areConditionsMet: () => areConditionsMet,
157
133
  compositeFieldTypes: () => compositeFieldTypes,
158
134
  createEmptyDraft: () => createEmptyDraft,
159
- createEventConditionals: () => createEventConditionals,
160
- createFieldConditionals: () => createFieldConditionals,
161
135
  createValidationSchema: () => createValidationSchema,
162
136
  deepDropNulls: () => deepDropNulls,
163
137
  deepMerge: () => deepMerge,
@@ -168,7 +142,6 @@ __export(events_exports, {
168
142
  defineFormConditional: () => defineFormConditional,
169
143
  defineFormPage: () => defineFormPage,
170
144
  definePage: () => definePage,
171
- defineWorkqueue: () => defineWorkqueue,
172
145
  errorMessages: () => errorMessages,
173
146
  event: () => event,
174
147
  eventMetadataLabelMap: () => eventMetadataLabelMap,
@@ -177,7 +150,6 @@ __export(events_exports, {
177
150
  eventStatuses: () => eventStatuses,
178
151
  field: () => field,
179
152
  fieldTypes: () => fieldTypes,
180
- filterUnallowedActions: () => filterUnallowedActions,
181
153
  findActiveDrafts: () => findActiveDrafts,
182
154
  findAllFields: () => findAllFields,
183
155
  findLastAssignmentAction: () => findLastAssignmentAction,
@@ -194,26 +166,21 @@ __export(events_exports, {
194
166
  getActionAnnotationFields: () => getActionAnnotationFields,
195
167
  getActionReview: () => getActionReview,
196
168
  getActionReviewFields: () => getActionReviewFields,
197
- getActionVerificationPageIds: () => getActionVerificationPageIds,
169
+ getAllAnnotationFields: () => getAllAnnotationFields,
198
170
  getAnnotationFromDrafts: () => getAnnotationFromDrafts,
199
- getAssignedUserFromActions: () => getAssignedUserFromActions,
200
171
  getCurrentEventState: () => getCurrentEventState,
201
172
  getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
202
173
  getDeclaration: () => getDeclaration,
203
174
  getDeclarationFields: () => getDeclarationFields,
204
175
  getDeclarationPages: () => getDeclarationPages,
205
- getMixedPath: () => getMixedPath,
206
- getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
207
- hasAnyOfScopes: () => hasAnyOfScopes,
176
+ getFieldValidationErrors: () => getFieldValidationErrors,
208
177
  isAddressFieldType: () => isAddressFieldType,
209
178
  isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
210
179
  isBulletListFieldType: () => isBulletListFieldType,
211
180
  isCheckboxFieldType: () => isCheckboxFieldType,
212
- isConditionMet: () => isConditionMet,
213
181
  isCountryFieldType: () => isCountryFieldType,
214
182
  isDataFieldType: () => isDataFieldType,
215
183
  isDateFieldType: () => isDateFieldType,
216
- isDateRangeFieldType: () => isDateRangeFieldType,
217
184
  isDividerFieldType: () => isDividerFieldType,
218
185
  isEmailFieldType: () => isEmailFieldType,
219
186
  isFacilityFieldType: () => isFacilityFieldType,
@@ -245,14 +212,13 @@ __export(events_exports, {
245
212
  mapFieldTypeToZod: () => mapFieldTypeToZod,
246
213
  never: () => never,
247
214
  not: () => not,
248
- omitHiddenAnnotationFields: () => omitHiddenAnnotationFields,
249
215
  omitHiddenFields: () => omitHiddenFields,
250
216
  omitHiddenPaginatedFields: () => omitHiddenPaginatedFields,
251
217
  or: () => or,
252
- runFieldValidations: () => runFieldValidations,
253
218
  user: () => user,
254
219
  validate: () => validate,
255
220
  validateFieldInput: () => validateFieldInput,
221
+ validateWorkqueueConfig: () => validateWorkqueueConfig,
256
222
  writeActions: () => writeActions
257
223
  });
258
224
  module.exports = __toCommonJS(events_exports);
@@ -329,12 +295,12 @@ var FieldType = {
329
295
  TEXTAREA: "TEXTAREA",
330
296
  EMAIL: "EMAIL",
331
297
  DATE: "DATE",
332
- DATE_RANGE: "DATE_RANGE",
333
298
  PARAGRAPH: "PARAGRAPH",
334
299
  PAGE_HEADER: "PAGE_HEADER",
335
300
  RADIO_GROUP: "RADIO_GROUP",
336
301
  FILE: "FILE",
337
302
  FILE_WITH_OPTIONS: "FILE_WITH_OPTIONS",
303
+ HIDDEN: "HIDDEN",
338
304
  BULLET_LIST: "BULLET_LIST",
339
305
  CHECKBOX: "CHECKBOX",
340
306
  SELECT: "SELECT",
@@ -349,7 +315,6 @@ var FieldType = {
349
315
  };
350
316
  var fieldTypes = Object.values(FieldType);
351
317
  var compositeFieldTypes = [
352
- FieldType.DATE_RANGE,
353
318
  FieldType.ADDRESS,
354
319
  FieldType.FILE_WITH_OPTIONS,
355
320
  FieldType.FILE
@@ -440,10 +405,8 @@ var FileFieldWithOptionValue = import_zod3.z.array(FileFieldValueWithOption);
440
405
 
441
406
  // ../commons/src/events/FieldValue.ts
442
407
  var TextValue = import_zod4.z.string();
443
- var NonEmptyTextValue = TextValue.min(1);
408
+ var RequiredTextValue = TextValue.min(1);
444
409
  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]));
447
410
  var EmailValue = import_zod4.z.string().email();
448
411
  var CheckboxFieldValue = import_zod4.z.boolean();
449
412
  var NumberFieldValue = import_zod4.z.number();
@@ -451,7 +414,6 @@ var DataFieldValue = import_zod4.z.undefined();
451
414
  var FieldValue = import_zod4.z.union([
452
415
  TextValue,
453
416
  DateValue,
454
- DateRangeFieldValue,
455
417
  CheckboxFieldValue,
456
418
  NumberFieldValue,
457
419
  FileFieldValue,
@@ -464,7 +426,6 @@ var FieldValue = import_zod4.z.union([
464
426
  var FieldUpdateValue = import_zod4.z.union([
465
427
  TextValue,
466
428
  DateValue,
467
- DateRangeFieldValue,
468
429
  CheckboxFieldValue,
469
430
  NumberFieldValue,
470
431
  FileFieldValue,
@@ -477,21 +438,27 @@ var FieldUpdateValue = import_zod4.z.union([
477
438
 
478
439
  // ../commons/src/events/FieldConfig.ts
479
440
  var FieldId = import_zod5.z.string();
480
- var ParentReference = import_zod5.z.object({
481
- _fieldId: FieldId.optional()
482
- }).optional();
441
+ var DependencyExpression = import_zod5.z.object({
442
+ dependsOn: import_zod5.z.array(FieldId).default([]),
443
+ expression: import_zod5.z.string()
444
+ });
483
445
  var BaseField = import_zod5.z.object({
484
446
  id: FieldId,
485
447
  defaultValue: import_zod5.z.union([
486
- TextValue,
487
- NonEmptyTextValue,
488
- DateValue,
489
- NumberFieldValue,
490
- CheckboxFieldValue
448
+ // These are the currently supported default values types
449
+ import_zod5.z.union([
450
+ TextValue,
451
+ RequiredTextValue,
452
+ DateValue,
453
+ NumberFieldValue,
454
+ CheckboxFieldValue
455
+ ]),
456
+ DependencyExpression
491
457
  ]).optional(),
492
- parent: ParentReference,
493
458
  conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
494
459
  required: import_zod5.z.boolean().default(false).optional(),
460
+ disabled: import_zod5.z.boolean().default(false).optional(),
461
+ hidden: import_zod5.z.boolean().default(false).optional(),
495
462
  placeholder: TranslationConfig.optional(),
496
463
  validation: import_zod5.z.array(
497
464
  import_zod5.z.object({
@@ -499,6 +466,7 @@ var BaseField = import_zod5.z.object({
499
466
  message: TranslationConfig
500
467
  })
501
468
  ).default([]).optional(),
469
+ dependsOn: import_zod5.z.array(FieldId).default([]).optional(),
502
470
  label: TranslationConfig,
503
471
  hideLabel: import_zod5.z.boolean().default(false).optional()
504
472
  });
@@ -507,7 +475,7 @@ var Divider = BaseField.extend({
507
475
  });
508
476
  var TextField = BaseField.extend({
509
477
  type: import_zod5.z.literal(FieldType.TEXT),
510
- defaultValue: NonEmptyTextValue.optional(),
478
+ defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional(),
511
479
  configuration: import_zod5.z.object({
512
480
  maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
513
481
  type: import_zod5.z.enum(["text", "password"]).optional(),
@@ -517,7 +485,7 @@ var TextField = BaseField.extend({
517
485
  }).describe("Text input");
518
486
  var NumberField = BaseField.extend({
519
487
  type: import_zod5.z.literal(FieldType.NUMBER),
520
- defaultValue: NumberFieldValue.optional(),
488
+ defaultValue: import_zod5.z.union([NumberFieldValue, DependencyExpression]).optional(),
521
489
  configuration: import_zod5.z.object({
522
490
  min: import_zod5.z.number().optional().describe("Minimum value"),
523
491
  max: import_zod5.z.number().optional().describe("Maximum value"),
@@ -527,7 +495,7 @@ var NumberField = BaseField.extend({
527
495
  }).describe("Number input");
528
496
  var TextAreaField = BaseField.extend({
529
497
  type: import_zod5.z.literal(FieldType.TEXTAREA),
530
- defaultValue: NonEmptyTextValue.optional(),
498
+ defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional(),
531
499
  configuration: import_zod5.z.object({
532
500
  maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
533
501
  rows: import_zod5.z.number().optional().describe("Number of visible text lines"),
@@ -561,28 +529,17 @@ var EmailField = BaseField.extend({
561
529
  configuration: import_zod5.z.object({
562
530
  maxLength: import_zod5.z.number().optional().describe("Maximum length of the text")
563
531
  }).default({ maxLength: 10 }).optional(),
564
- defaultValue: NonEmptyTextValue.optional()
532
+ defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
565
533
  });
566
534
  var DateField = BaseField.extend({
567
535
  type: import_zod5.z.literal(FieldType.DATE),
568
- defaultValue: DateValue.optional(),
536
+ defaultValue: import_zod5.z.union([DateValue, DependencyExpression]).optional(),
569
537
  configuration: import_zod5.z.object({
570
538
  notice: TranslationConfig.describe(
571
539
  "Text to display above the date input"
572
540
  ).optional()
573
541
  }).optional()
574
542
  }).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
- );
586
543
  var HtmlFontVariant = import_zod5.z.enum([
587
544
  "reg12",
588
545
  "reg14",
@@ -595,7 +552,7 @@ var HtmlFontVariant = import_zod5.z.enum([
595
552
  ]);
596
553
  var Paragraph = BaseField.extend({
597
554
  type: import_zod5.z.literal(FieldType.PARAGRAPH),
598
- defaultValue: NonEmptyTextValue.optional(),
555
+ defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional(),
599
556
  configuration: import_zod5.z.object({
600
557
  styles: import_zod5.z.object({
601
558
  fontVariant: HtmlFontVariant.optional()
@@ -604,7 +561,7 @@ var Paragraph = BaseField.extend({
604
561
  }).describe("A read-only HTML <p> paragraph");
605
562
  var PageHeader = BaseField.extend({
606
563
  type: import_zod5.z.literal(FieldType.PAGE_HEADER),
607
- defaultValue: NonEmptyTextValue.optional()
564
+ defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
608
565
  }).describe("A read-only header component for form pages");
609
566
  var File = BaseField.extend({
610
567
  type: import_zod5.z.literal(FieldType.FILE),
@@ -615,8 +572,7 @@ var File = BaseField.extend({
615
572
  width: import_zod5.z.enum(["full", "auto"]).optional().describe(
616
573
  "Whether the file upload button should take the full width of the container or not"
617
574
  )
618
- }).optional(),
619
- fileName: TranslationConfig.optional()
575
+ }).optional()
620
576
  }).default({
621
577
  maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
622
578
  })
@@ -627,7 +583,7 @@ var SelectOption = import_zod5.z.object({
627
583
  });
628
584
  var RadioGroup = BaseField.extend({
629
585
  type: import_zod5.z.literal(FieldType.RADIO_GROUP),
630
- defaultValue: TextValue.optional(),
586
+ defaultValue: import_zod5.z.union([TextValue, DependencyExpression]).optional(),
631
587
  options: import_zod5.z.array(SelectOption).describe("A list of options"),
632
588
  configuration: import_zod5.z.object({
633
589
  styles: import_zod5.z.object({
@@ -637,7 +593,7 @@ var RadioGroup = BaseField.extend({
637
593
  }).describe("Grouped radio options");
638
594
  var BulletList = BaseField.extend({
639
595
  type: import_zod5.z.literal(FieldType.BULLET_LIST),
640
- defaultValue: TextValue.optional(),
596
+ defaultValue: import_zod5.z.string().optional(),
641
597
  items: import_zod5.z.array(TranslationConfig).describe("A list of items"),
642
598
  configuration: import_zod5.z.object({
643
599
  styles: import_zod5.z.object({
@@ -647,16 +603,16 @@ var BulletList = BaseField.extend({
647
603
  }).describe("A list of bullet points");
648
604
  var Select = BaseField.extend({
649
605
  type: import_zod5.z.literal(FieldType.SELECT),
650
- defaultValue: TextValue.optional(),
606
+ defaultValue: import_zod5.z.union([TextValue, DependencyExpression]).optional(),
651
607
  options: import_zod5.z.array(SelectOption).describe("A list of options")
652
608
  }).describe("Select input");
653
609
  var Checkbox = BaseField.extend({
654
610
  type: import_zod5.z.literal(FieldType.CHECKBOX),
655
- defaultValue: CheckboxFieldValue.optional()
611
+ defaultValue: import_zod5.z.union([CheckboxFieldValue, DependencyExpression]).optional()
656
612
  }).describe("Boolean checkbox field");
657
613
  var Country = BaseField.extend({
658
614
  type: import_zod5.z.literal(FieldType.COUNTRY),
659
- defaultValue: NonEmptyTextValue.optional()
615
+ defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
660
616
  }).describe("Country select field");
661
617
  var AdministrativeAreas = import_zod5.z.enum([
662
618
  "ADMIN_STRUCTURE",
@@ -671,12 +627,12 @@ var AdministrativeAreaConfiguration = import_zod5.z.object({
671
627
  }).describe("Administrative area options");
672
628
  var AdministrativeArea = BaseField.extend({
673
629
  type: import_zod5.z.literal(FieldType.ADMINISTRATIVE_AREA),
674
- defaultValue: NonEmptyTextValue.optional(),
630
+ defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional(),
675
631
  configuration: AdministrativeAreaConfiguration
676
632
  }).describe("Administrative area input field e.g. facility, office");
677
633
  var Location = BaseField.extend({
678
634
  type: import_zod5.z.literal(FieldType.LOCATION),
679
- defaultValue: NonEmptyTextValue.optional()
635
+ defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
680
636
  }).describe("Input field for a location");
681
637
  var FileUploadWithOptions = BaseField.extend({
682
638
  type: import_zod5.z.literal(FieldType.FILE_WITH_OPTIONS),
@@ -690,11 +646,11 @@ var FileUploadWithOptions = BaseField.extend({
690
646
  });
691
647
  var Facility = BaseField.extend({
692
648
  type: import_zod5.z.literal(FieldType.FACILITY),
693
- defaultValue: NonEmptyTextValue.optional()
649
+ defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
694
650
  }).describe("Input field for a facility");
695
651
  var Office = BaseField.extend({
696
652
  type: import_zod5.z.literal(FieldType.OFFICE),
697
- defaultValue: NonEmptyTextValue.optional()
653
+ defaultValue: import_zod5.z.union([RequiredTextValue, DependencyExpression]).optional()
698
654
  }).describe("Input field for an office");
699
655
  var Address = BaseField.extend({
700
656
  type: import_zod5.z.literal(FieldType.ADDRESS),
@@ -703,7 +659,7 @@ var Address = BaseField.extend({
703
659
  var DataEntry = import_zod5.z.union([
704
660
  import_zod5.z.object({
705
661
  label: TranslationConfig,
706
- value: TranslationConfig.or(import_zod5.z.string())
662
+ value: import_zod5.z.string()
707
663
  }),
708
664
  import_zod5.z.object({
709
665
  fieldId: import_zod5.z.string()
@@ -722,7 +678,6 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
722
678
  NumberField,
723
679
  TextAreaField,
724
680
  DateField,
725
- DateRangeField,
726
681
  Paragraph,
727
682
  RadioGroup,
728
683
  BulletList,
@@ -740,6 +695,7 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
740
695
  EmailField,
741
696
  FileUploadWithOptions,
742
697
  DataField
698
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
743
699
  ]);
744
700
 
745
701
  // ../commons/src/events/PageConfig.ts
@@ -864,8 +820,6 @@ var ActionFormConfig = import_zod8.z.object({
864
820
  var FormConfig = import_zod8.z.union([DeclarationFormConfig, ActionFormConfig]);
865
821
 
866
822
  // ../commons/src/events/ActionConfig.ts
867
- var import_zod_openapi = require("zod-openapi");
868
- (0, import_zod_openapi.extendZodWithOpenApi)(import_zod9.z);
869
823
  var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
870
824
  /** If conditional is defined, the action is shown to the user only if the condition is met */
871
825
  ShowConditional,
@@ -943,24 +897,18 @@ var ApproveCorrectionConfig = ActionConfigBase.merge(
943
897
  })
944
898
  );
945
899
  var ActionConfig = import_zod9.z.discriminatedUnion("type", [
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" });
900
+ DeclareConfig,
901
+ ValidateConfig,
902
+ RejectDeclarationConfig,
903
+ MarkedAsDuplicateConfig,
904
+ ArchiveConfig,
905
+ RegisterConfig,
906
+ DeleteConfig,
907
+ PrintCertificateActionConfig,
908
+ RequestCorrectionConfig,
909
+ RejectCorrectionConfig,
910
+ ApproveCorrectionConfig
911
+ ]);
964
912
  var DeclarationActionConfig = import_zod9.z.discriminatedUnion("type", [
965
913
  DeclareConfig,
966
914
  ValidateConfig,
@@ -1004,12 +952,10 @@ var LanguageConfig = import_zod11.z.object({
1004
952
  });
1005
953
 
1006
954
  // ../commons/src/events/EventConfig.ts
1007
- var import_zod17 = require("zod");
955
+ var import_zod20 = require("zod");
1008
956
 
1009
957
  // ../commons/src/events/DeduplicationConfig.ts
1010
958
  var import_zod12 = require("zod");
1011
- var import_zod_openapi2 = require("zod-openapi");
1012
- (0, import_zod_openapi2.extendZodWithOpenApi)(import_zod12.z);
1013
959
  var FieldReference = import_zod12.z.string();
1014
960
  var Matcher = import_zod12.z.object({
1015
961
  fieldId: import_zod12.z.string(),
@@ -1070,9 +1016,7 @@ var Clause = import_zod12.z.lazy(
1070
1016
  DateRangeMatcher,
1071
1017
  DateDistanceMatcher
1072
1018
  ])
1073
- ).openapi({
1074
- ref: "Clause"
1075
- });
1019
+ );
1076
1020
  var DeduplicationConfig = import_zod12.z.object({
1077
1021
  id: import_zod12.z.string(),
1078
1022
  label: TranslationConfig,
@@ -1081,214 +1025,272 @@ var DeduplicationConfig = import_zod12.z.object({
1081
1025
 
1082
1026
  // ../commons/src/events/SummaryConfig.ts
1083
1027
  var import_zod13 = require("zod");
1084
- var BaseField2 = import_zod13.z.object({
1085
- emptyValueMessage: TranslationConfig.optional(),
1086
- conditionals: import_zod13.z.array(ShowConditional).default([]).optional()
1087
- });
1088
- var ReferenceField = BaseField2.extend({
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
- )
1093
- }).describe("Field directly referencing event data with field id");
1094
- var Field = BaseField2.extend({
1028
+ var Field = import_zod13.z.object({
1095
1029
  id: import_zod13.z.string().describe("Id of summary field"),
1096
1030
  value: TranslationConfig.describe(
1097
1031
  "Summary field value. Can utilise values defined in configuration and EventMetadata"
1098
1032
  ),
1099
1033
  label: TranslationConfig,
1100
1034
  emptyValueMessage: TranslationConfig.optional()
1101
- }).describe("Custom configured field");
1035
+ });
1036
+ var Title = import_zod13.z.object({
1037
+ id: import_zod13.z.string(),
1038
+ label: TranslationConfig.describe("Title content"),
1039
+ emptyValueMessage: TranslationConfig.optional()
1040
+ });
1102
1041
  var SummaryConfig = import_zod13.z.object({
1103
- fields: import_zod13.z.array(import_zod13.z.union([Field, ReferenceField])).describe("Fields rendered in summary view.")
1042
+ title: Title.describe("Title of summary view."),
1043
+ fields: import_zod13.z.array(Field).describe("Fields rendered in summary view.")
1104
1044
  }).describe("Configuration for summary in event.");
1105
1045
 
1106
- // ../commons/src/events/AdvancedSearchConfig.ts
1046
+ // ../commons/src/events/WorkqueueConfig.ts
1047
+ var import_zod15 = require("zod");
1048
+
1049
+ // ../commons/src/events/EventMetadata.ts
1107
1050
  var import_zod14 = require("zod");
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()
1114
- });
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")
1051
+ var EventStatus = {
1052
+ CREATED: "CREATED",
1053
+ NOTIFIED: "NOTIFIED",
1054
+ DECLARED: "DECLARED",
1055
+ VALIDATED: "VALIDATED",
1056
+ REGISTERED: "REGISTERED",
1057
+ CERTIFIED: "CERTIFIED",
1058
+ REJECTED: "REJECTED",
1059
+ ARCHIVED: "ARCHIVED"
1060
+ };
1061
+ var eventStatuses = Object.values(EventStatus);
1062
+ var EventStatuses = import_zod14.z.nativeEnum(EventStatus);
1063
+ var EventMetadata = import_zod14.z.object({
1064
+ id: import_zod14.z.string(),
1065
+ type: import_zod14.z.string(),
1066
+ status: EventStatuses,
1067
+ createdAt: import_zod14.z.string().datetime(),
1068
+ createdBy: import_zod14.z.string(),
1069
+ createdAtLocation: import_zod14.z.string(),
1070
+ modifiedAt: import_zod14.z.string().datetime(),
1071
+ assignedTo: import_zod14.z.string().nullish(),
1072
+ updatedBy: import_zod14.z.string(),
1073
+ trackingId: import_zod14.z.string(),
1074
+ registrationNumber: import_zod14.z.string().nullish()
1123
1075
  });
1124
- var SearchField = import_zod14.z.discriminatedUnion("fieldType", [
1125
- FieldConfigSchema,
1126
- EventFieldConfigSchema
1127
- ]);
1128
- var AdvancedSearchConfig = import_zod14.z.object({
1076
+ var eventMetadataLabelMap = {
1077
+ "event.assignedTo": {
1078
+ id: "event.assignedTo.label",
1079
+ defaultMessage: "Assigned To",
1080
+ description: "Assigned To"
1081
+ },
1082
+ "event.createdAt": {
1083
+ id: "event.createdAt.label",
1084
+ defaultMessage: "Created",
1085
+ description: "Created At"
1086
+ },
1087
+ "event.createdAtLocation": {
1088
+ id: "event.createdAtLocation.label",
1089
+ defaultMessage: "Location",
1090
+ description: "Created At Location"
1091
+ },
1092
+ "event.createdBy": {
1093
+ id: "event.createdBy.label",
1094
+ defaultMessage: "Created By",
1095
+ description: "Created By"
1096
+ },
1097
+ "event.id": {
1098
+ id: "event.id.label",
1099
+ defaultMessage: "ID",
1100
+ description: "ID"
1101
+ },
1102
+ "event.modifiedAt": {
1103
+ id: "event.modifiedAt.label",
1104
+ defaultMessage: "Updated",
1105
+ description: "Modified At"
1106
+ },
1107
+ "event.status": {
1108
+ id: "event.status.label",
1109
+ defaultMessage: "Status",
1110
+ description: "Status"
1111
+ },
1112
+ "event.type": {
1113
+ id: "event.type.label",
1114
+ defaultMessage: "Type",
1115
+ description: "Type"
1116
+ },
1117
+ "event.updatedBy": {
1118
+ id: "event.updatedBy.label",
1119
+ defaultMessage: "Updated By",
1120
+ description: "Updated By"
1121
+ },
1122
+ "event.trackingId": {
1123
+ id: "event.trackingId.label",
1124
+ defaultMessage: "Tracking ID",
1125
+ description: "Tracking ID"
1126
+ },
1127
+ "event.registrationNumber": {
1128
+ id: "event.registrationNumber.label",
1129
+ defaultMessage: "Registration Number",
1130
+ description: "Registration Number"
1131
+ }
1132
+ };
1133
+
1134
+ // ../commons/src/events/WorkqueueConfig.ts
1135
+ var WorkqueueConfig = import_zod15.z.object({
1136
+ id: import_zod15.z.string().describe("Unique identifier for workqueue."),
1137
+ filters: import_zod15.z.array(
1138
+ import_zod15.z.object({
1139
+ status: import_zod15.z.array(EventStatuses).describe("Defines which statusese are included in the workqueue.")
1140
+ })
1141
+ ).describe("Filters to be applied to workqueue.")
1142
+ }).describe("Configuration for workqueue.");
1143
+
1144
+ // ../commons/src/events/AdvancedSearchConfig.ts
1145
+ var import_zod16 = require("zod");
1146
+ var AdvancedSearchConfig = import_zod16.z.object({
1129
1147
  title: TranslationConfig.describe("Advanced search tab title"),
1130
- fields: import_zod14.z.array(SearchField).describe("Advanced search fields.")
1148
+ fields: import_zod16.z.array(
1149
+ import_zod16.z.object({
1150
+ fieldId: import_zod16.z.string(),
1151
+ config: import_zod16.z.object({
1152
+ type: import_zod16.z.enum(["FUZZY", "EXACT", "RANGE"]).describe("Determines the type of field")
1153
+ }).optional().describe("Configuration options for the field")
1154
+ })
1155
+ ).optional().default([]).describe("Advanced search fields.")
1131
1156
  });
1132
1157
 
1133
1158
  // ../commons/src/events/utils.ts
1134
1159
  var import_lodash = require("lodash");
1135
1160
 
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"
1146
- };
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()
1161
+ // ../commons/src/workqueues/WorkqueueConfig.ts
1162
+ var import_zod18 = require("zod");
1163
+
1164
+ // ../commons/src/workqueues/defaultColumns.ts
1165
+ var import_zod17 = require("zod");
1166
+ var WorkQueueColumnConfig = import_zod17.z.object({
1167
+ id: import_zod17.z.string(),
1168
+ label: TranslationConfig
1163
1169
  });
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
- })
1170
+ var defaultColumns = {
1171
+ event: {
1172
+ id: "event",
1173
+ label: {
1174
+ defaultMessage: "Event",
1175
+ description: "This is the label for the workqueue column",
1176
+ id: "workqueue.default.column.event"
1177
+ }
1178
+ },
1179
+ status: {
1180
+ id: "status",
1181
+ label: {
1182
+ defaultMessage: "Status",
1183
+ description: "This is the label for the workqueue column",
1184
+ id: "workqueue.default.column.status"
1185
+ }
1186
+ },
1187
+ createdAt: {
1188
+ id: "createdAt",
1189
+ label: {
1190
+ defaultMessage: "Created",
1191
+ description: "This is the label for the workqueue column",
1192
+ id: "workqueue.default.column.createdAt"
1193
+ }
1194
+ },
1195
+ modifiedAt: {
1196
+ id: "modifiedAt",
1197
+ label: {
1198
+ defaultMessage: "Modified",
1199
+ description: "This is the label for the workqueue column",
1200
+ id: "workqueue.default.column.modifiedAt"
1201
+ }
1202
+ }
1203
+ };
1204
+ var DefaultColumnKeys = import_zod17.z.enum(
1205
+ Object.keys(defaultColumns)
1243
1206
  );
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"
1207
+
1208
+ // ../commons/src/workqueues/WorkqueueConfig.ts
1209
+ var rootWorkqueueConfig = import_zod18.z.object({
1210
+ id: import_zod18.z.string(),
1211
+ title: TranslationConfig,
1212
+ columns: import_zod18.z.array(WorkQueueColumnConfig),
1213
+ defaultColumns: import_zod18.z.array(DefaultColumnKeys)
1262
1214
  });
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
- )
1215
+ var defineWorkqueue = (config) => rootWorkqueueConfig.parse(config);
1216
+
1217
+ // ../commons/src/workqueues/all.ts
1218
+ var allWorkqueue = defineWorkqueue({
1219
+ id: "all",
1220
+ title: {
1221
+ defaultMessage: "All events",
1222
+ description: "This is the label for the workqueue",
1223
+ id: "workqueue.all.label"
1224
+ },
1225
+ columns: [
1226
+ {
1227
+ id: "title",
1228
+ label: {
1229
+ defaultMessage: "Title",
1230
+ description: "This is the label for the workqueue column",
1231
+ id: "workqueue.all.column.title"
1232
+ }
1233
+ }
1234
+ ],
1235
+ defaultColumns: ["event", "status", "createdAt", "modifiedAt"]
1236
+ });
1237
+
1238
+ // ../commons/src/workqueues/readyForReview.ts
1239
+ var inReviewWorkqueue = defineWorkqueue({
1240
+ id: "ready-for-review",
1241
+ title: {
1242
+ defaultMessage: "Ready for review",
1243
+ description: "Label for in review workqueue",
1244
+ id: "event.workqueue.in-review.label"
1245
+ },
1246
+ columns: [
1247
+ {
1248
+ id: "title",
1249
+ label: {
1250
+ defaultMessage: "Title",
1251
+ description: "This is the label for the workqueue column",
1252
+ id: "workqueue.in-reveiw.column.title"
1253
+ }
1254
+ }
1255
+ ],
1256
+ defaultColumns: ["event", "createdAt", "modifiedAt"]
1257
+ });
1258
+
1259
+ // ../commons/src/workqueues/readyToPrint.ts
1260
+ var registeredWorkqueue = defineWorkqueue({
1261
+ id: "registered",
1262
+ title: {
1263
+ defaultMessage: "Ready to print",
1264
+ description: "Label for registered workqueue",
1265
+ id: "event.workqueue.registered.label"
1266
+ },
1267
+ columns: [
1268
+ {
1269
+ id: "title",
1270
+ label: {
1271
+ defaultMessage: "Title",
1272
+ description: "This is the label for the workqueue column",
1273
+ id: "workqueue.registered.column.title"
1274
+ }
1275
+ }
1276
+ ],
1277
+ defaultColumns: ["event", "createdAt", "modifiedAt"]
1283
1278
  });
1284
1279
 
1280
+ // ../commons/src/workqueues/index.ts
1281
+ var workqueues = {
1282
+ all: allWorkqueue,
1283
+ registered: registeredWorkqueue,
1284
+ inReview: inReviewWorkqueue
1285
+ };
1286
+
1285
1287
  // ../commons/src/conditionals/validate.ts
1286
1288
  var import_ajv = __toESM(require("ajv"));
1287
1289
  var import_ajv_formats = __toESM(require("ajv-formats"));
1288
1290
  var import_date_fns = require("date-fns");
1289
1291
 
1290
1292
  // ../commons/src/events/FieldTypeMapping.ts
1291
- var import_zod16 = require("zod");
1293
+ var import_zod19 = require("zod");
1292
1294
  function mapFieldTypeToZod(type, required) {
1293
1295
  let schema;
1294
1296
  switch (type) {
@@ -1298,9 +1300,6 @@ function mapFieldTypeToZod(type, required) {
1298
1300
  case FieldType.EMAIL:
1299
1301
  schema = EmailValue;
1300
1302
  break;
1301
- case FieldType.DATE_RANGE:
1302
- schema = DateRangeFieldValue;
1303
- break;
1304
1303
  case FieldType.TEXT:
1305
1304
  case FieldType.TEXTAREA:
1306
1305
  case FieldType.DIVIDER:
@@ -1315,7 +1314,8 @@ function mapFieldTypeToZod(type, required) {
1315
1314
  case FieldType.FACILITY:
1316
1315
  case FieldType.OFFICE:
1317
1316
  case FieldType.SIGNATURE:
1318
- schema = required ? NonEmptyTextValue : TextValue;
1317
+ case FieldType.HIDDEN:
1318
+ schema = required ? RequiredTextValue : TextValue;
1319
1319
  break;
1320
1320
  case FieldType.NUMBER:
1321
1321
  schema = NumberFieldValue;
@@ -1343,7 +1343,7 @@ function createValidationSchema(config) {
1343
1343
  for (const field2 of config) {
1344
1344
  shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
1345
1345
  }
1346
- return import_zod16.z.object(shape);
1346
+ return import_zod19.z.object(shape);
1347
1347
  }
1348
1348
  function mapFieldTypeToMockValue(field2, i) {
1349
1349
  switch (field2.type) {
@@ -1381,8 +1381,6 @@ function mapFieldTypeToMockValue(field2, i) {
1381
1381
  };
1382
1382
  case FieldType.DATE:
1383
1383
  return "2021-01-01";
1384
- case FieldType.DATE_RANGE:
1385
- return ["2021-01-01", "2021-01-02"];
1386
1384
  case FieldType.CHECKBOX:
1387
1385
  return true;
1388
1386
  case FieldType.FILE:
@@ -1417,7 +1415,6 @@ function mapFieldTypeToEmptyValue(field2) {
1417
1415
  case FieldType.EMAIL:
1418
1416
  case FieldType.DATE:
1419
1417
  case FieldType.CHECKBOX:
1420
- case FieldType.DATE_RANGE:
1421
1418
  case FieldType.DATA:
1422
1419
  return null;
1423
1420
  case FieldType.ADDRESS:
@@ -1450,9 +1447,6 @@ var isParagraphFieldType = (field2) => {
1450
1447
  var isDateFieldType = (field2) => {
1451
1448
  return field2.config.type === FieldType.DATE;
1452
1449
  };
1453
- var isDateRangeFieldType = (field2) => {
1454
- return field2.config.type === FieldType.DATE_RANGE;
1455
- };
1456
1450
  var isPageHeaderFieldType = (field2) => {
1457
1451
  return field2.config.type === FieldType.PAGE_HEADER;
1458
1452
  };
@@ -1523,23 +1517,12 @@ var ajv = new import_ajv.default({
1523
1517
  function validate(schema, data) {
1524
1518
  return ajv.validate(schema, data);
1525
1519
  }
1526
- function isConditionMet(conditional, values) {
1527
- return validate(conditional, {
1528
- $form: values,
1529
- $now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
1530
- });
1531
- }
1532
1520
  function getConditionalActionsForField(field2, values) {
1533
1521
  if (!field2.conditionals) {
1534
1522
  return [];
1535
1523
  }
1536
1524
  return field2.conditionals.filter((conditional) => validate(conditional.conditional, values)).map((conditional) => conditional.type);
1537
1525
  }
1538
- function areConditionsMet(conditions, values) {
1539
- return conditions.every(
1540
- (condition) => isConditionMet(condition.conditional, values)
1541
- );
1542
- }
1543
1526
  function isFieldConditionMet(field2, form, conditionalType) {
1544
1527
  const hasRule = (field2.conditionals ?? []).some(
1545
1528
  (conditional) => conditional.type === conditionalType
@@ -1558,10 +1541,6 @@ function isFieldConditionMet(field2, form, conditionalType) {
1558
1541
  function isFieldVisible(field2, form) {
1559
1542
  return isFieldConditionMet(field2, form, ConditionalType.SHOW);
1560
1543
  }
1561
- function isFieldEmptyAndNotRequired(field2, form) {
1562
- const fieldValue = form[field2.id];
1563
- return !field2.required && (fieldValue === void 0 || fieldValue === "");
1564
- }
1565
1544
  function isFieldEnabled(field2, form) {
1566
1545
  return isFieldConditionMet(field2, form, ConditionalType.ENABLE);
1567
1546
  }
@@ -1666,11 +1645,6 @@ function runFieldValidations({
1666
1645
  field: field2,
1667
1646
  values
1668
1647
  }) {
1669
- if (!isFieldVisible(field2, values) || isFieldEmptyAndNotRequired(field2, values)) {
1670
- return {
1671
- errors: []
1672
- };
1673
- }
1674
1648
  const conditionalParameters = {
1675
1649
  $form: values,
1676
1650
  $now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
@@ -1688,6 +1662,29 @@ function runFieldValidations({
1688
1662
  errors: [...fieldValidationResult, ...customValidationResults]
1689
1663
  };
1690
1664
  }
1665
+ function getFieldValidationErrors({
1666
+ field: field2,
1667
+ values
1668
+ }) {
1669
+ if (!isFieldVisible(field2, values) || !isFieldEnabled(field2, values)) {
1670
+ if (values[field2.id]) {
1671
+ return {
1672
+ errors: [
1673
+ {
1674
+ message: errorMessages.hiddenField
1675
+ }
1676
+ ]
1677
+ };
1678
+ }
1679
+ return {
1680
+ errors: []
1681
+ };
1682
+ }
1683
+ return runFieldValidations({
1684
+ field: field2,
1685
+ values
1686
+ });
1687
+ }
1691
1688
 
1692
1689
  // ../commons/src/uuid.ts
1693
1690
  var import_uuid = require("uuid");
@@ -1695,6 +1692,9 @@ function getUUID() {
1695
1692
  return (0, import_uuid.v4)();
1696
1693
  }
1697
1694
 
1695
+ // ../commons/src/events/utils.ts
1696
+ var import_date_fns2 = require("date-fns");
1697
+
1698
1698
  // ../commons/src/utils.ts
1699
1699
  function getOrThrow(x, message) {
1700
1700
  if (x === void 0 || x === null) {
@@ -1731,9 +1731,15 @@ var getActionAnnotationFields = (actionConfig) => {
1731
1731
  }
1732
1732
  return [];
1733
1733
  };
1734
- function getAllAnnotationFields(config) {
1734
+ var getAllAnnotationFields = (config) => {
1735
1735
  return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
1736
- }
1736
+ };
1737
+ var findAllFields = (config) => {
1738
+ return (0, import_lodash.flattenDeep)([
1739
+ ...getDeclarationFields(config),
1740
+ ...getAllAnnotationFields(config)
1741
+ ]);
1742
+ };
1737
1743
  var findRecordActionPages = (config, actionType) => {
1738
1744
  const action = config.actions.find((a) => a.type === actionType);
1739
1745
  if (action?.type === ActionType.REQUEST_CORRECTION) {
@@ -1756,22 +1762,34 @@ function getActionReview(configuration, actionType) {
1756
1762
  function getActionReviewFields(configuration, actionType) {
1757
1763
  return getActionReview(configuration, actionType).fields;
1758
1764
  }
1759
- function isPageVisible(page, formValues) {
1760
- if (!page.conditional) {
1761
- return true;
1765
+ function validateWorkqueueConfig(workqueueConfigs) {
1766
+ workqueueConfigs.map((workqueue) => {
1767
+ const rootWorkqueue = Object.values(workqueues).find(
1768
+ (wq) => wq.id === workqueue.id
1769
+ );
1770
+ if (!rootWorkqueue) {
1771
+ throw new Error(
1772
+ `Invalid workqueue configuration: workqueue not found with id: ${workqueue.id}`
1773
+ );
1774
+ }
1775
+ });
1776
+ }
1777
+ function isPageVisible(page, formValues) {
1778
+ if (!page.conditional) {
1779
+ return true;
1762
1780
  }
1763
- return isConditionMet(page.conditional, formValues);
1781
+ return validate(page.conditional, {
1782
+ $form: formValues,
1783
+ $now: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
1784
+ });
1764
1785
  }
1765
- function omitHiddenFields(fields, values, visibleVerificationPageIds = []) {
1786
+ function omitHiddenFields(fields, values) {
1766
1787
  return (0, import_lodash.omitBy)(values, (_, fieldId) => {
1767
- if (visibleVerificationPageIds.includes(fieldId)) {
1768
- return false;
1769
- }
1770
- const fieldConfigs = fields.filter((f) => f.id === fieldId);
1771
- if (!fieldConfigs.length) {
1788
+ const field2 = fields.find((f) => f.id === fieldId);
1789
+ if (!field2) {
1772
1790
  return true;
1773
1791
  }
1774
- return fieldConfigs.every((f) => !isFieldVisible(f, values));
1792
+ return !isFieldVisible(field2, values);
1775
1793
  });
1776
1794
  }
1777
1795
  function omitHiddenPaginatedFields(formConfig, declaration) {
@@ -1795,49 +1813,13 @@ function createEmptyDraft(eventId, draftId, actionType) {
1795
1813
  annotation: {},
1796
1814
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1797
1815
  createdBy: "@todo",
1798
- createdAtLocation: "@todo",
1799
- status: ActionStatus.Accepted,
1800
- transactionId: "@todo",
1801
- createdByRole: "@todo"
1816
+ createdAtLocation: "@todo"
1802
1817
  }
1803
1818
  };
1804
1819
  }
1805
1820
  function isVerificationPage(page) {
1806
1821
  return page.type === PageTypes.enum.VERIFICATION;
1807
1822
  }
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
- }
1841
1823
  function deepMerge(currentDocument, actionDocument) {
1842
1824
  return (0, import_lodash.mergeWith)(
1843
1825
  currentDocument,
@@ -1864,49 +1846,19 @@ function findLastAssignmentAction(actions) {
1864
1846
  function isWriteAction(actionType) {
1865
1847
  return writeActions.safeParse(actionType).success;
1866
1848
  }
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
1849
 
1892
1850
  // ../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(
1851
+ var EventConfig = import_zod20.z.object({
1852
+ id: import_zod20.z.string().describe(
1897
1853
  'A machine-readable identifier for the event, e.g. "birth" or "death"'
1898
1854
  ),
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
1855
  summary: SummaryConfig,
1905
1856
  label: TranslationConfig,
1906
- actions: import_zod17.z.array(ActionConfig),
1857
+ actions: import_zod20.z.array(ActionConfig),
1907
1858
  declaration: DeclarationFormConfig,
1908
- deduplication: import_zod17.z.array(DeduplicationConfig).optional().default([]),
1909
- advancedSearch: import_zod17.z.array(AdvancedSearchConfig).optional().default([])
1859
+ workqueues: import_zod20.z.array(WorkqueueConfig),
1860
+ deduplication: import_zod20.z.array(DeduplicationConfig).optional().default([]),
1861
+ advancedSearch: import_zod20.z.array(AdvancedSearchConfig).optional().default([])
1910
1862
  }).superRefine((event2, ctx) => {
1911
1863
  const allFields = findAllFields(event2);
1912
1864
  const fieldIds = allFields.map((field2) => field2.id);
@@ -1922,43 +1874,16 @@ var EventConfig = import_zod17.z.object({
1922
1874
  });
1923
1875
  }
1924
1876
  const invalidFields = event2.advancedSearch.flatMap(
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
- )
1877
+ (section) => section.fields.filter((field2) => !fieldIds.includes(field2.fieldId))
1932
1878
  );
1933
1879
  if (invalidFields.length > 0) {
1934
1880
  ctx.addIssue({
1935
1881
  code: "custom",
1936
- message: `Advanced search id must match a field id of form fields or pre-defined metadata fields.
1882
+ message: `Advanced search id must match a field id in fields array.
1937
1883
  Invalid AdvancedSearch field IDs for event ${event2.id}: ${invalidFields.map((f) => f.fieldId).join(", ")}`,
1938
1884
  path: ["advancedSearch"]
1939
1885
  });
1940
1886
  }
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"
1962
1887
  });
1963
1888
 
1964
1889
  // ../commons/src/events/EventConfigInput.ts
@@ -1967,807 +1892,306 @@ var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
1967
1892
  var definePage = (page) => PageConfig.parse(page);
1968
1893
  var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
1969
1894
 
1970
- // ../commons/src/events/WorkqueueConfig.ts
1971
- var import_zod20 = require("zod");
1972
-
1973
- // ../commons/src/events/EventIndex.ts
1974
- var import_zod19 = require("zod");
1895
+ // ../commons/src/events/Draft.ts
1896
+ var import_zod23 = require("zod");
1975
1897
 
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"
1987
- };
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.")
2006
- });
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
- }
1898
+ // ../commons/src/events/ActionDocument.ts
1899
+ var import_zod21 = require("zod");
1900
+ var ActionUpdate = import_zod21.z.record(import_zod21.z.string(), FieldUpdateValue);
1901
+ var ActionStatus = {
1902
+ Requested: "Requested",
1903
+ Accepted: "Accepted",
1904
+ Rejected: "Rejected"
2129
1905
  };
2130
-
2131
- // ../commons/src/events/EventIndex.ts
2132
- var EventIndex = EventMetadata.extend({
2133
- declaration: EventState
1906
+ var ActionBase = import_zod21.z.object({
1907
+ id: import_zod21.z.string(),
1908
+ createdAt: import_zod21.z.string().datetime(),
1909
+ createdBy: import_zod21.z.string(),
1910
+ declaration: ActionUpdate,
1911
+ annotation: ActionUpdate.optional(),
1912
+ createdAtLocation: import_zod21.z.string(),
1913
+ status: import_zod21.z.enum([
1914
+ ActionStatus.Requested,
1915
+ ActionStatus.Accepted,
1916
+ ActionStatus.Rejected
1917
+ ]),
1918
+ // If the action is an asynchronous confirmation for another action, we will save the original action id here.
1919
+ originalActionId: import_zod21.z.string().optional()
2134
1920
  });
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
1921
+ var AssignedAction = ActionBase.merge(
1922
+ import_zod21.z.object({
1923
+ type: import_zod21.z.literal(ActionType.ASSIGN),
1924
+ assignedTo: import_zod21.z.string()
2139
1925
  })
2140
1926
  );
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
- ])
1927
+ var UnassignedAction = ActionBase.merge(
1928
+ import_zod21.z.object({
1929
+ type: import_zod21.z.literal(ActionType.UNASSIGN),
1930
+ assignedTo: import_zod21.z.literal(null).default(null)
1931
+ })
2160
1932
  );
2161
- var QueryExpression = import_zod19.z.object({
2162
- type: import_zod19.z.literal("and"),
2163
- eventType: import_zod19.z.string(),
2164
- status: import_zod19.z.optional(import_zod19.z.union([AnyOf, Exact])),
2165
- createdAt: import_zod19.z.optional(DateCondition),
2166
- updatedAt: import_zod19.z.optional(DateCondition),
2167
- createAtLocation: import_zod19.z.optional(import_zod19.z.union([Within, Exact])),
2168
- updatedAtLocation: import_zod19.z.optional(import_zod19.z.union([Within, Exact])),
2169
- createdBy: import_zod19.z.optional(Exact),
2170
- updatedBy: import_zod19.z.optional(Exact),
2171
- trackingId: import_zod19.z.optional(Exact),
2172
- flags: import_zod19.z.optional(import_zod19.z.array(import_zod19.z.union([AnyOf, Not]))),
2173
- data: QueryInput
2174
- }).partial();
2175
- var Or2 = import_zod19.z.object({
2176
- type: import_zod19.z.literal("or"),
2177
- clauses: import_zod19.z.array(QueryExpression)
2178
- });
2179
- var QueryType = import_zod19.z.discriminatedUnion("type", [QueryExpression, Or2]);
2180
-
2181
- // ../commons/src/conditionals/conditionals.ts
2182
- function defineConditional(schema) {
2183
- return schema;
2184
- }
2185
- function defineFormConditional(schema) {
2186
- const schemaWithForm = {
2187
- type: "object",
2188
- properties: {
2189
- $form: schema
2190
- },
2191
- required: ["$form"]
2192
- };
2193
- return defineConditional(schemaWithForm);
2194
- }
2195
- function alwaysTrue() {
2196
- return {};
2197
- }
2198
- function and(...conditions) {
2199
- return defineConditional({
2200
- type: "object",
2201
- allOf: conditions,
2202
- required: []
2203
- });
2204
- }
2205
- function or(...conditions) {
2206
- return defineConditional({
2207
- type: "object",
2208
- anyOf: conditions,
2209
- required: []
2210
- });
2211
- }
2212
- function not(condition) {
2213
- return defineConditional({
2214
- type: "object",
2215
- not: condition,
2216
- required: []
2217
- });
2218
- }
2219
- function never() {
2220
- return not(alwaysTrue());
2221
- }
2222
- var user = {
2223
- hasScope: (scope) => defineConditional({
2224
- type: "object",
2225
- properties: {
2226
- $user: {
2227
- type: "object",
2228
- required: ["scope"],
2229
- properties: {
2230
- scope: {
2231
- type: "array",
2232
- contains: {
2233
- type: "string",
2234
- const: scope
2235
- }
2236
- }
2237
- }
2238
- }
2239
- },
2240
- required: ["$user"]
1933
+ var RegisterAction = ActionBase.merge(
1934
+ import_zod21.z.object({
1935
+ type: import_zod21.z.literal(ActionType.REGISTER),
1936
+ registrationNumber: import_zod21.z.string().optional()
2241
1937
  })
2242
- };
2243
- function createEventConditionals() {
2244
- return {
2245
- /**
2246
- * Checks if the event contains a specific action type.
2247
- * @param action - The action type to check for.
2248
- */
2249
- hasAction: (action) => defineConditional({
2250
- type: "object",
2251
- properties: {
2252
- $event: {
2253
- type: "object",
2254
- properties: {
2255
- actions: {
2256
- type: "array",
2257
- contains: {
2258
- type: "object",
2259
- properties: {
2260
- type: {
2261
- const: action
2262
- }
2263
- },
2264
- required: ["type"]
2265
- }
2266
- }
2267
- },
2268
- required: ["actions"]
2269
- }
2270
- },
2271
- required: ["$event"]
2272
- })
2273
- };
2274
- }
2275
- function getDateFromNow(days) {
2276
- return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
2277
- }
2278
- function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
2279
- return {
2280
- type: "object",
2281
- properties: {
2282
- [fieldId]: {
2283
- type: "string",
2284
- format: "date",
2285
- [clause]: { $data: `1/${comparedFieldId}` }
2286
- },
2287
- [comparedFieldId]: { type: "string", format: "date" }
2288
- },
2289
- required: [fieldId]
2290
- };
2291
- }
2292
- function isFieldReference(value) {
2293
- return typeof value === "object" && value !== null && "_fieldId" in value;
2294
- }
2295
- function createFieldConditionals(fieldId) {
2296
- const getDateRange = (date, clause) => ({
2297
- type: "object",
2298
- properties: {
2299
- [fieldId]: {
2300
- type: "string",
2301
- format: "date",
2302
- [clause]: date
2303
- }
2304
- },
2305
- required: [fieldId]
2306
- });
2307
- return {
2308
- isAfter: () => ({
2309
- days: (days) => ({
2310
- inPast: () => defineFormConditional(
2311
- getDateRange(getDateFromNow(days), "formatMinimum")
2312
- ),
2313
- inFuture: () => defineFormConditional(
2314
- getDateRange(getDateFromNow(-days), "formatMinimum")
2315
- )
2316
- }),
2317
- date: (date) => {
2318
- if (isFieldReference(date)) {
2319
- const comparedFieldId = date._fieldId;
2320
- return defineFormConditional(
2321
- getDateRangeToFieldReference(
2322
- fieldId,
2323
- comparedFieldId,
2324
- "formatMinimum"
2325
- )
2326
- );
2327
- }
2328
- return defineFormConditional(getDateRange(date, "formatMinimum"));
2329
- },
2330
- now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
2331
- }),
2332
- isBefore: () => ({
2333
- days: (days) => ({
2334
- inPast: () => defineFormConditional(
2335
- getDateRange(getDateFromNow(days), "formatMaximum")
2336
- ),
2337
- inFuture: () => defineFormConditional(
2338
- getDateRange(getDateFromNow(-days), "formatMaximum")
2339
- )
2340
- }),
2341
- date: (date) => {
2342
- if (isFieldReference(date)) {
2343
- const comparedFieldId = date._fieldId;
2344
- return defineFormConditional(
2345
- getDateRangeToFieldReference(
2346
- fieldId,
2347
- comparedFieldId,
2348
- "formatMaximum"
2349
- )
2350
- );
2351
- }
2352
- return defineFormConditional(getDateRange(date, "formatMaximum"));
2353
- },
2354
- now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
2355
- }),
2356
- isEqualTo: (value) => {
2357
- if (isFieldReference(value)) {
2358
- const comparedFieldId = value._fieldId;
2359
- return defineFormConditional({
2360
- type: "object",
2361
- properties: {
2362
- [fieldId]: {
2363
- type: ["string", "boolean"],
2364
- const: { $data: `1/${comparedFieldId}` }
2365
- },
2366
- [comparedFieldId]: { type: ["string", "boolean"] }
2367
- },
2368
- required: [fieldId, comparedFieldId]
2369
- });
2370
- }
2371
- return defineFormConditional({
2372
- type: "object",
2373
- properties: {
2374
- [fieldId]: {
2375
- oneOf: [
2376
- { type: "string", const: value },
2377
- { type: "boolean", const: value }
2378
- ],
2379
- const: value
2380
- }
2381
- },
2382
- required: [fieldId]
2383
- });
2384
- },
2385
- /**
2386
- * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
2387
- * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
2388
- * @returns whether the field is falsy (undefined, false, null, empty string)
2389
- *
2390
- * NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
2391
- *
2392
- */
2393
- isFalsy: () => defineFormConditional({
2394
- type: "object",
2395
- properties: {
2396
- [fieldId]: {
2397
- anyOf: [
2398
- { const: "undefined" },
2399
- { const: false },
2400
- { const: null },
2401
- { const: "" }
2402
- ]
2403
- }
2404
- },
2405
- anyOf: [
2406
- {
2407
- required: [fieldId]
2408
- },
2409
- {
2410
- not: {
2411
- required: [fieldId]
2412
- }
2413
- }
2414
- ]
2415
- }),
2416
- isUndefined: () => defineFormConditional({
2417
- type: "object",
2418
- properties: {
2419
- [fieldId]: {
2420
- type: "string",
2421
- enum: ["undefined"]
2422
- }
2423
- },
2424
- not: {
2425
- required: [fieldId]
2426
- }
2427
- }),
2428
- inArray: (values) => defineFormConditional({
2429
- type: "object",
2430
- properties: {
2431
- [fieldId]: {
2432
- type: "string",
2433
- enum: values
2434
- }
2435
- },
2436
- required: [fieldId]
2437
- }),
2438
- isValidEnglishName: () => defineFormConditional({
2439
- type: "object",
2440
- properties: {
2441
- [fieldId]: {
2442
- type: "string",
2443
- 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'._-]*)*$",
2444
- description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
2445
- }
2446
- },
2447
- required: [fieldId]
2448
- }),
2449
- /**
2450
- * Checks if the field value matches a given regular expression pattern.
2451
- * @param pattern - The regular expression pattern to match the field value against.
2452
- * @returns A JSONSchema conditional that validates the field value against the pattern.
2453
- */
2454
- matches: (pattern) => defineFormConditional({
2455
- type: "object",
2456
- properties: {
2457
- [fieldId]: {
2458
- type: "string",
2459
- pattern
2460
- }
2461
- },
2462
- required: [fieldId]
2463
- }),
2464
- isBetween: (min, max) => defineFormConditional({
2465
- type: "object",
2466
- properties: {
2467
- [fieldId]: {
2468
- type: "number",
2469
- minimum: min,
2470
- maximum: max
2471
- }
2472
- },
2473
- required: [fieldId]
2474
- }),
2475
- getId: () => ({ fieldId })
2476
- };
2477
- }
2478
-
2479
- // ../commons/src/event-config/event-configuration.ts
2480
- function createEventFieldConfig(fieldId, options) {
2481
- return {
2482
- fieldId,
2483
- options,
2484
- config: { type: "exact" },
2485
- fieldType: "event"
2486
- };
2487
- }
2488
-
2489
- // ../commons/src/events/event.ts
2490
- function eventFn(fieldId, options) {
2491
- return createEventFieldConfig(fieldId, options);
2492
- }
2493
- var event = Object.assign(eventFn, {
2494
- ...createEventConditionals(),
2495
- field(field2) {
2496
- return {
2497
- $event: field2
2498
- };
2499
- }
2500
- });
2501
-
2502
- // ../commons/src/events/WorkqueueConfig.ts
2503
- var WorkqueueConfig = import_zod20.z.object({
2504
- slug: import_zod20.z.string().describe("Determines the url of the workqueue."),
2505
- name: TranslationConfig.describe(
2506
- "Title of the workflow (both in navigation and on the page)"
2507
- ),
2508
- query: QueryType,
2509
- actions: import_zod20.z.array(
2510
- import_zod20.z.object({
2511
- type: import_zod20.z.string(),
2512
- conditionals: import_zod20.z.array(Conditional).optional()
1938
+ );
1939
+ var DeclareAction = ActionBase.merge(
1940
+ import_zod21.z.object({
1941
+ type: import_zod21.z.literal(ActionType.DECLARE)
1942
+ })
1943
+ );
1944
+ var ValidateAction = ActionBase.merge(
1945
+ import_zod21.z.object({
1946
+ type: import_zod21.z.literal(ActionType.VALIDATE)
1947
+ })
1948
+ );
1949
+ var RejectAction = ActionBase.merge(
1950
+ import_zod21.z.object({
1951
+ type: import_zod21.z.literal(ActionType.REJECT)
1952
+ })
1953
+ );
1954
+ var MarkAsDuplicateAction = ActionBase.merge(
1955
+ import_zod21.z.object({
1956
+ type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE)
1957
+ })
1958
+ );
1959
+ var ArchiveAction = ActionBase.merge(
1960
+ import_zod21.z.object({
1961
+ type: import_zod21.z.literal(ActionType.ARCHIVE)
1962
+ })
1963
+ );
1964
+ var CreatedAction = ActionBase.merge(
1965
+ import_zod21.z.object({
1966
+ type: import_zod21.z.literal(ActionType.CREATE)
1967
+ })
1968
+ );
1969
+ var NotifiedAction = ActionBase.merge(
1970
+ import_zod21.z.object({
1971
+ type: import_zod21.z.literal(ActionType.NOTIFY)
1972
+ })
1973
+ );
1974
+ var PrintCertificateAction = ActionBase.merge(
1975
+ import_zod21.z.object({
1976
+ type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE)
1977
+ })
1978
+ );
1979
+ var RequestedCorrectionAction = ActionBase.merge(
1980
+ import_zod21.z.object({
1981
+ type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION)
1982
+ })
1983
+ );
1984
+ var ApprovedCorrectionAction = ActionBase.merge(
1985
+ import_zod21.z.object({
1986
+ type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION),
1987
+ requestId: import_zod21.z.string()
1988
+ })
1989
+ );
1990
+ var RejectedCorrectionAction = ActionBase.merge(
1991
+ import_zod21.z.object({
1992
+ type: import_zod21.z.literal(ActionType.REJECT_CORRECTION),
1993
+ requestId: import_zod21.z.string()
1994
+ })
1995
+ );
1996
+ var ReadAction = ActionBase.merge(
1997
+ import_zod21.z.object({
1998
+ type: import_zod21.z.literal(ActionType.READ)
1999
+ })
2000
+ );
2001
+ var ActionDocument = import_zod21.z.discriminatedUnion("type", [
2002
+ CreatedAction,
2003
+ ValidateAction,
2004
+ RejectAction,
2005
+ MarkAsDuplicateAction,
2006
+ ArchiveAction,
2007
+ NotifiedAction,
2008
+ RegisterAction,
2009
+ DeclareAction,
2010
+ AssignedAction,
2011
+ RequestedCorrectionAction,
2012
+ ApprovedCorrectionAction,
2013
+ RejectedCorrectionAction,
2014
+ UnassignedAction,
2015
+ PrintCertificateAction,
2016
+ ReadAction
2017
+ ]);
2018
+ var AsyncRejectActionDocument = ActionBase.omit({
2019
+ declaration: true,
2020
+ annotation: true,
2021
+ createdBy: true,
2022
+ createdAtLocation: true
2023
+ }).merge(
2024
+ import_zod21.z.object({
2025
+ type: import_zod21.z.enum(ConfirmableActions),
2026
+ status: import_zod21.z.literal(ActionStatus.Rejected)
2027
+ })
2028
+ );
2029
+ var Action = import_zod21.z.union([ActionDocument, AsyncRejectActionDocument]);
2030
+ var ResolvedUser = import_zod21.z.object({
2031
+ id: import_zod21.z.string(),
2032
+ role: import_zod21.z.string(),
2033
+ name: import_zod21.z.array(
2034
+ import_zod21.z.object({
2035
+ use: import_zod21.z.string(),
2036
+ given: import_zod21.z.array(import_zod21.z.string()),
2037
+ family: import_zod21.z.string()
2513
2038
  })
2514
- ),
2515
- columns: import_zod20.z.array(
2516
- import_zod20.z.object({ label: TranslationConfig, value: EventMetadataParameter })
2517
- ).default([
2518
- {
2519
- label: {
2520
- id: "workqueues.dateOfEvent",
2521
- defaultMessage: "Date of Event",
2522
- description: "Label for workqueue column: dateOfEvent"
2523
- },
2524
- value: event.field("dateOfEvent")
2525
- }
2526
- ])
2527
- }).describe("Configuration for workqueue.");
2528
- function defineWorkqueue(workqueues) {
2529
- return workqueues.map((workqueue) => WorkqueueConfig.parse(workqueue));
2530
- }
2531
-
2532
- // ../commons/src/events/Draft.ts
2533
- var import_zod22 = require("zod");
2039
+ )
2040
+ });
2534
2041
 
2535
2042
  // ../commons/src/events/ActionInput.ts
2536
- var import_zod21 = require("zod");
2537
- var import_zod_openapi5 = require("zod-openapi");
2538
- (0, import_zod_openapi5.extendZodWithOpenApi)(import_zod21.z);
2539
- var BaseActionInput = import_zod21.z.object({
2540
- eventId: import_zod21.z.string(),
2541
- transactionId: import_zod21.z.string(),
2043
+ var import_zod22 = require("zod");
2044
+ var BaseActionInput = import_zod22.z.object({
2045
+ eventId: import_zod22.z.string(),
2046
+ transactionId: import_zod22.z.string(),
2542
2047
  declaration: ActionUpdate.default({}),
2543
2048
  annotation: ActionUpdate.optional(),
2544
- originalActionId: import_zod21.z.string().optional(),
2545
- keepAssignment: import_zod21.z.boolean().optional()
2049
+ originalActionId: import_zod22.z.string().optional(),
2050
+ keepAssignment: import_zod22.z.boolean().optional()
2546
2051
  });
2547
2052
  var CreateActionInput = BaseActionInput.merge(
2548
- import_zod21.z.object({
2549
- type: import_zod21.z.literal(ActionType.CREATE).default(ActionType.CREATE),
2550
- createdAtLocation: import_zod21.z.string()
2053
+ import_zod22.z.object({
2054
+ type: import_zod22.z.literal(ActionType.CREATE).default(ActionType.CREATE),
2055
+ createdAtLocation: import_zod22.z.string()
2551
2056
  })
2552
2057
  );
2553
2058
  var RegisterActionInput = BaseActionInput.merge(
2554
- import_zod21.z.object({
2555
- type: import_zod21.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
2556
- registrationNumber: import_zod21.z.string().optional()
2059
+ import_zod22.z.object({
2060
+ type: import_zod22.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
2061
+ registrationNumber: import_zod22.z.string().optional()
2557
2062
  })
2558
2063
  );
2559
2064
  var ValidateActionInput = BaseActionInput.merge(
2560
- import_zod21.z.object({
2561
- type: import_zod21.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
2562
- duplicates: import_zod21.z.array(import_zod21.z.string())
2065
+ import_zod22.z.object({
2066
+ type: import_zod22.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
2067
+ duplicates: import_zod22.z.array(import_zod22.z.string())
2563
2068
  })
2564
2069
  );
2565
2070
  var NotifyActionInput = BaseActionInput.merge(
2566
- import_zod21.z.object({
2567
- type: import_zod21.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
2071
+ import_zod22.z.object({
2072
+ type: import_zod22.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
2568
2073
  })
2569
2074
  );
2570
2075
  var DeclareActionInput = BaseActionInput.merge(
2571
- import_zod21.z.object({
2572
- type: import_zod21.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
2076
+ import_zod22.z.object({
2077
+ type: import_zod22.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
2573
2078
  })
2574
2079
  );
2575
2080
  var PrintCertificateActionInput = BaseActionInput.merge(
2576
- import_zod21.z.object({
2577
- type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
2081
+ import_zod22.z.object({
2082
+ type: import_zod22.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
2578
2083
  })
2579
2084
  );
2580
2085
  var RejectDeclarationActionInput = BaseActionInput.merge(
2581
- import_zod21.z.object({
2582
- type: import_zod21.z.literal(ActionType.REJECT).default(ActionType.REJECT)
2086
+ import_zod22.z.object({
2087
+ type: import_zod22.z.literal(ActionType.REJECT).default(ActionType.REJECT)
2583
2088
  })
2584
2089
  );
2585
2090
  var MarkedAsDuplicateActionInput = BaseActionInput.merge(
2586
- import_zod21.z.object({
2587
- type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
2091
+ import_zod22.z.object({
2092
+ type: import_zod22.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
2588
2093
  })
2589
2094
  );
2590
2095
  var ArchiveActionInput = BaseActionInput.merge(
2591
- import_zod21.z.object({
2592
- type: import_zod21.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
2096
+ import_zod22.z.object({
2097
+ type: import_zod22.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
2593
2098
  })
2594
2099
  );
2595
2100
  var AssignActionInput = BaseActionInput.merge(
2596
- import_zod21.z.object({
2597
- type: import_zod21.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
2598
- assignedTo: import_zod21.z.string()
2101
+ import_zod22.z.object({
2102
+ type: import_zod22.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
2103
+ assignedTo: import_zod22.z.string()
2599
2104
  })
2600
2105
  );
2601
2106
  var UnassignActionInput = BaseActionInput.merge(
2602
- import_zod21.z.object({
2603
- type: import_zod21.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
2604
- assignedTo: import_zod21.z.literal(null).default(null)
2107
+ import_zod22.z.object({
2108
+ type: import_zod22.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
2109
+ assignedTo: import_zod22.z.literal(null).default(null)
2605
2110
  })
2606
2111
  );
2607
2112
  var RequestCorrectionActionInput = BaseActionInput.merge(
2608
- import_zod21.z.object({
2609
- type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
2113
+ import_zod22.z.object({
2114
+ type: import_zod22.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
2610
2115
  })
2611
2116
  );
2612
2117
  var RejectCorrectionActionInput = BaseActionInput.merge(
2613
- import_zod21.z.object({
2614
- requestId: import_zod21.z.string(),
2615
- type: import_zod21.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
2118
+ import_zod22.z.object({
2119
+ requestId: import_zod22.z.string(),
2120
+ type: import_zod22.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
2616
2121
  })
2617
2122
  );
2618
2123
  var ApproveCorrectionActionInput = BaseActionInput.merge(
2619
- import_zod21.z.object({
2620
- requestId: import_zod21.z.string(),
2621
- type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
2124
+ import_zod22.z.object({
2125
+ requestId: import_zod22.z.string(),
2126
+ type: import_zod22.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
2622
2127
  })
2623
2128
  );
2624
2129
  var ReadActionInput = BaseActionInput.merge(
2625
- import_zod21.z.object({
2626
- type: import_zod21.z.literal(ActionType.READ).default(ActionType.READ)
2130
+ import_zod22.z.object({
2131
+ type: import_zod22.z.literal(ActionType.READ).default(ActionType.READ)
2627
2132
  })
2628
2133
  );
2629
- var DeleteActionInput = import_zod21.z.object({ eventId: import_zod21.z.string() });
2630
- var ActionInput = import_zod21.z.discriminatedUnion("type", [
2631
- CreateActionInput.openapi({ ref: "CreateActionInput" }),
2632
- ValidateActionInput.openapi({ ref: "ValidateActionInput" }),
2633
- RegisterActionInput.openapi({ ref: "RegisterActionInput" }),
2634
- NotifyActionInput.openapi({ ref: "NotifyActionInput" }),
2635
- DeclareActionInput.openapi({ ref: "DeclareActionInput" }),
2636
- RejectDeclarationActionInput.openapi({
2637
- ref: "RejectDeclarationActionInput"
2638
- }),
2639
- MarkedAsDuplicateActionInput.openapi({
2640
- ref: "MarkedAsDuplicateActionInput"
2641
- }),
2642
- ArchiveActionInput.openapi({ ref: "ArchiveActionInput" }),
2643
- AssignActionInput.openapi({ ref: "AssignActionInput" }),
2644
- UnassignActionInput.openapi({ ref: "UnassignActionInput" }),
2645
- PrintCertificateActionInput.openapi({ ref: "PrintCertificateActionInput" }),
2646
- RequestCorrectionActionInput.openapi({
2647
- ref: "RequestCorrectionActionInput"
2648
- }),
2649
- RejectCorrectionActionInput.openapi({ ref: "RejectCorrectionActionInput" }),
2650
- ApproveCorrectionActionInput.openapi({
2651
- ref: "ApproveCorrectionActionInput"
2652
- }),
2653
- ReadActionInput.openapi({ ref: "ReadActionInput" })
2654
- ]).openapi({
2655
- ref: "ActionInput"
2656
- });
2134
+ var ActionInput = import_zod22.z.discriminatedUnion("type", [
2135
+ CreateActionInput,
2136
+ ValidateActionInput,
2137
+ RegisterActionInput,
2138
+ NotifyActionInput,
2139
+ DeclareActionInput,
2140
+ RejectDeclarationActionInput,
2141
+ MarkedAsDuplicateActionInput,
2142
+ ArchiveActionInput,
2143
+ AssignActionInput,
2144
+ UnassignActionInput,
2145
+ PrintCertificateActionInput,
2146
+ RequestCorrectionActionInput,
2147
+ RejectCorrectionActionInput,
2148
+ ApproveCorrectionActionInput,
2149
+ ReadActionInput
2150
+ ]);
2657
2151
 
2658
2152
  // ../commons/src/events/Draft.ts
2659
- var Draft = import_zod22.z.object({
2660
- id: import_zod22.z.string(),
2661
- eventId: import_zod22.z.string(),
2662
- transactionId: import_zod22.z.string(),
2663
- createdAt: import_zod22.z.string().datetime(),
2153
+ var Draft = import_zod23.z.object({
2154
+ id: import_zod23.z.string(),
2155
+ eventId: import_zod23.z.string(),
2156
+ transactionId: import_zod23.z.string(),
2157
+ createdAt: import_zod23.z.string().datetime(),
2664
2158
  action: ActionBase.extend({
2665
2159
  type: ActionTypes
2666
2160
  }).omit({ id: true })
2667
2161
  });
2668
2162
  var DraftInput = BaseActionInput.extend({
2669
- type: ActionTypes,
2670
- status: import_zod22.z.enum([
2671
- ActionStatus.Requested,
2672
- ActionStatus.Accepted,
2673
- ActionStatus.Rejected
2674
- ])
2163
+ type: ActionTypes
2675
2164
  });
2676
2165
 
2677
2166
  // ../commons/src/events/EventInput.ts
2678
- var import_zod23 = require("zod");
2679
- var EventInput = import_zod23.z.object({
2680
- transactionId: import_zod23.z.string(),
2681
- type: import_zod23.z.string(),
2682
- dateOfEvent: import_zod23.z.object({ fieldId: import_zod23.z.string() }).optional()
2167
+ var import_zod24 = require("zod");
2168
+ var EventInput = import_zod24.z.object({
2169
+ transactionId: import_zod24.z.string(),
2170
+ type: import_zod24.z.string()
2683
2171
  });
2684
2172
 
2685
2173
  // ../commons/src/events/EventDocument.ts
2686
- var import_zod24 = require("zod");
2687
- var import_zod_openapi6 = require("zod-openapi");
2688
- (0, import_zod_openapi6.extendZodWithOpenApi)(import_zod24.z);
2689
- var EventDocument = import_zod24.z.object({
2690
- id: import_zod24.z.string(),
2691
- type: import_zod24.z.string(),
2692
- dateOfEvent: import_zod24.z.object({ fieldId: import_zod24.z.string() }).optional(),
2693
- createdAt: import_zod24.z.string().datetime(),
2694
- updatedAt: import_zod24.z.string().datetime(),
2695
- actions: import_zod24.z.array(Action),
2696
- trackingId: import_zod24.z.string()
2697
- }).openapi({ ref: "EventDocument" });
2174
+ var import_zod25 = require("zod");
2175
+ var EventDocument = import_zod25.z.object({
2176
+ id: import_zod25.z.string(),
2177
+ type: import_zod25.z.string(),
2178
+ createdAt: import_zod25.z.string().datetime(),
2179
+ updatedAt: import_zod25.z.string().datetime(),
2180
+ actions: import_zod25.z.array(Action),
2181
+ trackingId: import_zod25.z.string()
2182
+ });
2698
2183
 
2699
- // ../commons/src/events/state/utils.ts
2700
- function getActionRequests(actionType, actions) {
2701
- const filtered = actions.filter((action) => action.type === actionType);
2702
- const accept = filtered.find(
2703
- (action) => action.status === ActionStatus.Accepted
2704
- );
2705
- const request = filtered.find(
2706
- (action) => action.status === ActionStatus.Requested
2707
- );
2708
- const reject = filtered.find(
2709
- (action) => action.status === ActionStatus.Rejected
2710
- );
2711
- return {
2712
- reject,
2713
- accept,
2714
- request
2715
- };
2716
- }
2717
- function getDeclarationActionCreationMetadata(actionType, actions) {
2718
- const { accept: acceptAction, request: requestAction } = getActionRequests(
2719
- actionType,
2720
- actions
2721
- );
2722
- if (!acceptAction) {
2723
- return null;
2724
- }
2725
- const registrationNumber = acceptAction.type === ActionType.REGISTER ? acceptAction.registrationNumber : null;
2726
- return {
2727
- // When 3rd party API returns 200 OK, we assume that the request was accepted, and persist single 'accepted' action.
2728
- createdAt: requestAction?.createdAt ?? acceptAction.createdAt,
2729
- createdBy: requestAction?.createdBy ?? acceptAction.createdBy,
2730
- createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
2731
- acceptedAt: acceptAction.createdAt,
2732
- createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
2733
- registrationNumber
2734
- };
2735
- }
2736
- function getDeclarationActionUpdateMetadata(actions) {
2737
- const createAction = getOrThrow(
2738
- actions.find((action) => action.type === ActionType.CREATE),
2739
- `Event has no ${ActionType.CREATE} action`
2740
- );
2741
- return [ActionType.DECLARE, ActionType.VALIDATE, ActionType.REGISTER].reduce(
2742
- (metadata, actionType) => {
2743
- const { accept, request } = getActionRequests(actionType, actions);
2744
- return {
2745
- createdAt: request?.createdAt ?? accept?.createdAt ?? metadata.createdAt,
2746
- createdBy: request?.createdBy ?? accept?.createdBy ?? metadata.createdBy,
2747
- createdAtLocation: request?.createdAtLocation ?? accept?.createdAtLocation ?? metadata.createdAtLocation,
2748
- createdByRole: request?.createdByRole ?? accept?.createdByRole ?? metadata.createdByRole
2749
- };
2750
- },
2751
- {
2752
- createdAt: createAction.createdAt,
2753
- createdBy: createAction.createdBy,
2754
- createdAtLocation: createAction.createdAtLocation,
2755
- createdByRole: createAction.createdByRole
2756
- }
2757
- );
2758
- }
2759
- function getLegalStatuses(actions) {
2760
- return {
2761
- [EventStatus.DECLARED]: getDeclarationActionCreationMetadata(
2762
- ActionType.DECLARE,
2763
- actions
2764
- ),
2765
- [EventStatus.REGISTERED]: getDeclarationActionCreationMetadata(
2766
- ActionType.REGISTER,
2767
- actions
2768
- )
2769
- };
2770
- }
2184
+ // ../commons/src/events/EventIndex.ts
2185
+ var import_zod26 = require("zod");
2186
+ var EventIndex = EventMetadata.extend({
2187
+ declaration: import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any())
2188
+ });
2189
+ var EventSearchIndex = import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any()).and(
2190
+ import_zod26.z.object({
2191
+ type: import_zod26.z.string()
2192
+ // Ensures "type" (event-id) exists and is a string
2193
+ })
2194
+ );
2771
2195
 
2772
2196
  // ../commons/src/events/state/index.ts
2773
2197
  function getStatusFromActions(actions) {
@@ -2778,67 +2202,30 @@ function getStatusFromActions(actions) {
2778
2202
  return EventStatus.REJECTED;
2779
2203
  }
2780
2204
  return actions.reduce((status, action) => {
2781
- switch (action.type) {
2782
- case ActionType.CREATE:
2783
- return EventStatus.CREATED;
2784
- case ActionType.DECLARE:
2785
- return EventStatus.DECLARED;
2786
- case ActionType.VALIDATE:
2787
- return EventStatus.VALIDATED;
2788
- case ActionType.REGISTER:
2789
- return EventStatus.REGISTERED;
2790
- case ActionType.REJECT:
2791
- return EventStatus.REJECTED;
2792
- case ActionType.ARCHIVE:
2793
- return EventStatus.ARCHIVED;
2794
- case ActionType.NOTIFY:
2795
- return EventStatus.NOTIFIED;
2796
- case ActionType.PRINT_CERTIFICATE:
2797
- return EventStatus.CERTIFIED;
2798
- case ActionType.ASSIGN:
2799
- case ActionType.UNASSIGN:
2800
- case ActionType.REQUEST_CORRECTION:
2801
- case ActionType.APPROVE_CORRECTION:
2802
- case ActionType.MARKED_AS_DUPLICATE:
2803
- case ActionType.REJECT_CORRECTION:
2804
- case ActionType.READ:
2805
- default:
2806
- return status;
2205
+ if (action.type === ActionType.CREATE) {
2206
+ return EventStatus.CREATED;
2207
+ }
2208
+ if (action.type === ActionType.DECLARE) {
2209
+ return EventStatus.DECLARED;
2210
+ }
2211
+ if (action.type === ActionType.VALIDATE) {
2212
+ return EventStatus.VALIDATED;
2807
2213
  }
2214
+ if (action.type === ActionType.REGISTER) {
2215
+ return EventStatus.REGISTERED;
2216
+ }
2217
+ if (action.type === ActionType.REJECT) {
2218
+ return EventStatus.REJECTED;
2219
+ }
2220
+ if (action.type === ActionType.ARCHIVE) {
2221
+ return EventStatus.ARCHIVED;
2222
+ }
2223
+ if (action.type === ActionType.NOTIFY) {
2224
+ return EventStatus.NOTIFIED;
2225
+ }
2226
+ return status;
2808
2227
  }, EventStatus.CREATED);
2809
2228
  }
2810
- function getFlagsFromActions(actions) {
2811
- const sortedactions = actions.sort(
2812
- (a, b) => a.createdAt.localeCompare(b.createdAt)
2813
- );
2814
- const actionStatus = sortedactions.reduce(
2815
- (actionStatuses, { type, status }) => ({
2816
- ...actionStatuses,
2817
- [type]: status
2818
- }),
2819
- {}
2820
- );
2821
- const flags = Object.entries(actionStatus).filter(([, status]) => status !== ActionStatus.Accepted).map(([type, status]) => {
2822
- const flag = `${type.toLowerCase()}:${status.toLowerCase()}`;
2823
- return flag;
2824
- });
2825
- const isCertificatePrinted = sortedactions.reduce(
2826
- (prev, { type }) => {
2827
- if (type === ActionType.PRINT_CERTIFICATE) {
2828
- return true;
2829
- }
2830
- if (type === ActionType.APPROVE_CORRECTION) {
2831
- return false;
2832
- }
2833
- return prev;
2834
- },
2835
- false
2836
- );
2837
- if (isCertificatePrinted) {
2838
- flags.push(CustomFlags.CERTIFICATE_PRINTED);
2839
- }
2840
- return flags;
2841
- }
2842
2229
  function getAssignedUserFromActions(actions) {
2843
2230
  return actions.reduce((user2, action) => {
2844
2231
  if (action.type === ActionType.ASSIGN) {
@@ -2893,7 +2280,6 @@ function getAcceptedActions(event2) {
2893
2280
  (a) => a.status === ActionStatus.Accepted
2894
2281
  );
2895
2282
  }
2896
- var DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
2897
2283
  function getCurrentEventState(event2) {
2898
2284
  const creationAction = event2.actions.find(
2899
2285
  (action) => action.type === ActionType.CREATE
@@ -2901,32 +2287,25 @@ function getCurrentEventState(event2) {
2901
2287
  if (!creationAction) {
2902
2288
  throw new Error(`Event ${event2.id} has no creation action`);
2903
2289
  }
2904
- const acceptedActions = getAcceptedActions(event2);
2905
- const declarationUpdateMetadata = getDeclarationActionUpdateMetadata(
2906
- event2.actions
2290
+ const activeActions = getAcceptedActions(event2);
2291
+ const latestAction = activeActions[activeActions.length - 1];
2292
+ const registrationAction = activeActions.find(
2293
+ (a) => a.type === ActionType.REGISTER && a.status === ActionStatus.Accepted
2907
2294
  );
2908
- const declaration = aggregateActionDeclarations(acceptedActions);
2909
- const dateOfEvent = ZodDate.safeParse(
2910
- event2.dateOfEvent?.fieldId ? declaration[event2.dateOfEvent.fieldId] : event2[DEFAULT_DATE_OF_EVENT_PROPERTY]
2911
- ).data ?? null;
2295
+ const registrationNumber = registrationAction?.registrationNumber ?? null;
2912
2296
  return deepDropNulls({
2913
2297
  id: event2.id,
2914
2298
  type: event2.type,
2915
2299
  status: getStatusFromActions(event2.actions),
2916
- legalStatuses: getLegalStatuses(event2.actions),
2917
- createdAt: creationAction.createdAt,
2300
+ createdAt: event2.createdAt,
2918
2301
  createdBy: creationAction.createdBy,
2919
2302
  createdAtLocation: creationAction.createdAtLocation,
2920
- updatedAt: declarationUpdateMetadata.createdAt,
2921
- assignedTo: getAssignedUserFromActions(acceptedActions),
2922
- updatedBy: declarationUpdateMetadata.createdBy,
2923
- updatedAtLocation: declarationUpdateMetadata.createdAtLocation,
2924
- declaration,
2303
+ modifiedAt: latestAction.createdAt,
2304
+ assignedTo: getAssignedUserFromActions(activeActions),
2305
+ updatedBy: latestAction.createdBy,
2306
+ declaration: aggregateActionDeclarations(activeActions),
2925
2307
  trackingId: event2.trackingId,
2926
- // @TODO: unify this with rest of the code. It will trip us if updatedBy has different rules than updatedByUserRole
2927
- updatedByUserRole: declarationUpdateMetadata.createdByRole,
2928
- dateOfEvent,
2929
- flags: getFlagsFromActions(event2.actions)
2308
+ registrationNumber
2930
2309
  });
2931
2310
  }
2932
2311
  function getCurrentEventStateWithDrafts(event2, drafts) {
@@ -2951,7 +2330,7 @@ function getCurrentEventStateWithDrafts(event2, drafts) {
2951
2330
  return getCurrentEventState(withDrafts);
2952
2331
  }
2953
2332
  function applyDraftsToEventIndex(eventIndex, drafts) {
2954
- const indexedAt = eventIndex.updatedAt;
2333
+ const indexedAt = eventIndex.modifiedAt;
2955
2334
  const activeDrafts = drafts.filter(({ createdAt }) => new Date(createdAt) > new Date(indexedAt)).map((draft) => draft.action).sort();
2956
2335
  if (activeDrafts.length === 0) {
2957
2336
  return eventIndex;
@@ -2974,7 +2353,7 @@ function getAnnotationFromDrafts(drafts) {
2974
2353
  function getActionAnnotation({
2975
2354
  event: event2,
2976
2355
  actionType,
2977
- drafts = []
2356
+ drafts
2978
2357
  }) {
2979
2358
  const activeActions = getAcceptedActions(event2);
2980
2359
  const action = activeActions.find(
@@ -2993,6 +2372,7 @@ function getActionAnnotation({
2993
2372
 
2994
2373
  // ../commons/src/events/defineConfig.ts
2995
2374
  var defineConfig = (config) => {
2375
+ validateWorkqueueConfig(config.workqueues);
2996
2376
  const input = EventConfig.parse(config);
2997
2377
  return input;
2998
2378
  };
@@ -3005,69 +2385,301 @@ function generateTransactionId() {
3005
2385
  // ../commons/src/events/test.utils.ts
3006
2386
  var import_lodash2 = require("lodash");
3007
2387
 
3008
- // ../commons/src/field-config/field-configuration.ts
3009
- function createFieldConfigs(fieldId) {
3010
- const baseField = {
3011
- fieldId,
3012
- fieldType: "field"
2388
+ // ../commons/src/conditionals/conditionals.ts
2389
+ function defineConditional(schema) {
2390
+ return schema;
2391
+ }
2392
+ function defineFormConditional(schema) {
2393
+ const schemaWithForm = {
2394
+ type: "object",
2395
+ properties: {
2396
+ $form: schema
2397
+ },
2398
+ required: ["$form"]
2399
+ };
2400
+ return defineConditional(schemaWithForm);
2401
+ }
2402
+ function alwaysTrue() {
2403
+ return {};
2404
+ }
2405
+ function and(...conditions) {
2406
+ return defineConditional({
2407
+ type: "object",
2408
+ allOf: conditions,
2409
+ required: []
2410
+ });
2411
+ }
2412
+ function or(...conditions) {
2413
+ return defineConditional({
2414
+ type: "object",
2415
+ anyOf: conditions,
2416
+ required: []
2417
+ });
2418
+ }
2419
+ function not(condition) {
2420
+ return defineConditional({
2421
+ type: "object",
2422
+ not: condition,
2423
+ required: []
2424
+ });
2425
+ }
2426
+ function never() {
2427
+ return not(alwaysTrue());
2428
+ }
2429
+ var user = {
2430
+ hasScope: (scope) => defineConditional({
2431
+ type: "object",
2432
+ properties: {
2433
+ $user: {
2434
+ type: "object",
2435
+ required: ["scope"],
2436
+ properties: {
2437
+ scope: {
2438
+ type: "array",
2439
+ contains: {
2440
+ type: "string",
2441
+ const: scope
2442
+ }
2443
+ }
2444
+ }
2445
+ }
2446
+ },
2447
+ required: ["$user"]
2448
+ })
2449
+ };
2450
+ var event = {
2451
+ hasAction: (action) => defineConditional({
2452
+ type: "object",
2453
+ properties: {
2454
+ $event: {
2455
+ type: "object",
2456
+ properties: {
2457
+ actions: {
2458
+ type: "array",
2459
+ contains: {
2460
+ type: "object",
2461
+ properties: {
2462
+ type: {
2463
+ const: action
2464
+ }
2465
+ },
2466
+ required: ["type"]
2467
+ }
2468
+ }
2469
+ },
2470
+ required: ["actions"]
2471
+ }
2472
+ },
2473
+ required: ["$event"]
2474
+ })
2475
+ };
2476
+ function getDateFromNow(days) {
2477
+ return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
2478
+ }
2479
+ function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
2480
+ return {
2481
+ type: "object",
2482
+ properties: {
2483
+ [fieldId]: {
2484
+ type: "string",
2485
+ format: "date",
2486
+ [clause]: { $data: `1/${comparedFieldId}` }
2487
+ },
2488
+ [comparedFieldId]: { type: "string", format: "date" }
2489
+ },
2490
+ required: [fieldId]
3013
2491
  };
2492
+ }
2493
+ function isFieldReference(value) {
2494
+ return typeof value === "object" && value !== null && "_fieldId" in value;
2495
+ }
2496
+ function field(fieldId) {
2497
+ const getDateRange = (date, clause) => ({
2498
+ type: "object",
2499
+ properties: {
2500
+ [fieldId]: {
2501
+ type: "string",
2502
+ format: "date",
2503
+ [clause]: date
2504
+ }
2505
+ },
2506
+ required: [fieldId]
2507
+ });
3014
2508
  return {
3015
2509
  /**
3016
- * Creates a range configuration for the specified field.
3017
- *
3018
- * @returns An object containing the field ID and a configuration object with a type of 'range'.
3019
- *
3020
- * @example field('age').range()
3021
- * // {
3022
- * // fieldId: 'age',
3023
- * // config: { type: 'range' }
3024
- * // }
2510
+ * @private Internal property used for field reference tracking.
3025
2511
  */
3026
- range: () => ({
3027
- ...baseField,
3028
- config: { type: "range" }
2512
+ _fieldId: fieldId,
2513
+ isAfter: () => ({
2514
+ days: (days) => ({
2515
+ inPast: () => defineFormConditional(
2516
+ getDateRange(getDateFromNow(days), "formatMinimum")
2517
+ ),
2518
+ inFuture: () => defineFormConditional(
2519
+ getDateRange(getDateFromNow(-days), "formatMinimum")
2520
+ )
2521
+ }),
2522
+ date: (date) => {
2523
+ if (isFieldReference(date)) {
2524
+ const comparedFieldId = date._fieldId;
2525
+ return defineFormConditional(
2526
+ getDateRangeToFieldReference(
2527
+ fieldId,
2528
+ comparedFieldId,
2529
+ "formatMinimum"
2530
+ )
2531
+ );
2532
+ }
2533
+ return defineFormConditional(getDateRange(date, "formatMinimum"));
2534
+ },
2535
+ now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
3029
2536
  }),
2537
+ isBefore: () => ({
2538
+ days: (days) => ({
2539
+ inPast: () => defineFormConditional(
2540
+ getDateRange(getDateFromNow(days), "formatMaximum")
2541
+ ),
2542
+ inFuture: () => defineFormConditional(
2543
+ getDateRange(getDateFromNow(-days), "formatMaximum")
2544
+ )
2545
+ }),
2546
+ date: (date) => {
2547
+ if (isFieldReference(date)) {
2548
+ const comparedFieldId = date._fieldId;
2549
+ return defineFormConditional(
2550
+ getDateRangeToFieldReference(
2551
+ fieldId,
2552
+ comparedFieldId,
2553
+ "formatMaximum"
2554
+ )
2555
+ );
2556
+ }
2557
+ return defineFormConditional(getDateRange(date, "formatMaximum"));
2558
+ },
2559
+ now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
2560
+ }),
2561
+ isEqualTo: (value) => {
2562
+ if (isFieldReference(value)) {
2563
+ const comparedFieldId = value._fieldId;
2564
+ return defineFormConditional({
2565
+ type: "object",
2566
+ properties: {
2567
+ [fieldId]: {
2568
+ type: ["string", "boolean"],
2569
+ const: { $data: `1/${comparedFieldId}` }
2570
+ },
2571
+ [comparedFieldId]: { type: ["string", "boolean"] }
2572
+ },
2573
+ required: [fieldId, comparedFieldId]
2574
+ });
2575
+ }
2576
+ return defineFormConditional({
2577
+ type: "object",
2578
+ properties: {
2579
+ [fieldId]: {
2580
+ oneOf: [
2581
+ { type: "string", const: value },
2582
+ { type: "boolean", const: value }
2583
+ ],
2584
+ const: value
2585
+ }
2586
+ },
2587
+ required: [fieldId]
2588
+ });
2589
+ },
3030
2590
  /**
3031
- * Creates a configuration for exact matching of the specified field.
3032
- * @returns An object containing the field ID and a configuration object with a type of 'exact'.
3033
- * @example field('dob').exact()
3034
- * // {
3035
- * // fieldId: 'dob',
3036
- * // config: { type: 'exact' }
3037
- * // }
2591
+ * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
2592
+ * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
2593
+ * @returns whether the field is falsy (undefined, false, null, empty string)
2594
+ *
2595
+ * NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
2596
+ *
3038
2597
  */
3039
- exact: () => ({
3040
- ...baseField,
3041
- config: { type: "exact" }
2598
+ isFalsy: () => defineFormConditional({
2599
+ type: "object",
2600
+ properties: {
2601
+ [fieldId]: {
2602
+ anyOf: [
2603
+ { const: "undefined" },
2604
+ { const: false },
2605
+ { const: null },
2606
+ { const: "" }
2607
+ ]
2608
+ }
2609
+ },
2610
+ anyOf: [
2611
+ {
2612
+ required: [fieldId]
2613
+ },
2614
+ {
2615
+ not: {
2616
+ required: [fieldId]
2617
+ }
2618
+ }
2619
+ ]
2620
+ }),
2621
+ isUndefined: () => defineFormConditional({
2622
+ type: "object",
2623
+ properties: {
2624
+ [fieldId]: {
2625
+ type: "string",
2626
+ enum: ["undefined"]
2627
+ }
2628
+ },
2629
+ not: {
2630
+ required: [fieldId]
2631
+ }
2632
+ }),
2633
+ inArray: (values) => defineFormConditional({
2634
+ type: "object",
2635
+ properties: {
2636
+ [fieldId]: {
2637
+ type: "string",
2638
+ enum: values
2639
+ }
2640
+ },
2641
+ required: [fieldId]
2642
+ }),
2643
+ isValidEnglishName: () => defineFormConditional({
2644
+ type: "object",
2645
+ properties: {
2646
+ [fieldId]: {
2647
+ type: "string",
2648
+ pattern: "^[\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*( [\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*)*$",
2649
+ description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
2650
+ }
2651
+ },
2652
+ required: [fieldId]
3042
2653
  }),
3043
2654
  /**
3044
- * Creates a configuration for fuzzy matching of the specified field.
3045
- * @returns An object containing the field ID and a configuration object with a type of 'exact'.
3046
- * @example field('name').fuzzy()
3047
- * // {
3048
- * // fieldId: 'name',
3049
- * // config: { type: 'fuzzy' }
3050
- * // }
2655
+ * Checks if the field value matches a given regular expression pattern.
2656
+ * @param pattern - The regular expression pattern to match the field value against.
2657
+ * @returns A JSONSchema conditional that validates the field value against the pattern.
3051
2658
  */
3052
- fuzzy: () => ({
3053
- ...baseField,
3054
- config: { type: "fuzzy" }
2659
+ matches: (pattern) => defineFormConditional({
2660
+ type: "object",
2661
+ properties: {
2662
+ [fieldId]: {
2663
+ type: "string",
2664
+ pattern
2665
+ }
2666
+ },
2667
+ required: [fieldId]
2668
+ }),
2669
+ isBetween: (min, max) => defineFormConditional({
2670
+ type: "object",
2671
+ properties: {
2672
+ [fieldId]: {
2673
+ type: "number",
2674
+ minimum: min,
2675
+ maximum: max
2676
+ }
2677
+ },
2678
+ required: [fieldId]
3055
2679
  })
3056
2680
  };
3057
2681
  }
3058
2682
 
3059
- // ../commons/src/events/field.ts
3060
- function field(fieldId) {
3061
- return {
3062
- /**
3063
- * @private Internal property used for field reference tracking.
3064
- */
3065
- _fieldId: fieldId,
3066
- ...createFieldConditionals(fieldId),
3067
- ...createFieldConfigs(fieldId)
3068
- };
3069
- }
3070
-
3071
2683
  // ../commons/src/fixtures/tennis-club-membership-event.ts
3072
2684
  var PRINT_CERTIFICATE_FORM = defineActionForm({
3073
2685
  label: {
@@ -3984,12 +3596,20 @@ var tennisClubMembershipEvent = defineConfig({
3984
3596
  description: "This is what this event is referred as in the system",
3985
3597
  id: "event.tennis-club-membership.label"
3986
3598
  },
3987
- title: {
3988
- defaultMessage: "{applicant.firstname} {applicant.surname}",
3989
- description: "This is the title of the summary",
3990
- id: "v2.event.tennis-club-membership.title"
3991
- },
3992
3599
  summary: {
3600
+ title: {
3601
+ id: "event.tennis-club-membership.summary.title",
3602
+ label: {
3603
+ defaultMessage: "{applicant.firstname} {applicant.surname}",
3604
+ description: "This is the title of the summary",
3605
+ id: "v2.event.tennis-club-membership.summary.title"
3606
+ },
3607
+ emptyValueMessage: {
3608
+ defaultMessage: "Membership application",
3609
+ description: "This is the message shown when the applicant name is missing",
3610
+ id: "event.tennis-club-membership.summary.title.empty"
3611
+ }
3612
+ },
3993
3613
  fields: [
3994
3614
  {
3995
3615
  id: "applicant.firstname",
@@ -4010,18 +3630,47 @@ var tennisClubMembershipEvent = defineConfig({
4010
3630
  }
4011
3631
  },
4012
3632
  {
4013
- fieldId: "applicant.surname",
3633
+ id: "applicant.surname",
4014
3634
  label: {
4015
3635
  defaultMessage: "Applicant's last name",
4016
- description: "Label for surname",
4017
- id: "v2.event.tennis-club-membership.summary.field.surname.label"
3636
+ description: "This is the label for the field",
3637
+ id: "event.tennis-club-membership.summary.field.surname.label"
3638
+ },
3639
+ value: {
3640
+ defaultMessage: "{applicant.surname}",
3641
+ description: "This is the value to show in the summary",
3642
+ id: "event.tennis-club-membership.summary.field.surname"
3643
+ },
3644
+ emptyValueMessage: {
3645
+ defaultMessage: "Last name is not provided",
3646
+ description: "This is the message to show when the field is empty",
3647
+ id: "event.tennis-club-membership.summary.field.surname.empty"
4018
3648
  }
4019
- },
4020
- {
4021
- fieldId: "applicant.email"
4022
3649
  }
4023
3650
  ]
4024
3651
  },
3652
+ workqueues: [
3653
+ {
3654
+ id: "all",
3655
+ filters: []
3656
+ },
3657
+ {
3658
+ id: "ready-for-review",
3659
+ filters: [
3660
+ {
3661
+ status: ["DECLARED"]
3662
+ }
3663
+ ]
3664
+ },
3665
+ {
3666
+ id: "registered",
3667
+ filters: [
3668
+ {
3669
+ status: ["REGISTERED"]
3670
+ }
3671
+ ]
3672
+ }
3673
+ ],
4025
3674
  actions: [
4026
3675
  {
4027
3676
  type: ActionType.DECLARE,
@@ -4329,7 +3978,11 @@ var tennisClubMembershipEvent = defineConfig({
4329
3978
  description: "This is what this event is referred as in the system",
4330
3979
  id: "v2.event.tennis-club-membership.search"
4331
3980
  },
4332
- fields: [field("applicant.dob").exact()]
3981
+ fields: [
3982
+ {
3983
+ fieldId: "applicant.dob"
3984
+ }
3985
+ ]
4333
3986
  }
4334
3987
  ],
4335
3988
  declaration: TENNIS_CLUB_DECLARATION_FORM
@@ -4362,10 +4015,10 @@ function generateActionAnnotationInput(configuration, action) {
4362
4015
  );
4363
4016
  const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
4364
4017
  const annotation = fieldConfigsToActionPayload(annotationFields);
4365
- const visibleVerificationPageIds = getVisibleVerificationPageIds(
4366
- findRecordActionPages(configuration, action),
4367
- annotation
4368
- );
4018
+ const visibleVerificationPageIds = findRecordActionPages(
4019
+ configuration,
4020
+ action
4021
+ ).filter((page) => isVerificationPage(page)).filter((page) => isPageVisible(page, annotation)).map((page) => page.id);
4369
4022
  const visiblePageVerificationMap = visibleVerificationPageIds.reduce(
4370
4023
  (acc, pageId) => ({
4371
4024
  ...acc,
@@ -4396,7 +4049,6 @@ var eventPayloadGenerator = {
4396
4049
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4397
4050
  transactionId: getUUID(),
4398
4051
  action: {
4399
- transactionId: getUUID(),
4400
4052
  type: actionType,
4401
4053
  status: ActionStatus.Accepted,
4402
4054
  declaration: {
@@ -4411,7 +4063,6 @@ var eventPayloadGenerator = {
4411
4063
  },
4412
4064
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4413
4065
  createdBy: "@todo",
4414
- createdByRole: "@todo",
4415
4066
  createdAtLocation: "@todo"
4416
4067
  }
4417
4068
  },
@@ -4573,14 +4224,12 @@ function generateActionDocument({
4573
4224
  // @TODO: This should be fixed in the future.
4574
4225
  createdAt: new Date(Date.now() - 500).toISOString(),
4575
4226
  createdBy: getUUID(),
4576
- createdByRole: "FIELD_AGENT",
4577
4227
  id: getUUID(),
4578
- createdAtLocation: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
4228
+ createdAtLocation: "TODO",
4579
4229
  declaration: generateActionDeclarationInput(configuration, action),
4580
4230
  annotation: {},
4581
- status: ActionStatus.Accepted,
4582
- transactionId: getUUID(),
4583
- ...defaults
4231
+ ...defaults,
4232
+ status: ActionStatus.Accepted
4584
4233
  };
4585
4234
  switch (action) {
4586
4235
  case ActionType.READ:
@@ -4638,8 +4287,7 @@ function generateEventDocument({
4638
4287
  id: getUUID(),
4639
4288
  // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
4640
4289
  // @TODO: This should be fixed in the future.
4641
- updatedAt: new Date(Date.now() - 1e3).toISOString(),
4642
- dateOfEvent: configuration.dateOfEvent
4290
+ updatedAt: new Date(Date.now() - 1e3).toISOString()
4643
4291
  };
4644
4292
  }
4645
4293
  function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
@@ -4661,76 +4309,23 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, de
4661
4309
  eventId
4662
4310
  };
4663
4311
  }
4664
- function getEventStatus() {
4665
- const statuses = [
4666
- EventStatus.CREATED,
4667
- EventStatus.REGISTERED,
4668
- EventStatus.DECLARED
4669
- ];
4670
- const randomIndex = Math.floor(Math.random() * 3);
4671
- return statuses[randomIndex];
4672
- }
4673
- function getTrackingId() {
4674
- const uuid = getUUID().replace(/-/g, "");
4675
- const trackingId = uuid.slice(0, 6).toUpperCase();
4676
- return trackingId;
4677
- }
4678
- function getRandomApplicant() {
4679
- const firstNames = [
4680
- "Danny",
4681
- "John",
4682
- "Jane",
4683
- "Emily",
4684
- "Michael",
4685
- "Sarah",
4686
- "Chris",
4687
- "Jessica"
4688
- ];
4689
- const surnames = [
4690
- "Doe",
4691
- "Smith",
4692
- "Johnson",
4693
- "Brown",
4694
- "Williams",
4695
- "Jones",
4696
- "Garcia",
4697
- "Miller"
4698
- ];
4699
- function getRandomDate(start, end) {
4700
- const randomDate = new Date(
4701
- start.getTime() + Math.random() * (end.getTime() - start.getTime())
4702
- );
4703
- return randomDate.toISOString().split("T")[0];
4704
- }
4705
- const randomFirstName = firstNames[Math.floor(Math.random() * firstNames.length)];
4706
- const randomSurname = surnames[Math.floor(Math.random() * surnames.length)];
4707
- const randomDob = getRandomDate(
4708
- /* @__PURE__ */ new Date("1990-01-01"),
4709
- /* @__PURE__ */ new Date("2010-12-31")
4710
- );
4711
- return {
4712
- "recommender.none": true,
4713
- "applicant.firstname": randomFirstName,
4714
- "applicant.surname": randomSurname,
4715
- "applicant.dob": randomDob
4716
- };
4717
- }
4718
4312
  var eventQueryDataGenerator = (overrides = {}) => ({
4719
4313
  id: overrides.id ?? getUUID(),
4720
- type: overrides.type ?? "TENNIS_CLUB_MEMBERSHIP",
4721
- status: overrides.status ?? getEventStatus(),
4314
+ type: overrides.type ?? "tennis-club-membership",
4315
+ status: overrides.status ?? "REGISTERED",
4722
4316
  createdAt: overrides.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
4723
4317
  createdBy: overrides.createdBy ?? getUUID(),
4724
4318
  createdAtLocation: overrides.createdAtLocation ?? getUUID(),
4725
- updatedAtLocation: overrides.updatedAtLocation ?? getUUID(),
4726
- updatedAt: overrides.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
4319
+ modifiedAt: overrides.modifiedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
4727
4320
  assignedTo: overrides.assignedTo ?? null,
4728
4321
  updatedBy: overrides.updatedBy ?? getUUID(),
4729
- updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
4730
- flags: [],
4731
- legalStatuses: overrides.legalStatuses ?? {},
4732
- declaration: overrides.declaration ?? getRandomApplicant(),
4733
- trackingId: overrides.trackingId ?? getTrackingId()
4322
+ declaration: overrides.declaration ?? {
4323
+ "recommender.none": true,
4324
+ "applicant.firstname": "Danny",
4325
+ "applicant.surname": "Doe",
4326
+ "applicant.dob": "1999-11-11"
4327
+ },
4328
+ trackingId: overrides.trackingId ?? "M3F8YQ"
4734
4329
  });
4735
4330
  var generateTranslationConfig = (message) => ({
4736
4331
  defaultMessage: message,
@@ -4769,293 +4364,3 @@ function isFieldConfigDefaultValue(value) {
4769
4364
  }
4770
4365
  return false;
4771
4366
  }
4772
-
4773
- // ../commons/src/events/scopes.ts
4774
- var import_lodash3 = require("lodash");
4775
-
4776
- // ../commons/src/scopes.ts
4777
- var import_zod25 = require("zod");
4778
- var SCOPES = {
4779
- // TODO v1.8 legacy scopes
4780
- NATLSYSADMIN: "natlsysadmin",
4781
- BYPASSRATELIMIT: "bypassratelimit",
4782
- DECLARE: "declare",
4783
- REGISTER: "register",
4784
- VALIDATE: "validate",
4785
- DEMO: "demo",
4786
- CERTIFY: "certify",
4787
- PERFORMANCE: "performance",
4788
- SYSADMIN: "sysadmin",
4789
- TEAMS: "teams",
4790
- CONFIG: "config",
4791
- // systems / integrations
4792
- WEBHOOK: "webhook",
4793
- NATIONALID: "nationalId",
4794
- NOTIFICATION_API: "notification-api",
4795
- RECORDSEARCH: "recordsearch",
4796
- /**
4797
- * @TODO This is a temporary scope to be used for V2 Events custom events declaration
4798
- */
4799
- RECORD_DECLARE: "record.declare-birth",
4800
- // declare
4801
- RECORD_DECLARE_BIRTH: "record.declare-birth",
4802
- RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
4803
- RECORD_DECLARE_DEATH: "record.declare-death",
4804
- RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction",
4805
- RECORD_DECLARE_MARRIAGE: "record.declare-marriage",
4806
- RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction",
4807
- RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete",
4808
- RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review",
4809
- RECORD_UNASSIGN_OTHERS: "record.unassign-others",
4810
- // validate
4811
- RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval",
4812
- RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates",
4813
- RECORD_DECLARATION_EDIT: "record.declaration-edit",
4814
- RECORD_REVIEW_DUPLICATES: "record.review-duplicates",
4815
- RECORD_DECLARATION_ARCHIVE: "record.declaration-archive",
4816
- RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate",
4817
- // register
4818
- RECORD_REGISTER: "record.register",
4819
- // certify
4820
- RECORD_EXPORT_RECORDS: "record.export-records",
4821
- RECORD_DECLARATION_PRINT: "record.declaration-print",
4822
- RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS: "record.declaration-print-supporting-documents",
4823
- RECORD_REGISTRATION_PRINT: "record.registration-print",
4824
- // v1.8
4825
- /**
4826
- * This scope is used to **print and **issue certified copies of a record
4827
- * after it has been registered. Previously Registrars had this permission.
4828
- */
4829
- RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies",
4830
- RECORD_PRINT_CERTIFIED_COPIES: "record.registration-print-certified-copies",
4831
- // v1.8
4832
- RECORD_BULK_PRINT_CERTIFIED_COPIES: "record.registration-bulk-print-certified-copies",
4833
- // v1.8
4834
- RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES: "record.registration-verify-certified-copies",
4835
- // v1.8
4836
- // correct
4837
- RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction",
4838
- RECORD_REGISTRATION_CORRECT: "record.registration-correct",
4839
- RECORD_REGISTRATION_REQUEST_REVOCATION: "record.registration-request-revocation",
4840
- // v1.8
4841
- RECORD_REGISTRATION_REVOKE: "record.registration-revoke",
4842
- // v1.8
4843
- RECORD_REGISTRATION_REQUEST_REINSTATEMENT: "record.registration-request-reinstatement",
4844
- // v1.8
4845
- RECORD_REGISTRATION_REINSTATE: "record.registration-reinstate",
4846
- // v1.8
4847
- RECORD_CONFIRM_REGISTRATION: "record.confirm-registration",
4848
- RECORD_REJECT_REGISTRATION: "record.reject-registration",
4849
- // search
4850
- SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction",
4851
- SEARCH_BIRTH: "search.birth",
4852
- SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction",
4853
- SEARCH_DEATH: "search.death",
4854
- SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction",
4855
- SEARCH_MARRIAGE: "search.marriage",
4856
- // audit v1.8
4857
- RECORD_READ: "record.read",
4858
- RECORD_READ_AUDIT: "record.read-audit",
4859
- RECORD_READ_COMMENTS: "record.read-comments",
4860
- RECORD_CREATE_COMMENTS: "record.create-comments",
4861
- // profile
4862
- PROFILE_UPDATE: "profile.update",
4863
- //v1.8
4864
- PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
4865
- // performance
4866
- PERFORMANCE_READ: "performance.read",
4867
- PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
4868
- PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
4869
- // organisation
4870
- ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all",
4871
- ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
4872
- ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
4873
- // user
4874
- USER_READ: "user.read:all",
4875
- USER_READ_MY_OFFICE: "user.read:my-office",
4876
- USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
4877
- USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
4878
- //v1.8
4879
- USER_CREATE: "user.create:all",
4880
- USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
4881
- USER_UPDATE: "user.update:all",
4882
- USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction",
4883
- // config
4884
- CONFIG_UPDATE_ALL: "config.update:all",
4885
- // data seeding
4886
- USER_DATA_SEEDING: "user.data-seeding"
4887
- };
4888
- var LiteralScopes = import_zod25.z.union([
4889
- import_zod25.z.literal(SCOPES.NATLSYSADMIN),
4890
- import_zod25.z.literal(SCOPES.BYPASSRATELIMIT),
4891
- import_zod25.z.literal(SCOPES.DECLARE),
4892
- import_zod25.z.literal(SCOPES.REGISTER),
4893
- import_zod25.z.literal(SCOPES.VALIDATE),
4894
- import_zod25.z.literal(SCOPES.DEMO),
4895
- import_zod25.z.literal(SCOPES.CERTIFY),
4896
- import_zod25.z.literal(SCOPES.PERFORMANCE),
4897
- import_zod25.z.literal(SCOPES.SYSADMIN),
4898
- import_zod25.z.literal(SCOPES.TEAMS),
4899
- import_zod25.z.literal(SCOPES.CONFIG),
4900
- import_zod25.z.literal(SCOPES.WEBHOOK),
4901
- import_zod25.z.literal(SCOPES.NATIONALID),
4902
- import_zod25.z.literal(SCOPES.NOTIFICATION_API),
4903
- import_zod25.z.literal(SCOPES.RECORDSEARCH),
4904
- import_zod25.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
4905
- import_zod25.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
4906
- import_zod25.z.literal(SCOPES.RECORD_DECLARE_DEATH),
4907
- import_zod25.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
4908
- import_zod25.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
4909
- import_zod25.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
4910
- import_zod25.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
4911
- import_zod25.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW),
4912
- import_zod25.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS),
4913
- import_zod25.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
4914
- import_zod25.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
4915
- import_zod25.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
4916
- import_zod25.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
4917
- import_zod25.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
4918
- import_zod25.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE),
4919
- import_zod25.z.literal(SCOPES.RECORD_REGISTER),
4920
- import_zod25.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
4921
- import_zod25.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
4922
- import_zod25.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
4923
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
4924
- import_zod25.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
4925
- import_zod25.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
4926
- import_zod25.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
4927
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES),
4928
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
4929
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
4930
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
4931
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
4932
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
4933
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
4934
- import_zod25.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
4935
- import_zod25.z.literal(SCOPES.RECORD_REJECT_REGISTRATION),
4936
- import_zod25.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
4937
- import_zod25.z.literal(SCOPES.SEARCH_BIRTH),
4938
- import_zod25.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
4939
- import_zod25.z.literal(SCOPES.SEARCH_DEATH),
4940
- import_zod25.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
4941
- import_zod25.z.literal(SCOPES.SEARCH_MARRIAGE),
4942
- import_zod25.z.literal(SCOPES.RECORD_READ),
4943
- import_zod25.z.literal(SCOPES.RECORD_READ_AUDIT),
4944
- import_zod25.z.literal(SCOPES.RECORD_READ_COMMENTS),
4945
- import_zod25.z.literal(SCOPES.RECORD_CREATE_COMMENTS),
4946
- import_zod25.z.literal(SCOPES.PROFILE_UPDATE),
4947
- import_zod25.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE),
4948
- import_zod25.z.literal(SCOPES.PERFORMANCE_READ),
4949
- import_zod25.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
4950
- import_zod25.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS),
4951
- import_zod25.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
4952
- import_zod25.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
4953
- import_zod25.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION),
4954
- import_zod25.z.literal(SCOPES.USER_READ),
4955
- import_zod25.z.literal(SCOPES.USER_READ_MY_OFFICE),
4956
- import_zod25.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
4957
- import_zod25.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
4958
- import_zod25.z.literal(SCOPES.USER_CREATE),
4959
- import_zod25.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
4960
- import_zod25.z.literal(SCOPES.USER_UPDATE),
4961
- import_zod25.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION),
4962
- import_zod25.z.literal(SCOPES.CONFIG_UPDATE_ALL),
4963
- import_zod25.z.literal(SCOPES.USER_DATA_SEEDING)
4964
- ]);
4965
- var rawConfigurableScopeRegex = /^([a-zA-Z]+\.[a-zA-Z]+)\[((?:\w+=\w+(?:\|\w+)*)(:?,\w+=\w+(?:\|\w+)*)*)\]$/;
4966
- var rawConfigurableScope = import_zod25.z.string().regex(rawConfigurableScopeRegex);
4967
- var CreateUserScope = import_zod25.z.object({
4968
- type: import_zod25.z.literal("user.create"),
4969
- options: import_zod25.z.object({
4970
- role: import_zod25.z.array(import_zod25.z.string())
4971
- })
4972
- });
4973
- var EditUserScope = import_zod25.z.object({
4974
- type: import_zod25.z.literal("user.edit"),
4975
- options: import_zod25.z.object({
4976
- role: import_zod25.z.array(import_zod25.z.string())
4977
- })
4978
- });
4979
- var ConfigurableScopes = import_zod25.z.discriminatedUnion("type", [
4980
- CreateUserScope,
4981
- EditUserScope
4982
- ]);
4983
- var scopes = Object.values(SCOPES);
4984
-
4985
- // ../commons/src/events/scopes.ts
4986
- function hasAnyOfScopes(a, b) {
4987
- return (0, import_lodash3.intersection)(a, b).length > 0;
4988
- }
4989
- var CONFIG_GET_ALLOWED_SCOPES = [
4990
- SCOPES.RECORD_DECLARE,
4991
- SCOPES.RECORD_READ,
4992
- SCOPES.RECORD_SUBMIT_INCOMPLETE,
4993
- SCOPES.RECORD_SUBMIT_FOR_REVIEW,
4994
- SCOPES.RECORD_REGISTER,
4995
- SCOPES.RECORD_EXPORT_RECORDS,
4996
- SCOPES.CONFIG,
4997
- SCOPES.CONFIG_UPDATE_ALL
4998
- ];
4999
- var CONFIG_SEARCH_ALLOWED_SCOPES = [
5000
- SCOPES.SEARCH_BIRTH,
5001
- SCOPES.SEARCH_DEATH,
5002
- SCOPES.SEARCH_MARRIAGE,
5003
- SCOPES.SEARCH_BIRTH_MY_JURISDICTION,
5004
- SCOPES.SEARCH_DEATH_MY_JURISDICTION,
5005
- SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION
5006
- ];
5007
- var ACTION_ALLOWED_SCOPES = {
5008
- [ActionType.READ]: [
5009
- SCOPES.RECORD_DECLARE,
5010
- SCOPES.RECORD_READ,
5011
- SCOPES.RECORD_SUBMIT_INCOMPLETE,
5012
- SCOPES.RECORD_SUBMIT_FOR_REVIEW,
5013
- SCOPES.RECORD_REGISTER,
5014
- SCOPES.RECORD_EXPORT_RECORDS
5015
- ],
5016
- [ActionType.CREATE]: [
5017
- SCOPES.RECORD_DECLARE,
5018
- SCOPES.RECORD_SUBMIT_INCOMPLETE,
5019
- SCOPES.RECORD_SUBMIT_FOR_REVIEW
5020
- ],
5021
- [ActionType.NOTIFY]: [SCOPES.RECORD_SUBMIT_INCOMPLETE],
5022
- [ActionType.DECLARE]: [
5023
- SCOPES.RECORD_DECLARE,
5024
- SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
5025
- SCOPES.RECORD_REGISTER
5026
- ],
5027
- [ActionType.DELETE]: [SCOPES.RECORD_DECLARE],
5028
- [ActionType.VALIDATE]: [
5029
- SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
5030
- SCOPES.RECORD_REGISTER
5031
- ],
5032
- [ActionType.REGISTER]: [SCOPES.RECORD_REGISTER],
5033
- [ActionType.PRINT_CERTIFICATE]: [SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES],
5034
- [ActionType.REQUEST_CORRECTION]: [
5035
- SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION
5036
- ],
5037
- [ActionType.REJECT_CORRECTION]: [SCOPES.RECORD_REGISTRATION_CORRECT],
5038
- [ActionType.APPROVE_CORRECTION]: [SCOPES.RECORD_REGISTRATION_CORRECT],
5039
- [ActionType.MARKED_AS_DUPLICATE]: [SCOPES.RECORD_DECLARATION_ARCHIVE],
5040
- [ActionType.ARCHIVE]: [SCOPES.RECORD_DECLARATION_ARCHIVE],
5041
- [ActionType.REJECT]: [SCOPES.RECORD_SUBMIT_FOR_UPDATES],
5042
- [ActionType.ASSIGN]: null,
5043
- [ActionType.UNASSIGN]: null,
5044
- [ActionType.DETECT_DUPLICATE]: []
5045
- };
5046
- function filterUnallowedActions(actions, userScopes) {
5047
- const allowedActions = actions.filter((action) => {
5048
- const requiredScopes = ACTION_ALLOWED_SCOPES[action];
5049
- if (requiredScopes === null) {
5050
- return true;
5051
- }
5052
- return hasAnyOfScopes(userScopes, requiredScopes);
5053
- });
5054
- const hasOtherAllowedActions = allowedActions.some(
5055
- (action) => action !== ActionType.READ && action !== ActionType.ASSIGN && action !== ActionType.UNASSIGN
5056
- );
5057
- if (hasOtherAllowedActions) {
5058
- return allowedActions;
5059
- }
5060
- return [ActionType.READ];
5061
- }