api-client: copy request schema from api

This commit is contained in:
dumbmoron 2024-09-11 20:47:36 +00:00
parent 6cc1227288
commit c8ccb32421
No known key found for this signature in database
3 changed files with 51 additions and 1 deletions

View file

@ -10,6 +10,7 @@
"devDependencies": { "devDependencies": {
"prettier": "3.3.3", "prettier": "3.3.3",
"tsup": "^8.2.4", "tsup": "^8.2.4",
"typescript": "^5.4.5" "typescript": "^5.4.5",
"zod": "^3.23.8"
} }
} }

View file

@ -0,0 +1,46 @@
import { z } from "zod";
// FIXME: this is duplicated from api/src/processing/schema.js
// (minus defaults) until the api is converted to TS
const apiSchema = z.object({
url: z.string()
.min(1),
audioBitrate: z.enum(
["320", "256", "128", "96", "64", "8"]
).optional(),
audioFormat: z.enum(
["best", "mp3", "ogg", "wav", "opus"]
).optional(),
downloadMode: z.enum(
["auto", "audio", "mute"]
).optional(),
filenameStyle: z.enum(
["classic", "pretty", "basic", "nerdy"]
).optional(),
youtubeVideoCodec: z.enum(
["h264", "av1", "vp9"]
).optional(),
videoQuality: z.enum(
["max", "4320", "2160", "1440", "1080", "720", "480", "360", "240", "144"]
).optional(),
youtubeDubLang: z.string()
.length(2)
.optional(),
alwaysProxy: z.boolean().optional(),
disableMetadata: z.boolean().optional(),
tiktokFullAudio: z.boolean().optional(),
tiktokH265: z.boolean().optional(),
twitterGif: z.boolean().optional(),
youtubeDubBrowserLang: z.boolean().optional()
})
.strict();
export type CobaltRequest = z.infer<typeof apiSchema>;

View file

@ -80,6 +80,9 @@ importers:
typescript: typescript:
specifier: ^5.4.5 specifier: ^5.4.5
version: 5.5.4 version: 5.5.4
zod:
specifier: ^3.23.8
version: 3.23.8
packages/version-info: {} packages/version-info: {}