@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,432 @@
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: "Predictions",
24
+ propagate: "w3c",
25
+ } as const;
26
+
27
+ export interface CreatePredictionRequestOutcomesItem {
28
+ /** The text of one of the outcomes that the viewer may select. The title is limited to a maximum of 25 characters. */
29
+ title: string;
30
+ }
31
+ /** The list of possible outcomes that the viewers may choose from. The list must contain a minimum of 2 choices and up to a maximum of 10 choices. */
32
+ export type CreatePredictionRequestOutcomesList = Array<CreatePredictionRequestOutcomesItem>;
33
+ export interface CreatePredictionRequest {
34
+ /** The ID of the broadcaster that's running the prediction. This ID must match the user ID in the user access token. */
35
+ broadcaster_id: string;
36
+ /** The question that the broadcaster is asking. For example, *Will I finish this entire pizza?* The title is limited to a maximum of 45 characters. */
37
+ title: string;
38
+ /** The list of possible outcomes that the viewers may choose from. The list must contain a minimum of 2 choices and up to a maximum of 10 choices. */
39
+ outcomes: CreatePredictionRequestOutcomesList;
40
+ /** The length of time (in seconds) that the prediction will run for. The minimum is 1 second and the maximum is 1800 seconds (30 minutes). */
41
+ prediction_window: number;
42
+ }
43
+ export interface CreatePredictionResponseDataItemOutcomesItemTopPredictorsItem {
44
+ /** An ID that identifies the viewer. */
45
+ user_id?: string | undefined;
46
+ /** The viewer's display name. */
47
+ user_name?: string | undefined;
48
+ /** The viewer's login name. */
49
+ user_login?: string | undefined;
50
+ /** The number of Channel Points the viewer spent. */
51
+ channel_points_used?: number | undefined;
52
+ /** The number of Channel Points distributed to the viewer. */
53
+ channel_points_won?: number | undefined;
54
+ }
55
+ /** A list of viewers who were the top predictors; otherwise, **null** if none. */
56
+ export type CreatePredictionResponseDataItemOutcomesItemTopPredictorsList =
57
+ Array<CreatePredictionResponseDataItemOutcomesItemTopPredictorsItem>;
58
+ export interface CreatePredictionResponseDataItemOutcomesItem {
59
+ /** An ID that identifies this outcome. */
60
+ id?: string | undefined;
61
+ /** The outcome's text. */
62
+ title?: string | undefined;
63
+ /** The number of unique viewers that chose this outcome. */
64
+ users?: number | undefined;
65
+ /** The number of Channel Points spent by viewers on this outcome. */
66
+ channel_points?: number | undefined;
67
+ /** A list of viewers who were the top predictors; otherwise, **null** if none. */
68
+ top_predictors?: CreatePredictionResponseDataItemOutcomesItemTopPredictorsList | undefined;
69
+ /** The color that visually identifies this outcome in the UX. If the prediction has two outcomes, the first outcome is BLUE and the second is PINK. If it has more than two outcomes, all of them are BLUE. Possible values: - `BLUE` - `PINK` */
70
+ color?: string | undefined;
71
+ }
72
+ /** The list of possible outcomes for the prediction. */
73
+ export type CreatePredictionResponseDataItemOutcomesList =
74
+ Array<CreatePredictionResponseDataItemOutcomesItem>;
75
+ export interface CreatePredictionResponseDataItem {
76
+ /** An ID that identifies this prediction. */
77
+ id?: string | undefined;
78
+ /** An ID that identifies the broadcaster that created the prediction. */
79
+ broadcaster_id?: string | undefined;
80
+ /** The broadcaster's display name. */
81
+ broadcaster_name?: string | undefined;
82
+ /** The broadcaster's login name. */
83
+ broadcaster_login?: string | undefined;
84
+ /** The question that the prediction asks. For example, *Will I finish this entire pizza?* */
85
+ title?: string | undefined;
86
+ /** The ID of the winning outcome. Is **null** unless `status` is RESOLVED. */
87
+ winning_outcome_id?: string | undefined;
88
+ /** The list of possible outcomes for the prediction. */
89
+ outcomes?: CreatePredictionResponseDataItemOutcomesList | undefined;
90
+ /** The length of time (in seconds) that the prediction will run for. */
91
+ prediction_window?: number | undefined;
92
+ /** The prediction's status. Possible values: - `ACTIVE`: The Prediction is running and viewers can make predictions. - `CANCELED`: The broadcaster canceled the Prediction and refunded the Channel Points to the participants. - `LOCKED`: The broadcaster locked the Prediction, which means viewers can no longer make predictions. - `RESOLVED`: The winning outcome was determined and the Channel Points were distributed to the viewers who predicted the correct outcome. */
93
+ status?: string | undefined;
94
+ /** The UTC date and time of when the Prediction began. */
95
+ created_at?: string | undefined;
96
+ /** The UTC date and time of when the Prediction ended. If `status` is ACTIVE, this is set to **null**. */
97
+ ended_at?: string | undefined;
98
+ /** The UTC date and time of when the Prediction was locked. Is **null** if the Prediction hasn't been locked. */
99
+ locked_at?: string | undefined;
100
+ }
101
+ /** A list that contains the single prediction that you created. */
102
+ export type CreatePredictionResponseDataList = Array<CreatePredictionResponseDataItem>;
103
+ export interface CreatePredictionResponse {
104
+ /** A list that contains the single prediction that you created. */
105
+ data?: CreatePredictionResponseDataList | undefined;
106
+ }
107
+ export interface EndPredictionRequest {
108
+ /** The ID of the broadcaster that's running the prediction. This ID must match the user ID in the user access token. */
109
+ broadcaster_id: string;
110
+ /** The ID of the prediction to update. */
111
+ id: string;
112
+ /** The status to set the prediction to. Possible values: - `RESOLVED`: The winning outcome is determined and the Channel Points are distributed to the viewers who predicted the correct outcome. - `CANCELED`: The broadcaster is canceling the prediction and sending refunds to the participants. - `LOCKED`: The broadcaster is locking the prediction, which means viewers may no longer make predictions. */
113
+ status: string;
114
+ /** The ID of the winning outcome. You must set this parameter if you set *status* to RESOLVED. */
115
+ winning_outcome_id?: string | undefined;
116
+ }
117
+ export type EndPredictionResponseDataItemOutcomesItemTopPredictorsItem =
118
+ CreatePredictionResponseDataItemOutcomesItemTopPredictorsItem;
119
+ /** A list of viewers who were the top predictors; otherwise, **null** if none. */
120
+ export type EndPredictionResponseDataItemOutcomesItemTopPredictorsList =
121
+ Array<CreatePredictionResponseDataItemOutcomesItemTopPredictorsItem>;
122
+ export interface EndPredictionResponseDataItemOutcomesItem {
123
+ /** An ID that identifies this outcome. */
124
+ id?: string | undefined;
125
+ /** The outcome's text. */
126
+ title?: string | undefined;
127
+ /** The number of unique viewers that chose this outcome. */
128
+ users?: number | undefined;
129
+ /** The number of Channel Points spent by viewers on this outcome. */
130
+ channel_points?: number | undefined;
131
+ /** A list of viewers who were the top predictors; otherwise, **null** if none. */
132
+ top_predictors?: EndPredictionResponseDataItemOutcomesItemTopPredictorsList | undefined;
133
+ /** The color that visually identifies this outcome in the UX. Possible values: - `BLUE` - `PINK` */
134
+ color?: string | undefined;
135
+ }
136
+ /** The list of possible outcomes for the prediction. */
137
+ export type EndPredictionResponseDataItemOutcomesList =
138
+ Array<EndPredictionResponseDataItemOutcomesItem>;
139
+ export interface EndPredictionResponseDataItem {
140
+ /** An ID that identifies this prediction. */
141
+ id?: string | undefined;
142
+ /** An ID that identifies the broadcaster that created the prediction. */
143
+ broadcaster_id?: string | undefined;
144
+ /** The broadcaster's display name. */
145
+ broadcaster_name?: string | undefined;
146
+ /** The broadcaster's login name. */
147
+ broadcaster_login?: string | undefined;
148
+ /** The question that the prediction asks. For example, *Will I finish this entire pizza?* */
149
+ title?: string | undefined;
150
+ /** The ID of the winning outcome. Is **null** unless `status` is RESOLVED. */
151
+ winning_outcome_id?: string | undefined;
152
+ /** The list of possible outcomes for the prediction. */
153
+ outcomes?: EndPredictionResponseDataItemOutcomesList | undefined;
154
+ /** The length of time (in seconds) that the prediction will run for. */
155
+ prediction_window?: number | undefined;
156
+ /** The prediction's status. Possible values: - `ACTIVE`: The Prediction is running and viewers can make predictions. - `CANCELED`: The broadcaster canceled the Prediction and refunded the Channel Points to the participants. - `LOCKED`: The broadcaster locked the Prediction, which means viewers can no longer make predictions. - `RESOLVED`: The winning outcome was determined and the Channel Points were distributed to the viewers who predicted the correct outcome. */
157
+ status?: string | undefined;
158
+ /** The UTC date and time of when the Prediction began. */
159
+ created_at?: string | undefined;
160
+ /** The UTC date and time of when the Prediction ended. If `status` is ACTIVE, this is set to **null**. */
161
+ ended_at?: string | undefined;
162
+ /** The UTC date and time of when the Prediction was locked. Is **null** if the Prediction hasn't been locked. */
163
+ locked_at?: string | undefined;
164
+ }
165
+ /** A list that contains the single prediction that you updated. */
166
+ export type EndPredictionResponseDataList = Array<EndPredictionResponseDataItem>;
167
+ export interface EndPredictionResponse {
168
+ /** A list that contains the single prediction that you updated. */
169
+ data?: EndPredictionResponseDataList | undefined;
170
+ }
171
+ export type GetPredictionsRequestIdList = Array<string>;
172
+ export interface GetPredictionsRequest {
173
+ /** The ID of the broadcaster whose predictions you want to get. This ID must match the user ID in the user access token. */
174
+ broadcaster_id: string;
175
+ /** The ID of the prediction to get. To specify more than one ID, include this parameter for each prediction you want to get. For example, 'id=1234&id=5678'. You may specify a maximum of 25 IDs. The endpoint ignores duplicate IDs and those not owned by the broadcaster. */
176
+ id?: GetPredictionsRequestIdList | undefined;
177
+ /** 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 25 items per page. The default is 20. */
178
+ first?: number | undefined;
179
+ /** 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) */
180
+ after?: string | undefined;
181
+ }
182
+ export type GetPredictionsResponseDataItemOutcomesItemTopPredictorsItem =
183
+ CreatePredictionResponseDataItemOutcomesItemTopPredictorsItem;
184
+ /** A list of viewers who were the top predictors; otherwise, **null** if none. */
185
+ export type GetPredictionsResponseDataItemOutcomesItemTopPredictorsList =
186
+ Array<CreatePredictionResponseDataItemOutcomesItemTopPredictorsItem>;
187
+ export interface GetPredictionsResponseDataItemOutcomesItem {
188
+ /** An ID that identifies this outcome. */
189
+ id?: string | undefined;
190
+ /** The outcome's text. */
191
+ title?: string | undefined;
192
+ /** The number of unique viewers that chose this outcome. */
193
+ users?: number | undefined;
194
+ /** The number of Channel Points spent by viewers on this outcome. */
195
+ channel_points?: number | undefined;
196
+ /** A list of viewers who were the top predictors; otherwise, **null** if none. */
197
+ top_predictors?: GetPredictionsResponseDataItemOutcomesItemTopPredictorsList | undefined;
198
+ /** The color that visually identifies this outcome in the UX. Possible values: - `BLUE` - `PINK` */
199
+ color?: string | undefined;
200
+ }
201
+ /** The list of possible outcomes for the prediction. */
202
+ export type GetPredictionsResponseDataItemOutcomesList =
203
+ Array<GetPredictionsResponseDataItemOutcomesItem>;
204
+ export interface GetPredictionsResponseDataItem {
205
+ /** An ID that identifies this prediction. */
206
+ id?: string | undefined;
207
+ /** An ID that identifies the broadcaster that created the prediction. */
208
+ broadcaster_id?: string | undefined;
209
+ /** The broadcaster's display name. */
210
+ broadcaster_name?: string | undefined;
211
+ /** The broadcaster's login name. */
212
+ broadcaster_login?: string | undefined;
213
+ /** The question that the prediction asks. For example, *Will I finish this entire pizza?* */
214
+ title?: string | undefined;
215
+ /** The ID of the winning outcome. Is **null** unless `status` is RESOLVED. */
216
+ winning_outcome_id?: string | undefined;
217
+ /** The list of possible outcomes for the prediction. */
218
+ outcomes?: GetPredictionsResponseDataItemOutcomesList | undefined;
219
+ /** The length of time (in seconds) that the prediction will run for. */
220
+ prediction_window?: number | undefined;
221
+ /** The prediction's status. Possible values: - `ACTIVE`: The Prediction is running and viewers can make predictions. - `CANCELED`: The broadcaster canceled the Prediction and refunded the Channel Points to the participants. - `LOCKED`: The broadcaster locked the Prediction, which means viewers can no longer make predictions. - `RESOLVED`: The winning outcome was determined and the Channel Points were distributed to the viewers who predicted the correct outcome. */
222
+ status?: string | undefined;
223
+ /** The UTC date and time of when the Prediction began. */
224
+ created_at?: string | undefined;
225
+ /** The UTC date and time of when the Prediction ended. If `status` is ACTIVE, this is set to **null**. */
226
+ ended_at?: string | undefined;
227
+ /** The UTC date and time of when the Prediction was locked. Is **null** if the Prediction hasn't been locked. */
228
+ locked_at?: string | undefined;
229
+ }
230
+ /** The broadcaster's list of Channel Points Predictions. The list is sorted in descending order by when the prediction began (the most recent prediction is first) unless you specify IDs in the request, in which case the predictions are in the same order as the IDs. The list is empty if the broadcaster hasn't created predictions. */
231
+ export type GetPredictionsResponseDataList = Array<GetPredictionsResponseDataItem>;
232
+ /** Contains the information used to page through the list of results. The object is empty if there are no more pages left to page through. [Read More](https://dev.twitch.tv/docs/api/guide.md#pagination) */
233
+ export interface GetPredictionsResponsePagination {
234
+ /** The cursor used to get the next page of results. Use the cursor to set the request's *after* query parameter. */
235
+ cursor?: string | undefined;
236
+ }
237
+ export interface GetPredictionsResponse {
238
+ /** The broadcaster's list of Channel Points Predictions. The list is sorted in descending order by when the prediction began (the most recent prediction is first) unless you specify IDs in the request, in which case the predictions are in the same order as the IDs. The list is empty if the broadcaster hasn't created predictions. */
239
+ data: GetPredictionsResponseDataList;
240
+ /** Contains the information used to page through the list of results. The object is empty if there are no more pages left to page through. [Read More](https://dev.twitch.tv/docs/api/guide.md#pagination) */
241
+ pagination?: GetPredictionsResponsePagination | undefined;
242
+ }
243
+ export type CreatePredictionError = TwitchOpError;
244
+ /** Create Prediction Creates a Channel Points Prediction. With a Channel Points Prediction, the broadcaster poses a question and viewers try to predict the outcome. The prediction runs as soon as it's created. The broadcaster may run only one prediction at a time. 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:predictions** scope. Reference: https://dev.twitch.tv/docs/api/reference/predictions/#create-prediction */
245
+ export const createPrediction: API.OperationMethod<
246
+ CreatePredictionRequest,
247
+ CreatePredictionResponse,
248
+ CreatePredictionError,
249
+ TwitchOpContext
250
+ > = /*@__PURE__*/ API.make(() => ({
251
+ input: __S(2, __c0, 2) as any as S.Schema<CreatePredictionRequest>,
252
+ output: __S(8, __c1, 0) as any as S.Schema<CreatePredictionResponse>,
253
+ errors: [],
254
+ serviceErrors: TwitchServiceErrors,
255
+ protocol: TwitchProtocol,
256
+ retry: Retry.Retry,
257
+ telemetry: TELEMETRY,
258
+ span: "CreatePrediction",
259
+ }));
260
+
261
+ export type EndPredictionError = TwitchOpError;
262
+ /** End Prediction Locks, resolves, or cancels a Channel Points Prediction. 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:predictions** scope. Reference: https://dev.twitch.tv/docs/api/reference/predictions/#end-prediction */
263
+ export const endPrediction: API.OperationMethod<
264
+ EndPredictionRequest,
265
+ EndPredictionResponse,
266
+ EndPredictionError,
267
+ TwitchOpContext
268
+ > = /*@__PURE__*/ API.make(() => ({
269
+ input: __S(24, __c3, 0) as any as S.Schema<EndPredictionRequest>,
270
+ output: __S(8, __c1, 0) as any as S.Schema<EndPredictionResponse>,
271
+ errors: [],
272
+ serviceErrors: TwitchServiceErrors,
273
+ protocol: TwitchProtocol,
274
+ retry: Retry.Retry,
275
+ telemetry: TELEMETRY,
276
+ span: "EndPrediction",
277
+ }));
278
+
279
+ export type GetPredictionsError = TwitchOpError;
280
+ /** Get Predictions Gets a list of Channel Points Predictions that the broadcaster created. Authorization: Requires one of the following: - A [user access token](https://dev.twitch.tv/docs/authentication.md#user-access-tokens) that includes the **channel:read:predictions** or **channel:manage:predictions** scope. Reference: https://dev.twitch.tv/docs/api/reference/predictions/#get-predictions */
281
+ export const getPredictions: API.PaginatedOperationMethod<
282
+ GetPredictionsRequest,
283
+ GetPredictionsResponse,
284
+ GetPredictionsError,
285
+ TwitchOpContext,
286
+ GetPredictionsResponseDataItem
287
+ > = /*@__PURE__*/ API.makePaginated(
288
+ () => ({
289
+ input: __S(33, __c4, 1) as any as S.Schema<GetPredictionsRequest>,
290
+ output: __S(35, __c4, 3) as any as S.Schema<GetPredictionsResponse>,
291
+ errors: [],
292
+ serviceErrors: TwitchServiceErrors,
293
+ protocol: TwitchProtocol,
294
+ retry: Retry.Retry,
295
+ telemetry: TELEMETRY,
296
+ span: "GetPredictions",
297
+ pagination: {
298
+ mode: "cursor",
299
+ inputToken: "after",
300
+ outputToken: "pagination.cursor",
301
+ items: "data",
302
+ pageSize: "first",
303
+ } as const,
304
+ }),
305
+ paginateCursor,
306
+ ) as any;
307
+
308
+ // Schema builders: each runs one schema initializer, on that schema's first use.
309
+ function __c0(j: number): any {
310
+ switch (j) {
311
+ case 0:
312
+ return S.suspend(() =>
313
+ S.Struct({
314
+ title: S.String,
315
+ }),
316
+ ).annotate({ identifier: "CreatePredictionRequestOutcomesItem" });
317
+ case 1:
318
+ return S.Array(__S(0, __c0, 0));
319
+ case 2:
320
+ return S.suspend(() =>
321
+ S.Struct({
322
+ broadcaster_id: S.String,
323
+ title: S.String,
324
+ outcomes: __S(1, __c0, 1),
325
+ prediction_window: S.Number,
326
+ }).pipe(T.Http({ method: "POST", uri: "/predictions", code: 200 })),
327
+ ).annotate({ identifier: "CreatePredictionRequest" });
328
+ }
329
+ }
330
+ function __c1(j: number): any {
331
+ switch (j) {
332
+ case 0:
333
+ return S.suspend(() =>
334
+ S.Struct({
335
+ data: S.optional(__S(21, __c2, 5)),
336
+ }),
337
+ ).annotate({ identifier: "CreatePredictionResponse" });
338
+ }
339
+ }
340
+ function __c2(j: number): any {
341
+ switch (j) {
342
+ case 0:
343
+ return S.suspend(() =>
344
+ S.Struct({
345
+ user_id: S.optional(S.String),
346
+ user_name: S.optional(S.String),
347
+ user_login: S.optional(S.String),
348
+ channel_points_used: S.optional(S.Number),
349
+ channel_points_won: S.optional(S.Number),
350
+ }),
351
+ ).annotate({ identifier: "CreatePredictionResponseDataItemOutcomesItemTopPredictorsItem" });
352
+ case 1:
353
+ return S.Array(__S(16, __c2, 0));
354
+ case 2:
355
+ return S.suspend(() =>
356
+ S.Struct({
357
+ id: S.optional(S.String),
358
+ title: S.optional(S.String),
359
+ users: S.optional(S.Number),
360
+ channel_points: S.optional(S.Number),
361
+ top_predictors: S.optional(__S(17, __c2, 1)),
362
+ color: S.optional(S.String),
363
+ }),
364
+ ).annotate({ identifier: "CreatePredictionResponseDataItemOutcomesItem" });
365
+ case 3:
366
+ return S.Array(__S(18, __c2, 2));
367
+ case 4:
368
+ return S.suspend(() =>
369
+ S.Struct({
370
+ id: S.optional(S.String),
371
+ broadcaster_id: S.optional(S.String),
372
+ broadcaster_name: S.optional(S.String),
373
+ broadcaster_login: S.optional(S.String),
374
+ title: S.optional(S.String),
375
+ winning_outcome_id: S.optional(S.String),
376
+ outcomes: S.optional(__S(19, __c2, 3)),
377
+ prediction_window: S.optional(S.Number),
378
+ status: S.optional(S.String),
379
+ created_at: S.optional(S.String),
380
+ ended_at: S.optional(S.String),
381
+ locked_at: S.optional(S.String),
382
+ }),
383
+ ).annotate({ identifier: "CreatePredictionResponseDataItem" });
384
+ case 5:
385
+ return S.Array(__S(20, __c2, 4));
386
+ }
387
+ }
388
+ function __c3(j: number): any {
389
+ switch (j) {
390
+ case 0:
391
+ return S.suspend(() =>
392
+ S.Struct({
393
+ broadcaster_id: S.String,
394
+ id: S.String,
395
+ status: S.String,
396
+ winning_outcome_id: S.optional(S.String),
397
+ }).pipe(T.Http({ method: "PATCH", uri: "/predictions", code: 200 })),
398
+ ).annotate({ identifier: "EndPredictionRequest" });
399
+ }
400
+ }
401
+ function __c4(j: number): any {
402
+ switch (j) {
403
+ case 0:
404
+ return S.Array(S.String);
405
+ case 1:
406
+ return S.suspend(() =>
407
+ S.Struct({
408
+ broadcaster_id: S.String.pipe(T.Query()),
409
+ id: S.optional(__S(32, __c4, 0).pipe(T.Query())),
410
+ first: S.optional(S.Number.pipe(T.Query())),
411
+ after: S.optional(S.String.pipe(T.Query())),
412
+ }).pipe(T.Http({ method: "GET", uri: "/predictions", code: 200 })),
413
+ ).annotate({ identifier: "GetPredictionsRequest" });
414
+ case 2:
415
+ return S.suspend(() =>
416
+ S.Struct({
417
+ cursor: S.optional(S.String),
418
+ }),
419
+ ).annotate({ identifier: "GetPredictionsResponsePagination" });
420
+ case 3:
421
+ return S.suspend(() =>
422
+ S.Struct({
423
+ data: __S(21, __c2, 5),
424
+ pagination: S.optional(__S(34, __c4, 2)),
425
+ }),
426
+ ).annotate({ identifier: "GetPredictionsResponse" });
427
+ }
428
+ }
429
+ // Schema table: entry i is schema j of builder f, made on first reach.
430
+ function __S(i: number, f: (j: number) => unknown, j: number): any {
431
+ return (__s[i] ??= __L.at(f, j));
432
+ }
@@ -0,0 +1,127 @@
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: "Raids",
23
+ propagate: "w3c",
24
+ } as const;
25
+
26
+ export interface CancelARaidRequest {
27
+ /** The ID of the broadcaster that initiated the raid. This ID must match the user ID in the user access token. */
28
+ broadcaster_id: string;
29
+ }
30
+ export interface CancelARaidResponse {}
31
+ export interface StartARaidRequest {
32
+ /** The ID of the broadcaster that's sending the raiding party. This ID must match the user ID in the user access token. */
33
+ from_broadcaster_id: string;
34
+ /** The ID of the broadcaster to raid. */
35
+ to_broadcaster_id: string;
36
+ }
37
+ export interface StartARaidResponseDataItem {
38
+ /** The UTC date and time, in RFC3339 format, of when the raid was requested. */
39
+ created_at?: string | undefined;
40
+ /** **IMPORTANT** This field is deprecated and returns only **false**. A Boolean value that indicates whether the channel being raided contains mature content. */
41
+ is_mature?: boolean | undefined;
42
+ }
43
+ /** A list that contains a single object with information about the pending raid. */
44
+ export type StartARaidResponseDataList = Array<StartARaidResponseDataItem>;
45
+ export interface StartARaidResponse {
46
+ /** A list that contains a single object with information about the pending raid. */
47
+ data?: StartARaidResponseDataList | undefined;
48
+ }
49
+ export type CancelARaidError = TwitchOpError;
50
+ /** Cancel a raid Cancel a pending raid. You can cancel a raid at any point up until the broadcaster clicks **Raid Now** in the Twitch UX or the 90-second countdown expires. **Rate Limit**: The limit is 10 requests within a 10-minute window. 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:raids** scope. Reference: https://dev.twitch.tv/docs/api/reference/raids/#cancel-a-raid */
51
+ export const cancelARaid: API.OperationMethod<
52
+ CancelARaidRequest,
53
+ CancelARaidResponse,
54
+ CancelARaidError,
55
+ TwitchOpContext
56
+ > = /*@__PURE__*/ API.make(() => ({
57
+ input: __S(0, __c0, 0) as any as S.Schema<CancelARaidRequest>,
58
+ output: __S(1, __c0, 1) as any as S.Schema<CancelARaidResponse>,
59
+ errors: [],
60
+ serviceErrors: TwitchServiceErrors,
61
+ protocol: TwitchProtocol,
62
+ retry: Retry.Retry,
63
+ telemetry: TELEMETRY,
64
+ span: "CancelARaid",
65
+ }));
66
+
67
+ export type StartARaidError = TwitchOpError;
68
+ /** Start a raid Raid another channel by sending the broadcaster's viewers to the targeted channel. When you call the API from a chat bot or extension, the Twitch UX pops up a window at the top of the chat room that identifies the number of viewers in the raid. The raid occurs when the broadcaster clicks **Raid Now** or after the 90-second countdown expires. To determine whether the raid successfully occurred, you must subscribe to the [Channel Raid](https://dev.twitch.tv/docs/eventsub/reference/channel.md#channel-raid) event. For more information, see [Get notified when a raid begins](https://dev.twitch.tv/docs/api/raids.md#get-notified-when-a-raid-begins). To cancel a pending raid, use the [Cancel a raid](#cancel-a-raid) endpoint. **Rate Limit**: The limit is 10 requests within a 10-minute window. 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:raids** scope. Reference: https://dev.twitch.tv/docs/api/reference/raids/#start-a-raid */
69
+ export const startARaid: API.OperationMethod<
70
+ StartARaidRequest,
71
+ StartARaidResponse,
72
+ StartARaidError,
73
+ TwitchOpContext
74
+ > = /*@__PURE__*/ API.make(() => ({
75
+ input: __S(4, __c1, 0) as any as S.Schema<StartARaidRequest>,
76
+ output: __S(7, __c1, 3) as any as S.Schema<StartARaidResponse>,
77
+ errors: [],
78
+ serviceErrors: TwitchServiceErrors,
79
+ protocol: TwitchProtocol,
80
+ retry: Retry.Retry,
81
+ telemetry: TELEMETRY,
82
+ span: "StartARaid",
83
+ }));
84
+
85
+ // Schema builders: each runs one schema initializer, on that schema's first use.
86
+ function __c0(j: number): any {
87
+ switch (j) {
88
+ case 0:
89
+ return S.suspend(() =>
90
+ S.Struct({
91
+ broadcaster_id: S.String.pipe(T.Query()),
92
+ }).pipe(T.Http({ method: "DELETE", uri: "/raids", code: 200 })),
93
+ ).annotate({ identifier: "CancelARaidRequest" });
94
+ case 1:
95
+ return S.suspend(() => S.Struct({})).annotate({ identifier: "CancelARaidResponse" });
96
+ }
97
+ }
98
+ function __c1(j: number): any {
99
+ switch (j) {
100
+ case 0:
101
+ return S.suspend(() =>
102
+ S.Struct({
103
+ from_broadcaster_id: S.String.pipe(T.Query()),
104
+ to_broadcaster_id: S.String.pipe(T.Query()),
105
+ }).pipe(T.Http({ method: "POST", uri: "/raids", code: 200 })),
106
+ ).annotate({ identifier: "StartARaidRequest" });
107
+ case 1:
108
+ return S.suspend(() =>
109
+ S.Struct({
110
+ created_at: S.optional(S.String),
111
+ is_mature: S.optional(S.Boolean),
112
+ }),
113
+ ).annotate({ identifier: "StartARaidResponseDataItem" });
114
+ case 2:
115
+ return S.Array(__S(5, __c1, 1));
116
+ case 3:
117
+ return S.suspend(() =>
118
+ S.Struct({
119
+ data: S.optional(__S(6, __c1, 2)),
120
+ }),
121
+ ).annotate({ identifier: "StartARaidResponse" });
122
+ }
123
+ }
124
+ // Schema table: entry i is schema j of builder f, made on first reach.
125
+ function __S(i: number, f: (j: number) => unknown, j: number): any {
126
+ return (__s[i] ??= __L.at(f, j));
127
+ }