@opencrvs/toolkit 2.0.0-rc.3941c77 → 2.0.0-rc.3c7efd6
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 +37 -7
- package/dist/cli.js +37 -7
- package/dist/commons/api/router.d.ts +23 -38
- package/dist/commons/conditionals/conditionals.d.ts +6 -6
- package/dist/commons/events/FieldConfig.d.ts +10 -0
- package/dist/commons/events/locations.d.ts +17 -1
- package/dist/conditionals/index.js +37 -7
- package/dist/events/index.js +75 -7
- package/dist/migrations/v2.0/index.js +37 -7
- package/dist/notification/index.js +37 -7
- package/dist/scopes/index.d.ts +87 -10
- package/dist/scopes/index.js +43 -8
- package/opencrvs-toolkit-2.0.0-rc.3c7efd6.tgz +0 -0
- package/package.json +1 -1
- package/opencrvs-toolkit-2.0.0-rc.3941c77.tgz +0 -0
|
@@ -656,6 +656,10 @@ var scopeByEvent = z11.preprocess(
|
|
|
656
656
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
657
657
|
z11.array(z11.string()).optional()
|
|
658
658
|
).describe("Event type, e.g. birth, death");
|
|
659
|
+
var userRole = z11.preprocess(
|
|
660
|
+
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
661
|
+
z11.array(z11.string()).optional()
|
|
662
|
+
).describe("User role, e.g. admin, field agent");
|
|
659
663
|
var scopeOptionsPlaceEvent = z11.object({
|
|
660
664
|
event: scopeByEvent,
|
|
661
665
|
placeOfEvent: JurisdictionFilter.optional()
|
|
@@ -679,6 +683,9 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
|
679
683
|
var AccessLevelOptions = z11.object({
|
|
680
684
|
accessLevel: JurisdictionFilter.optional()
|
|
681
685
|
});
|
|
686
|
+
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
687
|
+
role: userRole.optional()
|
|
688
|
+
});
|
|
682
689
|
var WorkqueueOrDashboardOptions = z11.object({
|
|
683
690
|
ids: z11.preprocess(
|
|
684
691
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
@@ -688,6 +695,7 @@ var WorkqueueOrDashboardOptions = z11.object({
|
|
|
688
695
|
var AllScopeOptions = z11.object({
|
|
689
696
|
...AllRecordScopeOptions.shape,
|
|
690
697
|
...AccessLevelOptions.shape,
|
|
698
|
+
...AllUserScopeOptions.shape,
|
|
691
699
|
...WorkqueueOrDashboardOptions.shape
|
|
692
700
|
});
|
|
693
701
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
@@ -760,6 +768,30 @@ var RecordScopeV2 = z11.discriminatedUnion("type", [
|
|
|
760
768
|
]).describe(
|
|
761
769
|
"Scopes used to check user's permission to perform actions on a record."
|
|
762
770
|
);
|
|
771
|
+
var SystemScopeType = z11.enum([
|
|
772
|
+
"organisation.read-locations",
|
|
773
|
+
"user.read",
|
|
774
|
+
"user.create",
|
|
775
|
+
"user.edit",
|
|
776
|
+
"user.search"
|
|
777
|
+
]);
|
|
778
|
+
var UserScopeType = SystemScopeType.extract([
|
|
779
|
+
"user.read",
|
|
780
|
+
"user.create",
|
|
781
|
+
"user.edit",
|
|
782
|
+
"user.search"
|
|
783
|
+
]);
|
|
784
|
+
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
785
|
+
var UserScopeV2 = z11.discriminatedUnion("type", [
|
|
786
|
+
z11.object({
|
|
787
|
+
type: ScopesWithRoleOption,
|
|
788
|
+
options: AllUserScopeOptions.optional()
|
|
789
|
+
}),
|
|
790
|
+
z11.object({
|
|
791
|
+
type: UserScopeType.extract(["user.read", "user.search"]),
|
|
792
|
+
options: AccessLevelOptions.optional()
|
|
793
|
+
})
|
|
794
|
+
]);
|
|
763
795
|
var ResolvedRecordScopeV2 = z11.discriminatedUnion("type", [
|
|
764
796
|
z11.object({
|
|
765
797
|
type: ScopesWithPlaceEventOptions,
|
|
@@ -780,16 +812,14 @@ var ResolvedRecordScopeV2 = z11.discriminatedUnion("type", [
|
|
|
780
812
|
}).optional()
|
|
781
813
|
})
|
|
782
814
|
]).describe("Resolved scope with location/user IDs instead of filters.");
|
|
783
|
-
var SystemScopeType = z11.enum([
|
|
784
|
-
"organisation.read-locations",
|
|
785
|
-
"user.read",
|
|
786
|
-
"user.create",
|
|
787
|
-
"user.edit"
|
|
788
|
-
]);
|
|
789
815
|
var Scope = z11.discriminatedUnion("type", [
|
|
790
816
|
z11.object({ type: PlainScopeType }),
|
|
791
817
|
...RecordScopeV2.options,
|
|
792
|
-
|
|
818
|
+
...UserScopeV2.options,
|
|
819
|
+
z11.object({
|
|
820
|
+
type: z11.literal("organisation.read-locations"),
|
|
821
|
+
options: AccessLevelOptions.optional()
|
|
822
|
+
}),
|
|
793
823
|
z11.object({
|
|
794
824
|
type: z11.literal("workqueue"),
|
|
795
825
|
options: WorkqueueOrDashboardOptions
|
package/dist/cli.js
CHANGED
|
@@ -2110,6 +2110,10 @@ var scopeByEvent = z3.preprocess(
|
|
|
2110
2110
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
2111
2111
|
z3.array(z3.string()).optional()
|
|
2112
2112
|
).describe("Event type, e.g. birth, death");
|
|
2113
|
+
var userRole = z3.preprocess(
|
|
2114
|
+
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
2115
|
+
z3.array(z3.string()).optional()
|
|
2116
|
+
).describe("User role, e.g. admin, field agent");
|
|
2113
2117
|
var scopeOptionsPlaceEvent = z3.object({
|
|
2114
2118
|
event: scopeByEvent,
|
|
2115
2119
|
placeOfEvent: JurisdictionFilter.optional()
|
|
@@ -2133,6 +2137,9 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
|
2133
2137
|
var AccessLevelOptions = z3.object({
|
|
2134
2138
|
accessLevel: JurisdictionFilter.optional()
|
|
2135
2139
|
});
|
|
2140
|
+
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
2141
|
+
role: userRole.optional()
|
|
2142
|
+
});
|
|
2136
2143
|
var WorkqueueOrDashboardOptions = z3.object({
|
|
2137
2144
|
ids: z3.preprocess(
|
|
2138
2145
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
@@ -2142,6 +2149,7 @@ var WorkqueueOrDashboardOptions = z3.object({
|
|
|
2142
2149
|
var AllScopeOptions = z3.object({
|
|
2143
2150
|
...AllRecordScopeOptions.shape,
|
|
2144
2151
|
...AccessLevelOptions.shape,
|
|
2152
|
+
...AllUserScopeOptions.shape,
|
|
2145
2153
|
...WorkqueueOrDashboardOptions.shape
|
|
2146
2154
|
});
|
|
2147
2155
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
@@ -2214,6 +2222,30 @@ var RecordScopeV2 = z3.discriminatedUnion("type", [
|
|
|
2214
2222
|
]).describe(
|
|
2215
2223
|
"Scopes used to check user's permission to perform actions on a record."
|
|
2216
2224
|
);
|
|
2225
|
+
var SystemScopeType = z3.enum([
|
|
2226
|
+
"organisation.read-locations",
|
|
2227
|
+
"user.read",
|
|
2228
|
+
"user.create",
|
|
2229
|
+
"user.edit",
|
|
2230
|
+
"user.search"
|
|
2231
|
+
]);
|
|
2232
|
+
var UserScopeType = SystemScopeType.extract([
|
|
2233
|
+
"user.read",
|
|
2234
|
+
"user.create",
|
|
2235
|
+
"user.edit",
|
|
2236
|
+
"user.search"
|
|
2237
|
+
]);
|
|
2238
|
+
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
2239
|
+
var UserScopeV2 = z3.discriminatedUnion("type", [
|
|
2240
|
+
z3.object({
|
|
2241
|
+
type: ScopesWithRoleOption,
|
|
2242
|
+
options: AllUserScopeOptions.optional()
|
|
2243
|
+
}),
|
|
2244
|
+
z3.object({
|
|
2245
|
+
type: UserScopeType.extract(["user.read", "user.search"]),
|
|
2246
|
+
options: AccessLevelOptions.optional()
|
|
2247
|
+
})
|
|
2248
|
+
]);
|
|
2217
2249
|
var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
|
|
2218
2250
|
z3.object({
|
|
2219
2251
|
type: ScopesWithPlaceEventOptions,
|
|
@@ -2234,16 +2266,14 @@ var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
|
|
|
2234
2266
|
}).optional()
|
|
2235
2267
|
})
|
|
2236
2268
|
]).describe("Resolved scope with location/user IDs instead of filters.");
|
|
2237
|
-
var SystemScopeType = z3.enum([
|
|
2238
|
-
"organisation.read-locations",
|
|
2239
|
-
"user.read",
|
|
2240
|
-
"user.create",
|
|
2241
|
-
"user.edit"
|
|
2242
|
-
]);
|
|
2243
2269
|
var Scope2 = z3.discriminatedUnion("type", [
|
|
2244
2270
|
z3.object({ type: PlainScopeType }),
|
|
2245
2271
|
...RecordScopeV2.options,
|
|
2246
|
-
|
|
2272
|
+
...UserScopeV2.options,
|
|
2273
|
+
z3.object({
|
|
2274
|
+
type: z3.literal("organisation.read-locations"),
|
|
2275
|
+
options: AccessLevelOptions.optional()
|
|
2276
|
+
}),
|
|
2247
2277
|
z3.object({
|
|
2248
2278
|
type: z3.literal("workqueue"),
|
|
2249
2279
|
options: WorkqueueOrDashboardOptions
|
|
@@ -4092,33 +4092,18 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4092
4092
|
input: string[];
|
|
4093
4093
|
output: ({
|
|
4094
4094
|
id: string & import("zod").$brand<"UUID">;
|
|
4095
|
+
type: "user";
|
|
4095
4096
|
name: {
|
|
4096
4097
|
firstname: string;
|
|
4097
4098
|
surname: string;
|
|
4098
4099
|
};
|
|
4099
4100
|
role: string;
|
|
4100
|
-
primaryOfficeId: string & import("zod").$brand<"UUID">;
|
|
4101
|
-
type: "user";
|
|
4102
|
-
status: "active" | "pending" | "deactivated";
|
|
4103
|
-
avatar?: (string & import("zod").$brand<"DocumentPath">) | undefined;
|
|
4104
|
-
signature?: (string & import("zod").$brand<"DocumentPath">) | null | undefined;
|
|
4105
|
-
administrativeAreaId?: (string & import("zod").$brand<"UUID">) | null | undefined;
|
|
4106
|
-
device?: string | undefined;
|
|
4107
4101
|
fullHonorificName?: string | undefined;
|
|
4108
|
-
|
|
4109
|
-
email?: string | undefined;
|
|
4110
|
-
data?: Record<string, import("../commons").FieldValue> | undefined;
|
|
4102
|
+
signature?: (string & import("zod").$brand<"DocumentPath">) | null | undefined;
|
|
4111
4103
|
} | {
|
|
4112
4104
|
id: string & import("zod").$brand<"UUID">;
|
|
4113
|
-
name: string;
|
|
4114
4105
|
type: "system";
|
|
4115
|
-
|
|
4116
|
-
administrativeAreaId?: (string & import("zod").$brand<"UUID">) | undefined;
|
|
4117
|
-
signature?: undefined;
|
|
4118
|
-
avatar?: undefined;
|
|
4119
|
-
fullHonorificName?: string | undefined;
|
|
4120
|
-
legacyId?: string | undefined;
|
|
4121
|
-
status?: undefined;
|
|
4106
|
+
name: string;
|
|
4122
4107
|
})[];
|
|
4123
4108
|
meta: import("trpc-to-openapi").OpenApiMeta;
|
|
4124
4109
|
}>;
|
|
@@ -4765,7 +4750,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4765
4750
|
'legalStatuses.DECLARED.createdAtLocation'?: {
|
|
4766
4751
|
type: "within";
|
|
4767
4752
|
location: string | {
|
|
4768
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4753
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "avatar" | "signature" | "middlename";
|
|
4769
4754
|
$location?: string | undefined;
|
|
4770
4755
|
};
|
|
4771
4756
|
} | undefined;
|
|
@@ -4787,7 +4772,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4787
4772
|
'legalStatuses.REGISTERED.createdAtLocation'?: {
|
|
4788
4773
|
type: "within";
|
|
4789
4774
|
location: string | {
|
|
4790
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4775
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "avatar" | "signature" | "middlename";
|
|
4791
4776
|
$location?: string | undefined;
|
|
4792
4777
|
};
|
|
4793
4778
|
} | undefined;
|
|
@@ -4802,47 +4787,47 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4802
4787
|
createdAtLocation?: {
|
|
4803
4788
|
type: "within";
|
|
4804
4789
|
location: string | {
|
|
4805
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4790
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "avatar" | "signature" | "middlename";
|
|
4806
4791
|
$location?: string | undefined;
|
|
4807
4792
|
};
|
|
4808
4793
|
} | {
|
|
4809
4794
|
type: "exact";
|
|
4810
4795
|
term: string | {
|
|
4811
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4796
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "avatar" | "signature" | "middlename";
|
|
4812
4797
|
$location?: string | undefined;
|
|
4813
4798
|
};
|
|
4814
4799
|
} | undefined;
|
|
4815
4800
|
updatedAtLocation?: {
|
|
4816
4801
|
type: "within";
|
|
4817
4802
|
location: string | {
|
|
4818
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4803
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "avatar" | "signature" | "middlename";
|
|
4819
4804
|
$location?: string | undefined;
|
|
4820
4805
|
};
|
|
4821
4806
|
} | {
|
|
4822
4807
|
type: "exact";
|
|
4823
4808
|
term: string | {
|
|
4824
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4809
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "avatar" | "signature" | "middlename";
|
|
4825
4810
|
$location?: string | undefined;
|
|
4826
4811
|
};
|
|
4827
4812
|
} | undefined;
|
|
4828
4813
|
updatedByUserRole?: {
|
|
4829
4814
|
type: "exact";
|
|
4830
4815
|
term: string | {
|
|
4831
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4816
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "avatar" | "signature" | "middlename";
|
|
4832
4817
|
$location?: string | undefined;
|
|
4833
4818
|
};
|
|
4834
4819
|
} | undefined;
|
|
4835
4820
|
assignedTo?: {
|
|
4836
4821
|
type: "exact";
|
|
4837
4822
|
term: string | {
|
|
4838
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4823
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "avatar" | "signature" | "middlename";
|
|
4839
4824
|
$location?: string | undefined;
|
|
4840
4825
|
};
|
|
4841
4826
|
} | undefined;
|
|
4842
4827
|
createdBy?: {
|
|
4843
4828
|
type: "exact";
|
|
4844
4829
|
term: string | {
|
|
4845
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4830
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "avatar" | "signature" | "middlename";
|
|
4846
4831
|
$location?: string | undefined;
|
|
4847
4832
|
};
|
|
4848
4833
|
} | undefined;
|
|
@@ -4853,7 +4838,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4853
4838
|
updatedBy?: {
|
|
4854
4839
|
type: "exact";
|
|
4855
4840
|
term: string | {
|
|
4856
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4841
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "avatar" | "signature" | "middlename";
|
|
4857
4842
|
$location?: string | undefined;
|
|
4858
4843
|
};
|
|
4859
4844
|
} | undefined;
|
|
@@ -4903,7 +4888,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4903
4888
|
'legalStatuses.DECLARED.createdAtLocation'?: {
|
|
4904
4889
|
type: "within";
|
|
4905
4890
|
location: string | {
|
|
4906
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4891
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "avatar" | "signature" | "middlename";
|
|
4907
4892
|
$location?: string | undefined;
|
|
4908
4893
|
};
|
|
4909
4894
|
} | undefined;
|
|
@@ -4925,7 +4910,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4925
4910
|
'legalStatuses.REGISTERED.createdAtLocation'?: {
|
|
4926
4911
|
type: "within";
|
|
4927
4912
|
location: string | {
|
|
4928
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4913
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "avatar" | "signature" | "middlename";
|
|
4929
4914
|
$location?: string | undefined;
|
|
4930
4915
|
};
|
|
4931
4916
|
} | undefined;
|
|
@@ -4940,47 +4925,47 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4940
4925
|
createdAtLocation?: {
|
|
4941
4926
|
type: "within";
|
|
4942
4927
|
location: string | {
|
|
4943
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4928
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "avatar" | "signature" | "middlename";
|
|
4944
4929
|
$location?: string | undefined;
|
|
4945
4930
|
};
|
|
4946
4931
|
} | {
|
|
4947
4932
|
type: "exact";
|
|
4948
4933
|
term: string | {
|
|
4949
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4934
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "avatar" | "signature" | "middlename";
|
|
4950
4935
|
$location?: string | undefined;
|
|
4951
4936
|
};
|
|
4952
4937
|
} | undefined;
|
|
4953
4938
|
updatedAtLocation?: {
|
|
4954
4939
|
type: "within";
|
|
4955
4940
|
location: string | {
|
|
4956
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4941
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "avatar" | "signature" | "middlename";
|
|
4957
4942
|
$location?: string | undefined;
|
|
4958
4943
|
};
|
|
4959
4944
|
} | {
|
|
4960
4945
|
type: "exact";
|
|
4961
4946
|
term: string | {
|
|
4962
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4947
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "avatar" | "signature" | "middlename";
|
|
4963
4948
|
$location?: string | undefined;
|
|
4964
4949
|
};
|
|
4965
4950
|
} | undefined;
|
|
4966
4951
|
updatedByUserRole?: {
|
|
4967
4952
|
type: "exact";
|
|
4968
4953
|
term: string | {
|
|
4969
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4954
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "avatar" | "signature" | "middlename";
|
|
4970
4955
|
$location?: string | undefined;
|
|
4971
4956
|
};
|
|
4972
4957
|
} | undefined;
|
|
4973
4958
|
assignedTo?: {
|
|
4974
4959
|
type: "exact";
|
|
4975
4960
|
term: string | {
|
|
4976
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4961
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "avatar" | "signature" | "middlename";
|
|
4977
4962
|
$location?: string | undefined;
|
|
4978
4963
|
};
|
|
4979
4964
|
} | undefined;
|
|
4980
4965
|
createdBy?: {
|
|
4981
4966
|
type: "exact";
|
|
4982
4967
|
term: string | {
|
|
4983
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4968
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "avatar" | "signature" | "middlename";
|
|
4984
4969
|
$location?: string | undefined;
|
|
4985
4970
|
};
|
|
4986
4971
|
} | undefined;
|
|
@@ -4991,7 +4976,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4991
4976
|
updatedBy?: {
|
|
4992
4977
|
type: "exact";
|
|
4993
4978
|
term: string | {
|
|
4994
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4979
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "avatar" | "signature" | "middlename";
|
|
4995
4980
|
$location?: string | undefined;
|
|
4996
4981
|
};
|
|
4997
4982
|
} | undefined;
|
|
@@ -86,17 +86,17 @@ export declare const user: typeof userSerializer & {
|
|
|
86
86
|
};
|
|
87
87
|
scope: (scope: import("../scopes").ScopeType) => {
|
|
88
88
|
attribute: (option: import("../scopes").ScopeOptionKey) => {
|
|
89
|
-
$scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "workqueue" | "dashboard.view";
|
|
90
|
-
$option: "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
89
|
+
$scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "user.search" | "workqueue" | "dashboard.view";
|
|
90
|
+
$option: "role" | "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
91
91
|
};
|
|
92
92
|
};
|
|
93
93
|
jurisdiction: (jurisdiction: import("../scopes").JurisdictionFilter | {
|
|
94
|
-
$scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "workqueue" | "dashboard.view";
|
|
95
|
-
$option: "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
94
|
+
$scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "user.search" | "workqueue" | "dashboard.view";
|
|
95
|
+
$option: "role" | "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
96
96
|
}) => {
|
|
97
97
|
$jurisdiction: "administrativeArea" | "location" | "all" | {
|
|
98
|
-
$scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "workqueue" | "dashboard.view";
|
|
99
|
-
$option: "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
98
|
+
$scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "user.search" | "workqueue" | "dashboard.view";
|
|
99
|
+
$option: "role" | "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
100
100
|
};
|
|
101
101
|
};
|
|
102
102
|
};
|
|
@@ -1723,10 +1723,12 @@ declare const AdministrativeAreaField: z.ZodObject<{
|
|
|
1723
1723
|
"user.read": "user.read";
|
|
1724
1724
|
"user.create": "user.create";
|
|
1725
1725
|
"user.edit": "user.edit";
|
|
1726
|
+
"user.search": "user.search";
|
|
1726
1727
|
workqueue: "workqueue";
|
|
1727
1728
|
"dashboard.view": "dashboard.view";
|
|
1728
1729
|
}>;
|
|
1729
1730
|
$option: z.ZodEnum<{
|
|
1731
|
+
role: "role";
|
|
1730
1732
|
event: "event";
|
|
1731
1733
|
placeOfEvent: "placeOfEvent";
|
|
1732
1734
|
declaredIn: "declaredIn";
|
|
@@ -1841,10 +1843,12 @@ declare const LocationInput: z.ZodObject<{
|
|
|
1841
1843
|
"user.read": "user.read";
|
|
1842
1844
|
"user.create": "user.create";
|
|
1843
1845
|
"user.edit": "user.edit";
|
|
1846
|
+
"user.search": "user.search";
|
|
1844
1847
|
workqueue: "workqueue";
|
|
1845
1848
|
"dashboard.view": "dashboard.view";
|
|
1846
1849
|
}>;
|
|
1847
1850
|
$option: z.ZodEnum<{
|
|
1851
|
+
role: "role";
|
|
1848
1852
|
event: "event";
|
|
1849
1853
|
placeOfEvent: "placeOfEvent";
|
|
1850
1854
|
declaredIn: "declaredIn";
|
|
@@ -2024,10 +2028,12 @@ declare const Facility: z.ZodObject<{
|
|
|
2024
2028
|
"user.read": "user.read";
|
|
2025
2029
|
"user.create": "user.create";
|
|
2026
2030
|
"user.edit": "user.edit";
|
|
2031
|
+
"user.search": "user.search";
|
|
2027
2032
|
workqueue: "workqueue";
|
|
2028
2033
|
"dashboard.view": "dashboard.view";
|
|
2029
2034
|
}>;
|
|
2030
2035
|
$option: z.ZodEnum<{
|
|
2036
|
+
role: "role";
|
|
2031
2037
|
event: "event";
|
|
2032
2038
|
placeOfEvent: "placeOfEvent";
|
|
2033
2039
|
declaredIn: "declaredIn";
|
|
@@ -2128,10 +2134,12 @@ declare const Office: z.ZodObject<{
|
|
|
2128
2134
|
"user.read": "user.read";
|
|
2129
2135
|
"user.create": "user.create";
|
|
2130
2136
|
"user.edit": "user.edit";
|
|
2137
|
+
"user.search": "user.search";
|
|
2131
2138
|
workqueue: "workqueue";
|
|
2132
2139
|
"dashboard.view": "dashboard.view";
|
|
2133
2140
|
}>;
|
|
2134
2141
|
$option: z.ZodEnum<{
|
|
2142
|
+
role: "role";
|
|
2135
2143
|
event: "event";
|
|
2136
2144
|
placeOfEvent: "placeOfEvent";
|
|
2137
2145
|
declaredIn: "declaredIn";
|
|
@@ -2319,10 +2327,12 @@ declare const Address: z.ZodObject<{
|
|
|
2319
2327
|
"user.read": "user.read";
|
|
2320
2328
|
"user.create": "user.create";
|
|
2321
2329
|
"user.edit": "user.edit";
|
|
2330
|
+
"user.search": "user.search";
|
|
2322
2331
|
workqueue: "workqueue";
|
|
2323
2332
|
"dashboard.view": "dashboard.view";
|
|
2324
2333
|
}>;
|
|
2325
2334
|
$option: z.ZodEnum<{
|
|
2335
|
+
role: "role";
|
|
2326
2336
|
event: "event";
|
|
2327
2337
|
placeOfEvent: "placeOfEvent";
|
|
2328
2338
|
declaredIn: "declaredIn";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { UUID } from '../uuid';
|
|
1
2
|
import * as z from 'zod/v4';
|
|
2
3
|
import { EventIndex } from './EventIndex';
|
|
3
4
|
import { ActionCreationMetadata, RegistrationCreationMetadata } from './EventMetadata';
|
|
4
|
-
import { RecordScopeV2 } from '../scopes';
|
|
5
|
+
import { RecordScopeV2, UserScopeV2 } from '../scopes';
|
|
5
6
|
import { SystemContext, UserContext } from '../users/User';
|
|
6
7
|
/** @deprecated Moving on, location types are arbitrary and defined by the country config. */
|
|
7
8
|
export declare const LocationTypeV1: z.ZodEnum<{
|
|
@@ -51,6 +52,21 @@ export type EventIndexWithAdministrativeHierarchy = Omit<ToArrayFields<EventInde
|
|
|
51
52
|
*
|
|
52
53
|
*/
|
|
53
54
|
export declare function canAccessEventWithScope(event: Partial<EventIndexWithAdministrativeHierarchy>, scope: RecordScopeV2, user: UserContext | SystemContext, customActionType?: string): boolean;
|
|
55
|
+
export type UserWithResolvedHierarchy = {
|
|
56
|
+
role: string;
|
|
57
|
+
administrativeHierarchy: UUID[];
|
|
58
|
+
primaryOfficeId: UUID;
|
|
59
|
+
};
|
|
60
|
+
export declare function canAccessUserWithScope({ userToAccess, scope, user }: {
|
|
61
|
+
userToAccess: UserWithResolvedHierarchy;
|
|
62
|
+
scope: UserScopeV2;
|
|
63
|
+
user: UserContext | SystemContext;
|
|
64
|
+
}): boolean;
|
|
65
|
+
export declare function canAccessOtherUserWithScopes({ scopes, userToAccess, user }: {
|
|
66
|
+
scopes: UserScopeV2[];
|
|
67
|
+
userToAccess: UserWithResolvedHierarchy;
|
|
68
|
+
user: UserContext | SystemContext;
|
|
69
|
+
}): boolean;
|
|
54
70
|
/**
|
|
55
71
|
* Given indexed event and list of resolved scopes, determine if any of the scopes allow access to the event.
|
|
56
72
|
*
|
|
@@ -182,6 +182,10 @@ var scopeByEvent = z6.preprocess(
|
|
|
182
182
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
183
183
|
z6.array(z6.string()).optional()
|
|
184
184
|
).describe("Event type, e.g. birth, death");
|
|
185
|
+
var userRole = z6.preprocess(
|
|
186
|
+
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
187
|
+
z6.array(z6.string()).optional()
|
|
188
|
+
).describe("User role, e.g. admin, field agent");
|
|
185
189
|
var scopeOptionsPlaceEvent = z6.object({
|
|
186
190
|
event: scopeByEvent,
|
|
187
191
|
placeOfEvent: JurisdictionFilter.optional()
|
|
@@ -205,6 +209,9 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
|
205
209
|
var AccessLevelOptions = z6.object({
|
|
206
210
|
accessLevel: JurisdictionFilter.optional()
|
|
207
211
|
});
|
|
212
|
+
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
213
|
+
role: userRole.optional()
|
|
214
|
+
});
|
|
208
215
|
var WorkqueueOrDashboardOptions = z6.object({
|
|
209
216
|
ids: z6.preprocess(
|
|
210
217
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
@@ -214,6 +221,7 @@ var WorkqueueOrDashboardOptions = z6.object({
|
|
|
214
221
|
var AllScopeOptions = z6.object({
|
|
215
222
|
...AllRecordScopeOptions.shape,
|
|
216
223
|
...AccessLevelOptions.shape,
|
|
224
|
+
...AllUserScopeOptions.shape,
|
|
217
225
|
...WorkqueueOrDashboardOptions.shape
|
|
218
226
|
});
|
|
219
227
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
@@ -286,6 +294,30 @@ var RecordScopeV2 = z6.discriminatedUnion("type", [
|
|
|
286
294
|
]).describe(
|
|
287
295
|
"Scopes used to check user's permission to perform actions on a record."
|
|
288
296
|
);
|
|
297
|
+
var SystemScopeType = z6.enum([
|
|
298
|
+
"organisation.read-locations",
|
|
299
|
+
"user.read",
|
|
300
|
+
"user.create",
|
|
301
|
+
"user.edit",
|
|
302
|
+
"user.search"
|
|
303
|
+
]);
|
|
304
|
+
var UserScopeType = SystemScopeType.extract([
|
|
305
|
+
"user.read",
|
|
306
|
+
"user.create",
|
|
307
|
+
"user.edit",
|
|
308
|
+
"user.search"
|
|
309
|
+
]);
|
|
310
|
+
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
311
|
+
var UserScopeV2 = z6.discriminatedUnion("type", [
|
|
312
|
+
z6.object({
|
|
313
|
+
type: ScopesWithRoleOption,
|
|
314
|
+
options: AllUserScopeOptions.optional()
|
|
315
|
+
}),
|
|
316
|
+
z6.object({
|
|
317
|
+
type: UserScopeType.extract(["user.read", "user.search"]),
|
|
318
|
+
options: AccessLevelOptions.optional()
|
|
319
|
+
})
|
|
320
|
+
]);
|
|
289
321
|
var ResolvedRecordScopeV2 = z6.discriminatedUnion("type", [
|
|
290
322
|
z6.object({
|
|
291
323
|
type: ScopesWithPlaceEventOptions,
|
|
@@ -306,16 +338,14 @@ var ResolvedRecordScopeV2 = z6.discriminatedUnion("type", [
|
|
|
306
338
|
}).optional()
|
|
307
339
|
})
|
|
308
340
|
]).describe("Resolved scope with location/user IDs instead of filters.");
|
|
309
|
-
var SystemScopeType = z6.enum([
|
|
310
|
-
"organisation.read-locations",
|
|
311
|
-
"user.read",
|
|
312
|
-
"user.create",
|
|
313
|
-
"user.edit"
|
|
314
|
-
]);
|
|
315
341
|
var Scope2 = z6.discriminatedUnion("type", [
|
|
316
342
|
z6.object({ type: PlainScopeType }),
|
|
317
343
|
...RecordScopeV2.options,
|
|
318
|
-
|
|
344
|
+
...UserScopeV2.options,
|
|
345
|
+
z6.object({
|
|
346
|
+
type: z6.literal("organisation.read-locations"),
|
|
347
|
+
options: AccessLevelOptions.optional()
|
|
348
|
+
}),
|
|
319
349
|
z6.object({
|
|
320
350
|
type: z6.literal("workqueue"),
|
|
321
351
|
options: WorkqueueOrDashboardOptions
|
package/dist/events/index.js
CHANGED
|
@@ -243,6 +243,8 @@ __export(events_exports, {
|
|
|
243
243
|
areConditionsMet: () => areConditionsMet,
|
|
244
244
|
buildFormState: () => buildFormState,
|
|
245
245
|
canAccessEventWithScope: () => canAccessEventWithScope,
|
|
246
|
+
canAccessOtherUserWithScopes: () => canAccessOtherUserWithScopes,
|
|
247
|
+
canAccessUserWithScope: () => canAccessUserWithScope,
|
|
246
248
|
compositeFieldTypes: () => compositeFieldTypes,
|
|
247
249
|
createEmptyDraft: () => createEmptyDraft,
|
|
248
250
|
createFieldConditionals: () => createFieldConditionals,
|
|
@@ -489,6 +491,10 @@ var scopeByEvent = z2.preprocess(
|
|
|
489
491
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
490
492
|
z2.array(z2.string()).optional()
|
|
491
493
|
).describe("Event type, e.g. birth, death");
|
|
494
|
+
var userRole = z2.preprocess(
|
|
495
|
+
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
496
|
+
z2.array(z2.string()).optional()
|
|
497
|
+
).describe("User role, e.g. admin, field agent");
|
|
492
498
|
var scopeOptionsPlaceEvent = z2.object({
|
|
493
499
|
event: scopeByEvent,
|
|
494
500
|
placeOfEvent: JurisdictionFilter.optional()
|
|
@@ -512,6 +518,9 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
|
512
518
|
var AccessLevelOptions = z2.object({
|
|
513
519
|
accessLevel: JurisdictionFilter.optional()
|
|
514
520
|
});
|
|
521
|
+
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
522
|
+
role: userRole.optional()
|
|
523
|
+
});
|
|
515
524
|
var WorkqueueOrDashboardOptions = z2.object({
|
|
516
525
|
ids: z2.preprocess(
|
|
517
526
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
@@ -521,6 +530,7 @@ var WorkqueueOrDashboardOptions = z2.object({
|
|
|
521
530
|
var AllScopeOptions = z2.object({
|
|
522
531
|
...AllRecordScopeOptions.shape,
|
|
523
532
|
...AccessLevelOptions.shape,
|
|
533
|
+
...AllUserScopeOptions.shape,
|
|
524
534
|
...WorkqueueOrDashboardOptions.shape
|
|
525
535
|
});
|
|
526
536
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
@@ -593,6 +603,33 @@ var RecordScopeV2 = z2.discriminatedUnion("type", [
|
|
|
593
603
|
]).describe(
|
|
594
604
|
"Scopes used to check user's permission to perform actions on a record."
|
|
595
605
|
);
|
|
606
|
+
var SystemScopeType = z2.enum([
|
|
607
|
+
"organisation.read-locations",
|
|
608
|
+
"user.read",
|
|
609
|
+
"user.create",
|
|
610
|
+
"user.edit",
|
|
611
|
+
"user.search"
|
|
612
|
+
]);
|
|
613
|
+
var UserScopeType = SystemScopeType.extract([
|
|
614
|
+
"user.read",
|
|
615
|
+
"user.create",
|
|
616
|
+
"user.edit",
|
|
617
|
+
"user.search"
|
|
618
|
+
]);
|
|
619
|
+
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
620
|
+
var UserScopeV2 = z2.discriminatedUnion("type", [
|
|
621
|
+
z2.object({
|
|
622
|
+
type: ScopesWithRoleOption,
|
|
623
|
+
options: AllUserScopeOptions.optional()
|
|
624
|
+
}),
|
|
625
|
+
z2.object({
|
|
626
|
+
type: UserScopeType.extract(["user.read", "user.search"]),
|
|
627
|
+
options: AccessLevelOptions.optional()
|
|
628
|
+
})
|
|
629
|
+
]);
|
|
630
|
+
function scopeUsesRoleOptions(scope) {
|
|
631
|
+
return ScopesWithRoleOption?.options.some((opt) => opt === scope.type);
|
|
632
|
+
}
|
|
596
633
|
function scopeUsesDeclaredOptions(scope) {
|
|
597
634
|
return !ScopesWithPlaceEventOptions.options.some((opt) => opt === scope.type);
|
|
598
635
|
}
|
|
@@ -625,16 +662,14 @@ var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
|
|
|
625
662
|
}).optional()
|
|
626
663
|
})
|
|
627
664
|
]).describe("Resolved scope with location/user IDs instead of filters.");
|
|
628
|
-
var SystemScopeType = z2.enum([
|
|
629
|
-
"organisation.read-locations",
|
|
630
|
-
"user.read",
|
|
631
|
-
"user.create",
|
|
632
|
-
"user.edit"
|
|
633
|
-
]);
|
|
634
665
|
var Scope = z2.discriminatedUnion("type", [
|
|
635
666
|
z2.object({ type: PlainScopeType }),
|
|
636
667
|
...RecordScopeV2.options,
|
|
637
|
-
|
|
668
|
+
...UserScopeV2.options,
|
|
669
|
+
z2.object({
|
|
670
|
+
type: z2.literal("organisation.read-locations"),
|
|
671
|
+
options: AccessLevelOptions.optional()
|
|
672
|
+
}),
|
|
638
673
|
z2.object({
|
|
639
674
|
type: z2.literal("workqueue"),
|
|
640
675
|
options: WorkqueueOrDashboardOptions
|
|
@@ -9930,6 +9965,39 @@ function canAccessEventWithScope(event2, scope, user2, customActionType) {
|
|
|
9930
9965
|
}
|
|
9931
9966
|
return true;
|
|
9932
9967
|
}
|
|
9968
|
+
function canAccessUserWithScope({
|
|
9969
|
+
userToAccess,
|
|
9970
|
+
scope,
|
|
9971
|
+
user: user2
|
|
9972
|
+
}) {
|
|
9973
|
+
const opts = scope.options;
|
|
9974
|
+
const hasSameOffice = user2.primaryOfficeId === userToAccess.primaryOfficeId;
|
|
9975
|
+
if (opts?.accessLevel === JurisdictionFilter.enum.location && !hasSameOffice) {
|
|
9976
|
+
return false;
|
|
9977
|
+
}
|
|
9978
|
+
const hasAdministrativeAreaInHierarchy = userToAccess.administrativeHierarchy.some(
|
|
9979
|
+
(id) => user2.administrativeAreaId === id
|
|
9980
|
+
) || user2.administrativeAreaId === null;
|
|
9981
|
+
if (opts?.accessLevel === JurisdictionFilter.enum.administrativeArea && !hasAdministrativeAreaInHierarchy) {
|
|
9982
|
+
return false;
|
|
9983
|
+
}
|
|
9984
|
+
if (scopeUsesRoleOptions(scope)) {
|
|
9985
|
+
const { options } = scope;
|
|
9986
|
+
if (options?.role && !options.role.includes(userToAccess.role)) {
|
|
9987
|
+
return false;
|
|
9988
|
+
}
|
|
9989
|
+
}
|
|
9990
|
+
return true;
|
|
9991
|
+
}
|
|
9992
|
+
function canAccessOtherUserWithScopes({
|
|
9993
|
+
scopes,
|
|
9994
|
+
userToAccess,
|
|
9995
|
+
user: user2
|
|
9996
|
+
}) {
|
|
9997
|
+
return scopes.some(
|
|
9998
|
+
(scope) => canAccessUserWithScope({ userToAccess, scope, user: user2 })
|
|
9999
|
+
);
|
|
10000
|
+
}
|
|
9933
10001
|
function userCanAccessEventWithScopes(event2, scopes, user2, customActionType) {
|
|
9934
10002
|
return scopes.some(
|
|
9935
10003
|
(scope) => canAccessEventWithScope(event2, scope, user2, customActionType)
|
|
@@ -2122,6 +2122,10 @@ var scopeByEvent = z3.preprocess(
|
|
|
2122
2122
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
2123
2123
|
z3.array(z3.string()).optional()
|
|
2124
2124
|
).describe("Event type, e.g. birth, death");
|
|
2125
|
+
var userRole = z3.preprocess(
|
|
2126
|
+
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
2127
|
+
z3.array(z3.string()).optional()
|
|
2128
|
+
).describe("User role, e.g. admin, field agent");
|
|
2125
2129
|
var scopeOptionsPlaceEvent = z3.object({
|
|
2126
2130
|
event: scopeByEvent,
|
|
2127
2131
|
placeOfEvent: JurisdictionFilter.optional()
|
|
@@ -2145,6 +2149,9 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
|
2145
2149
|
var AccessLevelOptions = z3.object({
|
|
2146
2150
|
accessLevel: JurisdictionFilter.optional()
|
|
2147
2151
|
});
|
|
2152
|
+
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
2153
|
+
role: userRole.optional()
|
|
2154
|
+
});
|
|
2148
2155
|
var WorkqueueOrDashboardOptions = z3.object({
|
|
2149
2156
|
ids: z3.preprocess(
|
|
2150
2157
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
@@ -2154,6 +2161,7 @@ var WorkqueueOrDashboardOptions = z3.object({
|
|
|
2154
2161
|
var AllScopeOptions = z3.object({
|
|
2155
2162
|
...AllRecordScopeOptions.shape,
|
|
2156
2163
|
...AccessLevelOptions.shape,
|
|
2164
|
+
...AllUserScopeOptions.shape,
|
|
2157
2165
|
...WorkqueueOrDashboardOptions.shape
|
|
2158
2166
|
});
|
|
2159
2167
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
@@ -2226,6 +2234,30 @@ var RecordScopeV2 = z3.discriminatedUnion("type", [
|
|
|
2226
2234
|
]).describe(
|
|
2227
2235
|
"Scopes used to check user's permission to perform actions on a record."
|
|
2228
2236
|
);
|
|
2237
|
+
var SystemScopeType = z3.enum([
|
|
2238
|
+
"organisation.read-locations",
|
|
2239
|
+
"user.read",
|
|
2240
|
+
"user.create",
|
|
2241
|
+
"user.edit",
|
|
2242
|
+
"user.search"
|
|
2243
|
+
]);
|
|
2244
|
+
var UserScopeType = SystemScopeType.extract([
|
|
2245
|
+
"user.read",
|
|
2246
|
+
"user.create",
|
|
2247
|
+
"user.edit",
|
|
2248
|
+
"user.search"
|
|
2249
|
+
]);
|
|
2250
|
+
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
2251
|
+
var UserScopeV2 = z3.discriminatedUnion("type", [
|
|
2252
|
+
z3.object({
|
|
2253
|
+
type: ScopesWithRoleOption,
|
|
2254
|
+
options: AllUserScopeOptions.optional()
|
|
2255
|
+
}),
|
|
2256
|
+
z3.object({
|
|
2257
|
+
type: UserScopeType.extract(["user.read", "user.search"]),
|
|
2258
|
+
options: AccessLevelOptions.optional()
|
|
2259
|
+
})
|
|
2260
|
+
]);
|
|
2229
2261
|
var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
|
|
2230
2262
|
z3.object({
|
|
2231
2263
|
type: ScopesWithPlaceEventOptions,
|
|
@@ -2246,16 +2278,14 @@ var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
|
|
|
2246
2278
|
}).optional()
|
|
2247
2279
|
})
|
|
2248
2280
|
]).describe("Resolved scope with location/user IDs instead of filters.");
|
|
2249
|
-
var SystemScopeType = z3.enum([
|
|
2250
|
-
"organisation.read-locations",
|
|
2251
|
-
"user.read",
|
|
2252
|
-
"user.create",
|
|
2253
|
-
"user.edit"
|
|
2254
|
-
]);
|
|
2255
2281
|
var Scope2 = z3.discriminatedUnion("type", [
|
|
2256
2282
|
z3.object({ type: PlainScopeType }),
|
|
2257
2283
|
...RecordScopeV2.options,
|
|
2258
|
-
|
|
2284
|
+
...UserScopeV2.options,
|
|
2285
|
+
z3.object({
|
|
2286
|
+
type: z3.literal("organisation.read-locations"),
|
|
2287
|
+
options: AccessLevelOptions.optional()
|
|
2288
|
+
}),
|
|
2259
2289
|
z3.object({
|
|
2260
2290
|
type: z3.literal("workqueue"),
|
|
2261
2291
|
options: WorkqueueOrDashboardOptions
|
|
@@ -110,6 +110,10 @@ var scopeByEvent = z2.preprocess(
|
|
|
110
110
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
111
111
|
z2.array(z2.string()).optional()
|
|
112
112
|
).describe("Event type, e.g. birth, death");
|
|
113
|
+
var userRole = z2.preprocess(
|
|
114
|
+
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
115
|
+
z2.array(z2.string()).optional()
|
|
116
|
+
).describe("User role, e.g. admin, field agent");
|
|
113
117
|
var scopeOptionsPlaceEvent = z2.object({
|
|
114
118
|
event: scopeByEvent,
|
|
115
119
|
placeOfEvent: JurisdictionFilter.optional()
|
|
@@ -133,6 +137,9 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
|
133
137
|
var AccessLevelOptions = z2.object({
|
|
134
138
|
accessLevel: JurisdictionFilter.optional()
|
|
135
139
|
});
|
|
140
|
+
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
141
|
+
role: userRole.optional()
|
|
142
|
+
});
|
|
136
143
|
var WorkqueueOrDashboardOptions = z2.object({
|
|
137
144
|
ids: z2.preprocess(
|
|
138
145
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
@@ -142,6 +149,7 @@ var WorkqueueOrDashboardOptions = z2.object({
|
|
|
142
149
|
var AllScopeOptions = z2.object({
|
|
143
150
|
...AllRecordScopeOptions.shape,
|
|
144
151
|
...AccessLevelOptions.shape,
|
|
152
|
+
...AllUserScopeOptions.shape,
|
|
145
153
|
...WorkqueueOrDashboardOptions.shape
|
|
146
154
|
});
|
|
147
155
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
@@ -214,6 +222,30 @@ var RecordScopeV2 = z2.discriminatedUnion("type", [
|
|
|
214
222
|
]).describe(
|
|
215
223
|
"Scopes used to check user's permission to perform actions on a record."
|
|
216
224
|
);
|
|
225
|
+
var SystemScopeType = z2.enum([
|
|
226
|
+
"organisation.read-locations",
|
|
227
|
+
"user.read",
|
|
228
|
+
"user.create",
|
|
229
|
+
"user.edit",
|
|
230
|
+
"user.search"
|
|
231
|
+
]);
|
|
232
|
+
var UserScopeType = SystemScopeType.extract([
|
|
233
|
+
"user.read",
|
|
234
|
+
"user.create",
|
|
235
|
+
"user.edit",
|
|
236
|
+
"user.search"
|
|
237
|
+
]);
|
|
238
|
+
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
239
|
+
var UserScopeV2 = z2.discriminatedUnion("type", [
|
|
240
|
+
z2.object({
|
|
241
|
+
type: ScopesWithRoleOption,
|
|
242
|
+
options: AllUserScopeOptions.optional()
|
|
243
|
+
}),
|
|
244
|
+
z2.object({
|
|
245
|
+
type: UserScopeType.extract(["user.read", "user.search"]),
|
|
246
|
+
options: AccessLevelOptions.optional()
|
|
247
|
+
})
|
|
248
|
+
]);
|
|
217
249
|
var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
|
|
218
250
|
z2.object({
|
|
219
251
|
type: ScopesWithPlaceEventOptions,
|
|
@@ -234,16 +266,14 @@ var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
|
|
|
234
266
|
}).optional()
|
|
235
267
|
})
|
|
236
268
|
]).describe("Resolved scope with location/user IDs instead of filters.");
|
|
237
|
-
var SystemScopeType = z2.enum([
|
|
238
|
-
"organisation.read-locations",
|
|
239
|
-
"user.read",
|
|
240
|
-
"user.create",
|
|
241
|
-
"user.edit"
|
|
242
|
-
]);
|
|
243
269
|
var Scope = z2.discriminatedUnion("type", [
|
|
244
270
|
z2.object({ type: PlainScopeType }),
|
|
245
271
|
...RecordScopeV2.options,
|
|
246
|
-
|
|
272
|
+
...UserScopeV2.options,
|
|
273
|
+
z2.object({
|
|
274
|
+
type: z2.literal("organisation.read-locations"),
|
|
275
|
+
options: AccessLevelOptions.optional()
|
|
276
|
+
}),
|
|
247
277
|
z2.object({
|
|
248
278
|
type: z2.literal("workqueue"),
|
|
249
279
|
options: WorkqueueOrDashboardOptions
|
package/dist/scopes/index.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ declare const AllScopeOptions: z.ZodObject<{
|
|
|
41
41
|
location: "location";
|
|
42
42
|
all: "all";
|
|
43
43
|
}>>;
|
|
44
|
+
role: z.ZodOptional<z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>>;
|
|
44
45
|
event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
45
46
|
placeOfEvent: z.ZodOptional<z.ZodEnum<{
|
|
46
47
|
administrativeArea: "administrativeArea";
|
|
@@ -66,6 +67,7 @@ declare const AllScopeOptions: z.ZodObject<{
|
|
|
66
67
|
}, z.core.$strip>;
|
|
67
68
|
type AllScopeOptions = z.infer<typeof AllScopeOptions>;
|
|
68
69
|
export declare const ScopeOptionKey: z.ZodEnum<{
|
|
70
|
+
role: "role";
|
|
69
71
|
event: "event";
|
|
70
72
|
placeOfEvent: "placeOfEvent";
|
|
71
73
|
declaredIn: "declaredIn";
|
|
@@ -220,6 +222,56 @@ export declare const RecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
220
222
|
templates: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
221
223
|
}, z.core.$strip>>;
|
|
222
224
|
}, z.core.$strip>], "type">;
|
|
225
|
+
declare const SystemScopeType: z.ZodEnum<{
|
|
226
|
+
"organisation.read-locations": "organisation.read-locations";
|
|
227
|
+
"user.read": "user.read";
|
|
228
|
+
"user.create": "user.create";
|
|
229
|
+
"user.edit": "user.edit";
|
|
230
|
+
"user.search": "user.search";
|
|
231
|
+
}>;
|
|
232
|
+
export type SystemScopeType = z.infer<typeof SystemScopeType>;
|
|
233
|
+
declare const UserScopeType: z.ZodEnum<{
|
|
234
|
+
"user.read": "user.read";
|
|
235
|
+
"user.create": "user.create";
|
|
236
|
+
"user.edit": "user.edit";
|
|
237
|
+
"user.search": "user.search";
|
|
238
|
+
}>;
|
|
239
|
+
export type UserScopeType = z.infer<typeof UserScopeType>;
|
|
240
|
+
declare const ScopesWithRoleOption: z.ZodEnum<{
|
|
241
|
+
"user.create": "user.create";
|
|
242
|
+
"user.edit": "user.edit";
|
|
243
|
+
}>;
|
|
244
|
+
export type ScopesWithRoleOption = z.infer<typeof ScopesWithRoleOption>;
|
|
245
|
+
export declare const UserScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
246
|
+
type: z.ZodEnum<{
|
|
247
|
+
"user.create": "user.create";
|
|
248
|
+
"user.edit": "user.edit";
|
|
249
|
+
}>;
|
|
250
|
+
options: z.ZodOptional<z.ZodObject<{
|
|
251
|
+
accessLevel: z.ZodOptional<z.ZodEnum<{
|
|
252
|
+
administrativeArea: "administrativeArea";
|
|
253
|
+
location: "location";
|
|
254
|
+
all: "all";
|
|
255
|
+
}>>;
|
|
256
|
+
role: z.ZodOptional<z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>>;
|
|
257
|
+
}, z.core.$strip>>;
|
|
258
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
259
|
+
type: z.ZodEnum<{
|
|
260
|
+
"user.read": "user.read";
|
|
261
|
+
"user.search": "user.search";
|
|
262
|
+
}>;
|
|
263
|
+
options: z.ZodOptional<z.ZodObject<{
|
|
264
|
+
accessLevel: z.ZodOptional<z.ZodEnum<{
|
|
265
|
+
administrativeArea: "administrativeArea";
|
|
266
|
+
location: "location";
|
|
267
|
+
all: "all";
|
|
268
|
+
}>>;
|
|
269
|
+
}, z.core.$strip>>;
|
|
270
|
+
}, z.core.$strip>], "type">;
|
|
271
|
+
export type UserScopeV2 = z.infer<typeof UserScopeV2>;
|
|
272
|
+
export declare function scopeUsesRoleOptions(scope: UserScopeV2): scope is Extract<UserScopeV2, {
|
|
273
|
+
type: ScopesWithRoleOption;
|
|
274
|
+
}>;
|
|
223
275
|
export declare function scopeUsesDeclaredOptions(scope: Scope): scope is Extract<Scope, {
|
|
224
276
|
type: z.infer<typeof ScopesWithDeclaredOptions>;
|
|
225
277
|
}>;
|
|
@@ -286,13 +338,6 @@ export declare const ResolvedRecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
286
338
|
}, z.core.$strip>], "type">;
|
|
287
339
|
export type RecordScopeV2 = z.infer<typeof RecordScopeV2>;
|
|
288
340
|
export type ResolvedRecordScopeV2 = z.infer<typeof ResolvedRecordScopeV2>;
|
|
289
|
-
declare const SystemScopeType: z.ZodEnum<{
|
|
290
|
-
"organisation.read-locations": "organisation.read-locations";
|
|
291
|
-
"user.read": "user.read";
|
|
292
|
-
"user.create": "user.create";
|
|
293
|
-
"user.edit": "user.edit";
|
|
294
|
-
}>;
|
|
295
|
-
export type SystemScopeType = z.infer<typeof SystemScopeType>;
|
|
296
341
|
/** The primary scope schema which gathers all scope types together. All scopes are discriminated by type and options are determined according to the type. */
|
|
297
342
|
export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
298
343
|
type: z.ZodEnum<{
|
|
@@ -437,11 +482,31 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
437
482
|
}, z.core.$strip>>;
|
|
438
483
|
}, z.core.$strip>, z.ZodObject<{
|
|
439
484
|
type: z.ZodEnum<{
|
|
440
|
-
"organisation.read-locations": "organisation.read-locations";
|
|
441
|
-
"user.read": "user.read";
|
|
442
485
|
"user.create": "user.create";
|
|
443
486
|
"user.edit": "user.edit";
|
|
444
487
|
}>;
|
|
488
|
+
options: z.ZodOptional<z.ZodObject<{
|
|
489
|
+
accessLevel: z.ZodOptional<z.ZodEnum<{
|
|
490
|
+
administrativeArea: "administrativeArea";
|
|
491
|
+
location: "location";
|
|
492
|
+
all: "all";
|
|
493
|
+
}>>;
|
|
494
|
+
role: z.ZodOptional<z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>>;
|
|
495
|
+
}, z.core.$strip>>;
|
|
496
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
497
|
+
type: z.ZodEnum<{
|
|
498
|
+
"user.read": "user.read";
|
|
499
|
+
"user.search": "user.search";
|
|
500
|
+
}>;
|
|
501
|
+
options: z.ZodOptional<z.ZodObject<{
|
|
502
|
+
accessLevel: z.ZodOptional<z.ZodEnum<{
|
|
503
|
+
administrativeArea: "administrativeArea";
|
|
504
|
+
location: "location";
|
|
505
|
+
all: "all";
|
|
506
|
+
}>>;
|
|
507
|
+
}, z.core.$strip>>;
|
|
508
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
509
|
+
type: z.ZodLiteral<"organisation.read-locations">;
|
|
445
510
|
options: z.ZodOptional<z.ZodObject<{
|
|
446
511
|
accessLevel: z.ZodOptional<z.ZodEnum<{
|
|
447
512
|
administrativeArea: "administrativeArea";
|
|
@@ -495,6 +560,7 @@ export declare const ScopeType: z.ZodEnum<{
|
|
|
495
560
|
"user.read": "user.read";
|
|
496
561
|
"user.create": "user.create";
|
|
497
562
|
"user.edit": "user.edit";
|
|
563
|
+
"user.search": "user.search";
|
|
498
564
|
workqueue: "workqueue";
|
|
499
565
|
"dashboard.view": "dashboard.view";
|
|
500
566
|
}>;
|
|
@@ -567,10 +633,21 @@ export declare const decodeScope: (query: EncodedScope) => {
|
|
|
567
633
|
registeredBy?: "user" | undefined;
|
|
568
634
|
templates?: string[] | undefined;
|
|
569
635
|
} | undefined;
|
|
636
|
+
} | {
|
|
637
|
+
type: "user.create" | "user.edit";
|
|
638
|
+
options?: {
|
|
639
|
+
accessLevel?: "administrativeArea" | "location" | "all" | undefined;
|
|
640
|
+
role?: string[] | undefined;
|
|
641
|
+
} | undefined;
|
|
642
|
+
} | {
|
|
643
|
+
type: "user.read" | "user.search";
|
|
644
|
+
options?: {
|
|
645
|
+
accessLevel?: "administrativeArea" | "location" | "all" | undefined;
|
|
646
|
+
} | undefined;
|
|
570
647
|
} | {
|
|
571
648
|
type: "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration";
|
|
572
649
|
} | {
|
|
573
|
-
type: "organisation.read-locations"
|
|
650
|
+
type: "organisation.read-locations";
|
|
574
651
|
options?: {
|
|
575
652
|
accessLevel?: "administrativeArea" | "location" | "all" | undefined;
|
|
576
653
|
} | undefined;
|
package/dist/scopes/index.js
CHANGED
|
@@ -42,6 +42,7 @@ __export(scopes_exports, {
|
|
|
42
42
|
ScopesWithFullOptions: () => ScopesWithFullOptions,
|
|
43
43
|
ScopesWithPlaceEventOptions: () => ScopesWithPlaceEventOptions,
|
|
44
44
|
UserFilter: () => UserFilter,
|
|
45
|
+
UserScopeV2: () => UserScopeV2,
|
|
45
46
|
canUserCreateEvent: () => canUserCreateEvent,
|
|
46
47
|
decodeScope: () => decodeScope,
|
|
47
48
|
defineRoles: () => defineRoles,
|
|
@@ -54,7 +55,8 @@ __export(scopes_exports, {
|
|
|
54
55
|
isCustomActionScope: () => isCustomActionScope,
|
|
55
56
|
scopeUsesDeclaredOptions: () => scopeUsesDeclaredOptions,
|
|
56
57
|
scopeUsesFullOptions: () => scopeUsesFullOptions,
|
|
57
|
-
scopeUsesPrintCertifiedCopiesOptions: () => scopeUsesPrintCertifiedCopiesOptions
|
|
58
|
+
scopeUsesPrintCertifiedCopiesOptions: () => scopeUsesPrintCertifiedCopiesOptions,
|
|
59
|
+
scopeUsesRoleOptions: () => scopeUsesRoleOptions
|
|
58
60
|
});
|
|
59
61
|
module.exports = __toCommonJS(scopes_exports);
|
|
60
62
|
var z4 = __toESM(require("zod/v4"));
|
|
@@ -139,6 +141,10 @@ var scopeByEvent = z3.preprocess(
|
|
|
139
141
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
140
142
|
z3.array(z3.string()).optional()
|
|
141
143
|
).describe("Event type, e.g. birth, death");
|
|
144
|
+
var userRole = z3.preprocess(
|
|
145
|
+
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
146
|
+
z3.array(z3.string()).optional()
|
|
147
|
+
).describe("User role, e.g. admin, field agent");
|
|
142
148
|
var scopeOptionsPlaceEvent = z3.object({
|
|
143
149
|
event: scopeByEvent,
|
|
144
150
|
placeOfEvent: JurisdictionFilter.optional()
|
|
@@ -162,6 +168,9 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
|
162
168
|
var AccessLevelOptions = z3.object({
|
|
163
169
|
accessLevel: JurisdictionFilter.optional()
|
|
164
170
|
});
|
|
171
|
+
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
172
|
+
role: userRole.optional()
|
|
173
|
+
});
|
|
165
174
|
var WorkqueueOrDashboardOptions = z3.object({
|
|
166
175
|
ids: z3.preprocess(
|
|
167
176
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
@@ -171,6 +180,7 @@ var WorkqueueOrDashboardOptions = z3.object({
|
|
|
171
180
|
var AllScopeOptions = z3.object({
|
|
172
181
|
...AllRecordScopeOptions.shape,
|
|
173
182
|
...AccessLevelOptions.shape,
|
|
183
|
+
...AllUserScopeOptions.shape,
|
|
174
184
|
...WorkqueueOrDashboardOptions.shape
|
|
175
185
|
});
|
|
176
186
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
@@ -243,6 +253,33 @@ var RecordScopeV2 = z3.discriminatedUnion("type", [
|
|
|
243
253
|
]).describe(
|
|
244
254
|
"Scopes used to check user's permission to perform actions on a record."
|
|
245
255
|
);
|
|
256
|
+
var SystemScopeType = z3.enum([
|
|
257
|
+
"organisation.read-locations",
|
|
258
|
+
"user.read",
|
|
259
|
+
"user.create",
|
|
260
|
+
"user.edit",
|
|
261
|
+
"user.search"
|
|
262
|
+
]);
|
|
263
|
+
var UserScopeType = SystemScopeType.extract([
|
|
264
|
+
"user.read",
|
|
265
|
+
"user.create",
|
|
266
|
+
"user.edit",
|
|
267
|
+
"user.search"
|
|
268
|
+
]);
|
|
269
|
+
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
270
|
+
var UserScopeV2 = z3.discriminatedUnion("type", [
|
|
271
|
+
z3.object({
|
|
272
|
+
type: ScopesWithRoleOption,
|
|
273
|
+
options: AllUserScopeOptions.optional()
|
|
274
|
+
}),
|
|
275
|
+
z3.object({
|
|
276
|
+
type: UserScopeType.extract(["user.read", "user.search"]),
|
|
277
|
+
options: AccessLevelOptions.optional()
|
|
278
|
+
})
|
|
279
|
+
]);
|
|
280
|
+
function scopeUsesRoleOptions(scope) {
|
|
281
|
+
return ScopesWithRoleOption?.options.some((opt) => opt === scope.type);
|
|
282
|
+
}
|
|
246
283
|
function scopeUsesDeclaredOptions(scope) {
|
|
247
284
|
return !ScopesWithPlaceEventOptions.options.some((opt) => opt === scope.type);
|
|
248
285
|
}
|
|
@@ -275,16 +312,14 @@ var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
|
|
|
275
312
|
}).optional()
|
|
276
313
|
})
|
|
277
314
|
]).describe("Resolved scope with location/user IDs instead of filters.");
|
|
278
|
-
var SystemScopeType = z3.enum([
|
|
279
|
-
"organisation.read-locations",
|
|
280
|
-
"user.read",
|
|
281
|
-
"user.create",
|
|
282
|
-
"user.edit"
|
|
283
|
-
]);
|
|
284
315
|
var Scope2 = z3.discriminatedUnion("type", [
|
|
285
316
|
z3.object({ type: PlainScopeType }),
|
|
286
317
|
...RecordScopeV2.options,
|
|
287
|
-
|
|
318
|
+
...UserScopeV2.options,
|
|
319
|
+
z3.object({
|
|
320
|
+
type: z3.literal("organisation.read-locations"),
|
|
321
|
+
options: AccessLevelOptions.optional()
|
|
322
|
+
}),
|
|
288
323
|
z3.object({
|
|
289
324
|
type: z3.literal("workqueue"),
|
|
290
325
|
options: WorkqueueOrDashboardOptions
|
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|