stophy 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/generated/client.gen.ts","../src/generated/sdk.gen.ts","../src/errors.ts","../src/transport.ts","../src/methods/account.ts","../src/methods/channel.ts","../src/methods/playlist.ts","../src/methods/search.ts","../src/methods/suggest.ts","../src/methods/video.ts","../src/client.ts"],"names":["createClient","createConfig","client"],"mappings":";;;;;;;AAuBO,IAAM,MAAA,GAASA,wBAAA;AAAA,EACpBC,wBAAA,CAA4B;AAAA,IAC1B,OAAA,EAAS;AAAA,GACV;AACH,CAAA;;;AC6BO,IAAM,QAAA,GAAW,CACtB,OAAA,KACG;AACH,EAAA,OAAA,CAAQ,OAAA,CAAQ,MAAA,IAAU,MAAA,EAAe,IAAA,CAIvC;AAAA,IACA,QAAA,EAAU;AAAA,MACR;AAAA,QACE,MAAA,EAAQ,QAAA;AAAA,QACR,IAAA,EAAM;AAAA;AACR,KACF;AAAA,IACA,GAAA,EAAK,WAAA;AAAA,IACL,GAAG,OAAA;AAAA,IACH,OAAA,EAAS;AAAA,MACP,cAAA,EAAgB,kBAAA;AAAA,MAChB,GAAG,OAAA,EAAS;AAAA;AACd,GACD,CAAA;AACH,CAAA;AAMO,IAAM,YAAA,GAAe,CAC1B,OAAA,KACG;AACH,EAAA,OAAA,CAAQ,OAAA,CAAQ,MAAA,IAAU,MAAA,EAAe,IAAA,CAIvC;AAAA,IACA,QAAA,EAAU;AAAA,MACR;AAAA,QACE,MAAA,EAAQ,QAAA;AAAA,QACR,IAAA,EAAM;AAAA;AACR,KACF;AAAA,IACA,GAAA,EAAK,YAAA;AAAA,IACL,GAAG,OAAA;AAAA,IACH,OAAA,EAAS;AAAA,MACP,cAAA,EAAgB,kBAAA;AAAA,MAChB,GAAG,OAAA,EAAS;AAAA;AACd,GACD,CAAA;AACH,CAAA;AAMO,IAAM,UAAA,GAAa,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Y,IAAA,CAAK,MAAA,EAAQ,SAAA,EAAW,OAAO,CAAA;AAAA,EACnD;AAAA,EASA,MAAM,OAAA,CACL,cAAA,EACA,OAAA,EACkC;AAClC,IAAA,OAAO,OAAA,CAAe,IAAA,CAAK,MAAA,EAAQ,cAAA,EAAgB,OAAO,CAAA;AAAA,EAC3D;AAAA,EAEA,OAAA,GAAuC;AACtC,IAAA,OAAsB,OAAA,CAAQ,KAAK,MAAM,CAAA;AAAA,EAC1C;AAAA,EAEA,KAAK,KAAA,EAAwD;AAC5D,IAAA,OAAsB,IAAA,CAAK,IAAA,CAAK,MAAA,EAAQ,KAAK,CAAA;AAAA,EAC9C;AAAA,EAEA,MAAM,KAAA,EAA0D;AAC/D,IAAA,OAAsB,KAAA,CAAM,IAAA,CAAK,MAAA,EAAQ,KAAK,CAAA;AAAA,EAC/C;AACD","file":"index.cjs","sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nimport type { ClientOptions } from \"./types.gen\";\nimport {\n type Config,\n type ClientOptions as DefaultClientOptions,\n createClient,\n createConfig,\n} from \"@hey-api/client-fetch\";\n\n/**\n * The `createClientConfig()` function will be called on client initialization\n * and the returned object will become the client's initial configuration.\n *\n * You may want to initialize your client this way instead of calling\n * `setConfig()`. This is useful for example if you're using Next.js\n * to ensure your client always has the correct values.\n */\nexport type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> =\n (\n override?: Config<DefaultClientOptions & T>\n ) => Config<Required<DefaultClientOptions> & T>;\n\nexport const client = createClient(\n createConfig<ClientOptions>({\n baseUrl: \"https://api.stophy.dev\",\n })\n);\n","// This file is auto-generated by @hey-api/openapi-ts\n\nimport type {\n Options as ClientOptions,\n TDataShape,\n Client,\n} from \"@hey-api/client-fetch\";\nimport type {\n GetVideoData,\n GetVideoResponse,\n GetVideoError,\n SearchVideosData,\n SearchVideosResponse,\n SearchVideosError,\n GetChannelData,\n GetChannelResponse,\n GetChannelError,\n GetPlaylistData,\n GetPlaylistResponse,\n GetPlaylistError,\n GetSuggestionsData,\n GetSuggestionsResponse,\n GetSuggestionsError,\n GetCreditsData,\n GetCreditsResponse,\n GetCreditsError,\n GetLogsData,\n GetLogsResponse,\n GetLogsError,\n GetUsageData,\n GetUsageResponse,\n GetUsageError,\n} from \"./types.gen\";\nimport { client as _heyApiClient } from \"./client.gen\";\n\nexport type Options<\n TData extends TDataShape = TDataShape,\n ThrowOnError extends boolean = boolean\n> = ClientOptions<TData, ThrowOnError> & {\n /**\n * You can provide a client instance returned by `createClient()` instead of\n * individual options. This might be also useful if you want to implement a\n * custom client.\n */\n client?: Client;\n /**\n * You can pass arbitrary values through the `meta` object. This can be\n * used to access values that aren't defined as part of the SDK function.\n */\n meta?: Record<string, unknown>;\n};\n\n/**\n * Video\n * Fetch video details, transcript, comments, replies, or live chat. Pass type: details for metadata, transcript for timestamped captions, comments for top-level comments, replies for a comment thread (pass the repliesToken from a comment as continuationToken), or livechat for live stream chat messages.\n */\nexport const getVideo = <ThrowOnError extends boolean = false>(\n options: Options<GetVideoData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).post<\n GetVideoResponse,\n GetVideoError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/video\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n ...options?.headers,\n },\n });\n};\n\n/**\n * Search\n * Search YouTube with optional filters for content type, sort order, upload date, duration, and features. Returns paginated results.\n */\nexport const searchVideos = <ThrowOnError extends boolean = false>(\n options: Options<SearchVideosData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).post<\n SearchVideosResponse,\n SearchVideosError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/search\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n ...options?.headers,\n },\n });\n};\n\n/**\n * Channel\n * Retrieve channel metadata and content by channelUrl. Use the tab field to switch between videos, shorts, playlists, and about info.\n */\nexport const getChannel = <ThrowOnError extends boolean = false>(\n options: Options<GetChannelData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).post<\n GetChannelResponse,\n GetChannelError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/channel\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n ...options?.headers,\n },\n });\n};\n\n/**\n * Playlist\n * Retrieve items from a YouTube playlist. Use continuationToken to page through long playlists.\n */\nexport const getPlaylist = <ThrowOnError extends boolean = false>(\n options: Options<GetPlaylistData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).post<\n GetPlaylistResponse,\n GetPlaylistError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/playlist\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n ...options?.headers,\n },\n });\n};\n\n/**\n * Suggest\n * Get YouTube search autocomplete suggestions for a query.\n */\nexport const getSuggestions = <ThrowOnError extends boolean = false>(\n options: Options<GetSuggestionsData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).get<\n GetSuggestionsResponse,\n GetSuggestionsError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/suggest\",\n ...options,\n });\n};\n\n/**\n * Credits\n * Return the current credit balance for the authenticated API key.\n */\nexport const getCredits = <ThrowOnError extends boolean = false>(\n options?: Options<GetCreditsData, ThrowOnError>\n) => {\n return (options?.client ?? _heyApiClient).get<\n GetCreditsResponse,\n GetCreditsError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/credits\",\n ...options,\n });\n};\n\n/**\n * Logs\n * Return recent API request logs for the authenticated key.\n */\nexport const getLogs = <ThrowOnError extends boolean = false>(\n options?: Options<GetLogsData, ThrowOnError>\n) => {\n return (options?.client ?? _heyApiClient).get<\n GetLogsResponse,\n GetLogsError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/logs\",\n ...options,\n });\n};\n\n/**\n * Usage\n * Return daily credit and request counts for the authenticated key.\n */\nexport const getUsage = <ThrowOnError extends boolean = false>(\n options?: Options<GetUsageData, ThrowOnError>\n) => {\n return (options?.client ?? _heyApiClient).get<\n GetUsageResponse,\n GetUsageError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/usage\",\n ...options,\n });\n};\n","import type { ErrorResponse } from \"./generated/types.gen\";\n\n/** Thrown when the Stophy API responds with a non-success status. */\nexport class StophyError extends Error {\n\treadonly code?: ErrorResponse[\"code\"];\n\treadonly status: number;\n\treadonly requestId?: string;\n\treadonly details?: unknown;\n\n\tconstructor(\n\t\tmessage: string,\n\t\toptions: {\n\t\t\tstatus: number;\n\t\t\tcode?: ErrorResponse[\"code\"];\n\t\t\trequestId?: string;\n\t\t\tdetails?: unknown;\n\t\t},\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"StophyError\";\n\t\tthis.status = options.status;\n\t\tthis.code = options.code;\n\t\tthis.requestId = options.requestId;\n\t\tthis.details = options.details;\n\t}\n}\n","import { type Client, createClient, createConfig } from \"@hey-api/client-fetch\";\nimport { StophyError } from \"./errors\";\nimport type { ErrorResponse } from \"./generated/types.gen\";\n\nconst DEFAULT_BASE_URL = \"https://api.stophy.dev\";\nconst RETRYABLE_STATUS = new Set([429, 500, 502, 503, 504]);\n\nexport interface TransportOptions {\n\tapiKey: string;\n\tbaseUrl?: string;\n\tfetch?: typeof globalThis.fetch;\n\theaders?: Record<string, string>;\n\tmaxRetries?: number;\n\tretryInitialDelayMs?: number;\n}\n\nexport function createTransport(options: TransportOptions): Client {\n\tconst baseFetch = options.fetch ?? globalThis.fetch;\n\treturn createClient(\n\t\tcreateConfig({\n\t\t\tbaseUrl: options.baseUrl ?? DEFAULT_BASE_URL,\n\t\t\tauth: () => options.apiKey,\n\t\t\theaders: options.headers,\n\t\t\tfetch: withRetries(\n\t\t\t\tbaseFetch,\n\t\t\t\toptions.maxRetries ?? 2,\n\t\t\t\toptions.retryInitialDelayMs ?? 500,\n\t\t\t),\n\t\t}),\n\t);\n}\n\ntype FetchFn = (\n\tinput: Request | URL | string,\n\tinit?: RequestInit,\n) => Promise<Response>;\n\nfunction withRetries(\n\tbaseFetch: typeof globalThis.fetch,\n\tmaxRetries: number,\n\tinitialDelayMs: number,\n): FetchFn {\n\tif (maxRetries <= 0) return baseFetch;\n\n\treturn async (input, init) => {\n\t\tfor (let attempt = 0; ; attempt++) {\n\t\t\tconst request = input instanceof Request ? input.clone() : input;\n\t\t\ttry {\n\t\t\t\tconst response = await baseFetch(request, init);\n\t\t\t\tif (attempt < maxRetries && RETRYABLE_STATUS.has(response.status)) {\n\t\t\t\t\tawait sleep(\n\t\t\t\t\t\tretryAfterMs(response) ?? backoffMs(attempt, initialDelayMs),\n\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\treturn response;\n\t\t\t} catch (error) {\n\t\t\t\tif (attempt >= maxRetries) throw error;\n\t\t\t\tawait sleep(backoffMs(attempt, initialDelayMs));\n\t\t\t}\n\t\t}\n\t};\n}\n\nfunction backoffMs(attempt: number, base: number): number {\n\tconst window = base * 2 ** attempt;\n\treturn window / 2 + Math.random() * (window / 2);\n}\n\nfunction retryAfterMs(response: Response): number | null {\n\tconst header = response.headers.get(\"retry-after\");\n\tif (!header) return null;\n\tconst seconds = Number(header);\n\tif (!Number.isNaN(seconds)) return seconds * 1000;\n\tconst date = Date.parse(header);\n\treturn Number.isNaN(date) ? null : Math.max(0, date - Date.now());\n}\n\nfunction sleep(ms: number): Promise<void> {\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport function unwrap<T>(result: {\n\tdata?: T;\n\terror?: unknown;\n\tresponse: Response;\n}): T {\n\tif (result.error === undefined && result.data !== undefined)\n\t\treturn result.data;\n\n\tconst error = (result.error ?? {}) as Partial<ErrorResponse>;\n\tthrow new StophyError(\n\t\terror.error ??\n\t\t\t`Stophy request failed with status ${result.response.status}`,\n\t\t{\n\t\t\tstatus: result.response.status,\n\t\t\tcode: error.code,\n\t\t\trequestId: result.response.headers.get(\"x-request-id\") ?? undefined,\n\t\t\tdetails: error.details,\n\t\t},\n\t);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { getCredits, getLogs, getUsage } from \"../generated/sdk.gen\";\nimport type {\n\tGetCreditsResponse,\n\tGetLogsData,\n\tGetLogsResponse,\n\tGetUsageData,\n\tGetUsageResponse,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\nexport function credits(client: Client): Promise<GetCreditsResponse> {\n\treturn getCredits({ client }).then(unwrap);\n}\n\nexport function logs(\n\tclient: Client,\n\tquery?: GetLogsData[\"query\"],\n): Promise<GetLogsResponse> {\n\treturn getLogs({ client, query }).then(unwrap);\n}\n\nexport function usage(\n\tclient: Client,\n\tquery?: GetUsageData[\"query\"],\n): Promise<GetUsageResponse> {\n\treturn getUsage({ client, query }).then(unwrap);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { getChannel } from \"../generated/sdk.gen\";\nimport type {\n\tGetChannelData,\n\tGetChannelResponse,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\ntype ChannelBody = GetChannelData[\"body\"];\nexport type ChannelOptions = Omit<ChannelBody, \"channelUrl\">;\n\nexport function channel(\n\tclient: Client,\n\turlOrBody: string | ChannelBody,\n\toptions: ChannelOptions = {},\n): Promise<GetChannelResponse> {\n\tconst body =\n\t\ttypeof urlOrBody === \"string\"\n\t\t\t? { channelUrl: urlOrBody, ...options }\n\t\t\t: urlOrBody;\n\treturn getChannel({ client, body }).then(unwrap);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { getPlaylist } from \"../generated/sdk.gen\";\nimport type {\n\tGetPlaylistData,\n\tGetPlaylistResponse,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\ntype PlaylistBody = GetPlaylistData[\"body\"];\nexport type PlaylistOptions = Omit<PlaylistBody, \"playlistUrl\">;\n\nexport function playlist(\n\tclient: Client,\n\turlOrBody: string | PlaylistBody,\n\toptions: PlaylistOptions = {},\n): Promise<GetPlaylistResponse> {\n\tconst body =\n\t\ttypeof urlOrBody === \"string\"\n\t\t\t? { playlistUrl: urlOrBody, ...options }\n\t\t\t: urlOrBody;\n\treturn getPlaylist({ client, body }).then(unwrap);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { searchVideos } from \"../generated/sdk.gen\";\nimport type {\n\tSearchVideosData,\n\tSearchVideosResponse,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\ntype SearchBody = SearchVideosData[\"body\"];\nexport type SearchOptions = Omit<SearchBody, \"q\">;\n\nexport function search(\n\tclient: Client,\n\tqueryOrBody: string | SearchBody,\n\toptions: SearchOptions = {},\n): Promise<SearchVideosResponse> {\n\tif (typeof queryOrBody === \"string\" && !queryOrBody.trim()) {\n\t\tthrow new Error(\"query cannot be empty\");\n\t}\n\tconst body =\n\t\ttypeof queryOrBody === \"string\"\n\t\t\t? { q: queryOrBody, ...options }\n\t\t\t: queryOrBody;\n\treturn searchVideos({ client, body }).then(unwrap);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { getSuggestions } from \"../generated/sdk.gen\";\nimport type {\n\tGetSuggestionsData,\n\tGetSuggestionsResponse,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\ntype SuggestQuery = GetSuggestionsData[\"query\"];\nexport type SuggestOptions = Omit<SuggestQuery, \"q\">;\n\nexport function suggest(\n\tclient: Client,\n\tqueryOrOptions: string | SuggestQuery,\n\toptions: SuggestOptions = {},\n): Promise<GetSuggestionsResponse> {\n\tif (typeof queryOrOptions === \"string\" && !queryOrOptions.trim()) {\n\t\tthrow new Error(\"query cannot be empty\");\n\t}\n\tconst query =\n\t\ttypeof queryOrOptions === \"string\"\n\t\t\t? { q: queryOrOptions, ...options }\n\t\t\t: queryOrOptions;\n\treturn getSuggestions({ client, query }).then(unwrap);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { getVideo } from \"../generated/sdk.gen\";\nimport type {\n\tCommentsData,\n\tGetVideoData,\n\tGetVideoResponse,\n\tLiveChatData,\n\tTranscriptResult,\n\tVideoDetailsData,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\nexport type VideoResponseFor<T> = Omit<GetVideoResponse, \"data\"> & { data: T };\nexport type CommentsOptions = Pick<\n\tGetVideoData[\"body\"],\n\t\"sortBy\" | \"continuationToken\"\n>;\nexport type LiveChatOptions = Pick<\n\tGetVideoData[\"body\"],\n\t\"chatType\" | \"continuationToken\"\n>;\n\nexport async function video(\n\tclient: Client,\n\tbody: GetVideoData[\"body\"],\n): Promise<GetVideoResponse> {\n\treturn unwrap(await getVideo({ client, body }));\n}\n\nexport function videoDetails(\n\tclient: Client,\n\tvideoUrl: string,\n): Promise<VideoResponseFor<VideoDetailsData>> {\n\treturn video(client, { type: \"details\", videoUrl }) as Promise<\n\t\tVideoResponseFor<VideoDetailsData>\n\t>;\n}\n\nexport function transcript(\n\tclient: Client,\n\tvideoUrl: string,\n): Promise<VideoResponseFor<TranscriptResult>> {\n\treturn video(client, { type: \"transcript\", videoUrl }) as Promise<\n\t\tVideoResponseFor<TranscriptResult>\n\t>;\n}\n\nexport function comments(\n\tclient: Client,\n\tvideoUrl: string,\n\toptions: CommentsOptions = {},\n): Promise<VideoResponseFor<CommentsData>> {\n\treturn video(client, {\n\t\ttype: \"comments\",\n\t\tvideoUrl,\n\t\t...options,\n\t}) as Promise<VideoResponseFor<CommentsData>>;\n}\n\nexport function replies(\n\tclient: Client,\n\tcontinuationToken: string,\n): Promise<VideoResponseFor<CommentsData>> {\n\treturn video(client, {\n\t\ttype: \"replies\",\n\t\tcontinuationToken,\n\t} as GetVideoData[\"body\"]) as Promise<VideoResponseFor<CommentsData>>;\n}\n\nexport function liveChat(\n\tclient: Client,\n\tvideoUrl: string,\n\toptions: LiveChatOptions = {},\n): Promise<VideoResponseFor<LiveChatData>> {\n\treturn video(client, {\n\t\ttype: \"livechat\",\n\t\tvideoUrl,\n\t\t...options,\n\t}) as Promise<VideoResponseFor<LiveChatData>>;\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport type {\n\tCommentsData,\n\tGetChannelData,\n\tGetChannelResponse,\n\tGetCreditsResponse,\n\tGetLogsData,\n\tGetLogsResponse,\n\tGetPlaylistData,\n\tGetPlaylistResponse,\n\tGetSuggestionsData,\n\tGetSuggestionsResponse,\n\tGetUsageData,\n\tGetUsageResponse,\n\tGetVideoData,\n\tGetVideoResponse,\n\tLiveChatData,\n\tSearchVideosData,\n\tSearchVideosResponse,\n\tTranscriptResult,\n\tVideoDetailsData,\n} from \"./generated/types.gen\";\nimport * as accountMethods from \"./methods/account\";\nimport { type ChannelOptions, channel as getChannel } from \"./methods/channel\";\nimport {\n\tplaylist as getPlaylist,\n\ttype PlaylistOptions,\n} from \"./methods/playlist\";\nimport { type SearchOptions, search as searchVideos } from \"./methods/search\";\nimport {\n\tsuggest as getSuggestions,\n\ttype SuggestOptions,\n} from \"./methods/suggest\";\nimport type {\n\tCommentsOptions,\n\tLiveChatOptions,\n\tVideoResponseFor,\n} from \"./methods/video\";\nimport * as videoMethods from \"./methods/video\";\nimport { createTransport } from \"./transport\";\n\nexport interface StophyOptions {\n\t/** Defaults to `STOPHY_API_KEY`. */\n\tapiKey?: string;\n\t/** Defaults to `STOPHY_BASE_URL` or `https://api.stophy.dev`. */\n\tbaseUrl?: string;\n\tfetch?: typeof globalThis.fetch;\n\theaders?: Record<string, string>;\n\tmaxRetries?: number;\n\tretryInitialDelayMs?: number;\n}\n\nexport type StophyClientInput = StophyOptions | string;\n\nfunction env(name: string): string | undefined {\n\treturn typeof process === \"undefined\" ? undefined : process.env[name];\n}\n\n/** Typed client for the Stophy API. */\nexport class Stophy {\n\treadonly client: Client;\n\n\tconstructor(input: StophyClientInput = {}) {\n\t\tconst options = typeof input === \"string\" ? { apiKey: input } : input;\n\t\tconst apiKey = options.apiKey?.trim() || env(\"STOPHY_API_KEY\")?.trim();\n\t\tif (!apiKey) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Stophy: provide `apiKey` or set the STOPHY_API_KEY environment variable.\",\n\t\t\t);\n\t\t}\n\n\t\tthis.client = createTransport({\n\t\t\t...options,\n\t\t\tapiKey,\n\t\t\tbaseUrl: options.baseUrl ?? env(\"STOPHY_BASE_URL\"),\n\t\t});\n\t}\n\n\tasync video(\n\t\tbody: GetVideoData[\"body\"] & { type: \"details\" },\n\t): Promise<VideoResponseFor<VideoDetailsData>>;\n\tasync video(\n\t\tbody: GetVideoData[\"body\"] & { type: \"transcript\" },\n\t): Promise<VideoResponseFor<TranscriptResult>>;\n\tasync video(\n\t\tbody: GetVideoData[\"body\"] & { type: \"comments\" | \"replies\" },\n\t): Promise<VideoResponseFor<CommentsData>>;\n\tasync video(\n\t\tbody: GetVideoData[\"body\"] & { type: \"livechat\" },\n\t): Promise<VideoResponseFor<LiveChatData>>;\n\tasync video(body: GetVideoData[\"body\"]): Promise<GetVideoResponse>;\n\tasync video(body: GetVideoData[\"body\"]): Promise<GetVideoResponse> {\n\t\treturn videoMethods.video(this.client, body);\n\t}\n\n\tvideoDetails(videoUrl: string): Promise<VideoResponseFor<VideoDetailsData>> {\n\t\treturn videoMethods.videoDetails(this.client, videoUrl);\n\t}\n\n\ttranscript(videoUrl: string): Promise<VideoResponseFor<TranscriptResult>> {\n\t\treturn videoMethods.transcript(this.client, videoUrl);\n\t}\n\n\tcomments(\n\t\tvideoUrl: string,\n\t\toptions?: CommentsOptions,\n\t): Promise<VideoResponseFor<CommentsData>> {\n\t\treturn videoMethods.comments(this.client, videoUrl, options);\n\t}\n\n\treplies(continuationToken: string): Promise<VideoResponseFor<CommentsData>> {\n\t\treturn videoMethods.replies(this.client, continuationToken);\n\t}\n\n\tliveChat(\n\t\tvideoUrl: string,\n\t\toptions?: LiveChatOptions,\n\t): Promise<VideoResponseFor<LiveChatData>> {\n\t\treturn videoMethods.liveChat(this.client, videoUrl, options);\n\t}\n\n\tasync search(body: SearchVideosData[\"body\"]): Promise<SearchVideosResponse>;\n\tasync search(\n\t\tquery: string,\n\t\toptions?: SearchOptions,\n\t): Promise<SearchVideosResponse>;\n\tasync search(\n\t\tqueryOrBody: string | SearchVideosData[\"body\"],\n\t\toptions?: SearchOptions,\n\t): Promise<SearchVideosResponse> {\n\t\treturn searchVideos(this.client, queryOrBody, options);\n\t}\n\n\tasync channel(body: GetChannelData[\"body\"]): Promise<GetChannelResponse>;\n\tasync channel(\n\t\tchannelUrl: string,\n\t\toptions?: ChannelOptions,\n\t): Promise<GetChannelResponse>;\n\tasync channel(\n\t\turlOrBody: string | GetChannelData[\"body\"],\n\t\toptions?: ChannelOptions,\n\t): Promise<GetChannelResponse> {\n\t\treturn getChannel(this.client, urlOrBody, options);\n\t}\n\n\tasync playlist(body: GetPlaylistData[\"body\"]): Promise<GetPlaylistResponse>;\n\tasync playlist(\n\t\tplaylistUrl: string,\n\t\toptions?: PlaylistOptions,\n\t): Promise<GetPlaylistResponse>;\n\tasync playlist(\n\t\turlOrBody: string | GetPlaylistData[\"body\"],\n\t\toptions?: PlaylistOptions,\n\t): Promise<GetPlaylistResponse> {\n\t\treturn getPlaylist(this.client, urlOrBody, options);\n\t}\n\n\tasync suggest(\n\t\tquery: GetSuggestionsData[\"query\"],\n\t): Promise<GetSuggestionsResponse>;\n\tasync suggest(\n\t\tquery: string,\n\t\toptions?: SuggestOptions,\n\t): Promise<GetSuggestionsResponse>;\n\tasync suggest(\n\t\tqueryOrOptions: string | GetSuggestionsData[\"query\"],\n\t\toptions?: SuggestOptions,\n\t): Promise<GetSuggestionsResponse> {\n\t\treturn getSuggestions(this.client, queryOrOptions, options);\n\t}\n\n\tcredits(): Promise<GetCreditsResponse> {\n\t\treturn accountMethods.credits(this.client);\n\t}\n\n\tlogs(query?: GetLogsData[\"query\"]): Promise<GetLogsResponse> {\n\t\treturn accountMethods.logs(this.client, query);\n\t}\n\n\tusage(query?: GetUsageData[\"query\"]): Promise<GetUsageResponse> {\n\t\treturn accountMethods.usage(this.client, query);\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../src/generated/client.gen.ts","../src/generated/sdk.gen.ts","../src/errors.ts","../src/transport.ts","../src/methods/account.ts","../src/methods/channel.ts","../src/methods/playlist.ts","../src/methods/search.ts","../src/methods/suggest.ts","../src/methods/video.ts","../src/client.ts"],"names":["createClient","createConfig","client"],"mappings":";;;;;;;AAuBO,IAAM,MAAA,GAASA,wBAAA;AAAA,EACpBC,wBAAA,CAA4B;AAAA,IAC1B,OAAA,EAAS;AAAA,GACV;AACH,CAAA;;;AC6BO,IAAM,QAAA,GAAW,CACtB,OAAA,KACG;AACH,EAAA,OAAA,CAAQ,OAAA,CAAQ,MAAA,IAAU,MAAA,EAAe,IAAA,CAIvC;AAAA,IACA,QAAA,EAAU;AAAA,MACR;AAAA,QACE,MAAA,EAAQ,QAAA;AAAA,QACR,IAAA,EAAM;AAAA;AACR,KACF;AAAA,IACA,GAAA,EAAK,WAAA;AAAA,IACL,GAAG,OAAA;AAAA,IACH,OAAA,EAAS;AAAA,MACP,cAAA,EAAgB,kBAAA;AAAA,MAChB,GAAG,OAAA,EAAS;AAAA;AACd,GACD,CAAA;AACH,CAAA;AAMO,IAAM,YAAA,GAAe,CAC1B,OAAA,KACG;AACH,EAAA,OAAA,CAAQ,OAAA,CAAQ,MAAA,IAAU,MAAA,EAAe,IAAA,CAIvC;AAAA,IACA,QAAA,EAAU;AAAA,MACR;AAAA,QACE,MAAA,EAAQ,QAAA;AAAA,QACR,IAAA,EAAM;AAAA;AACR,KACF;AAAA,IACA,GAAA,EAAK,YAAA;AAAA,IACL,GAAG,OAAA;AAAA,IACH,OAAA,EAAS;AAAA,MACP,cAAA,EAAgB,kBAAA;AAAA,MAChB,G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MAAM,QAAA,CACL,SAAA,EACA,OAAA,EAC+B;AAC/B,IAAA,OAAO,QAAA,CAAY,IAAA,CAAK,MAAA,EAAQ,SAAA,EAAW,OAAO,CAAA;AAAA,EACnD;AAAA,EASA,MAAM,OAAA,CACL,cAAA,EACA,OAAA,EACkC;AAClC,IAAA,OAAO,OAAA,CAAe,IAAA,CAAK,MAAA,EAAQ,cAAA,EAAgB,OAAO,CAAA;AAAA,EAC3D;AAAA,EAEA,OAAA,GAAuC;AACtC,IAAA,OAAsB,OAAA,CAAQ,KAAK,MAAM,CAAA;AAAA,EAC1C;AAAA,EAEA,KAAK,KAAA,EAAwD;AAC5D,IAAA,OAAsB,IAAA,CAAK,IAAA,CAAK,MAAA,EAAQ,KAAK,CAAA;AAAA,EAC9C;AAAA,EAEA,MAAM,KAAA,EAA0D;AAC/D,IAAA,OAAsB,KAAA,CAAM,IAAA,CAAK,MAAA,EAAQ,KAAK,CAAA;AAAA,EAC/C;AACD","file":"index.cjs","sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nimport type { ClientOptions } from \"./types.gen\";\nimport {\n type Config,\n type ClientOptions as DefaultClientOptions,\n createClient,\n createConfig,\n} from \"@hey-api/client-fetch\";\n\n/**\n * The `createClientConfig()` function will be called on client initialization\n * and the returned object will become the client's initial configuration.\n *\n * You may want to initialize your client this way instead of calling\n * `setConfig()`. This is useful for example if you're using Next.js\n * to ensure your client always has the correct values.\n */\nexport type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> =\n (\n override?: Config<DefaultClientOptions & T>\n ) => Config<Required<DefaultClientOptions> & T>;\n\nexport const client = createClient(\n createConfig<ClientOptions>({\n baseUrl: \"https://api.stophy.dev\",\n })\n);\n","// This file is auto-generated by @hey-api/openapi-ts\n\nimport type {\n Options as ClientOptions,\n TDataShape,\n Client,\n} from \"@hey-api/client-fetch\";\nimport type {\n GetVideoData,\n GetVideoResponse,\n GetVideoError,\n SearchVideosData,\n SearchVideosResponse,\n SearchVideosError,\n GetChannelData,\n GetChannelResponse,\n GetChannelError,\n GetPlaylistData,\n GetPlaylistResponse,\n GetPlaylistError,\n GetSuggestionsData,\n GetSuggestionsResponse,\n GetSuggestionsError,\n GetCreditsData,\n GetCreditsResponse,\n GetCreditsError,\n GetLogsData,\n GetLogsResponse,\n GetLogsError,\n GetUsageData,\n GetUsageResponse,\n GetUsageError,\n} from \"./types.gen\";\nimport { client as _heyApiClient } from \"./client.gen\";\n\nexport type Options<\n TData extends TDataShape = TDataShape,\n ThrowOnError extends boolean = boolean\n> = ClientOptions<TData, ThrowOnError> & {\n /**\n * You can provide a client instance returned by `createClient()` instead of\n * individual options. This might be also useful if you want to implement a\n * custom client.\n */\n client?: Client;\n /**\n * You can pass arbitrary values through the `meta` object. This can be\n * used to access values that aren't defined as part of the SDK function.\n */\n meta?: Record<string, unknown>;\n};\n\n/**\n * Video\n * Fetch video details, transcript, comments, replies, or live chat. Pass type: details for metadata, transcript for timestamped captions, comments for top-level comments, replies for a comment thread (pass the repliesToken from a comment as continuationToken), or livechat for live stream chat messages.\n */\nexport const getVideo = <ThrowOnError extends boolean = false>(\n options: Options<GetVideoData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).post<\n GetVideoResponse,\n GetVideoError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/video\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n ...options?.headers,\n },\n });\n};\n\n/**\n * Search\n * Search YouTube with optional filters for content type, sort order, upload date, duration, and features. Returns paginated results.\n */\nexport const searchVideos = <ThrowOnError extends boolean = false>(\n options: Options<SearchVideosData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).post<\n SearchVideosResponse,\n SearchVideosError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/search\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n ...options?.headers,\n },\n });\n};\n\n/**\n * Channel\n * Retrieve channel metadata and content by channelUrl. Use the tab field to switch between videos, shorts, playlists, and about info.\n */\nexport const getChannel = <ThrowOnError extends boolean = false>(\n options: Options<GetChannelData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).post<\n GetChannelResponse,\n GetChannelError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/channel\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n ...options?.headers,\n },\n });\n};\n\n/**\n * Playlist\n * Retrieve items from a YouTube playlist. Use continuationToken to page through long playlists.\n */\nexport const getPlaylist = <ThrowOnError extends boolean = false>(\n options: Options<GetPlaylistData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).post<\n GetPlaylistResponse,\n GetPlaylistError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/playlist\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n ...options?.headers,\n },\n });\n};\n\n/**\n * Suggest\n * Get YouTube search autocomplete suggestions for a query.\n */\nexport const getSuggestions = <ThrowOnError extends boolean = false>(\n options: Options<GetSuggestionsData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).get<\n GetSuggestionsResponse,\n GetSuggestionsError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/suggest\",\n ...options,\n });\n};\n\n/**\n * Credits\n * Return the current credit balance for the authenticated API key.\n */\nexport const getCredits = <ThrowOnError extends boolean = false>(\n options?: Options<GetCreditsData, ThrowOnError>\n) => {\n return (options?.client ?? _heyApiClient).get<\n GetCreditsResponse,\n GetCreditsError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/credits\",\n ...options,\n });\n};\n\n/**\n * Logs\n * Return recent API request logs for the authenticated key.\n */\nexport const getLogs = <ThrowOnError extends boolean = false>(\n options?: Options<GetLogsData, ThrowOnError>\n) => {\n return (options?.client ?? _heyApiClient).get<\n GetLogsResponse,\n GetLogsError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/logs\",\n ...options,\n });\n};\n\n/**\n * Usage\n * Return daily credit and request counts for the authenticated key.\n */\nexport const getUsage = <ThrowOnError extends boolean = false>(\n options?: Options<GetUsageData, ThrowOnError>\n) => {\n return (options?.client ?? _heyApiClient).get<\n GetUsageResponse,\n GetUsageError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/usage\",\n ...options,\n });\n};\n","import type { ErrorResponse } from \"./generated/types.gen\";\n\n/** Thrown when the Stophy API responds with a non-success status. */\nexport class StophyError extends Error {\n\treadonly code?: ErrorResponse[\"code\"];\n\treadonly status: number;\n\treadonly requestId?: string;\n\treadonly details?: unknown;\n\n\tconstructor(\n\t\tmessage: string,\n\t\toptions: {\n\t\t\tstatus: number;\n\t\t\tcode?: ErrorResponse[\"code\"];\n\t\t\trequestId?: string;\n\t\t\tdetails?: unknown;\n\t\t},\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"StophyError\";\n\t\tthis.status = options.status;\n\t\tthis.code = options.code;\n\t\tthis.requestId = options.requestId;\n\t\tthis.details = options.details;\n\t}\n}\n","import { type Client, createClient, createConfig } from \"@hey-api/client-fetch\";\nimport { StophyError } from \"./errors\";\nimport type { ErrorResponse } from \"./generated/types.gen\";\n\nconst DEFAULT_BASE_URL = \"https://api.stophy.dev\";\nconst RETRYABLE_STATUS = new Set([429, 500, 502, 503, 504]);\n\nexport interface TransportOptions {\n\tapiKey: string;\n\tbaseUrl?: string;\n\tfetch?: typeof globalThis.fetch;\n\theaders?: Record<string, string>;\n\tmaxRetries?: number;\n\tretryInitialDelayMs?: number;\n}\n\nexport function createTransport(options: TransportOptions): Client {\n\tconst baseFetch = options.fetch ?? globalThis.fetch;\n\treturn createClient(\n\t\tcreateConfig({\n\t\t\tbaseUrl: options.baseUrl ?? DEFAULT_BASE_URL,\n\t\t\tauth: () => options.apiKey,\n\t\t\theaders: options.headers,\n\t\t\tfetch: withRetries(\n\t\t\t\tbaseFetch,\n\t\t\t\toptions.maxRetries ?? 2,\n\t\t\t\toptions.retryInitialDelayMs ?? 500,\n\t\t\t),\n\t\t}),\n\t);\n}\n\ntype FetchFn = (\n\tinput: Request | URL | string,\n\tinit?: RequestInit,\n) => Promise<Response>;\n\nfunction withRetries(\n\tbaseFetch: typeof globalThis.fetch,\n\tmaxRetries: number,\n\tinitialDelayMs: number,\n): FetchFn {\n\tif (maxRetries <= 0) return baseFetch;\n\n\treturn async (input, init) => {\n\t\tfor (let attempt = 0; ; attempt++) {\n\t\t\tconst request = input instanceof Request ? input.clone() : input;\n\t\t\ttry {\n\t\t\t\tconst response = await baseFetch(request, init);\n\t\t\t\tif (attempt < maxRetries && RETRYABLE_STATUS.has(response.status)) {\n\t\t\t\t\tawait sleep(\n\t\t\t\t\t\tretryAfterMs(response) ?? backoffMs(attempt, initialDelayMs),\n\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\treturn response;\n\t\t\t} catch (error) {\n\t\t\t\tif (attempt >= maxRetries) throw error;\n\t\t\t\tawait sleep(backoffMs(attempt, initialDelayMs));\n\t\t\t}\n\t\t}\n\t};\n}\n\nfunction backoffMs(attempt: number, base: number): number {\n\tconst window = base * 2 ** attempt;\n\treturn window / 2 + Math.random() * (window / 2);\n}\n\nfunction retryAfterMs(response: Response): number | null {\n\tconst header = response.headers.get(\"retry-after\");\n\tif (!header) return null;\n\tconst seconds = Number(header);\n\tif (!Number.isNaN(seconds)) return seconds * 1000;\n\tconst date = Date.parse(header);\n\treturn Number.isNaN(date) ? null : Math.max(0, date - Date.now());\n}\n\nfunction sleep(ms: number): Promise<void> {\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport function unwrap<T>(result: {\n\tdata?: T;\n\terror?: unknown;\n\tresponse: Response;\n}): T {\n\tif (result.error === undefined && result.data !== undefined)\n\t\treturn result.data;\n\n\tconst error = (result.error ?? {}) as Partial<ErrorResponse>;\n\tthrow new StophyError(\n\t\terror.error ??\n\t\t\t`Stophy request failed with status ${result.response.status}`,\n\t\t{\n\t\t\tstatus: result.response.status,\n\t\t\tcode: error.code,\n\t\t\trequestId: result.response.headers.get(\"x-request-id\") ?? undefined,\n\t\t\tdetails: error.details,\n\t\t},\n\t);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { getCredits, getLogs, getUsage } from \"../generated/sdk.gen\";\nimport type {\n\tGetCreditsResponse,\n\tGetLogsData,\n\tGetLogsResponse,\n\tGetUsageData,\n\tGetUsageResponse,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\nexport function credits(client: Client): Promise<GetCreditsResponse> {\n\treturn getCredits({ client }).then(unwrap);\n}\n\nexport function logs(\n\tclient: Client,\n\tquery?: GetLogsData[\"query\"],\n): Promise<GetLogsResponse> {\n\treturn getLogs({ client, query }).then(unwrap);\n}\n\nexport function usage(\n\tclient: Client,\n\tquery?: GetUsageData[\"query\"],\n): Promise<GetUsageResponse> {\n\treturn getUsage({ client, query }).then(unwrap);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { getChannel } from \"../generated/sdk.gen\";\nimport type {\n\tGetChannelData,\n\tGetChannelResponse,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\ntype ChannelBody = GetChannelData[\"body\"];\nexport type ChannelOptions = Omit<ChannelBody, \"channelUrl\">;\n\nexport function channel(\n\tclient: Client,\n\turlOrBody: string | ChannelBody,\n\toptions: ChannelOptions = {},\n): Promise<GetChannelResponse> {\n\tconst body =\n\t\ttypeof urlOrBody === \"string\"\n\t\t\t? { channelUrl: urlOrBody, ...options }\n\t\t\t: urlOrBody;\n\treturn getChannel({ client, body }).then(unwrap);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { getPlaylist } from \"../generated/sdk.gen\";\nimport type {\n\tGetPlaylistData,\n\tGetPlaylistResponse,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\ntype PlaylistBody = GetPlaylistData[\"body\"];\nexport type PlaylistOptions = Omit<PlaylistBody, \"playlistUrl\">;\n\nexport function playlist(\n\tclient: Client,\n\turlOrBody: string | PlaylistBody,\n\toptions: PlaylistOptions = {},\n): Promise<GetPlaylistResponse> {\n\tconst body =\n\t\ttypeof urlOrBody === \"string\"\n\t\t\t? { playlistUrl: urlOrBody, ...options }\n\t\t\t: urlOrBody;\n\treturn getPlaylist({ client, body }).then(unwrap);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { searchVideos } from \"../generated/sdk.gen\";\nimport type {\n\tSearchVideosData,\n\tSearchVideosResponse,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\ntype SearchBody = SearchVideosData[\"body\"];\nexport type SearchOptions = Omit<SearchBody, \"q\">;\n\nexport function search(\n\tclient: Client,\n\tqueryOrBody: string | SearchBody,\n\toptions: SearchOptions = {},\n): Promise<SearchVideosResponse> {\n\tif (typeof queryOrBody === \"string\" && !queryOrBody.trim()) {\n\t\tthrow new Error(\"query cannot be empty\");\n\t}\n\tconst body =\n\t\ttypeof queryOrBody === \"string\"\n\t\t\t? { q: queryOrBody, ...options }\n\t\t\t: queryOrBody;\n\treturn searchVideos({ client, body }).then(unwrap);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { getSuggestions } from \"../generated/sdk.gen\";\nimport type {\n\tGetSuggestionsData,\n\tGetSuggestionsResponse,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\ntype SuggestQuery = GetSuggestionsData[\"query\"];\nexport type SuggestOptions = Omit<SuggestQuery, \"q\">;\n\nexport function suggest(\n\tclient: Client,\n\tqueryOrOptions: string | SuggestQuery,\n\toptions: SuggestOptions = {},\n): Promise<GetSuggestionsResponse> {\n\tif (typeof queryOrOptions === \"string\" && !queryOrOptions.trim()) {\n\t\tthrow new Error(\"query cannot be empty\");\n\t}\n\tconst query =\n\t\ttypeof queryOrOptions === \"string\"\n\t\t\t? { q: queryOrOptions, ...options }\n\t\t\t: queryOrOptions;\n\treturn getSuggestions({ client, query }).then(unwrap);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { getVideo } from \"../generated/sdk.gen\";\nimport type {\n\tCommentsData,\n\tGetVideoData,\n\tGetVideoResponse,\n\tLiveChatData,\n\tTranscriptResult,\n\tVideoDetailsData,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\nexport type VideoResponseFor<T> = Omit<GetVideoResponse, \"data\"> & { data: T };\ntype VideoUrlBody = Extract<GetVideoData[\"body\"], { videoUrl: string }>;\nexport type CommentsOptions = Pick<\n\tVideoUrlBody,\n\t\"sortBy\" | \"continuationToken\"\n>;\nexport type LiveChatOptions = Pick<\n\tVideoUrlBody,\n\t\"chatType\" | \"continuationToken\"\n>;\n\nexport async function video(\n\tclient: Client,\n\tbody: GetVideoData[\"body\"],\n): Promise<GetVideoResponse> {\n\treturn unwrap(await getVideo({ client, body }));\n}\n\nexport function videoDetails(\n\tclient: Client,\n\tvideoUrl: string,\n): Promise<VideoResponseFor<VideoDetailsData>> {\n\treturn video(client, { type: \"details\", videoUrl }) as Promise<\n\t\tVideoResponseFor<VideoDetailsData>\n\t>;\n}\n\nexport function transcript(\n\tclient: Client,\n\tvideoUrl: string,\n): Promise<VideoResponseFor<TranscriptResult>> {\n\treturn video(client, { type: \"transcript\", videoUrl }) as Promise<\n\t\tVideoResponseFor<TranscriptResult>\n\t>;\n}\n\nexport function comments(\n\tclient: Client,\n\tvideoUrl: string,\n\toptions: CommentsOptions = {},\n): Promise<VideoResponseFor<CommentsData>> {\n\treturn video(client, {\n\t\ttype: \"comments\",\n\t\tvideoUrl,\n\t\t...options,\n\t}) as Promise<VideoResponseFor<CommentsData>>;\n}\n\nexport function replies(\n\tclient: Client,\n\tcontinuationToken: string,\n): Promise<VideoResponseFor<CommentsData>> {\n\treturn video(client, {\n\t\ttype: \"replies\",\n\t\tcontinuationToken,\n\t}) as Promise<VideoResponseFor<CommentsData>>;\n}\n\nexport function liveChat(\n\tclient: Client,\n\tvideoUrl: string,\n\toptions: LiveChatOptions = {},\n): Promise<VideoResponseFor<LiveChatData>> {\n\treturn video(client, {\n\t\ttype: \"livechat\",\n\t\tvideoUrl,\n\t\t...options,\n\t}) as Promise<VideoResponseFor<LiveChatData>>;\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport type {\n\tCommentsData,\n\tGetChannelData,\n\tGetChannelResponse,\n\tGetCreditsResponse,\n\tGetLogsData,\n\tGetLogsResponse,\n\tGetPlaylistData,\n\tGetPlaylistResponse,\n\tGetSuggestionsData,\n\tGetSuggestionsResponse,\n\tGetUsageData,\n\tGetUsageResponse,\n\tGetVideoData,\n\tGetVideoResponse,\n\tLiveChatData,\n\tSearchVideosData,\n\tSearchVideosResponse,\n\tTranscriptResult,\n\tVideoDetailsData,\n} from \"./generated/types.gen\";\nimport * as accountMethods from \"./methods/account\";\nimport { type ChannelOptions, channel as getChannel } from \"./methods/channel\";\nimport {\n\tplaylist as getPlaylist,\n\ttype PlaylistOptions,\n} from \"./methods/playlist\";\nimport { type SearchOptions, search as searchVideos } from \"./methods/search\";\nimport {\n\tsuggest as getSuggestions,\n\ttype SuggestOptions,\n} from \"./methods/suggest\";\nimport type {\n\tCommentsOptions,\n\tLiveChatOptions,\n\tVideoResponseFor,\n} from \"./methods/video\";\nimport * as videoMethods from \"./methods/video\";\nimport { createTransport } from \"./transport\";\n\nexport interface StophyOptions {\n\t/** Defaults to `STOPHY_API_KEY`. */\n\tapiKey?: string;\n\t/** Defaults to `STOPHY_BASE_URL` or `https://api.stophy.dev`. */\n\tbaseUrl?: string;\n\tfetch?: typeof globalThis.fetch;\n\theaders?: Record<string, string>;\n\tmaxRetries?: number;\n\tretryInitialDelayMs?: number;\n}\n\nexport type StophyClientInput = StophyOptions | string;\n\nfunction env(name: string): string | undefined {\n\treturn typeof process === \"undefined\" ? undefined : process.env[name];\n}\n\n/** Typed client for the Stophy API. */\nexport class Stophy {\n\treadonly client: Client;\n\n\tconstructor(input: StophyClientInput = {}) {\n\t\tconst options = typeof input === \"string\" ? { apiKey: input } : input;\n\t\tconst apiKey = options.apiKey?.trim() || env(\"STOPHY_API_KEY\")?.trim();\n\t\tif (!apiKey) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Stophy: provide `apiKey` or set the STOPHY_API_KEY environment variable.\",\n\t\t\t);\n\t\t}\n\n\t\tthis.client = createTransport({\n\t\t\t...options,\n\t\t\tapiKey,\n\t\t\tbaseUrl: options.baseUrl ?? env(\"STOPHY_BASE_URL\"),\n\t\t});\n\t}\n\n\tasync video(\n\t\tbody: GetVideoData[\"body\"] & { type: \"details\" },\n\t): Promise<VideoResponseFor<VideoDetailsData>>;\n\tasync video(\n\t\tbody: GetVideoData[\"body\"] & { type: \"transcript\" },\n\t): Promise<VideoResponseFor<TranscriptResult>>;\n\tasync video(\n\t\tbody: GetVideoData[\"body\"] & { type: \"comments\" | \"replies\" },\n\t): Promise<VideoResponseFor<CommentsData>>;\n\tasync video(\n\t\tbody: GetVideoData[\"body\"] & { type: \"livechat\" },\n\t): Promise<VideoResponseFor<LiveChatData>>;\n\tasync video(body: GetVideoData[\"body\"]): Promise<GetVideoResponse>;\n\tasync video(body: GetVideoData[\"body\"]): Promise<GetVideoResponse> {\n\t\treturn videoMethods.video(this.client, body);\n\t}\n\n\tvideoDetails(videoUrl: string): Promise<VideoResponseFor<VideoDetailsData>> {\n\t\treturn videoMethods.videoDetails(this.client, videoUrl);\n\t}\n\n\ttranscript(videoUrl: string): Promise<VideoResponseFor<TranscriptResult>> {\n\t\treturn videoMethods.transcript(this.client, videoUrl);\n\t}\n\n\tcomments(\n\t\tvideoUrl: string,\n\t\toptions?: CommentsOptions,\n\t): Promise<VideoResponseFor<CommentsData>> {\n\t\treturn videoMethods.comments(this.client, videoUrl, options);\n\t}\n\n\treplies(continuationToken: string): Promise<VideoResponseFor<CommentsData>> {\n\t\treturn videoMethods.replies(this.client, continuationToken);\n\t}\n\n\tliveChat(\n\t\tvideoUrl: string,\n\t\toptions?: LiveChatOptions,\n\t): Promise<VideoResponseFor<LiveChatData>> {\n\t\treturn videoMethods.liveChat(this.client, videoUrl, options);\n\t}\n\n\tasync search(body: SearchVideosData[\"body\"]): Promise<SearchVideosResponse>;\n\tasync search(\n\t\tquery: string,\n\t\toptions?: SearchOptions,\n\t): Promise<SearchVideosResponse>;\n\tasync search(\n\t\tqueryOrBody: string | SearchVideosData[\"body\"],\n\t\toptions?: SearchOptions,\n\t): Promise<SearchVideosResponse> {\n\t\treturn searchVideos(this.client, queryOrBody, options);\n\t}\n\n\tasync channel(body: GetChannelData[\"body\"]): Promise<GetChannelResponse>;\n\tasync channel(\n\t\tchannelUrl: string,\n\t\toptions?: ChannelOptions,\n\t): Promise<GetChannelResponse>;\n\tasync channel(\n\t\turlOrBody: string | GetChannelData[\"body\"],\n\t\toptions?: ChannelOptions,\n\t): Promise<GetChannelResponse> {\n\t\treturn getChannel(this.client, urlOrBody, options);\n\t}\n\n\tasync playlist(body: GetPlaylistData[\"body\"]): Promise<GetPlaylistResponse>;\n\tasync playlist(\n\t\tplaylistUrl: string,\n\t\toptions?: PlaylistOptions,\n\t): Promise<GetPlaylistResponse>;\n\tasync playlist(\n\t\turlOrBody: string | GetPlaylistData[\"body\"],\n\t\toptions?: PlaylistOptions,\n\t): Promise<GetPlaylistResponse> {\n\t\treturn getPlaylist(this.client, urlOrBody, options);\n\t}\n\n\tasync suggest(\n\t\tquery: GetSuggestionsData[\"query\"],\n\t): Promise<GetSuggestionsResponse>;\n\tasync suggest(\n\t\tquery: string,\n\t\toptions?: SuggestOptions,\n\t): Promise<GetSuggestionsResponse>;\n\tasync suggest(\n\t\tqueryOrOptions: string | GetSuggestionsData[\"query\"],\n\t\toptions?: SuggestOptions,\n\t): Promise<GetSuggestionsResponse> {\n\t\treturn getSuggestions(this.client, queryOrOptions, options);\n\t}\n\n\tcredits(): Promise<GetCreditsResponse> {\n\t\treturn accountMethods.credits(this.client);\n\t}\n\n\tlogs(query?: GetLogsData[\"query\"]): Promise<GetLogsResponse> {\n\t\treturn accountMethods.logs(this.client, query);\n\t}\n\n\tusage(query?: GetUsageData[\"query\"]): Promise<GetUsageResponse> {\n\t\treturn accountMethods.usage(this.client, query);\n\t}\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -8,7 +8,7 @@ type ErrorResponse = {
8
8
  /**
9
9
  * Machine-readable error code.
10
10
  */
