@opencrvs/toolkit 2.1.0-rc.ecb508d → 2.1.0-rc.f29a266

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 (69) 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 +254 -197
  6. package/dist/cli.js +195 -73
  7. package/dist/commons/api/router.d.ts +672 -57
  8. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  9. package/dist/commons/conditionals/validate.d.ts +16 -5
  10. package/dist/commons/events/ActionDocument.d.ts +5 -11
  11. package/dist/commons/events/ActionInput.d.ts +4 -4
  12. package/dist/commons/events/ActionStatus.d.ts +14 -0
  13. package/dist/commons/events/AdvancedSearchConfig.d.ts +18 -0
  14. package/dist/commons/events/AuditLog.d.ts +147 -0
  15. package/dist/commons/events/EventConfig.d.ts +3 -0
  16. package/dist/commons/events/EventDocument.d.ts +2 -2
  17. package/dist/commons/events/EventIndex.d.ts +3 -26
  18. package/dist/commons/events/FieldConfig.d.ts +83 -53
  19. package/dist/commons/events/FieldTypeMapping.d.ts +19 -19
  20. package/dist/commons/events/FieldValue.d.ts +2 -2
  21. package/dist/commons/events/Flag.d.ts +42 -0
  22. package/dist/commons/events/PlainDate.d.ts +8 -0
  23. package/dist/commons/events/SummaryConfig.d.ts +249 -0
  24. package/dist/commons/events/WorkqueueConfig.d.ts +17 -14
  25. package/dist/commons/events/event.d.ts +12 -0
  26. package/dist/commons/events/index.d.ts +1 -0
  27. package/dist/commons/events/locationPayloads.d.ts +95 -0
  28. package/dist/commons/events/locations.d.ts +163 -24
  29. package/dist/commons/events/mocks.test.utils.d.ts +30 -0
  30. package/dist/commons/events/test.utils.d.ts +8 -4
  31. package/dist/commons/events/utils.d.ts +2 -2
  32. package/dist/commons/notification/UserNotifications.d.ts +28 -0
  33. package/dist/conditionals/index.js +308 -55
  34. package/dist/environment/index.d.ts +1 -0
  35. package/dist/environment/index.d.ts.map +1 -1
  36. package/dist/environment/index.js +10 -0
  37. package/dist/environment/logger.d.ts +12 -3
  38. package/dist/environment/logger.d.ts.map +1 -1
  39. package/dist/environment/paths.d.ts +7 -0
  40. package/dist/environment/paths.d.ts.map +1 -0
  41. package/dist/environment/paths.js +72 -0
  42. package/dist/environment/questions.d.ts.map +1 -1
  43. package/dist/environment/questions.js +20 -14
  44. package/dist/environment/setup-environment.js +3 -2
  45. package/dist/environment/templates.d.ts.map +1 -1
  46. package/dist/environment/templates.js +2 -1
  47. package/dist/environment/update-workflows.d.ts.map +1 -1
  48. package/dist/environment/update-workflows.js +17 -5
  49. package/dist/environment/upgrade.d.ts +2 -0
  50. package/dist/environment/upgrade.d.ts.map +1 -0
  51. package/dist/environment/upgrade.js +82 -0
  52. package/dist/environment/users.js +11 -13
  53. package/dist/events/index.js +3621 -3243
  54. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
  55. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  56. package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
  57. package/dist/notification/index.js +1400 -1033
  58. package/dist/scopes/index.d.ts +253 -26
  59. package/dist/scopes/index.js +309 -55
  60. package/dist/templates/charts-values/opencrvs-services/values.yaml +4 -3
  61. package/dist/templates/charts-values/opentelemetry/values.yaml +95 -0
  62. package/dist/templates/charts-values/traefik/values.yaml +23 -9
  63. package/dist/templates/inventory/inventory.template.yml +1 -3
  64. package/opencrvs-toolkit-2.1.0-rc.f29a266.tgz +0 -0
  65. package/package.json +5 -5
  66. package/tsconfig.tsbuildinfo +1 -1
  67. package/dist/templates/inventory/production.example.yml +0 -77
  68. package/dist/templates/inventory/qa.example.yml +0 -48
  69. package/opencrvs-toolkit-2.1.0-rc.ecb508d.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,14 +711,20 @@ 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",
646
718
  "user.data-seeding",
647
719
  "integration.create",
