import { SmrtObject } from '@happyvertical/smrt-core'; import { AccessRequestStatus } from '../types/index.js'; /** * Options accepted by the {@link AccessRequest} constructor / collection * `create`. `requestContext` and `tenantHint` are stored as JSON *strings* — * use {@link AccessRequest.setRequestContext} / {@link AccessRequest.setTenantHint} * (or pass pre-serialized strings) rather than raw objects. */ export interface AccessRequestOptions { email?: string; name?: string | null; status?: AccessRequestStatus; source?: string; requestContext?: string; note?: string | null; requestedAt?: Date; decidedAt?: Date | null; decidedBy?: string | null; resultingUserId?: string | null; tenantHint?: string | null; [key: string]: unknown; } /** * A prospective user's request for access, captured before they become a * {@link User}. * * @example * ```typescript * // Public, unauthenticated path (app adds rate-limiting): * const request = await service.createAccessRequest({ * email: 'Jane@Example.com', * name: 'Jane Doe', * source: 'www', * context: { company: 'Acme', intendedUse: 'evaluation' }, * }); * // request.email === 'jane@example.com', request.status === 'requested' * ``` */ export declare class AccessRequest extends SmrtObject { /** * Requester's email address. Required, normalized to lowercase, and indexed * for lookup + open-request dedup. NOT unique: the same email may accumulate * multiple requests over time (e.g. an old GRADUATED record plus a new * REQUESTED one); dedup is enforced on *open* requests by the service. */ email: string; /** * Requester's display name, if supplied on the form. */ name: string | null; /** * Lifecycle status. Indexed so the operator triage queue can filter by status * efficiently. */ status: AccessRequestStatus; /** * Where the request came from, e.g. `www`, `sdk`. Indexed for per-source * filtering in the operator queue. */ source: string; /** * Free-form JSON metadata captured with the request (intended use, company, * message, referrer, etc.), stored as a JSON string. * * NOT named `context`: {@link SmrtObject} reserves the `context` field for * slug scoping, so this mirrors smrt-chat's `sessionContext` convention. Use * {@link getRequestContext} / {@link setRequestContext} for typed access. */ requestContext: string; /** * Operator note / decision reason (set on approve / decline / cancel). */ note: string | null; /** * When the request was submitted. Defaults to creation time. */ requestedAt: Date; /** * When an operator decided the request (approve / decline / cancel / * graduate). Null while still `REQUESTED`. */ decidedAt: Date | null; /** * User id of the operator who decided the request. Null while still pending. */ decidedBy: string | null; /** * Id of the `User` produced (or linked) when the request graduated. Null * until graduation. */ resultingUserId: string | null; /** * Optional JSON hint about the org/tenant the requester wants, stored as a * JSON string (null when absent). Advisory only — the operator decides the * actual tenant at graduation time. Use {@link getTenantHint} / * {@link setTenantHint} for typed access. */ tenantHint: string | null; constructor(options?: AccessRequestOptions); /** * Parse {@link requestContext} into an object. Returns `{}` on missing or * malformed JSON (graceful — never throws). */ getRequestContext(): Record; /** * Serialize and store {@link requestContext} from an object. */ setRequestContext(value: Record): void; /** * Parse {@link tenantHint} into an object, or `null` when unset / malformed. */ getTenantHint(): Record | null; /** * Serialize and store {@link tenantHint} from an object (or clear with null). */ setTenantHint(value: Record | null): void; /** * Whether the request is still open (awaiting a decision). */ isOpen(): boolean; /** * Whether the request has been approved (and not yet graduated). */ isApproved(): boolean; /** * Whether the request reached a terminal state (declined, graduated, or * canceled) and can no longer transition. */ isTerminal(): boolean; } //# sourceMappingURL=AccessRequest.d.ts.map