Merge pull request 'feat(scripts): כפתור "הרץ" מ-UI לסקריפטי read-only (קטגוריה B #4)' (#283) from worktree-scripts-run-ui into main
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 1m34s
G12 Leak-Guard / leak-guard (push) Successful in 4s
Lint — undefined names / undefined-names (push) Successful in 10s

This commit was merged in pull request #283.
This commit is contained in:
2026-06-17 04:31:19 +00:00
5 changed files with 315 additions and 25 deletions

View File

@@ -1,3 +1,4 @@
import { useMutation } from "@tanstack/react-query";
import { apiRequest } from "./client";
// ── Scripts catalog ───────────────────────────────────────────────
@@ -11,8 +12,32 @@ export type ScriptsCatalog = {
bytes: number;
last_modified: number;
gitea_url: string;
// #4 — basenames the UI may offer a "הרץ" button for (read-only allowlist,
// enforced host-side). Optional so an older backend (pre-deploy) degrades to
// "מקור"-only with no run buttons.
runnable_scripts?: string[];
};
export function fetchScriptsCatalog(signal?: AbortSignal) {
return apiRequest<ScriptsCatalog>("/api/scripts/catalog", { signal });
}
// ── Run a read-only script (#4) ───────────────────────────────────
// Proxies to the court-fetch host bridge; only allowlisted read-only scripts
// run, with a fixed safe argv. Exit code + captured output are relayed verbatim.
export type ScriptRunResult = {
ok: boolean;
exit_code: number;
stdout: string;
stderr: string;
};
export function useRunScript() {
return useMutation({
mutationFn: (name: string) =>
apiRequest<ScriptRunResult>(
`/api/scripts/${encodeURIComponent(name)}/run`,
{ method: "POST" },
),
});
}