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

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 (57) hide show
  1. package/build.sh +2 -2
  2. package/dist/application-config/index.js +212 -188
  3. package/dist/cli.js +165 -5154
  4. package/dist/commons/api/router.d.ts +758 -201
  5. package/dist/commons/conditionals/conditionals.d.ts +1592 -40
  6. package/dist/commons/conditionals/validate.d.ts +2 -1
  7. package/dist/commons/events/ActionConfig.d.ts +230 -0
  8. package/dist/commons/events/ActionDocument.d.ts +51 -13
  9. package/dist/commons/events/ActionInput.d.ts +26 -6
  10. package/dist/commons/events/ActionStatus.d.ts +14 -0
  11. package/dist/commons/events/ActionType.d.ts +6 -1
  12. package/dist/commons/events/AdvancedSearchConfig.d.ts +12 -0
  13. package/dist/commons/events/AuditLog.d.ts +2 -0
  14. package/dist/commons/events/CountryConfigQueryInput.d.ts +18 -0
  15. package/dist/commons/events/Draft.d.ts +2 -0
  16. package/dist/commons/events/EventDocument.d.ts +24 -2
  17. package/dist/commons/events/EventIndex.d.ts +5 -24
  18. package/dist/commons/events/EventMetadata.d.ts +2 -1
  19. package/dist/commons/events/FieldConfig.d.ts +10 -0
  20. package/dist/commons/events/Flag.d.ts +48 -0
  21. package/dist/commons/events/WorkqueueColumnConfig.d.ts +4 -4
  22. package/dist/commons/events/WorkqueueConfig.d.ts +25 -7
  23. package/dist/commons/events/field.d.ts +722 -34
  24. package/dist/commons/events/scopes.d.ts +1 -0
  25. package/dist/commons/events/test.utils.d.ts +9 -4
  26. package/dist/commons/events/utils.d.ts +26 -4
  27. package/dist/conditionals/index.js +305 -55
  28. package/dist/environment/derived-variables.d.ts +0 -12
  29. package/dist/environment/derived-variables.d.ts.map +1 -1
  30. package/dist/environment/derived-variables.js +0 -14
  31. package/dist/environment/logger.d.ts +3 -12
  32. package/dist/environment/logger.d.ts.map +1 -1
  33. package/dist/environment/manage-users.js +17 -7
  34. package/dist/environment/setup-environment.js +0 -14
  35. package/dist/environment/swarm-to-k8s.js +17 -7
  36. package/dist/environment/update-workflows.js +17 -7
  37. package/dist/environment/users.js +17 -7
  38. package/dist/environment/utils.js +17 -7
  39. package/dist/events/index.js +3330 -3128
  40. package/dist/migrations/v2.0/convert-config-files-to-ts.js +17 -7
  41. package/dist/migrations/v2.0/index.js +88 -5144
  42. package/dist/migrations/v2.0/remove-hearth-migrations.js +17 -7
  43. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +3 -0
  44. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +1 -0
  45. package/dist/migrations/v2.1/add-explicit-correction-flags.js +234 -0
  46. package/dist/migrations/v2.1/index.d.ts +6 -0
  47. package/dist/migrations/v2.1/index.d.ts.map +1 -0
  48. package/dist/migrations/v2.1/index.js +218 -0
  49. package/dist/notification/index.js +1557 -872
  50. package/dist/scopes/index.d.ts +257 -1
  51. package/dist/scopes/index.js +306 -55
  52. package/dist/templates/charts-values/dependencies/values.yaml +0 -3
  53. package/dist/templates/charts-values/opencrvs-services/values.yaml +0 -4
  54. package/opencrvs-toolkit-2.1.0-rc.b061691.tgz +0 -0
  55. package/package.json +3 -3
  56. package/tsconfig.tsbuildinfo +1 -1
  57. 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,89 @@ 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
