@opencrvs/toolkit 2.1.0-rc.4fe3086 → 2.1.0-rc.50fdb5f

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 (56) hide show
  1. package/README.md +1 -0
  2. package/create-countryconfig/index.js +114 -66
  3. package/create-countryconfig/node_modules/.bin/degit +21 -0
  4. package/create-countryconfig/package.json +4 -1
  5. package/dist/application-config/index.js +227 -196
  6. package/dist/cli.js +174 -58
  7. package/dist/commons/api/router.d.ts +193 -20
  8. package/dist/commons/conditionals/conditionals.d.ts +3 -3
  9. package/dist/commons/conditionals/validate.d.ts +11 -4
  10. package/dist/commons/events/ActionDocument.d.ts +1 -7
  11. package/dist/commons/events/ActionStatus.d.ts +14 -0
  12. package/dist/commons/events/AdvancedSearchConfig.d.ts +6 -0
  13. package/dist/commons/events/AuditLog.d.ts +110 -0
  14. package/dist/commons/events/EventConfig.d.ts +3 -0
  15. package/dist/commons/events/EventIndex.d.ts +3 -26
  16. package/dist/commons/events/FieldConfig.d.ts +65 -53
  17. package/dist/commons/events/FieldTypeMapping.d.ts +19 -19
  18. package/dist/commons/events/FieldValue.d.ts +2 -2
  19. package/dist/commons/events/Flag.d.ts +42 -0
  20. package/dist/commons/events/PlainDate.d.ts +8 -0
  21. package/dist/commons/events/SummaryConfig.d.ts +249 -0
  22. package/dist/commons/events/WorkqueueConfig.d.ts +17 -14
  23. package/dist/commons/events/event.d.ts +12 -0
  24. package/dist/commons/events/locations.d.ts +99 -16
  25. package/dist/commons/events/mocks.test.utils.d.ts +30 -0
  26. package/dist/conditionals/index.js +302 -55
  27. package/dist/environment/index.d.ts +1 -0
  28. package/dist/environment/index.d.ts.map +1 -1
  29. package/dist/environment/index.js +10 -0
  30. package/dist/environment/logger.d.ts +12 -3
  31. package/dist/environment/logger.d.ts.map +1 -1
  32. package/dist/environment/paths.d.ts +7 -0
  33. package/dist/environment/paths.d.ts.map +1 -0
  34. package/dist/environment/paths.js +72 -0
  35. package/dist/environment/setup-environment.js +2 -1
  36. package/dist/environment/templates.d.ts.map +1 -1
  37. package/dist/environment/templates.js +2 -1
  38. package/dist/environment/update-workflows.d.ts.map +1 -1
  39. package/dist/environment/update-workflows.js +17 -5
  40. package/dist/environment/upgrade.d.ts +2 -0
  41. package/dist/environment/upgrade.d.ts.map +1 -0
  42. package/dist/environment/upgrade.js +82 -0
  43. package/dist/environment/users.js +11 -13
  44. package/dist/events/index.js +3493 -3250
  45. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
  46. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  47. package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
  48. package/dist/notification/index.js +1806 -1050
  49. package/dist/scopes/index.d.ts +248 -25
  50. package/dist/scopes/index.js +303 -55
  51. package/dist/templates/charts-values/opencrvs-services/values.yaml +4 -3
  52. package/dist/templates/charts-values/opentelemetry/values.yaml +73 -0
  53. package/opencrvs-toolkit-2.1.0-rc.50fdb5f.tgz +0 -0
  54. package/package.json +5 -5
  55. package/tsconfig.tsbuildinfo +1 -1
  56. package/opencrvs-toolkit-2.1.0-rc.4fe3086.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"));
