@opencrvs/toolkit 2.0.0-rc.05c3312 → 2.0.0-rc.143d05a
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 +7 -35
- package/dist/cli.js +7 -35
- package/dist/commons/api/router.d.ts +52 -54
- 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.143d05a.tgz +0 -0
- package/package.json +1 -1
- package/opencrvs-toolkit-2.0.0-rc.05c3312.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
|
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";
|
|
@@ -4275,7 +4282,10 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4275
4282
|
changeAvatar: import("@trpc/server").TRPCMutationProcedure<{
|
|
4276
4283
|
input: {
|
|
4277
4284
|
userId: string;
|
|
4278
|
-
avatar:
|
|
4285
|
+
avatar: {
|
|
4286
|
+
type: string;
|
|
4287
|
+
data: string;
|
|
4288
|
+
};
|
|
4279
4289
|
};
|
|
4280
4290
|
output: void;
|
|
4281
4291
|
meta: import("trpc-to-openapi").OpenApiMeta;
|
|
@@ -4307,18 +4317,6 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4307
4317
|
output: void;
|
|
4308
4318
|
meta: import("trpc-to-openapi").OpenApiMeta;
|
|
4309
4319
|
}>;
|
|
4310
|
-
verifyLoggedInUserPassword: import("@trpc/server").TRPCMutationProcedure<{
|
|
4311
|
-
input: {
|
|
4312
|
-
password: string;
|
|
4313
|
-
};
|
|
4314
|
-
output: {
|
|
4315
|
-
status: string;
|
|
4316
|
-
username: string;
|
|
4317
|
-
id: string;
|
|
4318
|
-
mobile?: string | undefined;
|
|
4319
|
-
};
|
|
4320
|
-
meta: import("trpc-to-openapi").OpenApiMeta;
|
|
4321
|
-
}>;
|
|
4322
4320
|
audit: import("@trpc/server").TRPCBuiltRouter<{
|
|
4323
4321
|
ctx: Partial<{
|
|
4324
4322
|
token: `Bearer ${string}`;
|
|
@@ -4774,7 +4772,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4774
4772
|
'legalStatuses.DECLARED.createdAtLocation'?: {
|
|
4775
4773
|
type: "within";
|
|
4776
4774
|
location: string | {
|
|
4777
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4775
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "avatar" | "signature" | "primaryOfficeId";
|
|
4778
4776
|
$location?: string | undefined;
|
|
4779
4777
|
};
|
|
4780
4778
|
} | undefined;
|
|
@@ -4796,7 +4794,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4796
4794
|
'legalStatuses.REGISTERED.createdAtLocation'?: {
|
|
4797
4795
|
type: "within";
|
|
4798
4796
|
location: string | {
|
|
4799
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4797
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "avatar" | "signature" | "primaryOfficeId";
|
|
4800
4798
|
$location?: string | undefined;
|
|
4801
4799
|
};
|
|
4802
4800
|
} | undefined;
|
|
@@ -4811,47 +4809,47 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4811
4809
|
createdAtLocation?: {
|
|
4812
4810
|
type: "within";
|
|
4813
4811
|
location: string | {
|
|
4814
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4812
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "avatar" | "signature" | "primaryOfficeId";
|
|
4815
4813
|
$location?: string | undefined;
|
|
4816
4814
|
};
|
|
4817
4815
|
} | {
|
|
4818
4816
|
type: "exact";
|
|
4819
4817
|
term: string | {
|
|
4820
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4818
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "avatar" | "signature" | "primaryOfficeId";
|
|
4821
4819
|
$location?: string | undefined;
|
|
4822
4820
|
};
|
|
4823
4821
|
} | undefined;
|
|
4824
4822
|
updatedAtLocation?: {
|
|
4825
4823
|
type: "within";
|
|
4826
4824
|
location: string | {
|
|
4827
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4825
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "avatar" | "signature" | "primaryOfficeId";
|
|
4828
4826
|
$location?: string | undefined;
|
|
4829
4827
|
};
|
|
4830
4828
|
} | {
|
|
4831
4829
|
type: "exact";
|
|
4832
4830
|
term: string | {
|
|
4833
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4831
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "avatar" | "signature" | "primaryOfficeId";
|
|
4834
4832
|
$location?: string | undefined;
|
|
4835
4833
|
};
|
|
4836
4834
|
} | undefined;
|
|
4837
4835
|
updatedByUserRole?: {
|
|
4838
4836
|
type: "exact";
|
|
4839
4837
|
term: string | {
|
|
4840
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4838
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "avatar" | "signature" | "primaryOfficeId";
|
|
4841
4839
|
$location?: string | undefined;
|
|
4842
4840
|
};
|
|
4843
4841
|
} | undefined;
|
|
4844
4842
|
assignedTo?: {
|
|
4845
4843
|
type: "exact";
|
|
4846
4844
|
term: string | {
|
|
4847
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4845
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "avatar" | "signature" | "primaryOfficeId";
|
|
4848
4846
|
$location?: string | undefined;
|
|
4849
4847
|
};
|
|
4850
4848
|
} | undefined;
|
|
4851
4849
|
createdBy?: {
|
|
4852
4850
|
type: "exact";
|
|
4853
4851
|
term: string | {
|
|
4854
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4852
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "avatar" | "signature" | "primaryOfficeId";
|
|
4855
4853
|
$location?: string | undefined;
|
|
4856
4854
|
};
|
|
4857
4855
|
} | undefined;
|
|
@@ -4862,7 +4860,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4862
4860
|
updatedBy?: {
|
|
4863
4861
|
type: "exact";
|
|
4864
4862
|
term: string | {
|
|
4865
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4863
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "avatar" | "signature" | "primaryOfficeId";
|
|
4866
4864
|
$location?: string | undefined;
|
|
4867
4865
|
};
|
|
4868
4866
|
} | undefined;
|
|
@@ -4912,7 +4910,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4912
4910
|
'legalStatuses.DECLARED.createdAtLocation'?: {
|
|
4913
4911
|
type: "within";
|
|
4914
4912
|
location: string | {
|
|
4915
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4913
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "avatar" | "signature" | "primaryOfficeId";
|
|
4916
4914
|
$location?: string | undefined;
|
|
4917
4915
|
};
|
|
4918
4916
|
} | undefined;
|
|
@@ -4934,7 +4932,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4934
4932
|
'legalStatuses.REGISTERED.createdAtLocation'?: {
|
|
4935
4933
|
type: "within";
|
|
4936
4934
|
location: string | {
|
|
4937
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4935
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "avatar" | "signature" | "primaryOfficeId";
|
|
4938
4936
|
$location?: string | undefined;
|
|
4939
4937
|
};
|
|
4940
4938
|
} | undefined;
|
|
@@ -4949,47 +4947,47 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4949
4947
|
createdAtLocation?: {
|
|
4950
4948
|
type: "within";
|
|
4951
4949
|
location: string | {
|
|
4952
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4950
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "avatar" | "signature" | "primaryOfficeId";
|
|
4953
4951
|
$location?: string | undefined;
|
|
4954
4952
|
};
|
|
4955
4953
|
} | {
|
|
4956
4954
|
type: "exact";
|
|
4957
4955
|
term: string | {
|
|
4958
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4956
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "avatar" | "signature" | "primaryOfficeId";
|
|
4959
4957
|
$location?: string | undefined;
|
|
4960
4958
|
};
|
|
4961
4959
|
} | undefined;
|
|
4962
4960
|
updatedAtLocation?: {
|
|
4963
4961
|
type: "within";
|
|
4964
4962
|
location: string | {
|
|
4965
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4963
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "avatar" | "signature" | "primaryOfficeId";
|
|
4966
4964
|
$location?: string | undefined;
|
|
4967
4965
|
};
|
|
4968
4966
|
} | {
|
|
4969
4967
|
type: "exact";
|
|
4970
4968
|
term: string | {
|
|
4971
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4969
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "avatar" | "signature" | "primaryOfficeId";
|
|
4972
4970
|
$location?: string | undefined;
|
|
4973
4971
|
};
|
|
4974
4972
|
} | undefined;
|
|
4975
4973
|
updatedByUserRole?: {
|
|
4976
4974
|
type: "exact";
|
|
4977
4975
|
term: string | {
|
|
4978
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4976
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "avatar" | "signature" | "primaryOfficeId";
|
|
4979
4977
|
$location?: string | undefined;
|
|
4980
4978
|
};
|
|
4981
4979
|
} | undefined;
|
|
4982
4980
|
assignedTo?: {
|
|
4983
4981
|
type: "exact";
|
|
4984
4982
|
term: string | {
|
|
4985
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4983
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "avatar" | "signature" | "primaryOfficeId";
|
|
4986
4984
|
$location?: string | undefined;
|
|
4987
4985
|
};
|
|
4988
4986
|
} | undefined;
|
|
4989
4987
|
createdBy?: {
|
|
4990
4988
|
type: "exact";
|
|
4991
4989
|
term: string | {
|
|
4992
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
4990
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "avatar" | "signature" | "primaryOfficeId";
|
|
4993
4991
|
$location?: string | undefined;
|
|
4994
4992
|
};
|
|
4995
4993
|
} | undefined;
|
|
@@ -5000,7 +4998,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
5000
4998
|
updatedBy?: {
|
|
5001
4999
|
type: "exact";
|
|
5002
5000
|
term: string | {
|
|
5003
|
-
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "
|
|
5001
|
+
$userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "avatar" | "signature" | "primaryOfficeId";
|
|
5004
5002
|
$location?: string | undefined;
|
|
5005
5003
|
};
|
|
5006
5004
|
} | undefined;
|
|
@@ -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
|