11
- code?: "UNAUTHORIZED" | "INSUFFICIENT_CREDITS" | "BAD_REQUEST" | "INVALID_INPUT" | "NOT_FOUND" | "CONCURRENCY_LIMITED" | "INTERNAL_ERROR";
11
+ code?: "UNAUTHORIZED" | "INSUFFICIENT_CREDITS" | "BAD_REQUEST" | "INVALID_INPUT" | "NOT_FOUND" | "CONCURRENCY_LIMITED" | "UPSTREAM_UNAVAILABLE" | "INTERNAL_ERROR";
12
12
  /**
13
13
  * Human-readable error message.
14
14
  */
@@ -45,37 +45,37 @@ type TranscriptResult = {
45
45
  };
46
46
  type VideoDetails = {
47
47
  id: string;
48
- type?: "video";
48
+ type: "video";
49
49
  videoUrl: string;
50
50
  title: string | null;
51
- author?: string | null;
52
- authorId?: string | null;
53
- category?: string | null;
54
- description?: string | null;
55
- durationSec?: number | null;
56
- durationText?: string | null;
57
- isLive?: boolean;
58
- likeCount?: number | null;
59
- likeCountText?: string | null;
60
- publishedAt?: string | null;
61
- tags?: Array<string>;
62
- viewCount?: number | null;
63
- viewCountText?: string | null;
51
+ author: string | null;
52
+ authorId: string | null;
53
+ category: string | null;
54
+ description: string | null;
55
+ durationSec: number | null;
56
+ durationText: string | null;
57
+ isLive: boolean;
58
+ likeCount: number | null;
59
+ likeCountText: string | null;
60
+ publishedAt: string | null;
61
+ tags: Array<string>;
62
+ viewCount: number | null;
63
+ viewCountText: string | null;
64
64
  thumbnails: Array<Thumbnail>;
65
65
  };