+ SEALED: "sealed"
643
+ };
644
+ var actionFlagPattern;
645
+ function getActionFlagPattern() {
646
+ actionFlagPattern ??= new RegExp(
647
+ `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
648
+ ActionStatus
649
+ ).join("|").toLowerCase()})$`
650
+ );
651
+ return actionFlagPattern;
652
+ }
653
+ var ActionFlag = z11.string().refine((value) => getActionFlagPattern().test(value), {
654
+ message: "Flag must be in the format ActionType:ActionStatus (lowerCase)"
655
+ });
656
+ var CustomFlag = z11.string().refine((val) => !Object.values(InherentFlags).includes(val), {
657
+ message: `Custom flag cannot be one of the inherent flags: ${Object.values(
658
+ InherentFlags
659
+ ).join(", ")}`
660
+ }).refine((val) => !ActionFlag.safeParse(val).success, {
661
+ message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
662
+ }).describe("Custom flag identifier defined by the country config.");
663
+ var Flag = ActionFlag.or(z11.enum(InherentFlags)).or(CustomFlag);
664
+ var ContainsFlags = z11.object({
665
+ anyOf: z11.array(Flag).optional(),
666
+ noneOf: z11.array(Flag).optional(),
667
+ allOf: z11.array(Flag).optional()
668
+ }).meta({
669
+ id: "ContainsFlags"
670
+ });
671
+ var FlagConfig = z11.object({
672
+ id: CustomFlag,
673
+ requiresAction: z11.boolean().describe(
674
+ "Indicates if this flag expects an action to be performed to be cleared."
675
+ ),
676
+ label: TranslationConfig.describe("Human readable label of the flag.")
677
+ }).meta({
678
+ id: "FlagConfig",
679
+ description: "Configuration for a custom flag that can be added to or removed from records by event actions."
680
+ });
681
+ var ActionFlagConfig = z11.object({
682
+ id: Flag,
683
+ operation: z11.enum(["add", "remove"]).describe("Operation to perform on the flag."),
684
+ conditional: Conditional.optional().describe(
685
+ "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
686
+ )
687
+ }).meta({
688
+ id: "ActionFlagConfig",
689
+ description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
690
+ });
691
+
692
+ // ../commons/src/scopes.ts
693
+ var JurisdictionFilter = z12.enum(["administrativeArea", "location", "all"]).describe(
617
694
  "Filters based on user jurisdiction relative to their office location in hierarchy."
618
695
  );
