/** * The `invites` table: its row type and its guard. * * @module */ import type { SQLOutputValue } from "node:sqlite"; /** A row of the `invites` table. */ export interface InviteRow { /** The invite's token, which registering redeems. */ token: string; /** The id of the user who made the invite. */ inviter_id: string; /** When the invite was redeemed; null while unused. */ used_at: string | null; /** When the invite was made. */ created_at: string; /** Any other column the query selects. */ [key: string]: SQLOutputValue; } /** Checks whether `obj` is a {@link InviteRow}. */ export function isInviteRow( obj: unknown, ): obj is InviteRow { return !!obj && typeof obj === "object" && "token" in obj && typeof obj.token === "string" && "inviter_id" in obj && typeof obj.inviter_id === "string" && "created_at" in obj && typeof obj.created_at === "string" && "used_at" in obj && (obj.used_at === null || typeof obj.used_at === "string"); }