/** * Checks the rows `follow-service.ts` reads from `follows` to answer what a * user follows. * * @module */ import type { SQLOutputValue } from "node:sqlite"; /** * Read by `getFollowStatus`. Exactly one of `followed_user_id` and * `followed_playlist_id` is set, as the table's CHECK constraint requires. */ export interface FollowRow { id: string; follower_id: string; followed_user_id: string | null; followed_playlist_id: string | null; created_at: string; [key: string]: SQLOutputValue; } /** * Checks whether `obj`, a row `getFollowStatus` selected, is a * {@link FollowRow}. */ export function isFollowRow( obj: unknown, ): obj is FollowRow { return !!obj && typeof obj === "object" && "id" in obj && typeof obj.id === "string" && "follower_id" in obj && typeof obj.follower_id === "string" && "created_at" in obj && typeof obj.created_at === "string" && "followed_user_id" in obj && (obj.followed_user_id === null || typeof obj.followed_user_id === "string") && "followed_playlist_id" in obj && (obj.followed_playlist_id === null || typeof obj.followed_playlist_id === "string"); }