import type { Selectable } from 'kysely'; import type * as Db from '../Db.js'; import type * as db_Schema from '../Schema.js'; import * as Memberships from './memberships.js'; /** Columns of the `invitations` table, derived from `Schema.Invitation`. */ export type Table = db_Schema.Invitation; /** A stored invitation row. */ export type Record = Selectable; /** * Inserts an invitation and returns the stored record. Emails are stored * lowercase so matching against verified emails is case-insensitive. Re-inviting * a live (pending) (org, email) refreshes that row — role, inviter, expiry — * rather than accumulating duplicates, matching the `invitations_pending_unique` * partial index. * * @param db - The database. * @param input - The invitation to insert. * @returns The stored record. */ export declare function create(db: Db.Db, input: create.Input): Promise; export declare namespace create { /** Fields accepted when inserting an invitation. */ type Input = { /** Invitee email. */ email: string; /** When the invitation expires (ISO 8601). */ expiresAt: string; /** User or API key id creating the invitation. */ invitedBy: string; /** Organization id (`org_…`) the invitation joins. */ orgId: string; /** Role granted on accept. */ role: Memberships.Role; }; } /** * Reads an invitation by id. * * @param db - The database. * @param id - The invitation id (`inv_…`). * @returns The record, or `undefined` when absent. */ export declare function get(db: Db.Db, id: string): Promise; /** * Lists an organization's pending invitations (unaccepted, unrevoked, * unexpired), newest first. * * @param db - The database. * @param orgId - The organization id (`org_…`). * @returns The records. */ export declare function listByOrg(db: Db.Db, orgId: string): Promise; /** * Lists pending invitations addressed to an email, joined with the inviting * organization's name, newest first. * * @param db - The database. * @param email - The invitee email (matched lowercase). * @returns The records with `orgName` from the organization row. */ export declare function listByEmail(db: Db.Db, email: string): Promise<(Record & { orgName: string; })[]>; /** * Revokes a pending invitation. * * @param db - The database. * @param id - The invitation id (`inv_…`). * @returns The revoked record, or `undefined` when absent or already settled. */ export declare function revoke(db: Db.Db, id: string): Promise; /** * Accepts a pending invitation into a membership, atomically: the conditional * update settles the invitation exactly once (double accepts lose the race). * A new member is inserted at the invited role; an existing member is only ever * elevated to it — accepting never demotes (which could strip the last owner). * * @param db - The database. * @param id - The invitation id (`inv_…`). * @param userId - The accepting user id (`usr_…`). * @returns The accepted record, or `undefined` when absent, settled, or expired. */ export declare function accept(db: Db.Db, id: string, userId: string): Promise; //# sourceMappingURL=invitations.d.ts.map