66
66
  type RelatedVideo = {
67
67
  id: string;
68
- type?: "video";
68
+ type: "video";
69
69
  videoUrl: string;
70
- title?: string | null;
71
- author?: string | null;
72
- authorId?: string | null;
73
- durationSec?: number | null;
74
- durationText?: string | null;
75
- publishedAt?: string | null;
76
- publishedAtText?: string | null;
77
- viewCount?: number | null;
78
- viewCountText?: string | null;
70
+ title: string | null;
71
+ author: string | null;
72
+ authorId: string | null;
73
+ durationSec: number | null;
74
+ durationText: string | null;
75
+ publishedAt: string | null;
76
+ publishedAtText: string | null;
77
+ viewCount: number | null;
78
+ viewCountText: string | null;
79
79
  thumbnails: Array<Thumbnail>;
80
80
  };
81
81
  type VideoDetailsData = {
@@ -87,21 +87,29 @@ type Comment = {
87
87
  text: string | null;
88
88
  author: string | null;
89
89
  authorId: string | null;
90
- authorThumbnail?: string | null;
90
+ authorThumbnail: string | null;
91
91
  hasChannelOwnerReplied: boolean;
92
92
  isChannelOwner: boolean;
93
93
  isHearted: boolean;
94
94
  isPinned: boolean;
95
95
  isVerified: boolean;
96
- publishedAt?: string | null;
97
- publishedAtText?: string | null;
98
- likeCount?: number | null;
99
- likeCountText?: string | null;
100
- replyCount?: number | null;
101
- replyCountText?: string | null;
102
- repliesToken?: string | null;
96
+ publishedAt: string | null;
97
+ publishedAtText: string | null;
98
+ likeCount: number | null;
99
+ likeCountText: string | null;
100
+ replyCount: number | null;
101
+ replyCountText: string | null;
102
+ repliesToken: string | null;
103
103
  };
104
104
  type CommentsData = {
105
+ /**
106
+ * Present for top-level comment requests.
107
+ */
108
+ videoId?: string;
109
+ /**
110
+ * Resolved sort order for top-level comment requests.
111
+ */
112
+ sortBy?: "any" | "latest" | "top";
105
113
  items: Array<Comment>;
106
114
  continuationToken: string | null;
107
115
  empty?: EmptyState;
@@ -109,20 +117,20 @@ type CommentsData = {
109
117
  type LiveChatMessage = {
110
118
  id: string;
111
119
  text: string;
112
- author?: string | null;
113
- authorId?: string | null;
114
- timestampUsec?: string | null;
120
+ author: string | null;
121
+ authorId: string | null;
122
+ timestampUsec: string | null;
115
123
  isOwner: boolean;
116
124
  isModerator: boolean;
117
125
  isVerified: boolean;
118
- superChatAmount?: string | null;
119
- superChatCurrency?: string | null;
126
+ superChatAmount: string | null;
127
+ superChatCurrency: string | null;
120
128
  };
121
129
  type LiveChatData = {
122
- status: string;
130
+ status: "live" | "upcoming" | "replay" | "chat_disabled" | "not_live";
123
131
  isLive: boolean;
124
- concurrentViewers?: number | null;
125
- pollIntervalMs?: number | null;
132
+ concurrentViewers: number | null;
133
+ pollIntervalMs: number | null;
126
134
  messages: Array<LiveChatMessage>;
127
135
  continuationToken: string | null;
128
136
  };
@@ -135,19 +143,19 @@ type SearchVideo = {
135
143
  id: string;
136
144
  videoUrl: string;
137
145
  title: string;
138
- author?: string | null;
139
- authorId?: string | null;
140
- description?: string | null;
141
- duration?: string | null;
142
- durationSec?: number | null;
143
- durationText?: string | null;
144
- isLive?: boolean;
145
- isUpcoming?: boolean;
146
- isVerified?: boolean;
147
- viewCount?: number | null;
148
- viewCountText?: string | null;
149
- publishedAt?: string | null;
150
- publishedAtText?: string | null;
146
+ author: string | null;
147
+ authorId: string | null;
148
+ description: string | null;
149
+ duration: string | null;
150
+ durationSec: number | null;
151
+ durationText: string | null;
152
+ isLive: boolean;
153
+ isUpcoming: boolean;
154
+ isVerified: boolean;
155
+ viewCount: number | null;
156
+ viewCountText: string | null;
157
+ publishedAt: string | null;
158
+ publishedAtText: string | null;
151
159
  thumbnails: Array<Thumbnail>;
152
160
  };
153
161
  type SearchShort = {
@@ -155,16 +163,8 @@ type SearchShort = {
155
163
  id: string;
156
164
  shortUrl: string;
157
165
  title: string;
158
- author?: string | null;
159
- authorId?: string | null;
160
- description?: string | null;
161
- duration?: string | null;
162
- durationSec?: number | null;
163
- durationText?: string | null;
164
- viewCount?: number | null;
165
- viewCountText?: string | null;
166
- publishedAt?: string | null;
167
- publishedAtText?: string | null;
166
+ viewCount: number | null;
167
+ viewCountText: string | null;
168
168
  thumbnails: Array<Thumbnail>;
169
169
  };
170
170
  type SearchPlaylist = {
@@ -172,10 +172,10 @@ type SearchPlaylist = {
172
172
  id: string;
173
173
  playlistUrl: string;
174
174
  title: string;
175
- author?: string | null;
176
- authorId?: string | null;
177
- videoCount?: number | null;
178
- videoCountText?: string | null;
175
+ author: string | null;
176
+ authorId: string | null;
177
+ videoCount: number | null;
178
+ videoCountText: string | null;
179
179
  thumbnails: Array<Thumbnail>;
180
180
  };
181
181
  type SearchChannel = {
@@ -183,11 +183,11 @@ type SearchChannel = {
183
183
  id: string;
184
184
  channelUrl: string;
185
185
  name: string;
186
- handle?: string | null;
187
- description?: string | null;
188
- subscriberCount?: number | null;
189
- subscriberCountText?: string | null;
190
- isVerified?: boolean;
186
+ handle: string | null;
187
+ description: string | null;
188
+ subscriberCount: number | null;
189
+ subscriberCountText: string | null;
190
+ isVerified: boolean;
191
191
  thumbnails: Array<Thumbnail>;
192
192
  };
193
193
  type SearchItem = ({
@@ -199,7 +199,16 @@ type SearchItem = ({
199
199
  } & SearchPlaylist) | ({
200
200
  type?: "channel";
201
201
  } & SearchChannel);
202
+ type SearchQuery = {
203
+ q: string;
204
+ type?: "video" | "short" | "channel" | "playlist" | "movie";
205
+ sortBy?: "relevance" | "popularity" | "date" | "rating";
206
+ uploadDate?: "today" | "week" | "month" | "year";
207
+ duration?: "short" | "medium" | "long";
208
+ features?: Array<string>;
209
+ };
202
210
  type SearchData = {
211
+ query: SearchQuery;
203
212
  items: Array<SearchItem>;
204
213
  continuationToken: string | null;
205
214
  estimatedResults?: number;
@@ -214,11 +223,11 @@ type ChannelProfile = {
214
223
  name: string | null;
215
224
  handle: string | null;
216
225
  channelUrl: string | null;
217
- description?: string | null;
218
- subscriberCount?: number | null;
219
- subscriberCountText?: string | null;
220
- videoCount?: number | null;
221
- videoCountText?: string | null;
226
+ description: string | null;
227
+ subscriberCount: number | null;
228
+ subscriberCountText: string | null;
229
+ videoCount: number | null;
230
+ videoCountText: string | null;
222
231
  viewCount?: number | null;
223
232
  viewCountText?: string | null;
224
233
  isVerified: boolean;
@@ -228,59 +237,90 @@ type ChannelProfile = {
228
237
  banners: Array<Thumbnail>;
229
238
  links?: Array<ChannelLink> | null;
230
239
  };
231
- type ContentItem = {
240
+ type ChannelVideo = {
232
241
  id: string;
233
- type?: string;
234
- title?: string | null;
235
- videoUrl?: string;
236
- shortUrl?: string;
237
- playlistUrl?: string;
238
- author?: string | null;
239
- authorId?: string | null;
240
- durationSec?: number | null;
241
- durationText?: string | null;
242
- viewCount?: number | null;
243
- viewCountText?: string | null;
244
- publishedAt?: string | null;
245
- publishedAtText?: string | null;
242
+ type: "video";
243
+ title: string | null;
244
+ videoUrl: string;
245
+ author: string | null;
246
+ authorId: string | null;
247
+ duration: string | null;
248
+ durationSec: number | null;
249
+ durationText: string | null;
250
+ isLive: boolean;
251
+ isUpcoming: boolean;
252
+ upcomingAt: string | null;
253
+ viewCount: number | null;
254
+ viewCountText: string | null;
255
+ publishedAt: string | null;
256
+ publishedAtText: string | null;
257
+ thumbnails: Array<Thumbnail>;
258
+ };
259
+ type ChannelShort = {
260
+ id: string;
261
+ type: "short";
262
+ shortUrl: string;
263
+ title: string | null;
264
+ author: string | null;
265
+ authorId: string | null;
266
+ viewCount: number | null;
267
+ viewCountText: string | null;
268
+ thumbnails: Array<Thumbnail>;
269
+ };
270
+ type ChannelPlaylist = {
271
+ id: string;
272
+ type: "playlist";
273
+ playlistUrl: string;
274
+ title: string | null;
275
+ author: string | null;
276
+ authorId: string | null;
277
+ videoCount: string | null;
246
278
  thumbnails: Array<Thumbnail>;
247
279
  };
280
+ type ContentItem = ({
281
+ type?: "video";
282
+ } & ChannelVideo) | ({
283
+ type?: "short";
284
+ } & ChannelShort) | ({
285
+ type?: "playlist";
286
+ } & ChannelPlaylist);
248
287
  type ChannelData = {
249
288
  channel: ChannelProfile | null;
250
- tab?: string | null;
289
+ tab: "video" | "short" | "playlist" | "about";
251
290
  items?: Array<ContentItem>;
252
291
  continuationToken?: string | null;
253
292
  empty?: EmptyState;
254
293
  };
255
294
  type PlaylistMeta = {
256
295
  id: string;
257
- type?: "playlist";
296
+ type: "playlist";
258
297
  playlistUrl: string;
259
- title?: string | null;
260
- author?: string | null;
261
- authorId?: string | null;
262
- description?: string | null;
263
- videoCount?: string | null;
298
+ title: string | null;
299
+ author: string | null;
300
+ authorId: string | null;
301
+ description: string | null;
302
+ videoCount: string | null;
264
303
  thumbnails: Array<Thumbnail>;
265
304
  };
266
305
  type PlaylistItem = {
267
306
  id: string;
268
- type?: "video";
307
+ type: "video";
269
308
  videoUrl: string;
270
- title?: string | null;
271
- author?: string | null;
272
- authorId?: string | null;
273
- durationSec?: number | null;
274
- durationText?: string | null;
275
- index?: number | null;
276
- isLive?: boolean;
277
- isPlayable?: boolean;
278
- isUpcoming?: boolean;
279
- upcomingAt?: string | null;
280
- viewCount?: number | null;
281
- viewCountText?: string | null;
282
- publishedAt?: string | null;
283
- publishedAtText?: string | null;
309
+ title: string | null;
310
+ author: string | null;
311
+ authorId: string | null;
312
+ duration: string | null;
313
+ durationSec: number | null;
314
+ durationText: string | null;
315
+ index: number | null;
316
+ isLive: boolean;
317
+ isPlayable: boolean;
318
+ isUpcoming: boolean;
319
+ upcomingAt: string | null;
320
+ viewCount: number | null;
321
+ viewCountText: string | null;
322
+ publishedAt: string | null;
323
+ publishedAtText: string | null;
284
324
  thumbnails: Array<Thumbnail>;
285
325
  };
286
326
  type PlaylistData = {
@@ -332,9 +372,9 @@ type GetVideoData = {
332
372
  /**
333
373
  * The type of data to retrieve.
334
374
  */
335
- type: "details" | "transcript" | "comments" | "replies" | "livechat";
375
+ type: "details" | "transcript" | "comments" | "livechat";
336
376
  /**
337
- * Full YouTube video URL. Not required when type is replies.
377
+ * Full YouTube video URL.
338
378
  */
339
379
  videoUrl: string;
340
380
  /**
@@ -346,9 +386,15 @@ type GetVideoData = {
346
386
  */
347
387
  chatType?: "top" | "live";
348
388
  /**
349
- * Pagination token. Required when type is replies (use the repliesToken from a comment item); for livechat, pass the continuationToken from a previous livechat response to poll for new messages.
389
+ * For comments, pass a previous comments response token. For livechat, pass the previous livechat token to poll for new messages.
350
390
  */
351
391
  continuationToken?: string;
392
+ } | {
393
+ type: "replies";
394
+ /**
395
+ * The repliesToken from a top-level comment.
396
+ */
397
+ continuationToken: string;
352
398
  };
353
399
  path?: never;
354
400
  query?: never;
@@ -367,6 +413,10 @@ type GetVideoErrors = {
367
413
  * Insufficient credits
368
414
  */
369
415
  402: ErrorResponse;
416
+ /**
417
+ * Video or captions not found
418
+ */
419
+ 404: ErrorResponse;
370
420
  /**
371
421
  * Rate limited
372
422
  */
@@ -375,6 +425,10 @@ type GetVideoErrors = {
375
425
  * Internal error
376
426
  */
377
427
  500: ErrorResponse;
428
+ /**
429
+ * Upstream video data temporarily unavailable
430
+ */
431
+ 503: ErrorResponse;
378
432
  };
379
433
  type GetVideoError = GetVideoErrors[keyof GetVideoErrors];
380
434
  type GetVideoResponses = {
@@ -740,8 +794,11 @@ type SuggestOptions = Omit<SuggestQuery, "q">;
740
794
  type VideoResponseFor<T> = Omit<GetVideoResponse, "data"> & {
741
795
  data: T;
742
796
  };
743
- type CommentsOptions = Pick<GetVideoData["body"], "sortBy" | "continuationToken">;
744
- type LiveChatOptions = Pick<GetVideoData["body"], "chatType" | "continuationToken">;
797
+ type VideoUrlBody = Extract<GetVideoData["body"], {
798
+ videoUrl: string;
799
+ }>;
800
+ type CommentsOptions = Pick<VideoUrlBody, "sortBy" | "continuationToken">;
801
+ type LiveChatOptions = Pick<VideoUrlBody, "chatType" | "continuationToken">;
745
802
 
746
803
  interface StophyOptions {
747
804
  /** Defaults to `STOPHY_API_KEY`. */
@@ -803,4 +860,4 @@ declare class StophyError extends Error {
803
860
  });
804
861
  }
805
862
 
806
- export { type ChannelData, type ChannelLink, type ChannelOptions, type ChannelProfile, type ClientOptions, type Comment, type CommentsData, type CommentsOptions, type ContentItem, type CreditsData, type EmptyState, type ErrorResponse, type GetChannelData, type GetChannelError, type GetChannelErrors, type GetChannelResponse, type GetChannelResponses, type GetCreditsData, type GetCreditsError, type GetCreditsErrors, type GetCreditsResponse, type GetCreditsResponses, type GetLogsData, type GetLogsError, type GetLogsErrors, type GetLogsResponse, type GetLogsResponses, type GetPlaylistData, type GetPlaylistError, type GetPlaylistErrors, type GetPlaylistResponse, type GetPlaylistResponses, type GetSuggestionsData, type GetSuggestionsError, type GetSuggestionsErrors, type GetSuggestionsResponse, type GetSuggestionsResponses, type GetUsageData, type GetUsageError, type GetUsageErrors, type GetUsageResponse, type GetUsageResponses, type GetVideoData, type GetVideoError, type GetVideoErrors, type GetVideoResponse, type GetVideoResponses, type LiveChatData, type LiveChatMessage, type LiveChatOptions, type LogEntry, type LogsData, type PlaylistData, type PlaylistItem, type PlaylistMeta, type PlaylistOptions, type RelatedVideo, type SearchChannel, type SearchData, type SearchItem, type SearchOptions, type SearchPlaylist, type SearchShort, type SearchVideo, type SearchVideosData, type SearchVideosError, type SearchVideosErrors, type SearchVideosResponse, type SearchVideosResponses, Stophy, type StophyClientInput, StophyError, type StophyOptions, type SuggestData, type SuggestOptions, type Thumbnail, type TranscriptLanguage, type TranscriptResult, type TranscriptSegment, type UsageData, type UsageItem, type VideoData, type VideoDetails, type VideoDetailsData, Stophy as default };
863
+ export { type ChannelData, type ChannelLink, type ChannelOptions, type ChannelPlaylist, type ChannelProfile, type ChannelShort, type ChannelVideo, type ClientOptions, type Comment, type CommentsData, type CommentsOptions, type ContentItem, type CreditsData, type EmptyState, type ErrorResponse, type GetChannelData, type GetChannelError, type GetChannelErrors, type GetChannelResponse, type GetChannelResponses, type GetCreditsData, type GetCreditsError, type GetCreditsErrors, type GetCreditsResponse, type GetCreditsResponses, type GetLogsData, type GetLogsError, type GetLogsErrors, type GetLogsResponse, type GetLogsResponses, type GetPlaylistData, type GetPlaylistError, type GetPlaylistErrors, type GetPlaylistResponse, type GetPlaylistResponses, type GetSuggestionsData, type GetSuggestionsError, type GetSuggestionsErrors, type GetSuggestionsResponse, type GetSuggestionsResponses, type GetUsageData, type GetUsageError, type GetUsageErrors, type GetUsageResponse, type GetUsageResponses, type GetVideoData, type GetVideoError, type GetVideoErrors, type GetVideoResponse, type GetVideoResponses, type LiveChatData, type LiveChatMessage, type LiveChatOptions, type LogEntry, type LogsData, type PlaylistData, type PlaylistItem, type PlaylistMeta, type PlaylistOptions, type RelatedVideo, type SearchChannel, type SearchData, type SearchItem, type SearchOptions, type SearchPlaylist, type SearchQuery, type SearchShort, type SearchVideo, type SearchVideosData, type SearchVideosError, type SearchVideosErrors, type SearchVideosResponse, type SearchVideosResponses, Stophy, type StophyClientInput, StophyError, type StophyOptions, type SuggestData, type SuggestOptions, type Thumbnail, type TranscriptLanguage, type TranscriptResult, type TranscriptSegment, type UsageData, type UsageItem, type VideoData, type VideoDetails, type VideoDetailsData, Stophy as default };
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ type ErrorResponse = {
8
8
  /**
9
9
  * Machine-readable error code.
10
10
  */
11
- code?: "UNAUTHORIZED" | "INSUFFICIENT_CREDITS" | "BAD_REQUEST" | "INVALID_INPUT" | "NOT_FOUND" | "CONCURRENCY_LIMITED" | "INTERNAL_ERROR";
11
+ code?: "UNAUTHORIZED" | "INSUFFICIENT_CREDITS" | "BAD_REQUEST" | "INVALID_INPUT" | "NOT_FOUND" | "CONCURRENCY_LIMITED" | "UPSTREAM_UNAVAILABLE" | "INTERNAL_ERROR";
12
12
  /**
13
13
  * Human-readable error message.
14
14
  */
@@ -45,37 +45,37 @@ type TranscriptResult = {
45
45
  };
46
46
  type VideoDetails = {
47
47
  id: string;
48
- type?: "video";
48
+ type: "video";
49
49
  videoUrl: string;
50
50
  title: string | null;
51
- author?: string | null;
52
- authorId?: string | null;
53
- category?: string | null;
54
- description?: string | null;
55
- durationSec?: number | null;
56
- durationText?: string | null;
57
- isLive?: boolean;
58
- likeCount?: number | null;
59
- likeCountText?: string | null;
60
- publishedAt?: string | null;
61
- tags?: Array<string>;
62
- viewCount?: number | null;
63
- viewCountText?: string | null;
51
+ author: string | null;
52
+ authorId: string | null;
53
+ category: string | null;
54
+ description: string | null;
55
+ durationSec: number | null;
56
+ durationText: string | null;
57
+ isLive: boolean;
58
+ likeCount: number | null;
59
+ likeCountText: string | null;
60
+ publishedAt: string | null;
61
+ tags: Array<string>;
62
+ viewCount: number | null;
63
+ viewCountText: string | null;
64
64
  thumbnails: Array<Thumbnail>;
65
65
  };
66
66
  type RelatedVideo = {
67
67
  id: string;
68
- type?: "video";
68
+ type: "video";
69
69
  videoUrl: string;
70
- title?: string | null;
71
- author?: string | null;
72
- authorId?: string | null;
73
- durationSec?: number | null;
74
- durationText?: string | null;
75
- publishedAt?: string | null;
76
- publishedAtText?: string | null;
77
- viewCount?: number | null;
78
- viewCountText?: string | null;
70
+ title: string | null;
71
+ author: string | null;
72
+ authorId: string | null;
73
+ durationSec: number | null;
74
+ durationText: string | null;
75
+ publishedAt: string | null;
76
+ publishedAtText: string | null;
77
+ viewCount: number | null;
78
+ viewCountText: string | null;
79
79
  thumbnails: Array<Thumbnail>;
80
80
  };
81
81
  type VideoDetailsData = {
@@ -87,21 +87,29 @@ type Comment = {
87
87
  text: string | null;
88
88
  author: string | null;
89
89
  authorId: string | null;
90
- authorThumbnail?: string | null;
90
+ authorThumbnail: string | null;
91
91
  hasChannelOwnerReplied: boolean;
92
92
  isChannelOwner: boolean;
93
93
  isHearted: boolean;
94
94
  isPinned: boolean;
95
95
  isVerified: boolean;
96
- publishedAt?: string | null;
97
- publishedAtText?: string | null;
98
- likeCount?: number | null;
99
- likeCountText?: string | null;
100
- replyCount?: number | null;
101
- replyCountText?: string | null;
102
- repliesToken?: string | null;
96
+ publishedAt: string | null;
97
+ publishedAtText: string | null;
98
+ likeCount: number | null;
99
+ likeCountText: string | null;
100
+ replyCount: number | null;
101
+ replyCountText: string | null;
102
+ repliesToken: string | null;
103
103
  };
104
104
  type CommentsData = {
105
+ /**
106
+ * Present for top-level comment requests.
107
+ */
108
+ videoId?: string;
109
+ /**
110
+ * Resolved sort order for top-level comment requests.
111
+ */
112
+ sortBy?: "any" | "latest" | "top";
105
113
  items: Array<Comment>;
106
114
  continuationToken: string | null;
107
115
  empty?: EmptyState;
@@ -109,20 +117,20 @@ type CommentsData = {
109
117
  type LiveChatMessage = {
110
118
  id: string;
111
119
  text: string;
112
- author?: string | null;
113
- authorId?: string | null;
114
- timestampUsec?: string | null;
120
+ author: string | null;
121
+ authorId: string | null;
122
+ timestampUsec: string | null;
115
123
  isOwner: boolean;
116
124
  isModerator: boolean;
117
125
  isVerified: boolean;
118
- superChatAmount?: string | null;
119
- superChatCurrency?: string | null;
126
+ superChatAmount: string | null;
127
+ superChatCurrency: string | null;
120
128
  };
121
129
  type LiveChatData = {
122
- status: string;
130
+ status: "live" | "upcoming" | "replay" | "chat_disabled" | "not_live";
123
131
  isLive: boolean;
124
- concurrentViewers?: number | null;
125
- pollIntervalMs?: number | null;
132
+ concurrentViewers: number | null;
133
+ pollIntervalMs: number | null;
126
134
  messages: Array<LiveChatMessage>;
127
135
  continuationToken: string | null;
128
136
  };
@@ -135,19 +143,19 @@ type SearchVideo = {
135
143
  id: string;
136
144
  videoUrl: string;
137
145
  title: string;
138
- author?: string | null;
139
- authorId?: string | null;
140
- description?: string | null;
141
- duration?: string | null;
142
- durationSec?: number | null;
143
- durationText?: string | null;
144
- isLive?: boolean;
145
- isUpcoming?: boolean;
146
- isVerified?: boolean;
147
- viewCount?: number | null;
148
- viewCountText?: string | null;
149
- publishedAt?: string | null;
150
- publishedAtText?: string | null;
146
+ author: string | null;
147
+ authorId: string | null;
148
+ description: string | null;
149
+ duration: string | null;
150
+ durationSec: number | null;
151
+ durationText: string | null;
152
+ isLive: boolean;
153
+ isUpcoming: boolean;
154
+ isVerified: boolean;
155
+ viewCount: number | null;
156
+ viewCountText: string | null;
157
+ publishedAt: string | null;
158
+ publishedAtText: string | null;
151
159
  thumbnails: Array<Thumbnail>;
152
160
  };
153
161
  type SearchShort = {
@@ -155,16 +163,8 @@ type SearchShort = {
155
163
  id: string;
156
164
  shortUrl: string;
157
165
  title: string;
158
- author?: string | null;
159
- authorId?: string | null;
160
- description?: string | null;
161
- duration?: string | null;
162
- durationSec?: number | null;
163
- durationText?: string | null;
164
- viewCount?: number | null;
165
- viewCountText?: string | null;
166
- publishedAt?: string | null;
167
- publishedAtText?: string | null;
166
+ viewCount: number | null;
167
+ viewCountText: string | null;
168
168
  thumbnails: Array<Thumbnail>;
169
169
  };
170
170
  type SearchPlaylist = {
@@ -172,10 +172,10 @@ type SearchPlaylist = {
172
172
  id: string;
173
173
  playlistUrl: string;
174
174
  title: string;
175
- author?: string | null;
176
- authorId?: string | null;
177
- videoCount?: number | null;
178
- videoCountText?: string | null;
175
+ author: string | null;
176
+ authorId: string | null;
177
+ videoCount: number | null;
178
+ videoCountText: string | null;
179
179
  thumbnails: Array<Thumbnail>;
180
180
  };
181
181
  type SearchChannel = {
@@ -183,11 +183,11 @@ type SearchChannel = {
183
183
  id: string;
184
184
  channelUrl: string;
185
185
  name: string;
186
- handle?: string | null;
187
- description?: string | null;
188
- subscriberCount?: number | null;
189
- subscriberCountText?: string | null;
190
- isVerified?: boolean;
186
+ handle: string | null;
187
+ description: string | null;
188
+ subscriberCount: number | null;
189
+ subscriberCountText: string | null;
190
+ isVerified: boolean;
191
191
  thumbnails: Array<Thumbnail>;
192
192
  };
193
193
  type SearchItem = ({
@@ -199,7 +199,16 @@ type SearchItem = ({
199
199
  } & SearchPlaylist) | ({
200
200
  type?: "channel";
201
201
  } & SearchChannel);
202
+ type SearchQuery = {
203
+ q: string;
204
+ type?: "video" | "short" | "channel" | "playlist" | "movie";
205
+ sortBy?: "relevance" | "popularity" | "date" | "rating";
206
+ uploadDate?: "today" | "week" | "month" | "year";
207
+ duration?: "short" | "medium" | "long";
208
+ features?: Array<string>;
209
+ };
202
210
  type SearchData = {
211
+ query: SearchQuery;
203
212
  items: Array<SearchItem>;
204
213
  continuationToken: string | null;
205
214
  estimatedResults?: number;
@@ -214,11 +223,11 @@ type ChannelProfile = {
214
223
  name: string | null;
215
224
  handle: string | null;
216
225
  channelUrl: string | null;
217
- description?: string | null;
218
- subscriberCount?: number | null;
219
- subscriberCountText?: string | null;
220
- videoCount?: number | null;
221
- videoCountText?: string | null;
226
+ description: string | null;
227
+ subscriberCount: number | null;
228
+ subscriberCountText: string | null;
229
+ videoCount: number | null;
230
+ videoCountText: string | null;
222
231
  viewCount?: number | null;
223
232
  viewCountText?: string | null;
224
233
  isVerified: boolean;
@@ -228,59 +237,90 @@ type ChannelProfile = {
228
237
  banners: Array<Thumbnail>;
229
238
  links?: Array<ChannelLink> | null;
230
239
  };
231
- type ContentItem = {
240
+ type ChannelVideo = {
232
241
  id: string;
233
- type?: string;
234
- title?: string | null;
235
- videoUrl?: string;
236
- shortUrl?: string;
237
- playlistUrl?: string;
238
- author?: string | null;
239
- authorId?: string | null;
240
- durationSec?: number | null;
241
- durationText?: string | null;
242
- viewCount?: number | null;
243
- viewCountText?: string | null;
244
- publishedAt?: string | null;
245
- publishedAtText?: string | null;
242
+ type: "video";
243
+ title: string | null;
244
+ videoUrl: string;
245
+ author: string | null;
246
+ authorId: string | null;
247
+ duration: string | null;
248
+ durationSec: number | null;
249
+ durationText: string | null;
250
+ isLive: boolean;
251
+ isUpcoming: boolean;
252
+ upcomingAt: string | null;
253
+ viewCount: number | null;
254
+ viewCountText: string | null;
255
+ publishedAt: string | null;
256
+ publishedAtText: string | null;
257
+ thumbnails: Array<Thumbnail>;
258
+ };
259
+ type ChannelShort = {
260
+ id: string;
261
+ type: "short";
262
+ shortUrl: string;
263
+ title: string | null;
264
+ author: string | null;
265
+ authorId: string | null;
266
+ viewCount: number | null;
267
+ viewCountText: string | null;
268
+ thumbnails: Array<Thumbnail>;
269
+ };
270
+ type ChannelPlaylist = {
271
+ id: string;
272
+ type: "playlist";
273
+ playlistUrl: string;
274
+ title: string | null;
275
+ author: string | null;
276
+ authorId: string | null;
277
+ videoCount: string | null;
246
278
  thumbnails: Array<Thumbnail>;
247
279
  };
280
+ type ContentItem = ({
281
+ type?: "video";
282
+ } & ChannelVideo) | ({
283
+ type?: "short";
284
+ } & ChannelShort) | ({
285
+ type?: "playlist";
286
+ } & ChannelPlaylist);
248
287
  type ChannelData = {
249
288
  channel: ChannelProfile | null;
250
- tab?: string | null;
289
+ tab: "video" | "short" | "playlist" | "about";
251
290
  items?: Array<ContentItem>;
252
291
  continuationToken?: string | null;
253
292
  empty?: EmptyState;
254
293
  };
255
294
  type PlaylistMeta = {
256
295
  id: string;
257
- type?: "playlist";
296
+ type: "playlist";
258
297
  playlistUrl: string;
259
- title?: string | null;
260
- author?: string | null;
261
- authorId?: string | null;
262
- description?: string | null;
263
- videoCount?: string | null;
298
+ title: string | null;
299
+ author: string | null;
300
+ authorId: string | null;
301
+ description: string | null;
302
+ videoCount: string | null;
264
303
  thumbnails: Array<Thumbnail>;
265
304
  };
266
305
  type PlaylistItem = {
267
306
  id: string;
268
- type?: "video";
307
+ type: "video";
269
308
  videoUrl: string;
270
- title?: string | null;
271
- author?: string | null;
272
- authorId?: string | null;
273
- durationSec?: number | null;
274
- durationText?: string | null;
275
- index?: number | null;
276
- isLive?: boolean;
277
- isPlayable?: boolean;
278
- isUpcoming?: boolean;
279
- upcomingAt?: string | null;
280
- viewCount?: number | null;
281
- viewCountText?: string | null;
282
- publishedAt?: string | null;
283
- publishedAtText?: string | null;
309
+ title: string | null;
310
+ author: string | null;
311
+ authorId: string | null;
312
+ duration: string | null;
313
+ durationSec: number | null;
314
+ durationText: string | null;
315
+ index: number | null;
316
+ isLive: boolean;
317
+ isPlayable: boolean;
318
+ isUpcoming: boolean;
319
+ upcomingAt: string | null;
320
+ viewCount: number | null;
321
+ viewCountText: string | null;
322
+ publishedAt: string | null;
323
+ publishedAtText: string | null;
284
324
  thumbnails: Array<Thumbnail>;
285
325
  };
286
326
  type PlaylistData = {
@@ -332,9 +372,9 @@ type GetVideoData = {
332
372
  /**
333
373
  * The type of data to retrieve.
334
374
  */
335
- type: "details" | "transcript" | "comments" | "replies" | "livechat";
375
+ type: "details" | "transcript" | "comments" | "livechat";
336
376
  /**
337
- * Full YouTube video URL. Not required when type is replies.
377
+ * Full YouTube video URL.
338
378
  */
339
379
  videoUrl: string;
340
380
  /**
@@ -346,9 +386,15 @@ type GetVideoData = {
346
386
  */
347
387
  chatType?: "top" | "live";
348
388
  /**
349
- * Pagination token. Required when type is replies (use the repliesToken from a comment item); for livechat, pass the continuationToken from a previous livechat response to poll for new messages.
389
+ * For comments, pass a previous comments response token. For livechat, pass the previous livechat token to poll for new messages.
350
390
  */
351
391
  continuationToken?: string;
392
+ } | {
393
+ type: "replies";
394
+ /**
395
+ * The repliesToken from a top-level comment.
396
+ */
397
+ continuationToken: string;
352
398
  };
353
399
  path?: never;
354
400
  query?: never;
@@ -367,6 +413,10 @@ type GetVideoErrors = {
367
413
  * Insufficient credits
368
414
  */
369
415
  402: ErrorResponse;
416
+ /**
417
+ * Video or captions not found
418
+ */
419
+ 404: ErrorResponse;
370
420
  /**
371
421
  * Rate limited
372
422
  */
@@ -375,6 +425,10 @@ type GetVideoErrors = {
375
425
  * Internal error
376
426
  */
377
427
  500: ErrorResponse;
428
+ /**
429
+ * Upstream video data temporarily unavailable
430
+ */
431
+ 503: ErrorResponse;
378
432
  };
379
433
  type GetVideoError = GetVideoErrors[keyof GetVideoErrors];
380
434
  type GetVideoResponses = {
@@ -740,8 +794,11 @@ type SuggestOptions = Omit<SuggestQuery, "q">;
740
794
  type VideoResponseFor<T> = Omit<GetVideoResponse, "data"> & {
741
795
  data: T;
742
796
  };
743
- type CommentsOptions = Pick<GetVideoData["body"], "sortBy" | "continuationToken">;
744
- type LiveChatOptions = Pick<GetVideoData["body"], "chatType" | "continuationToken">;
797
+ type VideoUrlBody = Extract<GetVideoData["body"], {
798
+ videoUrl: string;
799
+ }>;
800
+ type CommentsOptions = Pick<VideoUrlBody, "sortBy" | "continuationToken">;
801
+ type LiveChatOptions = Pick<VideoUrlBody, "chatType" | "continuationToken">;
745
802
 
746
803
  interface StophyOptions {
747
804
  /** Defaults to `STOPHY_API_KEY`. */
@@ -803,4 +860,4 @@ declare class StophyError extends Error {
803
860
  });
804
861
  }
805
862
 
806
- export { type ChannelData, type ChannelLink, type ChannelOptions, type ChannelProfile, type ClientOptions, type Comment, type CommentsData, type CommentsOptions, type ContentItem, type CreditsData, type EmptyState, type ErrorResponse, type GetChannelData, type GetChannelError, type GetChannelErrors, type GetChannelResponse, type GetChannelResponses, type GetCreditsData, type GetCreditsError, type GetCreditsErrors, type GetCreditsResponse, type GetCreditsResponses, type GetLogsData, type GetLogsError, type GetLogsErrors, type GetLogsResponse, type GetLogsResponses, type GetPlaylistData, type GetPlaylistError, type GetPlaylistErrors, type GetPlaylistResponse, type GetPlaylistResponses, type GetSuggestionsData, type GetSuggestionsError, type GetSuggestionsErrors, type GetSuggestionsResponse, type GetSuggestionsResponses, type GetUsageData, type GetUsageError, type GetUsageErrors, type GetUsageResponse, type GetUsageResponses, type GetVideoData, type GetVideoError, type GetVideoErrors, type GetVideoResponse, type GetVideoResponses, type LiveChatData, type LiveChatMessage, type LiveChatOptions, type LogEntry, type LogsData, type PlaylistData, type PlaylistItem, type PlaylistMeta, type PlaylistOptions, type RelatedVideo, type SearchChannel, type SearchData, type SearchItem, type SearchOptions, type SearchPlaylist, type SearchShort, type SearchVideo, type SearchVideosData, type SearchVideosError, type SearchVideosErrors, type SearchVideosResponse, type SearchVideosResponses, Stophy, type StophyClientInput, StophyError, type StophyOptions, type SuggestData, type SuggestOptions, type Thumbnail, type TranscriptLanguage, type TranscriptResult, type TranscriptSegment, type UsageData, type UsageItem, type VideoData, type VideoDetails, type VideoDetailsData, Stophy as default };
863
+ export { type ChannelData, type ChannelLink, type ChannelOptions, type ChannelPlaylist, type ChannelProfile, type ChannelShort, type ChannelVideo, type ClientOptions, type Comment, type CommentsData, type CommentsOptions, type ContentItem, type CreditsData, type EmptyState, type ErrorResponse, type GetChannelData, type GetChannelError, type GetChannelErrors, type GetChannelResponse, type GetChannelResponses, type GetCreditsData, type GetCreditsError, type GetCreditsErrors, type GetCreditsResponse, type GetCreditsResponses, type GetLogsData, type GetLogsError, type GetLogsErrors, type GetLogsResponse, type GetLogsResponses, type GetPlaylistData, type GetPlaylistError, type GetPlaylistErrors, type GetPlaylistResponse, type GetPlaylistResponses, type GetSuggestionsData, type GetSuggestionsError, type GetSuggestionsErrors, type GetSuggestionsResponse, type GetSuggestionsResponses, type GetUsageData, type GetUsageError, type GetUsageErrors, type GetUsageResponse, type GetUsageResponses, type GetVideoData, type GetVideoError, type GetVideoErrors, type GetVideoResponse, type GetVideoResponses, type LiveChatData, type LiveChatMessage, type LiveChatOptions, type LogEntry, type LogsData, type PlaylistData, type PlaylistItem, type PlaylistMeta, type PlaylistOptions, type RelatedVideo, type SearchChannel, type SearchData, type SearchItem, type SearchOptions, type SearchPlaylist, type SearchQuery, type SearchShort, type SearchVideo, type SearchVideosData, type SearchVideosError, type SearchVideosErrors, type SearchVideosResponse, type SearchVideosResponses, Stophy, type StophyClientInput, StophyError, type StophyOptions, type SuggestData, type SuggestOptions, type Thumbnail, type TranscriptLanguage, type TranscriptResult, type TranscriptSegment, type UsageData, type UsageItem, type VideoData, type VideoDetails, type VideoDetailsData, Stophy as default };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/generated/client.gen.ts","../src/generated/sdk.gen.ts","../src/errors.ts","../src/transport.ts","../src/methods/account.ts","../src/methods/channel.ts","../src/methods/playlist.ts","../src/methods/search.ts","../src/methods/suggest.ts","../src/methods/video.ts","../src/client.ts"],"names":["createClient","createConfig","client"],"mappings":";;;AAuBO,IAAM,MAAA,GAAS,YAAA;AAAA,EACpB,YAAA,CAA4B;AAAA,IAC1B,OAAA,EAAS;AAAA,GACV;AACH,CAAA;;;AC6BO,IAAM,QAAA,GAAW,CACtB,OAAA,KACG;AACH,EAAA,OAAA,CAAQ,OAAA,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AAA;AAAA,EAC/C;AACD","file":"index.js","sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nimport type { ClientOptions } from \"./types.gen\";\nimport {\n type Config,\n type ClientOptions as DefaultClientOptions,\n createClient,\n createConfig,\n} from \"@hey-api/client-fetch\";\n\n/**\n * The `createClientConfig()` function will be called on client initialization\n * and the returned object will become the client's initial configuration.\n *\n * You may want to initialize your client this way instead of calling\n * `setConfig()`. This is useful for example if you're using Next.js\n * to ensure your client always has the correct values.\n */\nexport type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> =\n (\n override?: Config<DefaultClientOptions & T>\n ) => Config<Required<DefaultClientOptions> & T>;\n\nexport const client = createClient(\n createConfig<ClientOptions>({\n baseUrl: \"https://api.stophy.dev\",\n })\n);\n","// This file is auto-generated by @hey-api/openapi-ts\n\nimport type {\n Options as ClientOptions,\n TDataShape,\n Client,\n} from \"@hey-api/client-fetch\";\nimport type {\n GetVideoData,\n GetVideoResponse,\n GetVideoError,\n SearchVideosData,\n SearchVideosResponse,\n SearchVideosError,\n GetChannelData,\n GetChannelResponse,\n GetChannelError,\n GetPlaylistData,\n GetPlaylistResponse,\n GetPlaylistError,\n GetSuggestionsData,\n GetSuggestionsResponse,\n GetSuggestionsError,\n GetCreditsData,\n GetCreditsResponse,\n GetCreditsError,\n GetLogsData,\n GetLogsResponse,\n GetLogsError,\n GetUsageData,\n GetUsageResponse,\n GetUsageError,\n} from \"./types.gen\";\nimport { client as _heyApiClient } from \"./client.gen\";\n\nexport type Options<\n TData extends TDataShape = TDataShape,\n ThrowOnError extends boolean = boolean\n> = ClientOptions<TData, ThrowOnError> & {\n /**\n * You can provide a client instance returned by `createClient()` instead of\n * individual options. This might be also useful if you want to implement a\n * custom client.\n */\n client?: Client;\n /**\n * You can pass arbitrary values through the `meta` object. This can be\n * used to access values that aren't defined as part of the SDK function.\n */\n meta?: Record<string, unknown>;\n};\n\n/**\n * Video\n * Fetch video details, transcript, comments, replies, or live chat. Pass type: details for metadata, transcript for timestamped captions, comments for top-level comments, replies for a comment thread (pass the repliesToken from a comment as continuationToken), or livechat for live stream chat messages.\n */\nexport const getVideo = <ThrowOnError extends boolean = false>(\n options: Options<GetVideoData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).post<\n GetVideoResponse,\n GetVideoError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/video\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n ...options?.headers,\n },\n });\n};\n\n/**\n * Search\n * Search YouTube with optional filters for content type, sort order, upload date, duration, and features. Returns paginated results.\n */\nexport const searchVideos = <ThrowOnError extends boolean = false>(\n options: Options<SearchVideosData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).post<\n SearchVideosResponse,\n SearchVideosError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/search\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n ...options?.headers,\n },\n });\n};\n\n/**\n * Channel\n * Retrieve channel metadata and content by channelUrl. Use the tab field to switch between videos, shorts, playlists, and about info.\n */\nexport const getChannel = <ThrowOnError extends boolean = false>(\n options: Options<GetChannelData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).post<\n GetChannelResponse,\n GetChannelError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/channel\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n ...options?.headers,\n },\n });\n};\n\n/**\n * Playlist\n * Retrieve items from a YouTube playlist. Use continuationToken to page through long playlists.\n */\nexport const getPlaylist = <ThrowOnError extends boolean = false>(\n options: Options<GetPlaylistData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).post<\n GetPlaylistResponse,\n GetPlaylistError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/playlist\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n ...options?.headers,\n },\n });\n};\n\n/**\n * Suggest\n * Get YouTube search autocomplete suggestions for a query.\n */\nexport const getSuggestions = <ThrowOnError extends boolean = false>(\n options: Options<GetSuggestionsData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).get<\n GetSuggestionsResponse,\n GetSuggestionsError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/suggest\",\n ...options,\n });\n};\n\n/**\n * Credits\n * Return the current credit balance for the authenticated API key.\n */\nexport const getCredits = <ThrowOnError extends boolean = false>(\n options?: Options<GetCreditsData, ThrowOnError>\n) => {\n return (options?.client ?? _heyApiClient).get<\n GetCreditsResponse,\n GetCreditsError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/credits\",\n ...options,\n });\n};\n\n/**\n * Logs\n * Return recent API request logs for the authenticated key.\n */\nexport const getLogs = <ThrowOnError extends boolean = false>(\n options?: Options<GetLogsData, ThrowOnError>\n) => {\n return (options?.client ?? _heyApiClient).get<\n GetLogsResponse,\n GetLogsError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/logs\",\n ...options,\n });\n};\n\n/**\n * Usage\n * Return daily credit and request counts for the authenticated key.\n */\nexport const getUsage = <ThrowOnError extends boolean = false>(\n options?: Options<GetUsageData, ThrowOnError>\n) => {\n return (options?.client ?? _heyApiClient).get<\n GetUsageResponse,\n GetUsageError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/usage\",\n ...options,\n });\n};\n","import type { ErrorResponse } from \"./generated/types.gen\";\n\n/** Thrown when the Stophy API responds with a non-success status. */\nexport class StophyError extends Error {\n\treadonly code?: ErrorResponse[\"code\"];\n\treadonly status: number;\n\treadonly requestId?: string;\n\treadonly details?: unknown;\n\n\tconstructor(\n\t\tmessage: string,\n\t\toptions: {\n\t\t\tstatus: number;\n\t\t\tcode?: ErrorResponse[\"code\"];\n\t\t\trequestId?: string;\n\t\t\tdetails?: unknown;\n\t\t},\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"StophyError\";\n\t\tthis.status = options.status;\n\t\tthis.code = options.code;\n\t\tthis.requestId = options.requestId;\n\t\tthis.details = options.details;\n\t}\n}\n","import { type Client, createClient, createConfig } from \"@hey-api/client-fetch\";\nimport { StophyError } from \"./errors\";\nimport type { ErrorResponse } from \"./generated/types.gen\";\n\nconst DEFAULT_BASE_URL = \"https://api.stophy.dev\";\nconst RETRYABLE_STATUS = new Set([429, 500, 502, 503, 504]);\n\nexport interface TransportOptions {\n\tapiKey: string;\n\tbaseUrl?: string;\n\tfetch?: typeof globalThis.fetch;\n\theaders?: Record<string, string>;\n\tmaxRetries?: number;\n\tretryInitialDelayMs?: number;\n}\n\nexport function createTransport(options: TransportOptions): Client {\n\tconst baseFetch = options.fetch ?? globalThis.fetch;\n\treturn createClient(\n\t\tcreateConfig({\n\t\t\tbaseUrl: options.baseUrl ?? DEFAULT_BASE_URL,\n\t\t\tauth: () => options.apiKey,\n\t\t\theaders: options.headers,\n\t\t\tfetch: withRetries(\n\t\t\t\tbaseFetch,\n\t\t\t\toptions.maxRetries ?? 2,\n\t\t\t\toptions.retryInitialDelayMs ?? 500,\n\t\t\t),\n\t\t}),\n\t);\n}\n\ntype FetchFn = (\n\tinput: Request | URL | string,\n\tinit?: RequestInit,\n) => Promise<Response>;\n\nfunction withRetries(\n\tbaseFetch: typeof globalThis.fetch,\n\tmaxRetries: number,\n\tinitialDelayMs: number,\n): FetchFn {\n\tif (maxRetries <= 0) return baseFetch;\n\n\treturn async (input, init) => {\n\t\tfor (let attempt = 0; ; attempt++) {\n\t\t\tconst request = input instanceof Request ? input.clone() : input;\n\t\t\ttry {\n\t\t\t\tconst response = await baseFetch(request, init);\n\t\t\t\tif (attempt < maxRetries && RETRYABLE_STATUS.has(response.status)) {\n\t\t\t\t\tawait sleep(\n\t\t\t\t\t\tretryAfterMs(response) ?? backoffMs(attempt, initialDelayMs),\n\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\treturn response;\n\t\t\t} catch (error) {\n\t\t\t\tif (attempt >= maxRetries) throw error;\n\t\t\t\tawait sleep(backoffMs(attempt, initialDelayMs));\n\t\t\t}\n\t\t}\n\t};\n}\n\nfunction backoffMs(attempt: number, base: number): number {\n\tconst window = base * 2 ** attempt;\n\treturn window / 2 + Math.random() * (window / 2);\n}\n\nfunction retryAfterMs(response: Response): number | null {\n\tconst header = response.headers.get(\"retry-after\");\n\tif (!header) return null;\n\tconst seconds = Number(header);\n\tif (!Number.isNaN(seconds)) return seconds * 1000;\n\tconst date = Date.parse(header);\n\treturn Number.isNaN(date) ? null : Math.max(0, date - Date.now());\n}\n\nfunction sleep(ms: number): Promise<void> {\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport function unwrap<T>(result: {\n\tdata?: T;\n\terror?: unknown;\n\tresponse: Response;\n}): T {\n\tif (result.error === undefined && result.data !== undefined)\n\t\treturn result.data;\n\n\tconst error = (result.error ?? {}) as Partial<ErrorResponse>;\n\tthrow new StophyError(\n\t\terror.error ??\n\t\t\t`Stophy request failed with status ${result.response.status}`,\n\t\t{\n\t\t\tstatus: result.response.status,\n\t\t\tcode: error.code,\n\t\t\trequestId: result.response.headers.get(\"x-request-id\") ?? undefined,\n\t\t\tdetails: error.details,\n\t\t},\n\t);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { getCredits, getLogs, getUsage } from \"../generated/sdk.gen\";\nimport type {\n\tGetCreditsResponse,\n\tGetLogsData,\n\tGetLogsResponse,\n\tGetUsageData,\n\tGetUsageResponse,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\nexport function credits(client: Client): Promise<GetCreditsResponse> {\n\treturn getCredits({ client }).then(unwrap);\n}\n\nexport function logs(\n\tclient: Client,\n\tquery?: GetLogsData[\"query\"],\n): Promise<GetLogsResponse> {\n\treturn getLogs({ client, query }).then(unwrap);\n}\n\nexport function usage(\n\tclient: Client,\n\tquery?: GetUsageData[\"query\"],\n): Promise<GetUsageResponse> {\n\treturn getUsage({ client, query }).then(unwrap);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { getChannel } from \"../generated/sdk.gen\";\nimport type {\n\tGetChannelData,\n\tGetChannelResponse,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\ntype ChannelBody = GetChannelData[\"body\"];\nexport type ChannelOptions = Omit<ChannelBody, \"channelUrl\">;\n\nexport function channel(\n\tclient: Client,\n\turlOrBody: string | ChannelBody,\n\toptions: ChannelOptions = {},\n): Promise<GetChannelResponse> {\n\tconst body =\n\t\ttypeof urlOrBody === \"string\"\n\t\t\t? { channelUrl: urlOrBody, ...options }\n\t\t\t: urlOrBody;\n\treturn getChannel({ client, body }).then(unwrap);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { getPlaylist } from \"../generated/sdk.gen\";\nimport type {\n\tGetPlaylistData,\n\tGetPlaylistResponse,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\ntype PlaylistBody = GetPlaylistData[\"body\"];\nexport type PlaylistOptions = Omit<PlaylistBody, \"playlistUrl\">;\n\nexport function playlist(\n\tclient: Client,\n\turlOrBody: string | PlaylistBody,\n\toptions: PlaylistOptions = {},\n): Promise<GetPlaylistResponse> {\n\tconst body =\n\t\ttypeof urlOrBody === \"string\"\n\t\t\t? { playlistUrl: urlOrBody, ...options }\n\t\t\t: urlOrBody;\n\treturn getPlaylist({ client, body }).then(unwrap);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { searchVideos } from \"../generated/sdk.gen\";\nimport type {\n\tSearchVideosData,\n\tSearchVideosResponse,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\ntype SearchBody = SearchVideosData[\"body\"];\nexport type SearchOptions = Omit<SearchBody, \"q\">;\n\nexport function search(\n\tclient: Client,\n\tqueryOrBody: string | SearchBody,\n\toptions: SearchOptions = {},\n): Promise<SearchVideosResponse> {\n\tif (typeof queryOrBody === \"string\" && !queryOrBody.trim()) {\n\t\tthrow new Error(\"query cannot be empty\");\n\t}\n\tconst body =\n\t\ttypeof queryOrBody === \"string\"\n\t\t\t? { q: queryOrBody, ...options }\n\t\t\t: queryOrBody;\n\treturn searchVideos({ client, body }).then(unwrap);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { getSuggestions } from \"../generated/sdk.gen\";\nimport type {\n\tGetSuggestionsData,\n\tGetSuggestionsResponse,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\ntype SuggestQuery = GetSuggestionsData[\"query\"];\nexport type SuggestOptions = Omit<SuggestQuery, \"q\">;\n\nexport function suggest(\n\tclient: Client,\n\tqueryOrOptions: string | SuggestQuery,\n\toptions: SuggestOptions = {},\n): Promise<GetSuggestionsResponse> {\n\tif (typeof queryOrOptions === \"string\" && !queryOrOptions.trim()) {\n\t\tthrow new Error(\"query cannot be empty\");\n\t}\n\tconst query =\n\t\ttypeof queryOrOptions === \"string\"\n\t\t\t? { q: queryOrOptions, ...options }\n\t\t\t: queryOrOptions;\n\treturn getSuggestions({ client, query }).then(unwrap);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { getVideo } from \"../generated/sdk.gen\";\nimport type {\n\tCommentsData,\n\tGetVideoData,\n\tGetVideoResponse,\n\tLiveChatData,\n\tTranscriptResult,\n\tVideoDetailsData,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\nexport type VideoResponseFor<T> = Omit<GetVideoResponse, \"data\"> & { data: T };\nexport type CommentsOptions = Pick<\n\tGetVideoData[\"body\"],\n\t\"sortBy\" | \"continuationToken\"\n>;\nexport type LiveChatOptions = Pick<\n\tGetVideoData[\"body\"],\n\t\"chatType\" | \"continuationToken\"\n>;\n\nexport async function video(\n\tclient: Client,\n\tbody: GetVideoData[\"body\"],\n): Promise<GetVideoResponse> {\n\treturn unwrap(await getVideo({ client, body }));\n}\n\nexport function videoDetails(\n\tclient: Client,\n\tvideoUrl: string,\n): Promise<VideoResponseFor<VideoDetailsData>> {\n\treturn video(client, { type: \"details\", videoUrl }) as Promise<\n\t\tVideoResponseFor<VideoDetailsData>\n\t>;\n}\n\nexport function transcript(\n\tclient: Client,\n\tvideoUrl: string,\n): Promise<VideoResponseFor<TranscriptResult>> {\n\treturn video(client, { type: \"transcript\", videoUrl }) as Promise<\n\t\tVideoResponseFor<TranscriptResult>\n\t>;\n}\n\nexport function comments(\n\tclient: Client,\n\tvideoUrl: string,\n\toptions: CommentsOptions = {},\n): Promise<VideoResponseFor<CommentsData>> {\n\treturn video(client, {\n\t\ttype: \"comments\",\n\t\tvideoUrl,\n\t\t...options,\n\t}) as Promise<VideoResponseFor<CommentsData>>;\n}\n\nexport function replies(\n\tclient: Client,\n\tcontinuationToken: string,\n): Promise<VideoResponseFor<CommentsData>> {\n\treturn video(client, {\n\t\ttype: \"replies\",\n\t\tcontinuationToken,\n\t} as GetVideoData[\"body\"]) as Promise<VideoResponseFor<CommentsData>>;\n}\n\nexport function liveChat(\n\tclient: Client,\n\tvideoUrl: string,\n\toptions: LiveChatOptions = {},\n): Promise<VideoResponseFor<LiveChatData>> {\n\treturn video(client, {\n\t\ttype: \"livechat\",\n\t\tvideoUrl,\n\t\t...options,\n\t}) as Promise<VideoResponseFor<LiveChatData>>;\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport type {\n\tCommentsData,\n\tGetChannelData,\n\tGetChannelResponse,\n\tGetCreditsResponse,\n\tGetLogsData,\n\tGetLogsResponse,\n\tGetPlaylistData,\n\tGetPlaylistResponse,\n\tGetSuggestionsData,\n\tGetSuggestionsResponse,\n\tGetUsageData,\n\tGetUsageResponse,\n\tGetVideoData,\n\tGetVideoResponse,\n\tLiveChatData,\n\tSearchVideosData,\n\tSearchVideosResponse,\n\tTranscriptResult,\n\tVideoDetailsData,\n} from \"./generated/types.gen\";\nimport * as accountMethods from \"./methods/account\";\nimport { type ChannelOptions, channel as getChannel } from \"./methods/channel\";\nimport {\n\tplaylist as getPlaylist,\n\ttype PlaylistOptions,\n} from \"./methods/playlist\";\nimport { type SearchOptions, search as searchVideos } from \"./methods/search\";\nimport {\n\tsuggest as getSuggestions,\n\ttype SuggestOptions,\n} from \"./methods/suggest\";\nimport type {\n\tCommentsOptions,\n\tLiveChatOptions,\n\tVideoResponseFor,\n} from \"./methods/video\";\nimport * as videoMethods from \"./methods/video\";\nimport { createTransport } from \"./transport\";\n\nexport interface StophyOptions {\n\t/** Defaults to `STOPHY_API_KEY`. */\n\tapiKey?: string;\n\t/** Defaults to `STOPHY_BASE_URL` or `https://api.stophy.dev`. */\n\tbaseUrl?: string;\n\tfetch?: typeof globalThis.fetch;\n\theaders?: Record<string, string>;\n\tmaxRetries?: number;\n\tretryInitialDelayMs?: number;\n}\n\nexport type StophyClientInput = StophyOptions | string;\n\nfunction env(name: string): string | undefined {\n\treturn typeof process === \"undefined\" ? undefined : process.env[name];\n}\n\n/** Typed client for the Stophy API. */\nexport class Stophy {\n\treadonly client: Client;\n\n\tconstructor(input: StophyClientInput = {}) {\n\t\tconst options = typeof input === \"string\" ? { apiKey: input } : input;\n\t\tconst apiKey = options.apiKey?.trim() || env(\"STOPHY_API_KEY\")?.trim();\n\t\tif (!apiKey) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Stophy: provide `apiKey` or set the STOPHY_API_KEY environment variable.\",\n\t\t\t);\n\t\t}\n\n\t\tthis.client = createTransport({\n\t\t\t...options,\n\t\t\tapiKey,\n\t\t\tbaseUrl: options.baseUrl ?? env(\"STOPHY_BASE_URL\"),\n\t\t});\n\t}\n\n\tasync video(\n\t\tbody: GetVideoData[\"body\"] & { type: \"details\" },\n\t): Promise<VideoResponseFor<VideoDetailsData>>;\n\tasync video(\n\t\tbody: GetVideoData[\"body\"] & { type: \"transcript\" },\n\t): Promise<VideoResponseFor<TranscriptResult>>;\n\tasync video(\n\t\tbody: GetVideoData[\"body\"] & { type: \"comments\" | \"replies\" },\n\t): Promise<VideoResponseFor<CommentsData>>;\n\tasync video(\n\t\tbody: GetVideoData[\"body\"] & { type: \"livechat\" },\n\t): Promise<VideoResponseFor<LiveChatData>>;\n\tasync video(body: GetVideoData[\"body\"]): Promise<GetVideoResponse>;\n\tasync video(body: GetVideoData[\"body\"]): Promise<GetVideoResponse> {\n\t\treturn videoMethods.video(this.client, body);\n\t}\n\n\tvideoDetails(videoUrl: string): Promise<VideoResponseFor<VideoDetailsData>> {\n\t\treturn videoMethods.videoDetails(this.client, videoUrl);\n\t}\n\n\ttranscript(videoUrl: string): Promise<VideoResponseFor<TranscriptResult>> {\n\t\treturn videoMethods.transcript(this.client, videoUrl);\n\t}\n\n\tcomments(\n\t\tvideoUrl: string,\n\t\toptions?: CommentsOptions,\n\t): Promise<VideoResponseFor<CommentsData>> {\n\t\treturn videoMethods.comments(this.client, videoUrl, options);\n\t}\n\n\treplies(continuationToken: string): Promise<VideoResponseFor<CommentsData>> {\n\t\treturn videoMethods.replies(this.client, continuationToken);\n\t}\n\n\tliveChat(\n\t\tvideoUrl: string,\n\t\toptions?: LiveChatOptions,\n\t): Promise<VideoResponseFor<LiveChatData>> {\n\t\treturn videoMethods.liveChat(this.client, videoUrl, options);\n\t}\n\n\tasync search(body: SearchVideosData[\"body\"]): Promise<SearchVideosResponse>;\n\tasync search(\n\t\tquery: string,\n\t\toptions?: SearchOptions,\n\t): Promise<SearchVideosResponse>;\n\tasync search(\n\t\tqueryOrBody: string | SearchVideosData[\"body\"],\n\t\toptions?: SearchOptions,\n\t): Promise<SearchVideosResponse> {\n\t\treturn searchVideos(this.client, queryOrBody, options);\n\t}\n\n\tasync channel(body: GetChannelData[\"body\"]): Promise<GetChannelResponse>;\n\tasync channel(\n\t\tchannelUrl: string,\n\t\toptions?: ChannelOptions,\n\t): Promise<GetChannelResponse>;\n\tasync channel(\n\t\turlOrBody: string | GetChannelData[\"body\"],\n\t\toptions?: ChannelOptions,\n\t): Promise<GetChannelResponse> {\n\t\treturn getChannel(this.client, urlOrBody, options);\n\t}\n\n\tasync playlist(body: GetPlaylistData[\"body\"]): Promise<GetPlaylistResponse>;\n\tasync playlist(\n\t\tplaylistUrl: string,\n\t\toptions?: PlaylistOptions,\n\t): Promise<GetPlaylistResponse>;\n\tasync playlist(\n\t\turlOrBody: string | GetPlaylistData[\"body\"],\n\t\toptions?: PlaylistOptions,\n\t): Promise<GetPlaylistResponse> {\n\t\treturn getPlaylist(this.client, urlOrBody, options);\n\t}\n\n\tasync suggest(\n\t\tquery: GetSuggestionsData[\"query\"],\n\t): Promise<GetSuggestionsResponse>;\n\tasync suggest(\n\t\tquery: string,\n\t\toptions?: SuggestOptions,\n\t): Promise<GetSuggestionsResponse>;\n\tasync suggest(\n\t\tqueryOrOptions: string | GetSuggestionsData[\"query\"],\n\t\toptions?: SuggestOptions,\n\t): Promise<GetSuggestionsResponse> {\n\t\treturn getSuggestions(this.client, queryOrOptions, options);\n\t}\n\n\tcredits(): Promise<GetCreditsResponse> {\n\t\treturn accountMethods.credits(this.client);\n\t}\n\n\tlogs(query?: GetLogsData[\"query\"]): Promise<GetLogsResponse> {\n\t\treturn accountMethods.logs(this.client, query);\n\t}\n\n\tusage(query?: GetUsageData[\"query\"]): Promise<GetUsageResponse> {\n\t\treturn accountMethods.usage(this.client, query);\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../src/generated/client.gen.ts","../src/generated/sdk.gen.ts","../src/errors.ts","../src/transport.ts","../src/methods/account.ts","../src/methods/channel.ts","../src/methods/playlist.ts","../src/methods/search.ts","../src/methods/suggest.ts","../src/methods/video.ts","../src/client.ts"],"names":["createClient","createConfig","client"],"mappings":";;;AAuBO,IAAM,MAAA,GAAS,YAAA;AAAA,EACpB,YAAA,CAA4B;AAAA,IAC1B,OAAA,EAAS;AAAA,GACV;AACH,CAAA;;;AC6BO,IAAM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AAA,OAAsB,KAAA,CAAM,IAAA,CAAK,MAAA,EAAQ,KAAK,CAAA;AAAA,EAC/C;AACD","file":"index.js","sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nimport type { ClientOptions } from \"./types.gen\";\nimport {\n type Config,\n type ClientOptions as DefaultClientOptions,\n createClient,\n createConfig,\n} from \"@hey-api/client-fetch\";\n\n/**\n * The `createClientConfig()` function will be called on client initialization\n * and the returned object will become the client's initial configuration.\n *\n * You may want to initialize your client this way instead of calling\n * `setConfig()`. This is useful for example if you're using Next.js\n * to ensure your client always has the correct values.\n */\nexport type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> =\n (\n override?: Config<DefaultClientOptions & T>\n ) => Config<Required<DefaultClientOptions> & T>;\n\nexport const client = createClient(\n createConfig<ClientOptions>({\n baseUrl: \"https://api.stophy.dev\",\n })\n);\n","// This file is auto-generated by @hey-api/openapi-ts\n\nimport type {\n Options as ClientOptions,\n TDataShape,\n Client,\n} from \"@hey-api/client-fetch\";\nimport type {\n GetVideoData,\n GetVideoResponse,\n GetVideoError,\n SearchVideosData,\n SearchVideosResponse,\n SearchVideosError,\n GetChannelData,\n GetChannelResponse,\n GetChannelError,\n GetPlaylistData,\n GetPlaylistResponse,\n GetPlaylistError,\n GetSuggestionsData,\n GetSuggestionsResponse,\n GetSuggestionsError,\n GetCreditsData,\n GetCreditsResponse,\n GetCreditsError,\n GetLogsData,\n GetLogsResponse,\n GetLogsError,\n GetUsageData,\n GetUsageResponse,\n GetUsageError,\n} from \"./types.gen\";\nimport { client as _heyApiClient } from \"./client.gen\";\n\nexport type Options<\n TData extends TDataShape = TDataShape,\n ThrowOnError extends boolean = boolean\n> = ClientOptions<TData, ThrowOnError> & {\n /**\n * You can provide a client instance returned by `createClient()` instead of\n * individual options. This might be also useful if you want to implement a\n * custom client.\n */\n client?: Client;\n /**\n * You can pass arbitrary values through the `meta` object. This can be\n * used to access values that aren't defined as part of the SDK function.\n */\n meta?: Record<string, unknown>;\n};\n\n/**\n * Video\n * Fetch video details, transcript, comments, replies, or live chat. Pass type: details for metadata, transcript for timestamped captions, comments for top-level comments, replies for a comment thread (pass the repliesToken from a comment as continuationToken), or livechat for live stream chat messages.\n */\nexport const getVideo = <ThrowOnError extends boolean = false>(\n options: Options<GetVideoData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).post<\n GetVideoResponse,\n GetVideoError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/video\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n ...options?.headers,\n },\n });\n};\n\n/**\n * Search\n * Search YouTube with optional filters for content type, sort order, upload date, duration, and features. Returns paginated results.\n */\nexport const searchVideos = <ThrowOnError extends boolean = false>(\n options: Options<SearchVideosData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).post<\n SearchVideosResponse,\n SearchVideosError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/search\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n ...options?.headers,\n },\n });\n};\n\n/**\n * Channel\n * Retrieve channel metadata and content by channelUrl. Use the tab field to switch between videos, shorts, playlists, and about info.\n */\nexport const getChannel = <ThrowOnError extends boolean = false>(\n options: Options<GetChannelData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).post<\n GetChannelResponse,\n GetChannelError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/channel\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n ...options?.headers,\n },\n });\n};\n\n/**\n * Playlist\n * Retrieve items from a YouTube playlist. Use continuationToken to page through long playlists.\n */\nexport const getPlaylist = <ThrowOnError extends boolean = false>(\n options: Options<GetPlaylistData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).post<\n GetPlaylistResponse,\n GetPlaylistError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/playlist\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n ...options?.headers,\n },\n });\n};\n\n/**\n * Suggest\n * Get YouTube search autocomplete suggestions for a query.\n */\nexport const getSuggestions = <ThrowOnError extends boolean = false>(\n options: Options<GetSuggestionsData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).get<\n GetSuggestionsResponse,\n GetSuggestionsError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/suggest\",\n ...options,\n });\n};\n\n/**\n * Credits\n * Return the current credit balance for the authenticated API key.\n */\nexport const getCredits = <ThrowOnError extends boolean = false>(\n options?: Options<GetCreditsData, ThrowOnError>\n) => {\n return (options?.client ?? _heyApiClient).get<\n GetCreditsResponse,\n GetCreditsError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/credits\",\n ...options,\n });\n};\n\n/**\n * Logs\n * Return recent API request logs for the authenticated key.\n */\nexport const getLogs = <ThrowOnError extends boolean = false>(\n options?: Options<GetLogsData, ThrowOnError>\n) => {\n return (options?.client ?? _heyApiClient).get<\n GetLogsResponse,\n GetLogsError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/logs\",\n ...options,\n });\n};\n\n/**\n * Usage\n * Return daily credit and request counts for the authenticated key.\n */\nexport const getUsage = <ThrowOnError extends boolean = false>(\n options?: Options<GetUsageData, ThrowOnError>\n) => {\n return (options?.client ?? _heyApiClient).get<\n GetUsageResponse,\n GetUsageError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/usage\",\n ...options,\n });\n};\n","import type { ErrorResponse } from \"./generated/types.gen\";\n\n/** Thrown when the Stophy API responds with a non-success status. */\nexport class StophyError extends Error {\n\treadonly code?: ErrorResponse[\"code\"];\n\treadonly status: number;\n\treadonly requestId?: string;\n\treadonly details?: unknown;\n\n\tconstructor(\n\t\tmessage: string,\n\t\toptions: {\n\t\t\tstatus: number;\n\t\t\tcode?: ErrorResponse[\"code\"];\n\t\t\trequestId?: string;\n\t\t\tdetails?: unknown;\n\t\t},\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"StophyError\";\n\t\tthis.status = options.status;\n\t\tthis.code = options.code;\n\t\tthis.requestId = options.requestId;\n\t\tthis.details = options.details;\n\t}\n}\n","import { type Client, createClient, createConfig } from \"@hey-api/client-fetch\";\nimport { StophyError } from \"./errors\";\nimport type { ErrorResponse } from \"./generated/types.gen\";\n\nconst DEFAULT_BASE_URL = \"https://api.stophy.dev\";\nconst RETRYABLE_STATUS = new Set([429, 500, 502, 503, 504]);\n\nexport interface TransportOptions {\n\tapiKey: string;\n\tbaseUrl?: string;\n\tfetch?: typeof globalThis.fetch;\n\theaders?: Record<string, string>;\n\tmaxRetries?: number;\n\tretryInitialDelayMs?: number;\n}\n\nexport function createTransport(options: TransportOptions): Client {\n\tconst baseFetch = options.fetch ?? globalThis.fetch;\n\treturn createClient(\n\t\tcreateConfig({\n\t\t\tbaseUrl: options.baseUrl ?? DEFAULT_BASE_URL,\n\t\t\tauth: () => options.apiKey,\n\t\t\theaders: options.headers,\n\t\t\tfetch: withRetries(\n\t\t\t\tbaseFetch,\n\t\t\t\toptions.maxRetries ?? 2,\n\t\t\t\toptions.retryInitialDelayMs ?? 500,\n\t\t\t),\n\t\t}),\n\t);\n}\n\ntype FetchFn = (\n\tinput: Request | URL | string,\n\tinit?: RequestInit,\n) => Promise<Response>;\n\nfunction withRetries(\n\tbaseFetch: typeof globalThis.fetch,\n\tmaxRetries: number,\n\tinitialDelayMs: number,\n): FetchFn {\n\tif (maxRetries <= 0) return baseFetch;\n\n\treturn async (input, init) => {\n\t\tfor (let attempt = 0; ; attempt++) {\n\t\t\tconst request = input instanceof Request ? input.clone() : input;\n\t\t\ttry {\n\t\t\t\tconst response = await baseFetch(request, init);\n\t\t\t\tif (attempt < maxRetries && RETRYABLE_STATUS.has(response.status)) {\n\t\t\t\t\tawait sleep(\n\t\t\t\t\t\tretryAfterMs(response) ?? backoffMs(attempt, initialDelayMs),\n\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\treturn response;\n\t\t\t} catch (error) {\n\t\t\t\tif (attempt >= maxRetries) throw error;\n\t\t\t\tawait sleep(backoffMs(attempt, initialDelayMs));\n\t\t\t}\n\t\t}\n\t};\n}\n\nfunction backoffMs(attempt: number, base: number): number {\n\tconst window = base * 2 ** attempt;\n\treturn window / 2 + Math.random() * (window / 2);\n}\n\nfunction retryAfterMs(response: Response): number | null {\n\tconst header = response.headers.get(\"retry-after\");\n\tif (!header) return null;\n\tconst seconds = Number(header);\n\tif (!Number.isNaN(seconds)) return seconds * 1000;\n\tconst date = Date.parse(header);\n\treturn Number.isNaN(date) ? null : Math.max(0, date - Date.now());\n}\n\nfunction sleep(ms: number): Promise<void> {\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport function unwrap<T>(result: {\n\tdata?: T;\n\terror?: unknown;\n\tresponse: Response;\n}): T {\n\tif (result.error === undefined && result.data !== undefined)\n\t\treturn result.data;\n\n\tconst error = (result.error ?? {}) as Partial<ErrorResponse>;\n\tthrow new StophyError(\n\t\terror.error ??\n\t\t\t`Stophy request failed with status ${result.response.status}`,\n\t\t{\n\t\t\tstatus: result.response.status,\n\t\t\tcode: error.code,\n\t\t\trequestId: result.response.headers.get(\"x-request-id\") ?? undefined,\n\t\t\tdetails: error.details,\n\t\t},\n\t);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { getCredits, getLogs, getUsage } from \"../generated/sdk.gen\";\nimport type {\n\tGetCreditsResponse,\n\tGetLogsData,\n\tGetLogsResponse,\n\tGetUsageData,\n\tGetUsageResponse,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\nexport function credits(client: Client): Promise<GetCreditsResponse> {\n\treturn getCredits({ client }).then(unwrap);\n}\n\nexport function logs(\n\tclient: Client,\n\tquery?: GetLogsData[\"query\"],\n): Promise<GetLogsResponse> {\n\treturn getLogs({ client, query }).then(unwrap);\n}\n\nexport function usage(\n\tclient: Client,\n\tquery?: GetUsageData[\"query\"],\n): Promise<GetUsageResponse> {\n\treturn getUsage({ client, query }).then(unwrap);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { getChannel } from \"../generated/sdk.gen\";\nimport type {\n\tGetChannelData,\n\tGetChannelResponse,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\ntype ChannelBody = GetChannelData[\"body\"];\nexport type ChannelOptions = Omit<ChannelBody, \"channelUrl\">;\n\nexport function channel(\n\tclient: Client,\n\turlOrBody: string | ChannelBody,\n\toptions: ChannelOptions = {},\n): Promise<GetChannelResponse> {\n\tconst body =\n\t\ttypeof urlOrBody === \"string\"\n\t\t\t? { channelUrl: urlOrBody, ...options }\n\t\t\t: urlOrBody;\n\treturn getChannel({ client, body }).then(unwrap);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { getPlaylist } from \"../generated/sdk.gen\";\nimport type {\n\tGetPlaylistData,\n\tGetPlaylistResponse,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\ntype PlaylistBody = GetPlaylistData[\"body\"];\nexport type PlaylistOptions = Omit<PlaylistBody, \"playlistUrl\">;\n\nexport function playlist(\n\tclient: Client,\n\turlOrBody: string | PlaylistBody,\n\toptions: PlaylistOptions = {},\n): Promise<GetPlaylistResponse> {\n\tconst body =\n\t\ttypeof urlOrBody === \"string\"\n\t\t\t? { playlistUrl: urlOrBody, ...options }\n\t\t\t: urlOrBody;\n\treturn getPlaylist({ client, body }).then(unwrap);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { searchVideos } from \"../generated/sdk.gen\";\nimport type {\n\tSearchVideosData,\n\tSearchVideosResponse,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\ntype SearchBody = SearchVideosData[\"body\"];\nexport type SearchOptions = Omit<SearchBody, \"q\">;\n\nexport function search(\n\tclient: Client,\n\tqueryOrBody: string | SearchBody,\n\toptions: SearchOptions = {},\n): Promise<SearchVideosResponse> {\n\tif (typeof queryOrBody === \"string\" && !queryOrBody.trim()) {\n\t\tthrow new Error(\"query cannot be empty\");\n\t}\n\tconst body =\n\t\ttypeof queryOrBody === \"string\"\n\t\t\t? { q: queryOrBody, ...options }\n\t\t\t: queryOrBody;\n\treturn searchVideos({ client, body }).then(unwrap);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { getSuggestions } from \"../generated/sdk.gen\";\nimport type {\n\tGetSuggestionsData,\n\tGetSuggestionsResponse,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\ntype SuggestQuery = GetSuggestionsData[\"query\"];\nexport type SuggestOptions = Omit<SuggestQuery, \"q\">;\n\nexport function suggest(\n\tclient: Client,\n\tqueryOrOptions: string | SuggestQuery,\n\toptions: SuggestOptions = {},\n): Promise<GetSuggestionsResponse> {\n\tif (typeof queryOrOptions === \"string\" && !queryOrOptions.trim()) {\n\t\tthrow new Error(\"query cannot be empty\");\n\t}\n\tconst query =\n\t\ttypeof queryOrOptions === \"string\"\n\t\t\t? { q: queryOrOptions, ...options }\n\t\t\t: queryOrOptions;\n\treturn getSuggestions({ client, query }).then(unwrap);\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { getVideo } from \"../generated/sdk.gen\";\nimport type {\n\tCommentsData,\n\tGetVideoData,\n\tGetVideoResponse,\n\tLiveChatData,\n\tTranscriptResult,\n\tVideoDetailsData,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\n\nexport type VideoResponseFor<T> = Omit<GetVideoResponse, \"data\"> & { data: T };\ntype VideoUrlBody = Extract<GetVideoData[\"body\"], { videoUrl: string }>;\nexport type CommentsOptions = Pick<\n\tVideoUrlBody,\n\t\"sortBy\" | \"continuationToken\"\n>;\nexport type LiveChatOptions = Pick<\n\tVideoUrlBody,\n\t\"chatType\" | \"continuationToken\"\n>;\n\nexport async function video(\n\tclient: Client,\n\tbody: GetVideoData[\"body\"],\n): Promise<GetVideoResponse> {\n\treturn unwrap(await getVideo({ client, body }));\n}\n\nexport function videoDetails(\n\tclient: Client,\n\tvideoUrl: string,\n): Promise<VideoResponseFor<VideoDetailsData>> {\n\treturn video(client, { type: \"details\", videoUrl }) as Promise<\n\t\tVideoResponseFor<VideoDetailsData>\n\t>;\n}\n\nexport function transcript(\n\tclient: Client,\n\tvideoUrl: string,\n): Promise<VideoResponseFor<TranscriptResult>> {\n\treturn video(client, { type: \"transcript\", videoUrl }) as Promise<\n\t\tVideoResponseFor<TranscriptResult>\n\t>;\n}\n\nexport function comments(\n\tclient: Client,\n\tvideoUrl: string,\n\toptions: CommentsOptions = {},\n): Promise<VideoResponseFor<CommentsData>> {\n\treturn video(client, {\n\t\ttype: \"comments\",\n\t\tvideoUrl,\n\t\t...options,\n\t}) as Promise<VideoResponseFor<CommentsData>>;\n}\n\nexport function replies(\n\tclient: Client,\n\tcontinuationToken: string,\n): Promise<VideoResponseFor<CommentsData>> {\n\treturn video(client, {\n\t\ttype: \"replies\",\n\t\tcontinuationToken,\n\t}) as Promise<VideoResponseFor<CommentsData>>;\n}\n\nexport function liveChat(\n\tclient: Client,\n\tvideoUrl: string,\n\toptions: LiveChatOptions = {},\n): Promise<VideoResponseFor<LiveChatData>> {\n\treturn video(client, {\n\t\ttype: \"livechat\",\n\t\tvideoUrl,\n\t\t...options,\n\t}) as Promise<VideoResponseFor<LiveChatData>>;\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport type {\n\tCommentsData,\n\tGetChannelData,\n\tGetChannelResponse,\n\tGetCreditsResponse,\n\tGetLogsData,\n\tGetLogsResponse,\n\tGetPlaylistData,\n\tGetPlaylistResponse,\n\tGetSuggestionsData,\n\tGetSuggestionsResponse,\n\tGetUsageData,\n\tGetUsageResponse,\n\tGetVideoData,\n\tGetVideoResponse,\n\tLiveChatData,\n\tSearchVideosData,\n\tSearchVideosResponse,\n\tTranscriptResult,\n\tVideoDetailsData,\n} from \"./generated/types.gen\";\nimport * as accountMethods from \"./methods/account\";\nimport { type ChannelOptions, channel as getChannel } from \"./methods/channel\";\nimport {\n\tplaylist as getPlaylist,\n\ttype PlaylistOptions,\n} from \"./methods/playlist\";\nimport { type SearchOptions, search as searchVideos } from \"./methods/search\";\nimport {\n\tsuggest as getSuggestions,\n\ttype SuggestOptions,\n} from \"./methods/suggest\";\nimport type {\n\tCommentsOptions,\n\tLiveChatOptions,\n\tVideoResponseFor,\n} from \"./methods/video\";\nimport * as videoMethods from \"./methods/video\";\nimport { createTransport } from \"./transport\";\n\nexport interface StophyOptions {\n\t/** Defaults to `STOPHY_API_KEY`. */\n\tapiKey?: string;\n\t/** Defaults to `STOPHY_BASE_URL` or `https://api.stophy.dev`. */\n\tbaseUrl?: string;\n\tfetch?: typeof globalThis.fetch;\n\theaders?: Record<string, string>;\n\tmaxRetries?: number;\n\tretryInitialDelayMs?: number;\n}\n\nexport type StophyClientInput = StophyOptions | string;\n\nfunction env(name: string): string | undefined {\n\treturn typeof process === \"undefined\" ? undefined : process.env[name];\n}\n\n/** Typed client for the Stophy API. */\nexport class Stophy {\n\treadonly client: Client;\n\n\tconstructor(input: StophyClientInput = {}) {\n\t\tconst options = typeof input === \"string\" ? { apiKey: input } : input;\n\t\tconst apiKey = options.apiKey?.trim() || env(\"STOPHY_API_KEY\")?.trim();\n\t\tif (!apiKey) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Stophy: provide `apiKey` or set the STOPHY_API_KEY environment variable.\",\n\t\t\t);\n\t\t}\n\n\t\tthis.client = createTransport({\n\t\t\t...options,\n\t\t\tapiKey,\n\t\t\tbaseUrl: options.baseUrl ?? env(\"STOPHY_BASE_URL\"),\n\t\t});\n\t}\n\n\tasync video(\n\t\tbody: GetVideoData[\"body\"] & { type: \"details\" },\n\t): Promise<VideoResponseFor<VideoDetailsData>>;\n\tasync video(\n\t\tbody: GetVideoData[\"body\"] & { type: \"transcript\" },\n\t): Promise<VideoResponseFor<TranscriptResult>>;\n\tasync video(\n\t\tbody: GetVideoData[\"body\"] & { type: \"comments\" | \"replies\" },\n\t): Promise<VideoResponseFor<CommentsData>>;\n\tasync video(\n\t\tbody: GetVideoData[\"body\"] & { type: \"livechat\" },\n\t): Promise<VideoResponseFor<LiveChatData>>;\n\tasync video(body: GetVideoData[\"body\"]): Promise<GetVideoResponse>;\n\tasync video(body: GetVideoData[\"body\"]): Promise<GetVideoResponse> {\n\t\treturn videoMethods.video(this.client, body);\n\t}\n\n\tvideoDetails(videoUrl: string): Promise<VideoResponseFor<VideoDetailsData>> {\n\t\treturn videoMethods.videoDetails(this.client, videoUrl);\n\t}\n\n\ttranscript(videoUrl: string): Promise<VideoResponseFor<TranscriptResult>> {\n\t\treturn videoMethods.transcript(this.client, videoUrl);\n\t}\n\n\tcomments(\n\t\tvideoUrl: string,\n\t\toptions?: CommentsOptions,\n\t): Promise<VideoResponseFor<CommentsData>> {\n\t\treturn videoMethods.comments(this.client, videoUrl, options);\n\t}\n\n\treplies(continuationToken: string): Promise<VideoResponseFor<CommentsData>> {\n\t\treturn videoMethods.replies(this.client, continuationToken);\n\t}\n\n\tliveChat(\n\t\tvideoUrl: string,\n\t\toptions?: LiveChatOptions,\n\t): Promise<VideoResponseFor<LiveChatData>> {\n\t\treturn videoMethods.liveChat(this.client, videoUrl, options);\n\t}\n\n\tasync search(body: SearchVideosData[\"body\"]): Promise<SearchVideosResponse>;\n\tasync search(\n\t\tquery: string,\n\t\toptions?: SearchOptions,\n\t): Promise<SearchVideosResponse>;\n\tasync search(\n\t\tqueryOrBody: string | SearchVideosData[\"body\"],\n\t\toptions?: SearchOptions,\n\t): Promise<SearchVideosResponse> {\n\t\treturn searchVideos(this.client, queryOrBody, options);\n\t}\n\n\tasync channel(body: GetChannelData[\"body\"]): Promise<GetChannelResponse>;\n\tasync channel(\n\t\tchannelUrl: string,\n\t\toptions?: ChannelOptions,\n\t): Promise<GetChannelResponse>;\n\tasync channel(\n\t\turlOrBody: string | GetChannelData[\"body\"],\n\t\toptions?: ChannelOptions,\n\t): Promise<GetChannelResponse> {\n\t\treturn getChannel(this.client, urlOrBody, options);\n\t}\n\n\tasync playlist(body: GetPlaylistData[\"body\"]): Promise<GetPlaylistResponse>;\n\tasync playlist(\n\t\tplaylistUrl: string,\n\t\toptions?: PlaylistOptions,\n\t): Promise<GetPlaylistResponse>;\n\tasync playlist(\n\t\turlOrBody: string | GetPlaylistData[\"body\"],\n\t\toptions?: PlaylistOptions,\n\t): Promise<GetPlaylistResponse> {\n\t\treturn getPlaylist(this.client, urlOrBody, options);\n\t}\n\n\tasync suggest(\n\t\tquery: GetSuggestionsData[\"query\"],\n\t): Promise<GetSuggestionsResponse>;\n\tasync suggest(\n\t\tquery: string,\n\t\toptions?: SuggestOptions,\n\t): Promise<GetSuggestionsResponse>;\n\tasync suggest(\n\t\tqueryOrOptions: string | GetSuggestionsData[\"query\"],\n\t\toptions?: SuggestOptions,\n\t): Promise<GetSuggestionsResponse> {\n\t\treturn getSuggestions(this.client, queryOrOptions, options);\n\t}\n\n\tcredits(): Promise<GetCreditsResponse> {\n\t\treturn accountMethods.credits(this.client);\n\t}\n\n\tlogs(query?: GetLogsData[\"query\"]): Promise<GetLogsResponse> {\n\t\treturn accountMethods.logs(this.client, query);\n\t}\n\n\tusage(query?: GetUsageData[\"query\"]): Promise<GetUsageResponse> {\n\t\treturn accountMethods.usage(this.client, query);\n\t}\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stophy",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Official TypeScript SDK for Stophy - The YouTube context API for AI agents.",
5
5
  "type": "module",
6
6
  "license": "MIT",