@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,363 @@
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: "Polls",
24
+ propagate: "w3c",
25
+ } as const;
26
+
27
+ export interface CreatePollRequestChoicesItem {
28
+ /** One of the choices the viewer may select. The choice may contain a maximum of 25 characters. */
29
+ title: string;
30
+ }
31
+ /** A list of choices that viewers may choose from. The list must contain a minimum of 2 choices and up to a maximum of 5 choices. */
32
+ export type CreatePollRequestChoicesList = Array<CreatePollRequestChoicesItem>;
33
+ export interface CreatePollRequest {
34
+ /** The ID of the broadcaster that's running the poll. This ID must match the user ID in the user access token. */
35
+ broadcaster_id: string;
36
+ /** The question that viewers will vote on. For example, *What game should I play next?* The question may contain a maximum of 60 characters. */
37
+ title: string;
38
+ /** A list of choices that viewers may choose from. The list must contain a minimum of 2 choices and up to a maximum of 5 choices. */
39
+ choices: CreatePollRequestChoicesList;
40
+ /** The length of time (in seconds) that the poll will run for. The minimum is 15 seconds and the maximum is 1800 seconds (30 minutes). */
41
+ duration: number;
42
+ /** A Boolean value that indicates whether viewers may cast additional votes using Channel Points. If **true**, the viewer may cast more than one vote but each additional vote costs the number of Channel Points specified in *channel_points_per_vote*. The default is **false** (viewers may cast only one vote). For information about Channel Points, see [Channel Points Guide](https://help.twitch.tv/s/article/channel-points-guide). */
43
+ channel_points_voting_enabled?: boolean | undefined;
44
+ /** The number of points that the viewer must spend to cast one additional vote. The minimum is 1 and the maximum is 1000000. Set only if *channel_points_voting_enabled* is **true**. */
45
+ channel_points_per_vote?: number | undefined;
46
+ }
47
+ export interface CreatePollResponseDataItemChoicesItem {
48
+ /** An ID that identifies this choice. */
49
+ id?: string | undefined;
50
+ /** The choice's title. The title may contain a maximum of 25 characters. */
51
+ title?: string | undefined;
52
+ /** The total number of votes cast for this choice. */
53
+ votes?: number | undefined;
54
+ /** The number of votes cast using Channel Points. */
55
+ channel_points_votes?: number | undefined;
56
+ }
57
+ /** A list of choices that viewers can choose from. The list will contain a minimum of two choices and up to a maximum of five choices. */
58
+ export type CreatePollResponseDataItemChoicesList = Array<CreatePollResponseDataItemChoicesItem>;
59
+ export interface CreatePollResponseDataItem {
60
+ /** An ID that identifies the poll. */
61
+ id?: string | undefined;
62
+ /** An ID that identifies the broadcaster that created the poll. */
63
+ broadcaster_id?: string | undefined;
64
+ /** The broadcaster's display name. */
65
+ broadcaster_name?: string | undefined;
66
+ /** The broadcaster's login name. */
67
+ broadcaster_login?: string | undefined;
68
+ /** The question that viewers are voting on. For example, *What game should I play next?* The title may contain a maximum of 60 characters. */
69
+ title?: string | undefined;
70
+ /** A list of choices that viewers can choose from. The list will contain a minimum of two choices and up to a maximum of five choices. */
71
+ choices?: CreatePollResponseDataItemChoicesList | undefined;
72
+ /** A Boolean value that indicates whether viewers may cast additional votes using Channel Points. For information about Channel Points, see [Channel Points Guide](https://help.twitch.tv/s/article/channel-points-guide). */
73
+ channel_points_voting_enabled?: boolean | undefined;
74
+ /** The number of points the viewer must spend to cast one additional vote. */
75
+ channel_points_per_vote?: number | undefined;
76
+ /** The poll's status. Possible values: - `ACTIVE`: The poll is running. - `COMPLETED`: The poll ended on schedule (see the `duration` field). - `TERMINATED`: The poll was terminated before its scheduled end. - `ARCHIVED`: The poll has been archived and is no longer visible on the channel. - `MODERATED`: The poll was deleted. - `INVALID`: Something went wrong while determining the state. */
77
+ status?: string | undefined;
78
+ /** The length of time (in seconds) that the poll will run for. */
79
+ duration?: number | undefined;
80
+ /** The UTC date and time (in RFC3339 format) of when the poll began. */
81
+ started_at?: string | undefined;
82
+ /** The UTC date and time (in RFC3339 format) of when the poll ended. If `status` is ACTIVE, the object doesn't include this field. */
83
+ ended_at?: string | undefined;
84
+ }
85
+ /** A list that contains the single poll that you created. */
86
+ export type CreatePollResponseDataList = Array<CreatePollResponseDataItem>;
87
+ export interface CreatePollResponse {
88
+ /** A list that contains the single poll that you created. */
89
+ data?: CreatePollResponseDataList | undefined;
90
+ }
91
+ export interface EndPollRequest {
92
+ /** The ID of the broadcaster that's running the poll. This ID must match the user ID in the user access token. */
93
+ broadcaster_id: string;
94
+ /** The ID of the poll to update. */
95
+ id: string;
96
+ /** The status to set the poll to. Possible values: - `TERMINATED`: Ends the poll before the poll is scheduled to end. The poll remains publicly visible. - `ARCHIVED`: Ends the poll before the poll is scheduled to end, and then archives it so it's no longer publicly visible. */
97
+ status: string;
98
+ }
99
+ export type EndPollResponseDataItemChoicesItem = CreatePollResponseDataItemChoicesItem;
100
+ /** A list of choices that viewers can choose from. The list will contain a minimum of two choices and up to a maximum of five choices. */
101
+ export type EndPollResponseDataItemChoicesList = Array<CreatePollResponseDataItemChoicesItem>;
102
+ export interface EndPollResponseDataItem {
103
+ /** An ID that identifies the poll. */
104
+ id?: string | undefined;
105
+ /** An ID that identifies the broadcaster that created the poll. */
106
+ broadcaster_id?: string | undefined;
107
+ /** The broadcaster's display name. */
108
+ broadcaster_name?: string | undefined;
109
+ /** The broadcaster's login name. */
110
+ broadcaster_login?: string | undefined;
111
+ /** The question that viewers are voting on. For example, *What game should I play next?* The title may contain a maximum of 60 characters. */
112
+ title?: string | undefined;
113
+ /** A list of choices that viewers can choose from. The list will contain a minimum of two choices and up to a maximum of five choices. */
114
+ choices?: EndPollResponseDataItemChoicesList | undefined;
115
+ /** A Boolean value that indicates whether viewers may cast additional votes using Channel Points. For information about Channel Points, see [Channel Points Guide](https://help.twitch.tv/s/article/channel-points-guide). */
116
+ channel_points_voting_enabled?: boolean | undefined;
117
+ /** The number of points the viewer must spend to cast one additional vote. */
118
+ channel_points_per_vote?: number | undefined;
119
+ /** The poll's status. Possible values: - `ACTIVE`: The poll is running. - `COMPLETED`: The poll ended on schedule (see the `duration` field). - `TERMINATED`: The poll was terminated before its scheduled end. - `ARCHIVED`: The poll has been archived and is no longer visible on the channel. - `MODERATED`: The poll was deleted. - `INVALID`: Something went wrong while determining the state. */
120
+ status?: string | undefined;
121
+ /** The length of time (in seconds) that the poll will run for. */
122
+ duration?: number | undefined;
123
+ /** The UTC date and time (in RFC3339 format) of when the poll began. */
124
+ started_at?: string | undefined;
125
+ /** The UTC date and time (in RFC3339 format) of when the poll ended. If `status` is ACTIVE, the object doesn't include this field. */
126
+ ended_at?: string | undefined;
127
+ }
128
+ /** A list that contains the poll that you ended. */
129
+ export type EndPollResponseDataList = Array<EndPollResponseDataItem>;
130
+ export interface EndPollResponse {
131
+ /** A list that contains the poll that you ended. */
132
+ data?: EndPollResponseDataList | undefined;
133
+ }
134
+ export type GetPollsRequestIdList = Array<string>;
135
+ export interface GetPollsRequest {
136
+ /** The ID of the broadcaster that created the polls. This ID must match the user ID in the user access token. */
137
+ broadcaster_id: string;
138
+ /** A list of IDs that identify the polls to return. To specify more than one ID, include this parameter for each poll you want to get. For example, 'id=1234&id=5678'. You may specify a maximum of 20 IDs. Specify this parameter only if you want to filter the list that the request returns. The endpoint ignores duplicate IDs and those not owned by this broadcaster. */
139
+ id?: GetPollsRequestIdList | undefined;
140
+ /** 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 20 items per page. The default is 20. */
141
+ first?: number | undefined;
142
+ /** 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) */
143
+ after?: string | undefined;
144
+ }
145
+ export type GetPollsResponseDataItemChoicesItem = CreatePollResponseDataItemChoicesItem;
146
+ /** A list of choices that viewers can choose from. The list will contain a minimum of two choices and up to a maximum of five choices. */
147
+ export type GetPollsResponseDataItemChoicesList = Array<CreatePollResponseDataItemChoicesItem>;
148
+ export interface GetPollsResponseDataItem {
149
+ /** An ID that identifies the poll. */
150
+ id?: string | undefined;
151
+ /** An ID that identifies the broadcaster that created the poll. */
152
+ broadcaster_id?: string | undefined;
153
+ /** The broadcaster's display name. */
154
+ broadcaster_name?: string | undefined;
155
+ /** The broadcaster's login name. */
156
+ broadcaster_login?: string | undefined;
157
+ /** The question that viewers are voting on. For example, *What game should I play next?* The title may contain a maximum of 60 characters. */
158
+ title?: string | undefined;
159
+ /** A list of choices that viewers can choose from. The list will contain a minimum of two choices and up to a maximum of five choices. */
160
+ choices?: GetPollsResponseDataItemChoicesList | undefined;
161
+ /** A Boolean value that indicates whether viewers may cast additional votes using Channel Points. For information about Channel Points, see [Channel Points Guide](https://help.twitch.tv/s/article/channel-points-guide). */
162
+ channel_points_voting_enabled?: boolean | undefined;
163
+ /** The number of points the viewer must spend to cast one additional vote. */
164
+ channel_points_per_vote?: number | undefined;
165
+ /** The poll's status. Possible values: - `ACTIVE`: The poll is running. - `COMPLETED`: The poll ended on schedule (see the `duration` field). - `TERMINATED`: The poll was terminated before its scheduled end. - `ARCHIVED`: The poll has been archived and is no longer visible on the channel. - `INVALID`: Something went wrong while determining the state. */
166
+ status?: string | undefined;
167
+ /** The length of time (in seconds) that the poll will run for. */
168
+ duration?: number | undefined;
169
+ /** The UTC date and time (in RFC3339 format) of when the poll began. */
170
+ started_at?: string | undefined;
171
+ /** The UTC date and time (in RFC3339 format) of when the poll ended. If `status` is ACTIVE, the object doesn't include this field. */
172
+ ended_at?: string | undefined;
173
+ }
174
+ /** A list of polls. The polls are returned in descending order of start time unless you specify IDs in the request, in which case they're returned in the same order as you passed them in the request. The list is empty if the broadcaster hasn't created polls. */
175
+ export type GetPollsResponseDataList = Array<GetPollsResponseDataItem>;
176
+ /** 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) */
177
+ export interface GetPollsResponsePagination {
178
+ /** The cursor used to get the next page of results. Use the cursor to set the request's *after* query parameter. */
179
+ cursor?: string | undefined;
180
+ }
181
+ export interface GetPollsResponse {
182
+ /** A list of polls. The polls are returned in descending order of start time unless you specify IDs in the request, in which case they're returned in the same order as you passed them in the request. The list is empty if the broadcaster hasn't created polls. */
183
+ data: GetPollsResponseDataList;
184
+ /** 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) */
185
+ pagination?: GetPollsResponsePagination | undefined;
186
+ }
187
+ export type CreatePollError = TwitchOpError;
188
+ /** Create Poll Creates a poll that viewers in the broadcaster's channel can vote on. The poll begins as soon as it's created. You may run only one poll 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:polls** scope. Reference: https://dev.twitch.tv/docs/api/reference/polls/#create-poll */
189
+ export const createPoll: API.OperationMethod<
190
+ CreatePollRequest,
191
+ CreatePollResponse,
192
+ CreatePollError,
193
+ TwitchOpContext
194
+ > = /*@__PURE__*/ API.make(() => ({
195
+ input: __S(2, __c0, 2) as any as S.Schema<CreatePollRequest>,
196
+ output: __S(4, __c1, 0) as any as S.Schema<CreatePollResponse>,
197
+ errors: [],
198
+ serviceErrors: TwitchServiceErrors,
199
+ protocol: TwitchProtocol,
200
+ retry: Retry.Retry,
201
+ telemetry: TELEMETRY,
202
+ span: "CreatePoll",
203
+ }));
204
+
205
+ export type EndPollError = TwitchOpError;
206
+ /** End Poll Ends an active poll. You have the option to end it or end it and archive it. 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:polls** scope. Reference: https://dev.twitch.tv/docs/api/reference/polls/#end-poll */
207
+ export const endPoll: API.OperationMethod<
208
+ EndPollRequest,
209
+ EndPollResponse,
210
+ EndPollError,
211
+ TwitchOpContext
212
+ > = /*@__PURE__*/ API.make(() => ({
213
+ input: __S(12, __c3, 0) as any as S.Schema<EndPollRequest>,
214
+ output: __S(4, __c1, 0) as any as S.Schema<EndPollResponse>,
215
+ errors: [],
216
+ serviceErrors: TwitchServiceErrors,
217
+ protocol: TwitchProtocol,
218
+ retry: Retry.Retry,
219
+ telemetry: TELEMETRY,
220
+ span: "EndPoll",
221
+ }));
222
+
223
+ export type GetPollsError = TwitchOpError;
224
+ /** Get Polls Polls are available for 90 days after they're 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:polls** or **channel:manage:polls** scope. Reference: https://dev.twitch.tv/docs/api/reference/polls/#get-polls */
225
+ export const getPolls: API.PaginatedOperationMethod<
226
+ GetPollsRequest,
227
+ GetPollsResponse,
228
+ GetPollsError,
229
+ TwitchOpContext,
230
+ GetPollsResponseDataItem
231
+ > = /*@__PURE__*/ API.makePaginated(
232
+ () => ({
233
+ input: __S(17, __c4, 1) as any as S.Schema<GetPollsRequest>,
234
+ output: __S(19, __c4, 3) as any as S.Schema<GetPollsResponse>,
235
+ errors: [],
236
+ serviceErrors: TwitchServiceErrors,
237
+ protocol: TwitchProtocol,
238
+ retry: Retry.Retry,
239
+ telemetry: TELEMETRY,
240
+ span: "GetPolls",
241
+ pagination: {
242
+ mode: "cursor",
243
+ inputToken: "after",
244
+ outputToken: "pagination.cursor",
245
+ items: "data",
246
+ pageSize: "first",
247
+ } as const,
248
+ }),
249
+ paginateCursor,
250
+ ) as any;
251
+
252
+ // Schema builders: each runs one schema initializer, on that schema's first use.
253
+ function __c0(j: number): any {
254
+ switch (j) {
255
+ case 0:
256
+ return S.suspend(() =>
257
+ S.Struct({
258
+ title: S.String,
259
+ }),
260
+ ).annotate({ identifier: "CreatePollRequestChoicesItem" });
261
+ case 1:
262
+ return S.Array(__S(0, __c0, 0));
263
+ case 2:
264
+ return S.suspend(() =>
265
+ S.Struct({
266
+ broadcaster_id: S.String,
267
+ title: S.String,
268
+ choices: __S(1, __c0, 1),
269
+ duration: S.Number,
270
+ channel_points_voting_enabled: S.optional(S.Boolean),
271
+ channel_points_per_vote: S.optional(S.Number),
272
+ }).pipe(T.Http({ method: "POST", uri: "/polls", code: 200 })),
273
+ ).annotate({ identifier: "CreatePollRequest" });
274
+ }
275
+ }
276
+ function __c1(j: number): any {
277
+ switch (j) {
278
+ case 0:
279
+ return S.suspend(() =>
280
+ S.Struct({
281
+ data: S.optional(__S(11, __c2, 3)),
282
+ }),
283
+ ).annotate({ identifier: "CreatePollResponse" });
284
+ }
285
+ }
286
+ function __c2(j: number): any {
287
+ switch (j) {
288
+ case 0:
289
+ return S.suspend(() =>
290
+ S.Struct({
291
+ id: S.optional(S.String),
292
+ title: S.optional(S.String),
293
+ votes: S.optional(S.Number),
294
+ channel_points_votes: S.optional(S.Number),
295
+ }),
296
+ ).annotate({ identifier: "CreatePollResponseDataItemChoicesItem" });
297
+ case 1:
298
+ return S.Array(__S(8, __c2, 0));
299
+ case 2:
300
+ return S.suspend(() =>
301
+ S.Struct({
302
+ id: S.optional(S.String),
303
+ broadcaster_id: S.optional(S.String),
304
+ broadcaster_name: S.optional(S.String),
305
+ broadcaster_login: S.optional(S.String),
306
+ title: S.optional(S.String),
307
+ choices: S.optional(__S(9, __c2, 1)),
308
+ channel_points_voting_enabled: S.optional(S.Boolean),
309
+ channel_points_per_vote: S.optional(S.Number),
310
+ status: S.optional(S.String),
311
+ duration: S.optional(S.Number),
312
+ started_at: S.optional(S.String),
313
+ ended_at: S.optional(S.String),
314
+ }),
315
+ ).annotate({ identifier: "CreatePollResponseDataItem" });
316
+ case 3:
317
+ return S.Array(__S(10, __c2, 2));
318
+ }
319
+ }
320
+ function __c3(j: number): any {
321
+ switch (j) {
322
+ case 0:
323
+ return S.suspend(() =>
324
+ S.Struct({
325
+ broadcaster_id: S.String,
326
+ id: S.String,
327
+ status: S.String,
328
+ }).pipe(T.Http({ method: "PATCH", uri: "/polls", code: 200 })),
329
+ ).annotate({ identifier: "EndPollRequest" });
330
+ }
331
+ }
332
+ function __c4(j: number): any {
333
+ switch (j) {
334
+ case 0:
335
+ return S.Array(S.String);
336
+ case 1:
337
+ return S.suspend(() =>
338
+ S.Struct({
339
+ broadcaster_id: S.String.pipe(T.Query()),
340
+ id: S.optional(__S(16, __c4, 0).pipe(T.Query())),
341
+ first: S.optional(S.Number.pipe(T.Query())),
342
+ after: S.optional(S.String.pipe(T.Query())),
343
+ }).pipe(T.Http({ method: "GET", uri: "/polls", code: 200 })),
344
+ ).annotate({ identifier: "GetPollsRequest" });
345
+ case 2:
346
+ return S.suspend(() =>
347
+ S.Struct({
348
+ cursor: S.optional(S.String),
349
+ }),
350
+ ).annotate({ identifier: "GetPollsResponsePagination" });
351
+ case 3:
352
+ return S.suspend(() =>
353
+ S.Struct({
354
+ data: __S(11, __c2, 3),
355
+ pagination: S.optional(__S(18, __c4, 2)),
356
+ }),
357
+ ).annotate({ identifier: "GetPollsResponse" });
358
+ }
359
+ }
360
+ // Schema table: entry i is schema j of builder f, made on first reach.
361
+ function __S(i: number, f: (j: number) => unknown, j: number): any {
362
+ return (__s[i] ??= __L.at(f, j));
363
+ }