@opencrvs/toolkit 2.0.0-rc.edee239 → 2.0.0-rc.f1925c7

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.
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env node
2
+
3
+ /*
4
+ * This Source Code Form is subject to the terms of the Mozilla Public
5
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
6
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7
+ *
8
+ * OpenCRVS is also distributed under the terms of the Civil Registration
9
+ * & Healthcare Disclaimer located at http://opencrvs.org/license.
10
+ *
11
+ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
12
+ */
13
+
14
+ const { execSync } = require('child_process')
15
+ const path = require('path')
16
+ const fs = require('fs')
17
+
18
+ const REPO_URL = 'https://github.com/opencrvs/opencrvs-countryconfig.git'
19
+
20
+ const projectName = process.argv[2]
21
+
22
+ if (!projectName) {
23
+ console.error(
24
+ 'Please specify a project name:\n\n npm create @opencrvs/countryconfig <project-name>\n'
25
+ )
26
+ process.exit(1)
27
+ }
28
+
29
+ const targetDir = path.resolve(process.cwd(), projectName)
30
+
31
+ if (fs.existsSync(targetDir)) {
32
+ console.error(`Error: Directory "${projectName}" already exists.`)
33
+ process.exit(1)
34
+ }
35
+
36
+ console.log(`\nScaffolding OpenCRVS country config in ./${projectName}...\n`)
37
+
38
+ try {
39
+ execSync(`git clone --depth 1 ${REPO_URL} ${projectName}`, {
40
+ stdio: 'inherit'
41
+ })
42
+ } catch (err) {
43
+ console.error('Failed to clone the repository:', err.message)
44
+ process.exit(1)
45
+ }
46
+
47
+ try {
48
+ fs.rmSync(path.join(targetDir, '.git'), { recursive: true, force: true })
49
+ } catch (err) {
50
+ console.error('Failed to remove .git directory:', err.message)
51
+ process.exit(1)
52
+ }
53
+
54
+ const pkgPath = path.join(targetDir, 'package.json')
55
+ if (fs.existsSync(pkgPath)) {
56
+ try {
57
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))
58
+ pkg.name = projectName
59
+ fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n')
60
+ } catch (err) {
61
+ console.error('Failed to update package.json:', err.message)
62
+ process.exit(1)
63
+ }
64
+ } else {
65
+ console.warn(
66
+ `Warning: No package.json found in the cloned repository. Project name was not updated.`
67
+ )
68
+ }
69
+
70
+ console.log(`\nDone! To get started:\n`)
71
+ console.log(` cd ${projectName}`)
72
+ console.log(` git init`)
73
+ console.log(` npm install\n`)
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "@opencrvs/create-countryconfig",
3
+ "version": "1.0.0",
4
+ "description": "Scaffold a new OpenCRVS country configuration",
5
+ "bin": {
6
+ "create-countryconfig": "./index.js"
7
+ },
8
+ "files": ["index.js"],
9
+ "keywords": ["opencrvs", "countryconfig", "create"],
10
+ "license": "MPL-2.0"
11
+ }
@@ -772,12 +772,14 @@ var SystemScopeType = z11.enum([
772
772
  "organisation.read-locations",
773
773
  "user.read",
774
774
  "user.create",
775
- "user.edit"
775
+ "user.edit",
776
+ "user.search"
776
777
  ]);
777
778
  var UserScopeType = SystemScopeType.extract([
778
779
  "user.read",
779
780
  "user.create",
780
- "user.edit"
781
+ "user.edit",
782
+ "user.search"
781
783
  ]);
782
784
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
783
785
  var UserScopeV2 = z11.discriminatedUnion("type", [
@@ -786,7 +788,7 @@ var UserScopeV2 = z11.discriminatedUnion("type", [
786
788
  options: AllUserScopeOptions.optional()
787
789
  }),
788
790
  z11.object({
789
- type: UserScopeType.extract(["user.read"]),
791
+ type: UserScopeType.extract(["user.read", "user.search"]),
790
792
  options: AccessLevelOptions.optional()
791
793
  })
792
794
  ]);
