Claude a663764ee8
feat(media): contracts and foundation for Media Studio
Freeze the shared contracts every Media Studio slice builds on: zod DTOs,
EDL, platform profile, brand kit, gate and render plan schemas; the media
RPC surface with a scaffold router; provider interfaces for sources,
inference, rendering, motion graphics and publishing; media background
jobs; the Prisma models and migration; and the @rakazo/media domain
package signatures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0138YqDj3ttfayRwuMKKrqVj
2026-10-03 17:32:52 +00:00

114 lines
4.9 KiB
TypeScript

import { implement, ORPCError } from "@orpc/server";
import type { Actor } from "@rakazo/contracts";
import { appContract } from "@rakazo/contracts";
import type { PrismaClient } from "@rakazo/db";
export interface MediaRouterDeps {
prisma: PrismaClient;
dataDir: string;
}
// Phase A scaffold: every procedure is replaced by its real implementation.
function notImplemented(): never {
throw new ORPCError("NOT_IMPLEMENTED", { message: "Media Studio is not available yet" });
}
export function createMediaRouter(_deps: MediaRouterDeps) {
const os = implement(appContract.media).$context<{ actor: Actor | null; signal?: AbortSignal }>();
const authed = os.use(async ({ context, next }) => {
if (!context.actor) throw new ORPCError("UNAUTHORIZED");
return next({ context: { ...context, actor: context.actor } });
});
return os.router({
capabilities: authed.capabilities.handler(notImplemented),
sources: {
list: authed.sources.list.handler(notImplemented),
createFolder: authed.sources.createFolder.handler(notImplemented),
registerClient: authed.sources.registerClient.handler(notImplemented),
pushItems: authed.sources.pushItems.handler(notImplemented),
sync: authed.sources.sync.handler(notImplemented),
remove: authed.sources.remove.handler(notImplemented),
},
assets: {
search: authed.assets.search.handler(notImplemented),
get: authed.assets.get.handler(notImplemented),
setPaidOnly: authed.assets.setPaidOnly.handler(notImplemented),
requestUpload: authed.assets.requestUpload.handler(notImplemented),
},
uploads: {
begin: authed.uploads.begin.handler(notImplemented),
status: authed.uploads.status.handler(notImplemented),
complete: authed.uploads.complete.handler(notImplemented),
},
collections: {
list: authed.collections.list.handler(notImplemented),
get: authed.collections.get.handler(notImplemented),
rename: authed.collections.rename.handler(notImplemented),
merge: authed.collections.merge.handler(notImplemented),
split: authed.collections.split.handler(notImplemented),
createManual: authed.collections.createManual.handler(notImplemented),
recluster: authed.collections.recluster.handler(notImplemented),
},
people: {
list: authed.people.list.handler(notImplemented),
update: authed.people.update.handler(notImplemented),
merge: authed.people.merge.handler(notImplemented),
assignTrack: authed.people.assignTrack.handler(notImplemented),
recordConsent: authed.people.recordConsent.handler(notImplemented),
remove: authed.people.remove.handler(notImplemented),
},
marks: {
list: authed.marks.list.handler(notImplemented),
create: authed.marks.create.handler(notImplemented),
update: authed.marks.update.handler(notImplemented),
remove: authed.marks.remove.handler(notImplemented),
},
brandKits: {
list: authed.brandKits.list.handler(notImplemented),
upsert: authed.brandKits.upsert.handler(notImplemented),
remove: authed.brandKits.remove.handler(notImplemented),
templates: authed.brandKits.templates.handler(notImplemented),
introVariants: authed.brandKits.introVariants.handler(notImplemented),
},
profiles: {
list: authed.profiles.list.handler(notImplemented),
get: authed.profiles.get.handler(notImplemented),
},
projects: {
list: authed.projects.list.handler(notImplemented),
get: authed.projects.get.handler(notImplemented),
create: authed.projects.create.handler(notImplemented),
update: authed.projects.update.handler(notImplemented),
remove: authed.projects.remove.handler(notImplemented),
autoPlan: authed.projects.autoPlan.handler(notImplemented),
},
plans: {
submit: authed.plans.submit.handler(notImplemented),
},
renders: {
start: authed.renders.start.handler(notImplemented),
get: authed.renders.get.handler(notImplemented),
cancel: authed.renders.cancel.handler(notImplemented),
thumbnails: authed.renders.thumbnails.handler(notImplemented),
},
marketing: {
copy: authed.marketing.copy.handler(notImplemented),
},
publications: {
list: authed.publications.list.handler(notImplemented),
create: authed.publications.create.handler(notImplemented),
bundle: authed.publications.bundle.handler(notImplemented),
markPublished: authed.publications.markPublished.handler(notImplemented),
cancel: authed.publications.cancel.handler(notImplemented),
},
metrics: {
mappings: authed.metrics.mappings.handler(notImplemented),
saveMapping: authed.metrics.saveMapping.handler(notImplemented),
importCsv: authed.metrics.importCsv.handler(notImplemented),
record: authed.metrics.record.handler(notImplemented),
funnel: authed.metrics.funnel.handler(notImplemented),
},
});
}