stophy 0.2.1 → 0.3.0
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.
- package/README.md +20 -6
- package/dist/index.cjs +73 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1203 -377
- package/dist/index.d.ts +1203 -377
- package/dist/index.js +73 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var client = createClient(
|
|
|
8
8
|
);
|
|
9
9
|
|
|
10
10
|
// src/generated/sdk.gen.ts
|
|
11
|
-
var
|
|
11
|
+
var searchVideos = (options) => {
|
|
12
12
|
return (options.client ?? client).post({
|
|
13
13
|
security: [
|
|
14
14
|
{
|
|
@@ -16,7 +16,7 @@ var getVideo = (options) => {
|
|
|
16
16
|
type: "http"
|
|
17
17
|
}
|
|
18
18
|
],
|
|
19
|
-
url: "/v1/
|
|
19
|
+
url: "/v1/search",
|
|
20
20
|
...options,
|
|
21
21
|
headers: {
|
|
22
22
|
"Content-Type": "application/json",
|
|
@@ -24,7 +24,7 @@ var getVideo = (options) => {
|
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
};
|
|
27
|
-
var
|
|
27
|
+
var getVideo = (options) => {
|
|
28
28
|
return (options.client ?? client).post({
|
|
29
29
|
security: [
|
|
30
30
|
{
|
|
@@ -32,7 +32,7 @@ var searchVideos = (options) => {
|
|
|
32
32
|
type: "http"
|
|
33
33
|
}
|
|
34
34
|
],
|
|
35
|
-
url: "/v1/
|
|
35
|
+
url: "/v1/video",
|
|
36
36
|
...options,
|
|
37
37
|
headers: {
|
|
38
38
|
"Content-Type": "application/json",
|
|
@@ -73,7 +73,7 @@ var getPlaylist = (options) => {
|
|
|
73
73
|
});
|
|
74
74
|
};
|
|
75
75
|
var getSuggestions = (options) => {
|
|
76
|
-
return (options.client ?? client).
|
|
76
|
+
return (options.client ?? client).post({
|
|
77
77
|
security: [
|
|
78
78
|
{
|
|
79
79
|
scheme: "bearer",
|
|
@@ -81,7 +81,43 @@ var getSuggestions = (options) => {
|
|
|
81
81
|
}
|
|
82
82
|
],
|
|
83
83
|
url: "/v1/suggest",
|
|
84
|
-
...options
|
|
84
|
+
...options,
|
|
85
|
+
headers: {
|
|
86
|
+
"Content-Type": "application/json",
|
|
87
|
+
...options?.headers
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
var youtubeMusic = (options) => {
|
|
92
|
+
return (options.client ?? client).post({
|
|
93
|
+
security: [
|
|
94
|
+
{
|
|
95
|
+
scheme: "bearer",
|
|
96
|
+
type: "http"
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
url: "/v1/music",
|
|
100
|
+
...options,
|
|
101
|
+
headers: {
|
|
102
|
+
"Content-Type": "application/json",
|
|
103
|
+
...options?.headers
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
var youtubeKids = (options) => {
|
|
108
|
+
return (options.client ?? client).post({
|
|
109
|
+
security: [
|
|
110
|
+
{
|
|
111
|
+
scheme: "bearer",
|
|
112
|
+
type: "http"
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
url: "/v1/kids",
|
|
116
|
+
...options,
|
|
117
|
+
headers: {
|
|
118
|
+
"Content-Type": "application/json",
|
|
119
|
+
...options?.headers
|
|
120
|
+
}
|
|
85
121
|
});
|
|
86
122
|
};
|
|
87
123
|
var getCredits = (options) => {
|
|
@@ -96,7 +132,7 @@ var getCredits = (options) => {
|
|
|
96
132
|
...options
|
|
97
133
|
});
|
|
98
134
|
};
|
|
99
|
-
var
|
|
135
|
+
var getUsage = (options) => {
|
|
100
136
|
return (options?.client ?? client).get({
|
|
101
137
|
security: [
|
|
102
138
|
{
|
|
@@ -104,11 +140,11 @@ var getLogs = (options) => {
|
|
|
104
140
|
type: "http"
|
|
105
141
|
}
|
|
106
142
|
],
|
|
107
|
-
url: "/v1/
|
|
143
|
+
url: "/v1/usage",
|
|
108
144
|
...options
|
|
109
145
|
});
|
|
110
146
|
};
|
|
111
|
-
var
|
|
147
|
+
var getLogs = (options) => {
|
|
112
148
|
return (options?.client ?? client).get({
|
|
113
149
|
security: [
|
|
114
150
|
{
|
|
@@ -116,7 +152,7 @@ var getUsage = (options) => {
|
|
|
116
152
|
type: "http"
|
|
117
153
|
}
|
|
118
154
|
],
|
|
119
|
-
url: "/v1/
|
|
155
|
+
url: "/v1/logs",
|
|
120
156
|
...options
|
|
121
157
|
});
|
|
122
158
|
};
|
|
@@ -223,10 +259,22 @@ function channel(client2, urlOrBody, options = {}) {
|
|
|
223
259
|
return getChannel({ client: client2, body }).then(unwrap);
|
|
224
260
|
}
|
|
225
261
|
|
|
262
|
+
// src/methods/kids.ts
|
|
263
|
+
function kids(client2, body) {
|
|
264
|
+
return youtubeKids({ client: client2, body }).then(unwrap);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// src/methods/music.ts
|
|
268
|
+
function music(client2, body) {
|
|
269
|
+
return youtubeMusic({ client: client2, body }).then(unwrap);
|
|
270
|
+
}
|
|
271
|
+
|
|
226
272
|
// src/methods/playlist.ts
|
|
227
273
|
function playlist(client2, urlOrBody, options = {}) {
|
|
228
274
|
const body = typeof urlOrBody === "string" ? { playlistUrl: urlOrBody, ...options } : urlOrBody;
|
|
229
|
-
return getPlaylist({ client: client2, body }).then(
|
|
275
|
+
return getPlaylist({ client: client2, body }).then(
|
|
276
|
+
unwrap
|
|
277
|
+
);
|
|
230
278
|
}
|
|
231
279
|
|
|
232
280
|
// src/methods/search.ts
|
|
@@ -243,8 +291,10 @@ function suggest(client2, queryOrOptions, options = {}) {
|
|
|
243
291
|
if (typeof queryOrOptions === "string" && !queryOrOptions.trim()) {
|
|
244
292
|
throw new Error("query cannot be empty");
|
|
245
293
|
}
|
|
246
|
-
const
|
|
247
|
-
return getSuggestions({ client: client2,
|
|
294
|
+
const body = typeof queryOrOptions === "string" ? { q: queryOrOptions, ...options } : queryOrOptions;
|
|
295
|
+
return getSuggestions({ client: client2, body }).then(
|
|
296
|
+
unwrap
|
|
297
|
+
);
|
|
248
298
|
}
|
|
249
299
|
|
|
250
300
|
// src/methods/video.ts
|
|
@@ -254,8 +304,8 @@ async function video(client2, body) {
|
|
|
254
304
|
function videoDetails(client2, videoUrl) {
|
|
255
305
|
return video(client2, { type: "details", videoUrl });
|
|
256
306
|
}
|
|
257
|
-
function transcript(client2, videoUrl) {
|
|
258
|
-
return video(client2, { type: "transcript", videoUrl });
|
|
307
|
+
function transcript(client2, videoUrl, options = {}) {
|
|
308
|
+
return video(client2, { type: "transcript", videoUrl, ...options });
|
|
259
309
|
}
|
|
260
310
|
function comments(client2, videoUrl, options = {}) {
|
|
261
311
|
return video(client2, {
|
|
@@ -304,8 +354,8 @@ var Stophy = class {
|
|
|
304
354
|
videoDetails(videoUrl) {
|
|
305
355
|
return videoDetails(this.client, videoUrl);
|
|
306
356
|
}
|
|
307
|
-
transcript(videoUrl) {
|
|
308
|
-
return transcript(this.client, videoUrl);
|
|
357
|
+
transcript(videoUrl, options) {
|
|
358
|
+
return transcript(this.client, videoUrl, options);
|
|
309
359
|
}
|
|
310
360
|
comments(videoUrl, options) {
|
|
311
361
|
return comments(this.client, videoUrl, options);
|
|
@@ -328,6 +378,12 @@ var Stophy = class {
|
|
|
328
378
|
async suggest(queryOrOptions, options) {
|
|
329
379
|
return suggest(this.client, queryOrOptions, options);
|
|
330
380
|
}
|
|
381
|
+
music(body) {
|
|
382
|
+
return music(this.client, body);
|
|
383
|
+
}
|
|
384
|
+
kids(body) {
|
|
385
|
+
return kids(this.client, body);
|
|
386
|
+
}
|
|
331
387
|
credits() {
|
|
332
388
|
return credits(this.client);
|
|
333
389
|
}
|
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,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,CACxB,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,aAAA;AAAA,IACL,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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.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"]}
|
|
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/kids.ts","../src/methods/music.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;;;ACyCO,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,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,UAAA,GAAa,CACxB,OAAA,KACG;AACH,EAAA,OAAA,CAAQ,OAAA,CAAQ,MAAA,IAAU,MAAA,EAAe,IAAA,CAIvC;AAAA,IACA,QAAA,EAAU;AAAA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A,OAAO,OAAA,CAAe,IAAA,CAAK,MAAA,EAAQ,cAAA,EAAgB,OAAO,CAAA;AAAA,EAC3D;AAAA,EAEA,MACC,IAAA,EACoD;AACpD,IAAA,OAAO,KAAA,CAAS,IAAA,CAAK,MAAA,EAAQ,IAAI,CAAA;AAAA,EAClC;AAAA,EAEA,KACC,IAAA,EACmD;AACnD,IAAA,OAAO,IAAA,CAAQ,IAAA,CAAK,MAAA,EAAQ,IAAI,CAAA;AAAA,EACjC;AAAA,EAEA,OAAA,GAAoC;AACnC,IAAA,OAAsB,OAAA,CAAQ,KAAK,MAAM,CAAA;AAAA,EAC1C;AAAA,EAEA,KAAK,KAAA,EAAqD;AACzD,IAAA,OAAsB,IAAA,CAAK,IAAA,CAAK,MAAA,EAAQ,KAAK,CAAA;AAAA,EAC9C;AAAA,EAEA,MAAM,KAAA,EAAuD;AAC5D,IAAA,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 SearchVideosData,\n SearchVideosResponse,\n SearchVideosError,\n GetVideoData,\n GetVideoResponse,\n GetVideoError,\n GetChannelData,\n GetChannelResponse,\n GetChannelError,\n GetPlaylistData,\n GetPlaylistResponse,\n GetPlaylistError,\n GetSuggestionsData,\n GetSuggestionsResponse,\n GetSuggestionsError,\n YoutubeMusicData,\n YoutubeMusicResponse,\n YoutubeMusicError,\n YoutubeKidsData,\n YoutubeKidsResponse,\n YoutubeKidsError,\n GetCreditsData,\n GetCreditsResponse,\n GetCreditsError,\n GetUsageData,\n GetUsageResponse,\n GetUsageError,\n GetLogsData,\n GetLogsResponse,\n GetLogsError,\n McpTransportHeaderData,\n McpTransportHeaderResponse,\n McpTransportHeaderError,\n McpTransportPathData,\n McpTransportPathResponse,\n McpTransportPathError,\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 * 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 * 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 * Channel\n * Retrieve channel metadata and content by channelUrl. Use the tab field to switch between videos, Shorts, live streams, playlists, community posts, courses, and about info. Set query to search within the channel.\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).post<\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 headers: {\n \"Content-Type\": \"application/json\",\n ...options?.headers,\n },\n });\n};\n\n/**\n * YouTube Music\n * Search YouTube Music, fetch suggestions, song metadata, lyrics, albums, artists, and playlists. The `type` request field selects the operation.\n */\nexport const youtubeMusic = <ThrowOnError extends boolean = false>(\n options: Options<YoutubeMusicData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).post<\n YoutubeMusicResponse,\n YoutubeMusicError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/music\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n ...options?.headers,\n },\n });\n};\n\n/**\n * YouTube Kids\n * Search YouTube Kids or fetch Kids video details. The `type` request field selects the operation.\n */\nexport const youtubeKids = <ThrowOnError extends boolean = false>(\n options: Options<YoutubeKidsData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).post<\n YoutubeKidsResponse,\n YoutubeKidsError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/kids\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n ...options?.headers,\n },\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 * 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\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 * MCP transport (header auth)\n * Streamable HTTP MCP transport. Auth via Authorization: Bearer st_<key> header. Use this with MCP clients like Cursor or Claude Desktop. Each tool call costs 1 credit except stophy_get_credits which is free.\n */\nexport const mcpTransportHeader = <ThrowOnError extends boolean = false>(\n options: Options<McpTransportHeaderData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).post<\n McpTransportHeaderResponse,\n McpTransportHeaderError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/mcp\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n ...options?.headers,\n },\n });\n};\n\n/**\n * MCP transport (path auth)\n * Streamable HTTP MCP transport. Auth via the API key in the URL path. Useful when header auth isn't possible. Note that the key will appear in logs and referrer headers.\n */\nexport const mcpTransportPath = <ThrowOnError extends boolean = false>(\n options: Options<McpTransportPathData, ThrowOnError>\n) => {\n return (options.client ?? _heyApiClient).post<\n McpTransportPathResponse,\n McpTransportPathError,\n ThrowOnError\n >({\n security: [\n {\n scheme: \"bearer\",\n type: \"http\",\n },\n ],\n url: \"/v1/mcp/{apiKey}\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n ...options?.headers,\n },\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\";\nimport type { AccountResponse } from \"./response\";\n\nexport type CreditsResponse = AccountResponse<\n\tNonNullable<GetCreditsResponse[\"data\"]>\n>;\nexport type LogsResponse = AccountResponse<\n\tNonNullable<GetLogsResponse[\"data\"]>\n>;\nexport type UsageResponse = AccountResponse<\n\tNonNullable<GetUsageResponse[\"data\"]>\n>;\n\nexport function credits(client: Client): Promise<CreditsResponse> {\n\treturn getCredits({ client }).then(unwrap) as Promise<CreditsResponse>;\n}\n\nexport function logs(\n\tclient: Client,\n\tquery?: GetLogsData[\"query\"],\n): Promise<LogsResponse> {\n\treturn getLogs({ client, query }).then(unwrap) as Promise<LogsResponse>;\n}\n\nexport function usage(\n\tclient: Client,\n\tquery?: GetUsageData[\"query\"],\n): Promise<UsageResponse> {\n\treturn getUsage({ client, query }).then(unwrap) as Promise<UsageResponse>;\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\";\nimport type { MeteredResponse } from \"./response\";\n\ntype ChannelBody = GetChannelData[\"body\"];\nexport type ChannelOptions = Omit<ChannelBody, \"channelUrl\">;\ntype GeneratedChannelData = NonNullable<GetChannelResponse[\"data\"]>;\ntype GeneratedChannelItem = GeneratedChannelData[\"items\"][number];\n\nexport interface ChannelCourseItem {\n\ttype: \"course\";\n\tid: string;\n\turl: string;\n\tcourseUrl: string;\n\tplaylistUrl: string;\n\ttitle: string | null;\n\tauthor: string | null;\n\tauthorId: string | null;\n\tvideoCount: number | null;\n\tvideoCountText: string | null;\n\tthumbnails: Array<{ url: string; width: number; height: number }>;\n}\n\nexport type ChannelData = Omit<GeneratedChannelData, \"items\" | \"tab\"> & {\n\titems: Array<GeneratedChannelItem | ChannelCourseItem>;\n\ttab: ChannelBody[\"tab\"] | \"community\" | \"course\";\n};\n\nexport type ChannelResponse = MeteredResponse<ChannelData>;\n\nexport function channel(\n\tclient: Client,\n\turlOrBody: string | ChannelBody,\n\toptions: ChannelOptions = {},\n): Promise<ChannelResponse> {\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) as Promise<ChannelResponse>;\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { youtubeKids } from \"../generated/sdk.gen\";\nimport type { KidsSearchData, KidsVideoData } from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\nimport type { MeteredResponse } from \"./response\";\n\nexport type KidsInput =\n\t| { type: \"search\"; q: string; continuationToken?: string }\n\t| { type: \"video\"; videoUrl: string };\n\nexport type KidsDataFor<T extends KidsInput[\"type\"]> = T extends \"search\"\n\t? KidsSearchData\n\t: KidsVideoData;\n\nexport function kids<T extends KidsInput>(\n\tclient: Client,\n\tbody: T,\n): Promise<MeteredResponse<KidsDataFor<T[\"type\"]>>> {\n\treturn youtubeKids({ client, body }).then(unwrap) as Promise<\n\t\tMeteredResponse<KidsDataFor<T[\"type\"]>>\n\t>;\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { youtubeMusic } from \"../generated/sdk.gen\";\nimport type {\n\tMusicAlbumData,\n\tMusicArtistData,\n\tMusicLyricsData,\n\tMusicPlaylistData,\n\tMusicSearchData,\n\tMusicSongData,\n\tMusicSuggestData,\n\tYoutubeMusicData,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\nimport type { MeteredResponse } from \"./response\";\n\ntype GeneratedMusicBody = YoutubeMusicData[\"body\"];\ntype SearchType = NonNullable<GeneratedMusicBody[\"searchType\"]>;\n\nexport type MusicInput =\n\t| {\n\t\t\ttype: \"search\";\n\t\t\tq: string;\n\t\t\tsearchType?: SearchType;\n\t\t\tcontinuationToken?: string;\n\t }\n\t| { type: \"suggest\"; q: string }\n\t| { type: \"song\" | \"lyrics\"; videoUrl: string }\n\t| { type: \"album\"; albumUrl: string }\n\t| { type: \"artist\"; artistUrl: string }\n\t| {\n\t\t\ttype: \"playlist\";\n\t\t\tplaylistUrl: string;\n\t\t\tcontinuationToken?: string;\n\t };\n\nexport type MusicDataFor<T extends MusicInput[\"type\"]> = T extends \"search\"\n\t? MusicSearchData\n\t: T extends \"suggest\"\n\t\t? MusicSuggestData\n\t\t: T extends \"song\"\n\t\t\t? MusicSongData\n\t\t\t: T extends \"lyrics\"\n\t\t\t\t? MusicLyricsData\n\t\t\t\t: T extends \"album\"\n\t\t\t\t\t? MusicAlbumData\n\t\t\t\t\t: T extends \"artist\"\n\t\t\t\t\t\t? MusicArtistData\n\t\t\t\t\t\t: MusicPlaylistData;\n\nexport function music<T extends MusicInput>(\n\tclient: Client,\n\tbody: T,\n): Promise<MeteredResponse<MusicDataFor<T[\"type\"]>>> {\n\treturn youtubeMusic({ client, body }).then(unwrap) as Promise<\n\t\tMeteredResponse<MusicDataFor<T[\"type\"]>>\n\t>;\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\";\nimport type { MeteredResponse } from \"./response\";\n\ntype PlaylistBody = GetPlaylistData[\"body\"];\nexport type PlaylistOptions = Omit<PlaylistBody, \"playlistUrl\">;\nexport type PlaylistResponse = MeteredResponse<\n\tNonNullable<GetPlaylistResponse[\"data\"]>\n>;\n\nexport function playlist(\n\tclient: Client,\n\turlOrBody: string | PlaylistBody,\n\toptions: PlaylistOptions = {},\n): Promise<PlaylistResponse> {\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(\n\t\tunwrap,\n\t) as Promise<PlaylistResponse>;\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\";\nimport type { MeteredResponse } from \"./response\";\n\ntype SearchBody = SearchVideosData[\"body\"];\nexport type SearchOptions = Omit<SearchBody, \"q\">;\nexport type SearchResponse = MeteredResponse<\n\tNonNullable<SearchVideosResponse[\"data\"]>\n>;\n\nexport function search(\n\tclient: Client,\n\tqueryOrBody: string | SearchBody,\n\toptions: SearchOptions = {},\n): Promise<SearchResponse> {\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) as Promise<SearchResponse>;\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\";\nimport type { MeteredResponse } from \"./response\";\n\ntype SuggestBody = GetSuggestionsData[\"body\"];\nexport type SuggestOptions = Omit<SuggestBody, \"q\">;\nexport type SuggestResponse = MeteredResponse<\n\tNonNullable<GetSuggestionsResponse[\"data\"]>\n>;\n\nexport function suggest(\n\tclient: Client,\n\tqueryOrOptions: string | SuggestBody,\n\toptions: SuggestOptions = {},\n): Promise<SuggestResponse> {\n\tif (typeof queryOrOptions === \"string\" && !queryOrOptions.trim()) {\n\t\tthrow new Error(\"query cannot be empty\");\n\t}\n\tconst body =\n\t\ttypeof queryOrOptions === \"string\"\n\t\t\t? { q: queryOrOptions, ...options }\n\t\t\t: queryOrOptions;\n\treturn getSuggestions({ client, body }).then(\n\t\tunwrap,\n\t) as Promise<SuggestResponse>;\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport { getVideo } from \"../generated/sdk.gen\";\nimport type {\n\tGetVideoData,\n\tVideoResponseComments,\n\tVideoResponseDetails,\n\tVideoResponseLivechat,\n\tVideoResponseReplies,\n\tVideoResponseTranscript,\n} from \"../generated/types.gen\";\nimport { unwrap } from \"../transport\";\nimport type { MeteredResponse } from \"./response\";\n\nexport type VideoResponseFor<T> = MeteredResponse<T>;\ntype VideoUrlBody = Extract<GetVideoData[\"body\"], { videoUrl: string }>;\nexport type CommentsOptions = Pick<\n\tVideoUrlBody,\n\t\"sortBy\" | \"continuationToken\"\n>;\nexport type TranscriptOptions = Pick<VideoUrlBody, \"lang\">;\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<\n\tVideoResponseFor<\n\t\t| VideoResponseDetails\n\t\t| VideoResponseTranscript\n\t\t| VideoResponseComments\n\t\t| VideoResponseReplies\n\t\t| VideoResponseLivechat\n\t>\n> {\n\treturn unwrap(await getVideo({ client, body })) as VideoResponseFor<\n\t\t| VideoResponseDetails\n\t\t| VideoResponseTranscript\n\t\t| VideoResponseComments\n\t\t| VideoResponseReplies\n\t\t| VideoResponseLivechat\n\t>;\n}\n\nexport function videoDetails(\n\tclient: Client,\n\tvideoUrl: string,\n): Promise<VideoResponseFor<VideoResponseDetails>> {\n\treturn video(client, { type: \"details\", videoUrl }) as Promise<\n\t\tVideoResponseFor<VideoResponseDetails>\n\t>;\n}\n\nexport function transcript(\n\tclient: Client,\n\tvideoUrl: string,\n\toptions: TranscriptOptions = {},\n): Promise<VideoResponseFor<VideoResponseTranscript>> {\n\treturn video(client, { type: \"transcript\", videoUrl, ...options }) as Promise<\n\t\tVideoResponseFor<VideoResponseTranscript>\n\t>;\n}\n\nexport function comments(\n\tclient: Client,\n\tvideoUrl: string,\n\toptions: CommentsOptions = {},\n): Promise<VideoResponseFor<VideoResponseComments>> {\n\treturn video(client, {\n\t\ttype: \"comments\",\n\t\tvideoUrl,\n\t\t...options,\n\t}) as Promise<VideoResponseFor<VideoResponseComments>>;\n}\n\nexport function replies(\n\tclient: Client,\n\tcontinuationToken: string,\n): Promise<VideoResponseFor<VideoResponseReplies>> {\n\treturn video(client, {\n\t\ttype: \"replies\",\n\t\tcontinuationToken,\n\t}) as Promise<VideoResponseFor<VideoResponseReplies>>;\n}\n\nexport function liveChat(\n\tclient: Client,\n\tvideoUrl: string,\n\toptions: LiveChatOptions = {},\n): Promise<VideoResponseFor<VideoResponseLivechat>> {\n\treturn video(client, {\n\t\ttype: \"livechat\",\n\t\tvideoUrl,\n\t\t...options,\n\t}) as Promise<VideoResponseFor<VideoResponseLivechat>>;\n}\n","import type { Client } from \"@hey-api/client-fetch\";\nimport type {\n\tGetChannelData,\n\tGetLogsData,\n\tGetPlaylistData,\n\tGetSuggestionsData,\n\tGetUsageData,\n\tGetVideoData,\n\tGetVideoResponse,\n\tSearchVideosData,\n\tVideoResponseComments,\n\tVideoResponseDetails,\n\tVideoResponseLivechat,\n\tVideoResponseReplies,\n\tVideoResponseTranscript,\n} from \"./generated/types.gen\";\nimport type {\n\tCreditsResponse,\n\tLogsResponse,\n\tUsageResponse,\n} from \"./methods/account\";\nimport * as accountMethods from \"./methods/account\";\nimport {\n\ttype ChannelOptions,\n\ttype ChannelResponse,\n\tchannel as getChannel,\n} from \"./methods/channel\";\nimport {\n\tkids as getKids,\n\ttype KidsDataFor,\n\ttype KidsInput,\n} from \"./methods/kids\";\nimport {\n\tmusic as getMusic,\n\ttype MusicDataFor,\n\ttype MusicInput,\n} from \"./methods/music\";\nimport {\n\tplaylist as getPlaylist,\n\ttype PlaylistOptions,\n\ttype PlaylistResponse,\n} from \"./methods/playlist\";\nimport type { MeteredResponse } from \"./methods/response\";\nimport {\n\ttype SearchOptions,\n\ttype SearchResponse,\n\tsearch as searchVideos,\n} from \"./methods/search\";\nimport {\n\tsuggest as getSuggestions,\n\ttype SuggestOptions,\n\ttype SuggestResponse,\n} from \"./methods/suggest\";\nimport type {\n\tCommentsOptions,\n\tLiveChatOptions,\n\tTranscriptOptions,\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<VideoResponseDetails>>;\n\tasync video(\n\t\tbody: GetVideoData[\"body\"] & { type: \"transcript\" },\n\t): Promise<VideoResponseFor<VideoResponseTranscript>>;\n\tasync video(\n\t\tbody: GetVideoData[\"body\"] & { type: \"comments\" },\n\t): Promise<VideoResponseFor<VideoResponseComments>>;\n\tasync video(\n\t\tbody: GetVideoData[\"body\"] & { type: \"replies\" },\n\t): Promise<VideoResponseFor<VideoResponseReplies>>;\n\tasync video(\n\t\tbody: GetVideoData[\"body\"] & { type: \"livechat\" },\n\t): Promise<VideoResponseFor<VideoResponseLivechat>>;\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(\n\t\tvideoUrl: string,\n\t): Promise<VideoResponseFor<VideoResponseDetails>> {\n\t\treturn videoMethods.videoDetails(this.client, videoUrl);\n\t}\n\n\ttranscript(\n\t\tvideoUrl: string,\n\t\toptions?: TranscriptOptions,\n\t): Promise<VideoResponseFor<VideoResponseTranscript>> {\n\t\treturn videoMethods.transcript(this.client, videoUrl, options);\n\t}\n\n\tcomments(\n\t\tvideoUrl: string,\n\t\toptions?: CommentsOptions,\n\t): Promise<VideoResponseFor<VideoResponseComments>> {\n\t\treturn videoMethods.comments(this.client, videoUrl, options);\n\t}\n\n\treplies(\n\t\tcontinuationToken: string,\n\t): Promise<VideoResponseFor<VideoResponseReplies>> {\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<VideoResponseLivechat>> {\n\t\treturn videoMethods.liveChat(this.client, videoUrl, options);\n\t}\n\n\tasync search(body: SearchVideosData[\"body\"]): Promise<SearchResponse>;\n\tasync search(query: string, options?: SearchOptions): Promise<SearchResponse>;\n\tasync search(\n\t\tqueryOrBody: string | SearchVideosData[\"body\"],\n\t\toptions?: SearchOptions,\n\t): Promise<SearchResponse> {\n\t\treturn searchVideos(this.client, queryOrBody, options);\n\t}\n\n\tasync channel(body: GetChannelData[\"body\"]): Promise<ChannelResponse>;\n\tasync channel(\n\t\tchannelUrl: string,\n\t\toptions?: ChannelOptions,\n\t): Promise<ChannelResponse>;\n\tasync channel(\n\t\turlOrBody: string | GetChannelData[\"body\"],\n\t\toptions?: ChannelOptions,\n\t): Promise<ChannelResponse> {\n\t\treturn getChannel(this.client, urlOrBody, options);\n\t}\n\n\tasync playlist(body: GetPlaylistData[\"body\"]): Promise<PlaylistResponse>;\n\tasync playlist(\n\t\tplaylistUrl: string,\n\t\toptions?: PlaylistOptions,\n\t): Promise<PlaylistResponse>;\n\tasync playlist(\n\t\turlOrBody: string | GetPlaylistData[\"body\"],\n\t\toptions?: PlaylistOptions,\n\t): Promise<PlaylistResponse> {\n\t\treturn getPlaylist(this.client, urlOrBody, options);\n\t}\n\n\tasync suggest(query: GetSuggestionsData[\"body\"]): Promise<SuggestResponse>;\n\tasync suggest(\n\t\tquery: string,\n\t\toptions?: SuggestOptions,\n\t): Promise<SuggestResponse>;\n\tasync suggest(\n\t\tqueryOrOptions: string | GetSuggestionsData[\"body\"],\n\t\toptions?: SuggestOptions,\n\t): Promise<SuggestResponse> {\n\t\treturn getSuggestions(this.client, queryOrOptions, options);\n\t}\n\n\tmusic<T extends MusicInput>(\n\t\tbody: T,\n\t): Promise<MeteredResponse<MusicDataFor<T[\"type\"]>>> {\n\t\treturn getMusic(this.client, body);\n\t}\n\n\tkids<T extends KidsInput>(\n\t\tbody: T,\n\t): Promise<MeteredResponse<KidsDataFor<T[\"type\"]>>> {\n\t\treturn getKids(this.client, body);\n\t}\n\n\tcredits(): Promise<CreditsResponse> {\n\t\treturn accountMethods.credits(this.client);\n\t}\n\n\tlogs(query?: GetLogsData[\"query\"]): Promise<LogsResponse> {\n\t\treturn accountMethods.logs(this.client, query);\n\t}\n\n\tusage(query?: GetUsageData[\"query\"]): Promise<UsageResponse> {\n\t\treturn accountMethods.usage(this.client, query);\n\t}\n}\n"]}
|