@opencrvs/toolkit 2.0.0-rc.bb52508 → 2.0.0-rc.c14c17b
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/create-countryconfig/index.js +73 -0
- package/create-countryconfig/package.json +11 -0
- package/dist/application-config/index.js +35 -7
- package/dist/cli.js +1657 -318
- package/dist/commons/api/router.d.ts +34 -32
- package/dist/commons/conditionals/conditionals.d.ts +3 -3
- package/dist/commons/events/FieldConfig.d.ts +5 -0
- package/dist/commons/events/locations.d.ts +38 -1
- package/dist/commons/events/mocks.test.utils.d.ts +19 -0
- package/dist/commons/events/scopes.d.ts +24 -1
- package/dist/conditionals/index.js +35 -7
- package/dist/events/index.js +128 -7
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -1
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +63 -39
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +3 -0
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +1 -0
- package/dist/migrations/v2.0/add-resend-invite-notification.js +373 -0
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +19 -0
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
- package/dist/migrations/v2.0/checkout-upstream-files.js +17 -13
- package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -1
- package/dist/migrations/v2.0/convert-config-files-to-ts.js +4 -5
- package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -1
- package/dist/migrations/v2.0/convert-paragraph-to-heading.js +4 -5
- package/dist/migrations/v2.0/create-events-index.d.ts.map +1 -1
- package/dist/migrations/v2.0/create-events-index.js +1 -2
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +3 -0
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -0
- package/dist/migrations/v2.0/delete-infrastructure-directory.js +77 -0
- package/dist/migrations/v2.0/index.d.ts +8 -4
- package/dist/migrations/v2.0/index.d.ts.map +1 -1
- package/dist/migrations/v2.0/index.js +1625 -315
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -1
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +95 -7
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +3 -0
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -0
- package/dist/migrations/v2.0/merge-infrastructure-directory.js +221 -0
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts +3 -0
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +1 -0
- package/dist/migrations/v2.0/migrate-application-config-url.js +342 -0
- package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-scopes.js +6 -7
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +3 -4
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-workqueue-configs.js +3 -4
- package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-delete-actions.js +3 -4
- package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-demo-scope.js +2 -3
- package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-deprecated-imports.js +3 -4
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +3 -0
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-fhir-url-helpers.js +163 -0
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-hearth-migrations.js +1 -2
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +3 -0
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-old-statistics-service.js +356 -0
- package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-pending-certification-flag.js +3 -4
- package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-review-from-register-action.js +3 -4
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +3 -0
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-unused-environment-variables.js +186 -0
- package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -1
- package/dist/migrations/v2.0/rename-api-paths.js +3 -4
- package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +1 -1
- package/dist/migrations/v2.0/rename-location-parent-id.js +3 -4
- package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +1 -1
- package/dist/migrations/v2.0/simplify-analytics-precalculations.js +1 -2
- package/dist/migrations/v2.0/update-package-json.d.ts +3 -0
- package/dist/migrations/v2.0/update-package-json.d.ts.map +1 -0
- package/dist/migrations/v2.0/update-package-json.js +105 -0
- package/dist/notification/index.js +35 -7
- package/dist/scopes/index.d.ts +82 -10
- package/dist/scopes/index.js +41 -8
- package/opencrvs-toolkit-2.0.0-rc.c14c17b.tgz +0 -0
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/opencrvs-toolkit-2.0.0-rc.bb52508.tgz +0 -0
|
@@ -3975,10 +3975,9 @@ 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
|
-
|
|
3981
|
-
}[];
|
|
3978
|
+
firstname: string;
|
|
3979
|
+
surname: string;
|
|
3980
|
+
};
|
|
3982
3981
|
role: string;
|
|
3983
3982
|
primaryOfficeId: string & import("zod").$brand<"UUID">;
|
|
3984
3983
|
type: "user";
|
|
@@ -4008,10 +4007,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4008
4007
|
create: import("@trpc/server").TRPCMutationProcedure<{
|
|
4009
4008
|
input: {
|
|
4010
4009
|
name: {
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
}[];
|
|
4010
|
+
firstname: string;
|
|
4011
|
+
surname: string;
|
|
4012
|
+
};
|
|
4015
4013
|
role: string;
|
|
4016
4014
|
primaryOfficeId: string;
|
|
4017
4015
|
data?: Record<string, unknown> | undefined;
|
|
@@ -4030,10 +4028,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4030
4028
|
output: {
|
|
4031
4029
|
id: string & import("zod").$brand<"UUID">;
|
|
4032
4030
|
name: {
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
}[];
|
|
4031
|
+
firstname: string;
|
|
4032
|
+
surname: string;
|
|
4033
|
+
};
|
|
4037
4034
|
role: string;
|
|
4038
4035
|
primaryOfficeId: string & import("zod").$brand<"UUID">;
|
|
4039
4036
|
type: "user";
|
|
@@ -4054,10 +4051,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4054
4051
|
id: string;
|
|
4055
4052
|
data?: Record<string, unknown> | undefined;
|
|
4056
4053
|
name?: {
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
}[] | undefined;
|
|
4054
|
+
firstname: string;
|
|
4055
|
+
surname: string;
|
|
4056
|
+
} | undefined;
|
|
4061
4057
|
role?: string | undefined;
|
|
4062
4058
|
fullHonorificName?: string | undefined;
|
|
4063
4059
|
device?: string | undefined;
|
|
@@ -4074,10 +4070,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4074
4070
|
output: {
|
|
4075
4071
|
id: string & import("zod").$brand<"UUID">;
|
|
4076
4072
|
name: {
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
}[];
|
|
4073
|
+
firstname: string;
|
|
4074
|
+
surname: string;
|
|
4075
|
+
};
|
|
4081
4076
|
role: string;
|
|
4082
4077
|
primaryOfficeId: string & import("zod").$brand<"UUID">;
|
|
4083
4078
|
type: "user";
|
|
@@ -4098,10 +4093,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4098
4093
|
output: ({
|
|
4099
4094
|
id: string & import("zod").$brand<"UUID">;
|
|
4100
4095
|
name: {
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
}[];
|
|
4096
|
+
firstname: string;
|
|
4097
|
+
surname: string;
|
|
4098
|
+
};
|
|
4105
4099
|
role: string;
|
|
4106
4100
|
primaryOfficeId: string & import("zod").$brand<"UUID">;
|
|
4107
4101
|
type: "user";
|
|
@@ -4143,10 +4137,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4143
4137
|
output: ({
|
|
4144
4138
|
id: string & import("zod").$brand<"UUID">;
|
|
4145
4139
|
name: {
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
}[];
|
|
4140
|
+
firstname: string;
|
|
4141
|
+
surname: string;
|
|
4142
|
+
};
|
|
4150
4143
|
role: string;
|
|
4151
4144
|
primaryOfficeId: string & import("zod").$brand<"UUID">;
|
|
4152
4145
|
type: "user";
|
|
@@ -4282,10 +4275,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4282
4275
|
changeAvatar: import("@trpc/server").TRPCMutationProcedure<{
|
|
4283
4276
|
input: {
|
|
4284
4277
|
userId: string;
|
|
4285
|
-
avatar:
|
|
4286
|
-
type: string;
|
|
4287
|
-
data: string;
|
|
4288
|
-
};
|
|
4278
|
+
avatar: string;
|
|
4289
4279
|
};
|
|
4290
4280
|
output: void;
|
|
4291
4281
|
meta: import("trpc-to-openapi").OpenApiMeta;
|
|
@@ -4317,6 +4307,18 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
4317
4307
|
output: void;
|
|
4318
4308
|
meta: import("trpc-to-openapi").OpenApiMeta;
|
|
4319
4309
|
}>;
|
|
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
|
+
}>;
|
|
4320
4322
|
audit: import("@trpc/server").TRPCBuiltRouter<{
|
|
4321
4323
|
ctx: Partial<{
|
|
4322
4324
|
token: `Bearer ${string}`;
|
|
@@ -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: "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
90
|
+
$option: "role" | "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: "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
95
|
+
$option: "role" | "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: "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
99
|
+
$option: "role" | "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
100
100
|
};
|
|
101
101
|
};
|
|
102
102
|
};
|
|
@@ -1727,6 +1727,7 @@ declare const AdministrativeAreaField: z.ZodObject<{
|
|
|
1727
1727
|
"dashboard.view": "dashboard.view";
|
|
1728
1728
|
}>;
|
|
1729
1729
|
$option: z.ZodEnum<{
|
|
1730
|
+
role: "role";
|
|
1730
1731
|
event: "event";
|
|
1731
1732
|
placeOfEvent: "placeOfEvent";
|
|
1732
1733
|
declaredIn: "declaredIn";
|
|
@@ -1845,6 +1846,7 @@ declare const LocationInput: z.ZodObject<{
|
|
|
1845
1846
|
"dashboard.view": "dashboard.view";
|
|
1846
1847
|
}>;
|
|
1847
1848
|
$option: z.ZodEnum<{
|
|
1849
|
+
role: "role";
|
|
1848
1850
|
event: "event";
|
|
1849
1851
|
placeOfEvent: "placeOfEvent";
|
|
1850
1852
|
declaredIn: "declaredIn";
|
|
@@ -2028,6 +2030,7 @@ declare const Facility: z.ZodObject<{
|
|
|
2028
2030
|
"dashboard.view": "dashboard.view";
|
|
2029
2031
|
}>;
|
|
2030
2032
|
$option: z.ZodEnum<{
|
|
2033
|
+
role: "role";
|
|
2031
2034
|
event: "event";
|
|
2032
2035
|
placeOfEvent: "placeOfEvent";
|
|
2033
2036
|
declaredIn: "declaredIn";
|
|
@@ -2132,6 +2135,7 @@ declare const Office: z.ZodObject<{
|
|
|
2132
2135
|
"dashboard.view": "dashboard.view";
|
|
2133
2136
|
}>;
|
|
2134
2137
|
$option: z.ZodEnum<{
|
|
2138
|
+
role: "role";
|
|
2135
2139
|
event: "event";
|
|
2136
2140
|
placeOfEvent: "placeOfEvent";
|
|
2137
2141
|
declaredIn: "declaredIn";
|
|
@@ -2323,6 +2327,7 @@ declare const Address: z.ZodObject<{
|
|
|
2323
2327
|
"dashboard.view": "dashboard.view";
|
|
2324
2328
|
}>;
|
|
2325
2329
|
$option: z.ZodEnum<{
|
|
2330
|
+
role: "role";
|
|
2326
2331
|
event: "event";
|
|
2327
2332
|
placeOfEvent: "placeOfEvent";
|
|
2328
2333
|
declaredIn: "declaredIn";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { UUID } from '../uuid';
|
|
1
2
|
import * as z from 'zod/v4';
|
|
2
3
|
import { EventIndex } from './EventIndex';
|
|
3
4
|
import { ActionCreationMetadata, RegistrationCreationMetadata } from './EventMetadata';
|
|
4
|
-
import { RecordScopeV2 } from '../scopes';
|
|
5
|
+
import { RecordScopeV2, UserScopeV2 } from '../scopes';
|
|
5
6
|
import { SystemContext, UserContext } from '../users/User';
|
|
6
7
|
/** @deprecated Moving on, location types are arbitrary and defined by the country config. */
|
|
7
8
|
export declare const LocationTypeV1: z.ZodEnum<{
|
|
@@ -51,11 +52,47 @@ export type EventIndexWithAdministrativeHierarchy = Omit<ToArrayFields<EventInde
|
|
|
51
52
|
*
|
|
52
53
|
*/
|
|
53
54
|
export declare function canAccessEventWithScope(event: Partial<EventIndexWithAdministrativeHierarchy>, scope: RecordScopeV2, user: UserContext | SystemContext, customActionType?: string): boolean;
|
|
55
|
+
export type UserWithResolvedHierarchy = {
|
|
56
|
+
role: string;
|
|
57
|
+
administrativeHierarchy: UUID[];
|
|
58
|
+
primaryOfficeId: UUID;
|
|
59
|
+
};
|
|
60
|
+
export declare function canAccessUserWithScope({ userToAccess, scope, user }: {
|
|
61
|
+
userToAccess: UserWithResolvedHierarchy;
|
|
62
|
+
scope: UserScopeV2;
|
|
63
|
+
user: UserContext | SystemContext;
|
|
64
|
+
}): boolean;
|
|
65
|
+
export declare function canAccessOtherUserWithScopes({ scopes, userToAccess, user }: {
|
|
66
|
+
scopes: UserScopeV2[];
|
|
67
|
+
userToAccess: UserWithResolvedHierarchy;
|
|
68
|
+
user: UserContext | SystemContext;
|
|
69
|
+
}): boolean;
|
|
54
70
|
/**
|
|
55
71
|
* Given indexed event and list of resolved scopes, determine if any of the scopes allow access to the event.
|
|
56
72
|
*
|
|
57
73
|
* One of the scopes must allow access for the event to be accessible.
|
|
58
74
|
*/
|
|
59
75
|
export declare function userCanAccessEventWithScopes(event: Partial<EventIndexWithAdministrativeHierarchy>, scopes: RecordScopeV2[], user: UserContext | SystemContext, customActionType?: string): boolean;
|
|
76
|
+
export declare function getAdministrativeAreaHierarchy(administrativeAreaId: string | undefined | null, administrativeAreas: Map<UUID, AdministrativeArea>): {
|
|
77
|
+
id: string & z.core.$brand<"UUID">;
|
|
78
|
+
name: string;
|
|
79
|
+
parentId: (string & z.core.$brand<"UUID">) | null;
|
|
80
|
+
validUntil: string | null;
|
|
81
|
+
externalId?: string | null | undefined;
|
|
82
|
+
}[];
|
|
83
|
+
/**
|
|
84
|
+
* Resolves a location or administrative area UUID into a root-first hierarchy of UUIDs.
|
|
85
|
+
*
|
|
86
|
+
* If the ID refers to a `Location` (e.g. CRVS office), the hierarchy includes
|
|
87
|
+
* the administrative area ancestors followed by the location itself.
|
|
88
|
+
* If the ID refers to an `AdministrativeArea`, returns the area's ancestor chain (root-first).
|
|
89
|
+
*
|
|
90
|
+
* Uses `getAdministrativeAreaHierarchy` which returns leaf-first order,
|
|
91
|
+
* so the result is reversed to match the root-first convention used by the server.
|
|
92
|
+
*/
|
|
93
|
+
export declare function getLocationHierarchy(selectedId: UUID, context: {
|
|
94
|
+
administrativeAreas: Map<UUID, AdministrativeArea>;
|
|
95
|
+
locations: Map<UUID, Location>;
|
|
96
|
+
}): UUID[];
|
|
60
97
|
export {};
|
|
61
98
|
//# sourceMappingURL=locations.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AdministrativeArea, Location } from './locations';
|
|
2
|
+
export declare const V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS: AdministrativeArea[];
|
|
3
|
+
export declare const V2_DEFAULT_MOCK_LOCATIONS: Location[];
|
|
4
|
+
export declare const V2_DEFAULT_MOCK_LOCATIONS_MAP: Map<string & import("zod").$brand<"UUID">, {
|
|
5
|
+
id: string & import("zod").$brand<"UUID">;
|
|
6
|
+
name: string;
|
|
7
|
+
administrativeAreaId: (string & import("zod").$brand<"UUID">) | null;
|
|
8
|
+
validUntil: string | null;
|
|
9
|
+
locationType: string | null;
|
|
10
|
+
externalId?: string | null | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP: Map<string & import("zod").$brand<"UUID">, {
|
|
13
|
+
id: string & import("zod").$brand<"UUID">;
|
|
14
|
+
name: string;
|
|
15
|
+
parentId: (string & import("zod").$brand<"UUID">) | null;
|
|
16
|
+
validUntil: string | null;
|
|
17
|
+
externalId?: string | null | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
//# sourceMappingURL=mocks.test.utils.d.ts.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { DisplayableAction } from './ActionType';
|
|
2
|
-
import { EncodedScope } from '../scopes';
|
|
2
|
+
import { EncodedScope, UserScopeV2 } from '../scopes';
|
|
3
3
|
import { EventIndexWithAdministrativeHierarchy } from './locations';
|
|
4
4
|
import { UserContext } from '../users/User';
|
|
5
5
|
import { EventIndex } from './EventIndex';
|
|
6
|
+
import { UUID } from 'src/uuid';
|
|
6
7
|
export declare const ACTION_SCOPE_MAP: {
|
|
7
8
|
READ: "record.read"[];
|
|
8
9
|
CREATE: "record.create"[];
|
|
@@ -53,4 +54,26 @@ export declare function isActionInScope({ scopes, action, event, currentUser }:
|
|
|
53
54
|
event: EventIndexWithAdministrativeHierarchy;
|
|
54
55
|
currentUser: UserContext;
|
|
55
56
|
}): boolean;
|
|
57
|
+
/**
|
|
58
|
+
*
|
|
59
|
+
*
|
|
60
|
+
* @param allRoles - All possible roles in the system
|
|
61
|
+
* @param userLocation - The location and role information of the user whose role options are being determined
|
|
62
|
+
* @param acceptedScopes - The scopes of the user requesting the role update, used to determine which roles they can assign.
|
|
63
|
+
* @param userRequesting - The user context of the user requesting the role update, used to check location-based access to the target user's location.
|
|
64
|
+
*
|
|
65
|
+
* @returns An array of roles that the requesting user is allowed to assign to the target user based on their scopes and location
|
|
66
|
+
*
|
|
67
|
+
* 1) Used to determine which roles should be available in the dropdown when a user is editing another user's role in the user management interface.
|
|
68
|
+
* 2) Used to check if payload includes valid role.
|
|
69
|
+
*/
|
|
70
|
+
export declare function getAvailableRolesForUserUpdatePayload({ allRoles, userLocation, acceptedScopes, userRequesting }: {
|
|
71
|
+
allRoles: string[];
|
|
72
|
+
userRequesting: UserContext;
|
|
73
|
+
acceptedScopes: UserScopeV2[];
|
|
74
|
+
userLocation: {
|
|
75
|
+
administrativeHierarchy: UUID[];
|
|
76
|
+
primaryOfficeId: UUID;
|
|
77
|
+
};
|
|
78
|
+
}): string[];
|
|
56
79
|
//# sourceMappingURL=scopes.d.ts.map
|
|
@@ -182,6 +182,10 @@ var scopeByEvent = z6.preprocess(
|
|
|
182
182
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
183
183
|
z6.array(z6.string()).optional()
|
|
184
184
|
).describe("Event type, e.g. birth, death");
|
|
185
|
+
var userRole = z6.preprocess(
|
|
186
|
+
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
187
|
+
z6.array(z6.string()).optional()
|
|
188
|
+
).describe("User role, e.g. admin, field agent");
|
|
185
189
|
var scopeOptionsPlaceEvent = z6.object({
|
|
186
190
|
event: scopeByEvent,
|
|
187
191
|
placeOfEvent: JurisdictionFilter.optional()
|
|
@@ -205,6 +209,9 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
|
205
209
|
var AccessLevelOptions = z6.object({
|
|
206
210
|
accessLevel: JurisdictionFilter.optional()
|
|
207
211
|
});
|
|
212
|
+
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
213
|
+
role: userRole.optional()
|
|
214
|
+
});
|
|
208
215
|
var WorkqueueOrDashboardOptions = z6.object({
|
|
209
216
|
ids: z6.preprocess(
|
|
210
217
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
@@ -214,6 +221,7 @@ var WorkqueueOrDashboardOptions = z6.object({
|
|
|
214
221
|
var AllScopeOptions = z6.object({
|
|
215
222
|
...AllRecordScopeOptions.shape,
|
|
216
223
|
...AccessLevelOptions.shape,
|
|
224
|
+
...AllUserScopeOptions.shape,
|
|
217
225
|
...WorkqueueOrDashboardOptions.shape
|
|
218
226
|
});
|
|
219
227
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
@@ -286,6 +294,28 @@ var RecordScopeV2 = z6.discriminatedUnion("type", [
|
|
|
286
294
|
]).describe(
|
|
287
295
|
"Scopes used to check user's permission to perform actions on a record."
|
|
288
296
|
);
|
|
297
|
+
var SystemScopeType = z6.enum([
|
|
298
|
+
"organisation.read-locations",
|
|
299
|
+
"user.read",
|
|
300
|
+
"user.create",
|
|
301
|
+
"user.edit"
|
|
302
|
+
]);
|
|
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
|
+
]);
|
|
289
319
|
var ResolvedRecordScopeV2 = z6.discriminatedUnion("type", [
|
|
290
320
|
z6.object({
|
|
291
321
|
type: ScopesWithPlaceEventOptions,
|
|
@@ -306,16 +336,14 @@ var ResolvedRecordScopeV2 = z6.discriminatedUnion("type", [
|
|
|
306
336
|
}).optional()
|
|
307
337
|
})
|
|
308
338
|
]).describe("Resolved scope with location/user IDs instead of filters.");
|
|
309
|
-
var SystemScopeType = z6.enum([
|
|
310
|
-
"organisation.read-locations",
|
|
311
|
-
"user.read",
|
|
312
|
-
"user.create",
|
|
313
|
-
"user.edit"
|
|
314
|
-
]);
|
|
315
339
|
var Scope2 = z6.discriminatedUnion("type", [
|
|
316
340
|
z6.object({ type: PlainScopeType }),
|
|
317
341
|
...RecordScopeV2.options,
|
|
318
|
-
|
|
342
|
+
...UserScopeV2.options,
|
|
343
|
+
z6.object({
|
|
344
|
+
type: z6.literal("organisation.read-locations"),
|
|
345
|
+
options: AccessLevelOptions.optional()
|
|
346
|
+
}),
|
|
319
347
|
z6.object({
|
|
320
348
|
type: z6.literal("workqueue"),
|
|
321
349
|
options: WorkqueueOrDashboardOptions
|
package/dist/events/index.js
CHANGED
|
@@ -243,6 +243,8 @@ __export(events_exports, {
|
|
|
243
243
|
areConditionsMet: () => areConditionsMet,
|
|
244
244
|
buildFormState: () => buildFormState,
|
|
245
245
|
canAccessEventWithScope: () => canAccessEventWithScope,
|
|
246
|
+
canAccessOtherUserWithScopes: () => canAccessOtherUserWithScopes,
|
|
247
|
+
canAccessUserWithScope: () => canAccessUserWithScope,
|
|
246
248
|
compositeFieldTypes: () => compositeFieldTypes,
|
|
247
249
|
createEmptyDraft: () => createEmptyDraft,
|
|
248
250
|
createFieldConditionals: () => createFieldConditionals,
|
|
@@ -300,12 +302,14 @@ __export(events_exports, {
|
|
|
300
302
|
getActionConfig: () => getActionConfig,
|
|
301
303
|
getActionReview: () => getActionReview,
|
|
302
304
|
getActionReviewFields: () => getActionReviewFields,
|
|
305
|
+
getAdministrativeAreaHierarchy: () => getAdministrativeAreaHierarchy,
|
|
303
306
|
getAllUniqueFields: () => getAllUniqueFields,
|
|
304
307
|
getAnnotationFromDrafts: () => getAnnotationFromDrafts,
|
|
305
308
|
getAssignedUserFromActions: () => getAssignedUserFromActions,
|
|
306
309
|
getAssignedUserSignatureFromActions: () => getAssignedUserSignatureFromActions,
|
|
307
310
|
getAssignmentStatus: () => getAssignmentStatus,
|
|
308
311
|
getAvailableActionsForEvent: () => getAvailableActionsForEvent,
|
|
312
|
+
getAvailableRolesForUserUpdatePayload: () => getAvailableRolesForUserUpdatePayload,
|
|
309
313
|
getCompleteActionAnnotation: () => getCompleteActionAnnotation,
|
|
310
314
|
getCompleteActionDeclaration: () => getCompleteActionDeclaration,
|
|
311
315
|
getCurrentEventState: () => getCurrentEventState,
|
|
@@ -316,6 +320,7 @@ __export(events_exports, {
|
|
|
316
320
|
getDeclarationPages: () => getDeclarationPages,
|
|
317
321
|
getEventConfigById: () => getEventConfigById,
|
|
318
322
|
getFilePathsFromEvent: () => getFilePathsFromEvent,
|
|
323
|
+
getLocationHierarchy: () => getLocationHierarchy,
|
|
319
324
|
getMixedPath: () => getMixedPath,
|
|
320
325
|
getPendingAction: () => getPendingAction,
|
|
321
326
|
getPrintCertificatePages: () => getPrintCertificatePages,
|
|
@@ -489,6 +494,10 @@ var scopeByEvent = z2.preprocess(
|
|
|
489
494
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
490
495
|
z2.array(z2.string()).optional()
|
|
491
496
|
).describe("Event type, e.g. birth, death");
|
|
497
|
+
var userRole = z2.preprocess(
|
|
498
|
+
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
499
|
+
z2.array(z2.string()).optional()
|
|
500
|
+
).describe("User role, e.g. admin, field agent");
|
|
492
501
|
var scopeOptionsPlaceEvent = z2.object({
|
|
493
502
|
event: scopeByEvent,
|
|
494
503
|
placeOfEvent: JurisdictionFilter.optional()
|
|
@@ -512,6 +521,9 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
|
512
521
|
var AccessLevelOptions = z2.object({
|
|
513
522
|
accessLevel: JurisdictionFilter.optional()
|
|
514
523
|
});
|
|
524
|
+
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
525
|
+
role: userRole.optional()
|
|
526
|
+
});
|
|
515
527
|
var WorkqueueOrDashboardOptions = z2.object({
|
|
516
528
|
ids: z2.preprocess(
|
|
517
529
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
@@ -521,6 +533,7 @@ var WorkqueueOrDashboardOptions = z2.object({
|
|
|
521
533
|
var AllScopeOptions = z2.object({
|
|
522
534
|
...AllRecordScopeOptions.shape,
|
|
523
535
|
...AccessLevelOptions.shape,
|
|
536
|
+
...AllUserScopeOptions.shape,
|
|
524
537
|
...WorkqueueOrDashboardOptions.shape
|
|
525
538
|
});
|
|
526
539
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
@@ -593,6 +606,31 @@ var RecordScopeV2 = z2.discriminatedUnion("type", [
|
|
|
593
606
|
]).describe(
|
|
594
607
|
"Scopes used to check user's permission to perform actions on a record."
|
|
595
608
|
);
|
|
609
|
+
var SystemScopeType = z2.enum([
|
|
610
|
+
"organisation.read-locations",
|
|
611
|
+
"user.read",
|
|
612
|
+
"user.create",
|
|
613
|
+
"user.edit"
|
|
614
|
+
]);
|
|
615
|
+
var UserScopeType = SystemScopeType.extract([
|
|
616
|
+
"user.read",
|
|
617
|
+
"user.create",
|
|
618
|
+
"user.edit"
|
|
619
|
+
]);
|
|
620
|
+
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
621
|
+
var UserScopeV2 = z2.discriminatedUnion("type", [
|
|
622
|
+
z2.object({
|
|
623
|
+
type: ScopesWithRoleOption,
|
|
624
|
+
options: AllUserScopeOptions.optional()
|
|
625
|
+
}),
|
|
626
|
+
z2.object({
|
|
627
|
+
type: UserScopeType.extract(["user.read"]),
|
|
628
|
+
options: AccessLevelOptions.optional()
|
|
629
|
+
})
|
|
630
|
+
]);
|
|
631
|
+
function scopeUsesRoleOptions(scope) {
|
|
632
|
+
return ScopesWithRoleOption?.options.some((opt) => opt === scope.type);
|
|
633
|
+
}
|
|
596
634
|
function scopeUsesDeclaredOptions(scope) {
|
|
597
635
|
return !ScopesWithPlaceEventOptions.options.some((opt) => opt === scope.type);
|
|
598
636
|
}
|
|
@@ -625,16 +663,14 @@ var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
|
|
|
625
663
|
}).optional()
|
|
626
664
|
})
|
|
627
665
|
]).describe("Resolved scope with location/user IDs instead of filters.");
|
|
628
|
-
var SystemScopeType = z2.enum([
|
|
629
|
-
"organisation.read-locations",
|
|
630
|
-
"user.read",
|
|
631
|
-
"user.create",
|
|
632
|
-
"user.edit"
|
|
633
|
-
]);
|
|
634
666
|
var Scope = z2.discriminatedUnion("type", [
|
|
635
667
|
z2.object({ type: PlainScopeType }),
|
|
636
668
|
...RecordScopeV2.options,
|
|
637
|
-
|
|
669
|
+
...UserScopeV2.options,
|
|
670
|
+
z2.object({
|
|
671
|
+
type: z2.literal("organisation.read-locations"),
|
|
672
|
+
options: AccessLevelOptions.optional()
|
|
673
|
+
}),
|
|
638
674
|
z2.object({
|
|
639
675
|
type: z2.literal("workqueue"),
|
|
640
676
|
options: WorkqueueOrDashboardOptions
|
|
@@ -9930,11 +9966,77 @@ function canAccessEventWithScope(event2, scope, user2, customActionType) {
|
|
|
9930
9966
|
}
|
|
9931
9967
|
return true;
|
|
9932
9968
|
}
|
|
9969
|
+
function canAccessUserWithScope({
|
|
9970
|
+
userToAccess,
|
|
9971
|
+
scope,
|
|
9972
|
+
user: user2
|
|
9973
|
+
}) {
|
|
9974
|
+
const opts = scope.options;
|
|
9975
|
+
const hasSameOffice = user2.primaryOfficeId === userToAccess.primaryOfficeId;
|
|
9976
|
+
if (opts?.accessLevel === JurisdictionFilter.enum.location && !hasSameOffice) {
|
|
9977
|
+
return false;
|
|
9978
|
+
}
|
|
9979
|
+
const hasAdministrativeAreaInHierarchy = userToAccess.administrativeHierarchy.some(
|
|
9980
|
+
(id) => user2.administrativeAreaId === id
|
|
9981
|
+
) || user2.administrativeAreaId === null;
|
|
9982
|
+
if (opts?.accessLevel === JurisdictionFilter.enum.administrativeArea && !hasAdministrativeAreaInHierarchy) {
|
|
9983
|
+
return false;
|
|
9984
|
+
}
|
|
9985
|
+
if (scopeUsesRoleOptions(scope)) {
|
|
9986
|
+
const { options } = scope;
|
|
9987
|
+
if (options?.role && !options.role.includes(userToAccess.role)) {
|
|
9988
|
+
return false;
|
|
9989
|
+
}
|
|
9990
|
+
}
|
|
9991
|
+
return true;
|
|
9992
|
+
}
|
|
9993
|
+
function canAccessOtherUserWithScopes({
|
|
9994
|
+
scopes,
|
|
9995
|
+
userToAccess,
|
|
9996
|
+
user: user2
|
|
9997
|
+
}) {
|
|
9998
|
+
return scopes.some(
|
|
9999
|
+
(scope) => canAccessUserWithScope({ userToAccess, scope, user: user2 })
|
|
10000
|
+
);
|
|
10001
|
+
}
|
|
9933
10002
|
function userCanAccessEventWithScopes(event2, scopes, user2, customActionType) {
|
|
9934
10003
|
return scopes.some(
|
|
9935
10004
|
(scope) => canAccessEventWithScope(event2, scope, user2, customActionType)
|
|
9936
10005
|
);
|
|
9937
10006
|
}
|
|
10007
|
+
function getAdministrativeAreaHierarchy(administrativeAreaId, administrativeAreas) {
|
|
10008
|
+
const collectedLocations = [];
|
|
10009
|
+
const parsedAdministrativeAreaId = administrativeAreaId && UUID.safeParse(administrativeAreaId).data;
|
|
10010
|
+
let current = parsedAdministrativeAreaId ? administrativeAreas.get(parsedAdministrativeAreaId) : null;
|
|
10011
|
+
while (current) {
|
|
10012
|
+
collectedLocations.push(current);
|
|
10013
|
+
if (!current.parentId) {
|
|
10014
|
+
break;
|
|
10015
|
+
}
|
|
10016
|
+
const parentId = current.parentId;
|
|
10017
|
+
current = administrativeAreas.get(parentId);
|
|
10018
|
+
}
|
|
10019
|
+
return collectedLocations;
|
|
10020
|
+
}
|
|
10021
|
+
function getLocationHierarchy(selectedId, context) {
|
|
10022
|
+
const { administrativeAreas, locations } = context;
|
|
10023
|
+
const loc = locations.get(selectedId);
|
|
10024
|
+
if (loc) {
|
|
10025
|
+
if (loc.administrativeAreaId) {
|
|
10026
|
+
const hierarchy2 = getAdministrativeAreaHierarchy(
|
|
10027
|
+
loc.administrativeAreaId,
|
|
10028
|
+
administrativeAreas
|
|
10029
|
+
);
|
|
10030
|
+
return [...hierarchy2.reverse().map((area) => area.id), loc.id];
|
|
10031
|
+
}
|
|
10032
|
+
return [loc.id];
|
|
10033
|
+
}
|
|
10034
|
+
const hierarchy = getAdministrativeAreaHierarchy(
|
|
10035
|
+
selectedId,
|
|
10036
|
+
administrativeAreas
|
|
10037
|
+
);
|
|
10038
|
+
return hierarchy.reverse().map((area) => area.id);
|
|
10039
|
+
}
|
|
9938
10040
|
|
|
9939
10041
|
// ../commons/src/events/scopes.ts
|
|
9940
10042
|
var ACTION_SCOPE_MAP = {
|
|
@@ -10009,6 +10111,25 @@ function isActionInScope({
|
|
|
10009
10111
|
);
|
|
10010
10112
|
return canAccess;
|
|
10011
10113
|
}
|
|
10114
|
+
function getAvailableRolesForUserUpdatePayload({
|
|
10115
|
+
allRoles,
|
|
10116
|
+
userLocation,
|
|
10117
|
+
acceptedScopes,
|
|
10118
|
+
userRequesting
|
|
10119
|
+
}) {
|
|
10120
|
+
const availableRoles = allRoles.filter((role) => {
|
|
10121
|
+
const canAccess = canAccessOtherUserWithScopes({
|
|
10122
|
+
userToAccess: {
|
|
10123
|
+
...userLocation,
|
|
10124
|
+
role
|
|
10125
|
+
},
|
|
10126
|
+
user: userRequesting,
|
|
10127
|
+
scopes: acceptedScopes
|
|
10128
|
+
});
|
|
10129
|
+
return canAccess;
|
|
10130
|
+
});
|
|
10131
|
+
return availableRoles;
|
|
10132
|
+
}
|
|
10012
10133
|
|
|
10013
10134
|
// ../commons/src/events/serializers/user/deserializer.ts
|
|
10014
10135
|
function userDeserializer(serializedUserField, user2) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-birth-certificate-issuance-flag.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/add-birth-certificate-issuance-flag.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"add-birth-certificate-issuance-flag.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/add-birth-certificate-issuance-flag.ts"],"names":[],"mappings":"AAycA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|