package/dist/cli.js CHANGED
@@ -2296,12 +2296,14 @@ var SystemScopeType = z3.enum([
2296
2296
  "organisation.read-locations",
2297
2297
  "user.read",
2298
2298
  "user.create",
2299
- "user.edit"
2299
+ "user.edit",
2300
+ "user.search"
2300
2301
  ]);
2301
2302
  var UserScopeType = SystemScopeType.extract([
2302
2303
  "user.read",
2303
2304
  "user.create",
2304
- "user.edit"
2305
+ "user.edit",
2306
+ "user.search"
2305
2307
  ]);
2306
2308
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
2307
2309
  var UserScopeV2 = z3.discriminatedUnion("type", [
@@ -2310,7 +2312,7 @@ var UserScopeV2 = z3.discriminatedUnion("type", [
2310
2312
  options: AllUserScopeOptions.optional()
2311
2313
  }),
2312
2314
  z3.object({
2313
- type: UserScopeType.extract(["user.read"]),
2315
+ type: UserScopeType.extract(["user.read", "user.search"]),
2314
2316
  options: AccessLevelOptions.optional()
2315
2317
  })
2316
2318
  ]);
@@ -4774,7 +4774,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
4774
4774
  'legalStatuses.DECLARED.createdAtLocation'?: {
4775
4775
  type: "within";
4776
4776
  location: string | {
4777
- $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
4777
+ $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "middlename" | "signature" | "avatar";
4778
4778
  $location?: string | undefined;
4779
4779
  };
4780
4780
  } | undefined;
@@ -4796,7 +4796,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
4796
4796
  'legalStatuses.REGISTERED.createdAtLocation'?: {
4797
4797
  type: "within";
4798
4798
  location: string | {
4799
- $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
4799
+ $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "middlename" | "signature" | "avatar";
4800
4800
  $location?: string | undefined;
4801
4801
  };
4802
4802
  } | undefined;
@@ -4811,47 +4811,47 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
4811
4811
  createdAtLocation?: {
4812
4812
  type: "within";
4813
4813
  location: string | {
4814
- $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
4814
+ $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "middlename" | "signature" | "avatar";
4815
4815
  $location?: string | undefined;
4816
4816
  };
4817
4817
  } | {
4818
4818
  type: "exact";
4819
4819
  term: string | {
4820
- $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
4820
+ $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "middlename" | "signature" | "avatar";
4821
4821
  $location?: string | undefined;
4822
4822
  };
4823
4823
  } | undefined;
4824
4824
  updatedAtLocation?: {
4825
4825
  type: "within";
4826
4826
  location: string | {
4827
- $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
4827
+ $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "middlename" | "signature" | "avatar";
4828
4828
  $location?: string | undefined;
4829
4829
  };
4830
4830
  } | {
4831
4831
  type: "exact";
4832
4832
  term: string | {
4833
- $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
4833
+ $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "middlename" | "signature" | "avatar";
4834
4834
  $location?: string | undefined;
4835
4835
  };
4836
4836
  } | undefined;
4837
4837
  updatedByUserRole?: {
4838
4838
  type: "exact";
4839
4839
  term: string | {
4840
- $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
4840
+ $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "middlename" | "signature" | "avatar";
4841
4841
  $location?: string | undefined;
4842
4842
  };
4843
4843
  } | undefined;
4844
4844
  assignedTo?: {
4845
4845
  type: "exact";
4846
4846
  term: string | {
4847
- $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
4847
+ $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "middlename" | "signature" | "avatar";
4848
4848
  $location?: string | undefined;
4849
4849
  };
4850
4850
  } | undefined;
