WebHooker/admin/types.ts
RhenCloud 407514f3c9
feat(admin): GitHub OAuth login, admin whitelist and Nuxt WebUI
Add an admin WebUI (Nuxt static SPA in admin/, served via the ASSETS
binding) for managing routes and viewing send logs. Access is gated by
GitHub OAuth plus an ADMIN_USER_IDS whitelist with cookie sessions
(admin-session.ts). Expose routes/logs CRUD API (admin-routes.ts), add a
discord-link mapping in token-store.ts, and mount admin routes with an
SPA assets fallback in the server.
2026-08-02 06:50:41 +08:00

43 lines
894 B
TypeScript

export interface Filter {
type: "event" | "repo" | "actor" | "action" | "branch" | "keyword";
match: string | string[];
exclude?: boolean;
}
export interface Route {
id: string;
name: string;
enabled: boolean;
filters: Filter[];
target: {
channelId: string;
threadId?: string;
};
lang?: string;
}
export const FILTER_TYPES = ["event", "repo", "actor", "action", "branch", "keyword"] as const;
export const FILTER_LABELS: Record<string, string> = {
event: "Event",
repo: "Repo",
actor: "Actor",
action: "Action",
branch: "Branch",
keyword: "Keyword",
};
export function fmtMatch(match: string | string[]): string {
if (Array.isArray(match)) return match.join(", ");
return String(match ?? "");
}
export interface SendRecord {
ts: number;
routeId: string;
event: string;
repo?: string;
target: string;
ok: boolean;
error?: string;
}