UNPKG

@accounter/server

Version:
34 lines (33 loc) 1.58 kB
import DataLoader from 'dataloader'; import { TenantAwareDBClient } from '../../app-providers/tenant-db-client.js'; import { AuthContextProvider } from '../../auth/providers/auth-context.provider.js'; import type { AdminContext, IGetAdminContextsResult, IUpdateAdminContextParams } from '../types.js'; export declare class AdminContextProvider { private authContextProvider; private db; private authContext; private authContextInitialized; private cachedContext; private cachedContextInitializing; constructor(authContextProvider: AuthContextProvider, db: TenantAwareDBClient); normalizeContext(rawContext: IGetAdminContextsResult): AdminContext; getAdminContext(): Promise<AdminContext | null>; getVerifiedAdminContext(): Promise<AdminContext>; updateAdminContext(params: IUpdateAdminContextParams): Promise<AdminContext | null>; private batchAdminContextsByOwnerIds; adminContextByOwnerIdLoader: DataLoader<string, AdminContext | null, string>; clearCache(): void; /** * Resolve the owner business for this request. * - Single-business read scope selects that business. * - Multi-business scope prefers the primary tenant business only when it is * part of the scope; otherwise the first scoped business is used. * - No scope falls back to the primary tenant business. */ private resolveOwnerIdForRequest; /** * Lazy initialization of auth context on first use. * This ensures the async provider is called only when needed. */ private ensureAuthContext; }