import { UUID } from '../uuid'; import * as z from 'zod/v4'; import { EventIndex } from './EventIndex'; import { ActionCreationMetadata, RegistrationCreationMetadata } from './EventMetadata'; import { RecordScopeV2, UserScopeV2 } from '../scopes'; import { SystemContext, UserContext } from '../users/User'; /** @deprecated Moving on, location types are arbitrary and defined by the country config. */ export declare const LocationTypeV1: z.ZodEnum<{ ADMIN_STRUCTURE: "ADMIN_STRUCTURE"; HEALTH_FACILITY: "HEALTH_FACILITY"; CRVS_OFFICE: "CRVS_OFFICE"; }>; export type LocationTypeV1 = z.infer; export declare const AdministrativeArea: z.ZodObject<{ id: z.core.$ZodBranded; name: z.ZodString; externalId: z.ZodOptional>; parentId: z.ZodNullable>; validUntil: z.ZodNullable; }, z.core.$strip>; export type AdministrativeArea = z.infer; export declare const Location: z.ZodObject<{ id: z.core.$ZodBranded; name: z.ZodString; externalId: z.ZodOptional>; administrativeAreaId: z.ZodNullable>; validUntil: z.ZodNullable; locationType: z.ZodNullable; }, z.core.$strip>; export type Location = z.infer; type WrapArrayPreserveNullish = V extends readonly any[] ? V : NonNullable[] | Extract; /** * For type T, convert fields K to arrays. If field is string, convert to string[]. */ type ToArrayFields = T extends unknown ? T extends object ? { [P in keyof T]: P extends K ? WrapArrayPreserveNullish : T[P]; } : T : never; /** * Event index type where all location fields are arrays representing full location hierarchy. */ export type EventIndexWithAdministrativeHierarchy = Omit, 'legalStatuses'> & { legalStatuses: { DECLARED: ToArrayFields | undefined; REGISTERED: ToArrayFields | undefined; }; }; /** * Given indexed event and resolved scope, determine if the scope allows access to the event. * * All of the options within the scope must be satisfied for access to be granted. * Return false early to break out of checks as soon as possible - if any option is not satisfied, the scope does not allow access to the event, so no need to check further options. * */ export declare function canAccessEventWithScope(event: Partial, scope: RecordScopeV2, user: UserContext | SystemContext, customActionType?: string): boolean; export type UserWithResolvedHierarchy = { role: string; administrativeHierarchy: UUID[]; primaryOfficeId: UUID; }; export declare function canAccessUserWithScope({ userToAccess, scope, user }: { userToAccess: UserWithResolvedHierarchy; scope: UserScopeV2; user: UserContext | SystemContext; }): boolean; export declare function canAccessOtherUserWithScopes({ scopes, userToAccess, user }: { scopes: UserScopeV2[]; userToAccess: UserWithResolvedHierarchy; user: UserContext | SystemContext; }): boolean; /** * Given indexed event and list of resolved scopes, determine if any of the scopes allow access to the event. * * One of the scopes must allow access for the event to be accessible. */ export declare function userCanAccessEventWithScopes(event: Partial, scopes: RecordScopeV2[], user: UserContext | SystemContext, customActionType?: string): boolean; export declare function getAdministrativeAreaHierarchy(administrativeAreaId: string | undefined | null, administrativeAreas: Map): { id: string & z.core.$brand<"UUID">; name: string; parentId: (string & z.core.$brand<"UUID">) | null; validUntil: string | null; externalId?: string | null | undefined; }[]; /** * Resolves a location or administrative area UUID into a root-first hierarchy of UUIDs. * * If the ID refers to a `Location` (e.g. CRVS office), the hierarchy includes * the administrative area ancestors followed by the location itself. * If the ID refers to an `AdministrativeArea`, returns the area's ancestor chain (root-first). * * Uses `getAdministrativeAreaHierarchy` which returns leaf-first order, * so the result is reversed to match the root-first convention used by the server. */ export declare function getLocationHierarchy(selectedId: UUID, context: { administrativeAreas: Map; locations: Map; }): UUID[]; export {}; //# sourceMappingURL=locations.d.ts.map