import { LANGUAGE_COLORS } from "#lib/components/repo/languageColors.ts"; import { SORT_OPTIONS, SORT_VALUES, type QueryDialect } from "#lib/ticketQuery.ts"; export const POPULAR_LANGUAGES = [ "Go", "JavaScript", "TypeScript", "Python", "Rust", "OCaml", "Haskell", "C", "C++", "Ruby", "Swift" ]; const LANGUAGE_OPTIONS = [ ...POPULAR_LANGUAGES, ...Object.keys(LANGUAGE_COLORS) .filter((name) => !POPULAR_LANGUAGES.includes(name)) .sort((a, b) => a.localeCompare(b)) ].map((value) => ({ value })); type RepoKey = "language" | "author" | "sort"; const repoDialect = (qualifiers: readonly RepoKey[]): QueryDialect => ({ qualifiers, hints: { language: "primary language", author: "handle or did", sort: "order" }, values: (key) => { switch (key) { case "language": return LANGUAGE_OPTIONS; case "sort": return SORT_OPTIONS; case "author": return []; } }, problem: (key, value) => { const v = value.trim().toLowerCase(); if (v === "") return `\`${key}:\` needs a value`; if (key === "sort" && !SORT_VALUES.has(v)) return `\`${key}:${value}\` is not valid`; return null; } }); export const REPO_DIALECT = repoDialect(["language", "author", "sort"]); export const OWNED_REPO_DIALECT = repoDialect(["language", "sort"]);