@@ -612,16 +612,88 @@ var META_ACTIONS = [
612
612
 
613
613
  // ../commons/src/authentication.ts
614
614
  var import_jwt_decode = __toESM(require("jwt-decode"));
615
- var z12 = __toESM(require("zod/v4"));
615
+ var z13 = __toESM(require("zod/v4"));
616
616
 
617
617
  // ../commons/src/scopes.ts
618
- var z11 = __toESM(require("zod/v4"));
618
+ var z12 = __toESM(require("zod/v4"));
619
619
  var qs = __toESM(require("qs"));
620
- 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(
621
693
  "Filters based on user jurisdiction relative to their office location in hierarchy."
622
694
  );
623
- var UserFilter = z11.enum(["user"]).describe("Filters based on the user. Limits to self.");
624
- var RecordScopeTypeV2 = z11.enum([
695
+ var UserFilter = z12.enum(["user"]).describe("Filters based on the user. Limits to self.");
696
+ var RecordScopeTypeV2 = z12.enum([
625
697
  "record.search",
626
698
  "record.create",
627
699
  "record.read",
@@ -639,7 +711,7 @@ var RecordScopeTypeV2 = z11.enum([
639
711
  "record.unassign-others",
640
712
  "record.custom-action"
641
713
  ]);
642
- var PlainScopeType = z11.enum([
714
+ var PlainScopeType = z12.enum([
643
715
  // Misc. system scopes
644
716
  "bypassratelimit",
645
717
  "record.reindex",
@@ -659,15 +731,15 @@ var PlainScopeType = z11.enum([
659
731
  "record.confirm-registration",
660
732
  "record.reject-registration"
661
733
  ]);
662
- var scopeByEvent = z11.preprocess(
734
+ var scopeByEvent = z12.preprocess(
663
735
  (val) => val === void 0 ? void 0 : [val].flat(),
664
- z11.array(z11.string()).optional()
736
+ z12.array(z12.string()).optional()
665
737
  ).describe("Event type, e.g. birth, death");
666
- var userRole = z11.preprocess(
738
+ var userRole = z12.preprocess(
667
739
  (val) => val === void 0 ? void 0 : [val].flat(),
668
- z11.array(z11.string()).optional()
740
+ z12.array(z12.string()).optional()
669
741
  ).describe("User role, e.g. admin, field agent");
670
- var scopeOptionsPlaceEvent = z11.object({
742
+ var scopeOptionsPlaceEvent = z12.object({
671
743
  event: scopeByEvent,
672
744
  placeOfEvent: JurisdictionFilter.optional()
673
745
  }).describe("Options applicable to all record scopes.");
@@ -679,36 +751,37 @@ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
679
751
  }).describe("Options applicable to actions that may take place after DECLARE");
680
752
  var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
681
753
  registeredIn: JurisdictionFilter.optional(),
682
- registeredBy: UserFilter.optional()
754
+ registeredBy: UserFilter.optional(),
755
+ flags: ContainsFlags.optional()
683
756
  }).describe(
684
757
  "Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
685
758
  );
686
759
  var CustomActionScopeOptions = AllRecordScopeOptions.extend({
687
- customActionTypes: z11.preprocess(
760
+ customActionTypes: z12.preprocess(
688
761
  (val) => val === void 0 ? void 0 : [val].flat(),
689
- z11.array(z11.string()).optional()
762
+ z12.array(z12.string()).optional()
690
763
  ).describe("Allowed custom action types")
691
764
  });
692
- var AccessLevelOptions = z11.object({
765
+ var AccessLevelOptions = z12.object({
693
766
  accessLevel: JurisdictionFilter.optional()
694
767
  });
695
768
  var AllUserScopeOptions = AccessLevelOptions.extend({
696
769
  role: userRole.optional()
697
770
  });
698
- var WorkqueueOrDashboardOptions = z11.object({
699
- ids: z11.preprocess(
771
+ var WorkqueueOrDashboardOptions = z12.object({
772
+ ids: z12.preprocess(
700
773
  (val) => val === void 0 ? void 0 : [val].flat(),
701
- z11.array(z11.string())
774
+ z12.array(z12.string())
702
775
  ).describe("Must contain a list of workqueue or dashboard ids.")
703
776
  });
704
- var AllScopeOptions = z11.object({
777
+ var AllScopeOptions = z12.object({
705
778
  ...AllRecordScopeOptions.shape,
706
779
  ...AccessLevelOptions.shape,
707
780
  ...AllUserScopeOptions.shape,
708
781
  ...WorkqueueOrDashboardOptions.shape
709
782
  });
710
783
  var ScopeOptionKey = AllScopeOptions.keyof();
711
- var ResolvedScopeOptionsPlaceEvent = z11.object({
784
+ var ResolvedScopeOptionsPlaceEvent = z12.object({
712
785
  event: scopeByEvent,
713
786
  placeOfEvent: UUID.nullish()
714
787
  }).describe(
@@ -716,15 +789,16 @@ var ResolvedScopeOptionsPlaceEvent = z11.object({
716
789
  );
717
790
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
718
791
  notifiedIn: UUID.nullish(),
719
- notifiedBy: z11.string().optional(),
792
+ notifiedBy: z12.string().optional(),
720
793
  declaredIn: UUID.nullish(),
721
- declaredBy: z11.string().optional()
794
+ declaredBy: z12.string().optional()
722
795
  }).describe(
723
796
  "Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
724
797
  );
725
798
  var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
726
799
  registeredIn: UUID.nullish(),
727
- registeredBy: z11.string().optional()
800
+ registeredBy: z12.string().optional(),
801
+ flags: ContainsFlags.optional()
728
802
  }).describe(
729
803
  "Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
730
804
  );
@@ -749,38 +823,38 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
749
823
  "record.unassign-others"
750
824
  ]);
751
825
  var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
752
- templates: z11.preprocess(
826
+ templates: z12.preprocess(
753
827
  (val) => val === void 0 ? void 0 : [val].flat(),
754
- z11.array(z11.string()).optional()
828
+ z12.array(z12.string()).optional()
755
829
  ).describe(
756
830
  "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."
757
831
  )
758
832
  });
759
- var RecordScopeV2 = z11.discriminatedUnion("type", [
760
- z11.object({
833
+ var RecordScopeV2 = z12.discriminatedUnion("type", [
834
+ z12.object({
761
835
  type: ScopesWithPlaceEventOptions,
762
836
  options: scopeOptionsPlaceEvent.optional()
763
837
  }),
764
- z11.object({
838
+ z12.object({
765
839
  type: ScopesWithDeclaredOptions,
766
840
  options: scopeOptionsDeclaredOrNotified.optional()
767
841
  }),
768
- z11.object({
842
+ z12.object({
769
843
  type: ScopesWithFullOptions,
770
844
  options: AllRecordScopeOptions.optional()
771
845
  }),
772
- z11.object({
773
- type: z11.literal("record.custom-action"),
846
+ z12.object({
847
+ type: z12.literal("record.custom-action"),
774
848
  options: CustomActionScopeOptions.optional()
775
849
  }),
776
- z11.object({
777
- type: z11.literal("record.print-certified-copies"),
850
+ z12.object({
851
+ type: z12.literal("record.print-certified-copies"),
778
852
  options: ScopeOptionsPrintCertifiedCopies.optional()
779
853
  })
780
854
  ]).describe(
781
855
  "Scopes used to check user's permission to perform actions on a record."
782
856
  );
783
- var SystemScopeType = z11.enum([
857
+ var SystemScopeType = z12.enum([
784
858
  "organisation.read-locations",
785
859
  "user.read",
786
860
  "user.create",
@@ -794,61 +868,61 @@ var UserScopeType = SystemScopeType.extract([
794
868
  "user.search"
795
869
  ]);
796
870
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
797
- var UserScopeV2 = z11.discriminatedUnion("type", [
798
- z11.object({
871
+ var UserScopeV2 = z12.discriminatedUnion("type", [
872
+ z12.object({
799
873
  type: ScopesWithRoleOption,
800
874
  options: AllUserScopeOptions.optional()
801
875
  }),
802
- z11.object({
876
+ z12.object({
803
877
  type: UserScopeType.extract(["user.read", "user.search"]),
804
878
  options: AccessLevelOptions.optional()
805
879
  })
806
880
  ]);
807
- var ResolvedRecordScopeV2 = z11.discriminatedUnion("type", [
808
- z11.object({
881
+ var ResolvedRecordScopeV2 = z12.discriminatedUnion("type", [
882
+ z12.object({
809
883
  type: ScopesWithPlaceEventOptions,
810
884
  options: ResolvedScopeOptionsPlaceEvent.optional()
811
885
  }),
812
- z11.object({
886
+ z12.object({
813
887
  type: ScopesWithDeclaredOptions,
814
888
  options: ResolvedScopeOptionsDeclared.optional()
815
889
  }),
816
- z11.object({
890
+ z12.object({
817
891
  type: ScopesWithFullOptions,
818
892
  options: ResolvedScopeOptionsFull.optional()
819
893
  }),
820
- z11.object({
821
- type: z11.literal("record.print-certified-copies"),
894
+ z12.object({
895
+ type: z12.literal("record.print-certified-copies"),
822
896
  options: ResolvedScopeOptionsFull.extend({
823
- templates: z11.array(z11.string()).optional()
897
+ templates: z12.array(z12.string()).optional()
824
898
  }).optional()
825
899
  })
826
900
  ]).describe("Resolved scope with location/user IDs instead of filters.");
827
- var Scope = z11.discriminatedUnion("type", [
828
- z11.object({ type: PlainScopeType }),
901
+ var Scope = z12.discriminatedUnion("type", [
902
+ z12.object({ type: PlainScopeType }),
829
903
  ...RecordScopeV2.options,
830
904
  ...UserScopeV2.options,
831
- z11.object({
832
- type: z11.literal("organisation.read-locations"),
905
+ z12.object({
906
+ type: z12.literal("organisation.read-locations"),
833
907
  options: AccessLevelOptions.optional()
834
908
  }),
835
- z11.object({
836
- type: z11.literal("workqueue"),
909
+ z12.object({
910
+ type: z12.literal("workqueue"),
837
911
  options: WorkqueueOrDashboardOptions
838
912
  }),
839
- z11.object({
840
- type: z11.literal("dashboard.view"),
913
+ z12.object({
914
+ type: z12.literal("dashboard.view"),
841
915
  options: WorkqueueOrDashboardOptions
842
916
  })
843
917
  ]);
844
- var ScopeType = z11.enum([
918
+ var ScopeType = z12.enum([
845
919
  ...SystemScopeType.options,
846
920
  ...RecordScopeTypeV2.options,
847
921
  ...PlainScopeType.options,
848
922
  "workqueue",
849
923
  "dashboard.view"
850
924
  ]);
851
- var EncodedScope = z11.string().brand("EncodedScope");
925
+ var EncodedScope = z12.string().brand("EncodedScope");
852
926
  var DEFAULT_SCOPE_OPTIONS = {
853
927
  placeOfEvent: JurisdictionFilter.enum.all,
854
928
  accessLevel: JurisdictionFilter.enum.all,
@@ -858,30 +932,25 @@ var DEFAULT_SCOPE_OPTIONS = {
858
932
  };
859
933
 
860
934
  // ../commons/src/authentication.ts
861
- var TokenUserType = z12.enum(["user", "system"]);
862
- var TokenWithBearer = z12.string().regex(/^Bearer\s/);
935
+ var TokenUserType = z13.enum(["user", "system"]);
936
+ var TokenWithBearer = z13.string().regex(/^Bearer\s/);
863
937
 
864
938
  // ../commons/src/events/ActionDocument.ts
865
- var ActionUpdate = z13.record(z13.string(), FieldUpdateValue).describe(
939
+ var ActionUpdate = z14.record(z14.string(), FieldUpdateValue).describe(
866
940
  "Record of field-level changes made by an action. Supports partial updates and nullable values."
867
941
  );
868
- var EventState = z13.record(z13.string(), FieldValue).describe(
942
+ var EventState = z14.record(z14.string(), FieldValue).describe(
869
943
  "Aggregate representation of event data after all actions have been applied, with all updates consolidated and null values removed."
870
944
  );
871
- var ActionStatus = {
872
- Requested: "Requested",
873
- Accepted: "Accepted",
874
- Rejected: "Rejected"
875
- };
876
- var ActionBase = z13.object({
945
+ var ActionBase = z14.object({
877
946
  id: UUID.describe("Unique identifier of the action."),
878
- transactionId: z13.string().describe("Unique identifier of the transaction."),
947
+ transactionId: z14.string().describe("Unique identifier of the transaction."),
879
948
  createdByUserType: TokenUserType.describe(
880
949
  "Indicates whether the action was created by a human-user or by a system-user."
881
950
  ),
882
- createdAt: z13.string().datetime().describe("Timestamp indicating when the action was created."),
883
- createdBy: z13.string().describe("Identifier of the user who created the action."),
884
- createdByRole: z13.string().optional().describe("Role of the user who created the action."),
951
+ createdAt: z14.string().datetime().describe("Timestamp indicating when the action was created."),
952
+ createdBy: z14.string().describe("Identifier of the user who created the action."),
953
+ createdByRole: z14.string().optional().describe("Role of the user who created the action."),
885
954
  createdBySignature: DocumentPath.nullish().describe(
886
955
  "Reference to the signature of the user who created the action."
887
956
  ),
@@ -893,7 +962,7 @@ var ActionBase = z13.object({
893
962
  "Declaration data defined by the ActionConfig. Supports partial updates."
894
963
  ),
895
964
  annotation: ActionUpdate.optional().nullable().describe("Action-specific metadata used to annotate the event."),
896
- status: z13.enum([
965
+ status: z14.enum([
897
966
  ActionStatus.Requested,
898
967
  ActionStatus.Accepted,
899
968
  ActionStatus.Rejected
@@ -905,139 +974,139 @@ var ActionBase = z13.object({
905
974
  )
906
975
  });
907
976
  var AssignedAction = ActionBase.extend(
908
- z13.object({
909
- type: z13.literal(ActionType.ASSIGN),
910
- assignedTo: z13.string().describe("Identifier of the user to whom the action is assigned.")
977
+ z14.object({
978
+ type: z14.literal(ActionType.ASSIGN),
979
+ assignedTo: z14.string().describe("Identifier of the user to whom the action is assigned.")
911
980
  // TODO move into 'content' property
912
981
  }).shape
913
982
  );
914
983
  var UnassignedAction = ActionBase.extend(
915
- z13.object({
916
- type: z13.literal(ActionType.UNASSIGN)
984
+ z14.object({
985
+ type: z14.literal(ActionType.UNASSIGN)
917
986
  }).shape
918
987
  );
919
988
  var RegisterAction = ActionBase.extend(
920
- z13.object({
921
- type: z13.literal(ActionType.REGISTER),
922
- registrationNumber: z13.string().optional().describe(
989
+ z14.object({
990
+ type: z14.literal(ActionType.REGISTER),
991
+ registrationNumber: z14.string().optional().describe(
923
992
  "Registration number of the event. Always present for accepted registrations."
924
993
  )
925
994
  // TODO move into 'content' property
926
995
  }).shape
927
996
  );
928
997
  var DeclareAction = ActionBase.extend(
929
- z13.object({
930
- type: z13.literal(ActionType.DECLARE)
998
+ z14.object({
999
+ type: z14.literal(ActionType.DECLARE)
931
1000
  }).shape
932
1001
  );
933
- var ReasonContent = z13.object({
934
- reason: z13.string().min(1, { error: "Message cannot be empty" }).describe(
1002
+ var ReasonContent = z14.object({
1003
+ reason: z14.string().min(1, { error: "Message cannot be empty" }).describe(
935
1004
  "Message describing the reason for rejecting or archiving the event."
936
1005
  )
937
1006
  });
938
1007
  var RejectAction = ActionBase.extend(
939
- z13.object({
940
- type: z13.literal(ActionType.REJECT),
1008
+ z14.object({
1009
+ type: z14.literal(ActionType.REJECT),
941
1010
  content: ReasonContent
942
1011
  }).shape
943
1012
  );
944
- var PotentialDuplicate = z13.object({
1013
+ var PotentialDuplicate = z14.object({
945
1014
  id: UUID,
946
- trackingId: z13.string()
1015
+ trackingId: z14.string()
947
1016
  });
948
1017
  var DuplicateDetectedAction = ActionBase.extend(
949
- z13.object({
950
- type: z13.literal(ActionType.DUPLICATE_DETECTED),
951
- content: z13.object({
952
- duplicates: z13.array(PotentialDuplicate)
1018
+ z14.object({
1019
+ type: z14.literal(ActionType.DUPLICATE_DETECTED),
1020
+ content: z14.object({
1021
+ duplicates: z14.array(PotentialDuplicate)
953
1022
  })
954
1023
  }).shape
955
1024
  );
956
1025
  var MarkNotDuplicateAction = ActionBase.extend(
957
- z13.object({
958
- type: z13.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1026
+ z14.object({
1027
+ type: z14.literal(ActionType.MARK_AS_NOT_DUPLICATE)
959
1028
  }).shape
960
1029
  );
961
1030
  var MarkAsDuplicateAction = ActionBase.extend(
962
- z13.object({
963
- type: z13.literal(ActionType.MARK_AS_DUPLICATE),
964
- content: z13.object({
1031
+ z14.object({
1032
+ type: z14.literal(ActionType.MARK_AS_DUPLICATE),
1033
+ content: z14.object({
965
1034
  duplicateOf: UUID
966
1035
  }).optional()
967
1036
  }).shape
968
1037
  );
969
1038
  var ArchiveAction = ActionBase.extend(
970
- z13.object({
971
- type: z13.literal(ActionType.ARCHIVE),
1039
+ z14.object({
1040
+ type: z14.literal(ActionType.ARCHIVE),
972
1041
  content: ReasonContent
973
1042
  }).shape
974
1043
  );
975
1044
  var UnarchiveAction = ActionBase.extend(
976
- z13.object({
977
- type: z13.literal(ActionType.UNARCHIVE)
1045
+ z14.object({
1046
+ type: z14.literal(ActionType.UNARCHIVE)
978
1047
  }).shape
979
1048
  );
980
1049
  var CreatedAction = ActionBase.extend(
981
- z13.object({
982
- type: z13.literal(ActionType.CREATE)
1050
+ z14.object({
1051
+ type: z14.literal(ActionType.CREATE)
983
1052
  }).shape
984
1053
  );
985
1054
  var NotifiedAction = ActionBase.extend(
986
- z13.object({
987
- type: z13.literal(ActionType.NOTIFY)
1055
+ z14.object({
1056
+ type: z14.literal(ActionType.NOTIFY)
988
1057
  }).shape
989
1058
  );
990
1059
  var EditAction = ActionBase.extend(
991
- z13.object({
992
- type: z13.literal(ActionType.EDIT),
1060
+ z14.object({
1061
+ type: z14.literal(ActionType.EDIT),
993
1062
  /** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
994
- content: z13.object({
995
- comment: z13.string().describe("Comment for the edit action.").optional()
1063
+ content: z14.object({
1064
+ comment: z14.string().describe("Comment for the edit action.").optional()
996
1065
  }).optional()
997
1066
  }).shape
998
1067
  );
999
- var PrintContent = z13.object({
1000
- templateId: z13.string().optional()
1068
+ var PrintContent = z14.object({
1069
+ templateId: z14.string().optional()
1001
1070
  });
1002
1071
  var PrintCertificateAction = ActionBase.extend(
1003
- z13.object({
1004
- type: z13.literal(ActionType.PRINT_CERTIFICATE),
1072
+ z14.object({
1073
+ type: z14.literal(ActionType.PRINT_CERTIFICATE),
1005
1074
  content: PrintContent.optional().nullable()
1006
1075
  }).shape
1007
1076
  );
1008
1077
  var RequestedCorrectionAction = ActionBase.extend(
1009
- z13.object({
1010
- type: z13.literal(ActionType.REQUEST_CORRECTION)
1078
+ z14.object({
1079
+ type: z14.literal(ActionType.REQUEST_CORRECTION)
1011
1080
  }).shape
1012
1081
  );
1013
1082
  var ApprovedCorrectionAction = ActionBase.extend(
1014
- z13.object({
1015
- type: z13.literal(ActionType.APPROVE_CORRECTION),
1016
- requestId: z13.string(),
1083
+ z14.object({
1084
+ type: z14.literal(ActionType.APPROVE_CORRECTION),
1085
+ requestId: z14.string(),
1017
1086
  // TODO move into 'content' property
1018
- content: z13.object({ immediateCorrection: z13.boolean().optional() }).optional()
1087
+ content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
1019
1088
  }).shape
1020
1089
  );
1021
1090
  var RejectedCorrectionAction = ActionBase.extend(
1022
- z13.object({
1023
- type: z13.literal(ActionType.REJECT_CORRECTION),
1024
- requestId: z13.string(),
1091
+ z14.object({
1092
+ type: z14.literal(ActionType.REJECT_CORRECTION),
1093
+ requestId: z14.string(),
1025
1094
  // TODO move into 'content' property
1026
1095
  content: ReasonContent
1027
1096
  }).shape
1028
1097
  );
1029
1098
  var ReadAction = ActionBase.extend(
1030
- z13.object({
1031
- type: z13.literal(ActionType.READ)
1099
+ z14.object({
1100
+ type: z14.literal(ActionType.READ)
1032
1101
  }).shape
1033
1102
  );
1034
1103
  var CustomAction = ActionBase.merge(
1035
- z13.object({
1036
- type: z13.literal(ActionType.CUSTOM),
1037
- customActionType: z13.string()
1104
+ z14.object({
1105
+ type: z14.literal(ActionType.CUSTOM),
1106
+ customActionType: z14.string()
1038
1107
  })
1039
1108
  );
1040
- var ActionDocument = z13.discriminatedUnion("type", [
1109
+ var ActionDocument = z14.discriminatedUnion("type", [
1041
1110
  CreatedAction.meta({ id: "CreatedAction" }),
1042
1111
  RejectAction.meta({ id: "RejectAction" }),
1043
1112
  DuplicateDetectedAction.meta({ id: "DuplicateDetectedAction" }),
@@ -1064,64 +1133,12 @@ var AsyncRejectActionDocument = ActionBase.omit({
1064
1133
  declaration: true,
1065
1134
  annotation: true
1066
1135
  }).extend(
1067
- z13.object({
1068
- type: z13.enum(ConfirmableActions),
1069
- status: z13.literal(ActionStatus.Rejected)
1136
+ z14.object({
1137
+ type: z14.enum(ConfirmableActions),
1138
+ status: z14.literal(ActionStatus.Rejected)
1070
1139
  }).shape
1071
1140
  );
1072
- var Action = z13.union([ActionDocument, AsyncRejectActionDocument]);
1073
-
1074
- // ../commons/src/events/Flag.ts
1075
- var z14 = __toESM(require("zod/v4"));
1076
- var InherentFlags = {
1077
- INCOMPLETE: "incomplete",
1078
- REJECTED: "rejected",
1079
- CORRECTION_REQUESTED: "correction-requested",
1080
- POTENTIAL_DUPLICATE: "potential-duplicate",
1081
- /**
1082
- * This flag is set by the Edit-action and removed after the declaration or registration.
1083
- * A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
1084
- *
1085
- * We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
1086
- */
1087
- EDIT_IN_PROGRESS: "edit-in-progress"
1088
- };
1089
- var ActionFlag = z14.string().regex(
1090
- new RegExp(
1091
- `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
1092
- ActionStatus
1093
- ).join("|").toLowerCase()})$`
1094
- ),
1095
- "Flag must be in the format ActionType:ActionStatus (lowerCase)"
1096
- );
1097
- var CustomFlag = z14.string().refine((val) => !Object.values(InherentFlags).includes(val), {
1098
- message: `Custom flag cannot be one of the inherent flags: ${Object.values(
1099
- InherentFlags
1100
- ).join(", ")}`
1101
- }).refine((val) => !ActionFlag.safeParse(val).success, {
1102
- message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
1103
- }).describe("Custom flag identifier defined by the country config.");
1104
- var Flag = ActionFlag.or(z14.enum(InherentFlags)).or(CustomFlag);
1105
- var FlagConfig = z14.object({
1106
- id: CustomFlag,
1107
- requiresAction: z14.boolean().describe(
1108
- "Indicates if this flag expects an action to be performed to be cleared."
1109
- ),
1110
- label: TranslationConfig.describe("Human readable label of the flag.")
1111
- }).meta({
1112
- id: "FlagConfig",
1113
- description: "Configuration for a custom flag that can be added to or removed from records by event actions."
1114
- });
1115
- var ActionFlagConfig = z14.object({
1116
- id: Flag,
1117
- operation: z14.enum(["add", "remove"]).describe("Operation to perform on the flag."),
1118
- conditional: Conditional.optional().describe(
1119
- "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
1120
- )
1121
- }).meta({
1122
- id: "ActionFlagConfig",
1123
- description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
1124
- });
1141
+ var Action = z14.union([ActionDocument, AsyncRejectActionDocument]);
1125
1142
 
1126
1143
  // ../commons/src/events/EventMetadata.ts
1127
1144
  var EventStatus = z15.enum([
@@ -1282,13 +1299,6 @@ var Range = import_v4.z.object({
1282
1299
  }).meta({
1283
1300
  id: "Range"
1284
1301
  });
1285
- var ContainsFlags = import_v4.z.object({
1286
- anyOf: import_v4.z.array(Flag).optional(),
1287
- noneOf: import_v4.z.array(Flag).optional(),
1288
- allOf: import_v4.z.array(Flag).optional()
1289
- }).meta({
1290
- id: "ContainsFlags"
1291
- });
1292
1302
  var Within = import_v4.z.object({ type: import_v4.z.literal("within"), location: import_v4.z.string() }).meta({
1293
1303
  id: "Within"
1294
1304
  });
@@ -1483,8 +1493,8 @@ var BaseField = import_v43.default.object({
1483
1493
  conditionals: import_v43.default.array(FieldConditional).default([]).optional().describe(
1484
1494
  "Conditions determining when the field is shown or enabled. By default, the field is always shown and enabled."
1485
1495
  ),
1486
- secured: import_v43.default.boolean().default(false).optional().describe(
1487
- "Indicates whether the field is secured. Secured fields are not indexed for search and are only visible when explicitly assigned."
1496
+ secured: import_v43.default.union([import_v43.default.boolean(), Conditional]).default(false).optional().describe(
1497
+ "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."
1488
1498
  ),
1489
1499
  placeholder: TranslationConfig.optional(),
1490
1500
  validation: import_v43.default.array(ValidationConfig).default([]).optional().describe("Additional validation rules applied to the field."),
@@ -1882,7 +1892,13 @@ var AdministrativeAreaField = BaseField.extend({
1882
1892
  configuration: import_v43.default.object({
1883
1893
  partOf: FieldReference.optional().describe("Parent location"),
1884
1894
  type: AdministrativeAreas,
1885
- allowedLocations: AllowedLocations
1895
+ allowedLocations: AllowedLocations,
1896
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
1897
+ "Advanced search: list every historical name a location has had as a separate, selectable option."
1898
+ ),
1899
+ activeOnly: import_v43.default.boolean().optional().describe(
1900
+ "Advanced search: offer only currently-active locations; inactivated ones are excluded."
1901
+ )
1886
1902
  }).describe("Administrative area options")
1887
1903
  }).meta({
1888
1904
  description: "Administrative area input field",
@@ -1893,7 +1909,10 @@ var LocationInput = BaseField.extend({
1893
1909
  defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
1894
1910
  configuration: import_v43.default.object({
1895
1911
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
1896
- allowedLocations: AllowedLocations
1912
+ allowedLocations: AllowedLocations,
1913
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
1914
+ "Advanced search: list every historical name a location has had as a separate, selectable option."
1915
+ )
1897
1916
  }).optional()
1898
1917
  }).meta({
1899
1918
  description: "A field for selecting a location",
@@ -1919,12 +1938,18 @@ var FileUploadWithOptions = BaseField.extend({
1919
1938
  var Facility = BaseField.extend({
1920
1939
  type: import_v43.default.literal(FieldType.FACILITY),
1921
1940
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1922
- configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
1941
+ configuration: import_v43.default.object({
1942
+ allowedLocations: AllowedLocations,
1943
+ listHistoricalNames: import_v43.default.boolean().optional()
1944
+ }).optional()
1923
1945
  }).describe("Input field for a facility");
1924
1946
  var Office = BaseField.extend({
1925
1947
  type: import_v43.default.literal(FieldType.OFFICE),
1926
1948
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1927
- configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
1949
+ configuration: import_v43.default.object({
1950
+ allowedLocations: AllowedLocations,
1951
+ listHistoricalNames: import_v43.default.boolean().optional()
1952
+ }).optional()
1928
1953
  }).describe("Input field for an office");
1929
1954
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
1930
1955
  administrativeArea: import_v43.default.union([UUID, SerializedUserField]).optional()
@@ -1957,7 +1982,13 @@ var Address = BaseField.extend({
1957
1982
  parent: FieldReference.optional()
1958
1983
  })
1959
1984
  ).optional(),
1960
- allowedLocations: AllowedLocations
1985
+ allowedLocations: AllowedLocations,
1986
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
1987
+ "Advanced search: list every historical name a location has had as a separate, selectable option. Propagated to the embedded admin-area selectors."
1988
+ ),
1989
+ activeOnly: import_v43.default.boolean().optional().describe(
1990
+ "Advanced search: offer only currently-active admin areas; inactivated ones are excluded. Propagated to the embedded admin-area selectors."
1991
+ )
1961
1992
  }).optional(),
1962
1993
  defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
1963
1994
  }).meta({