@opencrvs/toolkit 2.0.0-rc.bee2b7b → 2.0.0-rc.c4ed9c8

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.
@@ -656,10 +656,6 @@ var scopeByEvent = z11.preprocess(
656
656
  (val) => val === void 0 ? void 0 : [val].flat(),
657
657
  z11.array(z11.string()).optional()
658
658
  ).describe("Event type, e.g. birth, death");
659
- var userRole = z11.preprocess(
660
- (val) => val === void 0 ? void 0 : [val].flat(),
661
- z11.array(z11.string()).optional()
662
- ).describe("User role, e.g. admin, field agent");
663
659
  var scopeOptionsPlaceEvent = z11.object({
664
660
  event: scopeByEvent,
665
661
  placeOfEvent: JurisdictionFilter.optional()
@@ -764,33 +760,6 @@ var RecordScopeV2 = z11.discriminatedUnion("type", [
764
760
  ]).describe(
765
761
  "Scopes used to check user's permission to perform actions on a record."
766
762
  );
767
- var SystemScopeType = z11.enum([
768
- "organisation.read-locations",
769
- "user.read",
770
- "user.create",
771
- "user.edit"
772
- ]);
773
- var UserScopeType = SystemScopeType.extract([
774
- "user.read",
775
- "user.create",
776
- "user.edit"
777
- ]);
778
- var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
779
- var UserScopeV2 = z11.discriminatedUnion("type", [
780
- z11.object({
781
- type: ScopesWithRoleOption,
782
- options: z11.object({
783
- accessLevel: JurisdictionFilter.optional(),
784
- role: userRole.optional()
785
- }).optional()
786
- }),
787
- z11.object({
788
- type: UserScopeType.extract(["user.read"]),
789
- options: z11.object({
790
- accessLevel: JurisdictionFilter.optional()
791
- }).optional()
792
- })
793
- ]);
794
763
  var ResolvedRecordScopeV2 = z11.discriminatedUnion("type", [
795
764
  z11.object({
796
765
  type: ScopesWithPlaceEventOptions,
@@ -811,14 +780,16 @@ var ResolvedRecordScopeV2 = z11.discriminatedUnion("type", [
811
780
  }).optional()
812
781
  })
813
782
  ]).describe("Resolved scope with location/user IDs instead of filters.");
783
+ var SystemScopeType = z11.enum([
784
+ "organisation.read-locations",
785
+ "user.read",
786
+ "user.create",
787
+ "user.edit"
788
+ ]);
814
789
  var Scope = z11.discriminatedUnion("type", [
815
790
  z11.object({ type: PlainScopeType }),
816
791
  ...RecordScopeV2.options,
817
- ...UserScopeV2.options,
818
- z11.object({
819
- type: z11.literal("organisation.read-locations"),
820
- options: AccessLevelOptions.optional()
821
- }),
792
+ z11.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
822
793
  z11.object({
823
794
  type: z11.literal("workqueue"),
824
795
  options: WorkqueueOrDashboardOptions
package/dist/cli.js CHANGED
@@ -2110,10 +2110,6 @@ var scopeByEvent = z3.preprocess(
2110
2110
  (val) => val === void 0 ? void 0 : [val].flat(),
2111
2111
  z3.array(z3.string()).optional()
2112
2112
  ).describe("Event type, e.g. birth, death");
2113
- var userRole = z3.preprocess(
2114
- (val) => val === void 0 ? void 0 : [val].flat(),
2115
- z3.array(z3.string()).optional()
2116
- ).describe("User role, e.g. admin, field agent");
2117
2113
  var scopeOptionsPlaceEvent = z3.object({
2118
2114
  event: scopeByEvent,
2119
2115
  placeOfEvent: JurisdictionFilter.optional()
@@ -2218,33 +2214,6 @@ var RecordScopeV2 = z3.discriminatedUnion("type", [
2218
2214
  ]).describe(
2219
2215
  "Scopes used to check user's permission to perform actions on a record."
2220
2216
  );
2221
- var SystemScopeType = z3.enum([
2222
- "organisation.read-locations",
2223
- "user.read",
2224
- "user.create",
2225
- "user.edit"
2226
- ]);
2227
- var UserScopeType = SystemScopeType.extract([
2228
- "user.read",
2229
- "user.create",
2230
- "user.edit"
2231
- ]);
2232
- var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
2233
- var UserScopeV2 = z3.discriminatedUnion("type", [
2234
- z3.object({
2235
- type: ScopesWithRoleOption,
2236
- options: z3.object({
2237
- accessLevel: JurisdictionFilter.optional(),
2238
- role: userRole.optional()
2239
- }).optional()
2240
- }),
2241
- z3.object({
2242
- type: UserScopeType.extract(["user.read"]),
2243
- options: z3.object({
2244
- accessLevel: JurisdictionFilter.optional()
2245
- }).optional()
2246
- })
2247
- ]);
2248
2217
  var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
2249
2218
  z3.object({
2250
2219
  type: ScopesWithPlaceEventOptions,
@@ -2265,14 +2234,16 @@ var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
2265
2234
  }).optional()
2266
2235
  })
2267
2236
  ]).describe("Resolved scope with location/user IDs instead of filters.");
2237
+ var SystemScopeType = z3.enum([
2238
+ "organisation.read-locations",
2239
+ "user.read",
2240
+ "user.create",
2241
+ "user.edit"
2242
+ ]);
2268
2243
  var Scope2 = z3.discriminatedUnion("type", [
2269
2244
  z3.object({ type: PlainScopeType }),
2270
2245
  ...RecordScopeV2.options,
2271
- ...UserScopeV2.options,
2272
- z3.object({
2273
- type: z3.literal("organisation.read-locations"),
2274
- options: AccessLevelOptions.optional()
2275
- }),
2246
+ z3.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
2276
2247
  z3.object({
2277
2248
  type: z3.literal("workqueue"),
2278
2249
  options: WorkqueueOrDashboardOptions
@@ -4020,6 +4020,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
4020
4020
  email?: string | undefined;
4021
4021
  mobile?: string | undefined;
4022
4022
  username?: undefined;
4023
+ password?: undefined;
4023
4024
  signature?: {
4024
4025
  path: string;
4025
4026
  originalFilename: string;
@@ -4069,8 +4070,6 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
4069
4070
  type: string;
4070
4071
  } | undefined;
4071
4072
  status?: "active" | "deactivated" | undefined;
4072
- } & {
4073
- id: string;
4074
4073
  };
4075
4074
  output: {
4076
4075
  id: string & import("zod").$brand<"UUID">;
@@ -1,8 +1,7 @@
1
- import { UUID } from '../uuid';
2
1
  import * as z from 'zod/v4';
3
2
  import { EventIndex } from './EventIndex';
4
3
  import { ActionCreationMetadata, RegistrationCreationMetadata } from './EventMetadata';
5
- import { RecordScopeV2, UserScopeV2 } from '../scopes';
4
+ import { RecordScopeV2 } from '../scopes';
6
5
  import { SystemContext, UserContext } from '../users/User';
7
6
  /** @deprecated Moving on, location types are arbitrary and defined by the country config. */
8
7
  export declare const LocationTypeV1: z.ZodEnum<{
@@ -52,21 +51,6 @@ export type EventIndexWithAdministrativeHierarchy = Omit<ToArrayFields<EventInde
52
51
  *
53
52
  */
54
53
  export declare function canAccessEventWithScope(event: Partial<EventIndexWithAdministrativeHierarchy>, scope: RecordScopeV2, user: UserContext | SystemContext, customActionType?: string): boolean;
55
- export type UserWithResolvedHierarchy = {
56
- role: string;
57
- administrativeHierarchy: UUID[];
58
- primaryOfficeId: UUID;
59
- };
60
- export declare function canAccessUserWithScope({ userToAccess, scope, user }: {
61
- userToAccess: UserWithResolvedHierarchy;
62
- scope: UserScopeV2;
63
- user: UserContext | SystemContext;
64
- }): boolean;
65
- export declare function canAccessOtherUserWithScopes({ scopes, userToAccess, user }: {
66
- scopes: UserScopeV2[];
67
- userToAccess: UserWithResolvedHierarchy;
68
- user: UserContext | SystemContext;
69
- }): boolean;
70
54
  /**
71
55
  * Given indexed event and list of resolved scopes, determine if any of the scopes allow access to the event.
72
56
  *
@@ -182,10 +182,6 @@ var scopeByEvent = z6.preprocess(
182
182
  (val) => val === void 0 ? void 0 : [val].flat(),
183
183
  z6.array(z6.string()).optional()
184
184
  ).describe("Event type, e.g. birth, death");
185
- var userRole = z6.preprocess(
186
- (val) => val === void 0 ? void 0 : [val].flat(),
187
- z6.array(z6.string()).optional()
188
- ).describe("User role, e.g. admin, field agent");
189
185
  var scopeOptionsPlaceEvent = z6.object({
190
186
  event: scopeByEvent,
191
187
  placeOfEvent: JurisdictionFilter.optional()
@@ -290,33 +286,6 @@ var RecordScopeV2 = z6.discriminatedUnion("type", [
290
286
  ]).describe(
291
287
  "Scopes used to check user's permission to perform actions on a record."
292
288
  );
293
- var SystemScopeType = z6.enum([
294
- "organisation.read-locations",
295
- "user.read",
296
- "user.create",
297
- "user.edit"
298
- ]);
299
- var UserScopeType = SystemScopeType.extract([
300
- "user.read",
301
- "user.create",
302
- "user.edit"
303
- ]);
304
- var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
305
- var UserScopeV2 = z6.discriminatedUnion("type", [
306
- z6.object({
307
- type: ScopesWithRoleOption,
308
- options: z6.object({
309
- accessLevel: JurisdictionFilter.optional(),
310
- role: userRole.optional()
311
- }).optional()
312
- }),
313
- z6.object({
314
- type: UserScopeType.extract(["user.read"]),
315
- options: z6.object({
316
- accessLevel: JurisdictionFilter.optional()
317
- }).optional()
318
- })
319
- ]);
320
289
  var ResolvedRecordScopeV2 = z6.discriminatedUnion("type", [
321
290
  z6.object({
322
291
  type: ScopesWithPlaceEventOptions,
@@ -337,14 +306,16 @@ var ResolvedRecordScopeV2 = z6.discriminatedUnion("type", [
337
306
  }).optional()
338
307
  })
339
308
  ]).describe("Resolved scope with location/user IDs instead of filters.");
309
+ var SystemScopeType = z6.enum([
310
+ "organisation.read-locations",
311
+ "user.read",
312
+ "user.create",
313
+ "user.edit"
314
+ ]);
340
315
  var Scope2 = z6.discriminatedUnion("type", [
341
316
  z6.object({ type: PlainScopeType }),
342
317
  ...RecordScopeV2.options,
343
- ...UserScopeV2.options,
344
- z6.object({
345
- type: z6.literal("organisation.read-locations"),
346
- options: AccessLevelOptions.optional()
347
- }),
318
+ z6.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
348
319
  z6.object({
349
320
  type: z6.literal("workqueue"),
350
321
  options: WorkqueueOrDashboardOptions
@@ -243,8 +243,6 @@ __export(events_exports, {
243
243
  areConditionsMet: () => areConditionsMet,
244
244
  buildFormState: () => buildFormState,
245
245
  canAccessEventWithScope: () => canAccessEventWithScope,
246
- canAccessOtherUserWithScopes: () => canAccessOtherUserWithScopes,
247
- canAccessUserWithScope: () => canAccessUserWithScope,
248
246
  compositeFieldTypes: () => compositeFieldTypes,
249
247
  createEmptyDraft: () => createEmptyDraft,
250
248
  createFieldConditionals: () => createFieldConditionals,
@@ -491,10 +489,6 @@ var scopeByEvent = z2.preprocess(
491
489
  (val) => val === void 0 ? void 0 : [val].flat(),
492
490
  z2.array(z2.string()).optional()
493
491
  ).describe("Event type, e.g. birth, death");
494
- var userRole = z2.preprocess(
495
- (val) => val === void 0 ? void 0 : [val].flat(),
496
- z2.array(z2.string()).optional()
497
- ).describe("User role, e.g. admin, field agent");
498
492
  var scopeOptionsPlaceEvent = z2.object({
499
493
  event: scopeByEvent,
500
494
  placeOfEvent: JurisdictionFilter.optional()
@@ -599,36 +593,6 @@ var RecordScopeV2 = z2.discriminatedUnion("type", [
599
593
  ]).describe(
600
594
  "Scopes used to check user's permission to perform actions on a record."
601
595
  );
602
- var SystemScopeType = z2.enum([
603
- "organisation.read-locations",
604
- "user.read",
605
- "user.create",
606
- "user.edit"
607
- ]);
608
- var UserScopeType = SystemScopeType.extract([
609
- "user.read",
610
- "user.create",
611
- "user.edit"
612
- ]);
613
- var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
614
- var UserScopeV2 = z2.discriminatedUnion("type", [
615
- z2.object({
616
- type: ScopesWithRoleOption,
617
- options: z2.object({
618
- accessLevel: JurisdictionFilter.optional(),
619
- role: userRole.optional()
620
- }).optional()
621
- }),
622
- z2.object({
623
- type: UserScopeType.extract(["user.read"]),
624
- options: z2.object({
625
- accessLevel: JurisdictionFilter.optional()
626
- }).optional()
627
- })
628
- ]);
629
- function scopeUsesRoleOptions(scope) {
630
- return ScopesWithRoleOption?.options.some((opt) => opt === scope.type);
631
- }
632
596
  function scopeUsesDeclaredOptions(scope) {
633
597
  return !ScopesWithPlaceEventOptions.options.some((opt) => opt === scope.type);
634
598
  }
@@ -661,14 +625,16 @@ var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
661
625
  }).optional()
662
626
  })
663
627
  ]).describe("Resolved scope with location/user IDs instead of filters.");
628
+ var SystemScopeType = z2.enum([
629
+ "organisation.read-locations",
630
+ "user.read",
631
+ "user.create",
632
+ "user.edit"
633
+ ]);
664
634
  var Scope = z2.discriminatedUnion("type", [
665
635
  z2.object({ type: PlainScopeType }),
666
636
  ...RecordScopeV2.options,
667
- ...UserScopeV2.options,
668
- z2.object({
669
- type: z2.literal("organisation.read-locations"),
670
- options: AccessLevelOptions.optional()
671
- }),
637
+ z2.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
672
638
  z2.object({
673
639
  type: z2.literal("workqueue"),
674
640
  options: WorkqueueOrDashboardOptions
@@ -9964,39 +9930,6 @@ function canAccessEventWithScope(event2, scope, user2, customActionType) {
9964
9930
  }
9965
9931
  return true;
9966
9932
  }
9967
- function canAccessUserWithScope({
9968
- userToAccess,
9969
- scope,
9970
- user: user2
9971
- }) {
9972
- const opts = scope.options;
9973
- const hasSameOffice = user2.primaryOfficeId === userToAccess.primaryOfficeId;
9974
- if (opts?.accessLevel === JurisdictionFilter.enum.location && !hasSameOffice) {
9975
- return false;
9976
- }
9977
- const hasAdministrativeAreaInHierarchy = userToAccess.administrativeHierarchy.some(
9978
- (id) => user2.administrativeAreaId === id
9979
- ) || user2.administrativeAreaId === null;
9980
- if (opts?.accessLevel === JurisdictionFilter.enum.administrativeArea && !hasAdministrativeAreaInHierarchy) {
9981
- return false;
9982
- }
9983
- if (scopeUsesRoleOptions(scope)) {
9984
- const { options } = scope;
9985
- if (options?.role && !options.role.includes(userToAccess.role)) {
9986
- return false;
9987
- }
9988
- }
9989
- return true;
9990
- }
9991
- function canAccessOtherUserWithScopes({
9992
- scopes,
9993
- userToAccess,
9994
- user: user2
9995
- }) {
9996
- return scopes.some(
9997
- (scope) => canAccessUserWithScope({ userToAccess, scope, user: user2 })
9998
- );
9999
- }
10000
9933
  function userCanAccessEventWithScopes(event2, scopes, user2, customActionType) {
10001
9934
  return scopes.some(
10002
9935
  (scope) => canAccessEventWithScope(event2, scope, user2, customActionType)
@@ -2123,10 +2123,6 @@ var scopeByEvent = z3.preprocess(
2123
2123
  (val) => val === void 0 ? void 0 : [val].flat(),
2124
2124
  z3.array(z3.string()).optional()
2125
2125
  ).describe("Event type, e.g. birth, death");
2126
- var userRole = z3.preprocess(
2127
- (val) => val === void 0 ? void 0 : [val].flat(),
2128
- z3.array(z3.string()).optional()
2129
- ).describe("User role, e.g. admin, field agent");
2130
2126
  var scopeOptionsPlaceEvent = z3.object({
2131
2127
  event: scopeByEvent,
2132
2128
  placeOfEvent: JurisdictionFilter.optional()
@@ -2231,33 +2227,6 @@ var RecordScopeV2 = z3.discriminatedUnion("type", [
2231
2227
  ]).describe(
2232
2228
  "Scopes used to check user's permission to perform actions on a record."
2233
2229
  );
2234
- var SystemScopeType = z3.enum([
2235
- "organisation.read-locations",
2236
- "user.read",
2237
- "user.create",
2238
- "user.edit"
2239
- ]);
2240
- var UserScopeType = SystemScopeType.extract([
2241
- "user.read",
2242
- "user.create",
2243
- "user.edit"
2244
- ]);
2245
- var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
2246
- var UserScopeV2 = z3.discriminatedUnion("type", [
2247
- z3.object({
2248
- type: ScopesWithRoleOption,
2249
- options: z3.object({
2250
- accessLevel: JurisdictionFilter.optional(),
2251
- role: userRole.optional()
2252
- }).optional()
2253
- }),
2254
- z3.object({
2255
- type: UserScopeType.extract(["user.read"]),
2256
- options: z3.object({
2257
- accessLevel: JurisdictionFilter.optional()
2258
- }).optional()
2259
- })
2260
- ]);
2261
2230
  var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
2262
2231
  z3.object({
2263
2232
  type: ScopesWithPlaceEventOptions,
@@ -2278,14 +2247,16 @@ var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
2278
2247
  }).optional()
2279
2248
  })
2280
2249
  ]).describe("Resolved scope with location/user IDs instead of filters.");
2250
+ var SystemScopeType = z3.enum([
2251
+ "organisation.read-locations",
2252
+ "user.read",
2253
+ "user.create",
2254
+ "user.edit"
2255
+ ]);
2281
2256
  var Scope2 = z3.discriminatedUnion("type", [
2282
2257
  z3.object({ type: PlainScopeType }),
2283
2258
  ...RecordScopeV2.options,
2284
- ...UserScopeV2.options,
2285
- z3.object({
2286
- type: z3.literal("organisation.read-locations"),
2287
- options: AccessLevelOptions.optional()
2288
- }),
2259
+ z3.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
2289
2260
  z3.object({
2290
2261
  type: z3.literal("workqueue"),
2291
2262
  options: WorkqueueOrDashboardOptions
@@ -110,10 +110,6 @@ var scopeByEvent = z2.preprocess(
110
110
  (val) => val === void 0 ? void 0 : [val].flat(),
111
111
  z2.array(z2.string()).optional()
112
112
  ).describe("Event type, e.g. birth, death");
113
- var userRole = z2.preprocess(
114
- (val) => val === void 0 ? void 0 : [val].flat(),
115
- z2.array(z2.string()).optional()
116
- ).describe("User role, e.g. admin, field agent");
117
113
  var scopeOptionsPlaceEvent = z2.object({
118
114
  event: scopeByEvent,
119
115
  placeOfEvent: JurisdictionFilter.optional()
@@ -218,33 +214,6 @@ var RecordScopeV2 = z2.discriminatedUnion("type", [
218
214
  ]).describe(
219
215
  "Scopes used to check user's permission to perform actions on a record."
220
216
  );
221
- var SystemScopeType = z2.enum([
222
- "organisation.read-locations",
223
- "user.read",
224
- "user.create",
225
- "user.edit"
226
- ]);
227
- var UserScopeType = SystemScopeType.extract([
228
- "user.read",
229
- "user.create",
230
- "user.edit"
231
- ]);
232
- var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
233
- var UserScopeV2 = z2.discriminatedUnion("type", [
234
- z2.object({
235
- type: ScopesWithRoleOption,
236
- options: z2.object({
237
- accessLevel: JurisdictionFilter.optional(),
238
- role: userRole.optional()
239
- }).optional()
240
- }),
241
- z2.object({
242
- type: UserScopeType.extract(["user.read"]),
243
- options: z2.object({
244
- accessLevel: JurisdictionFilter.optional()
245
- }).optional()
246
- })
247
- ]);
248
217
  var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
249
218
  z2.object({
250
219
  type: ScopesWithPlaceEventOptions,
@@ -265,14 +234,16 @@ var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
265
234
  }).optional()
266
235
  })
267
236
  ]).describe("Resolved scope with location/user IDs instead of filters.");
237
+ var SystemScopeType = z2.enum([
238
+ "organisation.read-locations",
239
+ "user.read",
240
+ "user.create",
241
+ "user.edit"
242
+ ]);
268
243
  var Scope = z2.discriminatedUnion("type", [
269
244
  z2.object({ type: PlainScopeType }),
270
245
  ...RecordScopeV2.options,
271
- ...UserScopeV2.options,
272
- z2.object({
273
- type: z2.literal("organisation.read-locations"),
274
- options: AccessLevelOptions.optional()
275
- }),
246
+ z2.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
276
247
  z2.object({
277
248
  type: z2.literal("workqueue"),
278
249
  options: WorkqueueOrDashboardOptions
@@ -220,53 +220,6 @@ export declare const RecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
220
220
  templates: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
221
221
  }, z.core.$strip>>;
222
222
  }, z.core.$strip>], "type">;
223
- declare const SystemScopeType: z.ZodEnum<{
224
- "organisation.read-locations": "organisation.read-locations";
225
- "user.read": "user.read";
226
- "user.create": "user.create";
227
- "user.edit": "user.edit";
228
- }>;
229
- export type SystemScopeType = z.infer<typeof SystemScopeType>;
230
- declare const UserScopeType: z.ZodEnum<{
231
- "user.read": "user.read";
232
- "user.create": "user.create";
233
- "user.edit": "user.edit";
234
- }>;
235
- export type UserScopeType = z.infer<typeof UserScopeType>;
236
- declare const ScopesWithRoleOption: z.ZodEnum<{
237
- "user.create": "user.create";
238
- "user.edit": "user.edit";
239
- }>;
240
- export type ScopesWithRoleOption = z.infer<typeof ScopesWithRoleOption>;
241
- export declare const UserScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
242
- type: z.ZodEnum<{
243
- "user.create": "user.create";
244
- "user.edit": "user.edit";
245
- }>;
246
- options: z.ZodOptional<z.ZodObject<{
247
- accessLevel: z.ZodOptional<z.ZodEnum<{
248
- administrativeArea: "administrativeArea";
249
- location: "location";
250
- all: "all";
251
- }>>;
252
- role: z.ZodOptional<z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>>;
253
- }, z.core.$strip>>;
254
- }, z.core.$strip>, z.ZodObject<{
255
- type: z.ZodEnum<{
256
- "user.read": "user.read";
257
- }>;
258
- options: z.ZodOptional<z.ZodObject<{
259
- accessLevel: z.ZodOptional<z.ZodEnum<{
260
- administrativeArea: "administrativeArea";
261
- location: "location";
262
- all: "all";
263
- }>>;
264
- }, z.core.$strip>>;
265
- }, z.core.$strip>], "type">;
266
- export type UserScopeV2 = z.infer<typeof UserScopeV2>;
267
- export declare function scopeUsesRoleOptions(scope: UserScopeV2): scope is Extract<UserScopeV2, {
268
- type: ScopesWithRoleOption;
269
- }>;
270
223
  export declare function scopeUsesDeclaredOptions(scope: Scope): scope is Extract<Scope, {
271
224
  type: z.infer<typeof ScopesWithDeclaredOptions>;
272
225
  }>;
@@ -333,6 +286,13 @@ export declare const ResolvedRecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject
333
286
  }, z.core.$strip>], "type">;
334
287
  export type RecordScopeV2 = z.infer<typeof RecordScopeV2>;
335
288
  export type ResolvedRecordScopeV2 = z.infer<typeof ResolvedRecordScopeV2>;
289
+ declare const SystemScopeType: z.ZodEnum<{
290
+ "organisation.read-locations": "organisation.read-locations";
291
+ "user.read": "user.read";
292
+ "user.create": "user.create";
293
+ "user.edit": "user.edit";
294
+ }>;
295
+ export type SystemScopeType = z.infer<typeof SystemScopeType>;
336
296
  /** The primary scope schema which gathers all scope types together. All scopes are discriminated by type and options are determined according to the type. */
337
297
  export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
338
298
  type: z.ZodEnum<{
@@ -477,30 +437,11 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
477
437
  }, z.core.$strip>>;
478
438
  }, z.core.$strip>, z.ZodObject<{
479
439
  type: z.ZodEnum<{
440
+ "organisation.read-locations": "organisation.read-locations";
441
+ "user.read": "user.read";
480
442
  "user.create": "user.create";
481
443
  "user.edit": "user.edit";
482
444
  }>;
483
- options: z.ZodOptional<z.ZodObject<{
484
- accessLevel: z.ZodOptional<z.ZodEnum<{
485
- administrativeArea: "administrativeArea";
486
- location: "location";
487
- all: "all";
488
- }>>;
489
- role: z.ZodOptional<z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>>;
490
- }, z.core.$strip>>;
491
- }, z.core.$strip>, z.ZodObject<{
492
- type: z.ZodEnum<{
493
- "user.read": "user.read";
494
- }>;
495
- options: z.ZodOptional<z.ZodObject<{
496
- accessLevel: z.ZodOptional<z.ZodEnum<{
497
- administrativeArea: "administrativeArea";
498
- location: "location";
499
- all: "all";
500
- }>>;
501
- }, z.core.$strip>>;
502
- }, z.core.$strip>, z.ZodObject<{
503
- type: z.ZodLiteral<"organisation.read-locations">;
504
445
  options: z.ZodOptional<z.ZodObject<{
505
446
  accessLevel: z.ZodOptional<z.ZodEnum<{
506
447
  administrativeArea: "administrativeArea";
@@ -626,21 +567,10 @@ export declare const decodeScope: (query: EncodedScope) => {
626
567
  registeredBy?: "user" | undefined;
627
568
  templates?: string[] | undefined;
628
569
  } | undefined;
629
- } | {
630
- type: "user.create" | "user.edit";
631
- options?: {
632
- accessLevel?: "administrativeArea" | "location" | "all" | undefined;
633
- role?: string[] | undefined;
634
- } | undefined;
635
- } | {
636
- type: "user.read";
637
- options?: {
638
- accessLevel?: "administrativeArea" | "location" | "all" | undefined;
639
- } | undefined;
640
570
  } | {
641
571
  type: "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration";
642
572
  } | {
643
- type: "organisation.read-locations";
573
+ type: "organisation.read-locations" | "user.read" | "user.create" | "user.edit";
644
574
  options?: {
645
575
  accessLevel?: "administrativeArea" | "location" | "all" | undefined;
646
576
  } | undefined;
@@ -42,7 +42,6 @@ __export(scopes_exports, {
42
42
  ScopesWithFullOptions: () => ScopesWithFullOptions,
43
43
  ScopesWithPlaceEventOptions: () => ScopesWithPlaceEventOptions,
44
44
  UserFilter: () => UserFilter,
45
- UserScopeV2: () => UserScopeV2,
46
45
  canUserCreateEvent: () => canUserCreateEvent,
47
46
  decodeScope: () => decodeScope,
48
47
  defineRoles: () => defineRoles,
@@ -55,8 +54,7 @@ __export(scopes_exports, {
55
54
  isCustomActionScope: () => isCustomActionScope,
56
55
  scopeUsesDeclaredOptions: () => scopeUsesDeclaredOptions,
57
56
  scopeUsesFullOptions: () => scopeUsesFullOptions,
58
- scopeUsesPrintCertifiedCopiesOptions: () => scopeUsesPrintCertifiedCopiesOptions,
59
- scopeUsesRoleOptions: () => scopeUsesRoleOptions
57
+ scopeUsesPrintCertifiedCopiesOptions: () => scopeUsesPrintCertifiedCopiesOptions
60
58
  });
61
59
  module.exports = __toCommonJS(scopes_exports);
62
60
  var z4 = __toESM(require("zod/v4"));
@@ -141,10 +139,6 @@ var scopeByEvent = z3.preprocess(
141
139
  (val) => val === void 0 ? void 0 : [val].flat(),
142
140
  z3.array(z3.string()).optional()
143
141
  ).describe("Event type, e.g. birth, death");
144
- var userRole = z3.preprocess(
145
- (val) => val === void 0 ? void 0 : [val].flat(),
146
- z3.array(z3.string()).optional()
147
- ).describe("User role, e.g. admin, field agent");
148
142
  var scopeOptionsPlaceEvent = z3.object({
149
143
  event: scopeByEvent,
150
144
  placeOfEvent: JurisdictionFilter.optional()
@@ -249,36 +243,6 @@ var RecordScopeV2 = z3.discriminatedUnion("type", [
249
243
  ]).describe(
250
244
  "Scopes used to check user's permission to perform actions on a record."
251
245
  );
252
- var SystemScopeType = z3.enum([
253
- "organisation.read-locations",
254
- "user.read",
255
- "user.create",
256
- "user.edit"
257
- ]);
258
- var UserScopeType = SystemScopeType.extract([
259
- "user.read",
260
- "user.create",
261
- "user.edit"
262
- ]);
263
- var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
264
- var UserScopeV2 = z3.discriminatedUnion("type", [
265
- z3.object({
266
- type: ScopesWithRoleOption,
267
- options: z3.object({
268
- accessLevel: JurisdictionFilter.optional(),
269
- role: userRole.optional()
270
- }).optional()
271
- }),
272
- z3.object({
273
- type: UserScopeType.extract(["user.read"]),
274
- options: z3.object({
275
- accessLevel: JurisdictionFilter.optional()
276
- }).optional()
277
- })
278
- ]);
279
- function scopeUsesRoleOptions(scope) {
280
- return ScopesWithRoleOption?.options.some((opt) => opt === scope.type);
281
- }
282
246
  function scopeUsesDeclaredOptions(scope) {
283
247
  return !ScopesWithPlaceEventOptions.options.some((opt) => opt === scope.type);
284
248
  }
@@ -311,14 +275,16 @@ var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
311
275
  }).optional()
312
276
  })
313
277
  ]).describe("Resolved scope with location/user IDs instead of filters.");
278
+ var SystemScopeType = z3.enum([
279
+ "organisation.read-locations",
280
+ "user.read",
281
+ "user.create",
282
+ "user.edit"
283
+ ]);
314
284
  var Scope2 = z3.discriminatedUnion("type", [
315
285
  z3.object({ type: PlainScopeType }),
316
286
  ...RecordScopeV2.options,
317
- ...UserScopeV2.options,
318
- z3.object({
319
- type: z3.literal("organisation.read-locations"),
320
- options: AccessLevelOptions.optional()
321
- }),
287
+ z3.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
322
288
  z3.object({
323
289
  type: z3.literal("workqueue"),
324
290
  options: WorkqueueOrDashboardOptions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/toolkit",
3
- "version": "2.0.0-rc.bee2b7b",
3
+ "version": "2.0.0-rc.c4ed9c8",
4
4
  "description": "OpenCRVS toolkit for building country configurations",
5
5
  "license": "MPL-2.0",
6
6
  "bin": {