import { Permission, type OrganizationServiceAccount, type OrganizationServiceAccountRole } from "@opengeni/contracts"; import { type Database } from "./database.js"; import * as schema from "./schema.js"; export declare class OrganizationServiceAccountNotFoundError extends Error { constructor(); } export declare class OrganizationServiceAccountRoleError extends Error { readonly permissions: Permission[]; constructor(permissions: Permission[]); } type ServiceAccountRow = typeof schema.organizationServiceAccounts.$inferSelect; type KeyRow = typeof schema.apiKeys.$inferSelect; /** Everything a stored key can do, as an explicit list. */ export declare function effectiveKeyPermissions(key: Pick): Permission[]; /** The permissions a service account's role leaves out of `permissions`. */ export declare function permissionsBeyondServiceAccountRole(role: OrganizationServiceAccountRole, permissions: readonly Permission[]): Permission[]; export declare function listOrganizationServiceAccounts(db: Database, accountId: string): Promise; /** A live service account, locked for the rest of the transaction. */ export declare function lockOrganizationServiceAccount(tx: Database, accountId: string, serviceAccountId: string): Promise; export declare function getOrganizationServiceAccount(db: Database, accountId: string, serviceAccountId: string): Promise; /** Insert inside an existing organization-scoped transaction. */ export declare function insertOrganizationServiceAccount(tx: Database, input: { accountId: string; name: string; description?: string | null; role: OrganizationServiceAccountRole; createdBySubjectId?: string | null; }): Promise; export declare function createOrganizationServiceAccount(db: Database, input: { accountId: string; name: string; description?: string | null; role: OrganizationServiceAccountRole; createdBySubjectId: string; }): Promise; /** * Rename, describe or change the role. Making it a member narrows its live * keys in the same transaction: each becomes an explicit key without * administrator permissions, so no key keeps more than its holder may have. */ export declare function updateOrganizationServiceAccount(db: Database, accountId: string, serviceAccountId: string, input: { name?: string | undefined; description?: string | null | undefined; role?: OrganizationServiceAccountRole | undefined; }): Promise; /** Delete a service account and revoke every key it holds, at once. */ export declare function deleteOrganizationServiceAccount(db: Database, accountId: string, serviceAccountId: string): Promise; /** The holder of each key, for key listings. */ export declare function serviceAccountsForKeys(tx: Database, keys: ReadonlyArray>): Promise>; export {};