@opencrvs/toolkit 2.0.0-rc.dd19028 → 2.0.0-rc.df1ed4f
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 +11 -39
- package/dist/cli.js +7 -35
- package/dist/commons/api/router.d.ts +48 -41
- package/dist/commons/application-config/index.d.ts +16 -4
- package/dist/commons/conditionals/conditionals.d.ts +3 -3
- package/dist/commons/events/FieldConfig.d.ts +0 -5
- package/dist/commons/events/locations.d.ts +1 -17
- package/dist/conditionals/index.js +7 -35
- package/dist/events/index.js +7 -73
- package/dist/migrations/v2.0/index.js +7 -35
- package/dist/notification/index.js +7 -35
- package/dist/scopes/index.d.ts +10 -82
- package/dist/scopes/index.js +8 -41
- package/opencrvs-toolkit-2.0.0-rc.df1ed4f.tgz +0 -0
- package/package.json +1 -1
- package/opencrvs-toolkit-2.0.0-rc.dd19028.tgz +0 -0
|
@@ -656,10 +656,6 @@ 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");
|
|
663
659
|
var scopeOptionsPlaceEvent = z11.object({
|
|
664
660
|
event: scopeByEvent,
|
|
665
661
|
placeOfEvent: JurisdictionFilter.optional()
|
|
@@ -683,9 +679,6 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
|
683
679
|
var AccessLevelOptions = z11.object({
|
|
684
680
|
accessLevel: JurisdictionFilter.optional()
|
|
685
681
|
});
|
|
686
|
-
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
687
|
-
role: userRole.optional()
|
|
688
|
-
});
|
|
689
682
|
var WorkqueueOrDashboardOptions = z11.object({
|
|
690
683
|
ids: z11.preprocess(
|
|
691
684
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
@@ -695,7 +688,6 @@ var WorkqueueOrDashboardOptions = z11.object({
|
|
|
695
688
|
var AllScopeOptions = z11.object({
|
|
696
689
|
...AllRecordScopeOptions.shape,
|
|
697
690
|
...AccessLevelOptions.shape,
|
|
698
|
-
...AllUserScopeOptions.shape,
|
|
699
691
|
...WorkqueueOrDashboardOptions.shape
|
|
700
692
|
});
|
|
701
693
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
@@ -768,28 +760,6 @@ var RecordScopeV2 = z11.discriminatedUnion("type", [
|
|
|
768
760
|
]).describe(
|
|
769
761
|
"Scopes used to check user's permission to perform actions on a record."
|
|
770
762
|
);
|
|
771
|
-
var SystemScopeType = z11.enum([
|
|
772
|
-
"organisation.read-locations",
|
|
773
|
-
"user.read",
|
|
774
|
-
"user.create",
|
|
775
|
-
"user.edit"
|
|
776
|
-
]);
|
|
777
|
-
var UserScopeType = SystemScopeType.extract([
|
|
778
|
-
"user.read",
|
|
779
|
-
"user.create",
|
|
780
|
-
"user.edit"
|
|
781
|
-
]);
|
|
782
|
-
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
783
|
-
var UserScopeV2 = z11.discriminatedUnion("type", [
|
|
784
|
-
z11.object({
|
|
785
|
-
type: ScopesWithRoleOption,
|
|
786
|
-
options: AllUserScopeOptions.optional()
|
|
787
|
-
}),
|
|
788
|
-
z11.object({
|
|
789
|
-
type: UserScopeType.extract(["user.read"]),
|
|
790
|
-
options: AccessLevelOptions.optional()
|
|
791
|
-
})
|
|
792
|
-
]);
|
|
793
763
|
var ResolvedRecordScopeV2 = z11.discriminatedUnion("type", [
|
|
794
764
|
z11.object({
|
|
795
765
|
type: ScopesWithPlaceEventOptions,
|
|
@@ -810,14 +780,16 @@ var ResolvedRecordScopeV2 = z11.discriminatedUnion("type", [
|
|
|
810
780
|
}).optional()
|
|
811
781
|
})
|
|
812
782
|
]).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
|
+
]);
|
|
813
789
|
var Scope = z11.discriminatedUnion("type", [
|
|
814
790
|
z11.object({ type: PlainScopeType }),
|
|
815
791
|
...RecordScopeV2.options,
|
|
816
|
-
|
|
817
|
-
z11.object({
|
|
818
|
-
type: z11.literal("organisation.read-locations"),
|
|
819
|
-
options: AccessLevelOptions.optional()
|
|
820
|
-
}),
|
|
792
|
+
z11.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
|
|
821
793
|
z11.object({
|
|
822
794
|
type: z11.literal("workqueue"),
|
|
823
795
|
options: WorkqueueOrDashboardOptions
|
|
@@ -2106,8 +2078,8 @@ var ApplicationConfig = z20.object({
|
|
|
2106
2078
|
})
|
|
2107
2079
|
),
|
|
2108
2080
|
PHONE_NUMBER_PATTERN: z20.string().or(z20.instanceof(RegExp)),
|
|
2109
|
-
USER_NOTIFICATION_DELIVERY_METHOD: z20.
|
|
2110
|
-
INFORMANT_NOTIFICATION_DELIVERY_METHOD: z20.
|
|
2081
|
+
USER_NOTIFICATION_DELIVERY_METHOD: z20.enum(["email", "sms"]),
|
|
2082
|
+
INFORMANT_NOTIFICATION_DELIVERY_METHOD: z20.enum(["email", "sms"]),
|
|
2111
2083
|
SEARCH_DEFAULT_CRITERIA: SearchCriteria.optional().default("TRACKING_ID"),
|
|
2112
2084
|
ADDITIONAL_USER_FIELDS: z20.array(FieldConfig).optional().default([])
|
|
2113
2085
|
});
|
|
@@ -2125,8 +2097,8 @@ var BackgroundConfig = z20.object({
|
|
|
2125
2097
|
var LoginConfig = z20.object({
|
|
2126
2098
|
COUNTRY: z20.string(),
|
|
2127
2099
|
LANGUAGES: z20.array(z20.string()),
|
|
2128
|
-
USER_NOTIFICATION_DELIVERY_METHOD: z20.
|
|
2129
|
-
INFORMANT_NOTIFICATION_DELIVERY_METHOD: z20.
|
|
2100
|
+
USER_NOTIFICATION_DELIVERY_METHOD: z20.enum(["email", "sms"]),
|
|
2101
|
+
INFORMANT_NOTIFICATION_DELIVERY_METHOD: z20.enum(["email", "sms"]),
|
|
2130
2102
|
PHONE_NUMBER_PATTERN: z20.string().or(z20.instanceof(RegExp)),
|
|
2131
2103
|
LOGIN_BACKGROUND: BackgroundConfig,
|
|
2132
2104
|
SENTRY: z20.string().optional()
|
package/dist/cli.js
CHANGED
|
@@ -2110,10 +2110,6 @@ 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");
|
|
2117
2113
|
var scopeOptionsPlaceEvent = z3.object({
|
|
2118
2114
|
event: scopeByEvent,
|
|
2119
2115
|
placeOfEvent: JurisdictionFilter.optional()
|
|
@@ -2137,9 +2133,6 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
|
2137
2133
|
var AccessLevelOptions = z3.object({
|
|
2138
2134
|
accessLevel: JurisdictionFilter.optional()
|
|
2139
2135
|
});
|
|
2140
|
-
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
2141
|
-
role: userRole.optional()
|
|
2142
|
-
});
|
|
2143
2136
|
var WorkqueueOrDashboardOptions = z3.object({
|
|
2144
2137
|
ids: z3.preprocess(
|
|
2145
2138
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
@@ -2149,7 +2142,6 @@ var WorkqueueOrDashboardOptions = z3.object({
|
|
|
2149
2142
|
var AllScopeOptions = z3.object({
|
|
2150
2143
|
...AllRecordScopeOptions.shape,
|
|
2151
2144
|
...AccessLevelOptions.shape,
|
|
2152
|
-
...AllUserScopeOptions.shape,
|
|
2153
2145
|
...WorkqueueOrDashboardOptions.shape
|
|
2154
2146
|
});
|
|
2155
2147
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
@@ -2222,28 +2214,6 @@ var RecordScopeV2 = z3.discriminatedUnion("type", [
|
|
|
2222
2214
|
]).describe(
|
|
2223
2215
|
"Scopes used to check user's permission to perform actions on a record."
|
|
2224
2216
|
);
|
|
2225
|
-
var SystemScopeType = z3.enum([
|
|
2226
|
-
"organisation.read-locations",
|
|
2227
|
-
"user.read",
|
|
2228
|
-
"user.create",
|
|
2229
|
-
"user.edit"
|
|
2230
|
-
]);
|
|
2231
|
-
var UserScopeType = SystemScopeType.extract([
|
|
2232
|
-
"user.read",
|
|
2233
|
-
"user.create",
|
|
2234
|
-
"user.edit"
|
|
2235
|
-
]);
|
|
2236
|
-
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
2237
|
-
var UserScopeV2 = z3.discriminatedUnion("type", [
|
|
2238
|
-
z3.object({
|
|
2239
|
-
type: ScopesWithRoleOption,
|
|
2240
|
-
options: AllUserScopeOptions.optional()
|
|
2241
|
-
}),
|
|
2242
|
-
z3.object({
|
|
2243
|
-
type: UserScopeType.extract(["user.read"]),
|
|
2244
|
-
options: AccessLevelOptions.optional()
|
|
2245
|
-
})
|
|
2246
|
-
]);
|
|
2247
2217
|
var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
|
|
2248
2218
|
z3.object({
|
|
2249
2219
|
type: ScopesWithPlaceEventOptions,
|
|
@@ -2264,14 +2234,16 @@ var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
|
|
|
2264
2234
|
}).optional()
|
|
2265
2235
|
})
|
|
2266
2236
|
]).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
|
+
]);
|
|
2267
2243
|
var Scope2 = z3.discriminatedUnion("type", [
|
|
2268
2244
|
z3.object({ type: PlainScopeType }),
|
|
2269
2245
|
...RecordScopeV2.options,
|
|
2270
|
-
|
|
2271
|
-
z3.object({
|
|
2272
|
-
type: z3.literal("organisation.read-locations"),
|
|
2273
|
-
options: AccessLevelOptions.optional()
|
|
2274
|
-
}),
|
|
2246
|
+
z3.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
|
|
2275
2247
|
z3.object({
|
|
2276
2248
|
type: z3.literal("workqueue"),
|
|
2277
2249
|
options: WorkqueueOrDashboardOptions
|
|
@@ -3975,9 +3975,10 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
3975
3975
|
output: {
|
|
3976
3976
|
id: string & import("zod").$brand<"UUID">;
|
|
3977
3977
|
name: {
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3978
|
+
use: string;
|
|
3979
|
+
given: string[];
|
|
3980
|
+
family: string;
|
|
3981
|
+
}[];
|
|
3981
3982
|
role: string;
|
|
3982
3983
|
primaryOfficeId: string & import("zod").$brand<"UUID">;
|
|
3983
3984
|
type: "user";
|
|
@@ -4007,9 +4008,10 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4007
4008
|
create: import("@trpc/server").TRPCMutationProcedure<{
|
|
4008
4009
|
input: {
|
|
4009
4010
|
name: {
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4011
|
+
use: string;
|
|
4012
|
+
given: string[];
|
|
4013
|
+
family: string;
|
|
4014
|
+
}[];
|
|
4013
4015
|
role: string;
|
|
4014
4016
|
primaryOfficeId: string;
|
|
4015
4017
|
data?: Record<string, unknown> | undefined;
|
|
@@ -4028,9 +4030,10 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4028
4030
|
output: {
|
|
4029
4031
|
id: string & import("zod").$brand<"UUID">;
|
|
4030
4032
|
name: {
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4033
|
+
use: string;
|
|
4034
|
+
given: string[];
|
|
4035
|
+
family: string;
|
|
4036
|
+
}[];
|
|
4034
4037
|
role: string;
|
|
4035
4038
|
primaryOfficeId: string & import("zod").$brand<"UUID">;
|
|
4036
4039
|
type: "user";
|
|
@@ -4051,9 +4054,10 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4051
4054
|
id: string;
|
|
4052
4055
|
data?: Record<string, unknown> | undefined;
|
|
4053
4056
|
name?: {
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
+
use: string;
|
|
4058
|
+
given: string[];
|
|
4059
|
+
family: string;
|
|
4060
|
+
}[] | undefined;
|
|
4057
4061
|
role?: string | undefined;
|
|
4058
4062
|
fullHonorificName?: string | undefined;
|
|
4059
4063
|
device?: string | undefined;
|
|
@@ -4070,9 +4074,10 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4070
4074
|
output: {
|
|
4071
4075
|
id: string & import("zod").$brand<"UUID">;
|
|
4072
4076
|
name: {
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4077
|
+
use: string;
|
|
4078
|
+
given: string[];
|
|
4079
|
+
family: string;
|
|
4080
|
+
}[];
|
|
4076
4081
|
role: string;
|
|
4077
4082
|
primaryOfficeId: string & import("zod").$brand<"UUID">;
|
|
4078
4083
|
type: "user";
|
|
@@ -4093,9 +4098,10 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4093
4098
|
output: ({
|
|
4094
4099
|
id: string & import("zod").$brand<"UUID">;
|
|
4095
4100
|
name: {
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4101
|
+
use: string;
|
|
4102
|
+
given: string[];
|
|
4103
|
+
family: string;
|
|
4104
|
+
}[];
|
|
4099
4105
|
role: string;
|
|
4100
4106
|
primaryOfficeId: string & import("zod").$brand<"UUID">;
|
|
4101
4107
|
type: "user";
|
|
@@ -4137,9 +4143,10 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4137
4143
|
output: ({
|
|
4138
4144
|
id: string & import("zod").$brand<"UUID">;
|
|
4139
4145
|
name: {
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4146
|
+
use: string;
|
|
4147
|
+
given: string[];
|
|
4148
|
+
family: string;
|
|
4149
|
+
}[];
|
|
4143
4150
|
role: string;
|
|
4144
4151
|
primaryOfficeId: string & import("zod").$brand<"UUID">;
|
|
4145
4152
|
type: "user";
|
|
@@ -4765,7 +4772,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4765
4772
|
'legalStatuses.DECLARED.createdAtLocation'?: {
|
|
4766
4773
|
type: "within";
|
|
4767
4774
|
location: string | {
|
|
4768
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4775
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
|
|
4769
4776
|
$location?: string | undefined;
|
|
4770
4777
|
};
|
|
4771
4778
|
} | undefined;
|
|
@@ -4787,7 +4794,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4787
4794
|
'legalStatuses.REGISTERED.createdAtLocation'?: {
|
|
4788
4795
|
type: "within";
|
|
4789
4796
|
location: string | {
|
|
4790
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4797
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
|
|
4791
4798
|
$location?: string | undefined;
|
|
4792
4799
|
};
|
|
4793
4800
|
} | undefined;
|
|
@@ -4802,47 +4809,47 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4802
4809
|
createdAtLocation?: {
|
|
4803
4810
|
type: "within";
|
|
4804
4811
|
location: string | {
|
|
4805
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4812
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
|
|
4806
4813
|
$location?: string | undefined;
|
|
4807
4814
|
};
|
|
4808
4815
|
} | {
|
|
4809
4816
|
type: "exact";
|
|
4810
4817
|
term: string | {
|
|
4811
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4818
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
|
|
4812
4819
|
$location?: string | undefined;
|
|
4813
4820
|
};
|
|
4814
4821
|
} | undefined;
|
|
4815
4822
|
updatedAtLocation?: {
|
|
4816
4823
|
type: "within";
|
|
4817
4824
|
location: string | {
|
|
4818
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4825
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
|
|
4819
4826
|
$location?: string | undefined;
|
|
4820
4827
|
};
|
|
4821
4828
|
} | {
|
|
4822
4829
|
type: "exact";
|
|
4823
4830
|
term: string | {
|
|
4824
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4831
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
|
|
4825
4832
|
$location?: string | undefined;
|
|
4826
4833
|
};
|
|
4827
4834
|
} | undefined;
|
|
4828
4835
|
updatedByUserRole?: {
|
|
4829
4836
|
type: "exact";
|
|
4830
4837
|
term: string | {
|
|
4831
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4838
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
|
|
4832
4839
|
$location?: string | undefined;
|
|
4833
4840
|
};
|
|
4834
4841
|
} | undefined;
|
|
4835
4842
|
assignedTo?: {
|
|
4836
4843
|
type: "exact";
|
|
4837
4844
|
term: string | {
|
|
4838
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4845
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
|
|
4839
4846
|
$location?: string | undefined;
|
|
4840
4847
|
};
|
|
4841
4848
|
} | undefined;
|
|
4842
4849
|
createdBy?: {
|
|
4843
4850
|
type: "exact";
|
|
4844
4851
|
term: string | {
|
|
4845
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4852
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
|
|
4846
4853
|
$location?: string | undefined;
|
|
4847
4854
|
};
|
|
4848
4855
|
} | undefined;
|
|
@@ -4853,7 +4860,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4853
4860
|
updatedBy?: {
|
|
4854
4861
|
type: "exact";
|
|
4855
4862
|
term: string | {
|
|
4856
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4863
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
|
|
4857
4864
|
$location?: string | undefined;
|
|
4858
4865
|
};
|
|
4859
4866
|
} | undefined;
|
|
@@ -4903,7 +4910,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4903
4910
|
'legalStatuses.DECLARED.createdAtLocation'?: {
|
|
4904
4911
|
type: "within";
|
|
4905
4912
|
location: string | {
|
|
4906
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4913
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
|
|
4907
4914
|
$location?: string | undefined;
|
|
4908
4915
|
};
|
|
4909
4916
|
} | undefined;
|
|
@@ -4925,7 +4932,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4925
4932
|
'legalStatuses.REGISTERED.createdAtLocation'?: {
|
|
4926
4933
|
type: "within";
|
|
4927
4934
|
location: string | {
|
|
4928
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4935
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
|
|
4929
4936
|
$location?: string | undefined;
|
|
4930
4937
|
};
|
|
4931
4938
|
} | undefined;
|
|
@@ -4940,47 +4947,47 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4940
4947
|
createdAtLocation?: {
|
|
4941
4948
|
type: "within";
|
|
4942
4949
|
location: string | {
|
|
4943
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4950
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
|
|
4944
4951
|
$location?: string | undefined;
|
|
4945
4952
|
};
|
|
4946
4953
|
} | {
|
|
4947
4954
|
type: "exact";
|
|
4948
4955
|
term: string | {
|
|
4949
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4956
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
|
|
4950
4957
|
$location?: string | undefined;
|
|
4951
4958
|
};
|
|
4952
4959
|
} | undefined;
|
|
4953
4960
|
updatedAtLocation?: {
|
|
4954
4961
|
type: "within";
|
|
4955
4962
|
location: string | {
|
|
4956
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4963
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
|
|
4957
4964
|
$location?: string | undefined;
|
|
4958
4965
|
};
|
|
4959
4966
|
} | {
|
|
4960
4967
|
type: "exact";
|
|
4961
4968
|
term: string | {
|
|
4962
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4969
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
|
|
4963
4970
|
$location?: string | undefined;
|
|
4964
4971
|
};
|
|
4965
4972
|
} | undefined;
|
|
4966
4973
|
updatedByUserRole?: {
|
|
4967
4974
|
type: "exact";
|
|
4968
4975
|
term: string | {
|
|
4969
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4976
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
|
|
4970
4977
|
$location?: string | undefined;
|
|
4971
4978
|
};
|
|
4972
4979
|
} | undefined;
|
|
4973
4980
|
assignedTo?: {
|
|
4974
4981
|
type: "exact";
|
|
4975
4982
|
term: string | {
|
|
4976
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4983
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
|
|
4977
4984
|
$location?: string | undefined;
|
|
4978
4985
|
};
|
|
4979
4986
|
} | undefined;
|
|
4980
4987
|
createdBy?: {
|
|
4981
4988
|
type: "exact";
|
|
4982
4989
|
term: string | {
|
|
4983
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4990
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
|
|
4984
4991
|
$location?: string | undefined;
|
|
4985
4992
|
};
|
|
4986
4993
|
} | undefined;
|
|
@@ -4991,7 +4998,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4991
4998
|
updatedBy?: {
|
|
4992
4999
|
type: "exact";
|
|
4993
5000
|
term: string | {
|
|
4994
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
5001
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
|
|
4995
5002
|
$location?: string | undefined;
|
|
4996
5003
|
};
|
|
4997
5004
|
} | undefined;
|
|
@@ -24,8 +24,14 @@ export declare const ApplicationConfig: z.ZodObject<{
|
|
|
24
24
|
label: z.ZodObject<import("./events/TranslationConfig").MessageDescriptorZod, z.core.$strip>;
|
|
25
25
|
}, z.core.$strip>>;
|
|
26
26
|
PHONE_NUMBER_PATTERN: z.ZodUnion<[z.ZodString, z.ZodCustom<RegExp, RegExp>]>;
|
|
27
|
-
USER_NOTIFICATION_DELIVERY_METHOD: z.
|
|
28
|
-
|
|
27
|
+
USER_NOTIFICATION_DELIVERY_METHOD: z.ZodEnum<{
|
|
28
|
+
email: "email";
|
|
29
|
+
sms: "sms";
|
|
30
|
+
}>;
|
|
31
|
+
INFORMANT_NOTIFICATION_DELIVERY_METHOD: z.ZodEnum<{
|
|
32
|
+
email: "email";
|
|
33
|
+
sms: "sms";
|
|
34
|
+
}>;
|
|
29
35
|
SEARCH_DEFAULT_CRITERIA: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
30
36
|
NAME: "NAME";
|
|
31
37
|
EMAIL: "EMAIL";
|
|
@@ -46,8 +52,14 @@ export declare const BackgroundConfig: z.ZodObject<{
|
|
|
46
52
|
export declare const LoginConfig: z.ZodObject<{
|
|
47
53
|
COUNTRY: z.ZodString;
|
|
48
54
|
LANGUAGES: z.ZodArray<z.ZodString>;
|
|
49
|
-
USER_NOTIFICATION_DELIVERY_METHOD: z.
|
|
50
|
-
|
|
55
|
+
USER_NOTIFICATION_DELIVERY_METHOD: z.ZodEnum<{
|
|
56
|
+
email: "email";
|
|
57
|
+
sms: "sms";
|
|
58
|
+
}>;
|
|
59
|
+
INFORMANT_NOTIFICATION_DELIVERY_METHOD: z.ZodEnum<{
|
|
60
|
+
email: "email";
|
|
61
|
+
sms: "sms";
|
|
62
|
+
}>;
|
|
51
63
|
PHONE_NUMBER_PATTERN: z.ZodUnion<[z.ZodString, z.ZodCustom<RegExp, RegExp>]>;
|
|
52
64
|
LOGIN_BACKGROUND: z.ZodObject<{
|
|
53
65
|
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
@@ -87,16 +87,16 @@ export declare const user: typeof userSerializer & {
|
|
|
87
87
|
scope: (scope: import("../scopes").ScopeType) => {
|
|
88
88
|
attribute: (option: import("../scopes").ScopeOptionKey) => {
|
|
89
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: "
|
|
90
|
+
$option: "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
91
91
|
};
|
|
92
92
|
};
|
|
93
93
|
jurisdiction: (jurisdiction: import("../scopes").JurisdictionFilter | {
|
|
94
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: "
|
|
95
|
+
$option: "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
96
96
|
}) => {
|
|
97
97
|
$jurisdiction: "administrativeArea" | "location" | "all" | {
|
|
98
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: "
|
|
99
|
+
$option: "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
100
100
|
};
|
|
101
101
|
};
|
|
102
102
|
};
|
|
@@ -1727,7 +1727,6 @@ declare const AdministrativeAreaField: z.ZodObject<{
|
|
|
1727
1727
|
"dashboard.view": "dashboard.view";
|
|
1728
1728
|
}>;
|
|
1729
1729
|
$option: z.ZodEnum<{
|
|
1730
|
-
role: "role";
|
|
1731
1730
|
event: "event";
|
|
1732
1731
|
placeOfEvent: "placeOfEvent";
|
|
1733
1732
|
declaredIn: "declaredIn";
|
|
@@ -1846,7 +1845,6 @@ declare const LocationInput: z.ZodObject<{
|
|
|
1846
1845
|
"dashboard.view": "dashboard.view";
|
|
1847
1846
|
}>;
|
|
1848
1847
|
$option: z.ZodEnum<{
|
|
1849
|
-
role: "role";
|
|
1850
1848
|
event: "event";
|
|
1851
1849
|
placeOfEvent: "placeOfEvent";
|
|
1852
1850
|
declaredIn: "declaredIn";
|
|
@@ -2030,7 +2028,6 @@ declare const Facility: z.ZodObject<{
|
|
|
2030
2028
|
"dashboard.view": "dashboard.view";
|
|
2031
2029
|
}>;
|
|
2032
2030
|
$option: z.ZodEnum<{
|
|
2033
|
-
role: "role";
|
|
2034
2031
|
event: "event";
|
|
2035
2032
|
placeOfEvent: "placeOfEvent";
|
|
2036
2033
|
declaredIn: "declaredIn";
|
|
@@ -2135,7 +2132,6 @@ declare const Office: z.ZodObject<{
|
|
|
2135
2132
|
"dashboard.view": "dashboard.view";
|
|
2136
2133
|
}>;
|
|
2137
2134
|
$option: z.ZodEnum<{
|
|
2138
|
-
role: "role";
|
|
2139
2135
|
event: "event";
|
|
2140
2136
|
placeOfEvent: "placeOfEvent";
|
|
2141
2137
|
declaredIn: "declaredIn";
|
|
@@ -2327,7 +2323,6 @@ declare const Address: z.ZodObject<{
|
|
|
2327
2323
|
"dashboard.view": "dashboard.view";
|
|
2328
2324
|
}>;
|
|
2329
2325
|
$option: z.ZodEnum<{
|
|
2330
|
-
role: "role";
|
|
2331
2326
|
event: "event";
|
|
2332
2327
|
placeOfEvent: "placeOfEvent";
|
|
2333
2328
|
declaredIn: "declaredIn";
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { UUID } from '../uuid';
|
|
2
1
|
import * as z from 'zod/v4';
|
|
3
2
|
import { EventIndex } from './EventIndex';
|
|
4
3
|
import { ActionCreationMetadata, RegistrationCreationMetadata } from './EventMetadata';
|
|
5
|
-
import { RecordScopeV2
|
|
4
|
+
import { RecordScopeV2 } from '../scopes';
|
|
6
5
|
import { SystemContext, UserContext } from '../users/User';
|
|
7
6
|
/** @deprecated Moving on, location types are arbitrary and defined by the country config. */
|
|
8
7
|
export declare const LocationTypeV1: z.ZodEnum<{
|
|
@@ -52,21 +51,6 @@ export type EventIndexWithAdministrativeHierarchy = Omit<ToArrayFields<EventInde
|
|
|
52
51
|
*
|
|
53
52
|
*/
|
|
54
53
|
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;
|
|
70
54
|
/**
|
|
71
55
|
* Given indexed event and list of resolved scopes, determine if any of the scopes allow access to the event.
|
|
72
56
|
*
|
|
@@ -182,10 +182,6 @@ 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");
|
|
189
185
|
var scopeOptionsPlaceEvent = z6.object({
|
|
190
186
|
event: scopeByEvent,
|
|
191
187
|
placeOfEvent: JurisdictionFilter.optional()
|
|
@@ -209,9 +205,6 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
|
209
205
|
var AccessLevelOptions = z6.object({
|
|
210
206
|
accessLevel: JurisdictionFilter.optional()
|
|
211
207
|
});
|
|
212
|
-
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
213
|
-
role: userRole.optional()
|
|
214
|
-
});
|
|
215
208
|
var WorkqueueOrDashboardOptions = z6.object({
|
|
216
209
|
ids: z6.preprocess(
|
|
217
210
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
@@ -221,7 +214,6 @@ var WorkqueueOrDashboardOptions = z6.object({
|
|
|
221
214
|
var AllScopeOptions = z6.object({
|
|
222
215
|
...AllRecordScopeOptions.shape,
|
|
223
216
|
...AccessLevelOptions.shape,
|
|
224
|
-
...AllUserScopeOptions.shape,
|
|
225
217
|
...WorkqueueOrDashboardOptions.shape
|
|
226
218
|
});
|
|
227
219
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
@@ -294,28 +286,6 @@ var RecordScopeV2 = z6.discriminatedUnion("type", [
|
|
|
294
286
|
]).describe(
|
|
295
287
|
"Scopes used to check user's permission to perform actions on a record."
|
|
296
288
|
);
|
|
297
|
-
var SystemScopeType = z6.enum([
|
|
298
|
-
"organisation.read-locations",
|
|
299
|
-
"user.read",
|
|
300
|
-
"user.create",
|
|
301
|
-
"user.edit"
|
|
302
|
-
]);
|
|
303
|
-
var UserScopeType = SystemScopeType.extract([
|
|
304
|
-
"user.read",
|
|
305
|
-
"user.create",
|
|
306
|
-
"user.edit"
|
|
307
|
-
]);
|
|
308
|
-
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
309
|
-
var UserScopeV2 = z6.discriminatedUnion("type", [
|
|
310
|
-
z6.object({
|
|
311
|
-
type: ScopesWithRoleOption,
|
|
312
|
-
options: AllUserScopeOptions.optional()
|
|
313
|
-
}),
|
|
314
|
-
z6.object({
|
|
315
|
-
type: UserScopeType.extract(["user.read"]),
|
|
316
|
-
options: AccessLevelOptions.optional()
|
|
317
|
-
})
|
|
318
|
-
]);
|
|
319
289
|
var ResolvedRecordScopeV2 = z6.discriminatedUnion("type", [
|
|
320
290
|
z6.object({
|
|
321
291
|
type: ScopesWithPlaceEventOptions,
|
|
@@ -336,14 +306,16 @@ var ResolvedRecordScopeV2 = z6.discriminatedUnion("type", [
|
|
|
336
306
|
}).optional()
|
|
337
307
|
})
|
|
338
308
|
]).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
|
+
]);
|
|
339
315
|
var Scope2 = z6.discriminatedUnion("type", [
|
|
340
316
|
z6.object({ type: PlainScopeType }),
|
|
341
317
|
...RecordScopeV2.options,
|
|
342
|
-
|
|
343
|
-
z6.object({
|
|
344
|
-
type: z6.literal("organisation.read-locations"),
|
|
345
|
-
options: AccessLevelOptions.optional()
|
|
346
|
-
}),
|
|
318
|
+
z6.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
|
|
347
319
|
z6.object({
|
|
348
320
|
type: z6.literal("workqueue"),
|
|
349
321
|
options: WorkqueueOrDashboardOptions
|
package/dist/events/index.js
CHANGED
|
@@ -243,8 +243,6 @@ __export(events_exports, {
|
|
|
243
243
|
areConditionsMet: () => areConditionsMet,
|
|
244
244
|
buildFormState: () => buildFormState,
|
|
245
245
|
canAccessEventWithScope: () => canAccessEventWithScope,
|
|
246
|
-
canAccessOtherUserWithScopes: () => canAccessOtherUserWithScopes,
|
|
247
|
-
canAccessUserWithScope: () => canAccessUserWithScope,
|
|
248
246
|
compositeFieldTypes: () => compositeFieldTypes,
|
|
249
247
|
createEmptyDraft: () => createEmptyDraft,
|
|
250
248
|
createFieldConditionals: () => createFieldConditionals,
|
|
@@ -491,10 +489,6 @@ var scopeByEvent = z2.preprocess(
|
|
|
491
489
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
492
490
|
z2.array(z2.string()).optional()
|
|
493
491
|
).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");
|
|
498
492
|
var scopeOptionsPlaceEvent = z2.object({
|
|
499
493
|
event: scopeByEvent,
|
|
500
494
|
placeOfEvent: JurisdictionFilter.optional()
|
|
@@ -518,9 +512,6 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
|
518
512
|
var AccessLevelOptions = z2.object({
|
|
519
513
|
accessLevel: JurisdictionFilter.optional()
|
|
520
514
|
});
|
|
521
|
-
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
522
|
-
role: userRole.optional()
|
|
523
|
-
});
|
|
524
515
|
var WorkqueueOrDashboardOptions = z2.object({
|
|
525
516
|
ids: z2.preprocess(
|
|
526
517
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
@@ -530,7 +521,6 @@ var WorkqueueOrDashboardOptions = z2.object({
|
|
|
530
521
|
var AllScopeOptions = z2.object({
|
|
531
522
|
...AllRecordScopeOptions.shape,
|
|
532
523
|
...AccessLevelOptions.shape,
|
|
533
|
-
...AllUserScopeOptions.shape,
|
|
534
524
|
...WorkqueueOrDashboardOptions.shape
|
|
535
525
|
});
|
|
536
526
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
@@ -603,31 +593,6 @@ var RecordScopeV2 = z2.discriminatedUnion("type", [
|
|
|
603
593
|
]).describe(
|
|
604
594
|
"Scopes used to check user's permission to perform actions on a record."
|
|
605
595
|
);
|
|
606
|
-
var SystemScopeType = z2.enum([
|
|
607
|
-
"organisation.read-locations",
|
|
608
|
-
"user.read",
|
|
609
|
-
"user.create",
|
|
610
|
-
"user.edit"
|
|
611
|
-
]);
|
|
612
|
-
var UserScopeType = SystemScopeType.extract([
|
|
613
|
-
"user.read",
|
|
614
|
-
"user.create",
|
|
615
|
-
"user.edit"
|
|
616
|
-
]);
|
|
617
|
-
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
618
|
-
var UserScopeV2 = z2.discriminatedUnion("type", [
|
|
619
|
-
z2.object({
|
|
620
|
-
type: ScopesWithRoleOption,
|
|
621
|
-
options: AllUserScopeOptions.optional()
|
|
622
|
-
}),
|
|
623
|
-
z2.object({
|
|
624
|
-
type: UserScopeType.extract(["user.read"]),
|
|
625
|
-
options: AccessLevelOptions.optional()
|
|
626
|
-
})
|
|
627
|
-
]);
|
|
628
|
-
function scopeUsesRoleOptions(scope) {
|
|
629
|
-
return ScopesWithRoleOption?.options.some((opt) => opt === scope.type);
|
|
630
|
-
}
|
|
631
596
|
function scopeUsesDeclaredOptions(scope) {
|
|
632
597
|
return !ScopesWithPlaceEventOptions.options.some((opt) => opt === scope.type);
|
|
633
598
|
}
|
|
@@ -660,14 +625,16 @@ var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
|
|
|
660
625
|
}).optional()
|
|
661
626
|
})
|
|
662
627
|
]).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
|
+
]);
|
|
663
634
|
var Scope = z2.discriminatedUnion("type", [
|
|
664
635
|
z2.object({ type: PlainScopeType }),
|
|
665
636
|
...RecordScopeV2.options,
|
|
666
|
-
|
|
667
|
-
z2.object({
|
|
668
|
-
type: z2.literal("organisation.read-locations"),
|
|
669
|
-
options: AccessLevelOptions.optional()
|
|
670
|
-
}),
|
|
637
|
+
z2.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
|
|
671
638
|
z2.object({
|
|
672
639
|
type: z2.literal("workqueue"),
|
|
673
640
|
options: WorkqueueOrDashboardOptions
|
|
@@ -9963,39 +9930,6 @@ function canAccessEventWithScope(event2, scope, user2, customActionType) {
|
|
|
9963
9930
|
}
|
|
9964
9931
|
return true;
|
|
9965
9932
|
}
|
|
9966
|
-
function canAccessUserWithScope({
|
|
9967
|
-
userToAccess,
|
|
9968
|
-
scope,
|
|
9969
|
-
user: user2
|
|
9970
|
-
}) {
|
|
9971
|
-
const opts = scope.options;
|
|
9972
|
-
const hasSameOffice = user2.primaryOfficeId === userToAccess.primaryOfficeId;
|
|
9973
|
-
if (opts?.accessLevel === JurisdictionFilter.enum.location && !hasSameOffice) {
|
|
9974
|
-
return false;
|
|
9975
|
-
}
|
|
9976
|
-
const hasAdministrativeAreaInHierarchy = userToAccess.administrativeHierarchy.some(
|
|
9977
|
-
(id) => user2.administrativeAreaId === id
|
|
9978
|
-
) || user2.administrativeAreaId === null;
|
|
9979
|
-
if (opts?.accessLevel === JurisdictionFilter.enum.administrativeArea && !hasAdministrativeAreaInHierarchy) {
|
|
9980
|
-
return false;
|
|
9981
|
-
}
|
|
9982
|
-
if (scopeUsesRoleOptions(scope)) {
|
|
9983
|
-
const { options } = scope;
|
|
9984
|
-
if (options?.role && !options.role.includes(userToAccess.role)) {
|
|
9985
|
-
return false;
|
|
9986
|
-
}
|
|
9987
|
-
}
|
|
9988
|
-
return true;
|
|
9989
|
-
}
|
|
9990
|
-
function canAccessOtherUserWithScopes({
|
|
9991
|
-
scopes,
|
|
9992
|
-
userToAccess,
|
|
9993
|
-
user: user2
|
|
9994
|
-
}) {
|
|
9995
|
-
return scopes.some(
|
|
9996
|
-
(scope) => canAccessUserWithScope({ userToAccess, scope, user: user2 })
|
|
9997
|
-
);
|
|
9998
|
-
}
|
|
9999
9933
|
function userCanAccessEventWithScopes(event2, scopes, user2, customActionType) {
|
|
10000
9934
|
return scopes.some(
|
|
10001
9935
|
(scope) => canAccessEventWithScope(event2, scope, user2, customActionType)
|
|
@@ -2122,10 +2122,6 @@ 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");
|
|
2129
2125
|
var scopeOptionsPlaceEvent = z3.object({
|
|
2130
2126
|
event: scopeByEvent,
|
|
2131
2127
|
placeOfEvent: JurisdictionFilter.optional()
|
|
@@ -2149,9 +2145,6 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
|
2149
2145
|
var AccessLevelOptions = z3.object({
|
|
2150
2146
|
accessLevel: JurisdictionFilter.optional()
|
|
2151
2147
|
});
|
|
2152
|
-
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
2153
|
-
role: userRole.optional()
|
|
2154
|
-
});
|
|
2155
2148
|
var WorkqueueOrDashboardOptions = z3.object({
|
|
2156
2149
|
ids: z3.preprocess(
|
|
2157
2150
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
@@ -2161,7 +2154,6 @@ var WorkqueueOrDashboardOptions = z3.object({
|
|
|
2161
2154
|
var AllScopeOptions = z3.object({
|
|
2162
2155
|
...AllRecordScopeOptions.shape,
|
|
2163
2156
|
...AccessLevelOptions.shape,
|
|
2164
|
-
...AllUserScopeOptions.shape,
|
|
2165
2157
|
...WorkqueueOrDashboardOptions.shape
|
|
2166
2158
|
});
|
|
2167
2159
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
@@ -2234,28 +2226,6 @@ var RecordScopeV2 = z3.discriminatedUnion("type", [
|
|
|
2234
2226
|
]).describe(
|
|
2235
2227
|
"Scopes used to check user's permission to perform actions on a record."
|
|
2236
2228
|
);
|
|
2237
|
-
var SystemScopeType = z3.enum([
|
|
2238
|
-
"organisation.read-locations",
|
|
2239
|
-
"user.read",
|
|
2240
|
-
"user.create",
|
|
2241
|
-
"user.edit"
|
|
2242
|
-
]);
|
|
2243
|
-
var UserScopeType = SystemScopeType.extract([
|
|
2244
|
-
"user.read",
|
|
2245
|
-
"user.create",
|
|
2246
|
-
"user.edit"
|
|
2247
|
-
]);
|
|
2248
|
-
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
2249
|
-
var UserScopeV2 = z3.discriminatedUnion("type", [
|
|
2250
|
-
z3.object({
|
|
2251
|
-
type: ScopesWithRoleOption,
|
|
2252
|
-
options: AllUserScopeOptions.optional()
|
|
2253
|
-
}),
|
|
2254
|
-
z3.object({
|
|
2255
|
-
type: UserScopeType.extract(["user.read"]),
|
|
2256
|
-
options: AccessLevelOptions.optional()
|
|
2257
|
-
})
|
|
2258
|
-
]);
|
|
2259
2229
|
var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
|
|
2260
2230
|
z3.object({
|
|
2261
2231
|
type: ScopesWithPlaceEventOptions,
|
|
@@ -2276,14 +2246,16 @@ var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
|
|
|
2276
2246
|
}).optional()
|
|
2277
2247
|
})
|
|
2278
2248
|
]).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
|
+
]);
|
|
2279
2255
|
var Scope2 = z3.discriminatedUnion("type", [
|
|
2280
2256
|
z3.object({ type: PlainScopeType }),
|
|
2281
2257
|
...RecordScopeV2.options,
|
|
2282
|
-
|
|
2283
|
-
z3.object({
|
|
2284
|
-
type: z3.literal("organisation.read-locations"),
|
|
2285
|
-
options: AccessLevelOptions.optional()
|
|
2286
|
-
}),
|
|
2258
|
+
z3.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
|
|
2287
2259
|
z3.object({
|
|
2288
2260
|
type: z3.literal("workqueue"),
|
|
2289
2261
|
options: WorkqueueOrDashboardOptions
|
|
@@ -110,10 +110,6 @@ 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");
|
|
117
113
|
var scopeOptionsPlaceEvent = z2.object({
|
|
118
114
|
event: scopeByEvent,
|
|
119
115
|
placeOfEvent: JurisdictionFilter.optional()
|
|
@@ -137,9 +133,6 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
|
137
133
|
var AccessLevelOptions = z2.object({
|
|
138
134
|
accessLevel: JurisdictionFilter.optional()
|
|
139
135
|
});
|
|
140
|
-
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
141
|
-
role: userRole.optional()
|
|
142
|
-
});
|
|
143
136
|
var WorkqueueOrDashboardOptions = z2.object({
|
|
144
137
|
ids: z2.preprocess(
|
|
145
138
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
@@ -149,7 +142,6 @@ var WorkqueueOrDashboardOptions = z2.object({
|
|
|
149
142
|
var AllScopeOptions = z2.object({
|
|
150
143
|
...AllRecordScopeOptions.shape,
|
|
151
144
|
...AccessLevelOptions.shape,
|
|
152
|
-
...AllUserScopeOptions.shape,
|
|
153
145
|
...WorkqueueOrDashboardOptions.shape
|
|
154
146
|
});
|
|
155
147
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
@@ -222,28 +214,6 @@ var RecordScopeV2 = z2.discriminatedUnion("type", [
|
|
|
222
214
|
]).describe(
|
|
223
215
|
"Scopes used to check user's permission to perform actions on a record."
|
|
224
216
|
);
|
|
225
|
-
var SystemScopeType = z2.enum([
|
|
226
|
-
"organisation.read-locations",
|
|
227
|
-
"user.read",
|
|
228
|
-
"user.create",
|
|
229
|
-
"user.edit"
|
|
230
|
-
]);
|
|
231
|
-
var UserScopeType = SystemScopeType.extract([
|
|
232
|
-
"user.read",
|
|
233
|
-
"user.create",
|
|
234
|
-
"user.edit"
|
|
235
|
-
]);
|
|
236
|
-
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
237
|
-
var UserScopeV2 = z2.discriminatedUnion("type", [
|
|
238
|
-
z2.object({
|
|
239
|
-
type: ScopesWithRoleOption,
|
|
240
|
-
options: AllUserScopeOptions.optional()
|
|
241
|
-
}),
|
|
242
|
-
z2.object({
|
|
243
|
-
type: UserScopeType.extract(["user.read"]),
|
|
244
|
-
options: AccessLevelOptions.optional()
|
|
245
|
-
})
|
|
246
|
-
]);
|
|
247
217
|
var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
|
|
248
218
|
z2.object({
|
|
249
219
|
type: ScopesWithPlaceEventOptions,
|
|
@@ -264,14 +234,16 @@ var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
|
|
|
264
234
|
}).optional()
|
|
265
235
|
})
|
|
266
236
|
]).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
|
+
]);
|
|
267
243
|
var Scope = z2.discriminatedUnion("type", [
|
|
268
244
|
z2.object({ type: PlainScopeType }),
|
|
269
245
|
...RecordScopeV2.options,
|
|
270
|
-
|
|
271
|
-
z2.object({
|
|
272
|
-
type: z2.literal("organisation.read-locations"),
|
|
273
|
-
options: AccessLevelOptions.optional()
|
|
274
|
-
}),
|
|
246
|
+
z2.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
|
|
275
247
|
z2.object({
|
|
276
248
|
type: z2.literal("workqueue"),
|
|
277
249
|
options: WorkqueueOrDashboardOptions
|
package/dist/scopes/index.d.ts
CHANGED
|
@@ -41,7 +41,6 @@ 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>>>>;
|
|
45
44
|
event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
46
45
|
placeOfEvent: z.ZodOptional<z.ZodEnum<{
|
|
47
46
|
administrativeArea: "administrativeArea";
|
|
@@ -67,7 +66,6 @@ declare const AllScopeOptions: z.ZodObject<{
|
|
|
67
66
|
}, z.core.$strip>;
|
|
68
67
|
type AllScopeOptions = z.infer<typeof AllScopeOptions>;
|
|
69
68
|
export declare const ScopeOptionKey: z.ZodEnum<{
|
|
70
|
-
role: "role";
|
|
71
69
|
event: "event";
|
|
72
70
|
placeOfEvent: "placeOfEvent";
|
|
73
71
|
declaredIn: "declaredIn";
|
|
@@ -222,53 +220,6 @@ export declare const RecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
222
220
|
templates: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
223
221
|
}, z.core.$strip>>;
|
|
224
222
|
}, 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
|
-
}>;
|
|
231
|
-
export type SystemScopeType = z.infer<typeof SystemScopeType>;
|
|
232
|
-
declare const UserScopeType: z.ZodEnum<{
|
|
233
|
-
"user.read": "user.read";
|
|
234
|
-
"user.create": "user.create";
|
|
235
|
-
"user.edit": "user.edit";
|
|
236
|
-
}>;
|
|
237
|
-
export type UserScopeType = z.infer<typeof UserScopeType>;
|
|
238
|
-
declare const ScopesWithRoleOption: z.ZodEnum<{
|
|
239
|
-
"user.create": "user.create";
|
|
240
|
-
"user.edit": "user.edit";
|
|
241
|
-
}>;
|
|
242
|
-
export type ScopesWithRoleOption = z.infer<typeof ScopesWithRoleOption>;
|
|
243
|
-
export declare const UserScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
244
|
-
type: z.ZodEnum<{
|
|
245
|
-
"user.create": "user.create";
|
|
246
|
-
"user.edit": "user.edit";
|
|
247
|
-
}>;
|
|
248
|
-
options: z.ZodOptional<z.ZodObject<{
|
|
249
|
-
accessLevel: z.ZodOptional<z.ZodEnum<{
|
|
250
|
-
administrativeArea: "administrativeArea";
|
|
251
|
-
location: "location";
|
|
252
|
-
all: "all";
|
|
253
|
-
}>>;
|
|
254
|
-
role: z.ZodOptional<z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>>;
|
|
255
|
-
}, z.core.$strip>>;
|
|
256
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
257
|
-
type: z.ZodEnum<{
|
|
258
|
-
"user.read": "user.read";
|
|
259
|
-
}>;
|
|
260
|
-
options: z.ZodOptional<z.ZodObject<{
|
|
261
|
-
accessLevel: z.ZodOptional<z.ZodEnum<{
|
|
262
|
-
administrativeArea: "administrativeArea";
|
|
263
|
-
location: "location";
|
|
264
|
-
all: "all";
|
|
265
|
-
}>>;
|
|
266
|
-
}, z.core.$strip>>;
|
|
267
|
-
}, z.core.$strip>], "type">;
|
|
268
|
-
export type UserScopeV2 = z.infer<typeof UserScopeV2>;
|
|
269
|
-
export declare function scopeUsesRoleOptions(scope: UserScopeV2): scope is Extract<UserScopeV2, {
|
|
270
|
-
type: ScopesWithRoleOption;
|
|
271
|
-
}>;
|
|
272
223
|
export declare function scopeUsesDeclaredOptions(scope: Scope): scope is Extract<Scope, {
|
|
273
224
|
type: z.infer<typeof ScopesWithDeclaredOptions>;
|
|
274
225
|
}>;
|
|
@@ -335,6 +286,13 @@ export declare const ResolvedRecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
335
286
|
}, z.core.$strip>], "type">;
|
|
336
287
|
export type RecordScopeV2 = z.infer<typeof RecordScopeV2>;
|
|
337
288
|
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>;
|
|
338
296
|
/** The primary scope schema which gathers all scope types together. All scopes are discriminated by type and options are determined according to the type. */
|
|
339
297
|
export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
340
298
|
type: z.ZodEnum<{
|
|
@@ -479,30 +437,11 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
479
437
|
}, z.core.$strip>>;
|
|
480
438
|
}, z.core.$strip>, z.ZodObject<{
|
|
481
439
|
type: z.ZodEnum<{
|
|
440
|
+
"organisation.read-locations": "organisation.read-locations";
|
|
441
|
+
"user.read": "user.read";
|
|
482
442
|
"user.create": "user.create";
|
|
483
443
|
"user.edit": "user.edit";
|
|
484
444
|
}>;
|
|
485
|
-
options: z.ZodOptional<z.ZodObject<{
|
|
486
|
-
accessLevel: z.ZodOptional<z.ZodEnum<{
|
|
487
|
-
administrativeArea: "administrativeArea";
|
|
488
|
-
location: "location";
|
|
489
|
-
all: "all";
|
|
490
|
-
}>>;
|
|
491
|
-
role: z.ZodOptional<z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>>;
|
|
492
|
-
}, z.core.$strip>>;
|
|
493
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
494
|
-
type: z.ZodEnum<{
|
|
495
|
-
"user.read": "user.read";
|
|
496
|
-
}>;
|
|
497
|
-
options: z.ZodOptional<z.ZodObject<{
|
|
498
|
-
accessLevel: z.ZodOptional<z.ZodEnum<{
|
|
499
|
-
administrativeArea: "administrativeArea";
|
|
500
|
-
location: "location";
|
|
501
|
-
all: "all";
|
|
502
|
-
}>>;
|
|
503
|
-
}, z.core.$strip>>;
|
|
504
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
505
|
-
type: z.ZodLiteral<"organisation.read-locations">;
|
|
506
445
|
options: z.ZodOptional<z.ZodObject<{
|
|
507
446
|
accessLevel: z.ZodOptional<z.ZodEnum<{
|
|
508
447
|
administrativeArea: "administrativeArea";
|
|
@@ -628,21 +567,10 @@ export declare const decodeScope: (query: EncodedScope) => {
|
|
|
628
567
|
registeredBy?: "user" | undefined;
|
|
629
568
|
templates?: string[] | undefined;
|
|
630
569
|
} | undefined;
|
|
631
|
-
} | {
|
|
632
|
-
type: "user.create" | "user.edit";
|
|
633
|
-
options?: {
|
|
634
|
-
accessLevel?: "administrativeArea" | "location" | "all" | undefined;
|
|
635
|
-
role?: string[] | undefined;
|
|
636
|
-
} | undefined;
|
|
637
|
-
} | {
|
|
638
|
-
type: "user.read";
|
|
639
|
-
options?: {
|
|
640
|
-
accessLevel?: "administrativeArea" | "location" | "all" | undefined;
|
|
641
|
-
} | undefined;
|
|
642
570
|
} | {
|
|
643
571
|
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";
|
|
644
572
|
} | {
|
|
645
|
-
type: "organisation.read-locations";
|
|
573
|
+
type: "organisation.read-locations" | "user.read" | "user.create" | "user.edit";
|
|
646
574
|
options?: {
|
|
647
575
|
accessLevel?: "administrativeArea" | "location" | "all" | undefined;
|
|
648
576
|
} | undefined;
|
package/dist/scopes/index.js
CHANGED
|
@@ -42,7 +42,6 @@ __export(scopes_exports, {
|
|
|
42
42
|
ScopesWithFullOptions: () => ScopesWithFullOptions,
|
|
43
43
|
ScopesWithPlaceEventOptions: () => ScopesWithPlaceEventOptions,
|
|
44
44
|
UserFilter: () => UserFilter,
|
|
45
|
-
UserScopeV2: () => UserScopeV2,
|
|
46
45
|
canUserCreateEvent: () => canUserCreateEvent,
|
|
47
46
|
decodeScope: () => decodeScope,
|
|
48
47
|
defineRoles: () => defineRoles,
|
|
@@ -55,8 +54,7 @@ __export(scopes_exports, {
|
|
|
55
54
|
isCustomActionScope: () => isCustomActionScope,
|
|
56
55
|
scopeUsesDeclaredOptions: () => scopeUsesDeclaredOptions,
|
|
57
56
|
scopeUsesFullOptions: () => scopeUsesFullOptions,
|
|
58
|
-
scopeUsesPrintCertifiedCopiesOptions: () => scopeUsesPrintCertifiedCopiesOptions
|
|
59
|
-
scopeUsesRoleOptions: () => scopeUsesRoleOptions
|
|
57
|
+
scopeUsesPrintCertifiedCopiesOptions: () => scopeUsesPrintCertifiedCopiesOptions
|
|
60
58
|
});
|
|
61
59
|
module.exports = __toCommonJS(scopes_exports);
|
|
62
60
|
var z4 = __toESM(require("zod/v4"));
|
|
@@ -141,10 +139,6 @@ var scopeByEvent = z3.preprocess(
|
|
|
141
139
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
142
140
|
z3.array(z3.string()).optional()
|
|
143
141
|
).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");
|
|
148
142
|
var scopeOptionsPlaceEvent = z3.object({
|
|
149
143
|
event: scopeByEvent,
|
|
150
144
|
placeOfEvent: JurisdictionFilter.optional()
|
|
@@ -168,9 +162,6 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
|
168
162
|
var AccessLevelOptions = z3.object({
|
|
169
163
|
accessLevel: JurisdictionFilter.optional()
|
|
170
164
|
});
|
|
171
|
-
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
172
|
-
role: userRole.optional()
|
|
173
|
-
});
|
|
174
165
|
var WorkqueueOrDashboardOptions = z3.object({
|
|
175
166
|
ids: z3.preprocess(
|
|
176
167
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
@@ -180,7 +171,6 @@ var WorkqueueOrDashboardOptions = z3.object({
|
|
|
180
171
|
var AllScopeOptions = z3.object({
|
|
181
172
|
...AllRecordScopeOptions.shape,
|
|
182
173
|
...AccessLevelOptions.shape,
|
|
183
|
-
...AllUserScopeOptions.shape,
|
|
184
174
|
...WorkqueueOrDashboardOptions.shape
|
|
185
175
|
});
|
|
186
176
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
@@ -253,31 +243,6 @@ var RecordScopeV2 = z3.discriminatedUnion("type", [
|
|
|
253
243
|
]).describe(
|
|
254
244
|
"Scopes used to check user's permission to perform actions on a record."
|
|
255
245
|
);
|
|
256
|
-
var SystemScopeType = z3.enum([
|
|
257
|
-
"organisation.read-locations",
|
|
258
|
-
"user.read",
|
|
259
|
-
"user.create",
|
|
260
|
-
"user.edit"
|
|
261
|
-
]);
|
|
262
|
-
var UserScopeType = SystemScopeType.extract([
|
|
263
|
-
"user.read",
|
|
264
|
-
"user.create",
|
|
265
|
-
"user.edit"
|
|
266
|
-
]);
|
|
267
|
-
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
268
|
-
var UserScopeV2 = z3.discriminatedUnion("type", [
|
|
269
|
-
z3.object({
|
|
270
|
-
type: ScopesWithRoleOption,
|
|
271
|
-
options: AllUserScopeOptions.optional()
|
|
272
|
-
}),
|
|
273
|
-
z3.object({
|
|
274
|
-
type: UserScopeType.extract(["user.read"]),
|
|
275
|
-
options: AccessLevelOptions.optional()
|
|
276
|
-
})
|
|
277
|
-
]);
|
|
278
|
-
function scopeUsesRoleOptions(scope) {
|
|
279
|
-
return ScopesWithRoleOption?.options.some((opt) => opt === scope.type);
|
|
280
|
-
}
|
|
281
246
|
function scopeUsesDeclaredOptions(scope) {
|
|
282
247
|
return !ScopesWithPlaceEventOptions.options.some((opt) => opt === scope.type);
|
|
283
248
|
}
|
|
@@ -310,14 +275,16 @@ var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
|
|
|
310
275
|
}).optional()
|
|
311
276
|
})
|
|
312
277
|
]).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
|
+
]);
|
|
313
284
|
var Scope2 = z3.discriminatedUnion("type", [
|
|
314
285
|
z3.object({ type: PlainScopeType }),
|
|
315
286
|
...RecordScopeV2.options,
|
|
316
|
-
|
|
317
|
-
z3.object({
|
|
318
|
-
type: z3.literal("organisation.read-locations"),
|
|
319
|
-
options: AccessLevelOptions.optional()
|
|
320
|
-
}),
|
|
287
|
+
z3.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
|
|
321
288
|
z3.object({
|
|
322
289
|
type: z3.literal("workqueue"),
|
|
323
290
|
options: WorkqueueOrDashboardOptions
|
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|