619
- var UserFilter = z11.enum(["user"]).describe("Filters based on the user. Limits to self.");
620
- var RecordScopeTypeV2 = z11.enum([
696
+ var UserFilter = z12.enum(["user"]).describe("Filters based on the user. Limits to self.");
697
+ var RecordScopeTypeV2 = z12.enum([
621
698
  "record.search",
622
699
  "record.create",
623
700
  "record.read",
@@ -626,6 +703,7 @@ var RecordScopeTypeV2 = z11.enum([
626
703
  "record.edit",
627
704
  "record.reject",
628
705
  "record.archive",
706
+ "record.unarchive",
629
707
  "record.review-duplicates",
630
708
  "record.register",
631
709
  "record.print-certified-copies",
@@ -634,7 +712,7 @@ var RecordScopeTypeV2 = z11.enum([
634
712
  "record.unassign-others",
635
713
  "record.custom-action"
636
714
  ]);
637
- var PlainScopeType = z11.enum([
715
+ var PlainScopeType = z12.enum([
638
716
  // Misc. system scopes
639
717
  "bypassratelimit",
640
718
  "record.reindex",
@@ -653,15 +731,15 @@ 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
744
  placeOfEvent: JurisdictionFilter.optional()
667
745
  }).describe("Options applicable to all record scopes.");
@@ -673,36 +751,37 @@ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
673
751
  }).describe("Options applicable to actions that may take place after DECLARE");
674
752
  var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
675
753
  registeredIn: JurisdictionFilter.optional(),
676
- registeredBy: UserFilter.optional()
754
+ registeredBy: UserFilter.optional(),
755
+ flags: ContainsFlags.optional()
677
756
  }).describe(
678
757
  "Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
679
758
  );
680
759
  var CustomActionScopeOptions = AllRecordScopeOptions.extend({
681
- customActionTypes: z11.preprocess(
760
+ customActionTypes: z12.preprocess(
682
761
  (val) => val === void 0 ? void 0 : [val].flat(),
683
- z11.array(z11.string()).optional()
762
+ z12.array(z12.string()).optional()
684
763
  ).describe("Allowed custom action types")
685
764
  });
686
- var AccessLevelOptions = z11.object({
765
+ var AccessLevelOptions = z12.object({
687
766
  accessLevel: JurisdictionFilter.optional()
688
767
  });
689
768
  var AllUserScopeOptions = AccessLevelOptions.extend({
690
769
  role: userRole.optional()
691
770
  });
692
- var WorkqueueOrDashboardOptions = z11.object({
693
- ids: z11.preprocess(
771
+ var WorkqueueOrDashboardOptions = z12.object({
772
+ ids: z12.preprocess(
694
773
  (val) => val === void 0 ? void 0 : [val].flat(),
695
- z11.array(z11.string())
774
+ z12.array(z12.string())
696
775
  ).describe("Must contain a list of workqueue or dashboard ids.")
697
776
  });
698
- var AllScopeOptions = z11.object({
777
+ var AllScopeOptions = z12.object({
699
778
  ...AllRecordScopeOptions.shape,
700
779
  ...AccessLevelOptions.shape,
701
780
  ...AllUserScopeOptions.shape,
702
781
  ...WorkqueueOrDashboardOptions.shape
703
782
  });
704
783
  var ScopeOptionKey = AllScopeOptions.keyof();
705
- var ResolvedScopeOptionsPlaceEvent = z11.object({
784
+ var ResolvedScopeOptionsPlaceEvent = z12.object({
706
785
  event: scopeByEvent,
707
786
  placeOfEvent: UUID.nullish()
708
787
  }).describe(
@@ -710,15 +789,16 @@ var ResolvedScopeOptionsPlaceEvent = z11.object({
710
789
  );
711
790
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
712
791
  notifiedIn: UUID.nullish(),
713
- notifiedBy: z11.string().optional(),
792
+ notifiedBy: z12.string().optional(),
714
793
  declaredIn: UUID.nullish(),
715
- declaredBy: z11.string().optional()
794
+ declaredBy: z12.string().optional()
716
795
  }).describe(
717
796
  "Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
718
797
  );
719
798
  var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
720
799
  registeredIn: UUID.nullish(),
721
- registeredBy: z11.string().optional()
800
+ registeredBy: z12.string().optional(),
801
+ flags: ContainsFlags.optional()
722
802
  }).describe(
723
803
  "Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
724
804
  );
@@ -731,6 +811,7 @@ var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
731
811
  "record.edit",
732
812
  "record.reject",
733
813
  "record.archive",
814
+ "record.unarchive",
734
815
  "record.review-duplicates",
735
816
  "record.register"
736
817
  ]);
@@ -742,38 +823,38 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
742
823
  "record.unassign-others"
743
824
  ]);
744
825
  var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
745
- templates: z11.preprocess(
826
+ templates: z12.preprocess(
746
827
  (val) => val === void 0 ? void 0 : [val].flat(),
747
- z11.array(z11.string()).optional()
828
+ z12.array(z12.string()).optional()
748
829
  ).describe(
749
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."
750
831
  )
751
832
  });
752
- var RecordScopeV2 = z11.discriminatedUnion("type", [
753
- z11.object({
833
+ var RecordScopeV2 = z12.discriminatedUnion("type", [
834
+ z12.object({
754
835
  type: ScopesWithPlaceEventOptions,
755
836
  options: scopeOptionsPlaceEvent.optional()
756
837
  }),
757
- z11.object({
838
+ z12.object({
758
839
  type: ScopesWithDeclaredOptions,
759
840
  options: scopeOptionsDeclaredOrNotified.optional()
760
841
  }),
761
- z11.object({
842
+ z12.object({
762
843
  type: ScopesWithFullOptions,
763
844
  options: AllRecordScopeOptions.optional()
764
845
  }),
765
- z11.object({
766
- type: z11.literal("record.custom-action"),
846
+ z12.object({
847
+ type: z12.literal("record.custom-action"),
767
848
  options: CustomActionScopeOptions.optional()
768
849
  }),
769
- z11.object({
770
- type: z11.literal("record.print-certified-copies"),
850
+ z12.object({
851
+ type: z12.literal("record.print-certified-copies"),
771
852
  options: ScopeOptionsPrintCertifiedCopies.optional()
772
853
  })
773
854
  ]).describe(
774
855
  "Scopes used to check user's permission to perform actions on a record."
775
856
  );
776
- var SystemScopeType = z11.enum([
857
+ var SystemScopeType = z12.enum([
777
858
  "organisation.read-locations",
778
859
  "user.read",
779
860
  "user.create",
@@ -787,61 +868,61 @@ var UserScopeType = SystemScopeType.extract([
787
868
  "user.search"
788
869
  ]);
789
870
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
790
- var UserScopeV2 = z11.discriminatedUnion("type", [
791
- z11.object({
871
+ var UserScopeV2 = z12.discriminatedUnion("type", [
872
+ z12.object({
792
873
  type: ScopesWithRoleOption,
793
874
  options: AllUserScopeOptions.optional()
794
875
  }),
795
- z11.object({
876
+ z12.object({
796
877
  type: UserScopeType.extract(["user.read", "user.search"]),
797
878
  options: AccessLevelOptions.optional()
798
879
  })
799
880
  ]);
800
- var ResolvedRecordScopeV2 = z11.discriminatedUnion("type", [
801
- z11.object({
881
+ var ResolvedRecordScopeV2 = z12.discriminatedUnion("type", [
882
+ z12.object({
802
883
  type: ScopesWithPlaceEventOptions,
803
884
  options: ResolvedScopeOptionsPlaceEvent.optional()
804
885
  }),
805
- z11.object({
886
+ z12.object({
806
887
  type: ScopesWithDeclaredOptions,
807
888
  options: ResolvedScopeOptionsDeclared.optional()
808
889
  }),
809
- z11.object({
890
+ z12.object({
810
891
  type: ScopesWithFullOptions,
811
892
  options: ResolvedScopeOptionsFull.optional()
812
893
  }),
813
- z11.object({
814
- type: z11.literal("record.print-certified-copies"),
894
+ z12.object({
895
+ type: z12.literal("record.print-certified-copies"),
815
896
  options: ResolvedScopeOptionsFull.extend({
816
- templates: z11.array(z11.string()).optional()
897
+ templates: z12.array(z12.string()).optional()
817
898
  }).optional()
818
899
  })
819
900
  ]).describe("Resolved scope with location/user IDs instead of filters.");
820
- var Scope = z11.discriminatedUnion("type", [
821
- z11.object({ type: PlainScopeType }),
901
+ var Scope = z12.discriminatedUnion("type", [
902
+ z12.object({ type: PlainScopeType }),
822
903
  ...RecordScopeV2.options,
823
904
  ...UserScopeV2.options,
824
- z11.object({
825
- type: z11.literal("organisation.read-locations"),
905
+ z12.object({
906
+ type: z12.literal("organisation.read-locations"),
826
907
  options: AccessLevelOptions.optional()
827
908
  }),
828
- z11.object({
829
- type: z11.literal("workqueue"),
909
+ z12.object({
910
+ type: z12.literal("workqueue"),
830
911
  options: WorkqueueOrDashboardOptions
831
912
  }),
832
- z11.object({
833
- type: z11.literal("dashboard.view"),
913
+ z12.object({
914
+ type: z12.literal("dashboard.view"),
834
915
  options: WorkqueueOrDashboardOptions
835
916
  })
836
917
  ]);
837
- var ScopeType = z11.enum([
918
+ var ScopeType = z12.enum([
838
919
  ...SystemScopeType.options,
839
920
  ...RecordScopeTypeV2.options,
840
921
  ...PlainScopeType.options,
841
922
  "workqueue",
842
923
  "dashboard.view"
843
924
  ]);
844
- var EncodedScope = z11.string().brand("EncodedScope");
925
+ var EncodedScope = z12.string().brand("EncodedScope");
845
926
  var DEFAULT_SCOPE_OPTIONS = {
846
927
  placeOfEvent: JurisdictionFilter.enum.all,
847
928
  accessLevel: JurisdictionFilter.enum.all,
@@ -851,30 +932,25 @@ var DEFAULT_SCOPE_OPTIONS = {
851
932
  };
852
933
 
853
934
  // ../commons/src/authentication.ts
854
- var TokenUserType = z12.enum(["user", "system"]);
855
- var TokenWithBearer = z12.string().regex(/^Bearer\s/);
935
+ var TokenUserType = z13.enum(["user", "system"]);
936
+ var TokenWithBearer = z13.string().regex(/^Bearer\s/);
856
937
 
857
938
  // ../commons/src/events/ActionDocument.ts
858
- var ActionUpdate = z13.record(z13.string(), FieldUpdateValue).describe(
939
+ var ActionUpdate = z14.record(z14.string(), FieldUpdateValue).describe(
859
940
  "Record of field-level changes made by an action. Supports partial updates and nullable values."
860
941
  );
861
- var EventState = z13.record(z13.string(), FieldValue).describe(
942
+ var EventState = z14.record(z14.string(), FieldValue).describe(
862
943
  "Aggregate representation of event data after all actions have been applied, with all updates consolidated and null values removed."
863
944
  );
864
- var ActionStatus = {
865
- Requested: "Requested",
866
- Accepted: "Accepted",
867
- Rejected: "Rejected"
868
- };
869
- var ActionBase = z13.object({
945
+ var ActionBase = z14.object({
870
946
  id: UUID.describe("Unique identifier of the action."),
871
- transactionId: z13.string().describe("Unique identifier of the transaction."),
947
+ transactionId: z14.string().describe("Unique identifier of the transaction."),
872
948
  createdByUserType: TokenUserType.describe(
873
949
  "Indicates whether the action was created by a human-user or by a system-user."
874
950
  ),
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."),
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."),
878
954
  createdBySignature: DocumentPath.nullish().describe(
879
955
  "Reference to the signature of the user who created the action."
880
956
  ),
@@ -886,7 +962,7 @@ var ActionBase = z13.object({
886
962
  "Declaration data defined by the ActionConfig. Supports partial updates."
887
963
  ),
888
964
  annotation: ActionUpdate.optional().nullable().describe("Action-specific metadata used to annotate the event."),
889
- status: z13.enum([
965
+ status: z14.enum([
890
966
  ActionStatus.Requested,
891
967
  ActionStatus.Accepted,
892
968
  ActionStatus.Rejected
@@ -898,139 +974,146 @@ var ActionBase = z13.object({
898
974
  )
899
975
  });
900
976
  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.")
977
+ z14.object({
978
+ type: z14.literal(ActionType.ASSIGN),
979
+ assignedTo: z14.string().describe("Identifier of the user to whom the action is assigned.")
904
980
  // TODO move into 'content' property
905
981
  }).shape
906
982
  );
907
983
  var UnassignedAction = ActionBase.extend(
908
- z13.object({
909
- type: z13.literal(ActionType.UNASSIGN)
984
+ z14.object({
985
+ type: z14.literal(ActionType.UNASSIGN)
910
986
  }).shape
911
987
  );
912
988
  var RegisterAction = ActionBase.extend(
913
- z13.object({
914
- type: z13.literal(ActionType.REGISTER),
915
- registrationNumber: z13.string().optional().describe(
989
+ z14.object({
990
+ type: z14.literal(ActionType.REGISTER),
991
+ registrationNumber: z14.string().optional().describe(
916
992
  "Registration number of the event. Always present for accepted registrations."
917
993
  )
918
994
  // TODO move into 'content' property
919
995
  }).shape
920
996
  );
921
997
  var DeclareAction = ActionBase.extend(
922
- z13.object({
923
- type: z13.literal(ActionType.DECLARE)
998
+ z14.object({
999
+ type: z14.literal(ActionType.DECLARE)
924
1000
  }).shape
925
1001
  );
926
- var ReasonContent = z13.object({
927
- 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(
928
1004
  "Message describing the reason for rejecting or archiving the event."
929
1005
  )
930
1006
  });
931
1007
  var RejectAction = ActionBase.extend(
932
- z13.object({
933
- type: z13.literal(ActionType.REJECT),
1008
+ z14.object({
1009
+ type: z14.literal(ActionType.REJECT),
934
1010
  content: ReasonContent
935
1011
  }).shape
936
1012
  );
937
- var PotentialDuplicate = z13.object({
1013
+ var PotentialDuplicate = z14.object({
938
1014
  id: UUID,
939
- trackingId: z13.string()
1015
+ trackingId: z14.string()
940
1016
  });
941
1017
  var DuplicateDetectedAction = ActionBase.extend(
942
- z13.object({
943
- type: z13.literal(ActionType.DUPLICATE_DETECTED),
944
- content: z13.object({
945
- duplicates: z13.array(PotentialDuplicate)
1018
+ z14.object({
1019
+ type: z14.literal(ActionType.DUPLICATE_DETECTED),
1020
+ content: z14.object({
1021
+ duplicates: z14.array(PotentialDuplicate)
946
1022
  })
947
1023
  }).shape
948
1024
  );
949
1025
  var MarkNotDuplicateAction = ActionBase.extend(
950
- z13.object({
951
- type: z13.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1026
+ z14.object({
1027
+ type: z14.literal(ActionType.MARK_AS_NOT_DUPLICATE)
952
1028
  }).shape
953
1029
  );
954
1030
  var MarkAsDuplicateAction = ActionBase.extend(
955
- z13.object({
956
- type: z13.literal(ActionType.MARK_AS_DUPLICATE),
957
- content: z13.object({
1031
+ z14.object({
1032
+ type: z14.literal(ActionType.MARK_AS_DUPLICATE),
1033
+ content: z14.object({
958
1034
  duplicateOf: UUID
959
1035
  }).optional()
960
1036
  }).shape
961
1037
  );
962
1038
  var ArchiveAction = ActionBase.extend(
963
- z13.object({
964
- type: z13.literal(ActionType.ARCHIVE),
1039
+ z14.object({
1040
+ type: z14.literal(ActionType.ARCHIVE),
965
1041
  content: ReasonContent
966
1042
  }).shape
967
1043
  );
1044
+ var UnarchiveAction = ActionBase.extend(
1045
+ z14.object({
1046
+ type: z14.literal(ActionType.UNARCHIVE)
1047
+ }).shape
1048
+ );
968
1049
  var CreatedAction = ActionBase.extend(
969
- z13.object({
970
- type: z13.literal(ActionType.CREATE)
1050
+ z14.object({
1051
+ type: z14.literal(ActionType.CREATE)
971
1052
  }).shape
972
1053
  );
973
1054
  var NotifiedAction = ActionBase.extend(
974
- z13.object({
975
- type: z13.literal(ActionType.NOTIFY)
1055
+ z14.object({
1056
+ type: z14.literal(ActionType.NOTIFY)
976
1057
  }).shape
977
1058
  );
978
1059
  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
- })
1060
+ z14.object({
1061
+ type: z14.literal(ActionType.EDIT),
1062
+ /** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
1063
+ content: z14.object({
1064
+ comment: z14.string().describe("Comment for the edit action.").optional()
1065
+ }).optional()
984
1066
  }).shape
985
1067
  );
986
- var PrintContent = z13.object({
987
- templateId: z13.string().optional()
1068
+ var PrintContent = z14.object({
1069
+ templateId: z14.string().optional()
988
1070
  });
989
1071
  var PrintCertificateAction = ActionBase.extend(
990
- z13.object({
991
- type: z13.literal(ActionType.PRINT_CERTIFICATE),
1072
+ z14.object({
1073
+ type: z14.literal(ActionType.PRINT_CERTIFICATE),
992
1074
  content: PrintContent.optional().nullable()
993
1075
  }).shape
994
1076
  );
995
1077
  var RequestedCorrectionAction = ActionBase.extend(
996
- z13.object({
997
- type: z13.literal(ActionType.REQUEST_CORRECTION)
1078
+ z14.object({
1079
+ type: z14.literal(ActionType.REQUEST_CORRECTION)
998
1080
  }).shape
999
1081
  );
1000
1082
  var ApprovedCorrectionAction = ActionBase.extend(
1001
- z13.object({
1002
- type: z13.literal(ActionType.APPROVE_CORRECTION),
1003
- requestId: z13.string(),
1083
+ z14.object({
1084
+ type: z14.literal(ActionType.APPROVE_CORRECTION),
1085
+ requestId: z14.string(),
1004
1086
  // TODO move into 'content' property
1005
- content: z13.object({ immediateCorrection: z13.boolean().optional() }).optional()
1087
+ content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
1006
1088
  }).shape
1007
1089
  );
1008
1090
  var RejectedCorrectionAction = ActionBase.extend(
1009
- z13.object({
1010
- type: z13.literal(ActionType.REJECT_CORRECTION),
1011
- requestId: z13.string(),
1091
+ z14.object({
1092
+ type: z14.literal(ActionType.REJECT_CORRECTION),
1093
+ requestId: z14.string(),
1012
1094
  // TODO move into 'content' property
1013
1095
  content: ReasonContent
1014
1096
  }).shape
1015
1097
  );
1016
1098
  var ReadAction = ActionBase.extend(
1017
- z13.object({
1018
- type: z13.literal(ActionType.READ)
1099
+ z14.object({
1100
+ type: z14.literal(ActionType.READ)
1019
1101
  }).shape
1020
1102
  );
1021
1103
  var CustomAction = ActionBase.merge(
1022
- z13.object({
1023
- type: z13.literal(ActionType.CUSTOM),
1024
- customActionType: z13.string()
1104
+ z14.object({
1105
+ type: z14.literal(ActionType.CUSTOM),
1106
+ customActionType: z14.string()
1025
1107
  })
1026
1108
  );
1027
- var ActionDocument = z13.discriminatedUnion("type", [
1109
+ var ActionDocument = z14.discriminatedUnion("type", [
1028
1110
  CreatedAction.meta({ id: "CreatedAction" }),
1029
1111
  RejectAction.meta({ id: "RejectAction" }),
1030
1112
  DuplicateDetectedAction.meta({ id: "DuplicateDetectedAction" }),
1031
1113
  MarkNotDuplicateAction.meta({ id: "MarkNotDuplicateAction" }),
1032
1114
  MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
1033
1115
  ArchiveAction.meta({ id: "ArchiveAction" }),
1116
+ UnarchiveAction.meta({ id: "UnarchiveAction" }),
1034
1117
  NotifiedAction.meta({ id: "NotifiedAction" }),
1035
1118
  RegisterAction.meta({ id: "RegisterAction" }),
1036
1119
  DeclareAction.meta({ id: "DeclareAction" }),
@@ -1050,64 +1133,12 @@ var AsyncRejectActionDocument = ActionBase.omit({
1050
1133
  declaration: true,
1051
1134
  annotation: true
1052
1135
  }).extend(
1053
- z13.object({
1054
- type: z13.enum(ConfirmableActions),
1055
- status: z13.literal(ActionStatus.Rejected)
1136
+ z14.object({
1137
+ type: z14.enum(ConfirmableActions),
1138
+ status: z14.literal(ActionStatus.Rejected)
1056
1139
  }).shape
1057
1140
  );
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
- });
1141
+ var Action = z14.union([ActionDocument, AsyncRejectActionDocument]);
1111
1142
 
1112
1143
  // ../commons/src/events/EventMetadata.ts
1113
1144
  var EventStatus = z15.enum([
@@ -1268,13 +1299,6 @@ var Range = import_v4.z.object({
1268
1299
  }).meta({
1269
1300
  id: "Range"
1270
1301
  });
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
1302
  var Within = import_v4.z.object({ type: import_v4.z.literal("within"), location: import_v4.z.string() }).meta({
1279
1303
  id: "Within"
1280
1304
  });