@opencrvs/toolkit 2.1.0-rc.b0003b1 → 2.1.0-rc.b263ac1

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 (95) hide show
  1. package/README.md +1 -0
  2. package/build.sh +2 -2
  3. package/dist/application-config/index.js +244 -197
  4. package/dist/cli.js +347 -5220
  5. package/dist/commons/api/router.d.ts +3730 -2896
  6. package/dist/commons/application-config/index.d.ts +6 -6
  7. package/dist/commons/conditionals/conditionals.d.ts +32 -323
  8. package/dist/commons/conditionals/validate.d.ts +11 -4
  9. package/dist/commons/events/ActionConfig.d.ts +279 -70
  10. package/dist/commons/events/ActionDocument.d.ts +153 -115
  11. package/dist/commons/events/ActionInput.d.ts +26 -6
  12. package/dist/commons/events/ActionStatus.d.ts +14 -0
  13. package/dist/commons/events/ActionType.d.ts +63 -58
  14. package/dist/commons/events/AdvancedSearchConfig.d.ts +525 -501
  15. package/dist/commons/events/AuditLog.d.ts +189 -40
  16. package/dist/commons/events/CompositeFieldValue.d.ts +4 -4
  17. package/dist/commons/events/Conditional.d.ts +3 -3
  18. package/dist/commons/events/CountryConfigQueryInput.d.ts +590 -590
  19. package/dist/commons/events/Draft.d.ts +37 -35
  20. package/dist/commons/events/DynamicFieldValue.d.ts +9 -9
  21. package/dist/commons/events/EventConfig.d.ts +8 -5
  22. package/dist/commons/events/EventDocument.d.ts +66 -44
  23. package/dist/commons/events/EventIndex.d.ts +49 -72
  24. package/dist/commons/events/EventMetadata.d.ts +40 -40
  25. package/dist/commons/events/FieldConfig.d.ts +411 -384
  26. package/dist/commons/events/FieldType.d.ts +51 -51
  27. package/dist/commons/events/FieldTypeMapping.d.ts +90 -90
  28. package/dist/commons/events/FieldValue.d.ts +14 -14
  29. package/dist/commons/events/Flag.d.ts +57 -15
  30. package/dist/commons/events/PlainDate.d.ts +8 -0
  31. package/dist/commons/events/SummaryConfig.d.ts +249 -0
  32. package/dist/commons/events/TemplateConfig.d.ts +1 -1
  33. package/dist/commons/events/WorkqueueColumnConfig.d.ts +40 -40
  34. package/dist/commons/events/WorkqueueConfig.d.ts +822 -816
  35. package/dist/commons/events/deduplication.d.ts +1 -1
  36. package/dist/commons/events/event.d.ts +14 -2
  37. package/dist/commons/events/field.d.ts +69 -198
  38. package/dist/commons/events/index.d.ts +1 -0
  39. package/dist/commons/events/locationPayloads.d.ts +95 -0
  40. package/dist/commons/events/locations.d.ts +192 -12
  41. package/dist/commons/events/mocks.test.utils.d.ts +48 -4
  42. package/dist/commons/events/scopes.d.ts +5 -4
  43. package/dist/commons/events/state/index.d.ts +17 -17
  44. package/dist/commons/events/state/utils.d.ts +7 -7
  45. package/dist/commons/events/test.utils.d.ts +44 -39
  46. package/dist/commons/events/utils.d.ts +127 -105
  47. package/dist/commons/notification/UserNotifications.d.ts +10 -10
  48. package/dist/conditionals/index.js +309 -57
  49. package/dist/environment/derived-variables.d.ts +119 -131
  50. package/dist/environment/derived-variables.d.ts.map +1 -1
  51. package/dist/environment/derived-variables.js +0 -14
  52. package/dist/environment/index.d.ts +1 -0
  53. package/dist/environment/index.d.ts.map +1 -1
  54. package/dist/environment/index.js +10 -0
  55. package/dist/environment/logger.d.ts +3 -3
  56. package/dist/environment/manage-users.js +17 -7
  57. package/dist/environment/paths.d.ts +7 -0
  58. package/dist/environment/paths.d.ts.map +1 -0
  59. package/dist/environment/paths.js +72 -0
  60. package/dist/environment/questions.d.ts +75 -74
  61. package/dist/environment/questions.d.ts.map +1 -1
  62. package/dist/environment/setup-environment.js +10 -29
  63. package/dist/environment/swarm-to-k8s.js +17 -7
  64. package/dist/environment/templates.d.ts.map +1 -1
  65. package/dist/environment/templates.js +2 -1
  66. package/dist/environment/update-workflows.d.ts.map +1 -1
  67. package/dist/environment/update-workflows.js +34 -12
  68. package/dist/environment/upgrade.d.ts +2 -0
  69. package/dist/environment/upgrade.d.ts.map +1 -0
  70. package/dist/environment/upgrade.js +82 -0
  71. package/dist/environment/users.js +28 -20
  72. package/dist/environment/utils.d.ts +1 -1
  73. package/dist/environment/utils.js +17 -7
  74. package/dist/events/deduplication.d.ts +1 -1
  75. package/dist/events/index.js +3650 -3145
  76. package/dist/migrations/v2.0/convert-config-files-to-ts.js +17 -7
  77. package/dist/migrations/v2.0/index.js +88 -5144
  78. package/dist/migrations/v2.0/migrate-application-config-url.js +4 -3
  79. package/dist/migrations/v2.0/remove-hearth-migrations.js +17 -7
  80. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +3 -0
  81. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +1 -0
  82. package/dist/migrations/v2.1/add-explicit-correction-flags.js +234 -0
  83. package/dist/migrations/v2.1/index.d.ts +6 -0
  84. package/dist/migrations/v2.1/index.d.ts.map +1 -0
  85. package/dist/migrations/v2.1/index.js +218 -0
  86. package/dist/notification/index.js +2019 -1072
  87. package/dist/scopes/index.d.ts +437 -163
  88. package/dist/scopes/index.js +310 -57
  89. package/dist/templates/charts-values/dependencies/values.yaml +0 -3
  90. package/dist/templates/charts-values/opencrvs-services/values.yaml +4 -7
  91. package/dist/templates/charts-values/opentelemetry/values.yaml +73 -0
  92. package/opencrvs-toolkit-2.1.0-rc.b263ac1.tgz +0 -0
  93. package/package.json +7 -7
  94. package/tsconfig.tsbuildinfo +1 -1
  95. package/opencrvs-toolkit-2.1.0-rc.b0003b1.tgz +0 -0
