@distilled.cloud/twitch 0.0.0 → 1.0.0-rc.22

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.
Files changed (214) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +79 -4
  3. package/lib/.lazy.json +1 -0
  4. package/lib/_bundle/lazy.js +4 -0
  5. package/lib/_bundle/sdk.js +2 -0
  6. package/lib/_bundle/sdk.js.map +1 -0
  7. package/lib/credentials.d.ts +31 -0
  8. package/lib/credentials.d.ts.map +1 -0
  9. package/lib/credentials.js +1 -0
  10. package/lib/errors.d.ts +49 -0
  11. package/lib/errors.d.ts.map +1 -0
  12. package/lib/errors.js +1 -0
  13. package/lib/index.d.ts +46 -0
  14. package/lib/index.d.ts.map +1 -0
  15. package/lib/index.js +6 -0
  16. package/lib/pagination.d.ts +10 -0
  17. package/lib/pagination.d.ts.map +1 -0
  18. package/lib/pagination.js +1 -0
  19. package/lib/protocol.d.ts +19 -0
  20. package/lib/protocol.d.ts.map +1 -0
  21. package/lib/protocol.js +1 -0
  22. package/lib/retry.d.ts +50 -0
  23. package/lib/retry.d.ts.map +1 -0
  24. package/lib/retry.js +1 -0
  25. package/lib/services/ads.d.ts +75 -0
  26. package/lib/services/ads.d.ts.map +1 -0
  27. package/lib/services/ads.js +2 -0
  28. package/lib/services/ads.js.map +1 -0
  29. package/lib/services/analytics.d.ts +90 -0
  30. package/lib/services/analytics.d.ts.map +1 -0
  31. package/lib/services/analytics.js +2 -0
  32. package/lib/services/analytics.js.map +1 -0
  33. package/lib/services/bits.d.ts +284 -0
  34. package/lib/services/bits.d.ts.map +1 -0
  35. package/lib/services/bits.js +2 -0
  36. package/lib/services/bits.js.map +1 -0
  37. package/lib/services/ccls.d.ts +26 -0
  38. package/lib/services/ccls.d.ts.map +1 -0
  39. package/lib/services/ccls.js +2 -0
  40. package/lib/services/ccls.js.map +1 -0
  41. package/lib/services/channel_points.d.ts +416 -0
  42. package/lib/services/channel_points.d.ts.map +1 -0
  43. package/lib/services/channel_points.js +2 -0
  44. package/lib/services/channel_points.js.map +1 -0
  45. package/lib/services/channels.d.ts +173 -0
  46. package/lib/services/channels.d.ts.map +1 -0
  47. package/lib/services/channels.js +2 -0
  48. package/lib/services/channels.js.map +1 -0
  49. package/lib/services/charity.d.ts +97 -0
  50. package/lib/services/charity.d.ts.map +1 -0
  51. package/lib/services/charity.js +2 -0
  52. package/lib/services/charity.js.map +1 -0
  53. package/lib/services/chat.d.ts +638 -0
  54. package/lib/services/chat.d.ts.map +1 -0
  55. package/lib/services/chat.js +33 -0
  56. package/lib/services/chat.js.map +1 -0
  57. package/lib/services/clips.d.ts +153 -0
  58. package/lib/services/clips.d.ts.map +1 -0
  59. package/lib/services/clips.js +2 -0
  60. package/lib/services/clips.js.map +1 -0
  61. package/lib/services/conduits.d.ts +172 -0
  62. package/lib/services/conduits.d.ts.map +1 -0
  63. package/lib/services/conduits.js +2 -0
  64. package/lib/services/conduits.js.map +1 -0
  65. package/lib/services/entitlements.d.ts +76 -0
  66. package/lib/services/entitlements.d.ts.map +1 -0
  67. package/lib/services/entitlements.js +2 -0
  68. package/lib/services/entitlements.js.map +1 -0
  69. package/lib/services/eventsub.d.ts +158 -0
  70. package/lib/services/eventsub.d.ts.map +1 -0
  71. package/lib/services/eventsub.js +2 -0
  72. package/lib/services/eventsub.js.map +1 -0
  73. package/lib/services/extensions.d.ts +497 -0
  74. package/lib/services/extensions.d.ts.map +1 -0
  75. package/lib/services/extensions.js +2 -0
  76. package/lib/services/extensions.js.map +1 -0
  77. package/lib/services/games.d.ts +57 -0
  78. package/lib/services/games.d.ts.map +1 -0
  79. package/lib/services/games.js +2 -0
  80. package/lib/services/games.js.map +1 -0
  81. package/lib/services/goals.d.ts +37 -0
  82. package/lib/services/goals.d.ts.map +1 -0
  83. package/lib/services/goals.js +2 -0
  84. package/lib/services/goals.js.map +1 -0
  85. package/lib/services/guest_star.d.ts +314 -0
  86. package/lib/services/guest_star.d.ts.map +1 -0
  87. package/lib/services/guest_star.js +2 -0
  88. package/lib/services/guest_star.js.map +1 -0
  89. package/lib/services/hype_train.d.ts +91 -0
  90. package/lib/services/hype_train.d.ts.map +1 -0
  91. package/lib/services/hype_train.js +2 -0
  92. package/lib/services/hype_train.js.map +1 -0
  93. package/lib/services/index.d.ts +30 -0
  94. package/lib/services/index.d.ts.map +1 -0
  95. package/lib/services/index.js +29 -0
  96. package/lib/services/moderation.d.ts +731 -0
  97. package/lib/services/moderation.d.ts.map +1 -0
  98. package/lib/services/moderation.js +41 -0
  99. package/lib/services/moderation.js.map +1 -0
  100. package/lib/services/polls.d.ts +173 -0
  101. package/lib/services/polls.d.ts.map +1 -0
  102. package/lib/services/polls.js +2 -0
  103. package/lib/services/polls.js.map +1 -0
  104. package/lib/services/predictions.d.ts +221 -0
  105. package/lib/services/predictions.d.ts.map +1 -0
  106. package/lib/services/predictions.js +2 -0
  107. package/lib/services/predictions.js.map +1 -0
  108. package/lib/services/raids.d.ts +34 -0
  109. package/lib/services/raids.d.ts.map +1 -0
  110. package/lib/services/raids.js +2 -0
  111. package/lib/services/raids.js.map +1 -0
  112. package/lib/services/schedule.d.ts +223 -0
  113. package/lib/services/schedule.d.ts.map +1 -0
  114. package/lib/services/schedule.js +2 -0
  115. package/lib/services/schedule.js.map +1 -0
  116. package/lib/services/search.d.ts +89 -0
  117. package/lib/services/search.d.ts.map +1 -0
  118. package/lib/services/search.js +2 -0
  119. package/lib/services/search.js.map +1 -0
  120. package/lib/services/streams.d.ts +235 -0
  121. package/lib/services/streams.d.ts.map +1 -0
  122. package/lib/services/streams.js +2 -0
  123. package/lib/services/streams.js.map +1 -0
  124. package/lib/services/subscriptions.d.ts +96 -0
  125. package/lib/services/subscriptions.d.ts.map +1 -0
  126. package/lib/services/subscriptions.js +2 -0
  127. package/lib/services/subscriptions.js.map +1 -0
  128. package/lib/services/teams.d.ts +90 -0
  129. package/lib/services/teams.d.ts.map +1 -0
  130. package/lib/services/teams.js +2 -0
  131. package/lib/services/teams.js.map +1 -0
  132. package/lib/services/users.d.ts +324 -0
  133. package/lib/services/users.d.ts.map +1 -0
  134. package/lib/services/users.js +2 -0
  135. package/lib/services/users.js.map +1 -0
  136. package/lib/services/videos.d.ts +101 -0
  137. package/lib/services/videos.d.ts.map +1 -0
  138. package/lib/services/videos.js +2 -0
  139. package/lib/services/videos.js.map +1 -0
  140. package/lib/services/whispers.d.ts +17 -0
  141. package/lib/services/whispers.d.ts.map +1 -0
  142. package/lib/services/whispers.js +2 -0
  143. package/lib/services/whispers.js.map +1 -0
  144. package/lib/services.lazy/ads.js +1 -0
  145. package/lib/services.lazy/analytics.js +1 -0
  146. package/lib/services.lazy/bits.js +1 -0
  147. package/lib/services.lazy/ccls.js +1 -0
  148. package/lib/services.lazy/channel_points.js +1 -0
  149. package/lib/services.lazy/channels.js +1 -0
  150. package/lib/services.lazy/charity.js +1 -0
  151. package/lib/services.lazy/chat.js +3 -0
  152. package/lib/services.lazy/clips.js +1 -0
  153. package/lib/services.lazy/conduits.js +1 -0
  154. package/lib/services.lazy/entitlements.js +1 -0
  155. package/lib/services.lazy/eventsub.js +1 -0
  156. package/lib/services.lazy/extensions.js +1 -0
  157. package/lib/services.lazy/games.js +1 -0
  158. package/lib/services.lazy/goals.js +1 -0
  159. package/lib/services.lazy/guest_star.js +1 -0
  160. package/lib/services.lazy/hype_train.js +1 -0
  161. package/lib/services.lazy/index.js +3 -0
  162. package/lib/services.lazy/moderation.js +3 -0
  163. package/lib/services.lazy/polls.js +1 -0
  164. package/lib/services.lazy/predictions.js +1 -0
  165. package/lib/services.lazy/raids.js +1 -0
  166. package/lib/services.lazy/schedule.js +1 -0
  167. package/lib/services.lazy/search.js +1 -0
  168. package/lib/services.lazy/streams.js +1 -0
  169. package/lib/services.lazy/subscriptions.js +1 -0
  170. package/lib/services.lazy/teams.js +1 -0
  171. package/lib/services.lazy/users.js +1 -0
  172. package/lib/services.lazy/videos.js +1 -0
  173. package/lib/services.lazy/whispers.js +1 -0
  174. package/lib/traits.d.ts +10 -0
  175. package/lib/traits.d.ts.map +1 -0
  176. package/lib/traits.js +1 -0
  177. package/package.json +82 -2
  178. package/src/credentials.ts +79 -0
  179. package/src/errors.ts +78 -0
  180. package/src/index.ts +45 -0
  181. package/src/pagination.ts +9 -0
  182. package/src/protocol.ts +43 -0
  183. package/src/retry.ts +69 -0
  184. package/src/services/ads.ts +228 -0
  185. package/src/services/analytics.ts +253 -0
  186. package/src/services/bits.ts +631 -0
  187. package/src/services/ccls.ts +96 -0
  188. package/src/services/channel_points.ts +804 -0
  189. package/src/services/channels.ts +471 -0
  190. package/src/services/charity.ts +250 -0
  191. package/src/services/chat.ts +1547 -0
  192. package/src/services/clips.ts +385 -0
  193. package/src/services/conduits.ts +453 -0
  194. package/src/services/entitlements.ts +219 -0
  195. package/src/services/eventsub.ts +372 -0
  196. package/src/services/extensions.ts +1098 -0
  197. package/src/services/games.ts +184 -0
  198. package/src/services/goals.ts +110 -0
  199. package/src/services/guest_star.ts +762 -0
  200. package/src/services/hype_train.ts +214 -0
  201. package/src/services/index.ts +30 -0
  202. package/src/services/moderation.ts +1817 -0
  203. package/src/services/polls.ts +363 -0
  204. package/src/services/predictions.ts +432 -0
  205. package/src/services/raids.ts +127 -0
  206. package/src/services/schedule.ts +539 -0
  207. package/src/services/search.ts +248 -0
  208. package/src/services/streams.ts +579 -0
  209. package/src/services/subscriptions.ts +247 -0
  210. package/src/services/teams.ts +225 -0
  211. package/src/services/users.ts +729 -0
  212. package/src/services/videos.ts +257 -0
  213. package/src/services/whispers.ts +71 -0
  214. package/src/traits.ts +47 -0