720
+ // Reading an integration's audit log. Deliberately separate from
721
+ // 'integration.create' so read-only oversight can be granted on its own, and
722
+ // deliberately option-less: system clients have no office and no
723
+ // administrative area, so jurisdiction options would have nothing to bind to.
724
+ "integration.audit.read",
648
725
  "record.import",
649
726
  "config.update-all",
727
+ "location.edit",
650
728
  "attachment.upload",
651
729
  "profile.electronic-signature",
652
730
  "user.read-only-my-audit",
@@ -658,15 +736,15 @@ var PlainScopeType = z11.enum([
658
736
  "record.confirm-registration",
659
737
  "record.reject-registration"
660
738
  ]);
661
- var scopeByEvent = z11.preprocess(
739
+ var scopeByEvent = z12.preprocess(
662
740
  (val) => val === void 0 ? void 0 : [val].flat(),
663
- z11.array(z11.string()).optional()
741
+ z12.array(z12.string()).optional()
664
742
  ).describe("Event type, e.g. birth, death");
665
- var userRole = z11.preprocess(
743
+ var userRole = z12.preprocess(
666
744
  (val) => val === void 0 ? void 0 : [val].flat(),
667
- z11.array(z11.string()).optional()
745
+ z12.array(z12.string()).optional()
668
746
  ).describe("User role, e.g. admin, field agent");
669
- var scopeOptionsPlaceEvent = z11.object({
747
+ var scopeOptionsPlaceEvent = z12.object({
670
748
  event: scopeByEvent,
671
749
  placeOfEvent: JurisdictionFilter.optional()
672
750
  }).describe("Options applicable to all record scopes.");
@@ -678,36 +756,37 @@ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
678
756
  }).describe("Options applicable to actions that may take place after DECLARE");
679
757
  var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
680
758
  registeredIn: JurisdictionFilter.optional(),
681
- registeredBy: UserFilter.optional()
759
+ registeredBy: UserFilter.optional(),
760
+ flags: ContainsFlags.optional()
682
761
  }).describe(
683
762
  "Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
684
763
  );