4851
4851
  createdBy?: {
4852
4852
  type: "exact";
4853
4853
  term: string | {
4854
- $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
4854
+ $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "middlename" | "signature" | "avatar";
4855
4855
  $location?: string | undefined;
4856
4856
  };
4857
4857
  } | undefined;
@@ -4862,7 +4862,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
4862
4862
  updatedBy?: {
4863
4863
  type: "exact";
4864
4864
  term: string | {
4865
- $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
4865
+ $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "middlename" | "signature" | "avatar";
4866
4866
  $location?: string | undefined;
4867
4867
  };
4868
4868
  } | undefined;
@@ -4912,7 +4912,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
4912
4912
  'legalStatuses.DECLARED.createdAtLocation'?: {
4913
4913
  type: "within";
4914
4914
  location: string | {
4915
- $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
4915
+ $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "middlename" | "signature" | "avatar";
4916
4916
  $location?: string | undefined;
4917
4917
  };
4918
4918
  } | undefined;
@@ -4934,7 +4934,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
4934
4934
  'legalStatuses.REGISTERED.createdAtLocation'?: {
4935
4935
  type: "within";
4936
4936
  location: string | {
4937
- $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
4937
+ $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "middlename" | "signature" | "avatar";
4938
4938
  $location?: string | undefined;
4939
4939
  };
4940
4940
  } | undefined;
@@ -4949,47 +4949,47 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
4949
4949
  createdAtLocation?: {
4950
4950
  type: "within";
4951
4951
  location: string | {
4952
- $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
4952
+ $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "middlename" | "signature" | "avatar";
4953
4953
  $location?: string | undefined;
4954
4954
  };
4955
4955
  } | {
4956
4956
  type: "exact";
4957
4957
  term: string | {
4958
- $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
4958
+ $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "middlename" | "signature" | "avatar";
4959
4959
  $location?: string | undefined;
4960
4960
  };
4961
4961
  } | undefined;
4962
4962
  updatedAtLocation?: {
4963
4963
  type: "within";
4964
4964
  location: string | {
4965
- $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
4965
+ $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "middlename" | "signature" | "avatar";
4966
4966
  $location?: string | undefined;
4967
4967
  };
4968
4968
  } | {
4969
4969
  type: "exact";
4970
4970
  term: string | {
4971
- $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
4971
+ $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "middlename" | "signature" | "avatar";
4972
4972
  $location?: string | undefined;
4973
4973
  };
4974
4974
  } | undefined;
4975
4975
  updatedByUserRole?: {
4976
4976
  type: "exact";
4977
4977
  term: string | {
4978
- $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
4978
+ $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "middlename" | "signature" | "avatar";
4979
4979
  $location?: string | undefined;
4980
4980
  };
4981
4981
  } | undefined;
4982
4982
  assignedTo?: {
4983
4983
  type: "exact";
4984
4984
  term: string | {
4985
- $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
4985
+ $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "middlename" | "signature" | "avatar";
4986
4986
  $location?: string | undefined;
4987
4987
  };
4988
4988
  } | undefined;
4989
4989
  createdBy?: {
4990
4990
  type: "exact";
4991
4991
  term: string | {
4992
- $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
4992
+ $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "middlename" | "signature" | "avatar";
4993
4993
  $location?: string | undefined;
4994
4994
  };
4995
4995
  } | undefined;
@@ -5000,7 +5000,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
5000
5000
  updatedBy?: {
5001
5001
  type: "exact";
5002
5002
  term: string | {
5003
- $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "middlename" | "signature" | "avatar" | "primaryOfficeId";
5003
+ $userField: "id" | "name" | "administrativeAreaId" | "firstname" | "surname" | "fullHonorificName" | "role" | "device" | "primaryOfficeId" | "middlename" | "signature" | "avatar";
5004
5004
  $location?: string | undefined;
5005
5005
  };
5006
5006
  } | undefined;
@@ -86,16 +86,16 @@ export declare const user: typeof userSerializer & {
86
86
  };
