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

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,228 @@
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: "Ads",
23
+ propagate: "w3c",
24
+ } as const;
25
+
26
+ export interface GetAdScheduleRequest {
27
+ /** Provided _broadcaster_id_ must match the `user_id` in the authentication token. */
28
+ broadcaster_id: string;
29
+ }
30
+ export interface GetAdScheduleResponseDataItem {
31
+ /** The number of snoozes available for the broadcaster. */
32
+ snooze_count?: number | undefined;
33
+ /** The time when the broadcaster will gain an additional snooze, as a Unix timestamp in seconds. Is 0 if the broadcaster already has the maximum number of snoozes. */
34
+ snooze_refresh_at?: number | undefined;
35
+ /** The time of the broadcaster's next scheduled ad, as a Unix timestamp in seconds. Is 0 if the channel has no ad scheduled or is not live. */
36
+ next_ad_at?: number | undefined;
37
+ /** The length in seconds of the scheduled upcoming ad break. */
38
+ duration?: number | undefined;
39
+ /** The time of the broadcaster's last ad-break, as a Unix timestamp in seconds. Is 0 if the channel has not run an ad or is not live. */
40
+ last_ad_at?: number | undefined;
41
+ /** The amount of pre-roll free time remaining for the channel in seconds. Returns 0 if they are currently not pre-roll free. */
42
+ preroll_free_time?: number | undefined;
43
+ }
44
+ /** A list that contains information related to the channel's ad schedule. */
45
+ export type GetAdScheduleResponseDataList = Array<GetAdScheduleResponseDataItem>;
46
+ export interface GetAdScheduleResponse {
47
+ /** A list that contains information related to the channel's ad schedule. */
48
+ data?: GetAdScheduleResponseDataList | undefined;
49
+ }
50
+ export interface SnoozeNextAdRequest {
51
+ /** Provided _broadcaster_id_ must match the `user_id` in the authentication token. */
52
+ broadcaster_id: string;
53
+ }
54
+ export interface SnoozeNextAdResponseDataItem {
55
+ /** The number of snoozes available for the broadcaster. */
56
+ snooze_count?: number | undefined;
57
+ /** The time when the broadcaster will gain an additional snooze, as a Unix timestamp in seconds. */
58
+ snooze_refresh_at?: number | undefined;
59
+ /** The time of the broadcaster's next scheduled ad, as a Unix timestamp in seconds. */
60
+ next_ad_at?: number | undefined;
61
+ }
62
+ /** A list that contains information about the channel's snoozes and next upcoming ad after successfully snoozing. */
63
+ export type SnoozeNextAdResponseDataList = Array<SnoozeNextAdResponseDataItem>;
64
+ export interface SnoozeNextAdResponse {
65
+ /** A list that contains information about the channel's snoozes and next upcoming ad after successfully snoozing. */
66
+ data?: SnoozeNextAdResponseDataList | undefined;
67
+ }
68
+ export interface StartCommercialRequest {
69
+ /** The ID of the partner or affiliate broadcaster that wants to run the commercial. This ID must match the user ID found in the OAuth token. */
70
+ broadcaster_id: string;
71
+ /** The length of the commercial to run, in seconds. Twitch tries to serve a commercial that's the requested length, but it may be shorter or longer. If you request a commercial that's longer than the channel's maximum ad break length, the API uses the maximum. For most channels, the maximum is 180 seconds. */
72
+ length: number;
73
+ }
74
+ export interface StartCommercialResponseDataItem {
75
+ /** The length of the commercial, in seconds. If you requested a commercial that's longer than the channel's maximum ad break length, this is the maximum length. */
76
+ length?: number | undefined;
77
+ /** A message that indicates whether Twitch was able to serve an ad. */
78
+ message?: string | undefined;
79
+ /** The number of seconds you must wait before running another commercial. */
80
+ retry_after?: number | undefined;
81
+ }
82
+ /** An array that contains a single object with the status of your start commercial request. */
83
+ export type StartCommercialResponseDataList = Array<StartCommercialResponseDataItem>;
84
+ export interface StartCommercialResponse {
85
+ /** An array that contains a single object with the status of your start commercial request. */
86
+ data?: StartCommercialResponseDataList | undefined;
87
+ }
88
+ export type GetAdScheduleError = TwitchOpError;
89
+ /** Get Ad Schedule Returns ad schedule related information, including snooze, when the last ad was run, when the next ad is scheduled, and if the channel is currently in pre-roll free time. > **Note** After an ad starts, a new ad cannot be run until the cooldown period ends. The cooldown is 8 > minutes by default and is never shorter than the ad. 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:ads** scope. The User ID associated with the token must match the _broadcaster_id_ in the query parameter. - An [app access token](https://dev.twitch.tv/docs/authentication.md#app-access-tokens). The application, through prior authorization, must have been granted: - The **channel:read:ads** scope for the user represented by the *broadcaster_id* query parameter. Reference: https://dev.twitch.tv/docs/api/reference/ads/#get-ad-schedule */
90
+ export const getAdSchedule: API.OperationMethod<
91
+ GetAdScheduleRequest,
92
+ GetAdScheduleResponse,
93
+ GetAdScheduleError,
94
+ TwitchOpContext
95
+ > = /*@__PURE__*/ API.make(() => ({
96
+ input: __S(0, __c0, 0) as any as S.Schema<GetAdScheduleRequest>,
97
+ output: __S(3, __c0, 3) as any as S.Schema<GetAdScheduleResponse>,
98
+ errors: [],
99
+ serviceErrors: TwitchServiceErrors,
100
+ protocol: TwitchProtocol,
101
+ retry: Retry.Retry,
102
+ telemetry: TELEMETRY,
103
+ span: "GetAdSchedule",
104
+ }));
105
+
106
+ export type SnoozeNextAdError = TwitchOpError;
107
+ /** Snooze Next Ad If available, pushes back the timestamp of the upcoming automatic mid-roll ad by 5 minutes. This endpoint duplicates the snooze functionality in the creator dashboard's Ads Manager. 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:ads** scope. The user ID associated with the token must match the _broadcaster_id_ in the query parameter. - An [app access token](https://dev.twitch.tv/docs/authentication.md#app-access-tokens). The application, through prior authorization, must have been granted: - The **channel:manage:ads** scope for the user represented by the *broadcaster_id* query parameter. Reference: https://dev.twitch.tv/docs/api/reference/ads/#snooze-next-ad */
108
+ export const snoozeNextAd: API.OperationMethod<
109
+ SnoozeNextAdRequest,
110
+ SnoozeNextAdResponse,
111
+ SnoozeNextAdError,
112
+ TwitchOpContext
113
+ > = /*@__PURE__*/ API.make(() => ({
114
+ input: __S(4, __c1, 0) as any as S.Schema<SnoozeNextAdRequest>,
115
+ output: __S(7, __c1, 3) as any as S.Schema<SnoozeNextAdResponse>,
116
+ errors: [],
117
+ serviceErrors: TwitchServiceErrors,
118
+ protocol: TwitchProtocol,
119
+ retry: Retry.Retry,
120
+ telemetry: TELEMETRY,
121
+ span: "SnoozeNextAd",
122
+ }));
123
+
124
+ export type StartCommercialError = TwitchOpError;
125
+ /** Start Commercial Starts a commercial on the specified channel. > **Note** Only partners and affiliates may run commercials and they must be streaming live at the time. > **Note** Only the broadcaster may start a commercial; the broadcaster's editors and moderators may not start commercials on behalf of the broadcaster. Authorization: Requires one of the following: - A [user access token](https://dev.twitch.tv/docs/authentication.md#user-access-tokens) that includes the **channel:edit:commercial** scope. - An [app access token](https://dev.twitch.tv/docs/authentication.md#app-access-tokens). The application, through prior authorization, must have been granted: - The **channel:edit:commercial** scope for the user represented by the *broadcaster_id* body field. Reference: https://dev.twitch.tv/docs/api/reference/ads/#start-commercial */
126
+ export const startCommercial: API.OperationMethod<
127
+ StartCommercialRequest,
128
+ StartCommercialResponse,
129
+ StartCommercialError,
130
+ TwitchOpContext
131
+ > = /*@__PURE__*/ API.make(() => ({
132
+ input: __S(8, __c2, 0) as any as S.Schema<StartCommercialRequest>,
133
+ output: __S(11, __c2, 3) as any as S.Schema<StartCommercialResponse>,
134
+ errors: [],
135
+ serviceErrors: TwitchServiceErrors,
136
+ protocol: TwitchProtocol,
137
+ retry: Retry.Retry,
138
+ telemetry: TELEMETRY,
139
+ span: "StartCommercial",
140
+ }));
141
+
142
+ // Schema builders: each runs one schema initializer, on that schema's first use.
143
+ function __c0(j: number): any {
144
+ switch (j) {
145
+ case 0:
146
+ return S.suspend(() =>
147
+ S.Struct({
148
+ broadcaster_id: S.String.pipe(T.Query()),
149
+ }).pipe(T.Http({ method: "GET", uri: "/channels/ads", code: 200 })),
150
+ ).annotate({ identifier: "GetAdScheduleRequest" });
151
+ case 1:
152
+ return S.suspend(() =>
153
+ S.Struct({
154
+ snooze_count: S.optional(S.Number),
155
+ snooze_refresh_at: S.optional(S.Number),
156
+ next_ad_at: S.optional(S.Number),
157
+ duration: S.optional(S.Number),
158
+ last_ad_at: S.optional(S.Number),
159
+ preroll_free_time: S.optional(S.Number),
160
+ }),
161
+ ).annotate({ identifier: "GetAdScheduleResponseDataItem" });
162
+ case 2:
163
+ return S.Array(__S(1, __c0, 1));
164
+ case 3:
165
+ return S.suspend(() =>
166
+ S.Struct({
167
+ data: S.optional(__S(2, __c0, 2)),
168
+ }),
169
+ ).annotate({ identifier: "GetAdScheduleResponse" });
170
+ }
171
+ }
172
+ function __c1(j: number): any {
173
+ switch (j) {
174
+ case 0:
175
+ return S.suspend(() =>
176
+ S.Struct({
177
+ broadcaster_id: S.String.pipe(T.Query()),
178
+ }).pipe(T.Http({ method: "POST", uri: "/channels/ads/schedule/snooze", code: 200 })),
179
+ ).annotate({ identifier: "SnoozeNextAdRequest" });
180
+ case 1:
181
+ return S.suspend(() =>
182
+ S.Struct({
183
+ snooze_count: S.optional(S.Number),
184
+ snooze_refresh_at: S.optional(S.Number),
185
+ next_ad_at: S.optional(S.Number),
186
+ }),
187
+ ).annotate({ identifier: "SnoozeNextAdResponseDataItem" });
188
+ case 2:
189
+ return S.Array(__S(5, __c1, 1));
190
+ case 3:
191
+ return S.suspend(() =>
192
+ S.Struct({
193
+ data: S.optional(__S(6, __c1, 2)),
194
+ }),
195
+ ).annotate({ identifier: "SnoozeNextAdResponse" });
196
+ }
197
+ }
198
+ function __c2(j: number): any {
199
+ switch (j) {
200
+ case 0:
201
+ return S.suspend(() =>
202
+ S.Struct({
203
+ broadcaster_id: S.String,
204
+ length: S.Number,
205
+ }).pipe(T.Http({ method: "POST", uri: "/channels/commercial", code: 200 })),
206
+ ).annotate({ identifier: "StartCommercialRequest" });
207
+ case 1:
208
+ return S.suspend(() =>
209
+ S.Struct({
210
+ length: S.optional(S.Number),
211
+ message: S.optional(S.String),
212
+ retry_after: S.optional(S.Number),
213
+ }),
214
+ ).annotate({ identifier: "StartCommercialResponseDataItem" });
215
+ case 2:
216
+ return S.Array(__S(9, __c2, 1));
217
+ case 3:
218
+ return S.suspend(() =>
219
+ S.Struct({
220
+ data: S.optional(__S(10, __c2, 2)),
221
+ }),
222
+ ).annotate({ identifier: "StartCommercialResponse" });
223
+ }
224
+ }
225
+ // Schema table: entry i is schema j of builder f, made on first reach.
226
+ function __S(i: number, f: (j: number) => unknown, j: number): any {
227
+ return (__s[i] ??= __L.at(f, j));
228
+ }
@@ -0,0 +1,253 @@
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: "Analytics",
24
+ propagate: "w3c",
25
+ } as const;
26
+
27
+ export interface GetExtensionAnalyticsRequest {
28
+ /** The extension's client ID. If specified, the response contains a report for the specified extension. If not specified, the response includes a report for each extension that the authenticated user owns. */
29
+ extension_id?: string | undefined;
30
+ /** The type of analytics report to get. Possible values: - `overview_v2` */
31
+ type?: string | undefined;
32
+ /** The reporting window's start date, in RFC3339 format. Set the time portion to zeroes (for example, `2021-10-22T00:00:00Z`). The start date must be on or after January 31, 2018. If you specify an earlier date, the API ignores it and uses January 31, 2018. If you specify a start date, you must specify an end date. If you don't specify a start and end date, the report includes all available data since January 31, 2018. The report contains one row of data for each day in the reporting window. */
33
+ started_at?: string | undefined;
34
+ /** The reporting window's end date, in RFC3339 format. Set the time portion to zeroes (for example, `2021-10-27T00:00:00Z`). The report is inclusive of the end date. Specify an end date only if you provide a start date. Because it can take up to two days for the data to be available, you should specify an end date that's earlier than today minus one to two days. If you specify an end date that's later than yesterday (UTC), the API ignores it and uses yesterday's date. */
35
+ ended_at?: string | undefined;
36
+ /** The maximum number of report URLs to return per page in the response. The minimum page size is 1 URL per page and the maximum is 100 URLs per page. The default is 20. **NOTE**: While you may specify a maximum value of 100, the response will contain at most 20 URLs per page. */
37
+ first?: number | undefined;
38
+ /** 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) This parameter is ignored if the *extension_id* parameter is set, but the cursor must still be valid. */
39
+ after?: string | undefined;
40
+ }
41
+ /** The earliest and latest dates that the report contains data for, in RFC3339 format. These dates can differ from the reporting window that you requested. */
42
+ export interface GetExtensionAnalyticsResponseDataItemDateRange {
43
+ /** The earliest date that the report contains data for. */
44
+ started_at?: string | undefined;
45
+ /** The latest date that the report contains data for. */
46
+ ended_at?: string | undefined;
47
+ }
48
+ export interface GetExtensionAnalyticsResponseDataItem {
49
+ /** An ID that identifies the extension that the report was generated for. */
50
+ extension_id?: string | undefined;
51
+ /** The URL that you use to download the report. The URL is valid for 5 minutes. */
52
+ URL?: string | undefined;
53
+ /** The type of report. */
54
+ type?: string | undefined;
55
+ /** The earliest and latest dates that the report contains data for, in RFC3339 format. These dates can differ from the reporting window that you requested. */
56
+ date_range?: GetExtensionAnalyticsResponseDataItemDateRange | undefined;
57
+ }
58
+ /** A list of reports. The reports are returned in no particular order; however, the data within each report is in ascending order by date (newest first). The report contains one row of data per day of the reporting window; the report contains rows for only those days that the extension was used. The array is empty if there are no reports. Extensions that have no data in the reporting window are left out, so a page may contain fewer than *first* reports, or none, and still contain a cursor. */
59
+ export type GetExtensionAnalyticsResponseDataList = Array<GetExtensionAnalyticsResponseDataItem>;
60
+ /** Contains the information used to page through the list of results. The response doesn't include this object if there are no more pages left to page through or if you specify the *extension_id* query parameter. [Read More](https://dev.twitch.tv/docs/api/guide.md#pagination) */
61
+ export interface GetExtensionAnalyticsResponsePagination {
62
+ /** The cursor used to get the next page of results. Use the cursor to set the request's *after* query parameter. */
63
+ cursor?: string | undefined;
64
+ }
65
+ export interface GetExtensionAnalyticsResponse {
66
+ /** A list of reports. The reports are returned in no particular order; however, the data within each report is in ascending order by date (newest first). The report contains one row of data per day of the reporting window; the report contains rows for only those days that the extension was used. The array is empty if there are no reports. Extensions that have no data in the reporting window are left out, so a page may contain fewer than *first* reports, or none, and still contain a cursor. */
67
+ data: GetExtensionAnalyticsResponseDataList;
68
+ /** Contains the information used to page through the list of results. The response doesn't include this object if there are no more pages left to page through or if you specify the *extension_id* query parameter. [Read More](https://dev.twitch.tv/docs/api/guide.md#pagination) */
69
+ pagination?: GetExtensionAnalyticsResponsePagination | undefined;
70
+ }
71
+ export interface GetGameAnalyticsRequest {
72
+ /** The game's ID, which is numeric. If specified, the response contains a report for the specified game. If not specified, the response includes a report for each of the authenticated user's games. */
73
+ game_id?: string | undefined;
74
+ /** The type of analytics report to get. Possible values: - `overview_v2` */
75
+ type?: string | undefined;
76
+ /** The reporting window's start date, in RFC3339 format. Set the time portion to zeroes (for example, `2021-10-22T00:00:00Z`). If you specify a start date, you must specify an end date. The start date must be within one year of today's date. If you specify an earlier date, the API ignores it and uses a date that's one year prior to today's date. If you don't specify a start and end date, the report includes all available data for the last 365 days from today. The report contains one row of data for each day in the reporting window. */
77
+ started_at?: string | undefined;
78
+ /** The reporting window's end date, in RFC3339 format. Set the time portion to zeroes (for example, `2021-10-22T00:00:00Z`). The report is inclusive of the end date. Specify an end date only if you provide a start date. Because it can take up to two days for the data to be available, you should specify an end date that's earlier than today minus one to two days. If you specify an end date that's later than yesterday (UTC), the API ignores it and uses yesterday's date. */
79
+ ended_at?: string | undefined;
80
+ /** The maximum number of report URLs to return per page in the response. The minimum page size is 1 URL per page and the maximum is 100 URLs per page. The default is 20. **NOTE**: While you may specify a maximum value of 100, the response will contain at most 20 URLs per page. */
81
+ first?: number | undefined;
82
+ /** 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) This parameter is ignored if *game_id* parameter is set, but the cursor must still be valid. */
83
+ after?: string | undefined;
84
+ }
85
+ /** The earliest and latest dates that the report contains data for, in RFC3339 format. These dates can differ from the reporting window that you requested. */
86
+ export type GetGameAnalyticsResponseDataItemDateRange =
87
+ GetExtensionAnalyticsResponseDataItemDateRange;
88
+ export interface GetGameAnalyticsResponseDataItem {
89
+ /** An ID that identifies the game that the report was generated for. */
90
+ game_id?: string | undefined;
91
+ /** The URL that you use to download the report. The URL is valid for 5 minutes. */
92
+ URL?: string | undefined;
93
+ /** The type of report. */
94
+ type?: string | undefined;
95
+ /** The earliest and latest dates that the report contains data for, in RFC3339 format. These dates can differ from the reporting window that you requested. */
96
+ date_range?: GetExtensionAnalyticsResponseDataItemDateRange | undefined;
97
+ }
98
+ /** A list of reports. The reports are returned in no particular order; however, the data within each report is in ascending order by date (newest first). The report contains one row of data per day of the reporting window; the report contains rows for only those days that the game was used. A report is available only if the game was broadcast for at least 5 hours over the reporting period. The array is empty if there are no reports. Games that have no data in the reporting window, or whose analytics aren't available, are left out, so a page may contain fewer than *first* reports, or none, and still contain a cursor. */
99
+ export type GetGameAnalyticsResponseDataList = Array<GetGameAnalyticsResponseDataItem>;
100
+ /** Contains the information used to page through the list of results. The response doesn't include this object if there are no more pages left to page through or if you specify the *game_id* query parameter. [Read More](https://dev.twitch.tv/docs/api/guide.md#pagination) */
101
+ export type GetGameAnalyticsResponsePagination = GetExtensionAnalyticsResponsePagination;
102
+ export interface GetGameAnalyticsResponse {
103
+ /** A list of reports. The reports are returned in no particular order; however, the data within each report is in ascending order by date (newest first). The report contains one row of data per day of the reporting window; the report contains rows for only those days that the game was used. A report is available only if the game was broadcast for at least 5 hours over the reporting period. The array is empty if there are no reports. Games that have no data in the reporting window, or whose analytics aren't available, are left out, so a page may contain fewer than *first* reports, or none, and still contain a cursor. */
104
+ data: GetGameAnalyticsResponseDataList;
105
+ /** Contains the information used to page through the list of results. The response doesn't include this object if there are no more pages left to page through or if you specify the *game_id* query parameter. [Read More](https://dev.twitch.tv/docs/api/guide.md#pagination) */
106
+ pagination?: GetExtensionAnalyticsResponsePagination | undefined;
107
+ }
108
+ export type GetExtensionAnalyticsError = TwitchOpError;
109
+ /** Get Extension Analytics Gets an analytics report for one or more extensions. The response contains the URLs used to download the reports (CSV files). [Learn More](https://dev.twitch.tv/docs/insights.md) Authorization: Requires one of the following: - A [user access token](https://dev.twitch.tv/docs/authentication.md#user-access-tokens) that includes the **analytics:read:extensions** scope. Reference: https://dev.twitch.tv/docs/api/reference/analytics/#get-extension-analytics */
110
+ export const getExtensionAnalytics: API.PaginatedOperationMethod<
111
+ GetExtensionAnalyticsRequest,
112
+ GetExtensionAnalyticsResponse,
113
+ GetExtensionAnalyticsError,
114
+ TwitchOpContext,
115
+ GetExtensionAnalyticsResponseDataItem
116
+ > = /*@__PURE__*/ API.makePaginated(
117
+ () => ({
118
+ input: __S(0, __c0, 0) as any as S.Schema<GetExtensionAnalyticsRequest>,
119
+ output: __S(3, __c0, 3) as any as S.Schema<GetExtensionAnalyticsResponse>,
120
+ errors: [],
121
+ serviceErrors: TwitchServiceErrors,
122
+ protocol: TwitchProtocol,
123
+ retry: Retry.Retry,
124
+ telemetry: TELEMETRY,
125
+ span: "GetExtensionAnalytics",
126
+ pagination: {
127
+ mode: "cursor",
128
+ inputToken: "after",
129
+ outputToken: "pagination.cursor",
130
+ items: "data",
131
+ pageSize: "first",
132
+ } as const,
133
+ }),
134
+ paginateCursor,
135
+ ) as any;
136
+
137
+ export type GetGameAnalyticsError = TwitchOpError;
138
+ /** Get Game Analytics Gets an analytics report for one or more games. The response contains the URLs used to download the reports (CSV files). [Learn more](https://dev.twitch.tv/docs/insights.md) Authorization: Requires one of the following: - A [user access token](https://dev.twitch.tv/docs/authentication.md#user-access-tokens) that includes the **analytics:read:games** scope. Reference: https://dev.twitch.tv/docs/api/reference/analytics/#get-game-analytics */
139
+ export const getGameAnalytics: API.PaginatedOperationMethod<
140
+ GetGameAnalyticsRequest,
141
+ GetGameAnalyticsResponse,
142
+ GetGameAnalyticsError,
143
+ TwitchOpContext,
144
+ GetGameAnalyticsResponseDataItem
145
+ > = /*@__PURE__*/ API.makePaginated(
146
+ () => ({
147
+ input: __S(8, __c2, 0) as any as S.Schema<GetGameAnalyticsRequest>,
148
+ output: __S(11, __c2, 3) as any as S.Schema<GetGameAnalyticsResponse>,
149
+ errors: [],
150
+ serviceErrors: TwitchServiceErrors,
151
+ protocol: TwitchProtocol,
152
+ retry: Retry.Retry,
153
+ telemetry: TELEMETRY,
154
+ span: "GetGameAnalytics",
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
+ extension_id: S.optional(S.String.pipe(T.Query())),
173
+ type: S.optional(S.String.pipe(T.Query())),
174
+ started_at: S.optional(S.String.pipe(T.Query())),
175
+ ended_at: S.optional(S.String.pipe(T.Query())),
176
+ first: S.optional(S.Number.pipe(T.Query())),
177
+ after: S.optional(S.String.pipe(T.Query())),
178
+ }).pipe(T.Http({ method: "GET", uri: "/analytics/extensions", code: 200 })),
179
+ ).annotate({ identifier: "GetExtensionAnalyticsRequest" });
180
+ case 1:
181
+ return S.suspend(() =>
182
+ S.Struct({
183
+ extension_id: S.optional(S.String),
184
+ URL: S.optional(S.String),
185
+ type: S.optional(S.String),
186
+ date_range: S.optional(__S(4, __c1, 0)),
187
+ }),
188
+ ).annotate({ identifier: "GetExtensionAnalyticsResponseDataItem" });
189
+ case 2:
190
+ return S.Array(__S(1, __c0, 1));
191
+ case 3:
192
+ return S.suspend(() =>
193
+ S.Struct({
194
+ data: __S(2, __c0, 2),
195
+ pagination: S.optional(__S(5, __c1, 1)),
196
+ }),
197
+ ).annotate({ identifier: "GetExtensionAnalyticsResponse" });
198
+ }
199
+ }
200
+ function __c1(j: number): any {
201
+ switch (j) {
202
+ case 0:
203
+ return S.suspend(() =>
204
+ S.Struct({
205
+ started_at: S.optional(S.String),
206
+ ended_at: S.optional(S.String),
207
+ }),
208
+ ).annotate({ identifier: "GetExtensionAnalyticsResponseDataItemDateRange" });
209
+ case 1:
210
+ return S.suspend(() =>
211
+ S.Struct({
212
+ cursor: S.optional(S.String),
213
+ }),
214
+ ).annotate({ identifier: "GetExtensionAnalyticsResponsePagination" });
215
+ }
216
+ }
217
+ function __c2(j: number): any {
218
+ switch (j) {
219
+ case 0:
220
+ return S.suspend(() =>
221
+ S.Struct({
222
+ game_id: S.optional(S.String.pipe(T.Query())),
223
+ type: S.optional(S.String.pipe(T.Query())),
224
+ started_at: S.optional(S.String.pipe(T.Query())),
225
+ ended_at: S.optional(S.String.pipe(T.Query())),
226
+ first: S.optional(S.Number.pipe(T.Query())),
227
+ after: S.optional(S.String.pipe(T.Query())),
228
+ }).pipe(T.Http({ method: "GET", uri: "/analytics/games", code: 200 })),
229
+ ).annotate({ identifier: "GetGameAnalyticsRequest" });
230
+ case 1:
231
+ return S.suspend(() =>
232
+ S.Struct({
233
+ game_id: S.optional(S.String),
234
+ URL: S.optional(S.String),
235
+ type: S.optional(S.String),
236
+ date_range: S.optional(__S(4, __c1, 0)),
237
+ }),
238
+ ).annotate({ identifier: "GetGameAnalyticsResponseDataItem" });
239
+ case 2:
240
+ return S.Array(__S(9, __c2, 1));
241
+ case 3:
242
+ return S.suspend(() =>
243
+ S.Struct({
244
+ data: __S(10, __c2, 2),
245
+ pagination: S.optional(__S(5, __c1, 1)),
246
+ }),
247
+ ).annotate({ identifier: "GetGameAnalyticsResponse" });
248
+ }
249
+ }
250
+ // Schema table: entry i is schema j of builder f, made on first reach.
251
+ function __S(i: number, f: (j: number) => unknown, j: number): any {
252
+ return (__s[i] ??= __L.at(f, j));
253
+ }