"use server"; // Run ONE registry operation over ONE video, from its panel. // // THE SPEAKER LANE ONLY. Digest keeps digestBucketAction: it runs on its own // queue with its own guards (the pause switch, the yield-to-transcription // carve-out, the spend cap, the remoteEnabled fail-fast), and none of those is // expressible through the backfill lane's single scalar. // // NOTHING BUT FUNCTIONS IS DECLARED HERE. A `"use server"` file must not // re-export a type: Next's server-actions transform does not erase a // re-export the way it erases a type declaration, and every route that reaches // the export 500s at runtime while tsc stays quiet. digestActions.ts has the // long version of this note. import { safeRevalidate } from "../../../../lib/safeRevalidate"; import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { getSettings } from "yt-dlp-transcript-common/lib/settings"; import { backfillLaneOperations, operationLabel, } from "yt-dlp-transcript-common/lib/operations"; import type { StreamActionResult } from "yt-dlp-transcript-common/jobs/streamCommand"; import { runBackfillChannelJob } from "yt-dlp-transcript-common/controller/operationJobs"; export async function runOperationForVideoAction( slug: string, videoId: string, operationId: string, ): Promise { // The live lane, not the declared one. A disabled operation's panel does not // draw the button at all; this is the belt behind that brace, and it names // where to switch the feature on rather than just refusing. const lane = backfillLaneOperations(getSettings()); if (!lane.some((op) => op.id === operationId)) { return { ok: false, error: `${operationLabel(operationId)} is not switched on, so there is nothing to run — enable it on its Operations page.`, }; } return runBackfillChannelJob({ paths: getPaths(), channelSlug: slug, kindIds: [operationId], // The whole of "one video": the batch intersects these with disk and // countBackfillWork sizes the bar to them. ids: [videoId], // No queueKey — the lane's own key. No `background` either: a hand-clicked // run goes in front of the sweep's, exactly as backfillChannelAction's does. onDone: () => { safeRevalidate([ `/channels/${slug}/videos/${videoId}`, `/channels/${slug}`, ]); }, }); }