685
764
  var CustomActionScopeOptions = AllRecordScopeOptions.extend({
686
- customActionTypes: z11.preprocess(
765
+ customActionTypes: z12.preprocess(
687
766
  (val) => val === void 0 ? void 0 : [val].flat(),
688
- z11.array(z11.string()).optional()
767
+ z12.array(z12.string()).optional()
689
768
  ).describe("Allowed custom action types")
690
769
  });
691
- var AccessLevelOptions = z11.object({
770
+ var AccessLevelOptions = z12.object({
692
771
  accessLevel: JurisdictionFilter.optional()
693
772
  });
694
773
  var AllUserScopeOptions = AccessLevelOptions.extend({
695
774
  role: userRole.optional()
696
775
  });
697
- var WorkqueueOrDashboardOptions = z11.object({
698
- ids: z11.preprocess(
776
+ var WorkqueueOrDashboardOptions = z12.object({
777
+ ids: z12.preprocess(
699
778
  (val) => val === void 0 ? void 0 : [val].flat(),
700
- z11.array(z11.string())
779
+ z12.array(z12.string())
701
780
  ).describe("Must contain a list of workqueue or dashboard ids.")
702
781
  });
703
- var AllScopeOptions = z11.object({
782
+ var AllScopeOptions = z12.object({
704
783
  ...AllRecordScopeOptions.shape,
705
784
  ...AccessLevelOptions.shape,
706
785
  ...AllUserScopeOptions.shape,
707
786
  ...WorkqueueOrDashboardOptions.shape
708
787
  });
709
788
  var ScopeOptionKey = AllScopeOptions.keyof();
710
- var ResolvedScopeOptionsPlaceEvent = z11.object({
789
+ var ResolvedScopeOptionsPlaceEvent = z12.object({
711
790
  event: scopeByEvent,
712
791
  placeOfEvent: UUID.nullish()
713
792
  }).describe(
@@ -715,15 +794,16 @@ var ResolvedScopeOptionsPlaceEvent = z11.object({
715
794
  );
716
795
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
717
796
  notifiedIn: UUID.nullish(),
718
- notifiedBy: z11.string().optional(),
797
+ notifiedBy: z12.string().optional(),
719
798
  declaredIn: UUID.nullish(),
720
- declaredBy: z11.string().optional()
799
+ declaredBy: z12.string().optional()
721
800
  }).describe(
722
801
  "Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
723
802
  );
724
803
  var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
725
804
  registeredIn: UUID.nullish(),
726
- registeredBy: z11.string().optional()
805
+ registeredBy: z12.string().optional(),
806
+ flags: ContainsFlags.optional()
727
807
  }).describe(
728
808
  "Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
729
809
  );
@@ -748,38 +828,38 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
748
828
  "record.unassign-others"
749
829
  ]);
750
830
  var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
751
- templates: z11.preprocess(
831
+ templates: z12.preprocess(
752
832
  (val) => val === void 0 ? void 0 : [val].flat(),
753
- z11.array(z11.string()).optional()
833
+ z12.array(z12.string()).optional()
754
834
  ).describe(
755
835
  "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."
756
836
  )
757
837
  });
758
- var RecordScopeV2 = z11.discriminatedUnion("type", [
759
- z11.object({
838
+ var RecordScopeV2 = z12.discriminatedUnion("type", [
839
+ z12.object({
760
840
  type: ScopesWithPlaceEventOptions,
761
841
  options: scopeOptionsPlaceEvent.optional()
762
842
  }),
763
- z11.object({
843
+ z12.object({
764
844
  type: ScopesWithDeclaredOptions,
765
845
  options: scopeOptionsDeclaredOrNotified.optional()
766
846
  }),
767
- z11.object({
847
+ z12.object({
768
848
  type: ScopesWithFullOptions,
769
849
  options: AllRecordScopeOptions.optional()
770
850
  }),
771
- z11.object({
772
- type: z11.literal("record.custom-action"),
851
+ z12.object({
852
+ type: z12.literal("record.custom-action"),
773
853
  options: CustomActionScopeOptions.optional()
774
854
  }),
775
- z11.object({
776
- type: z11.literal("record.print-certified-copies"),
855
+ z12.object({
856
+ type: z12.literal("record.print-certified-copies"),
777
857
  options: ScopeOptionsPrintCertifiedCopies.optional()
778
858
  })
779
859
  ]).describe(
780
860
  "Scopes used to check user's permission to perform actions on a record."
781
861
  );
782
- var SystemScopeType = z11.enum([
862
+ var SystemScopeType = z12.enum([
783
863
  "organisation.read-locations",
784
864
  "user.read",
785
865
  "user.create",
@@ -793,61 +873,61 @@ var UserScopeType = SystemScopeType.extract([
793
873
  "user.search"
794
874
  ]);
795
875
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
796
- var UserScopeV2 = z11.discriminatedUnion("type", [
797
- z11.object({
876
+ var UserScopeV2 = z12.discriminatedUnion("type", [
877
+ z12.object({
798
878
  type: ScopesWithRoleOption,
799
879
  options: AllUserScopeOptions.optional()
800
880
  }),
801
- z11.object({
881
+ z12.object({
802
882
  type: UserScopeType.extract(["user.read", "user.search"]),
803
883
  options: AccessLevelOptions.optional()
804
884
  })
805
885
  ]);
806
- var ResolvedRecordScopeV2 = z11.discriminatedUnion("type", [
807
- z11.object({
886
+ var ResolvedRecordScopeV2 = z12.discriminatedUnion("type", [
887
+ z12.object({
808
888
  type: ScopesWithPlaceEventOptions,
809
889
  options: ResolvedScopeOptionsPlaceEvent.optional()
810
890
  }),
811
- z11.object({
891
+ z12.object({
812
892
  type: ScopesWithDeclaredOptions,
813
893
  options: ResolvedScopeOptionsDeclared.optional()
814
894
  }),
815
- z11.object({
895
+ z12.object({
816
896
  type: ScopesWithFullOptions,
817
897
  options: ResolvedScopeOptionsFull.optional()
818
898
  }),
819
- z11.object({
820
- type: z11.literal("record.print-certified-copies"),
899
+ z12.object({
900
+ type: z12.literal("record.print-certified-copies"),
821
901
  options: ResolvedScopeOptionsFull.extend({
822
- templates: z11.array(z11.string()).optional()
902
+ templates: z12.array(z12.string()).optional()
823
903
  }).optional()
824
904
  })
825
905
  ]).describe("Resolved scope with location/user IDs instead of filters.");
826
- var Scope = z11.discriminatedUnion("type", [
827
- z11.object({ type: PlainScopeType }),
906
+ var Scope = z12.discriminatedUnion("type", [
907
+ z12.object({ type: PlainScopeType }),
828
908
  ...RecordScopeV2.options,
829
909
  ...UserScopeV2.options,
830
- z11.object({
831
- type: z11.literal("organisation.read-locations"),
910
+ z12.object({
911
+ type: z12.literal("organisation.read-locations"),
832
912
  options: AccessLevelOptions.optional()
833
913
  }),
834
- z11.object({
835
- type: z11.literal("workqueue"),
914
+ z12.object({
915
+ type: z12.literal("workqueue"),
836
916
  options: WorkqueueOrDashboardOptions
837
917
  }),
838
- z11.object({
839
- type: z11.literal("dashboard.view"),
918
+ z12.object({
919
+ type: z12.literal("dashboard.view"),
840
920
  options: WorkqueueOrDashboardOptions
841
921
  })
842
922
  ]);
843
- var ScopeType = z11.enum([
923
+ var ScopeType = z12.enum([
844
924
  ...SystemScopeType.options,
845
925
  ...RecordScopeTypeV2.options,
846
926
  ...PlainScopeType.options,
847
927
  "workqueue",
848
928
  "dashboard.view"
849
929
  ]);
850
- var EncodedScope = z11.string().brand("EncodedScope");
930
+ var EncodedScope = z12.string().brand("EncodedScope");
851
931
  var DEFAULT_SCOPE_OPTIONS = {
852
932
  placeOfEvent: JurisdictionFilter.enum.all,
853
933
  accessLevel: JurisdictionFilter.enum.all,
@@ -857,30 +937,25 @@ var DEFAULT_SCOPE_OPTIONS = {
857
937
  };
858
938
 
859
939
  // ../commons/src/authentication.ts
860
- var TokenUserType = z12.enum(["user", "system"]);
861
- var TokenWithBearer = z12.string().regex(/^Bearer\s/);
940
+ var TokenUserType = z13.enum(["user", "system"]);
941
+ var TokenWithBearer = z13.string().regex(/^Bearer\s/);
862
942
 
863
943
  // ../commons/src/events/ActionDocument.ts
864
- var ActionUpdate = z13.record(z13.string(), FieldUpdateValue).describe(
944
+ var ActionUpdate = z14.record(z14.string(), FieldUpdateValue).describe(
865
945
  "Record of field-level changes made by an action. Supports partial updates and nullable values."
866
946
  );
867
- var EventState = z13.record(z13.string(), FieldValue).describe(
947
+ var EventState = z14.record(z14.string(), FieldValue).describe(
868
948
  "Aggregate representation of event data after all actions have been applied, with all updates consolidated and null values removed."
869
949
  );
870
- var ActionStatus = {
871
- Requested: "Requested",
872
- Accepted: "Accepted",
873
- Rejected: "Rejected"
874
- };
875
- var ActionBase = z13.object({
950
+ var ActionBase = z14.object({
876
951
  id: UUID.describe("Unique identifier of the action."),
877
- transactionId: z13.string().describe("Unique identifier of the transaction."),
952
+ transactionId: z14.string().describe("Unique identifier of the transaction."),
878
953
  createdByUserType: TokenUserType.describe(
879
954
  "Indicates whether the action was created by a human-user or by a system-user."
880
955
  ),
881
- createdAt: z13.string().datetime().describe("Timestamp indicating when the action was created."),
882
- createdBy: z13.string().describe("Identifier of the user who created the action."),
883
- createdByRole: z13.string().optional().describe("Role of the user who created the action."),
956
+ createdAt: z14.string().datetime().describe("Timestamp indicating when the action was created."),
957
+ createdBy: z14.string().describe("Identifier of the user who created the action."),
958
+ createdByRole: z14.string().optional().describe("Role of the user who created the action."),
884
959
  createdBySignature: DocumentPath.nullish().describe(
885
960
  "Reference to the signature of the user who created the action."
886
961
  ),
@@ -892,7 +967,7 @@ var ActionBase = z13.object({
892
967
  "Declaration data defined by the ActionConfig. Supports partial updates."
893
968
  ),
894
969
  annotation: ActionUpdate.optional().nullable().describe("Action-specific metadata used to annotate the event."),
895
- status: z13.enum([
970
+ status: z14.enum([
896
971
  ActionStatus.Requested,
897
972
  ActionStatus.Accepted,
898
973
  ActionStatus.Rejected
@@ -904,139 +979,143 @@ var ActionBase = z13.object({
904
979
  )
905
980
  });
906
981
  var AssignedAction = ActionBase.extend(
907
- z13.object({
908
- type: z13.literal(ActionType.ASSIGN),
909
- assignedTo: z13.string().describe("Identifier of the user to whom the action is assigned.")
982
+ z14.object({
983
+ type: z14.literal(ActionType.ASSIGN),
984
+ assignedTo: z14.string().describe("Identifier of the user to whom the action is assigned.")
910
985
  // TODO move into 'content' property
911
986
  }).shape
912
987
  );
913
988
  var UnassignedAction = ActionBase.extend(
914
- z13.object({
915
- type: z13.literal(ActionType.UNASSIGN)
989
+ z14.object({
990
+ type: z14.literal(ActionType.UNASSIGN)
916
991
  }).shape
917
992
  );
918
993
  var RegisterAction = ActionBase.extend(
919
- z13.object({
920
- type: z13.literal(ActionType.REGISTER),
921
- registrationNumber: z13.string().optional().describe(
994
+ z14.object({
995
+ type: z14.literal(ActionType.REGISTER),
996
+ registrationNumber: z14.string().optional().describe(
922
997
  "Registration number of the event. Always present for accepted registrations."
923
998
  )
924
999
  // TODO move into 'content' property
925
1000
  }).shape
926
1001
  );
927
1002
  var DeclareAction = ActionBase.extend(
928
- z13.object({
929
- type: z13.literal(ActionType.DECLARE)
1003
+ z14.object({
1004
+ type: z14.literal(ActionType.DECLARE)
930
1005
  }).shape
931
1006
  );
932
- var ReasonContent = z13.object({
933
- reason: z13.string().min(1, { error: "Message cannot be empty" }).describe(
1007
+ var ReasonContent = z14.object({
1008
+ reason: z14.string().min(1, { error: "Message cannot be empty" }).describe(
934
1009
  "Message describing the reason for rejecting or archiving the event."
935
1010
  )
936
1011
  });
937
1012
  var RejectAction = ActionBase.extend(
938
- z13.object({
939
- type: z13.literal(ActionType.REJECT),
1013
+ z14.object({
1014
+ type: z14.literal(ActionType.REJECT),
940
1015
  content: ReasonContent
941
1016
  }).shape
942
1017
  );
943
- var PotentialDuplicate = z13.object({
1018
+ var PotentialDuplicate = z14.object({
944
1019
  id: UUID,
945
- trackingId: z13.string()
1020
+ trackingId: z14.string()
946
1021
  });
947
1022
  var DuplicateDetectedAction = ActionBase.extend(
948
- z13.object({
949
- type: z13.literal(ActionType.DUPLICATE_DETECTED),
950
- content: z13.object({
951
- duplicates: z13.array(PotentialDuplicate)
1023
+ z14.object({
1024
+ type: z14.literal(ActionType.DUPLICATE_DETECTED),
1025
+ content: z14.object({
1026
+ duplicates: z14.array(PotentialDuplicate)
952
1027
  })
953
1028
  }).shape
954
1029
  );
955
1030
  var MarkNotDuplicateAction = ActionBase.extend(
956
- z13.object({
957
- type: z13.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1031
+ z14.object({
1032
+ type: z14.literal(ActionType.MARK_AS_NOT_DUPLICATE)
958
1033
  }).shape
959
1034
  );
960
1035
  var MarkAsDuplicateAction = ActionBase.extend(
961
- z13.object({
962
- type: z13.literal(ActionType.MARK_AS_DUPLICATE),
963
- content: z13.object({
1036
+ z14.object({
1037
+ type: z14.literal(ActionType.MARK_AS_DUPLICATE),
1038
+ content: z14.object({
964
1039
  duplicateOf: UUID
965
1040
  }).optional()
966
1041
  }).shape
967
1042
  );
968
1043
  var ArchiveAction = ActionBase.extend(
969
- z13.object({
970
- type: z13.literal(ActionType.ARCHIVE),
971
- content: ReasonContent
1044
+ z14.object({
1045
+ type: z14.literal(ActionType.ARCHIVE),
1046
+ /**
1047
+ * Archiving does not collect a reason on its own. Only the
1048
+ * "mark as duplicate" flow archives with a reason attached.
1049
+ */
1050
+ content: ReasonContent.optional()
972
1051
  }).shape
973
1052
  );
974
1053
  var UnarchiveAction = ActionBase.extend(
975
- z13.object({
976
- type: z13.literal(ActionType.UNARCHIVE)
1054
+ z14.object({
1055
+ type: z14.literal(ActionType.UNARCHIVE)
977
1056
  }).shape
978
1057
  );
979
1058
  var CreatedAction = ActionBase.extend(
980
- z13.object({
981
- type: z13.literal(ActionType.CREATE)
1059
+ z14.object({
1060
+ type: z14.literal(ActionType.CREATE)
982
1061
  }).shape
983
1062
  );
984
1063
  var NotifiedAction = ActionBase.extend(
985
- z13.object({
986
- type: z13.literal(ActionType.NOTIFY)
1064
+ z14.object({
1065
+ type: z14.literal(ActionType.NOTIFY)
987
1066
  }).shape
988
1067
  );
989
1068
  var EditAction = ActionBase.extend(
990
- z13.object({
991
- type: z13.literal(ActionType.EDIT),
1069
+ z14.object({
1070
+ type: z14.literal(ActionType.EDIT),
992
1071
  /** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
993
- content: z13.object({
994
- comment: z13.string().describe("Comment for the edit action.").optional()
1072
+ content: z14.object({
1073
+ comment: z14.string().describe("Comment for the edit action.").optional()
995
1074
  }).optional()
996
1075
  }).shape
997
1076
  );
998
- var PrintContent = z13.object({
999
- templateId: z13.string().optional()
1077
+ var PrintContent = z14.object({
1078
+ templateId: z14.string().optional()
1000
1079
  });
1001
1080
  var PrintCertificateAction = ActionBase.extend(
1002
- z13.object({
1003
- type: z13.literal(ActionType.PRINT_CERTIFICATE),
1081
+ z14.object({
1082
+ type: z14.literal(ActionType.PRINT_CERTIFICATE),
1004
1083
  content: PrintContent.optional().nullable()
1005
1084
  }).shape
1006
1085
  );
1007
1086
  var RequestedCorrectionAction = ActionBase.extend(
1008
- z13.object({
1009
- type: z13.literal(ActionType.REQUEST_CORRECTION)
1087
+ z14.object({
1088
+ type: z14.literal(ActionType.REQUEST_CORRECTION)
1010
1089
  }).shape
1011
1090
  );
1012
1091
  var ApprovedCorrectionAction = ActionBase.extend(
1013
- z13.object({
1014
- type: z13.literal(ActionType.APPROVE_CORRECTION),
1015
- requestId: z13.string(),
1092
+ z14.object({
1093
+ type: z14.literal(ActionType.APPROVE_CORRECTION),
1094
+ requestId: z14.string(),
1016
1095
  // TODO move into 'content' property
1017
- content: z13.object({ immediateCorrection: z13.boolean().optional() }).optional()
1096
+ content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
1018
1097
  }).shape
1019
1098
  );
1020
1099
  var RejectedCorrectionAction = ActionBase.extend(
1021
- z13.object({
1022
- type: z13.literal(ActionType.REJECT_CORRECTION),
1023
- requestId: z13.string(),
1100
+ z14.object({
1101
+ type: z14.literal(ActionType.REJECT_CORRECTION),
1102
+ requestId: z14.string(),
1024
1103
  // TODO move into 'content' property
1025
1104
  content: ReasonContent
1026
1105
  }).shape
1027
1106
  );
1028
1107
  var ReadAction = ActionBase.extend(
1029
- z13.object({
1030
- type: z13.literal(ActionType.READ)
1108
+ z14.object({
1109
+ type: z14.literal(ActionType.READ)
1031
1110
  }).shape
1032
1111
  );
1033
1112
  var CustomAction = ActionBase.merge(
1034
- z13.object({
1035
- type: z13.literal(ActionType.CUSTOM),
1036
- customActionType: z13.string()
1113
+ z14.object({
1114
+ type: z14.literal(ActionType.CUSTOM),
1115
+ customActionType: z14.string()
1037
1116
  })
1038
1117
  );
1039
- var ActionDocument = z13.discriminatedUnion("type", [
1118
+ var ActionDocument = z14.discriminatedUnion("type", [
1040
1119
  CreatedAction.meta({ id: "CreatedAction" }),
1041
1120
  RejectAction.meta({ id: "RejectAction" }),
1042
1121
  DuplicateDetectedAction.meta({ id: "DuplicateDetectedAction" }),
@@ -1063,64 +1142,12 @@ var AsyncRejectActionDocument = ActionBase.omit({
1063
1142
  declaration: true,
1064
1143
  annotation: true
1065
1144
  }).extend(
1066
- z13.object({
1067
- type: z13.enum(ConfirmableActions),
1068
- status: z13.literal(ActionStatus.Rejected)
1145
+ z14.object({
1146
+ type: z14.enum(ConfirmableActions),
1147
+ status: z14.literal(ActionStatus.Rejected)
1069
1148
  }).shape
1070
1149
  );
1071
- var Action = z13.union([ActionDocument, AsyncRejectActionDocument]);
1072
-
1073
- // ../commons/src/events/Flag.ts
1074
- var z14 = __toESM(require("zod/v4"));
1075
- var InherentFlags = {
1076
- INCOMPLETE: "incomplete",
1077
- REJECTED: "rejected",
1078
- CORRECTION_REQUESTED: "correction-requested",
1079
- POTENTIAL_DUPLICATE: "potential-duplicate",
1080
- /**
1081
- * This flag is set by the Edit-action and removed after the declaration or registration.
1082
- * A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
1083
- *
1084
- * We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
1085
- */
1086
- EDIT_IN_PROGRESS: "edit-in-progress"
1087
- };
1088
- var ActionFlag = z14.string().regex(
1089
- new RegExp(
1090
- `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
1091
- ActionStatus
1092
- ).join("|").toLowerCase()})$`
1093
- ),
1094
- "Flag must be in the format ActionType:ActionStatus (lowerCase)"
1095
- );
1096
- var CustomFlag = z14.string().refine((val) => !Object.values(InherentFlags).includes(val), {
1097
- message: `Custom flag cannot be one of the inherent flags: ${Object.values(
1098
- InherentFlags
1099
- ).join(", ")}`
1100
- }).refine((val) => !ActionFlag.safeParse(val).success, {
1101
- message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
1102
- }).describe("Custom flag identifier defined by the country config.");
1103
- var Flag = ActionFlag.or(z14.enum(InherentFlags)).or(CustomFlag);
1104
- var FlagConfig = z14.object({
1105
- id: CustomFlag,
1106
- requiresAction: z14.boolean().describe(
1107
- "Indicates if this flag expects an action to be performed to be cleared."
1108
- ),
1109
- label: TranslationConfig.describe("Human readable label of the flag.")
1110
- }).meta({
1111
- id: "FlagConfig",
1112
- description: "Configuration for a custom flag that can be added to or removed from records by event actions."
1113
- });
1114
- var ActionFlagConfig = z14.object({
1115
- id: Flag,
1116
- operation: z14.enum(["add", "remove"]).describe("Operation to perform on the flag."),
1117
- conditional: Conditional.optional().describe(
1118
- "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
1119
- )
1120
- }).meta({
1121
- id: "ActionFlagConfig",
1122
- description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
1123
- });
1150
+ var Action = z14.union([ActionDocument, AsyncRejectActionDocument]);
1124
1151
 
1125
1152
  // ../commons/src/events/EventMetadata.ts
1126
1153
  var EventStatus = z15.enum([
@@ -1281,13 +1308,6 @@ var Range = import_v4.z.object({
1281
1308
  }).meta({
1282
1309
  id: "Range"
1283
1310
  });
1284
- var ContainsFlags = import_v4.z.object({
1285
- anyOf: import_v4.z.array(Flag).optional(),
1286
- noneOf: import_v4.z.array(Flag).optional(),
1287
- allOf: import_v4.z.array(Flag).optional()
1288
- }).meta({
1289
- id: "ContainsFlags"
1290
- });
1291
1311
  var Within = import_v4.z.object({ type: import_v4.z.literal("within"), location: import_v4.z.string() }).meta({
1292
1312
  id: "Within"
1293
1313
  });
@@ -1482,8 +1502,8 @@ var BaseField = import_v43.default.object({
1482
1502
  conditionals: import_v43.default.array(FieldConditional).default([]).optional().describe(
1483
1503
  "Conditions determining when the field is shown or enabled. By default, the field is always shown and enabled."
1484
1504
  ),
1485
- secured: import_v43.default.boolean().default(false).optional().describe(
1486
- "Indicates whether the field is secured. Secured fields are not indexed for search and are only visible when explicitly assigned."
1505
+ secured: import_v43.default.union([import_v43.default.boolean(), Conditional]).default(false).optional().describe(
1506
+ "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."
1487
1507
  ),
1488
1508
  placeholder: TranslationConfig.optional(),
1489
1509
  validation: import_v43.default.array(ValidationConfig).default([]).optional().describe("Additional validation rules applied to the field."),
@@ -1881,7 +1901,16 @@ var AdministrativeAreaField = BaseField.extend({
1881
1901
  configuration: import_v43.default.object({
1882
1902
  partOf: FieldReference.optional().describe("Parent location"),
1883
1903
  type: AdministrativeAreas,
1884
- allowedLocations: AllowedLocations
1904
+ allowedLocations: AllowedLocations,
1905
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
1906
+ "List every historical name a location has had as a separate, selectable option."
1907
+ ),
1908
+ activeOnly: import_v43.default.boolean().optional().describe(
1909
+ "Offer only locations that are active at the resolved anchor date (today, or the date of event when anchorToDateOfEvent is set); inactive or not-yet-effective versions are excluded."
1910
+ ),
1911
+ anchorToDateOfEvent: import_v43.default.boolean().optional().describe(
1912
+ "Resolve selectable/displayed versions against the event's date of event (falling back to the record's creation date when empty) instead of today. Does not by itself exclude inactive versions; combine with activeOnly for that."
1913
+ )
1885
1914
  }).describe("Administrative area options")
1886
1915
  }).meta({
1887
1916
  description: "Administrative area input field",
@@ -1892,7 +1921,16 @@ var LocationInput = BaseField.extend({
1892
1921
  defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
1893
1922
  configuration: import_v43.default.object({
1894
1923
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
1895
- allowedLocations: AllowedLocations
1924
+ allowedLocations: AllowedLocations,
1925
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
1926
+ "List every historical name a location has had as a separate, selectable option."
1927
+ ),
1928
+ activeOnly: import_v43.default.boolean().optional().describe(
1929
+ "Offer only locations that are active at the resolved anchor date (today, or the date of event when anchorToDateOfEvent is set); inactive or not-yet-effective versions are excluded."
1930
+ ),
1931
+ anchorToDateOfEvent: import_v43.default.boolean().optional().describe(
1932
+ "Resolve selectable/displayed versions against the event's date of event (falling back to the record's creation date when empty) instead of today. Does not by itself exclude inactive versions; combine with activeOnly for that."
1933
+ )
1896
1934
  }).optional()
1897
1935
  }).meta({
1898
1936
  description: "A field for selecting a location",
@@ -1918,12 +1956,22 @@ var FileUploadWithOptions = BaseField.extend({
1918
1956
  var Facility = BaseField.extend({
1919
1957
  type: import_v43.default.literal(FieldType.FACILITY),
1920
1958
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1921
- configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
1959
+ configuration: import_v43.default.object({
1960
+ allowedLocations: AllowedLocations,
1961
+ listHistoricalNames: import_v43.default.boolean().optional(),
1962
+ activeOnly: import_v43.default.boolean().optional(),
1963
+ anchorToDateOfEvent: import_v43.default.boolean().optional()
1964
+ }).optional()
1922
1965
  }).describe("Input field for a facility");
1923
1966
  var Office = BaseField.extend({
1924
1967
  type: import_v43.default.literal(FieldType.OFFICE),
1925
1968
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1926
- configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
1969
+ configuration: import_v43.default.object({
1970
+ allowedLocations: AllowedLocations,
1971
+ listHistoricalNames: import_v43.default.boolean().optional(),
1972
+ activeOnly: import_v43.default.boolean().optional(),
1973
+ anchorToDateOfEvent: import_v43.default.boolean().optional()
1974
+ }).optional()
1927
1975
  }).describe("Input field for an office");
1928
1976
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
1929
1977
  administrativeArea: import_v43.default.union([UUID, SerializedUserField]).optional()
@@ -1956,7 +2004,16 @@ var Address = BaseField.extend({
1956
2004
  parent: FieldReference.optional()
1957
2005
  })
1958
2006
  ).optional(),
1959
- allowedLocations: AllowedLocations
2007
+ allowedLocations: AllowedLocations,
2008
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
2009
+ "List every historical name a location has had as a separate, selectable option. Propagated to the embedded admin-area selectors."
2010
+ ),
2011
+ activeOnly: import_v43.default.boolean().optional().describe(
2012
+ "Offer only admin areas that are active at the resolved anchor date (today, or the date of event when anchorToDateOfEvent is set); inactive or not-yet-effective versions are excluded. Propagated to the embedded admin-area selectors."
2013
+ ),
2014
+ anchorToDateOfEvent: import_v43.default.boolean().optional().describe(
2015
+ "Resolve selectable/displayed versions against the event's date of event (falling back to the record's creation date when empty) instead of today. Does not by itself exclude inactive versions; combine with activeOnly for that. Propagated to the embedded admin-area selectors."
2016
+ )
1960
2017
  }).optional(),
1961
2018
  defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
1962
2019
  }).meta({