87
87
  scope: (scope: import("../scopes").ScopeType) => {
88
88
  attribute: (option: import("../scopes").ScopeOptionKey) => {
89
- $scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "workqueue" | "dashboard.view";
89
+ $scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "user.search" | "workqueue" | "dashboard.view";
90
90
  $option: "role" | "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
91
91
  };
92
92
  };
93
93
  jurisdiction: (jurisdiction: import("../scopes").JurisdictionFilter | {
94
- $scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "workqueue" | "dashboard.view";
94
+ $scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "user.search" | "workqueue" | "dashboard.view";
95
95
  $option: "role" | "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
96
96
  }) => {
97
97
  $jurisdiction: "administrativeArea" | "location" | "all" | {
98
- $scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "workqueue" | "dashboard.view";
98
+ $scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "user.search" | "workqueue" | "dashboard.view";
99
99
  $option: "role" | "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
100
100
  };
101
101
  };
@@ -1723,6 +1723,7 @@ declare const AdministrativeAreaField: z.ZodObject<{
1723
1723
  "user.read": "user.read";
1724
1724
  "user.create": "user.create";
1725
1725
  "user.edit": "user.edit";
1726
+ "user.search": "user.search";
1726
1727
  workqueue: "workqueue";
1727
1728
  "dashboard.view": "dashboard.view";
1728
1729
  }>;
@@ -1842,6 +1843,7 @@ declare const LocationInput: z.ZodObject<{
1842
1843
  "user.read": "user.read";
1843
1844
  "user.create": "user.create";
1844
1845
  "user.edit": "user.edit";
1846
+ "user.search": "user.search";
1845
1847
  workqueue: "workqueue";
1846
1848
  "dashboard.view": "dashboard.view";
1847
1849
  }>;
@@ -2026,6 +2028,7 @@ declare const Facility: z.ZodObject<{
2026
2028
  "user.read": "user.read";
2027
2029
  "user.create": "user.create";
2028
2030
  "user.edit": "user.edit";
2031
+ "user.search": "user.search";
2029
2032
  workqueue: "workqueue";
2030
2033
  "dashboard.view": "dashboard.view";
2031
2034
  }>;
@@ -2131,6 +2134,7 @@ declare const Office: z.ZodObject<{
2131
2134
  "user.read": "user.read";
2132
2135
  "user.create": "user.create";
2133
2136
  "user.edit": "user.edit";
2137
+ "user.search": "user.search";
2134
2138
  workqueue: "workqueue";
2135
2139
  "dashboard.view": "dashboard.view";
2136
2140
  }>;
@@ -2323,6 +2327,7 @@ declare const Address: z.ZodObject<{
2323
2327
  "user.read": "user.read";
2324
2328
  "user.create": "user.create";
2325
2329
  "user.edit": "user.edit";
2330
+ "user.search": "user.search";
2326
2331
  workqueue: "workqueue";
2327
2332
  "dashboard.view": "dashboard.view";
2328
2333
  }>;
