Rewrites the web app's comments to rule 32. Task, milestone, rule and spec ids are gone; regression stories are restated as the trap they guard (public auth routes, the menu's stopPropagation, universal loads under adapter-static, metric deltas with their margin). Flutter and Tauri mentions now name the Android app or a native shell, operator quotes and dates are dropped, and one library's counts no longer appear outside test fixtures. Verified with a TypeScript-scanner token comparison (template literals and regex literals re-scanned): only comment text changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
27 lines
992 B
TypeScript
27 lines
992 B
TypeScript
import { createQuery } from '@tanstack/svelte-query';
|
|
import { api } from './client';
|
|
import { qk } from './queries';
|
|
import type { CatalogueSearchResult, RequestKind } from './types';
|
|
|
|
// searchCatalogue asks MusicBrainz through Minstrel's release catalogue.
|
|
// URLSearchParams handles encoding (spaces, quotes,
|
|
// ampersands) so callers can pass q raw.
|
|
export async function searchCatalogue(
|
|
q: string,
|
|
kind: RequestKind
|
|
): Promise<CatalogueSearchResult[]> {
|
|
const params = new URLSearchParams({ q, kind });
|
|
return api.get<CatalogueSearchResult[]>(`/api/catalogue/search?${params.toString()}`);
|
|
}
|
|
|
|
// MusicBrainz allows a request a second, so a repeated search within a minute
|
|
// is served from the client's cache rather than asked again.
|
|
export function createCatalogueSearchQuery(q: string, kind: RequestKind) {
|
|
return createQuery({
|
|
queryKey: qk.catalogueSearch(q, kind),
|
|
queryFn: () => searchCatalogue(q, kind),
|
|
enabled: q.length > 0,
|
|
staleTime: 60_000
|
|
});
|
|
}
|