@opencrvs/toolkit 2.0.0-rc.d37719f → 2.0.0-rc.d451982

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.
Files changed (32) hide show
  1. package/create-countryconfig/index.js +73 -0
  2. package/create-countryconfig/package.json +11 -0
  3. package/dist/application-config/index.js +5 -3
  4. package/dist/cli.js +192 -96
  5. package/dist/commons/api/router.d.ts +20 -20
  6. package/dist/commons/conditionals/conditionals.d.ts +3 -3
  7. package/dist/commons/events/FieldConfig.d.ts +5 -0
  8. package/dist/commons/events/locations.d.ts +21 -0
  9. package/dist/commons/events/mocks.test.utils.d.ts +19 -0
  10. package/dist/commons/events/scopes.d.ts +24 -1
  11. package/dist/conditionals/index.js +5 -3
  12. package/dist/events/index.js +60 -3
  13. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +1 -1
  14. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  15. package/dist/migrations/v2.0/checkout-upstream-files.js +1 -2
  16. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +9 -1
  17. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -1
  18. package/dist/migrations/v2.0/delete-infrastructure-directory.js +66 -20
  19. package/dist/migrations/v2.0/index.d.ts +5 -3
  20. package/dist/migrations/v2.0/index.d.ts.map +1 -1
  21. package/dist/migrations/v2.0/index.js +192 -96
  22. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +11 -1
  23. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -1
  24. package/dist/migrations/v2.0/merge-infrastructure-directory.js +17 -16
  25. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
  26. package/dist/migrations/v2.0/migrate-workqueue-configs.js +140 -59
  27. package/dist/notification/index.js +5 -3
  28. package/dist/scopes/index.d.ts +6 -1
  29. package/dist/scopes/index.js +5 -3
  30. package/opencrvs-toolkit-2.0.0-rc.d451982.tgz +0 -0
  31. package/package.json +1 -1
  32. package/opencrvs-toolkit-2.0.0-rc.d37719f.tgz +0 -0
@@ -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) {
@@ -1,5 +1,5 @@
1
1
  export declare const UPSTREAM_URL = "https://github.com/opencrvs/opencrvs-countryconfig.git";
2
- export declare const UPSTREAM_BRANCH = "develop";
2
+ export declare const UPSTREAM_BRANCH = "release-v2.0.0";
3
3
  /**
4
4
  * Runs a git command in the country config working directory.
5
5
  *
@@ -1 +1 @@
1
- {"version":3,"file":"checkout-upstream-files.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/checkout-upstream-files.ts"],"names":[],"mappings":"AA8CA,eAAO,MAAM,YAAY,2DACiC,CAAA;AAG1D,eAAO,MAAM,eAAe,YAAY,CAAA;AAcxC;;;;;;GAMG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,MAAc,EAAE,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAC5C,MAAM,CAMR;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAO9C;AAED,wBAAgB,eAAe,IAAI,IAAI,CAMtC;AAID,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAuDnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"checkout-upstream-files.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/checkout-upstream-files.ts"],"names":[],"mappings":"AA8CA,eAAO,MAAM,YAAY,2DACiC,CAAA;AAE1D,eAAO,MAAM,eAAe,mBAAmB,CAAA;AAc/C;;;;;;GAMG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,MAAc,EAAE,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAC5C,MAAM,CAMR;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAO9C;AAED,wBAAgB,eAAe,IAAI,IAAI,CAMtC;AAID,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAuDnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -59,8 +59,7 @@ exports.main = main;
59
59
  */
60
60
  const child_process_1 = require("child_process");
61
61
  exports.UPSTREAM_URL = 'https://github.com/opencrvs/opencrvs-countryconfig.git';
62
- // @TODO: This needs to be changed to 'release-v2.0.0' once the branch is created
63
- exports.UPSTREAM_BRANCH = 'develop';
62
+ exports.UPSTREAM_BRANCH = 'release-v2.0.0';
64
63
  // Remote name used only for the duration of this codemod. Prefixed to avoid
65
64
  // clashing with remotes the user may have (origin, upstream, etc.).
66
65
  const TEMP_REMOTE = 'opencrvs-upgrade-v19-v20-codemod';
@@ -1,3 +1,11 @@
1
- declare function main(): Promise<void>;
1
+ interface DeleteInfrastructureOptions {
2
+ /**
3
+ * Top-level entries directly under `infrastructure/` to preserve. Names
4
+ * match against the basename of each entry (file or directory). When
5
+ * empty (the default), the whole `infrastructure/` directory is deleted.
6
+ */
7
+ keep?: string[];
8
+ }
9
+ declare function main({ keep }?: DeleteInfrastructureOptions): Promise<void>;
2
10
  export { main };
3
11
  //# sourceMappingURL=delete-infrastructure-directory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"delete-infrastructure-directory.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/delete-infrastructure-directory.ts"],"names":[],"mappings":"AA4CA,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAgCnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"delete-infrastructure-directory.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/delete-infrastructure-directory.ts"],"names":[],"mappings":"AAoDA,UAAU,2BAA2B;IACnC;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB;AAED,iBAAe,IAAI,CAAC,EAClB,IAAS,EACV,GAAE,2BAAgC,GAAG,OAAO,CAAC,IAAI,CAAC,CA4FlD;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}