@@ -73,5 +73,26 @@ export declare function canAccessOtherUserWithScopes({ scopes, userToAccess, use
73
73
  * One of the scopes must allow access for the event to be accessible.
74
74
  */
75
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[];
76
97
  export {};
77
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
@@ -298,12 +298,14 @@ var SystemScopeType = z6.enum([
298
298
  "organisation.read-locations",
299
299
  "user.read",
300
300
  "user.create",
301
- "user.edit"
301
+ "user.edit",
302
+ "user.search"
302
303
  ]);
303
304
  var UserScopeType = SystemScopeType.extract([
304
305
  "user.read",
305
306
  "user.create",
306
- "user.edit"
307
+ "user.edit",
308
+ "user.search"
307
309
  ]);
308
310
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
309
311
  var UserScopeV2 = z6.discriminatedUnion("type", [
@@ -312,7 +314,7 @@ var UserScopeV2 = z6.discriminatedUnion("type", [
312
314
  options: AllUserScopeOptions.optional()
313
315
  }),
314
316
  z6.object({
315
- type: UserScopeType.extract(["user.read"]),
317
+ type: UserScopeType.extract(["user.read", "user.search"]),
316
318
  options: AccessLevelOptions.optional()
317
319
  })
318
320
  ]);
@@ -302,12 +302,14 @@ __export(events_exports, {
302
302
  getActionConfig: () => getActionConfig,
303
303
  getActionReview: () => getActionReview,
304
304
  getActionReviewFields: () => getActionReviewFields,
305
+ getAdministrativeAreaHierarchy: () => getAdministrativeAreaHierarchy,
305
306
  getAllUniqueFields: () => getAllUniqueFields,
306
307
  getAnnotationFromDrafts: () => getAnnotationFromDrafts,
307
308
  getAssignedUserFromActions: () => getAssignedUserFromActions,
308
309
  getAssignedUserSignatureFromActions: () => getAssignedUserSignatureFromActions,
309
310
  getAssignmentStatus: () => getAssignmentStatus,
310
311
  getAvailableActionsForEvent: () => getAvailableActionsForEvent,
312
+ getAvailableRolesForUserUpdatePayload: () => getAvailableRolesForUserUpdatePayload,
311
313
  getCompleteActionAnnotation: () => getCompleteActionAnnotation,
312
314
  getCompleteActionDeclaration: () => getCompleteActionDeclaration,
313
315
  getCurrentEventState: () => getCurrentEventState,
@@ -318,6 +320,7 @@ __export(events_exports, {
318
320
  getDeclarationPages: () => getDeclarationPages,
319
321
  getEventConfigById: () => getEventConfigById,
320
322
  getFilePathsFromEvent: () => getFilePathsFromEvent,
323
+ getLocationHierarchy: () => getLocationHierarchy,
321
324
  getMixedPath: () => getMixedPath,
322
325
  getPendingAction: () => getPendingAction,
323
326
  getPrintCertificatePages: () => getPrintCertificatePages,
@@ -607,12 +610,14 @@ var SystemScopeType = z2.enum([
607
610
  "organisation.read-locations",
608
611
  "user.read",
609
612
  "user.create",
610
- "user.edit"
613
+ "user.edit",
614
+ "user.search"
611
615
  ]);
612
616
  var UserScopeType = SystemScopeType.extract([
613
617
  "user.read",
614
618
  "user.create",
615
- "user.edit"
619
+ "user.edit",
620
+ "user.search"
616
621
  ]);
617
622
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
618
623
  var UserScopeV2 = z2.discriminatedUnion("type", [
@@ -621,7 +626,7 @@ var UserScopeV2 = z2.discriminatedUnion("type", [
621
626
  options: AllUserScopeOptions.optional()
622
627
  }),
623
628
  z2.object({
624
- type: UserScopeType.extract(["user.read"]),
629
+ type: UserScopeType.extract(["user.read", "user.search"]),
625
630
  options: AccessLevelOptions.optional()
626
631
  })
627
632
  ]);
@@ -10001,6 +10006,39 @@ function userCanAccessEventWithScopes(event2, scopes, user2, customActionType) {
10001
10006
  (scope) => canAccessEventWithScope(event2, scope, user2, customActionType)
10002
10007
  );
10003
10008
  }
10009
+ function getAdministrativeAreaHierarchy(administrativeAreaId, administrativeAreas) {
10010
+ const collectedLocations = [];
10011
+ const parsedAdministrativeAreaId = administrativeAreaId && UUID.safeParse(administrativeAreaId).data;
10012
+ let current = parsedAdministrativeAreaId ? administrativeAreas.get(parsedAdministrativeAreaId) : null;
10013
+ while (current) {
10014
+ collectedLocations.push(current);
10015
+ if (!current.parentId) {
10016
+ break;
10017
+ }
10018
+ const parentId = current.parentId;
10019
+ current = administrativeAreas.get(parentId);
10020
+ }
10021
+ return collectedLocations;
10022
+ }
10023
+ function getLocationHierarchy(selectedId, context) {
10024
+ const { administrativeAreas, locations } = context;
10025
+ const loc = locations.get(selectedId);
10026
+ if (loc) {
10027
+ if (loc.administrativeAreaId) {
10028
+ const hierarchy2 = getAdministrativeAreaHierarchy(
10029
+ loc.administrativeAreaId,
10030
+ administrativeAreas
10031
+ );
10032
+ return [...hierarchy2.reverse().map((area) => area.id), loc.id];
10033
+ }
10034
+ return [loc.id];
10035
+ }
10036
+ const hierarchy = getAdministrativeAreaHierarchy(
10037
+ selectedId,
10038
+ administrativeAreas
10039
+ );
10040
+ return hierarchy.reverse().map((area) => area.id);
10041
+ }
10004
10042
 
10005
10043
  // ../commons/src/events/scopes.ts
10006
10044
  var ACTION_SCOPE_MAP = {
@@ -10075,6 +10113,25 @@ function isActionInScope({
10075
10113
  );
10076
10114
  return canAccess;
10077
10115
  }
10116
+ function getAvailableRolesForUserUpdatePayload({
10117
+ allRoles,
10118
+ userLocation,
10119
+ acceptedScopes,
10120
+ userRequesting
10121
+ }) {
10122
+ const availableRoles = allRoles.filter((role) => {
10123
+ const canAccess = canAccessOtherUserWithScopes({
10124
+ userToAccess: {
10125
+ ...userLocation,
10126
+ role
10127
+ },
10128
+ user: userRequesting,
10129
+ scopes: acceptedScopes
10130
+ });
10131
+ return canAccess;
10132
+ });
10133
+ return availableRoles;
10134
+ }
10078
10135
 
10079
10136
  // ../commons/src/events/serializers/user/deserializer.ts
10080
10137
  function userDeserializer(serializedUserField, user2) {
@@ -2308,12 +2308,14 @@ var SystemScopeType = z3.enum([
2308
2308
  "organisation.read-locations",
2309
2309
  "user.read",
2310
2310
  "user.create",
2311
- "user.edit"
2311
+ "user.edit",
2312
+ "user.search"
2312
2313
  ]);
2313
2314
  var UserScopeType = SystemScopeType.extract([
2314
2315
  "user.read",
2315
2316
  "user.create",
2316
- "user.edit"
2317
+ "user.edit",
2318
+ "user.search"
2317
2319
  ]);
2318
2320
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
2319
2321
  var UserScopeV2 = z3.discriminatedUnion("type", [
@@ -2322,7 +2324,7 @@ var UserScopeV2 = z3.discriminatedUnion("type", [
2322
2324
  options: AllUserScopeOptions.optional()
2323
2325
  }),
2324
2326
  z3.object({
2325
- type: UserScopeType.extract(["user.read"]),
2327
+ type: UserScopeType.extract(["user.read", "user.search"]),
2326
2328
  options: AccessLevelOptions.optional()
2327
2329
  })
2328
2330
  ]);
@@ -226,12 +226,14 @@ var SystemScopeType = z2.enum([
226
226
  "organisation.read-locations",
227
227
  "user.read",
228
228
  "user.create",
229
- "user.edit"
229
+ "user.edit",
230
+ "user.search"
230
231
  ]);
231
232
  var UserScopeType = SystemScopeType.extract([
232
233
  "user.read",
233
234
  "user.create",
234
- "user.edit"
235
+ "user.edit",
236
+ "user.search"
235
237
  ]);
236
238
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
237
239
  var UserScopeV2 = z2.discriminatedUnion("type", [
@@ -240,7 +242,7 @@ var UserScopeV2 = z2.discriminatedUnion("type", [
240
242
  options: AllUserScopeOptions.optional()
241
243
  }),
242
244
  z2.object({
243
- type: UserScopeType.extract(["user.read"]),
245
+ type: UserScopeType.extract(["user.read", "user.search"]),
244
246
  options: AccessLevelOptions.optional()
245
247
  })
246
248
  ]);
@@ -227,12 +227,14 @@ declare const SystemScopeType: z.ZodEnum<{
227
227
  "user.read": "user.read";
228
228
  "user.create": "user.create";
229
229
  "user.edit": "user.edit";
230
+ "user.search": "user.search";
230
231
  }>;
231
232
  export type SystemScopeType = z.infer<typeof SystemScopeType>;
232
233
  declare const UserScopeType: z.ZodEnum<{
233
234
  "user.read": "user.read";
234
235
  "user.create": "user.create";
235
236
  "user.edit": "user.edit";
237
+ "user.search": "user.search";
236
238
  }>;
237
239
  export type UserScopeType = z.infer<typeof UserScopeType>;
238
240
  declare const ScopesWithRoleOption: z.ZodEnum<{
@@ -256,6 +258,7 @@ export declare const UserScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
256
258
  }, z.core.$strip>, z.ZodObject<{
257
259
  type: z.ZodEnum<{
258
260
  "user.read": "user.read";
261
+ "user.search": "user.search";
259
262
  }>;
260
263
  options: z.ZodOptional<z.ZodObject<{
261
264
  accessLevel: z.ZodOptional<z.ZodEnum<{
@@ -493,6 +496,7 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
493
496
  }, z.core.$strip>, z.ZodObject<{
494
497
  type: z.ZodEnum<{
495
498
  "user.read": "user.read";
499
+ "user.search": "user.search";
496
500
  }>;
497
501
  options: z.ZodOptional<z.ZodObject<{
498
502
  accessLevel: z.ZodOptional<z.ZodEnum<{
@@ -556,6 +560,7 @@ export declare const ScopeType: z.ZodEnum<{
556
560
  "user.read": "user.read";
557
561
  "user.create": "user.create";
558
562
  "user.edit": "user.edit";
563
+ "user.search": "user.search";
559
564
  workqueue: "workqueue";
560
565
  "dashboard.view": "dashboard.view";
561
566
  }>;
@@ -635,7 +640,7 @@ export declare const decodeScope: (query: EncodedScope) => {
635
640
  role?: string[] | undefined;
636
641
  } | undefined;
637
642
  } | {
638
- type: "user.read";
643
+ type: "user.read" | "user.search";
639
644
  options?: {
640
645
  accessLevel?: "administrativeArea" | "location" | "all" | undefined;
641
646
  } | undefined;
@@ -257,12 +257,14 @@ var SystemScopeType = z3.enum([
257
257
  "organisation.read-locations",
258
258
  "user.read",
259
259
  "user.create",
260
- "user.edit"
260
+ "user.edit",
261
+ "user.search"
261
262
  ]);
262
263
  var UserScopeType = SystemScopeType.extract([
263
264
  "user.read",
264
265
  "user.create",
265
- "user.edit"
266
+ "user.edit",
267
+ "user.search"
266
268
  ]);
267
269
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
268
270
  var UserScopeV2 = z3.discriminatedUnion("type", [
@@ -271,7 +273,7 @@ var UserScopeV2 = z3.discriminatedUnion("type", [
271
273
  options: AllUserScopeOptions.optional()
272
274
  }),
273
275
  z3.object({
274
- type: UserScopeType.extract(["user.read"]),
276
+ type: UserScopeType.extract(["user.read", "user.search"]),
275
277
  options: AccessLevelOptions.optional()
276
278
  })
277
279
  ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/toolkit",
3
- "version": "2.0.0-rc.edee239",
3
+ "version": "2.0.0-rc.f1925c7",
4
4
  "description": "OpenCRVS toolkit for building country configurations",
5
5
  "license": "MPL-2.0",
6
6
  "bin": {