@@ -500,7 +500,7 @@ var import_v4 = require("zod/v4");
500
500
  var z15 = __toESM(require("zod/v4"));
501
501
 
502
502
  // ../commons/src/events/ActionDocument.ts
503
- var z13 = __toESM(require("zod/v4"));
503
+ var z14 = __toESM(require("zod/v4"));
504
504
 
505
505
  // ../commons/src/events/ActionType.ts
506
506
  var z10 = __toESM(require("zod/v4"));
@@ -520,6 +520,7 @@ var ActionType = {
520
520
  MARK_AS_DUPLICATE: "MARK_AS_DUPLICATE",
521
521
  MARK_AS_NOT_DUPLICATE: "MARK_AS_NOT_DUPLICATE",
522
522
  ARCHIVE: "ARCHIVE",
523
+ UNARCHIVE: "UNARCHIVE",
523
524
  // Record actions
524
525
  PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
525
526
  REQUEST_CORRECTION: "REQUEST_CORRECTION",
@@ -539,6 +540,7 @@ var ConfirmableActions = [
539
540
  ActionType.REGISTER,
540
541
  ActionType.REJECT,
541
542
  ActionType.ARCHIVE,
543
+ ActionType.UNARCHIVE,
542
544
  ActionType.PRINT_CERTIFICATE,
543
545
  ActionType.REQUEST_CORRECTION,
544
546
  ActionType.APPROVE_CORRECTION,
@@ -557,6 +559,7 @@ var ActionTypes = z10.enum([
557
559
  "MARK_AS_DUPLICATE",
558
560
  "MARK_AS_NOT_DUPLICATE",
559
561
  "ARCHIVE",
562
+ "UNARCHIVE",
560
563
  "PRINT_CERTIFICATE",
561
564
  "REQUEST_CORRECTION",
562
565
  "REJECT_CORRECTION",
@@ -597,6 +600,7 @@ var WorkqueueActionType = ActionTypes.extract([
597
600
  ActionType.REJECT,
598
601
  ActionType.MARK_AS_DUPLICATE,
599
602
  ActionType.ARCHIVE,
603
+ ActionType.UNARCHIVE,
600
604
  ActionType.PRINT_CERTIFICATE,
601
605
  ActionType.REQUEST_CORRECTION
602
606
  ]);
@@ -608,16 +612,88 @@ var META_ACTIONS = [
608
612
 
609
613
  // ../commons/src/authentication.ts
610
614
  var import_jwt_decode = __toESM(require("jwt-decode"));
611
- var z12 = __toESM(require("zod/v4"));
615
+ var z13 = __toESM(require("zod/v4"));
612
616
 
613
617
  // ../commons/src/scopes.ts
614
- var z11 = __toESM(require("zod/v4"));
618
+ var z12 = __toESM(require("zod/v4"));
615
619
  var qs = __toESM(require("qs"));
616
- var JurisdictionFilter = z11.enum(["administrativeArea", "location", "all"]).describe(
620
+
621
+ // ../commons/src/events/ActionStatus.ts
622
+ var ActionStatus = {
623
+ Requested: "Requested",
624
+ Accepted: "Accepted",
625
+ Rejected: "Rejected"
626
+ };
627
+
628
+ // ../commons/src/events/Flag.ts
629
+ var z11 = __toESM(require("zod/v4"));
630
+ var InherentFlags = {
631
+ INCOMPLETE: "incomplete",
632
+ REJECTED: "rejected",
633
+ CORRECTION_REQUESTED: "correction-requested",
634
+ POTENTIAL_DUPLICATE: "potential-duplicate",
635
+ /**
636
+ * This flag is set by the Edit-action and removed after the declaration or registration.
637
+ * A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
638
+ *
639
+ * We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
640
+ */
641
+ EDIT_IN_PROGRESS: "edit-in-progress"
642
+ };
643
+ var actionFlagPattern;
644
+ function getActionFlagPattern() {
645
+ actionFlagPattern ??= new RegExp(
646
+ `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
647
+ ActionStatus
648
+ ).join("|").toLowerCase()})$`
649
+ );
650
+ return actionFlagPattern;
651
+ }
652
+ var ActionFlag = z11.string().refine((value) => getActionFlagPattern().test(value), {
653
+ message: "Flag must be in the format ActionType:ActionStatus (lowerCase)"
654
+ });
655
+ var CustomFlag = z11.string().refine((val) => !Object.values(InherentFlags).includes(val), {
656
+ message: `Custom flag cannot be one of the inherent flags: ${Object.values(
657
+ InherentFlags
658
+ ).join(", ")}`
659
+ }).refine((val) => !ActionFlag.safeParse(val).success, {
660
+ message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
661
+ }).describe("Custom flag identifier defined by the country config.");
662
+ var Flag = ActionFlag.or(z11.enum(InherentFlags)).or(CustomFlag);
663
+ var ContainsFlags = z11.object({
664
+ anyOf: z11.array(Flag).optional(),
665
+ noneOf: z11.array(Flag).optional(),
666
+ allOf: z11.array(Flag).optional()
667
+ }).meta({
668
+ id: "ContainsFlags"
669
+ });
670
+ var FlagConfig = z11.object({
671
+ id: CustomFlag,
672
+ requiresAction: z11.boolean().describe(
673
+ "Indicates if this flag expects an action to be performed to be cleared."
674
+ ),
675
+ label: TranslationConfig.describe("Human readable label of the flag.")
676
+ }).meta({
677
+ id: "FlagConfig",
678
+ description: "Configuration for a custom flag that can be added to or removed from records by event actions."
679
+ });
680
+ var ActionFlagConfig = z11.object({
681
+ id: Flag,
682
+ operation: z11.enum(["add", "remove"]).describe("Operation to perform on the flag."),
683
+ conditional: Conditional.optional().describe(
684
+ "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
685
+ )
686
+ }).meta({
687
+ id: "ActionFlagConfig",
688
+ description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
689
+ });
690
+
691
+ // ../commons/src/scopes.ts
692
+ var JurisdictionFilter = z12.enum(["administrativeArea", "location", "all"]).describe(
617
693
  "Filters based on user jurisdiction relative to their office location in hierarchy."
618
694
  );
619
- var UserFilter = z11.enum(["user"]).describe("Filters based on the user. Limits to self.");
620
- var RecordScopeTypeV2 = z11.enum([
695
+ var UserFilter = z12.enum(["user"]).describe("Filters based on the user. Limits to self.");
696
+ var RecordScopeTypeV2 = z12.enum([
621
697
  "record.search",
622
698
  "record.create",
623
699
  "record.read",
@@ -626,6 +702,7 @@ var RecordScopeTypeV2 = z11.enum([
626
702
  "record.edit",
627
703
  "record.reject",
628
704
  "record.archive",
705
+ "record.unarchive",
629
706
  "record.review-duplicates",
630
707
  "record.register",
631
708
  "record.print-certified-copies",
@@ -634,7 +711,7 @@ var RecordScopeTypeV2 = z11.enum([
634
711
  "record.unassign-others",
635
712
  "record.custom-action"
636
713
  ]);
637
- var PlainScopeType = z11.enum([
714
+ var PlainScopeType = z12.enum([
638
715
  // Misc. system scopes
639
716
  "bypassratelimit",
640
717
  "record.reindex",
@@ -642,6 +719,7 @@ var PlainScopeType = z11.enum([
642
719
  "integration.create",
643
720
  "record.import",
644
721
  "config.update-all",
722
+ "location.edit",
645
723
  "attachment.upload",
646
724
  "profile.electronic-signature",
647
725
  "user.read-only-my-audit",
@@ -653,17 +731,18 @@ var PlainScopeType = z11.enum([
653
731
  "record.confirm-registration",
654
732
  "record.reject-registration"
655
733
  ]);
656
- var scopeByEvent = z11.preprocess(
734
+ var scopeByEvent = z12.preprocess(
657
735
  (val) => val === void 0 ? void 0 : [val].flat(),
658
- z11.array(z11.string()).optional()
736
+ z12.array(z12.string()).optional()
659
737
  ).describe("Event type, e.g. birth, death");
660
- var userRole = z11.preprocess(
738
+ var userRole = z12.preprocess(
661
739
  (val) => val === void 0 ? void 0 : [val].flat(),
662
- z11.array(z11.string()).optional()
740
+ z12.array(z12.string()).optional()
663
741
  ).describe("User role, e.g. admin, field agent");
664
- var scopeOptionsPlaceEvent = z11.object({
742
+ var scopeOptionsPlaceEvent = z12.object({
665
743
  event: scopeByEvent,
666
- placeOfEvent: JurisdictionFilter.optional()
744
+ placeOfEvent: JurisdictionFilter.optional(),
745
+ createdBy: UserFilter.optional()
667
746
  }).describe("Options applicable to all record scopes.");
668
747
  var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
669
748
  notifiedIn: JurisdictionFilter.optional(),
@@ -673,52 +752,55 @@ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
673
752
  }).describe("Options applicable to actions that may take place after DECLARE");
674
753
  var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
675
754
  registeredIn: JurisdictionFilter.optional(),
676
- registeredBy: UserFilter.optional()
755
+ registeredBy: UserFilter.optional(),
756
+ flags: ContainsFlags.optional()
677
757
  }).describe(
678
758
  "Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
679
759
  );
680
760
  var CustomActionScopeOptions = AllRecordScopeOptions.extend({
681
- customActionTypes: z11.preprocess(
761
+ customActionTypes: z12.preprocess(
682
762
  (val) => val === void 0 ? void 0 : [val].flat(),
683
- z11.array(z11.string()).optional()
763
+ z12.array(z12.string()).optional()
684
764
  ).describe("Allowed custom action types")
685
765
  });
686
- var AccessLevelOptions = z11.object({
766
+ var AccessLevelOptions = z12.object({
687
767
  accessLevel: JurisdictionFilter.optional()
688
768
  });
689
769
  var AllUserScopeOptions = AccessLevelOptions.extend({
690
770
  role: userRole.optional()
691
771
  });
692
- var WorkqueueOrDashboardOptions = z11.object({
693
- ids: z11.preprocess(
772
+ var WorkqueueOrDashboardOptions = z12.object({
773
+ ids: z12.preprocess(
694
774
  (val) => val === void 0 ? void 0 : [val].flat(),
695
- z11.array(z11.string())
775
+ z12.array(z12.string())
696
776
  ).describe("Must contain a list of workqueue or dashboard ids.")
697
777
  });
698
- var AllScopeOptions = z11.object({
778
+ var AllScopeOptions = z12.object({
699
779
  ...AllRecordScopeOptions.shape,
700
780
  ...AccessLevelOptions.shape,
701
781
  ...AllUserScopeOptions.shape,
702
782
  ...WorkqueueOrDashboardOptions.shape
703
783
  });
704
784
  var ScopeOptionKey = AllScopeOptions.keyof();
705
- var ResolvedScopeOptionsPlaceEvent = z11.object({
785
+ var ResolvedScopeOptionsPlaceEvent = z12.object({
706
786
  event: scopeByEvent,
707
- placeOfEvent: UUID.nullish()
787
+ placeOfEvent: UUID.nullish(),
788
+ createdBy: z12.string().optional()
708
789
  }).describe(
709
790
  "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
710
791
  );
711
792
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
712
793
  notifiedIn: UUID.nullish(),
713
- notifiedBy: z11.string().optional(),
794
+ notifiedBy: z12.string().optional(),
714
795
  declaredIn: UUID.nullish(),
715
- declaredBy: z11.string().optional()
796
+ declaredBy: z12.string().optional()
716
797
  }).describe(
717
798
  "Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
718
799
  );
719
800
  var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
720
801
  registeredIn: UUID.nullish(),
721
- registeredBy: z11.string().optional()
802
+ registeredBy: z12.string().optional(),
803
+ flags: ContainsFlags.optional()
722
804
  }).describe(
723
805
  "Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
724
806
  );
@@ -731,6 +813,7 @@ var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
731
813
  "record.edit",
732
814
  "record.reject",
733
815
  "record.archive",
816
+ "record.unarchive",
734
817
  "record.review-duplicates",
735
818
  "record.register"
736
819
  ]);
@@ -742,38 +825,38 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
742
825
  "record.unassign-others"
743
826
  ]);
744
827
  var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
745
- templates: z11.preprocess(
828
+ templates: z12.preprocess(
746
829
  (val) => val === void 0 ? void 0 : [val].flat(),
747
- z11.array(z11.string()).optional()
830
+ z12.array(z12.string()).optional()
748
831
  ).describe(
749
832
  "Template IDs for certified copies. Controls which certificate templates are returned to the client via the config service. Certificate printing is a client-side operation \u2014 this option is not validated when the printCertificate action is submitted."
750
833
  )
751
834
  });
752
- var RecordScopeV2 = z11.discriminatedUnion("type", [
753
- z11.object({
835
+ var RecordScopeV2 = z12.discriminatedUnion("type", [
836
+ z12.object({
754
837
  type: ScopesWithPlaceEventOptions,
755
838
  options: scopeOptionsPlaceEvent.optional()
756
839
  }),
757
- z11.object({
840
+ z12.object({
758
841
  type: ScopesWithDeclaredOptions,
759
842
  options: scopeOptionsDeclaredOrNotified.optional()
760
843
  }),
761
- z11.object({
844
+ z12.object({
762
845
  type: ScopesWithFullOptions,
763
846
  options: AllRecordScopeOptions.optional()
764
847
  }),
765
- z11.object({
766
- type: z11.literal("record.custom-action"),
848
+ z12.object({
849
+ type: z12.literal("record.custom-action"),
767
850
  options: CustomActionScopeOptions.optional()
768
851
  }),
769
- z11.object({
770
- type: z11.literal("record.print-certified-copies"),
852
+ z12.object({
853
+ type: z12.literal("record.print-certified-copies"),
771
854
  options: ScopeOptionsPrintCertifiedCopies.optional()
772
855
  })
773
856
  ]).describe(
774
857
  "Scopes used to check user's permission to perform actions on a record."
775
858
  );
776
- var SystemScopeType = z11.enum([
859
+ var SystemScopeType = z12.enum([
777
860
  "organisation.read-locations",
778
861
  "user.read",
779
862
  "user.create",
@@ -787,61 +870,61 @@ var UserScopeType = SystemScopeType.extract([
787
870
  "user.search"
788
871
  ]);
789
872
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
790
- var UserScopeV2 = z11.discriminatedUnion("type", [
791
- z11.object({
873
+ var UserScopeV2 = z12.discriminatedUnion("type", [
874
+ z12.object({
792
875
  type: ScopesWithRoleOption,
793
876
  options: AllUserScopeOptions.optional()
794
877
  }),
795
- z11.object({
878
+ z12.object({
796
879
  type: UserScopeType.extract(["user.read", "user.search"]),
797
880
  options: AccessLevelOptions.optional()
798
881
  })
799
882
  ]);
800
- var ResolvedRecordScopeV2 = z11.discriminatedUnion("type", [
801
- z11.object({
883
+ var ResolvedRecordScopeV2 = z12.discriminatedUnion("type", [
884
+ z12.object({
802
885
  type: ScopesWithPlaceEventOptions,
803
886
  options: ResolvedScopeOptionsPlaceEvent.optional()
804
887
  }),
805
- z11.object({
888
+ z12.object({
806
889
  type: ScopesWithDeclaredOptions,
807
890
  options: ResolvedScopeOptionsDeclared.optional()
808
891
  }),
809
- z11.object({
892
+ z12.object({
810
893
  type: ScopesWithFullOptions,
811
894
  options: ResolvedScopeOptionsFull.optional()
812
895
  }),
813
- z11.object({
814
- type: z11.literal("record.print-certified-copies"),
896
+ z12.object({
897
+ type: z12.literal("record.print-certified-copies"),
815
898
  options: ResolvedScopeOptionsFull.extend({
816
- templates: z11.array(z11.string()).optional()
899
+ templates: z12.array(z12.string()).optional()
817
900
  }).optional()
818
901
  })
819
902
  ]).describe("Resolved scope with location/user IDs instead of filters.");
820
- var Scope = z11.discriminatedUnion("type", [
821
- z11.object({ type: PlainScopeType }),
903
+ var Scope = z12.discriminatedUnion("type", [
904
+ z12.object({ type: PlainScopeType }),
822
905
  ...RecordScopeV2.options,
823
906
  ...UserScopeV2.options,
824
- z11.object({
825
- type: z11.literal("organisation.read-locations"),
907
+ z12.object({
908
+ type: z12.literal("organisation.read-locations"),
826
909
  options: AccessLevelOptions.optional()
827
910
  }),
828
- z11.object({
829
- type: z11.literal("workqueue"),
911
+ z12.object({
912
+ type: z12.literal("workqueue"),
830
913
  options: WorkqueueOrDashboardOptions
831
914
  }),
832
- z11.object({
833
- type: z11.literal("dashboard.view"),
915
+ z12.object({
916
+ type: z12.literal("dashboard.view"),
834
917
  options: WorkqueueOrDashboardOptions
835
918
  })
836
919
  ]);
837
- var ScopeType = z11.enum([
920
+ var ScopeType = z12.enum([
838
921
  ...SystemScopeType.options,
839
922
  ...RecordScopeTypeV2.options,
840
923
  ...PlainScopeType.options,
841
924
  "workqueue",
842
925
  "dashboard.view"
843
926
  ]);
844
- var EncodedScope = z11.string().brand("EncodedScope");
927
+ var EncodedScope = z12.string().brand("EncodedScope");
845
928
  var DEFAULT_SCOPE_OPTIONS = {
846
929
  placeOfEvent: JurisdictionFilter.enum.all,
847
930
  accessLevel: JurisdictionFilter.enum.all,
@@ -851,30 +934,25 @@ var DEFAULT_SCOPE_OPTIONS = {
851
934
  };
852
935
 
853
936
  // ../commons/src/authentication.ts
854
- var TokenUserType = z12.enum(["user", "system"]);
855
- var TokenWithBearer = z12.string().regex(/^Bearer\s/);
937
+ var TokenUserType = z13.enum(["user", "system"]);
938
+ var TokenWithBearer = z13.string().regex(/^Bearer\s/);
856
939
 
857
940
  // ../commons/src/events/ActionDocument.ts
858
- var ActionUpdate = z13.record(z13.string(), FieldUpdateValue).describe(
941
+ var ActionUpdate = z14.record(z14.string(), FieldUpdateValue).describe(
859
942
  "Record of field-level changes made by an action. Supports partial updates and nullable values."
860
943
  );
861
- var EventState = z13.record(z13.string(), FieldValue).describe(
944
+ var EventState = z14.record(z14.string(), FieldValue).describe(
862
945
  "Aggregate representation of event data after all actions have been applied, with all updates consolidated and null values removed."
863
946
  );
864
- var ActionStatus = {
865
- Requested: "Requested",
866
- Accepted: "Accepted",
867
- Rejected: "Rejected"
868
- };
869
- var ActionBase = z13.object({
947
+ var ActionBase = z14.object({
870
948
  id: UUID.describe("Unique identifier of the action."),
871
- transactionId: z13.string().describe("Unique identifier of the transaction."),
949
+ transactionId: z14.string().describe("Unique identifier of the transaction."),
872
950
  createdByUserType: TokenUserType.describe(
873
951
  "Indicates whether the action was created by a human-user or by a system-user."
874
952
  ),
875
- createdAt: z13.string().datetime().describe("Timestamp indicating when the action was created."),
876
- createdBy: z13.string().describe("Identifier of the user who created the action."),
877
- createdByRole: z13.string().optional().describe("Role of the user who created the action."),
953
+ createdAt: z14.string().datetime().describe("Timestamp indicating when the action was created."),
954
+ createdBy: z14.string().describe("Identifier of the user who created the action."),
955
+ createdByRole: z14.string().optional().describe("Role of the user who created the action."),
878
956
  createdBySignature: DocumentPath.nullish().describe(
879
957
  "Reference to the signature of the user who created the action."
880
958
  ),
@@ -886,7 +964,7 @@ var ActionBase = z13.object({
886
964
  "Declaration data defined by the ActionConfig. Supports partial updates."
887
965
  ),
888
966
  annotation: ActionUpdate.optional().nullable().describe("Action-specific metadata used to annotate the event."),
889
- status: z13.enum([
967
+ status: z14.enum([
890
968
  ActionStatus.Requested,
891
969
  ActionStatus.Accepted,
892
970
  ActionStatus.Rejected
@@ -898,139 +976,146 @@ var ActionBase = z13.object({
898
976
  )
899
977
  });
900
978
  var AssignedAction = ActionBase.extend(
901
- z13.object({
902
- type: z13.literal(ActionType.ASSIGN),
903
- assignedTo: z13.string().describe("Identifier of the user to whom the action is assigned.")
979
+ z14.object({
980
+ type: z14.literal(ActionType.ASSIGN),
981
+ assignedTo: z14.string().describe("Identifier of the user to whom the action is assigned.")
904
982
  // TODO move into 'content' property
905
983
  }).shape
906
984
  );
907
985
  var UnassignedAction = ActionBase.extend(
908
- z13.object({
909
- type: z13.literal(ActionType.UNASSIGN)
986
+ z14.object({
987
+ type: z14.literal(ActionType.UNASSIGN)
910
988
  }).shape
911
989
  );
912
990
  var RegisterAction = ActionBase.extend(
913
- z13.object({
914
- type: z13.literal(ActionType.REGISTER),
915
- registrationNumber: z13.string().optional().describe(
991
+ z14.object({
992
+ type: z14.literal(ActionType.REGISTER),
993
+ registrationNumber: z14.string().optional().describe(
916
994
  "Registration number of the event. Always present for accepted registrations."
917
995
  )
918
996
  // TODO move into 'content' property
919
997
  }).shape
920
998
  );
921
999
  var DeclareAction = ActionBase.extend(
922
- z13.object({
923
- type: z13.literal(ActionType.DECLARE)
1000
+ z14.object({
1001
+ type: z14.literal(ActionType.DECLARE)
924
1002
  }).shape
925
1003
  );
926
- var ReasonContent = z13.object({
927
- reason: z13.string().min(1, { error: "Message cannot be empty" }).describe(
1004
+ var ReasonContent = z14.object({
1005
+ reason: z14.string().min(1, { error: "Message cannot be empty" }).describe(
928
1006
  "Message describing the reason for rejecting or archiving the event."
929
1007
  )
930
1008
  });
931
1009
  var RejectAction = ActionBase.extend(
932
- z13.object({
933
- type: z13.literal(ActionType.REJECT),
1010
+ z14.object({
1011
+ type: z14.literal(ActionType.REJECT),
934
1012
  content: ReasonContent
935
1013
  }).shape
936
1014
  );
937
- var PotentialDuplicate = z13.object({
1015
+ var PotentialDuplicate = z14.object({
938
1016
  id: UUID,
939
- trackingId: z13.string()
1017
+ trackingId: z14.string()
940
1018
  });
941
1019
  var DuplicateDetectedAction = ActionBase.extend(
942
- z13.object({
943
- type: z13.literal(ActionType.DUPLICATE_DETECTED),
944
- content: z13.object({
945
- duplicates: z13.array(PotentialDuplicate)
1020
+ z14.object({
1021
+ type: z14.literal(ActionType.DUPLICATE_DETECTED),
1022
+ content: z14.object({
1023
+ duplicates: z14.array(PotentialDuplicate)
946
1024
  })
947
1025
  }).shape
948
1026
  );
949
1027
  var MarkNotDuplicateAction = ActionBase.extend(
950
- z13.object({
951
- type: z13.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1028
+ z14.object({
1029
+ type: z14.literal(ActionType.MARK_AS_NOT_DUPLICATE)
952
1030
  }).shape
953
1031
  );
954
1032
  var MarkAsDuplicateAction = ActionBase.extend(
955
- z13.object({
956
- type: z13.literal(ActionType.MARK_AS_DUPLICATE),
957
- content: z13.object({
1033
+ z14.object({
1034
+ type: z14.literal(ActionType.MARK_AS_DUPLICATE),
1035
+ content: z14.object({
958
1036
  duplicateOf: UUID
959
1037
  }).optional()
960
1038
  }).shape
961
1039
  );
962
1040
  var ArchiveAction = ActionBase.extend(
963
- z13.object({
964
- type: z13.literal(ActionType.ARCHIVE),
1041
+ z14.object({
1042
+ type: z14.literal(ActionType.ARCHIVE),
965
1043
  content: ReasonContent
966
1044
  }).shape
967
1045
  );
1046
+ var UnarchiveAction = ActionBase.extend(
1047
+ z14.object({
1048
+ type: z14.literal(ActionType.UNARCHIVE)
1049
+ }).shape
1050
+ );
968
1051
  var CreatedAction = ActionBase.extend(
969
- z13.object({
970
- type: z13.literal(ActionType.CREATE)
1052
+ z14.object({
1053
+ type: z14.literal(ActionType.CREATE)
971
1054
  }).shape
972
1055
  );
973
1056
  var NotifiedAction = ActionBase.extend(
974
- z13.object({
975
- type: z13.literal(ActionType.NOTIFY)
1057
+ z14.object({
1058
+ type: z14.literal(ActionType.NOTIFY)
976
1059
  }).shape
977
1060
  );
978
1061
  var EditAction = ActionBase.extend(
979
- z13.object({
980
- type: z13.literal(ActionType.EDIT),
981
- content: z13.object({
982
- comment: z13.string().describe("Comment for the edit action.").optional()
983
- })
1062
+ z14.object({
1063
+ type: z14.literal(ActionType.EDIT),
1064
+ /** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
1065
+ content: z14.object({
1066
+ comment: z14.string().describe("Comment for the edit action.").optional()
1067
+ }).optional()
984
1068
  }).shape
985
1069
  );
986
- var PrintContent = z13.object({
987
- templateId: z13.string().optional()
1070
+ var PrintContent = z14.object({
1071
+ templateId: z14.string().optional()
988
1072
  });
989
1073
  var PrintCertificateAction = ActionBase.extend(
990
- z13.object({
991
- type: z13.literal(ActionType.PRINT_CERTIFICATE),
1074
+ z14.object({
1075
+ type: z14.literal(ActionType.PRINT_CERTIFICATE),
992
1076
  content: PrintContent.optional().nullable()
993
1077
  }).shape
994
1078
  );
995
1079
  var RequestedCorrectionAction = ActionBase.extend(
996
- z13.object({
997
- type: z13.literal(ActionType.REQUEST_CORRECTION)
1080
+ z14.object({
1081
+ type: z14.literal(ActionType.REQUEST_CORRECTION)
998
1082
  }).shape
999
1083
  );
1000
1084
  var ApprovedCorrectionAction = ActionBase.extend(
1001
- z13.object({
1002
- type: z13.literal(ActionType.APPROVE_CORRECTION),
1003
- requestId: z13.string(),
1085
+ z14.object({
1086
+ type: z14.literal(ActionType.APPROVE_CORRECTION),
1087
+ requestId: z14.string(),
1004
1088
  // TODO move into 'content' property
1005
- content: z13.object({ immediateCorrection: z13.boolean().optional() }).optional()
1089
+ content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
1006
1090
  }).shape
1007
1091
  );
1008
1092
  var RejectedCorrectionAction = ActionBase.extend(
1009
- z13.object({
1010
- type: z13.literal(ActionType.REJECT_CORRECTION),
1011
- requestId: z13.string(),
1093
+ z14.object({
1094
+ type: z14.literal(ActionType.REJECT_CORRECTION),
1095
+ requestId: z14.string(),
1012
1096
  // TODO move into 'content' property
1013
1097
  content: ReasonContent
1014
1098
  }).shape
1015
1099
  );
1016
1100
  var ReadAction = ActionBase.extend(
1017
- z13.object({
1018
- type: z13.literal(ActionType.READ)
1101
+ z14.object({
1102
+ type: z14.literal(ActionType.READ)
1019
1103
  }).shape
1020
1104
  );
1021
1105
  var CustomAction = ActionBase.merge(
1022
- z13.object({
1023
- type: z13.literal(ActionType.CUSTOM),
1024
- customActionType: z13.string()
1106
+ z14.object({
1107
+ type: z14.literal(ActionType.CUSTOM),
1108
+ customActionType: z14.string()
1025
1109
  })
1026
1110
  );
1027
- var ActionDocument = z13.discriminatedUnion("type", [
1111
+ var ActionDocument = z14.discriminatedUnion("type", [
1028
1112
  CreatedAction.meta({ id: "CreatedAction" }),
1029
1113
  RejectAction.meta({ id: "RejectAction" }),
1030
1114
  DuplicateDetectedAction.meta({ id: "DuplicateDetectedAction" }),
1031
1115
  MarkNotDuplicateAction.meta({ id: "MarkNotDuplicateAction" }),
1032
1116
  MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
1033
1117
  ArchiveAction.meta({ id: "ArchiveAction" }),
1118
+ UnarchiveAction.meta({ id: "UnarchiveAction" }),
1034
1119
  NotifiedAction.meta({ id: "NotifiedAction" }),
1035
1120
  RegisterAction.meta({ id: "RegisterAction" }),
1036
1121
  DeclareAction.meta({ id: "DeclareAction" }),
@@ -1050,64 +1135,12 @@ var AsyncRejectActionDocument = ActionBase.omit({
1050
1135
  declaration: true,
1051
1136
  annotation: true
1052
1137
  }).extend(
1053
- z13.object({
1054
- type: z13.enum(ConfirmableActions),
1055
- status: z13.literal(ActionStatus.Rejected)
1138
+ z14.object({
1139
+ type: z14.enum(ConfirmableActions),
1140
+ status: z14.literal(ActionStatus.Rejected)
1056
1141
  }).shape
1057
1142
  );
1058
- var Action = z13.union([ActionDocument, AsyncRejectActionDocument]);
1059
-
1060
- // ../commons/src/events/Flag.ts
1061
- var z14 = __toESM(require("zod/v4"));
1062
- var InherentFlags = {
1063
- INCOMPLETE: "incomplete",
1064
- REJECTED: "rejected",
1065
- CORRECTION_REQUESTED: "correction-requested",
1066
- POTENTIAL_DUPLICATE: "potential-duplicate",
1067
- /**
1068
- * This flag is set by the Edit-action and removed after the declaration or registration.
1069
- * A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
1070
- *
1071
- * We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
1072
- */
1073
- EDIT_IN_PROGRESS: "edit-in-progress"
1074
- };
1075
- var ActionFlag = z14.string().regex(
1076
- new RegExp(
1077
- `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
1078
- ActionStatus
1079
- ).join("|").toLowerCase()})$`
1080
- ),
1081
- "Flag must be in the format ActionType:ActionStatus (lowerCase)"
1082
- );
1083
- var CustomFlag = z14.string().refine((val) => !Object.values(InherentFlags).includes(val), {
1084
- message: `Custom flag cannot be one of the inherent flags: ${Object.values(
1085
- InherentFlags
1086
- ).join(", ")}`
1087
- }).refine((val) => !ActionFlag.safeParse(val).success, {
1088
- message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
1089
- }).describe("Custom flag identifier defined by the country config.");
1090
- var Flag = ActionFlag.or(z14.enum(InherentFlags)).or(CustomFlag);
1091
- var FlagConfig = z14.object({
1092
- id: CustomFlag,
1093
- requiresAction: z14.boolean().describe(
1094
- "Indicates if this flag expects an action to be performed to be cleared."
1095
- ),
1096
- label: TranslationConfig.describe("Human readable label of the flag.")
1097
- }).meta({
1098
- id: "FlagConfig",
1099
- description: "Configuration for a custom flag that can be added to or removed from records by event actions."
1100
- });
1101
- var ActionFlagConfig = z14.object({
1102
- id: Flag,
1103
- operation: z14.enum(["add", "remove"]).describe("Operation to perform on the flag."),
1104
- conditional: Conditional.optional().describe(
1105
- "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
1106
- )
1107
- }).meta({
1108
- id: "ActionFlagConfig",
1109
- description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
1110
- });
1143
+ var Action = z14.union([ActionDocument, AsyncRejectActionDocument]);
1111
1144
 
1112
1145
  // ../commons/src/events/EventMetadata.ts
1113
1146
  var EventStatus = z15.enum([
@@ -1268,13 +1301,6 @@ var Range = import_v4.z.object({
1268
1301
  }).meta({
1269
1302
  id: "Range"
1270
1303
  });
1271
- var ContainsFlags = import_v4.z.object({
1272
- anyOf: import_v4.z.array(Flag).optional(),
1273
- noneOf: import_v4.z.array(Flag).optional(),
1274
- allOf: import_v4.z.array(Flag).optional()
1275
- }).meta({
1276
- id: "ContainsFlags"
1277
- });
1278
1304
  var Within = import_v4.z.object({ type: import_v4.z.literal("within"), location: import_v4.z.string() }).meta({
1279
1305
  id: "Within"
1280
1306
  });
@@ -1469,8 +1495,8 @@ var BaseField = import_v43.default.object({
1469
1495
  conditionals: import_v43.default.array(FieldConditional).default([]).optional().describe(
1470
1496
  "Conditions determining when the field is shown or enabled. By default, the field is always shown and enabled."
1471
1497
  ),
1472
- secured: import_v43.default.boolean().default(false).optional().describe(
1473
- "Indicates whether the field is secured. Secured fields are not indexed for search and are only visible when explicitly assigned."
1498
+ secured: import_v43.default.union([import_v43.default.boolean(), Conditional]).default(false).optional().describe(
1499
+ "Indicates whether the field is secured, either always (boolean) or conditionally, evaluated against the event (a JSONSchema conditional, e.g. flag('sealed')). Secured fields are not indexed for search and are only visible when explicitly assigned."
1474
1500
  ),
1475
1501
  placeholder: TranslationConfig.optional(),
1476
1502
  validation: import_v43.default.array(ValidationConfig).default([]).optional().describe("Additional validation rules applied to the field."),
@@ -1868,7 +1894,13 @@ var AdministrativeAreaField = BaseField.extend({
1868
1894
  configuration: import_v43.default.object({
1869
1895
  partOf: FieldReference.optional().describe("Parent location"),
1870
1896
  type: AdministrativeAreas,
1871
- allowedLocations: AllowedLocations
1897
+ allowedLocations: AllowedLocations,
1898
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
1899
+ "Advanced search: list every historical name a location has had as a separate, selectable option."
1900
+ ),
1901
+ activeOnly: import_v43.default.boolean().optional().describe(
1902
+ "Advanced search: offer only currently-active locations; inactivated ones are excluded."
1903
+ )
1872
1904
  }).describe("Administrative area options")
1873
1905
  }).meta({
1874
1906
  description: "Administrative area input field",
@@ -1879,7 +1911,10 @@ var LocationInput = BaseField.extend({
1879
1911
  defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
1880
1912
  configuration: import_v43.default.object({
1881
1913
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
1882
- allowedLocations: AllowedLocations
1914
+ allowedLocations: AllowedLocations,
1915
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
1916
+ "Advanced search: list every historical name a location has had as a separate, selectable option."
1917
+ )
1883
1918
  }).optional()
1884
1919
  }).meta({
1885
1920
  description: "A field for selecting a location",
@@ -1905,12 +1940,18 @@ var FileUploadWithOptions = BaseField.extend({
1905
1940
  var Facility = BaseField.extend({
1906
1941
  type: import_v43.default.literal(FieldType.FACILITY),
1907
1942
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1908
- configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
1943
+ configuration: import_v43.default.object({
1944
+ allowedLocations: AllowedLocations,
1945
+ listHistoricalNames: import_v43.default.boolean().optional()
1946
+ }).optional()
1909
1947
  }).describe("Input field for a facility");
1910
1948
  var Office = BaseField.extend({
1911
1949
  type: import_v43.default.literal(FieldType.OFFICE),
1912
1950
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1913
- configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
1951
+ configuration: import_v43.default.object({
1952
+ allowedLocations: AllowedLocations,
1953
+ listHistoricalNames: import_v43.default.boolean().optional()
1954
+ }).optional()
1914
1955
  }).describe("Input field for an office");
1915
1956
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
1916
1957
  administrativeArea: import_v43.default.union([UUID, SerializedUserField]).optional()
@@ -1943,7 +1984,13 @@ var Address = BaseField.extend({
1943
1984
  parent: FieldReference.optional()
1944
1985
  })
1945
1986
  ).optional(),
1946
- allowedLocations: AllowedLocations
1987
+ allowedLocations: AllowedLocations,
1988
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
1989
+ "Advanced search: list every historical name a location has had as a separate, selectable option. Propagated to the embedded admin-area selectors."
1990
+ ),
1991
+ activeOnly: import_v43.default.boolean().optional().describe(
1992
+ "Advanced search: offer only currently-active admin areas; inactivated ones are excluded. Propagated to the embedded admin-area selectors."
1993
+ )
1947
1994
  }).optional(),
1948
1995
  defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
1949
1996
  }).meta({