@opencrvs/toolkit 2.1.0-rc.e773220 → 2.1.0-rc.eb366a1
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.
- package/dist/application-config/index.js +210 -187
- package/dist/commons/api/router.d.ts +613 -20
- package/dist/commons/conditionals/conditionals.d.ts +6 -6
- package/dist/commons/conditionals/validate.d.ts +2 -1
- package/dist/commons/events/ActionConfig.d.ts +54 -0
- package/dist/commons/events/ActionDocument.d.ts +45 -7
- package/dist/commons/events/ActionInput.d.ts +26 -0
- package/dist/commons/events/ActionStatus.d.ts +14 -0
- package/dist/commons/events/ActionType.d.ts +6 -1
- package/dist/commons/events/AdvancedSearchConfig.d.ts +12 -0
- package/dist/commons/events/AuditLog.d.ts +2 -0
- package/dist/commons/events/CountryConfigQueryInput.d.ts +18 -0
- package/dist/commons/events/Draft.d.ts +2 -0
- package/dist/commons/events/EventDocument.d.ts +22 -0
- package/dist/commons/events/EventIndex.d.ts +5 -24
- package/dist/commons/events/EventMetadata.d.ts +2 -1
- package/dist/commons/events/FieldConfig.d.ts +10 -0
- package/dist/commons/events/Flag.d.ts +48 -0
- package/dist/commons/events/WorkqueueColumnConfig.d.ts +4 -4
- package/dist/commons/events/WorkqueueConfig.d.ts +25 -7
- package/dist/commons/events/scopes.d.ts +1 -0
- package/dist/commons/events/test.utils.d.ts +9 -1
- package/dist/commons/events/utils.d.ts +23 -1
- package/dist/conditionals/index.js +305 -55
- package/dist/events/index.js +3261 -3141
- package/dist/notification/index.js +1481 -882
- package/dist/scopes/index.d.ts +257 -1
- package/dist/scopes/index.js +306 -55
- package/opencrvs-toolkit-2.1.0-rc.eb366a1.tgz +0 -0
- package/package.json +1 -1
- package/opencrvs-toolkit-2.1.0-rc.e773220.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
|
|
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
|
|
615
|
+
var z13 = __toESM(require("zod/v4"));
|
|
612
616
|
|
|
613
617
|
// ../commons/src/scopes.ts
|
|
614
|
-
var
|
|
618
|
+
var z12 = __toESM(require("zod/v4"));
|
|
615
619
|
var qs = __toESM(require("qs"));
|
|
616
|
-
|
|
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 =
|
|
620
|
-
var RecordScopeTypeV2 =
|
|
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 =
|
|
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 =
|
|
734
|
+
var scopeByEvent = z12.preprocess(
|
|
657
735
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
658
|
-
|
|
736
|
+
z12.array(z12.string()).optional()
|
|
659
737
|
).describe("Event type, e.g. birth, death");
|
|
660
|
-
var userRole =
|
|
738
|
+
var userRole = z12.preprocess(
|
|
661
739
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
662
|
-
|
|
740
|
+
z12.array(z12.string()).optional()
|
|
663
741
|
).describe("User role, e.g. admin, field agent");
|
|
664
|
-
var scopeOptionsPlaceEvent =
|
|
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:
|
|
760
|
+
customActionTypes: z12.preprocess(
|
|
682
761
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
683
|
-
|
|
762
|
+
z12.array(z12.string()).optional()
|
|
684
763
|
).describe("Allowed custom action types")
|
|
685
764
|
});
|
|
686
|
-
var AccessLevelOptions =
|
|
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 =
|
|
693
|
-
ids:
|
|
771
|
+
var WorkqueueOrDashboardOptions = z12.object({
|
|
772
|
+
ids: z12.preprocess(
|
|
694
773
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
695
|
-
|
|
774
|
+
z12.array(z12.string())
|
|
696
775
|
).describe("Must contain a list of workqueue or dashboard ids.")
|
|
697
776
|
});
|
|
698
|
-
var AllScopeOptions =
|
|
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 =
|
|
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:
|
|
792
|
+
notifiedBy: z12.string().optional(),
|
|
714
793
|
declaredIn: UUID.nullish(),
|
|
715
|
-
declaredBy:
|
|
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:
|
|
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:
|
|
826
|
+
templates: z12.preprocess(
|
|
746
827
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
747
|
-
|
|
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 =
|
|
753
|
-
|
|
833
|
+
var RecordScopeV2 = z12.discriminatedUnion("type", [
|
|
834
|
+
z12.object({
|
|
754
835
|
type: ScopesWithPlaceEventOptions,
|
|
755
836
|
options: scopeOptionsPlaceEvent.optional()
|
|
756
837
|
}),
|
|
757
|
-
|
|
838
|
+
z12.object({
|
|
758
839
|
type: ScopesWithDeclaredOptions,
|
|
759
840
|
options: scopeOptionsDeclaredOrNotified.optional()
|
|
760
841
|
}),
|
|
761
|
-
|
|
842
|
+
z12.object({
|
|
762
843
|
type: ScopesWithFullOptions,
|
|
763
844
|
options: AllRecordScopeOptions.optional()
|
|
764
845
|
}),
|
|
765
|
-
|
|
766
|
-
type:
|
|
846
|
+
z12.object({
|
|
847
|
+
type: z12.literal("record.custom-action"),
|
|
767
848
|
options: CustomActionScopeOptions.optional()
|
|
768
849
|
}),
|
|
769
|
-
|
|
770
|
-
type:
|
|
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 =
|
|
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 =
|
|
791
|
-
|
|
871
|
+
var UserScopeV2 = z12.discriminatedUnion("type", [
|
|
872
|
+
z12.object({
|
|
792
873
|
type: ScopesWithRoleOption,
|
|
793
874
|
options: AllUserScopeOptions.optional()
|
|
794
875
|
}),
|
|
795
|
-
|
|
876
|
+
z12.object({
|
|
796
877
|
type: UserScopeType.extract(["user.read", "user.search"]),
|
|
797
878
|
options: AccessLevelOptions.optional()
|
|
798
879
|
})
|
|
799
880
|
]);
|
|
800
|
-
var ResolvedRecordScopeV2 =
|
|
801
|
-
|
|
881
|
+
var ResolvedRecordScopeV2 = z12.discriminatedUnion("type", [
|
|
882
|
+
z12.object({
|
|
802
883
|
type: ScopesWithPlaceEventOptions,
|
|
803
884
|
options: ResolvedScopeOptionsPlaceEvent.optional()
|
|
804
885
|
}),
|
|
805
|
-
|
|
886
|
+
z12.object({
|
|
806
887
|
type: ScopesWithDeclaredOptions,
|
|
807
888
|
options: ResolvedScopeOptionsDeclared.optional()
|
|
808
889
|
}),
|
|
809
|
-
|
|
890
|
+
z12.object({
|
|
810
891
|
type: ScopesWithFullOptions,
|
|
811
892
|
options: ResolvedScopeOptionsFull.optional()
|
|
812
893
|
}),
|
|
813
|
-
|
|
814
|
-
type:
|
|
894
|
+
z12.object({
|
|
895
|
+
type: z12.literal("record.print-certified-copies"),
|
|
815
896
|
options: ResolvedScopeOptionsFull.extend({
|
|
816
|
-
templates:
|
|
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 =
|
|
821
|
-
|
|
901
|
+
var Scope = z12.discriminatedUnion("type", [
|
|
902
|
+
z12.object({ type: PlainScopeType }),
|
|
822
903
|
...RecordScopeV2.options,
|
|
823
904
|
...UserScopeV2.options,
|
|
824
|
-
|
|
825
|
-
type:
|
|
905
|
+
z12.object({
|
|
906
|
+
type: z12.literal("organisation.read-locations"),
|
|
826
907
|
options: AccessLevelOptions.optional()
|
|
827
908
|
}),
|
|
828
|
-
|
|
829
|
-
type:
|
|
909
|
+
z12.object({
|
|
910
|
+
type: z12.literal("workqueue"),
|
|
830
911
|
options: WorkqueueOrDashboardOptions
|
|
831
912
|
}),
|
|
832
|
-
|
|
833
|
-
type:
|
|
913
|
+
z12.object({
|
|
914
|
+
type: z12.literal("dashboard.view"),
|
|
834
915
|
options: WorkqueueOrDashboardOptions
|
|
835
916
|
})
|
|
836
917
|
]);
|
|
837
|
-
var ScopeType =
|
|
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 =
|
|
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 =
|
|
855
|
-
var TokenWithBearer =
|
|
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 =
|
|
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 =
|
|
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
|
|
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:
|
|
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:
|
|
876
|
-
createdBy:
|
|
877
|
-
createdByRole:
|
|
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:
|
|
965
|
+
status: z14.enum([
|
|
890
966
|
ActionStatus.Requested,
|
|
891
967
|
ActionStatus.Accepted,
|
|
892
968
|
ActionStatus.Rejected
|
|
@@ -898,139 +974,145 @@ var ActionBase = z13.object({
|
|
|
898
974
|
)
|
|
899
975
|
});
|
|
900
976
|
var AssignedAction = ActionBase.extend(
|
|
901
|
-
|
|
902
|
-
type:
|
|
903
|
-
assignedTo:
|
|
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
|
-
|
|
909
|
-
type:
|
|
984
|
+
z14.object({
|
|
985
|
+
type: z14.literal(ActionType.UNASSIGN)
|
|
910
986
|
}).shape
|
|
911
987
|
);
|
|
912
988
|
var RegisterAction = ActionBase.extend(
|
|
913
|
-
|
|
914
|
-
type:
|
|
915
|
-
registrationNumber:
|
|
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
|
-
|
|
923
|
-
type:
|
|
998
|
+
z14.object({
|
|
999
|
+
type: z14.literal(ActionType.DECLARE)
|
|
924
1000
|
}).shape
|
|
925
1001
|
);
|
|
926
|
-
var ReasonContent =
|
|
927
|
-
reason:
|
|
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
|
-
|
|
933
|
-
type:
|
|
1008
|
+
z14.object({
|
|
1009
|
+
type: z14.literal(ActionType.REJECT),
|
|
934
1010
|
content: ReasonContent
|
|
935
1011
|
}).shape
|
|
936
1012
|
);
|
|
937
|
-
var PotentialDuplicate =
|
|
1013
|
+
var PotentialDuplicate = z14.object({
|
|
938
1014
|
id: UUID,
|
|
939
|
-
trackingId:
|
|
1015
|
+
trackingId: z14.string()
|
|
940
1016
|
});
|
|
941
1017
|
var DuplicateDetectedAction = ActionBase.extend(
|
|
942
|
-
|
|
943
|
-
type:
|
|
944
|
-
content:
|
|
945
|
-
duplicates:
|
|
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
|
-
|
|
951
|
-
type:
|
|
1026
|
+
z14.object({
|
|
1027
|
+
type: z14.literal(ActionType.MARK_AS_NOT_DUPLICATE)
|
|
952
1028
|
}).shape
|
|
953
1029
|
);
|
|
954
1030
|
var MarkAsDuplicateAction = ActionBase.extend(
|
|
955
|
-
|
|
956
|
-
type:
|
|
957
|
-
content:
|
|
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
|
-
|
|
964
|
-
type:
|
|
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
|
-
|
|
970
|
-
type:
|
|
1050
|
+
z14.object({
|
|
1051
|
+
type: z14.literal(ActionType.CREATE)
|
|
971
1052
|
}).shape
|
|
972
1053
|
);
|
|
973
1054
|
var NotifiedAction = ActionBase.extend(
|
|
974
|
-
|
|
975
|
-
type:
|
|
1055
|
+
z14.object({
|
|
1056
|
+
type: z14.literal(ActionType.NOTIFY)
|
|
976
1057
|
}).shape
|
|
977
1058
|
);
|
|
978
1059
|
var EditAction = ActionBase.extend(
|
|
979
|
-
|
|
980
|
-
type:
|
|
981
|
-
content:
|
|
982
|
-
comment:
|
|
1060
|
+
z14.object({
|
|
1061
|
+
type: z14.literal(ActionType.EDIT),
|
|
1062
|
+
content: z14.object({
|
|
1063
|
+
comment: z14.string().describe("Comment for the edit action.").optional()
|
|
983
1064
|
})
|
|
984
1065
|
}).shape
|
|
985
1066
|
);
|
|
986
|
-
var PrintContent =
|
|
987
|
-
templateId:
|
|
1067
|
+
var PrintContent = z14.object({
|
|
1068
|
+
templateId: z14.string().optional()
|
|
988
1069
|
});
|
|
989
1070
|
var PrintCertificateAction = ActionBase.extend(
|
|
990
|
-
|
|
991
|
-
type:
|
|
1071
|
+
z14.object({
|
|
1072
|
+
type: z14.literal(ActionType.PRINT_CERTIFICATE),
|
|
992
1073
|
content: PrintContent.optional().nullable()
|
|
993
1074
|
}).shape
|
|
994
1075
|
);
|
|
995
1076
|
var RequestedCorrectionAction = ActionBase.extend(
|
|
996
|
-
|
|
997
|
-
type:
|
|
1077
|
+
z14.object({
|
|
1078
|
+
type: z14.literal(ActionType.REQUEST_CORRECTION)
|
|
998
1079
|
}).shape
|
|
999
1080
|
);
|
|
1000
1081
|
var ApprovedCorrectionAction = ActionBase.extend(
|
|
1001
|
-
|
|
1002
|
-
type:
|
|
1003
|
-
requestId:
|
|
1082
|
+
z14.object({
|
|
1083
|
+
type: z14.literal(ActionType.APPROVE_CORRECTION),
|
|
1084
|
+
requestId: z14.string(),
|
|
1004
1085
|
// TODO move into 'content' property
|
|
1005
|
-
content:
|
|
1086
|
+
content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
|
|
1006
1087
|
}).shape
|
|
1007
1088
|
);
|
|
1008
1089
|
var RejectedCorrectionAction = ActionBase.extend(
|
|
1009
|
-
|
|
1010
|
-
type:
|
|
1011
|
-
requestId:
|
|
1090
|
+
z14.object({
|
|
1091
|
+
type: z14.literal(ActionType.REJECT_CORRECTION),
|
|
1092
|
+
requestId: z14.string(),
|
|
1012
1093
|
// TODO move into 'content' property
|
|
1013
1094
|
content: ReasonContent
|
|
1014
1095
|
}).shape
|
|
1015
1096
|
);
|
|
1016
1097
|
var ReadAction = ActionBase.extend(
|
|
1017
|
-
|
|
1018
|
-
type:
|
|
1098
|
+
z14.object({
|
|
1099
|
+
type: z14.literal(ActionType.READ)
|
|
1019
1100
|
}).shape
|
|
1020
1101
|
);
|
|
1021
1102
|
var CustomAction = ActionBase.merge(
|
|
1022
|
-
|
|
1023
|
-
type:
|
|
1024
|
-
customActionType:
|
|
1103
|
+
z14.object({
|
|
1104
|
+
type: z14.literal(ActionType.CUSTOM),
|
|
1105
|
+
customActionType: z14.string()
|
|
1025
1106
|
})
|
|
1026
1107
|
);
|
|
1027
|
-
var ActionDocument =
|
|
1108
|
+
var ActionDocument = z14.discriminatedUnion("type", [
|
|
1028
1109
|
CreatedAction.meta({ id: "CreatedAction" }),
|
|
1029
1110
|
RejectAction.meta({ id: "RejectAction" }),
|
|
1030
1111
|
DuplicateDetectedAction.meta({ id: "DuplicateDetectedAction" }),
|
|
1031
1112
|
MarkNotDuplicateAction.meta({ id: "MarkNotDuplicateAction" }),
|
|
1032
1113
|
MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
|
|
1033
1114
|
ArchiveAction.meta({ id: "ArchiveAction" }),
|
|
1115
|
+
UnarchiveAction.meta({ id: "UnarchiveAction" }),
|
|
1034
1116
|
NotifiedAction.meta({ id: "NotifiedAction" }),
|
|
1035
1117
|
RegisterAction.meta({ id: "RegisterAction" }),
|
|
1036
1118
|
DeclareAction.meta({ id: "DeclareAction" }),
|
|
@@ -1050,64 +1132,12 @@ var AsyncRejectActionDocument = ActionBase.omit({
|
|
|
1050
1132
|
declaration: true,
|
|
1051
1133
|
annotation: true
|
|
1052
1134
|
}).extend(
|
|
1053
|
-
|
|
1054
|
-
type:
|
|
1055
|
-
status:
|
|
1135
|
+
z14.object({
|
|
1136
|
+
type: z14.enum(ConfirmableActions),
|
|
1137
|
+
status: z14.literal(ActionStatus.Rejected)
|
|
1056
1138
|
}).shape
|
|
1057
1139
|
);
|
|
1058
|
-
var Action =
|
|
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
|
-
});
|
|
1140
|
+
var Action = z14.union([ActionDocument, AsyncRejectActionDocument]);
|
|
1111
1141
|
|
|
1112
1142
|
// ../commons/src/events/EventMetadata.ts
|
|
1113
1143
|
var EventStatus = z15.enum([
|
|
@@ -1268,13 +1298,6 @@ var Range = import_v4.z.object({
|
|
|
1268
1298
|
}).meta({
|
|
1269
1299
|
id: "Range"
|
|
1270
1300
|
});
|
|
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
1301
|
var Within = import_v4.z.object({ type: import_v4.z.literal("within"), location: import_v4.z.string() }).meta({
|
|
1279
1302
|
id: "Within"
|
|
1280
1303
|
});
|