@@ -0,0 +1,257 @@
1
+ import * as API from "@distilled.cloud/core/api";
2
+ // AUTO-GENERATED by scripts/generate.ts from .generated-specs (specs/spec-mirror-twitch/specs/api/reference). Do not edit.
3
+ import * as S from "@distilled.cloud/core/schema-lite";
4
+ import * as __L from "@distilled.cloud/core/schema-lite";
5
+ import { TwitchServiceErrors } from "../errors.ts";
6
+ import { paginateCursor } from "../pagination.ts";
7
+ import { TwitchProtocol, type TwitchOpError, type TwitchOpContext } from "../protocol.ts";
8
+ import * as Retry from "../retry.ts";
9
+ import * as T from "../traits.ts";
10
+ // Schema table, filled on first reach (see __S at the end).
11
+ const __s: any[] = [];
12
+
13
+ export type { TwitchOpError, TwitchOpContext };
14
+
15
+ /** Span facts shared by every operation (com.distilled.telemetry#service). */
16
+ const TELEMETRY = {
17
+ system: "twitch-api",
18
+ responseHeaders: [
19
+ { header: "x-request-id", name: "http.response.header.x-request-id", transform: "list" },
20
+ { header: "request-id", name: "http.response.header.request-id", transform: "list" },
21
+ ],
22
+ prefix: "Twitch",
23
+ service: "Videos",
24
+ propagate: "w3c",
25
+ } as const;
26
+
27
+ export type DeleteVideosRequestIdList = Array<string>;
28
+ export interface DeleteVideosRequest {
29
+ /** The list of videos to delete. To specify more than one video, include the *id* parameter for each video to delete. For example, 'id=1234&id=5678'. You can delete a maximum of 5 videos per request. If any ID doesn't identify a video that the user has permission to delete, none of the videos are deleted. */
30
+ id: DeleteVideosRequestIdList;
31
+ }
32
+ /** The list of IDs of the videos that were deleted. */
33
+ export type DeleteVideosResponseDataList = Array<string>;
34
+ export interface DeleteVideosResponse {
35
+ /** The list of IDs of the videos that were deleted. */
36
+ data?: DeleteVideosResponseDataList | undefined;
37
+ }
38
+ export type GetVideosRequestIdList = Array<string>;
39
+ export interface GetVideosRequest {
40
+ /** A list of IDs that identify the videos you want to get. To get more than one video, include this parameter for each video you want to get. For example, 'id=1234&id=5678'. You may specify a maximum of 100 IDs. The endpoint ignores duplicate IDs and IDs that weren't found. The *id*, *user_id*, and *game_id* parameters are mutually exclusive. */
41
+ id?: GetVideosRequestIdList | undefined;
42
+ /** The ID of the user whose list of videos you want to get. The *id*, *user_id*, and *game_id* parameters are mutually exclusive. */
43
+ user_id?: string | undefined;
44
+ /** A category or game ID. The response contains a maximum of 500 videos that show this content. To get category/game IDs, use the [Search Categories](https://dev.twitch.tv/docs/api/reference/search.md#search-categories) endpoint. The *id*, *user_id*, and *game_id* parameters are mutually exclusive. */
45
+ game_id?: string | undefined;
46
+ /** A filter used to filter the list of videos by the language that the video owner broadcasts in. For example, to get videos that were broadcast in German, set this parameter to the ISO 639-1 two-letter code for German (i.e., DE). For a list of supported languages, see [Supported Stream Language](https://help.twitch.tv/s/article/languages-on-twitch#streamlang). If the language is not supported, use "other." To filter by more than one language, separate the codes with commas (for example, de,en). Specify this parameter only if you specify the *game_id* or *user_id* query parameter. If you specify *game_id* but not *language*, the API filters by the first language in the request's Accept-Language header, if the request includes one. */
47
+ language?: string | undefined;
48
+ /** A filter used to filter the list of videos by when they were created. For example, videos created in the last week. The default is *all*. Possible values: - `all` - `day` - `month` - `week` */
49
+ period?: string | undefined;
50
+ /** The order to sort the returned videos in. The default is *time*. Possible values: - `time`: Sort the results in descending order by when they were created (i.e., latest video first). If you specify *user_id*, the API sorts by when the videos were published, or by when they were created if they weren't published. - `trending`: Sort the results in descending order by biggest gains in viewership (i.e., highest trending video first). - `views`: Sort the results in descending order by most views (i.e., highest number of views first). */
51
+ sort?: string | undefined;
52
+ /** A filter used to filter the list of videos by the video's type. The default is *all*. Possible values: - `all` - `archive`: On-demand videos (VODs) of past streams. - `highlight`: Highlight reels of past streams. - `upload`: External videos that the broadcaster uploaded using the Video Producer. */
53
+ type?: string | undefined;
54
+ /** The maximum number of items to return per page in the response. The minimum page size is 1 item per page and the maximum is 100. The default is 20. Specify this parameter only if you specify the *game_id* or *user_id* query parameter. */
55
+ first?: number | undefined;
56
+ /** The cursor used to get the next page of results. The **Pagination** object in the response contains the cursor's value. [Read More](https://dev.twitch.tv/docs/api/guide.md#pagination) Specify this parameter only if you specify the *game_id* or *user_id* query parameter. */
57
+ after?: string | undefined;
58
+ /** The cursor used to get the previous page of results. The **Pagination** object in the response contains the cursor's value. [Read More](https://dev.twitch.tv/docs/api/guide.md#pagination) Specify this parameter only if you specify the *game_id* or *user_id* query parameter. */
59
+ before?: string | undefined;
60
+ }
61
+ export interface GetVideosResponseDataItemMutedSegmentsItem {
62
+ /** The duration of the muted segment, in seconds. */
63
+ duration?: number | undefined;
64
+ /** The offset, in seconds, from the beginning of the video to where the muted segment begins. */
65
+ offset?: number | undefined;
66
+ }
67
+ /** The segments that Twitch Audio Recognition muted; otherwise, **null**. Always **null** if you use an app access token. */
68
+ export type GetVideosResponseDataItemMutedSegmentsList =
69
+ Array<GetVideosResponseDataItemMutedSegmentsItem>;
70
+ export interface GetVideosResponseDataItem {
71
+ /** An ID that identifies the video. */
72
+ id?: string | undefined;
73
+ /** The ID of the stream that the video originated from if the video's type is "archive;" otherwise, **null**. */
74
+ stream_id?: string | undefined;
75
+ /** The ID of the broadcaster that owns the video. */
76
+ user_id?: string | undefined;
77
+ /** The broadcaster's login name. */
78
+ user_login?: string | undefined;
79
+ /** The broadcaster's display name. */
80
+ user_name?: string | undefined;
81
+ /** The video's title. */
82
+ title?: string | undefined;
83
+ /** The video's description. */
84
+ description?: string | undefined;
85
+ /** The date and time, in UTC, of when the video was created. The timestamp is in RFC3339 format. */
86
+ created_at?: string | undefined;
87
+ /** The date and time, in UTC, of when the video was published. The timestamp is in RFC3339 format. */
88
+ published_at?: string | null | undefined;
89
+ /** The video's URL. */
90
+ url?: string | undefined;
91
+ /** A URL to a thumbnail image of the video. Before using the URL, you must replace the '%{width}' and '%{height}' placeholders with the width and height of the thumbnail you want returned. Due to current limitations, '${width}' must be 320 and '${height}' must be 180. */
92
+ thumbnail_url?: string | undefined;
93
+ /** The video's viewable state. Always set to **public**. */
94
+ viewable?: string | undefined;
95
+ /** The number of times that users have watched the video. */
96
+ view_count?: number | undefined;
97
+ /** The ISO 639-1 two-letter language code that the video was broadcast in. For example, the language code is DE if the video was broadcast in German. For a list of supported languages, see [Supported Stream Language](https://help.twitch.tv/s/article/languages-on-twitch#streamlang). The language value is "other" if the video was broadcast in a language not in the list of supported languages. */
98
+ language?: string | undefined;
99
+ /** The video's type. Possible values: - `archive`: An on-demand video (VOD) of one of the broadcaster's past streams. - `highlight`: A highlight reel of one of the broadcaster's past streams. See [Creating Highlights](https://help.twitch.tv/s/article/creating-highlights-and-stream-markers). - `upload`: A video that the broadcaster uploaded to their video library. See Upload under [Video Producer](https://help.twitch.tv/s/article/video-on-demand?language=en_US#videoproducer). - `past_premiere`: A past Premiere. Returned only when you get videos by *id*. - `premiere_upload`: A video uploaded for a Premiere. Returned only when you get videos by *id*. */
100
+ type?: string | undefined;
101
+ /** The video's length in hours (h), minutes (m), and seconds (s), with leading zero units left out. For example, 3m21s represents 3 minutes, 21 seconds, and 1h0m5s represents 1 hour, 5 seconds. */
102
+ duration?: string | undefined;
103
+ /** The segments that Twitch Audio Recognition muted; otherwise, **null**. Always **null** if you use an app access token. */
104
+ muted_segments?: GetVideosResponseDataItemMutedSegmentsList | null | undefined;
105
+ }
106
+ /** The list of published videos that match the filter criteria. The list is always empty if the request comes from a region where videos aren't available. */
107
+ export type GetVideosResponseDataList = Array<GetVideosResponseDataItem>;
108
+ /** Contains the information used to page through the list of results. The object is empty if the page has no videos, if you get videos by *id*, or if you specify *game_id* and reach the 500-video limit. The last page of results may still include a cursor; the page after it is empty. [Read More](https://dev.twitch.tv/docs/api/guide.md#pagination) */
109
+ export interface GetVideosResponsePagination {
110
+ /** The cursor used to get the next page of results. Use the cursor to set the request's *after* or *before* query parameter depending on whether you're paging forwards or backwards through the results. */
111
+ cursor?: string | undefined;
112
+ }
113
+ export interface GetVideosResponse {
114
+ /** The list of published videos that match the filter criteria. The list is always empty if the request comes from a region where videos aren't available. */
115
+ data: GetVideosResponseDataList;
116
+ /** Contains the information used to page through the list of results. The object is empty if the page has no videos, if you get videos by *id*, or if you specify *game_id* and reach the 500-video limit. The last page of results may still include a cursor; the page after it is empty. [Read More](https://dev.twitch.tv/docs/api/guide.md#pagination) */
117
+ pagination?: GetVideosResponsePagination | undefined;
118
+ }
119
+ export type DeleteVideosError = TwitchOpError;
120
+ /** Delete Videos You may delete past broadcasts, highlights, or uploads. The user in the access token must own the videos or be an editor for the channel that owns them. Authorization: Requires one of the following: - A [user access token](https://dev.twitch.tv/docs/authentication.md#user-access-tokens) that includes the **channel:manage:videos** scope. Reference: https://dev.twitch.tv/docs/api/reference/videos/#delete-videos */
121
+ export const deleteVideos: API.OperationMethod<
122
+ DeleteVideosRequest,
123
+ DeleteVideosResponse,
124
+ DeleteVideosError,
125
+ TwitchOpContext
126
+ > = /*@__PURE__*/ API.make(() => ({
127
+ input: __S(0, __c0, 0) as any as S.Schema<DeleteVideosRequest>,
128
+ output: __S(1, __c0, 1) as any as S.Schema<DeleteVideosResponse>,
129
+ errors: [],
130
+ serviceErrors: TwitchServiceErrors,
131
+ protocol: TwitchProtocol,
132
+ retry: Retry.Retry,
133
+ telemetry: TELEMETRY,
134
+ span: "DeleteVideos",
135
+ }));
136
+
137
+ export type GetVideosError = TwitchOpError;
138
+ /** Get Videos You may get videos by ID, by user, or by game/category. You must specify exactly one of the *id*, *user_id* and *game_id* query parameters; the request fails if you specify none of them or more than one. You may apply several filters to get a subset of the videos. The filters are applied as an AND operation to each video. For example, if *language* is set to **de** and *game_id* is set to 21779, the response includes only videos that show playing League of Legends by users that stream in German. The filters apply only if you get videos by user ID or game ID. Authorization: Requires one of the following: - A [user access token](https://dev.twitch.tv/docs/authentication.md#user-access-tokens). - An [app access token](https://dev.twitch.tv/docs/authentication.md#app-access-tokens). Reference: https://dev.twitch.tv/docs/api/reference/videos/#get-videos */
139
+ export const getVideos: API.PaginatedOperationMethod<
140
+ GetVideosRequest,
141
+ GetVideosResponse,
142
+ GetVideosError,
143
+ TwitchOpContext,
144
+ GetVideosResponseDataItem
145
+ > = /*@__PURE__*/ API.makePaginated(
146
+ () => ({
147
+ input: __S(16, __c2, 0) as any as S.Schema<GetVideosRequest>,
148
+ output: __S(22, __c2, 6) as any as S.Schema<GetVideosResponse>,
149
+ errors: [],
150
+ serviceErrors: TwitchServiceErrors,
151
+ protocol: TwitchProtocol,
152
+ retry: Retry.Retry,
153
+ telemetry: TELEMETRY,
154
+ span: "GetVideos",
155
+ pagination: {
156
+ mode: "cursor",
157
+ inputToken: "after",
158
+ outputToken: "pagination.cursor",
159
+ items: "data",
160
+ pageSize: "first",
161
+ } as const,
162
+ }),
163
+ paginateCursor,
164
+ ) as any;
165
+
166
+ // Schema builders: each runs one schema initializer, on that schema's first use.
167
+ function __c0(j: number): any {
168
+ switch (j) {
169
+ case 0:
170
+ return S.suspend(() =>
171
+ S.Struct({
172
+ id: __S(8, __c1, 0).pipe(T.Query()),
173
+ }).pipe(T.Http({ method: "DELETE", uri: "/videos", code: 200 })),
174
+ ).annotate({ identifier: "DeleteVideosRequest" });
175
+ case 1:
176
+ return S.suspend(() =>
177
+ S.Struct({
178
+ data: S.optional(__S(8, __c1, 0)),
179
+ }),
180
+ ).annotate({ identifier: "DeleteVideosResponse" });
181
+ }
182
+ }
183
+ function __c1(j: number): any {
184
+ switch (j) {
185
+ case 0:
186
+ return S.Array(S.String);
187
+ }
188
+ }
189
+ function __c2(j: number): any {
190
+ switch (j) {
191
+ case 0:
192
+ return S.suspend(() =>
193
+ S.Struct({
194
+ id: S.optional(__S(8, __c1, 0).pipe(T.Query())),
195
+ user_id: S.optional(S.String.pipe(T.Query())),
196
+ game_id: S.optional(S.String.pipe(T.Query())),
197
+ language: S.optional(S.String.pipe(T.Query())),
198
+ period: S.optional(S.String.pipe(T.Query())),
199
+ sort: S.optional(S.String.pipe(T.Query())),
200
+ type: S.optional(S.String.pipe(T.Query())),
201
+ first: S.optional(S.Number.pipe(T.Query())),
202
+ after: S.optional(S.String.pipe(T.Query())),
203
+ before: S.optional(S.String.pipe(T.Query())),
204
+ }).pipe(T.Http({ method: "GET", uri: "/videos", code: 200 })),
205
+ ).annotate({ identifier: "GetVideosRequest" });
206
+ case 1:
207
+ return S.suspend(() =>
208
+ S.Struct({
209
+ duration: S.optional(S.Number),
210
+ offset: S.optional(S.Number),
211
+ }),
212
+ ).annotate({ identifier: "GetVideosResponseDataItemMutedSegmentsItem" });
213
+ case 2:
214
+ return S.Array(__S(17, __c2, 1));
215
+ case 3:
216
+ return S.suspend(() =>
217
+ S.Struct({
218
+ id: S.optional(S.String),
219
+ stream_id: S.optional(S.String),
220
+ user_id: S.optional(S.String),
221
+ user_login: S.optional(S.String),
222
+ user_name: S.optional(S.String),
223
+ title: S.optional(S.String),
224
+ description: S.optional(S.String),
225
+ created_at: S.optional(S.String),
226
+ published_at: S.optional(S.NullOr(S.String)),
227
+ url: S.optional(S.String),
228
+ thumbnail_url: S.optional(S.String),
229
+ viewable: S.optional(S.String),
230
+ view_count: S.optional(S.Number),
231
+ language: S.optional(S.String),
232
+ type: S.optional(S.String),
233
+ duration: S.optional(S.String),
234
+ muted_segments: S.optional(S.NullOr(__S(18, __c2, 2))),
235
+ }),
236
+ ).annotate({ identifier: "GetVideosResponseDataItem" });
237
+ case 4:
238
+ return S.Array(__S(19, __c2, 3));
239
+ case 5:
240
+ return S.suspend(() =>
241
+ S.Struct({
242
+ cursor: S.optional(S.String),
243
+ }),
244
+ ).annotate({ identifier: "GetVideosResponsePagination" });
245
+ case 6:
246
+ return S.suspend(() =>
247
+ S.Struct({
248
+ data: __S(20, __c2, 4),
249
+ pagination: S.optional(__S(21, __c2, 5)),
250
+ }),
251
+ ).annotate({ identifier: "GetVideosResponse" });
252
+ }
253
+ }
254
+ // Schema table: entry i is schema j of builder f, made on first reach.
255
+ function __S(i: number, f: (j: number) => unknown, j: number): any {
256
+ return (__s[i] ??= __L.at(f, j));
257
+ }
@@ -0,0 +1,71 @@
1
+ import * as API from "@distilled.cloud/core/api";
2
+ // AUTO-GENERATED by scripts/generate.ts from .generated-specs (specs/spec-mirror-twitch/specs/api/reference). Do not edit.
3
+ import * as S from "@distilled.cloud/core/schema-lite";
4
+ import * as __L from "@distilled.cloud/core/schema-lite";
5
+ import { TwitchServiceErrors } from "../errors.ts";
6
+ import { TwitchProtocol, type TwitchOpError, type TwitchOpContext } from "../protocol.ts";
7
+ import * as Retry from "../retry.ts";
8
+ import * as T from "../traits.ts";
9
+ // Schema table, filled on first reach (see __S at the end).
10
+ const __s: any[] = [];
11
+
12
+ export type { TwitchOpError, TwitchOpContext };
13
+
14
+ /** Span facts shared by every operation (com.distilled.telemetry#service). */
15
+ const TELEMETRY = {
16
+ system: "twitch-api",
17
+ responseHeaders: [
18
+ { header: "x-request-id", name: "http.response.header.x-request-id", transform: "list" },
19
+ { header: "request-id", name: "http.response.header.request-id", transform: "list" },
20
+ ],
21
+ prefix: "Twitch",
22
+ service: "Whispers",
23
+ propagate: "w3c",
24
+ } as const;
25
+
26
+ export interface SendWhisperRequest {
27
+ /** The ID of the user sending the whisper. This user must have a verified phone number. This ID must match the user ID in the user access token. */
28
+ from_user_id: string;
29
+ /** The ID of the user to receive the whisper. */
30
+ to_user_id: string;
31
+ /** The whisper message to send. The message must not be empty. The maximum message lengths are: - 500 characters if the user you're sending the message to hasn't whispered you before. - 10,000 characters if the user you're sending the message to has whispered you before. Messages that exceed the maximum length are truncated. */
32
+ message: string;
33
+ }
34
+ export interface SendWhisperResponse {}
35
+ export type SendWhisperError = TwitchOpError;
36
+ /** Send Whisper NOTE: The user sending the whisper must have a verified phone number (see the **Phone Number** setting in your [Security and Privacy](https://www.twitch.tv/settings/security) settings). NOTE: The API may silently drop whispers that it suspects of violating Twitch policies. (The API does not indicate that it dropped the whisper; it returns a 204 status code as if it succeeded.) **Rate Limits**: You may whisper to a maximum of 40 unique recipients per day. Within the per day limit, you may whisper a maximum of 3 whispers per second and a maximum of 100 whispers per minute. Authorization: Requires one of the following: - A [user access token](https://dev.twitch.tv/docs/authentication.md#user-access-tokens) that includes the **user:manage:whispers** scope. Reference: https://dev.twitch.tv/docs/api/reference/whispers/#send-whisper */
37
+ export const sendWhisper: API.OperationMethod<
38
+ SendWhisperRequest,
39
+ SendWhisperResponse,
40
+ SendWhisperError,
41
+ TwitchOpContext
42
+ > = /*@__PURE__*/ API.make(() => ({
43
+ input: __S(0, __c0, 0) as any as S.Schema<SendWhisperRequest>,
44
+ output: __S(1, __c0, 1) as any as S.Schema<SendWhisperResponse>,
45
+ errors: [],
46
+ serviceErrors: TwitchServiceErrors,
47
+ protocol: TwitchProtocol,
48
+ retry: Retry.Retry,
49
+ telemetry: TELEMETRY,
50
+ span: "SendWhisper",
51
+ }));
52
+
53
+ // Schema builders: each runs one schema initializer, on that schema's first use.
54
+ function __c0(j: number): any {
55
+ switch (j) {
56
+ case 0:
57
+ return S.suspend(() =>
58
+ S.Struct({
59
+ from_user_id: S.String.pipe(T.Query()),
60
+ to_user_id: S.String.pipe(T.Query()),
61
+ message: S.String,
62
+ }).pipe(T.Http({ method: "POST", uri: "/whispers", code: 200 })),
63
+ ).annotate({ identifier: "SendWhisperRequest" });
64
+ case 1:
65
+ return S.suspend(() => S.Struct({})).annotate({ identifier: "SendWhisperResponse" });
66
+ }
67
+ }
68
+ // Schema table: entry i is schema j of builder f, made on first reach.
69
+ function __S(i: number, f: (j: number) => unknown, j: number): any {
70
+ return (__s[i] ??= __L.at(f, j));
71
+ }
package/src/traits.ts ADDED
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Twitch SDK trait surface -- hand-written.
3
+ *
4
+ * Re-exports the generic protocol traits from core so generated operations
5
+ * import everything from one place. Twitch speaks plain bearer-REST JSON with no
6
+ * success envelope, so there are no provider-specific traits.
7
+ */
8
+ export {
9
+ Body,
10
+ Header,
11
+ Query,
12
+ Label,
13
+ Http,
14
+ ResponseCode,
15
+ HttpBody,
16
+ FormDataFile,
17
+ KeyDictionary,
18
+ UnionCases,
19
+ applyErrorMatchers,
20
+ getErrorMatchers,
21
+ type HttpTrait,
22
+ type ErrorMatcher,
23
+ bodySymbol,
24
+ headerSymbol,
25
+ querySymbol,
26
+ labelSymbol,
27
+ httpSymbol,
28
+ responseCodeSymbol,
29
+ httpBodySymbol,
30
+ formDataFileSymbol,
31
+ keyDictionarySymbol,
32
+ unionCasesSymbol,
33
+ errorMatchersSymbol,
34
+ } from "@distilled.cloud/core/trait";
35
+
36
+ // Bearer-REST protocol traits (sensitive strings, bare-payload and binary
37
+ // responses).
38
+ export {
39
+ BinaryResponse,
40
+ SensitiveValue,
41
+ RawResponse,
42
+ RawResponseRoot,
43
+ binaryResponseSymbol,
44
+ sensitiveValueSymbol,
45
+ rawResponseSymbol,
46
+ rawResponseRootSymbol,
47
+ } from "@distilled.cloud/core/protocol-rest";