feat(core): API support helpers: token list, suggestions, attachment links, connection runs, device auth, file-mode sync
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
7f3d0d5c44
commit
7b0a6738dd
@@ -975,3 +975,34 @@ export async function rejectSuggestion(db: Db, userId: string, suggestionId: str
|
||||
if (s.status !== "pending") throw new ValidationError("status", "not_pending");
|
||||
await db.k.updateTable("match_suggestions").set({ status: "rejected" }).where("id", "=", s.id).execute();
|
||||
}
|
||||
|
||||
export interface MatchSuggestion {
|
||||
id: string;
|
||||
workId: string;
|
||||
candidateWorkId: string;
|
||||
score: number;
|
||||
status: "pending" | "accepted" | "rejected";
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
/** The user's pending match suggestions for a work, best first. Throws `NotFoundError` if the work is not visible. */
|
||||
export async function listSuggestions(db: Db, userId: string, workId: string): Promise<MatchSuggestion[]> {
|
||||
await resolveVisibleWork(db.k, userId, workId);
|
||||
const rows = await db.k
|
||||
.selectFrom("match_suggestions")
|
||||
.selectAll()
|
||||
.where("user_id", "=", userId)
|
||||
.where("work_id", "=", workId)
|
||||
.where("status", "=", "pending")
|
||||
.orderBy("score", "desc")
|
||||
.orderBy("id")
|
||||
.execute();
|
||||
return rows.map((r) => ({
|
||||
id: r.id,
|
||||
workId: r.work_id,
|
||||
candidateWorkId: r.candidate_work_id,
|
||||
score: r.score,
|
||||
status: r.status,
|
||||
createdAt: r.created_at,
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user