@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,247 @@
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: "Subscriptions",
24
+ propagate: "w3c",
25
+ } as const;
26
+
27
+ export interface CheckUserSubscriptionRequest {
28
+ /** The ID of a partner or affiliate broadcaster. */
29
+ broadcaster_id: string;
30
+ /** The ID of the user that you're checking to see whether they subscribe to the broadcaster in *broadcaster_id*. If you use a user access token, this ID must match the user ID in the token. */
31
+ user_id: string;
32
+ }
33
+ export interface CheckUserSubscriptionResponseDataItem {
34
+ /** An ID that identifies the broadcaster. */
35
+ broadcaster_id?: string | undefined;
36
+ /** The broadcaster's login name. */
37
+ broadcaster_login?: string | undefined;
38
+ /** The broadcaster's display name. */
39
+ broadcaster_name?: string | undefined;
40
+ /** The ID of the user that gifted the subscription. The object includes this field only if `is_gift` is **true**. For an anonymous gift, the ID is 274598607, which identifies the ananonymousgifter account. */
41
+ gifter_id?: string | undefined;
42
+ /** The gifter's login name. The object includes this field only if `is_gift` is **true**. */
43
+ gifter_login?: string | undefined;
44
+ /** The gifter's display name. The object includes this field only if `is_gift` is **true**. */
45
+ gifter_name?: string | undefined;
46
+ /** A Boolean value that determines whether the subscription is a gift subscription. Is **true** if the subscription was gifted. */
47
+ is_gift?: boolean | undefined;
48
+ /** The type of subscription. Possible values: - `1000`: Tier 1 - `2000`: Tier 2 - `3000`: Tier 3 */
49
+ tier?: string | undefined;
50
+ }
51
+ /** A list that contains a single object with information about the user's subscription. */
52
+ export type CheckUserSubscriptionResponseDataList = Array<CheckUserSubscriptionResponseDataItem>;
53
+ export interface CheckUserSubscriptionResponse {
54
+ /** A list that contains a single object with information about the user's subscription. */
55
+ data?: CheckUserSubscriptionResponseDataList | undefined;
56
+ }
57
+ export type GetBroadcasterSubscriptionsRequestUserIdList = Array<string>;
58
+ export interface GetBroadcasterSubscriptionsRequest {
59
+ /** The broadcaster's ID. This ID must match the user ID in the access token. */
60
+ broadcaster_id: string;
61
+ /** Filters the list to include only the specified subscribers. To specify more than one subscriber, include this parameter for each subscriber. For example, '&user_id=1234&user_id=5678'. You may specify a maximum of 100 subscribers. */
62
+ user_id?: GetBroadcasterSubscriptionsRequestUserIdList | undefined;
63
+ /** The maximum number of items to return per page in the response. The minimum page size is 1 item per page and the maximum is 100 items per page. The default is 20. */
64
+ first?: number | undefined;
65
+ /** The cursor used to get the next page of results. Do not specify if you set the *user_id* query parameter. The **Pagination** object in the response contains the cursor's value. [Read More](https://dev.twitch.tv/docs/api/guide.md#pagination) */
66
+ after?: string | undefined;
67
+ /** The cursor used to get the previous page of results. Do not specify if you set the *user_id* query parameter. The **Pagination** object in the response contains the cursor's value. [Read More](https://dev.twitch.tv/docs/api/guide.md#pagination) */
68
+ before?: string | undefined;
69
+ }
70
+ export interface GetBroadcasterSubscriptionsResponseDataItem {
71
+ /** An ID that identifies the broadcaster. */
72
+ broadcaster_id?: string | undefined;
73
+ /** The broadcaster's login name. */
74
+ broadcaster_login?: string | undefined;
75
+ /** The broadcaster's display name. */
76
+ broadcaster_name?: string | undefined;
77
+ /** The ID of the user that gifted the subscription to the user. Is an empty string if `is_gift` is **false**. For an anonymous gift, the ID is 274598607, which identifies the ananonymousgifter account. */
78
+ gifter_id?: string | undefined;
79
+ /** The gifter's login name. Is an empty string if `is_gift` is **false**. */
80
+ gifter_login?: string | undefined;
81
+ /** The gifter's display name. Is an empty string if `is_gift` is **false**. */
82
+ gifter_name?: string | undefined;
83
+ /** A Boolean value that determines whether the subscription is a gift subscription. Is **true** if the subscription was gifted. */
84
+ is_gift?: boolean | undefined;
85
+ /** The name of the subscription. */
86
+ plan_name?: string | undefined;
87
+ /** The type of subscription. Possible values: - `1000`: Tier 1 - `2000`: Tier 2 - `3000`: Tier 3 */
88
+ tier?: string | undefined;
89
+ /** An ID that identifies the subscribing user. */
90
+ user_id?: string | undefined;
91
+ /** The user's display name. */
92
+ user_name?: string | undefined;
93
+ /** The user's login name. */
94
+ user_login?: string | undefined;
95
+ }
96
+ /** The list of users that subscribe to the broadcaster. The list is empty if the broadcaster has no subscribers. Some subscriptions aren't included, such as those from users whose accounts no longer exist, so a page may contain fewer than *first* items, or none, and still contain a cursor. */
97
+ export type GetBroadcasterSubscriptionsResponseDataList =
98
+ Array<GetBroadcasterSubscriptionsResponseDataItem>;
99
+ /** Contains the information used to page through the list of results. The object contains a cursor even on the last page of subscriptions; using that cursor returns no subscriptions and an empty object. The response doesn't include this object if you specify the *user_id* query parameter. [Read More](https://dev.twitch.tv/docs/api/guide.md#pagination) */
100
+ export interface GetBroadcasterSubscriptionsResponsePagination {
101
+ /** The cursor used to get the next or previous page of results. Use the cursor to set the request's *after* or *before* query parameter depending on whether you're paging forwards or backwards. */
102
+ cursor?: string | undefined;
103
+ }
104
+ export interface GetBroadcasterSubscriptionsResponse {
105
+ /** The list of users that subscribe to the broadcaster. The list is empty if the broadcaster has no subscribers. Some subscriptions aren't included, such as those from users whose accounts no longer exist, so a page may contain fewer than *first* items, or none, and still contain a cursor. */
106
+ data: GetBroadcasterSubscriptionsResponseDataList;
107
+ /** Contains the information used to page through the list of results. The object contains a cursor even on the last page of subscriptions; using that cursor returns no subscriptions and an empty object. The response doesn't include this object if you specify the *user_id* query parameter. [Read More](https://dev.twitch.tv/docs/api/guide.md#pagination) */
108
+ pagination?: GetBroadcasterSubscriptionsResponsePagination | undefined;
109
+ /** The current number of subscriber points earned by this broadcaster. Points are based on the subscription tier of each user that subscribes to this broadcaster. For example, a Tier 1 subscription is worth 1 point, Tier 2 is worth 2 points, and Tier 3 is worth 6 points. The number of points determines the number of emote slots that are unlocked for the broadcaster (see [Subscriber Emote Slots](https://help.twitch.tv/s/article/subscriber-emote-guide#emoteslots)). The response doesn't include this field if you specify the *user_id* query parameter. */
110
+ points?: number | undefined;
111
+ /** The total number of users that subscribe to this broadcaster. The response doesn't include this field if you specify the *user_id* query parameter. */
112
+ total?: number | undefined;
113
+ }
114
+ export type CheckUserSubscriptionError = TwitchOpError;
115
+ /** Check User Subscription Checks whether the user subscribes to the broadcaster's channel. Authorization: Requires one of the following: - A [user access token](https://dev.twitch.tv/docs/authentication.md#user-access-tokens) that includes the **user:read:subscriptions** 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 **user:read:subscriptions** scope for the user represented by the *user_id* query parameter. Reference: https://dev.twitch.tv/docs/api/reference/subscriptions/#check-user-subscription */
116
+ export const checkUserSubscription: API.OperationMethod<
117
+ CheckUserSubscriptionRequest,
118
+ CheckUserSubscriptionResponse,
119
+ CheckUserSubscriptionError,
120
+ TwitchOpContext
121
+ > = /*@__PURE__*/ API.make(() => ({
122
+ input: __S(0, __c0, 0) as any as S.Schema<CheckUserSubscriptionRequest>,
123
+ output: __S(3, __c0, 3) as any as S.Schema<CheckUserSubscriptionResponse>,
124
+ errors: [],
125
+ serviceErrors: TwitchServiceErrors,
126
+ protocol: TwitchProtocol,
127
+ retry: Retry.Retry,
128
+ telemetry: TELEMETRY,
129
+ span: "CheckUserSubscription",
130
+ }));
131
+
132
+ export type GetBroadcasterSubscriptionsError = TwitchOpError;
133
+ /** Get Broadcaster Subscriptions Gets a list of users that subscribe to the specified 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:read:subscriptions** scope. - An [app access token](https://dev.twitch.tv/docs/authentication.md#app-access-tokens). Only accessible to Twitch Extensions. The broadcaster must have granted the **channel:read:subscriptions** scope from within the Twitch Extensions manager. Reference: https://dev.twitch.tv/docs/api/reference/subscriptions/#get-broadcaster-subscriptions */
134
+ export const getBroadcasterSubscriptions: API.PaginatedOperationMethod<
135
+ GetBroadcasterSubscriptionsRequest,
136
+ GetBroadcasterSubscriptionsResponse,
137
+ GetBroadcasterSubscriptionsError,
138
+ TwitchOpContext,
139
+ GetBroadcasterSubscriptionsResponseDataItem
140
+ > = /*@__PURE__*/ API.makePaginated(
141
+ () => ({
142
+ input: __S(9, __c1, 1) as any as S.Schema<GetBroadcasterSubscriptionsRequest>,
143
+ output: __S(13, __c1, 5) as any as S.Schema<GetBroadcasterSubscriptionsResponse>,
144
+ errors: [],
145
+ serviceErrors: TwitchServiceErrors,
146
+ protocol: TwitchProtocol,
147
+ retry: Retry.Retry,
148
+ telemetry: TELEMETRY,
149
+ span: "GetBroadcasterSubscriptions",
150
+ pagination: {
151
+ mode: "cursor",
152
+ inputToken: "after",
153
+ outputToken: "pagination.cursor",
154
+ items: "data",
155
+ pageSize: "first",
156
+ } as const,
157
+ }),
158
+ paginateCursor,
159
+ ) as any;
160
+
161
+ // Schema builders: each runs one schema initializer, on that schema's first use.
162
+ function __c0(j: number): any {
163
+ switch (j) {
164
+ case 0:
165
+ return S.suspend(() =>
166
+ S.Struct({
167
+ broadcaster_id: S.String.pipe(T.Query()),
168
+ user_id: S.String.pipe(T.Query()),
169
+ }).pipe(T.Http({ method: "GET", uri: "/subscriptions/user", code: 200 })),
170
+ ).annotate({ identifier: "CheckUserSubscriptionRequest" });
171
+ case 1:
172
+ return S.suspend(() =>
173
+ S.Struct({
174
+ broadcaster_id: S.optional(S.String),
175
+ broadcaster_login: S.optional(S.String),
176
+ broadcaster_name: S.optional(S.String),
177
+ gifter_id: S.optional(S.String),
178
+ gifter_login: S.optional(S.String),
179
+ gifter_name: S.optional(S.String),
180
+ is_gift: S.optional(S.Boolean),
181
+ tier: S.optional(S.String),
182
+ }),
183
+ ).annotate({ identifier: "CheckUserSubscriptionResponseDataItem" });
184
+ case 2:
185
+ return S.Array(__S(1, __c0, 1));
186
+ case 3:
187
+ return S.suspend(() =>
188
+ S.Struct({
189
+ data: S.optional(__S(2, __c0, 2)),
190
+ }),
191
+ ).annotate({ identifier: "CheckUserSubscriptionResponse" });
192
+ }
193
+ }
194
+ function __c1(j: number): any {
195
+ switch (j) {
196
+ case 0:
197
+ return S.Array(S.String);
198
+ case 1:
199
+ return S.suspend(() =>
200
+ S.Struct({
201
+ broadcaster_id: S.String.pipe(T.Query()),
202
+ user_id: S.optional(__S(8, __c1, 0).pipe(T.Query())),
203
+ first: S.optional(S.Number.pipe(T.Query())),
204
+ after: S.optional(S.String.pipe(T.Query())),
205
+ before: S.optional(S.String.pipe(T.Query())),
206
+ }).pipe(T.Http({ method: "GET", uri: "/subscriptions", code: 200 })),
207
+ ).annotate({ identifier: "GetBroadcasterSubscriptionsRequest" });
208
+ case 2:
209
+ return S.suspend(() =>
210
+ S.Struct({
211
+ broadcaster_id: S.optional(S.String),
212
+ broadcaster_login: S.optional(S.String),
213
+ broadcaster_name: S.optional(S.String),
214
+ gifter_id: S.optional(S.String),
215
+ gifter_login: S.optional(S.String),
216
+ gifter_name: S.optional(S.String),
217
+ is_gift: S.optional(S.Boolean),
218
+ plan_name: S.optional(S.String),
219
+ tier: S.optional(S.String),
220
+ user_id: S.optional(S.String),
221
+ user_name: S.optional(S.String),
222
+ user_login: S.optional(S.String),
223
+ }),
224
+ ).annotate({ identifier: "GetBroadcasterSubscriptionsResponseDataItem" });
225
+ case 3:
226
+ return S.Array(__S(10, __c1, 2));
227
+ case 4:
228
+ return S.suspend(() =>
229
+ S.Struct({
230
+ cursor: S.optional(S.String),
231
+ }),
232
+ ).annotate({ identifier: "GetBroadcasterSubscriptionsResponsePagination" });
233
+ case 5:
234
+ return S.suspend(() =>
235
+ S.Struct({
236
+ data: __S(11, __c1, 3),
237
+ pagination: S.optional(__S(12, __c1, 4)),
238
+ points: S.optional(S.Number),
239
+ total: S.optional(S.Number),
240
+ }),
241
+ ).annotate({ identifier: "GetBroadcasterSubscriptionsResponse" });
242
+ }
243
+ }
244
+ // Schema table: entry i is schema j of builder f, made on first reach.
245
+ function __S(i: number, f: (j: number) => unknown, j: number): any {
246
+ return (__s[i] ??= __L.at(f, j));
247
+ }
@@ -0,0 +1,225 @@
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: "Teams",
23
+ propagate: "w3c",
24
+ } as const;
25
+
26
+ export interface GetChannelTeamsRequest {
27
+ /** The ID of the broadcaster whose teams you want to get. */
28
+ broadcaster_id: string;
29
+ }
30
+ export interface GetChannelTeamsResponseDataItem {
31
+ /** An ID that identifies the broadcaster. */
32
+ broadcaster_id?: string | undefined;
33
+ /** The broadcaster's login name. */
34
+ broadcaster_login?: string | undefined;
35
+ /** The broadcaster's display name. */
36
+ broadcaster_name?: string | undefined;
37
+ /** A URL to the team's background image. This field is **null** if the team does not have a background image set. */
38
+ background_image_url?: string | null | undefined;
39
+ /** A URL to the team's banner. This field is **null** if the team does not have a banner set. */
40
+ banner?: string | null | undefined;
41
+ /** The UTC date and time (in RFC3339 format) of when the team was created. */
42
+ created_at?: string | null | undefined;
43
+ /** The UTC date and time (in RFC3339 format) of the last time the team was updated. */
44
+ updated_at?: string | null | undefined;
45
+ /** The team's description. The description may contain formatting such as Markdown, HTML, newline (\n) characters, etc. */
46
+ info?: string | undefined;
47
+ /** A URL to a thumbnail image of the team's logo. This field is **null** if the team does not have a logo set. */
48
+ thumbnail_url?: string | null | undefined;
49
+ /** The team's name. */
50
+ team_name?: string | undefined;
51
+ /** The team's display name. */
52
+ team_display_name?: string | undefined;
53
+ /** An ID that identifies the team. */
54
+ id?: string | undefined;
55
+ }
56
+ /** The list of teams that the broadcaster is a member of. Returns an empty array if the broadcaster is not a member of a team. */
57
+ export type GetChannelTeamsResponseDataList = Array<GetChannelTeamsResponseDataItem>;
58
+ export interface GetChannelTeamsResponse {
59
+ /** The list of teams that the broadcaster is a member of. Returns an empty array if the broadcaster is not a member of a team. */
60
+ data?: GetChannelTeamsResponseDataList | undefined;
61
+ }
62
+ export interface GetTeamsRequest {
63
+ /** The name of the team to get. This parameter and the *id* parameter are mutually exclusive; you must specify the team's name or ID but not both. */
64
+ name?: string | undefined;
65
+ /** The ID of the team to get. This parameter and the *name* parameter are mutually exclusive; you must specify the team's name or ID but not both. */
66
+ id?: string | undefined;
67
+ }
68
+ export interface GetTeamsResponseDataItemUsersItem {
69
+ /** An ID that identifies the team member. */
70
+ user_id?: string | undefined;
71
+ /** The team member's login name. */
72
+ user_login?: string | undefined;
73
+ /** The team member's display name. */
74
+ user_name?: string | undefined;
75
+ }
76
+ /** The list of team members. This field is omitted if the team has no members. */
77
+ export type GetTeamsResponseDataItemUsersList = Array<GetTeamsResponseDataItemUsersItem>;
78
+ export interface GetTeamsResponseDataItem {
79
+ /** The list of team members. This field is omitted if the team has no members. */
80
+ users?: GetTeamsResponseDataItemUsersList | undefined;
81
+ /** A URL to the team's background image. This field is **null** if the team does not have a background image set. */
82
+ background_image_url?: string | null | undefined;
83
+ /** A URL to the team's banner. This field is **null** if the team does not have a banner image set. */
84
+ banner?: string | null | undefined;
85
+ /** The UTC date and time (in RFC3339 format) of when the team was created. */
86
+ created_at?: string | null | undefined;
87
+ /** The UTC date and time (in RFC3339 format) of the last time the team was updated. */
88
+ updated_at?: string | null | undefined;
89
+ /** The team's description. The description may contain formatting such as Markdown, HTML, newline (\n) characters, etc. */
90
+ info?: string | undefined;
91
+ /** A URL to a thumbnail image of the team's logo. This field is **null** if the team does not have a logo set. */
92
+ thumbnail_url?: string | null | undefined;
93
+ /** The team's name. */
94
+ team_name?: string | undefined;
95
+ /** The team's display name. */
96
+ team_display_name?: string | undefined;
97
+ /** An ID that identifies the team. */
98
+ id?: string | undefined;
99
+ }
100
+ /** A list that contains the single team that you requested. */
101
+ export type GetTeamsResponseDataList = Array<GetTeamsResponseDataItem>;
102
+ export interface GetTeamsResponse {
103
+ /** A list that contains the single team that you requested. */
104
+ data?: GetTeamsResponseDataList | undefined;
105
+ }
106
+ export type GetChannelTeamsError = TwitchOpError;
107
+ /** Get Channel Teams Gets the list of Twitch teams that the broadcaster is a member of. Authorization: Requires one of the following: - A [user access token](https://dev.twitch.tv/docs/authentication.md#user-access-tokens). - An [app access token](https://dev.twitch.tv/docs/authentication.md#app-access-tokens). Reference: https://dev.twitch.tv/docs/api/reference/teams/#get-channel-teams */
108
+ export const getChannelTeams: API.OperationMethod<
109
+ GetChannelTeamsRequest,
110
+ GetChannelTeamsResponse,
111
+ GetChannelTeamsError,
112
+ TwitchOpContext
113
+ > = /*@__PURE__*/ API.make(() => ({
114
+ input: __S(0, __c0, 0) as any as S.Schema<GetChannelTeamsRequest>,
115
+ output: __S(3, __c0, 3) as any as S.Schema<GetChannelTeamsResponse>,
116
+ errors: [],
117
+ serviceErrors: TwitchServiceErrors,
118
+ protocol: TwitchProtocol,
119
+ retry: Retry.Retry,
120
+ telemetry: TELEMETRY,
121
+ span: "GetChannelTeams",
122
+ }));
123
+
124
+ export type GetTeamsError = TwitchOpError;
125
+ /** Get Teams Gets information about the specified Twitch team. [Read More](https://help.twitch.tv/s/article/twitch-teams) You must specify exactly one of the *name* and *id* query parameters; the request fails if you specify none of them or more than one. Authorization: Requires one of the following: - A [user access token](https://dev.twitch.tv/docs/authentication.md#user-access-tokens). - An [app access token](https://dev.twitch.tv/docs/authentication.md#app-access-tokens). Reference: https://dev.twitch.tv/docs/api/reference/teams/#get-teams */
126
+ export const getTeams: API.OperationMethod<
127
+ GetTeamsRequest,
128
+ GetTeamsResponse,
129
+ GetTeamsError,
130
+ TwitchOpContext
131
+ > = /*@__PURE__*/ API.make(() => ({
132
+ input: __S(8, __c1, 0) as any as S.Schema<GetTeamsRequest>,
133
+ output: __S(13, __c1, 5) as any as S.Schema<GetTeamsResponse>,
134
+ errors: [],
135
+ serviceErrors: TwitchServiceErrors,
136
+ protocol: TwitchProtocol,
137
+ retry: Retry.Retry,
138
+ telemetry: TELEMETRY,
139
+ span: "GetTeams",
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: "/teams/channel", code: 200 })),
150
+ ).annotate({ identifier: "GetChannelTeamsRequest" });
151
+ case 1:
152
+ return S.suspend(() =>
153
+ S.Struct({
154
+ broadcaster_id: S.optional(S.String),
155
+ broadcaster_login: S.optional(S.String),
156
+ broadcaster_name: S.optional(S.String),
157
+ background_image_url: S.optional(S.NullOr(S.String)),
158
+ banner: S.optional(S.NullOr(S.String)),
159
+ created_at: S.optional(S.NullOr(S.String)),
160
+ updated_at: S.optional(S.NullOr(S.String)),
161
+ info: S.optional(S.String),
162
+ thumbnail_url: S.optional(S.NullOr(S.String)),
163
+ team_name: S.optional(S.String),
164
+ team_display_name: S.optional(S.String),
165
+ id: S.optional(S.String),
166
+ }),
167
+ ).annotate({ identifier: "GetChannelTeamsResponseDataItem" });
168
+ case 2:
169
+ return S.Array(__S(1, __c0, 1));
170
+ case 3:
171
+ return S.suspend(() =>
172
+ S.Struct({
173
+ data: S.optional(__S(2, __c0, 2)),
174
+ }),
175
+ ).annotate({ identifier: "GetChannelTeamsResponse" });
176
+ }
177
+ }
178
+ function __c1(j: number): any {
179
+ switch (j) {
180
+ case 0:
181
+ return S.suspend(() =>
182
+ S.Struct({
183
+ name: S.optional(S.String.pipe(T.Query())),
184
+ id: S.optional(S.String.pipe(T.Query())),
185
+ }).pipe(T.Http({ method: "GET", uri: "/teams", code: 200 })),
186
+ ).annotate({ identifier: "GetTeamsRequest" });
187
+ case 1:
188
+ return S.suspend(() =>
189
+ S.Struct({
190
+ user_id: S.optional(S.String),
191
+ user_login: S.optional(S.String),
192
+ user_name: S.optional(S.String),
193
+ }),
194
+ ).annotate({ identifier: "GetTeamsResponseDataItemUsersItem" });
195
+ case 2:
196
+ return S.Array(__S(9, __c1, 1));
197
+ case 3:
198
+ return S.suspend(() =>
199
+ S.Struct({
200
+ users: S.optional(__S(10, __c1, 2)),
201
+ background_image_url: S.optional(S.NullOr(S.String)),
202
+ banner: S.optional(S.NullOr(S.String)),
203
+ created_at: S.optional(S.NullOr(S.String)),
204
+ updated_at: S.optional(S.NullOr(S.String)),
205
+ info: S.optional(S.String),
206
+ thumbnail_url: S.optional(S.NullOr(S.String)),
207
+ team_name: S.optional(S.String),
208
+ team_display_name: S.optional(S.String),
209
+ id: S.optional(S.String),
210
+ }),
211
+ ).annotate({ identifier: "GetTeamsResponseDataItem" });
212
+ case 4:
213
+ return S.Array(__S(11, __c1, 3));
214
+ case 5:
215
+ return S.suspend(() =>
216
+ S.Struct({
217
+ data: S.optional(__S(12, __c1, 4)),
218
+ }),
219
+ ).annotate({ identifier: "GetTeamsResponse" });
220
+ }
221
+ }
222
+ // Schema table: entry i is schema j of builder f, made on first reach.
223
+ function __S(i: number, f: (j: number) => unknown, j: number): any {
224
+ return (__s[i] ??= __L.at(f, j));
225
+ }