From c8ccb32421f6f39ff5593639d78f14634f97add7 Mon Sep 17 00:00:00 2001 From: dumbmoron Date: Wed, 11 Sep 2024 20:47:36 +0000 Subject: [PATCH] api-client: copy request schema from api --- packages/api-client/package.json | 3 +- packages/api-client/src/types/request.ts | 46 ++++++++++++++++++++++++ pnpm-lock.yaml | 3 ++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 packages/api-client/src/types/request.ts diff --git a/packages/api-client/package.json b/packages/api-client/package.json index 676d22bb..2de234a3 100644 --- a/packages/api-client/package.json +++ b/packages/api-client/package.json @@ -10,6 +10,7 @@ "devDependencies": { "prettier": "3.3.3", "tsup": "^8.2.4", - "typescript": "^5.4.5" + "typescript": "^5.4.5", + "zod": "^3.23.8" } } diff --git a/packages/api-client/src/types/request.ts b/packages/api-client/src/types/request.ts new file mode 100644 index 00000000..350b97ad --- /dev/null +++ b/packages/api-client/src/types/request.ts @@ -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; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9d316277..0759e255 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -80,6 +80,9 @@ importers: typescript: specifier: ^5.4.5 version: 5.5.4 + zod: + specifier: ^3.23.8 + version: 3.23.8 packages/version-info: {}