UNPKG

@vot.js/ext

Version:

package for web extensions

56 lines (48 loc) 2.13 kB
import { VideoService } from "./service" import { BaseHelperOpts } from "./helpers/base" import { Type, Static, TSchema } from '@sinclair/typebox' export type GetVideoDataOpts<T extends TSchema> = Static<ReturnType<typeof GetVideoDataOpts<T>>> export const GetVideoDataOpts = <T extends TSchema>(T: T) => Type.Omit(T, Type.Literal("service")) export type VideoData<T extends TSchema> = Static<ReturnType<typeof VideoData<T>>> export const VideoData = <T extends TSchema>(T: T) => Type.Object({ url: Type.String(), videoId: Type.String(), host: T, duration: Type.Optional(Type.Number()), isStream: Type.Optional(Type.Boolean()), title: Type.Optional(Type.String()), localizedTitle: Type.Optional(Type.String()), description: Type.Optional(Type.String()), subtitles: Type.Optional(Type.Array(VideoDataSubtitle)), detectedLanguage: Type.Optional(RequestLang), translationHelp: Type.Optional(Type.Union([ Type.Array(TranslationHelp), Type.Null() ])) }) export type VideoData<T extends TSchema> = Static<ReturnType<typeof VideoData<T>>> export const VideoData = <T extends TSchema>(T: T) => Type.Object({ url: Type.String(), videoId: Type.String(), host: T, duration: Type.Optional(Type.Number()), isStream: Type.Optional(Type.Boolean()), title: Type.Optional(Type.String()), localizedTitle: Type.Optional(Type.String()), description: Type.Optional(Type.String()), subtitles: Type.Optional(Type.Array(VideoDataSubtitle)), detectedLanguage: Type.Optional(RequestLang), translationHelp: Type.Optional(Type.Union([ Type.Array(TranslationHelp), Type.Null() ])) }) export type AtLeast<T extends TSchema, K extends TSchema> = Static<ReturnType<typeof AtLeast<T, K>>> export const AtLeast = <T extends TSchema, K extends TSchema>(T: T, K: K) => Type.Intersect([ Type.Partial(T), Type.Pick(T, K) ]) export type MinimalVideoData<T extends TSchema> = Static<ReturnType<typeof MinimalVideoData<T>>> export const MinimalVideoData = <T extends TSchema>(T: T) => AtLeast(VideoData(T), Type.Literal("url")) export type GetVideoDataOpts = Static<typeof GetVideoDataOpts> export const GetVideoDataOpts = CoreGetVideoDataOpts(BaseHelperOpts)