Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
71 lines
2.1 KiB
TypeScript
71 lines
2.1 KiB
TypeScript
/**
|
|
* Pure helpers that project a SPARK {@link Idea} onto the create-job wizard and
|
|
* resolve display labels for an idea's suggestion chips. Nothing here mutates
|
|
* its inputs; every function returns a fresh value.
|
|
*/
|
|
|
|
import type { Idea } from "@/lib/types";
|
|
import type { SparkPrefill } from "@/lib/spark-prefill";
|
|
import {
|
|
CAPTION_STYLE_OPTIONS,
|
|
LANGUAGE_OPTIONS,
|
|
LAYOUT_OPTIONS,
|
|
coerceLanguage,
|
|
} from "@/components/wizard/types";
|
|
|
|
/**
|
|
* Maps an idea to the wizard's prefill fields. `video_subject` is seeded from
|
|
* the hook (plus angle for context); the optional script is seeded from the
|
|
* numbered outline beats.
|
|
*/
|
|
export function ideaToPrefill(idea: Readonly<Idea>): SparkPrefill {
|
|
const hook = idea.hook.trim();
|
|
const angle = idea.angle.trim();
|
|
const subject = hook
|
|
? angle && angle !== hook
|
|
? `${hook} — ${angle}`
|
|
: hook
|
|
: angle || idea.title.trim();
|
|
|
|
const prompt = idea.script_outline
|
|
.map((beat, i) => `${i + 1}. ${beat.trim()}`)
|
|
.join("\n");
|
|
|
|
return {
|
|
videoSubject: subject,
|
|
prompt,
|
|
layout: idea.suggested_layout,
|
|
captionStyle: idea.suggested_caption_style,
|
|
// Idea languages are tr|en; coerce guards against anything unexpected.
|
|
language: coerceLanguage(idea.language, "auto"),
|
|
};
|
|
}
|
|
|
|
/** Human-readable name for a layout id, falling back to the raw id. */
|
|
export function layoutLabel(id: string): string {
|
|
return LAYOUT_OPTIONS.find((o) => o.value === id)?.title ?? id;
|
|
}
|
|
|
|
/** Human-readable name for a language code, falling back to the raw code. */
|
|
export function languageLabel(code: string): string {
|
|
return LANGUAGE_OPTIONS.find((o) => o.value === code)?.label ?? code;
|
|
}
|
|
|
|
export interface CaptionStyleMeta {
|
|
label: string;
|
|
/** Spoken-word swatch color. */
|
|
spoken: string;
|
|
/** Upcoming-word swatch color. */
|
|
upcoming: string;
|
|
}
|
|
|
|
/** Display metadata (name + swatch colors) for a caption-style id. */
|
|
export function captionStyleMeta(id: string): CaptionStyleMeta {
|
|
const match = CAPTION_STYLE_OPTIONS.find((o) => o.value === id);
|
|
return {
|
|
label: match?.title ?? id,
|
|
spoken: match?.spoken ?? "#ffffff",
|
|
upcoming: match?.upcoming ?? "#ffd60a",
|
|
};
|
|
}
|